@passioncode-ai/fabric-agent-adapter 0.22.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/README.md +1 -1
  3. package/package.json +1 -1
  4. package/plugins/fabric-agent-adapter/.claude-plugin/plugin.json +1 -1
  5. package/plugins/fabric-agent-adapter/skills/adapting-projects-to-fabric/SKILL.md +3 -3
  6. package/plugins/fabric-agent-adapter/skills/adapting-projects-to-fabric/scripts/adapt_project.py +2 -2
  7. package/plugins/fabric-agent-adapter/skills/building-fabric-services/SKILL.md +2 -2
  8. package/plugins/fabric-agent-adapter/skills/building-fabric-services/references/delegation.md +10 -7
  9. package/plugins/fabric-agent-adapter/skills/building-fabric-services/references/estate-record.md +32 -15
  10. package/plugins/fabric-agent-adapter/skills/building-fabric-services/references/lifecycle.md +46 -14
  11. package/plugins/fabric-agent-adapter/skills/building-fabric-services/references/protocol.md +4 -2
  12. package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/check_service.py +5 -2
  13. package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric-delegation.mjs +35 -20
  14. package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric-estate.mjs +77 -9
  15. package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric-service.mjs +167 -36
  16. package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric_delegation.py +53 -19
  17. package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric_estate.py +107 -16
  18. package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric_service.py +270 -49
  19. package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/sample_service.py +8 -2
  20. package/plugins/fabric-agent-adapter/skills/creating-fabric-agents/SKILL.md +3 -3
  21. package/plugins/fabric-agent-adapter/skills/working-with-fabric/SKILL.md +1 -1
  22. package/plugins/fabric-agent-adapter/skills/working-with-fabric/scripts/fabric_session.py +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,57 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.23.0 - 2026-10-13
4
+
5
+ The contract pin moves from `b291bf0` (DEC-0055) to contract `main` `fe55fc6`, and both kits follow every rule in that
6
+ range that touches what they already do (FAA-32; the contract's hand-over of 2026-10-12, its CT-18 row). `b291bf0`
7
+ joins the supported revisions. What the range adds beyond that is its own row: FAA-33…37.
8
+
9
+ ### Changed
10
+
11
+ - **The supervisor marker comes as an argument too** (DEC-0057, CT-01, P4-01): `supervisor_marker` /
12
+ `supervisorMarker` read `FABRIC_SERVICE_SUPERVISOR=<manager>` and `--fabric-supervisor <manager>` /
13
+ `--fabric-supervisor=<manager>` (after the executable, before `--`; a bare flag consumes no `--…` token), with `node`
14
+ among the managers. Markers that disagree — the two forms, the argument twice, a bare or empty argument beside the
15
+ variable — exit 75 at once, before the lock, naming both. `supervised()` and `supervised_by_launchd()` take the
16
+ marker; `hold_single_instance` / `holdSingleInstance` take `env` and `argv`. A holder whose pid cannot be read is
17
+ named unknown (`FAC-SEM-078`).
18
+ - **Writers:** `task_xml` / `taskXml` write `--fabric-supervisor task-scheduler` in the task's `Arguments`, before any
19
+ `--` (a task's action carries no environment, so a Task Scheduler copy now waits like one under launchd);
20
+ `systemd_unit` / `systemdUnit` set the variable unconditionally; every writer refuses a marker in the program
21
+ arguments. `add_supervisor_argument(parser)` lets a service's argparse accept the flag; the sample service uses it.
22
+ - **DL-HUBKEY** (DEC-0060): `hub_key_certified` / `hubKeyCertified(record, kid, x, at, applied, extra)` answer the
23
+ contract's verdict — `{certified, machine, revision}` or `{certified: false, fault, detail}` — instead of a boolean.
24
+ A revision outside its window, unreadable, lower than the applied one or forking it is the trust source's fault
25
+ (`issuer-unavailable`: `estate-outside-window`, `estate-unreadable`, `estate-rolled-back`, `estate-forked`); a `kid`
26
+ on two machines, a missing `x` and a numeric `kid` never certify; revocation refs compare exactly. The verifiers
27
+ take `estate_applied` / `estateApplied` and `estate_revocations` / `estateRevocations`; in the Node kit only an
28
+ absent `estate` skips the check (`null` is an unreadable source). Every verifier refuses a clock that is not a number
29
+ of seconds `unknown-state` `no-clock` before row 1.
30
+ - **The estate record** (DEC-0063, DEC-0066): `verify_estate_record` / `verifyEstateRecord` admit `issuedAt` up to 60 s
31
+ ahead (`CLOCK_SKEW_SECONDS`); the signing passkey must be under a `sign.<domain>` RP (`wrong-rp`) and its origins
32
+ within it (`wrong-origin`); the record's rules add `FAC-SEM-092`.
33
+ - **The Windows token-file reader** (DEC-0057, `FAC-SEM-079`): `windows_token_acl_problem` /
34
+ `windowsTokenAclProblem` decide over the file's flags, owner and ACEs `{type, sid, mask}`: an object or callback ACE
35
+ is refused, an allow with an empty mask and every deny grant nothing, SIDs compare case-insensitively, anything
36
+ unreadable is refused. The Python kit reads the ACEs from SDDL (`acl_from_sddl`), the Node kit through .NET's raw
37
+ descriptor with the mask read unsigned. `windows_acl` / `windowsAcl` now answer ACEs; `token_acl_problem` /
38
+ `tokenAclProblem` are replaced by `token_file_problem` / `tokenFileProblem`.
39
+ - **The descriptor** (DEC-0057 item 5): `label` and `plist` are refused beside `systemd` and `task-scheduler`; a
40
+ `localPath` starting `//` or `/\` is a share and refused.
41
+
42
+ ### Evidence
43
+
44
+ - Vendored from the contract at `fe55fc6` and re-answered by its own functions (`test/fixtures/contract/vendor_vectors.mjs`):
45
+ `hub-key-vectors.json` (51 cases, 14 verifier answers; the hub seeds dropped), `supervisor-vectors.json` (22 marker
46
+ cases, 11 `FAC-SEM-078` records), `windows-token-vectors.json` (30 cases), `descriptor-negatives.json` (DEC-0057's
47
+ seven); `estate-vectors.json` regenerated (49 verify cases). Both kits answer every case as the contract does.
48
+ - The kits' own starts against a held lock — by hand, the node, a task, an unknown holder, three conflicts — are
49
+ recorded and read by a port of `lockOutcomeRules` that itself reads the contract's 11 records as it does.
50
+ - The sample service, started with `--fabric-supervisor=node`, serves a well-known document, usage report and events
51
+ page valid under the `fe55fc6` schemas; the descriptors the kit writes under every manager are valid too.
52
+ - 34 planted defects, all caught.
53
+ - The `--fabric-supervisor` scenario eval (`supervised-by-argument`) was written before the prose.
54
+
3
55
  ## 0.22.0 - 2026-10-12
4
56
 
5
57
  `working-with-fabric`, the fourth skill, the plugin's session hooks, and coding agents as participants of Fabric's
package/README.md CHANGED
@@ -235,7 +235,7 @@ Scaffolding is non-destructive by default. It writes only the paths declared in
235
235
  The default pin for new bundles is [`fabric-contract.lock.json`](fabric-contract.lock.json):
236
236
 
237
237
  - version: `0.1.0`
238
- - commit: `b291bf09e0a9f9fd3c16cf540832cd021203b7d1`
238
+ - commit: `fe55fc67cba1a9e34a736da7d148d4fe2a8fbfa0`
239
239
 
240
240
  Every other mention of the default contract revision — this section, the skills' metadata, the
241
241
  skill card, `adapt_project.py` — must equal it; `python3 test/validate.py` fails a tree
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@passioncode-ai/fabric-agent-adapter",
3
- "version": "0.22.0",
3
+ "version": "0.23.0",
4
4
  "description": "Create Fabric-compatible agents, run them as always-alive local services with dashboards (fabric-service/0.1), and adapt existing projects to the Fabric Agent Contract. This package is the installer CLI.",
5
5
  "scripts": {
6
6
  "test": "python3 test/validate.py && python3 -m unittest discover -s test -q && node --test 'test/*.test.mjs'"
@@ -3,7 +3,7 @@
3
3
  "name": "fabric-agent-adapter",
4
4
  "displayName": "Fabric Agent Adapter",
5
5
  "description": "Create new Fabric-compatible agents, build them as always-alive local services with dashboards (fabric-service/0.1), and adapt existing projects to the Fabric Agent Contract through evidence-backed MCP, A2A, or local-runner provider bundles; and teach a coding agent to work in a project through Fabric (fabric-mcp, fabric_whoami, claim and release), with Claude Code session hooks.",
6
- "version": "0.22.0",
6
+ "version": "0.23.0",
7
7
  "author": {
8
8
  "name": "PassionCode.ai",
9
9
  "url": "https://passioncode.ai/"
@@ -5,9 +5,9 @@ license: AGPL-3.0-only OR LicenseRef-PassionCode-Commercial
5
5
  compatibility: Requires filesystem access and Python 3.9+. Exact schema checks additionally need git, Node.js, pnpm, and the pinned fabric-agent-contract checkout (a public repository). Works without those tools in an explicitly degraded structural-check mode.
6
6
  metadata:
7
7
  author: PassionCode.ai
8
- version: "0.22.0"
8
+ version: "0.23.0"
9
9
  contract-version: "0.1.0"
10
- contract-commit: "b291bf09e0a9f9fd3c16cf540832cd021203b7d1"
10
+ contract-commit: "fe55fc67cba1a9e34a736da7d148d4fe2a8fbfa0"
11
11
  ---
12
12
 
13
13
  # Adapting projects to Fabric
@@ -70,7 +70,7 @@ Use exactly:
70
70
 
71
71
  - contract version `0.1.0`;
72
72
  - repository `https://github.com/passioncode-ai/fabric-agent-contract`;
73
- - commit `b291bf09e0a9f9fd3c16cf540832cd021203b7d1`.
73
+ - commit `fe55fc67cba1a9e34a736da7d148d4fe2a8fbfa0`.
74
74
 
75
75
  This is the default for new bundles. When checking an issued legacy bundle, preserve its
76
76
  explicit supported lock and use that exact clean checkout. Never silently upgrade or
@@ -21,10 +21,10 @@ import fabric_secrets as _secrets # noqa: E402 - the contract's credential dete
21
21
 
22
22
  CONTRACT_VERSION = "0.1.0"
23
23
  CONTRACT_REPOSITORY = "https://github.com/passioncode-ai/fabric-agent-contract"
24
- CONTRACT_COMMIT = "b291bf09e0a9f9fd3c16cf540832cd021203b7d1"
24
+ CONTRACT_COMMIT = "fe55fc67cba1a9e34a736da7d148d4fe2a8fbfa0"
25
25
  # #region supported-contract-revisions — docs: README.md#contract-pin
26
26
  # Only this declaration may name a legacy revision in live files.
27
- SUPPORTED_CONTRACT_COMMITS = (CONTRACT_COMMIT, "0cacd08b0e95b6abf131eae1206b60792138bc3c", "2eb91c00e852d9c31d804310d38fad91589fcbac", "8e49fbd5fbbf230e32c1969cd24ac3c22422f0a5", "a83bec6b47776af688402c18efec507143061f68", "52da526d7cc1e063d74c5b520dbc03d0ace15246", "78b2da018d2c4bd9ac1bde1dc3b7f1a110a175f5", "623bf61358c339cb10297807b3f024b5d9f1f327", "23f9fda4c05f8a3852246ee98d4f2adf74ed0875", "9091d3d6606b0c4b5591a38c3674356a01fd7f55", "df55c8c54a23251342a7ee57ba95642b7eb39e61", "2ce392291c6668598d12cd38327e24696b5ca15c")
27
+ SUPPORTED_CONTRACT_COMMITS = (CONTRACT_COMMIT, "b291bf09e0a9f9fd3c16cf540832cd021203b7d1", "0cacd08b0e95b6abf131eae1206b60792138bc3c", "2eb91c00e852d9c31d804310d38fad91589fcbac", "8e49fbd5fbbf230e32c1969cd24ac3c22422f0a5", "a83bec6b47776af688402c18efec507143061f68", "52da526d7cc1e063d74c5b520dbc03d0ace15246", "78b2da018d2c4bd9ac1bde1dc3b7f1a110a175f5", "623bf61358c339cb10297807b3f024b5d9f1f327", "23f9fda4c05f8a3852246ee98d4f2adf74ed0875", "9091d3d6606b0c4b5591a38c3674356a01fd7f55", "df55c8c54a23251342a7ee57ba95642b7eb39e61", "2ce392291c6668598d12cd38327e24696b5ca15c")
28
28
  # #endregion supported-contract-revisions
29
29
  INTEROP_KEY = "https://fabric.passioncode.ai/agent-contract/extensions/interop/0.1"
30
30
  MCP_REVISION = "2026-07-28"
@@ -16,10 +16,10 @@ license: AGPL-3.0-only OR LicenseRef-PassionCode-Commercial
16
16
  compatibility: Python 3.9+ or Node.js 20+ for the kits; the probe needs Python 3.9+. launchd steps are macOS-only; Linux services install a systemd user unit and Windows ones a per-user Scheduled Task with the kits' writers. Dashboard handoff optionally uses Fabric Dashboards MCP link/host_status/open; without it, report unresolved host capability. The contract checkout is optional.
17
17
  metadata:
18
18
  author: PassionCode.ai
19
- version: "0.22.0"
19
+ version: "0.23.0"
20
20
  contract-version: "0.1.0"
21
21
  extension: "fabric-service/0.1"
22
- extension-commit: "b291bf09e0a9f9fd3c16cf540832cd021203b7d1"
22
+ extension-commit: "fe55fc67cba1a9e34a736da7d148d4fe2a8fbfa0"
23
23
  ---
24
24
 
25
25
  # Building Fabric services
@@ -95,16 +95,19 @@ itself (`isSmallOrderKey`), because Node before 26 lets OpenSSL accept a signatu
95
95
 
96
96
  ## Keys the estate record certifies
97
97
 
98
- A verifier that also reads the estate's record (DEC-0055, [the estate record reference](estate-record.md)) trusts a
99
- `kid` only while a current revision certifies it for a machine and does not revoke it (DL-14). Pass the current
100
- verified revision as `estate=` / `{ estate }`, as a value or as a function returning it, to `delegation_gate`,
98
+ A verifier that also reads the estate's record (DEC-0055, DEC-0060, [the estate record reference](estate-record.md))
99
+ trusts a `kid` only while the revision it reads certifies it (DL-14, row 4a, right after the signature). Pass the
100
+ current verified revision as `estate=` / `{ estate }`, as a value or as a function returning it, with
101
+ `estate_applied` / `estateApplied` and `estate_revocations` / `estateRevocations`, to `delegation_gate`,
101
102
  `verify_delegation` or `verify_approval`.
102
- - An uncertified `kid` is refused `unauthenticated` (`approval-invalid` for an approval), with detail
103
+ - An uncertified `kid` is the token's fault: `unauthenticated` (`approval-invalid` for an approval), detail
103
104
  `kid-not-certified`.
104
- - An unreadable record is refused `issuer-unavailable`, with detail `estate-unreadable`.
105
+ - A revision that cannot be read, is outside its window, is lower than the applied one or forks it is the trust
106
+ source's fault: `issuer-unavailable`, detail `estate-unreadable`, `estate-outside-window`, `estate-rolled-back` or
107
+ `estate-forked`.
105
108
  - Without `estate`, nothing changes.
106
- - Pass only a revision `verify_estate_record` accepted, and the highest one the machine has applied. The rule trusts
107
- what it is given, so an unverified or older revision would certify a key the current one revoked.
109
+ - Every verifier refuses a clock that is not a number of seconds `unknown-state` `no-clock` before row 1: a NaN clock
110
+ would make every time row false and pass an expired token.
108
111
 
109
112
  ## What the kit does not do
110
113
 
@@ -43,12 +43,16 @@ It checks, in the order of the ER table:
43
43
  parent, and no revocation dropped.
44
44
  5. **The signer.** The signing passkey must be among the trusted ones and not revoked by the parent. A revision may
45
45
  revoke its own signer: that is rotation.
46
- 6. **The assertion.**
46
+ 6. **The assertion.** The passkey is a signing credential (DEC-0063): an RP ID that is not a dedicated signing RP,
47
+ `sign.<domain>` in lower case, is `wrong-rp` before the assertion is read, and an origin outside the RP ID is not
48
+ pinned, so a ceremony that ran there is `wrong-origin`.
47
49
  - Client data: type, challenge, origin, no cross-origin use.
48
50
  - The RP ID hash, and the user-presence and user-verification flags.
49
51
  - The signature: ES256 or EdDSA, under a key validated first (a valid P-256 point; an Ed25519 key of full order).
50
- 7. **The window.** At most 30 days.
51
- 8. **The record's own rules.** A violation is `rule-violation` with its `codes`.
52
+ 7. **The window.** At most 30 days. A revision may be issued up to 60 s ahead of the verifier's clock (DEC-0066,
53
+ `CLOCK_SKEW_SECONDS`); earlier than that it is `not-yet-valid`.
54
+ 8. **The record's own rules.** A violation is `rule-violation` with its `codes`, `FAC-SEM-072…076` and `FAC-SEM-092`
55
+ (each passkey the record lists is a signing credential, its origins within its RP ID).
52
56
 
53
57
  Dates are strict RFC 3339: a `T`, an offset, and a day that exists. `:60` and a space are refused. Passkey JWK `x`
54
58
  and `y` must be canonical base64url. The Python kit verifies ES256 in pure Python (P-256, strict DER), and the Node
@@ -56,22 +60,35 @@ kit through `node:crypto`.
56
60
 
57
61
  ## Trusting a delegation key
58
62
 
59
- A delegation verifier that reads the estate record trusts a token's `kid` only while a current revision certifies it
60
- for a machine and does not revoke it (DL-14, contract CT-20). Give the gate the current verified revision, or a
61
- function that returns it:
63
+ A delegation verifier that reads the estate record trusts a token's `kid` only while the revision it reads certifies
64
+ it (DL-14, contract DEC-0060): exactly one machine's `hubKey` has that `kid` and the published key's `x`, the clock is
65
+ inside the revision's window (from 60 s before `issuedAt`, DEC-0066, to `validUntil`), and neither the revision nor the
66
+ revocation delta's entries applied since it revoke `hub-key <kid>` or `machine <id>`. It is checked right after the
67
+ signature (DL-13 row 4a). Give the gate the current verified revision, or a function that returns it, the highest
68
+ revision the machine applied, and the delta's revocations:
62
69
 
63
70
  ```python
64
- gate = fd.delegation_gate(audience=..., jwks=keys, issuer=..., effects=..., estate=lambda: current)
71
+ gate = fd.delegation_gate(audience=..., jwks=keys, issuer=..., effects=..., estate=lambda: current,
72
+ estate_applied={"revision": applied_number, "digest": applied_digest},
73
+ estate_revocations=lambda: delta_entries)
65
74
  ```
66
75
 
67
- - A `kid` the record does not certify is refused like an unknown key: `unauthenticated` (for an approval,
68
- `approval-invalid`) with detail `kid-not-certified`. The same holds when the record names another key under that
69
- kid, revokes it, or is outside its window.
70
- - A record that cannot be read certifies nothing: `issuer-unavailable` with detail `estate-unreadable`.
71
- - **What you pass in.** Pass only a revision that `verify_estate_record` accepted, and the highest revision the
72
- machine has applied. The rule trusts the record it is given. A record nobody verified, or an older revision still
73
- inside its window, would certify a key the current revision revoked (a rollback).
74
- - `hub_key_certified(record, kid, x, at)` / `hubKeyCertified(...)` answers the question on its own.
76
+ - **The token's fault** — no such certification, another key under that `kid`, a `kid` on two machines, a revoked hub
77
+ key or machine — is `unauthenticated` (for an approval, `approval-invalid`) with detail `kid-not-certified`.
78
+ - **The trust source's fault** is `issuer-unavailable`: `estate-unreadable` (a source that throws or answers nothing
79
+ readable, a revision without a number or digest, a window of zero or over 30 days, dates read strictly, `machines` or
80
+ `revocations` not arrays), `estate-outside-window`, `estate-rolled-back` (lower than the applied revision) and
81
+ `estate-forked` (the applied number with another digest). A caller cannot cure these by minting again.
82
+ - An unreadable clock — not a finite number of seconds a `Date` can hold — is refused `unknown-state` `no-clock`
83
+ before row 1, in every verifier.
84
+ - Only an absent `estate` skips the check. In the Node kit `null` is an unreadable source; in Python, where `None` is
85
+ the absent value, pass a function returning `None` for a source that has nothing.
86
+ - **What you pass in.** Pass only a revision that `verify_estate_record` accepted and whose number is not lower than
87
+ the highest the machine applied; a higher one only when you verified its chain from the applied revision.
88
+ - `hub_key_certified(record, kid, x, at, applied, extra_revocations)` /
89
+ `hubKeyCertified(record, kid, x, at, applied, {extraRevocations})` answers the question on its own:
90
+ `{certified: true, machine, revision}` or `{certified: false, fault, detail}`. Both kits are held to the contract's
91
+ `fixtures/vectors/hub-key.json` (`test/fixtures/contract/hub-key-vectors.json`).
75
92
 
76
93
  ## Checking a record you produce
77
94
 
@@ -73,12 +73,36 @@ operator's real jobs.
73
73
  ## One copy under a supervisor
74
74
 
75
75
  Started by hand, a copy that finds `service.lock` held prints one sentence naming the
76
- holder and exits 75 at once. Under launchd that exit is a respawn every `ThrottleInterval`
77
- (10 s), forever, and under systemd one every `RestartSec`. So a copy whose plist or unit
78
- carries `FABRIC_SERVICE_SUPERVISOR=launchd` (or `systemd`) backs off in-process — 0.5 s doubling to 30 s, 300 s in all — takes over if the holder leaves,
79
- and exits 75 only when the wait runs out: a few starts an hour instead of 360. It touches
80
- nothing while it waits. Two installs sharing one data directory are still the defect to
81
- remove; the back-off only stops the loop from costing the machine.
76
+ holder (or saying the holder is unknown, when its pid cannot be read) and exits 75 at once.
77
+ Under launchd that exit is a respawn every `ThrottleInterval` (10 s), forever, and under
78
+ systemd one every `RestartSec`. So a copy its supervisor started, and that says so with the
79
+ **supervisor marker**, backs off in-process — 0.5 s doubling to 30 s, 300 s in all — takes over
80
+ if the holder leaves, and exits 75 only when the wait runs out: a few starts an hour instead of
81
+ 360. It touches nothing while it waits. Two installs sharing one data directory are still the
82
+ defect to remove; the back-off only stops the loop from costing the machine.
83
+
84
+ The marker (contract DEC-0057, CT-01) is the variable `FABRIC_SERVICE_SUPERVISOR=<manager>` or
85
+ the argument `--fabric-supervisor <manager>` (also `--fabric-supervisor=<manager>`), after the
86
+ executable and before any `--`; `<manager>` is `launchd`, `systemd`, `task-scheduler` or `node`
87
+ (Project Observatory's node, which supervises the services it starts). The writer of the
88
+ supervisor file writes it: `launchd_plist` and `systemd_unit` / `systemdUnit` set the variable,
89
+ always; `task_xml` / `taskXml` put the argument in the task's `Arguments`, because a task's action
90
+ carries no environment. Each writer refuses a marker already in the program arguments. A copy
91
+ never infers supervision from its parent process.
92
+
93
+ - `supervisor_marker(env, argv)` / `supervisorMarker({env, argv})` reads both forms and answers
94
+ `supervised` (with the manager), `manual` or `conflict`. Only an empty variable counts as no
95
+ marker; a bare `--fabric-supervisor` (followed by nothing, by `--` or by another `--…` flag,
96
+ none of which it consumes) names no manager.
97
+ - Markers that disagree — the variable and the argument with different values, the argument
98
+ twice, or a bare or empty argument beside the variable — exit 75 at once, before the lock and
99
+ whether or not it is held, naming both markers.
100
+ - A service's own argument parser accepts the flag in both spellings and ignores it: in Python,
101
+ `add_supervisor_argument(parser)` (argparse otherwise exits 2 on an unknown flag); the sample
102
+ service adds it to the parser and to each command.
103
+ - The kits are held to the contract's `fixtures/vectors/service-supervisor.json`, and their
104
+ starts against a held lock are recorded and read as `FAC-SEM-078` reads them
105
+ (`test/*supervisors*`).
82
106
 
83
107
  ## Directories
84
108
 
@@ -151,7 +175,7 @@ control character (a line break would end a unit line early).
151
175
  **Linux — a systemd user unit.** `systemd_unit(unit, argv, working_directory=…)` /
152
176
  `systemdUnit(unit, argv, {workingDirectory})` writes `Restart=always`, `RestartSec=10`,
153
177
  `TimeoutStopSec` above the drain (15 s default), `KillMode=mixed`, `WantedBy=default.target`
154
- and `FABRIC_SERVICE_SUPERVISOR=systemd`, quoting every argument (`%` → `%%`, `$` → `$$`).
178
+ and `FABRIC_SERVICE_SUPERVISOR=systemd` (always, whatever the caller passed), quoting every argument (`%` → `%%`, `$` → `$$`).
155
179
  `WorkingDirectory=` is written unquoted: systemd reads it as the rest of the line, so quotes would
156
180
  become part of the path and the unit would be refused (`systemd-analyze verify` checks it in CI). The
157
181
  descriptor says `"lifecycle": {"manager": "systemd", "unit": "<id>.<instance>.service"}`.
@@ -179,9 +203,10 @@ CI job has the real `schtasks` create, read back and delete such a task. The des
179
203
  | stop, keep off | `schtasks /End /TN <task>`, then `schtasks /Change /TN <task> /DISABLE` |
180
204
  | uninstall | `task_uninstall` / `taskUninstall`: `/End`, then `/Delete /F` |
181
205
 
182
- A task cannot set an environment variable, so a copy Task Scheduler restarts does not back off
183
- in-process; `IgnoreNew` keeps the scheduler from starting a second copy, and a hand-started copy
184
- holding the lock makes the scheduled one exit 75 once a minute until it leaves.
206
+ A task cannot set an environment variable, so `task_xml` / `taskXml` write the marker as an
207
+ argument, `--fabric-supervisor task-scheduler`, before any `--`: a copy the Task Scheduler starts
208
+ backs off in-process like one under launchd or systemd. `IgnoreNew` keeps the scheduler from
209
+ starting a second copy.
185
210
 
186
211
  **One copy on each system.** The Python kit takes `flock` (Linux) or a locked byte
187
212
  (Windows); the Node kit cannot, so it holds a name instead — an abstract unix socket on Linux,
@@ -192,7 +217,14 @@ holds the same name beside its file lock, so the two kits exclude each other eve
192
217
 
193
218
  **Token files on Windows.** The privacy of `service.token` is its ACL (service.md *Windows
194
219
  token files*): the kits write a protected list — the user, SYSTEM and Administrators, set before the
195
- token's bytes go in, any entry already there dropped — and refuse
196
- on read a link, a file outside the profile, another owner, or any other granted SID, naming the
197
- SID. The Node kit reads the list with Windows PowerShell 5.1 (.NET, no modules) and writes it
198
- with `icacls`; the path goes through the environment, never a command line.
220
+ token's bytes go in, any entry already there dropped. On read, `windows_token_acl_problem` /
221
+ `windowsTokenAclProblem` decide over what was read — the file's flags, its owner SID and each ACE
222
+ as `{type, sid, mask}` (DEC-0057, `FAC-SEM-079`, held to the contract's
223
+ `fixtures/vectors/windows-token.json`): a reparse point, a directory, a real path outside the
224
+ profile, another owner, an allow ACE with a non-zero mask for any other SID, an ACE of another type
225
+ than allow or deny (an object or callback ACE), or anything unreadable is refused, naming the SID;
226
+ deny ACEs and an allow with an empty mask grant nothing; SIDs compare case-insensitively. The Python
227
+ kit reads the ACEs from the file's SDDL (`acl_from_sddl`); the Node kit reads them with Windows
228
+ PowerShell 5.1 (.NET's raw descriptor, no modules), converting .NET's signed mask to the unsigned
229
+ one, and writes the list with `icacls`; the path goes through the environment, never a command line.
230
+ An inherit-only ACE applies to children, not to the file, and is not read.
@@ -1,11 +1,13 @@
1
1
  # fabric-service/0.1 — wire reference
2
2
 
3
- Pinned to `fabric-agent-contract` commit `b291bf09e0a9f9fd3c16cf540832cd021203b7d1`
3
+ Pinned to `fabric-agent-contract` commit `fe55fc67cba1a9e34a736da7d148d4fe2a8fbfa0`
4
4
  (`docs/specification/service.md`, DEC-0015; the usage report DEC-0021; Windows and Linux supervision
5
5
  DEC-0032 and DEC-0033; the operator channel DEC-0034 and DEC-0035; the embedded dashboard DEC-0036;
6
6
  delegation and the operator session's lifetime DEC-0039; the meter's call window DEC-0041; session handoff DEC-0042;
7
7
  canonical forms DEC-0043; `degraded[].setup` and `run.mcp.stdio.scope` DEC-0044; delegation sealed and trust tiers
8
- DEC-0045; runner and model profiles DEC-0046). The contract's schemas are normative;
8
+ DEC-0045; runner and model profiles DEC-0046; the estate record DEC-0055; one copy under any supervisor and its marker,
9
+ the Windows token-file reader DEC-0057; the hub key the estate certifies DEC-0060; signing credentials DEC-0063; the
10
+ estate record's 60 s skew DEC-0066). The contract's schemas are normative;
9
11
  this page is the working summary. Extension key:
10
12
  `https://fabric.passioncode.ai/agent-contract/extensions/service/0.1`.
11
13
 
@@ -172,8 +172,11 @@ class Probe:
172
172
  self.add("descriptor.valid", "FAIL" if problems else "PASS", "; ".join(problems) or str(self.path))
173
173
  if fs.WINDOWS:
174
174
  # DEC-0032: on Windows the file's ACL is its privacy.
175
- owner, granting = fs.windows_acl(self.path)
176
- problem = fs.token_acl_problem(self.path, owner, granting, fs.windows_user_sid())
175
+ owner, aces = fs.windows_acl(self.path)
176
+ info = os.lstat(self.path)
177
+ problem = fs.windows_token_acl_problem({"isRegularFile": stat.S_ISREG(info.st_mode), "isReparsePoint": stat.S_ISLNK(info.st_mode),
178
+ "realPathInProfile": True, "ownerSid": owner, "aces": aces}, fs.windows_user_sid())
179
+ problem = problem and problem["message"]
177
180
  self.add("descriptor.private", "FAIL" if problem else "PASS", problem or "owner-only ACL")
178
181
  else:
179
182
  mode = stat.S_IMODE(os.stat(self.path).st_mode)
@@ -139,7 +139,7 @@ function keyFor(jwks, kid) {
139
139
  if (raw.length !== 32) return { problem: 'unusable-key' };
140
140
  if (isSmallOrderKey(raw)) return { problem: 'small-order-key' }; // before any verification (DEC-0045, CT-29)
141
141
  try {
142
- return { key: crypto.createPublicKey({ key: { kty: 'OKP', crv: 'Ed25519', x: jwk.x }, format: 'jwk' }), raw };
142
+ return { key: crypto.createPublicKey({ key: { kty: 'OKP', crv: 'Ed25519', x: jwk.x }, format: 'jwk' }), raw, x: jwk.x };
143
143
  } catch {
144
144
  return { problem: 'unusable-key' };
145
145
  }
@@ -175,7 +175,7 @@ function authentic(token, jwks, typ) {
175
175
  // Only an unknown kid is the token's fault; a published key that cannot be used is the issuer's (DL-13 row 3).
176
176
  if ('problem' in found) return found.problem === 'unknown-key' ? { problem: found.problem } : { problem: found.problem, issuer: true };
177
177
  if (compact.signature.length !== 64 || isSmallOrderKey(found.raw) || !crypto.verify(null, compact.signingInput, found.key, compact.signature)) return { problem: 'bad-signature' };
178
- return { compact, kid };
178
+ return { compact, kid, x: found.x };
179
179
  }
180
180
 
181
181
  /** Depth of an actor chain; Infinity for a chain that is not one (a missing or non-string sub at any level). */
@@ -249,33 +249,47 @@ function approvalShape(payload) {
249
249
  return payload;
250
250
  }
251
251
 
252
+ /** ECMAScript's time range in seconds (±8.64e15 ms): a NumericDate outside it is no instant a Date can hold. */
253
+ const MAX_CLOCK_SECONDS = 8.64e12;
254
+ /** A clock the time rows can compare (DEC-0060): a finite number of seconds within a Date's range. NaN or a string would pass every row. */
255
+ const readableClock = (now) => typeof now === 'number' && Number.isFinite(now) && Math.abs(now) <= MAX_CLOCK_SECONDS;
256
+
252
257
  /**
253
- * DL-13, in its fixed order: nothing about a token is believed before its signature is. `now` is seconds since
254
- * the epoch. Answers {ok: true, claims, principal, caller, chain, kid} or {ok: false, code, detail}.
255
- */
256
- /**
257
- * DL-14 with DEC-0055: a verifier that reads the estate record trusts a kid only while a current revision certifies it
258
- * for a machine and does not revoke it. `estate` is a revision the caller verified (fabric-estate.mjs
259
- * verifyEstateRecord) or a function returning the current one; undefined skips the rule. `[kind, detail]` or null.
258
+ * DL-14 row 4a (DEC-0055, DEC-0060), right after the signature: when the callee reads the estate record, the token's
259
+ * `kid` and the published key must be certified by that revision. `estate` is a revision the caller verified
260
+ * (fabric-estate.mjs verifyEstateRecord) and its machine applied, or a function returning it; only an absent `estate`
261
+ * skips the rule (null is an unreadable source). `estateApplied` is the highest revision the machine applied,
262
+ * `estateRevocations` the revocation delta's entries since (an array or a function). A source that throws is
263
+ * unreadable, never a pass. `[kind, detail]` or null.
260
264
  */
261
- function estateProblem(estate, jwks, kid, now) {
262
- if (estate === undefined || estate === null) return null;
265
+ function estateProblem({ estate, estateApplied, estateRevocations }, kid, x, now) {
266
+ if (estate === undefined) return null;
263
267
  let record;
268
+ let extra;
264
269
  try {
265
270
  record = typeof estate === 'function' ? estate() : estate;
271
+ extra = typeof estateRevocations === 'function' ? estateRevocations() : estateRevocations;
266
272
  } catch {
267
- return ['issuer', 'estate-unreadable']; // an unreadable record certifies nothing; it is never a pass
273
+ return ['issuer', 'estate-unreadable'];
268
274
  }
269
- const jwk = jwks.keys.find((candidate) => isObject(candidate) && candidate.kid === kid) ?? {};
270
- return hubKeyCertified(record, kid, jwk.x, now) ? null : ['token', 'kid-not-certified'];
275
+ const verdict = hubKeyCertified(record, kid, x, now, estateApplied, extra === undefined ? undefined : { extraRevocations: extra });
276
+ // The clock was refused before row 1, so a verdict here is the token's or the trust source's.
277
+ return verdict.certified ? null : [verdict.fault === 'token' ? 'token' : 'issuer', verdict.detail];
271
278
  }
272
279
 
273
- export function verifyDelegation(token, { audience, jwks, now, capability, effect, issuer, readOnly, estate } = {}) {
280
+ /**
281
+ * DL-13, in its fixed order: nothing about a token is believed before its signature is. `now` is seconds since
282
+ * the epoch; a clock that is not one is refused `unknown-state` `no-clock` before row 1. Answers {ok: true, claims,
283
+ * principal, caller, chain, kid} or {ok: false, code, detail}.
284
+ */
285
+ export function verifyDelegation(token, { audience, jwks, now, capability, effect, issuer, readOnly, estate, estateApplied, estateRevocations } = {}) {
286
+ // Before row 1: every time row compares against the clock, and a comparison with NaN is always false.
287
+ if (!readableClock(now)) return refuse('unknown-state', 'no-clock');
274
288
  if (!isString(issuer)) return refuse('issuer-unavailable', 'no-trusted-issuer');
275
289
  if (!hasKeys(jwks)) return refuse('issuer-unavailable', 'no-published-keys');
276
290
  const checked = authentic(token, jwks, DELEGATION_TYP);
277
291
  if ('problem' in checked) return refuse(checked.issuer ? 'issuer-unavailable' : 'unauthenticated', checked.problem);
278
- const uncertified = estateProblem(estate, jwks, checked.kid, now);
292
+ const uncertified = estateProblem({ estate, estateApplied, estateRevocations }, checked.kid, checked.x, now);
279
293
  if (uncertified) return refuse(uncertified[0] === 'issuer' ? 'issuer-unavailable' : 'unauthenticated', uncertified[1]);
280
294
  const shaped = delegationShape(checked.compact.payload);
281
295
  if ('problem' in shaped) return refuse('unauthenticated', shaped.problem);
@@ -295,14 +309,15 @@ export function verifyDelegation(token, { audience, jwks, now, capability, effec
295
309
  }
296
310
 
297
311
  /** DL-18: approval-required carries the digest; any fault is approval-invalid; the jti is consumed last. */
298
- export function verifyApproval(approval, { audience, jwks, now, actionDigest: expected, issuer, jtiStore, estate } = {}) {
312
+ export function verifyApproval(approval, { audience, jwks, now, actionDigest: expected, issuer, jtiStore, estate, estateApplied, estateRevocations } = {}) {
299
313
  if (approval === undefined || approval === null || approval === '') return refuse('approval-required', 'no-approval', { actionDigest: expected });
300
314
  if (!isObject(jtiStore) || typeof jtiStore.consume !== 'function') return refuse('unknown-state', 'no-jti-store');
315
+ if (!readableClock(now)) return refuse('unknown-state', 'no-clock');
301
316
  if (!isString(issuer)) return refuse('issuer-unavailable', 'no-trusted-issuer');
302
317
  if (!hasKeys(jwks)) return refuse('issuer-unavailable', 'no-published-keys');
303
318
  const checked = authentic(approval, jwks, APPROVAL_TYP);
304
319
  if ('problem' in checked) return refuse(checked.issuer ? 'issuer-unavailable' : 'approval-invalid', checked.problem);
305
- const uncertified = estateProblem(estate, jwks, checked.kid, now);
320
+ const uncertified = estateProblem({ estate, estateApplied, estateRevocations }, checked.kid, checked.x, now);
306
321
  if (uncertified) return refuse(uncertified[0] === 'issuer' ? 'issuer-unavailable' : 'approval-invalid', uncertified[1]);
307
322
  const claims = approvalShape(checked.compact.payload);
308
323
  if (!claims) return refuse('approval-invalid', 'malformed-claims');
@@ -469,7 +484,7 @@ export const TIERS = Object.freeze(['T0', 'T1', 'T2']);
469
484
  * relayed from off the machine). A T0 or T1 caller is never required to present a token: with none, the call passes
470
485
  * with no delegation. A present token is verified at every tier. `issuer` (auth.delegation.issuer) is required.
471
486
  */
472
- export function delegationGate({ audience, jwks, effects, issuer, readOnly = false, clock = () => Date.now() / 1000, estate }) {
487
+ export function delegationGate({ audience, jwks, effects, issuer, readOnly = false, clock = () => Date.now() / 1000, estate, estateApplied, estateRevocations }) {
473
488
  if (!isString(issuer)) throw new Error('the gate needs the issuer it trusts (auth.delegation.issuer)');
474
489
  return async (tool, headers, tier = 'T2') => {
475
490
  const effect = effects?.[tool];
@@ -480,7 +495,7 @@ export function delegationGate({ audience, jwks, effects, issuer, readOnly = fal
480
495
  return refuse('unauthenticated', 'no-token');
481
496
  }
482
497
  const keys = jwks instanceof JwksCache ? await jwks.get(kidOf(carried.token)) : jwks;
483
- const verdict = verifyDelegation(carried.token, { audience, jwks: keys, now: clock(), capability: tool, effect, readOnly, issuer, estate });
498
+ const verdict = verifyDelegation(carried.token, { audience, jwks: keys, now: clock(), capability: tool, effect, readOnly, issuer, estate, estateApplied, estateRevocations });
484
499
  if (verdict.ok) verdict.tier = TIERS.includes(tier) ? tier : 'T2';
485
500
  return verdict;
486
501
  };