@passioncode-ai/fabric-agent-adapter 0.39.0 → 0.39.1
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.
- package/CHANGELOG.md +47 -1
- package/README.md +16 -14
- package/bin/fabric-agent-adapter.js +6 -6
- package/package.json +1 -1
- package/plugins/fabric-agent-adapter/.claude-plugin/plugin.json +1 -1
- package/plugins/fabric-agent-adapter/skills/adapting-projects-to-fabric/SKILL.md +13 -13
- package/plugins/fabric-agent-adapter/skills/adapting-projects-to-fabric/references/dashboard-links.md +1 -1
- package/plugins/fabric-agent-adapter/skills/adapting-projects-to-fabric/references/provider-entry.md +4 -4
- package/plugins/fabric-agent-adapter/skills/building-fabric-services/SKILL.md +41 -41
- package/plugins/fabric-agent-adapter/skills/building-fabric-services/assets/dashboard-kit/demo.html +1 -1
- package/plugins/fabric-agent-adapter/skills/building-fabric-services/assets/dashboard-kit/fabric-button.js +3 -3
- package/plugins/fabric-agent-adapter/skills/building-fabric-services/assets/dashboard-kit/fabric-dashboard.css +1 -1
- package/plugins/fabric-agent-adapter/skills/building-fabric-services/assets/dashboard-kit/fabric-dashboard.js +2 -2
- package/plugins/fabric-agent-adapter/skills/building-fabric-services/assets/dashboard-kit/kit.json +9 -4
- package/plugins/fabric-agent-adapter/skills/building-fabric-services/references/board.md +12 -12
- package/plugins/fabric-agent-adapter/skills/building-fabric-services/references/dashboard-kit.md +4 -4
- package/plugins/fabric-agent-adapter/skills/building-fabric-services/references/dashboard-links.md +1 -1
- package/plugins/fabric-agent-adapter/skills/building-fabric-services/references/dashboard.md +4 -4
- package/plugins/fabric-agent-adapter/skills/building-fabric-services/references/delegation.md +13 -11
- package/plugins/fabric-agent-adapter/skills/building-fabric-services/references/estate-record.md +10 -5
- package/plugins/fabric-agent-adapter/skills/building-fabric-services/references/events-and-notifications.md +6 -6
- package/plugins/fabric-agent-adapter/skills/building-fabric-services/references/interop.md +8 -6
- package/plugins/fabric-agent-adapter/skills/building-fabric-services/references/lifecycle.md +26 -26
- package/plugins/fabric-agent-adapter/skills/building-fabric-services/references/migrating-a-service.md +1 -1
- package/plugins/fabric-agent-adapter/skills/building-fabric-services/references/package.md +3 -2
- package/plugins/fabric-agent-adapter/skills/building-fabric-services/references/profiles.md +10 -10
- package/plugins/fabric-agent-adapter/skills/building-fabric-services/references/protocol.md +13 -13
- package/plugins/fabric-agent-adapter/skills/building-fabric-services/references/remote-placement.md +4 -4
- package/plugins/fabric-agent-adapter/skills/building-fabric-services/references/settings-backups.md +3 -3
- package/plugins/fabric-agent-adapter/skills/building-fabric-services/references/surfaces-and-auth.md +5 -5
- package/plugins/fabric-agent-adapter/skills/building-fabric-services/references/usage.md +5 -4
- package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/check_service.py +20 -45
- package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/dashboard_kit.py +1 -1
- package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric-board.mjs +1 -1
- package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric-delegation.mjs +2 -1
- package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric-package.mjs +1 -1
- package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric-service.mjs +28 -8
- package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric_board.py +1 -1
- package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric_delegation.py +1 -1
- package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric_package.py +1 -1
- package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric_service.py +34 -14
- package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/sample_service.py +1 -1
- package/plugins/fabric-agent-adapter/skills/creating-fabric-agents/SKILL.md +33 -33
- package/plugins/fabric-agent-adapter/skills/creating-fabric-agents/references/dashboard-links.md +1 -1
- package/plugins/fabric-agent-adapter/skills/creating-fabric-agents/references/resilience-and-autonomy.md +27 -27
- package/plugins/fabric-agent-adapter/skills/working-with-fabric/SKILL.md +31 -31
- package/plugins/fabric-agent-adapter/skills/working-with-fabric/references/project-board.md +9 -9
- package/plugins/fabric-agent-adapter/skills/working-with-fabric/references/session-hooks.md +8 -8
- package/plugins/fabric-agent-adapter/skills/working-with-fabric/scripts/fabric_session.py +6 -6
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* fabric-dashboard-kit@1.1.
|
|
1
|
+
/* fabric-dashboard-kit@1.1.1 · Fabric's button (Fabric Agent Contract DEC-0040, FB-1…FB-8, FL-1…FL-6)
|
|
2
2
|
Load it same-origin, after fabric-dashboard.css, with the service it opens Fabric on:
|
|
3
3
|
<script src="fabric-button.js" defer data-service="example-agent.default" data-service-name="Example Agent"
|
|
4
4
|
data-project="project-a" data-project-name="Project A"></script>
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
(function (root) {
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
-
var VERSION = '1.1.
|
|
13
|
+
var VERSION = '1.1.1';
|
|
14
14
|
var COOKIE = 'fabric_button';
|
|
15
15
|
var GET_FABRIC = 'https://passioncode.ai/fabric';
|
|
16
16
|
var ABSENT_AFTER_MS = 1500;
|
|
@@ -212,7 +212,7 @@
|
|
|
212
212
|
return a;
|
|
213
213
|
});
|
|
214
214
|
var note = el(doc, 'p', { 'class': 'fd-fabric-button-note', role: 'note' });
|
|
215
|
-
note.appendChild(doc.createTextNode('Fabric is not installed
|
|
215
|
+
note.appendChild(doc.createTextNode('Fabric is not installed. Get it at '));
|
|
216
216
|
note.appendChild(el(doc, 'a', { href: GET_FABRIC, target: '_blank', rel: 'noopener', 'class': 'fd-fabric-button-get' }, 'passioncode.ai/fabric'));
|
|
217
217
|
note.hidden = !absent;
|
|
218
218
|
menu.appendChild(note);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* fabric-dashboard-kit@1.1.
|
|
1
|
+
/* fabric-dashboard-kit@1.1.1 · fabric-dashboard/0.1 (Fabric Agent Contract DEC-0036)
|
|
2
2
|
A Fabric service dashboard shown inside a host pane: usable from 360 CSS px up, navigation always
|
|
3
3
|
reachable, wide content in its own scroll box, one vertical scroller, appearance from the host.
|
|
4
4
|
Copy this file next to fabric-dashboard.js; do not edit it in place. Put the page's own rules in
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* fabric-dashboard-kit@1.1.
|
|
1
|
+
/* fabric-dashboard-kit@1.1.1 · fabric-dashboard/0.1 (Fabric Agent Contract DEC-0036)
|
|
2
2
|
Load it same-origin with <script src="fabric-dashboard.js" defer></script>: no inline script, no
|
|
3
3
|
eval, nothing from a CDN. It applies the host's appearance (ED-6, ED-8), folds navigation that
|
|
4
4
|
does not fit into a More menu (ED-3), makes wide boxes keyboard-reachable (ED-4) and keeps
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
'use strict';
|
|
9
9
|
|
|
10
10
|
var KIT = 'fabric-dashboard-kit';
|
|
11
|
-
var VERSION = '1.1.
|
|
11
|
+
var VERSION = '1.1.1';
|
|
12
12
|
/* fabric-dashboard-kit:theme-ids:begin */
|
|
13
13
|
var THEMES = ['graphite', 'fabric', 'paper', 'forest', 'ocean', 'ember', 'contrast'];
|
|
14
14
|
/* fabric-dashboard-kit:theme-ids:end */
|
package/plugins/fabric-agent-adapter/skills/building-fabric-services/assets/dashboard-kit/kit.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fabric-dashboard-kit",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"profile": "fabric-dashboard/0.1",
|
|
5
5
|
"decision": "DEC-0036",
|
|
6
6
|
"declarationKey": "https://fabric.passioncode.ai/agent-contract/extensions/dashboard/0.1",
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"contrast"
|
|
16
16
|
],
|
|
17
17
|
"files": {
|
|
18
|
-
"fabric-dashboard.css": "
|
|
19
|
-
"fabric-dashboard.js": "
|
|
20
|
-
"fabric-button.js": "
|
|
18
|
+
"fabric-dashboard.css": "a8847c8e2f386572318842ec1d1613fcb29e4aec060e033c060d8dba6b7c6f02",
|
|
19
|
+
"fabric-dashboard.js": "d0fc41144a6bd413383bd53bbfa6e01a29547c7ec9c01a3927d69fb36cd71a7d",
|
|
20
|
+
"fabric-button.js": "f5599fabfeadfb5c69d30f7ea500846521a166470078a736291c7753014bc25c",
|
|
21
21
|
"themes.json": "511839f1a1a83eb37fadfd132791474497d5c28c5091700b9aa31ad076e359b5"
|
|
22
22
|
},
|
|
23
23
|
"history": {
|
|
@@ -29,6 +29,11 @@
|
|
|
29
29
|
"fabric-dashboard.css": "498571903fac6dfd2d6645283da2f703fa945f410f2fafa269a8c9c322735c3b",
|
|
30
30
|
"fabric-dashboard.js": "100f55d940d4ed60aa8511cee4c65219c93114eb7d7a66639b0e4e4d7aa05f22",
|
|
31
31
|
"fabric-button.js": "4f1e100936ae65af5539594681e66092ae1834a4952da547a67d0558c9fadbbe"
|
|
32
|
+
},
|
|
33
|
+
"1.1.1": {
|
|
34
|
+
"fabric-dashboard.css": "a8847c8e2f386572318842ec1d1613fcb29e4aec060e033c060d8dba6b7c6f02",
|
|
35
|
+
"fabric-dashboard.js": "d0fc41144a6bd413383bd53bbfa6e01a29547c7ec9c01a3927d69fb36cd71a7d",
|
|
36
|
+
"fabric-button.js": "f5599fabfeadfb5c69d30f7ea500846521a166470078a736291c7753014bc25c"
|
|
32
37
|
}
|
|
33
38
|
}
|
|
34
39
|
}
|
|
@@ -63,12 +63,12 @@ One tick every 15 s ± 5 s (`step()` answers the wait):
|
|
|
63
63
|
|
|
64
64
|
| Step | Board call | Checkpoint written first |
|
|
65
65
|
|---|---|---|
|
|
66
|
-
| hold the slot | `com.enroll` (again at about 20 s while idle: the holder's enroll renews its 60 s lease) |
|
|
66
|
+
| hold the slot | `com.enroll` (again at about 20 s while idle: the holder's enroll renews its 60 s lease) | none |
|
|
67
67
|
| take a request | `com.claim`, the same key while nothing is claimable | `claimed` |
|
|
68
|
-
| read it | `com.get`: the digest must equal the claim's, and the request must name this Project and capability |
|
|
68
|
+
| read it | `com.get`: the digest must equal the claim's, and the request must name this Project and capability | none |
|
|
69
69
|
| accept | `com.accept` with the claim's exact fence (request, generation, attempt, digest, revision) | `accepting`, then `accepted` |
|
|
70
70
|
| act | `com.effect_begin`, only when the handler calls `ctx.begin_effect()` | `effect-beginning`, then `in-progress` |
|
|
71
|
-
| while working | `com.renew` at about 20 s; `com.progress` for `ctx.progress(note)` |
|
|
71
|
+
| while working | `com.renew` at about 20 s; `com.progress` for `ctx.progress(note)` | none |
|
|
72
72
|
| answer | `com.reply` (fenced) when the outcome carries `reply` | `replying` |
|
|
73
73
|
| settle | `com.complete {state, observed, summary?, evidence?}` | `completing`, then the entry is dropped |
|
|
74
74
|
|
|
@@ -82,12 +82,12 @@ own monotonic clock and never reasons from `leaseExpiresAt`.
|
|
|
82
82
|
`admit(request)` is required: it is the service's own input gate. It answers `None` to admit or one sentence saying
|
|
83
83
|
why not; a refusal accepts the request and completes it `failed_known` with that sentence, so the requester learns it
|
|
84
84
|
and the request does not bounce. A redacted body is refused the same way. The kit never hands a body to a model, a
|
|
85
|
-
shell or a tool; what the handler does with an admitted body
|
|
86
|
-
spend sees it
|
|
85
|
+
shell or a tool; what the handler does with an admitted body (and the checks it needs before a model, a tool or a
|
|
86
|
+
spend sees it) is the service's own responsibility. A message never carries an approval.
|
|
87
87
|
|
|
88
88
|
## Effects, observation, evidence and the reply
|
|
89
89
|
|
|
90
|
-
- Call `ctx.begin_effect(summary)
|
|
90
|
+
- Call `ctx.begin_effect(summary)`, and let it return, before the handler spends, writes outside the service or calls
|
|
91
91
|
anything that acts. If it raises `Stopped`, act no further.
|
|
92
92
|
- After an effect began, the outcome must be observed (`observed: true`): the kit never sends an unobserved result; the
|
|
93
93
|
request stays unknown and is reconciled later.
|
|
@@ -130,7 +130,7 @@ contract's matrix, held to its vectors (`test/fixtures/contract/comms-hold-vecto
|
|
|
130
130
|
| `com.enroll`, `com.claim`, `com.responder_replace` | the slot pauses: asked again after 15 s, then 30 s, doubling to 15 minutes; one `board.slot.held` event per capability, and `board.slot.released` when an enroll succeeds again |
|
|
131
131
|
| `com.accept` (the hold came after the claim) | nothing was done: the entry is dropped, the claim lapses and the request waits on the board (`board.request.waiting`); the slot pauses |
|
|
132
132
|
| `com.effect_begin` | the effect has not begun: the handler waits (same idempotency key, the pause doubling) while the tick keeps renewing the lease, then begins once the hold is lifted; `ctx.stopped` ends the wait |
|
|
133
|
-
| accepted work at restart under a hold | kept as `lapsed`, then taken back with `com.responder_replace` and a transfer once the hold is lifted
|
|
133
|
+
| accepted work at restart under a hold | kept as `lapsed`, then taken back with `com.responder_replace` and a transfer once the hold is lifted, never claimed back |
|
|
134
134
|
|
|
135
135
|
A hold is not an outage: no `board.down`, no notify. Work already accepted keeps running and completes.
|
|
136
136
|
|
|
@@ -143,7 +143,7 @@ whose responder was gone. Read it as the owner's attestation, not the responder'
|
|
|
143
143
|
A board session (`fabric.board.join`) is served the respond scope only: `com.status`, `com.list`, `com.get`,
|
|
144
144
|
`com.reply` (the fenced form), `com.enroll`, `com.claim`, `com.renew`, `com.accept`, `com.progress`,
|
|
145
145
|
`com.effect_begin`, `com.complete`, `com.reconcile`, `com.responder_replace`. `BoardSession.call` refuses anything else
|
|
146
|
-
locally (`not-in-scope`)
|
|
146
|
+
locally (`not-in-scope`): never `com.submit`, `com.cancel`, `com.read_ack` or `com.directory`.
|
|
147
147
|
|
|
148
148
|
The idempotency epoch comes from `com.status`. A Fabric built before its board-session fix tells a board session none:
|
|
149
149
|
the kit fails closed (`no-epoch`, `board.blocked`) instead of guessing one.
|
|
@@ -152,13 +152,13 @@ the kit fails closed (`no-epoch`, `board.blocked`) instead of guessing one.
|
|
|
152
152
|
|
|
153
153
|
The directory belongs to a Project session (a coding agent's, or a launched one). Before looking a Project up in a
|
|
154
154
|
`com.directory` page, `find_project(page, project_id, capability=None)` / `findProject` checks the page: closed shapes
|
|
155
|
-
(no count, holder or generation) and FAC-SEM-107
|
|
155
|
+
(no count, holder or generation) and FAC-SEM-107: each Project once, each capability once per Project. Project ids and
|
|
156
156
|
capability names compare **exactly as written** (DEC-0077; they are not URIs, so not by normal form). A page that fails
|
|
157
157
|
raises `directory-invalid` rather than answering; an unlisted Project may still be addressed by an id already held.
|
|
158
158
|
|
|
159
159
|
## Events, the probe and the live smoke
|
|
160
160
|
|
|
161
|
-
Events go to `emit(kind, level, text, notify=…, data=…)`
|
|
161
|
+
Events go to `emit(kind, level, text, notify=…, data=…)` (`JsonlEventLog.append` fits) with `data {schema, value}`
|
|
162
162
|
checked by FAC-SEM-101 (no credential in data): `board.request.completed`, `board.request.refused`,
|
|
163
163
|
`board.request.skipped`, `board.request.reconciled`, `board.request.held`, `board.attempt.lost`,
|
|
164
164
|
`board.reconcile.needed`, `board.slot.contested`, `board.access.needed`, `board.blocked`, `board.down`, each
|
|
@@ -167,10 +167,10 @@ notifying episode said once.
|
|
|
167
167
|
`check_service.py <id> [--board-kit <the service's fabric_board.py or fabric-board.mjs>]` rule **board.responder**:
|
|
168
168
|
`NOT_RUN` when the well-known `protocols` names no `fabric-project-comms` revision; `FAIL` for a revision this kit does
|
|
169
169
|
not read or a fixture conversation that goes wrong; `PASS` when the kit's `self_check()` / `selfCheck()` passes (the
|
|
170
|
-
whole conversation, a fenced accept, a session without an epoch
|
|
170
|
+
whole conversation, a fenced accept, a session without an epoch; no Fabric touched).
|
|
171
171
|
|
|
172
172
|
The live smoke runs only against a disposable Fabric (built app and its own stack), never an operator's estate: Fabric's
|
|
173
|
-
COM-03 packet (`docs/evidence/plans/2026-10-04-project-communications.md`) has the exact commands
|
|
173
|
+
COM-03 packet (`docs/evidence/plans/2026-10-04-project-communications.md`) has the exact commands: register
|
|
174
174
|
`fabric-mcp` for Claude Code and Codex, the operator allows `session.enroll` and `board.respond`
|
|
175
175
|
(`board:<example-agent project>/<capability>`), Claude submits a request, the responder enrolls, claims, accepts and
|
|
176
176
|
completes, then is killed mid-claim and replaced. Without that Fabric, report it `NOT_RUN`.
|
package/plugins/fabric-agent-adapter/skills/building-fabric-services/references/dashboard-kit.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# The dashboard kit
|
|
1
|
+
# The dashboard kit: `fabric-dashboard/0.1`
|
|
2
2
|
|
|
3
3
|
Fabric Dashboards shows a service's page in a pane beside its sidebar and the agent console, and the
|
|
4
4
|
operator drags the console wider whenever they need it. The page never knows how much room it will
|
|
@@ -97,12 +97,12 @@ service. Load it after the stylesheet, with ids only:
|
|
|
97
97
|
scroll. The mark and the word *Fabric*, the mark alone below 480 px; the accessible name is always *Open Fabric*;
|
|
98
98
|
`--ink` on `--panel` with an `--edge` boundary, the pairs the themes are measured on.
|
|
99
99
|
- **Links (FL-1…FL-6):** built with the kit's port of the contract's `buildFabricLink`; a value outside the grammar
|
|
100
|
-
|
|
100
|
+
(or one shaped like a credential) means no button, never a bad link. A press opens a view in Fabric and starts
|
|
101
101
|
nothing (FB-8).
|
|
102
102
|
- **The host (FB-6):** when the host's `fabric_button` cookie says `owner=host`, the page hides its own button.
|
|
103
103
|
- **Fabric absent (FB-5):** when the cookie says `fabric=absent`, or `data-fabric="absent"`, or when the page is still
|
|
104
|
-
visible and focused 1.5 s after a link was followed, the menu says
|
|
105
|
-
passioncode.ai/fabric
|
|
104
|
+
visible and focused 1.5 s after a link was followed, the menu says that Fabric is not installed and names
|
|
105
|
+
passioncode.ai/fabric to get it. Nothing downloads, nothing retries. A local service's server decides `data-fabric` with
|
|
106
106
|
`fabric_button_presence()` / `fabricButtonPresence()`: `present` while Fabric's own descriptor
|
|
107
107
|
(`services/fabric.default.json`, Fabric ADR-0139) is registered and, for an app's descriptor (`manager: "person"`,
|
|
108
108
|
DEC-0069), its app is still installed; `absent` otherwise. A press only follows a link, so the button never reads
|
package/plugins/fabric-agent-adapter/skills/building-fabric-services/references/dashboard.md
CHANGED
|
@@ -4,10 +4,10 @@ The dashboard is where the operator decides; it must stay truthful when parts of
|
|
|
4
4
|
service are not.
|
|
5
5
|
|
|
6
6
|
1. **Same origin, static assets.** HTML shell plus hashed `app.js`/`app.css` from a
|
|
7
|
-
whitelist; no inline script; a strict CSP. Nothing from a CDN
|
|
7
|
+
whitelist; no inline script; a strict CSP. Nothing from a CDN: the page must work
|
|
8
8
|
offline on a plane.
|
|
9
9
|
2. **State first, then detail.** The top of every page answers "is it working, and
|
|
10
|
-
does it need me?"
|
|
10
|
+
does it need me?": the same `status`, `degraded` and attention tiles the
|
|
11
11
|
well-known document publishes, so the page and Fabric Dashboards never disagree.
|
|
12
12
|
3. **Calm refresh.** Poll the page's own API every 5 s while visible, back off when
|
|
13
13
|
hidden, and pause while a field is focused, a form has unsaved input or a dialog is
|
|
@@ -16,7 +16,7 @@ service are not.
|
|
|
16
16
|
4. **Partial failure stays partial.** Load panels independently (`Promise.allSettled`);
|
|
17
17
|
a failed panel shows its own one-sentence error and a retry, and the rest render.
|
|
18
18
|
5. **Every error is a sentence and an action.** "Store listing push failed: App Store
|
|
19
|
-
Connect rejected the key. Settings → Keys"
|
|
19
|
+
Connect rejected the key. Settings → Keys", never a status code, a stack trace or a
|
|
20
20
|
blank area. Show when data was last fresh.
|
|
21
21
|
6. **Server down is a state, not a crash.** When the API stops answering, keep the
|
|
22
22
|
last data greyed with "Service not answering since 17:02", and recover by itself
|
|
@@ -30,4 +30,4 @@ service are not.
|
|
|
30
30
|
9. **Links into the page are stable.** Event `link`s point at hash routes that survive
|
|
31
31
|
a reload (`/dashboard#/approvals/77`) so a notification opens the exact item.
|
|
32
32
|
10. **No second browser tab required.** With Fabric Dashboards installed, the page is
|
|
33
|
-
shown inside it; do not open windows or tabs on your own
|
|
33
|
+
shown inside it; do not open windows or tabs on your own; use in-page dialogs.
|
package/plugins/fabric-agent-adapter/skills/building-fabric-services/references/delegation.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Delegation
|
|
1
|
+
# Delegation: checking who acts for whom (DEC-0039)
|
|
2
2
|
|
|
3
3
|
A service that other agents of the estate call checks each call offline with the kit's verifier: the estate hub
|
|
4
4
|
signs a delegation token naming the person (`sub`), the actor chain (`act`), this service (`aud`), the
|
|
@@ -22,7 +22,7 @@ contract's own verifier does.
|
|
|
22
22
|
## Declaring it
|
|
23
23
|
|
|
24
24
|
In the well-known document: `surfaces.mcp.auth: "delegation"` (only delegation tokens) and
|
|
25
|
-
`auth.delegation: {issuer, jwks}
|
|
25
|
+
`auth.delegation: {issuer, jwks}`: the `iss` you trust (`urn:fabric:estate:<id>`) and where the key set is read.
|
|
26
26
|
The descriptor's token stays the host's: it is never a caller's credential on `/mcp` (DL-12). The probe checks
|
|
27
27
|
the declaration (`auth.delegation-declared`) and that `/mcp` refuses the descriptor token.
|
|
28
28
|
|
|
@@ -34,7 +34,7 @@ keys = fd.JwksCache(well_known["auth"]["delegation"]["jwks"]) # https,
|
|
|
34
34
|
gate = fd.delegation_gate(audience="example-agent", jwks=keys, issuer=well_known["auth"]["delegation"]["issuer"], # required
|
|
35
35
|
effects={"example.write": "draft", "example.publish": "publish"}) # each tool's manifest effect
|
|
36
36
|
server = fi.McpToolServer("example-agent", VERSION, authorize=gate) # pass the request headers to handle()
|
|
37
|
-
# in a handler: ctx.delegation["principal"], ["caller"], ["chain"]
|
|
37
|
+
# in a handler: ctx.delegation["principal"], ["caller"], ["chain"]; record the chain with the work
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
```js
|
|
@@ -50,7 +50,7 @@ if (!verdict.ok) return refusalToolResult(verdict);
|
|
|
50
50
|
DL-25 places each caller in a tier by its origin: **T0** a loopback caller under the owner's account that the
|
|
51
51
|
service's own local floor (the descriptor token, the Host guard) has authenticated; **T1** an enrolled machine of
|
|
52
52
|
the same owner; **T2** everyone else, and any call relayed onto loopback from off the machine (a tunnel, a proxy, the
|
|
53
|
-
hub forwarding a T2 caller). DL-26: a T0 or T1 caller is never required to present a token
|
|
53
|
+
hub forwarding a T2 caller). DL-26: a T0 or T1 caller is never required to present a token; pass the tier,
|
|
54
54
|
`gate(tool, headers, tier="T0")` or `server.handle(message, headers, tier="T0")`, and the call passes with no
|
|
55
55
|
delegation. A token such a caller presents is still verified and refused when invalid. A T2 caller takes the whole
|
|
56
56
|
profile. Money limits and human gates bind at every tier.
|
|
@@ -66,8 +66,10 @@ job records who started it.
|
|
|
66
66
|
**A partner in the chain** (DEC-0090). A token a partner's agent presents for a customer organization carries the
|
|
67
67
|
partner as the innermost actor: `{partner: "org:<id>"}`, exactly that member, under at least one agent. It counts
|
|
68
68
|
toward the depth limit and ends the chain; outermost, with an `act` beneath, or as `personal` it is
|
|
69
|
-
`malformed-chain`. A node with a `sub` beside `partner` is an agent,
|
|
70
|
-
|
|
69
|
+
`malformed-chain`. A node with a `sub` beside `partner` is checked as an agent, yet `ctx.delegation["chain"]` lists it
|
|
70
|
+
by its `org:` id, as the contract's `chainOf` does; the schema refuses such a node, so a correct issuer never mints one
|
|
71
|
+
(raised with the contract, FAA-64). Job ownership and idempotency keys follow `(principal, caller)` and do not include
|
|
72
|
+
the partner (FAA-64). `chain_depth(act)` /
|
|
71
73
|
`chainDepth(act)` answer the contract's depth, infinity for a chain that is not one. Minting a partner's token (its
|
|
72
74
|
grant, FAC-SEM-124) is the issuer's, not the kit's.
|
|
73
75
|
|
|
@@ -76,19 +78,19 @@ grant, FAC-SEM-124) is the issuer's, not the kit's.
|
|
|
76
78
|
An action with an external effect may need the operator's approval (DL-17, DL-18). The order is fixed: the token,
|
|
77
79
|
then the grant check where there is one, then `verify_approval` / `verifyApproval`, which consumes the approval's
|
|
78
80
|
`jti` last, then the action. Without an approval, answer `approval-required` with
|
|
79
|
-
`action_digest(action)` / `actionDigest(action)`
|
|
81
|
+
`action_digest(action)` / `actionDigest(action)` (the SHA-256 of the action's RFC 8785 form, `jcs`) so the caller
|
|
80
82
|
can ask the hub. When the meter denies a grant check, answer `refusal_from_denial(denial)` /
|
|
81
83
|
`refusalFromDenial(denial)`: the meter's code unchanged, its window and level in `error.data` (DL-21 step 6). Keep consumed ids in `FileJtiStore` (0600, survives a restart); `MemoryJtiStore` is for tests
|
|
82
84
|
and `UNSAFE_NO_JTI_STORE` exists only by name. No store at all, or a store file that cannot be read, is
|
|
83
|
-
`unknown-state
|
|
85
|
+
`unknown-state`, never a pass.
|
|
84
86
|
|
|
85
87
|
## What a refusal looks like
|
|
86
88
|
|
|
87
|
-
DL-19: an MCP tool answers `refusal_tool_result(r)` / `refusalToolResult(r)
|
|
89
|
+
DL-19: an MCP tool answers `refusal_tool_result(r)` / `refusalToolResult(r)`: `isError: true` and
|
|
88
90
|
`structuredContent: {error: {code, message, data: {detail}}}`; an HTTP route answers `refusal_http(r)` /
|
|
89
91
|
`refusalHttp(r)` with the code's status (401 for `unauthenticated`, `token-expired`, `principal-unproven`, with
|
|
90
92
|
`WWW-Authenticate: Bearer error="invalid_token"`; 503 for `issuer-unavailable` and `unknown-state`; 403 for the
|
|
91
|
-
rest). A published key the service cannot use
|
|
93
|
+
rest). A published key the service cannot use (of small order, for another use, or published twice) is the
|
|
92
94
|
issuer's fault, `issuer-unavailable` (DEC-0045); a gate without a trusted issuer refuses everything as
|
|
93
95
|
`no-trusted-issuer`. `detail` is a short machine word; the token, the approval and the keys never appear in a result or a log.
|
|
94
96
|
|
|
@@ -120,4 +122,4 @@ current verified revision as `estate=` / `{ estate }`, as a value or as a functi
|
|
|
120
122
|
## What the kit does not do
|
|
121
123
|
|
|
122
124
|
It does not mint tokens, check attenuation against a parent (the issuer's rule, DL-5), check a grant or a spend
|
|
123
|
-
window (the meter's, DL-21), or decide which actions need an approval
|
|
125
|
+
window (the meter's, DL-21), or decide which actions need an approval; the service decides that.
|
package/plugins/fabric-agent-adapter/skills/building-fabric-services/references/estate-record.md
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
# The estate record
|
|
1
|
+
# The estate record: what the operator's machines are, signed by their passkey (DEC-0055)
|
|
2
2
|
|
|
3
3
|
Fabric Agent Contract DEC-0055, `docs/specification/estate-record.md`, schema `schemas/estate-record.schema.json`,
|
|
4
|
-
rules `FAC-SEM-072…076`, with contexts (DEC-0082, `docs/specification/contexts.md`, `FAC-SEM-110`, `FAC-SEM-111`)
|
|
4
|
+
rules `FAC-SEM-072…076`, with contexts (DEC-0082, `docs/specification/contexts.md`, `FAC-SEM-110`, `FAC-SEM-111`) and a
|
|
5
|
+
partner's scoped publisher key (DEC-0090, `docs/specification/partner-channel.md`, `FAC-SEM-122`).
|
|
5
6
|
One revision of one person's estate lists:
|
|
6
7
|
- the passkeys that sign it;
|
|
7
8
|
- the machines, with their device keys and a certificate of each machine's hub key;
|
|
@@ -78,13 +79,13 @@ gate = fd.delegation_gate(audience=..., jwks=keys, issuer=..., effects=..., esta
|
|
|
78
79
|
estate_revocations=lambda: delta_entries)
|
|
79
80
|
```
|
|
80
81
|
|
|
81
|
-
- **The token's fault**
|
|
82
|
-
key or machine
|
|
82
|
+
- **The token's fault** (no such certification, another key under that `kid`, a `kid` on two machines, a revoked hub
|
|
83
|
+
key or machine) is `unauthenticated` (for an approval, `approval-invalid`) with detail `kid-not-certified`.
|
|
83
84
|
- **The trust source's fault** is `issuer-unavailable`: `estate-unreadable` (a source that throws or answers nothing
|
|
84
85
|
readable, a revision without a number or digest, a window of zero or over 30 days, dates read strictly, `machines` or
|
|
85
86
|
`revocations` not arrays), `estate-outside-window`, `estate-rolled-back` (lower than the applied revision) and
|
|
86
87
|
`estate-forked` (the applied number with another digest). A caller cannot cure these by minting again.
|
|
87
|
-
- An unreadable clock
|
|
88
|
+
- An unreadable clock (not a finite number of seconds a `Date` can hold) is refused `unknown-state` `no-clock`
|
|
88
89
|
before row 1, in every verifier.
|
|
89
90
|
- Only an absent `estate` skips the check. In the Node kit `null` is an unreadable source; in Python, where `None` is
|
|
90
91
|
the absent value, pass a function returning `None` for a source that has nothing.
|
|
@@ -117,6 +118,10 @@ of `[A-Za-z0-9][A-Za-z0-9_-]{0,127}`. Absent is `personal`; `null` is not absent
|
|
|
117
118
|
names the keys that are a partner's (`kid`, `partner: org:<id>`, `contexts`); a placement under such a key is in one
|
|
118
119
|
of the organization contexts listed, never `personal` or another organization. A key is scoped once, and only a key
|
|
119
120
|
`publisherKeys` pins. A key no scope names keeps DEC-0051's meaning, trusted in any context.
|
|
121
|
+
- **Update a copied kit before a revision carries `publisherScopes`.** A service runs the copy of the kit it was built
|
|
122
|
+
with; a copy older than 0.39.0 does not read `publisherScopes`, so it trusts a partner's key in every context and
|
|
123
|
+
finds no rule broken. A service that applies the estate record updates its copy of `fabric_estate.py` /
|
|
124
|
+
`fabric-estate.mjs` to 0.39.0 or later first.
|
|
120
125
|
|
|
121
126
|
Every rule is total on hostile JSON, as the contract's are: an `instancePath` names an item by its index as written (a
|
|
122
127
|
non-object before it does not shift it), and a value whose own `toString` member is data is shown as its JSON. Both kits
|
|
@@ -13,7 +13,7 @@ The feed is a view: never copy rows into a second store that can drift from the
|
|
|
13
13
|
|
|
14
14
|
## Reading a feed (FAC-SEM-036)
|
|
15
15
|
|
|
16
|
-
A client of `GET /fabric/v1/events`
|
|
16
|
+
A client of `GET /fabric/v1/events` (or of any token-protected route) sends the token in the
|
|
17
17
|
header the descriptor's `auth.header` names, in the form `auth.scheme` names: the raw token for
|
|
18
18
|
`none`, `Bearer <token>` for `Bearer`. Never assume `Authorization: Bearer`: a client that did
|
|
19
19
|
was refused on every poll and silently dropped every notify event. `token_header(auth, token)` /
|
|
@@ -27,7 +27,7 @@ in the URL.
|
|
|
27
27
|
- `level`: `info` (routine), `notice` (the operator may want to look), `warning`
|
|
28
28
|
(something is degrading), `error` (something failed and needs action).
|
|
29
29
|
- `text`: one sentence, in the operator's language, with the object named and the
|
|
30
|
-
number stated
|
|
30
|
+
number stated: "The Q3 report draft is ready for your approval (12 sections, 3
|
|
31
31
|
languages)." Never a machine id, never a stack trace.
|
|
32
32
|
- `subject`: what it is about (`{type: "report", id: "q3", label: "Q3 report"}`), so a host
|
|
33
33
|
can group.
|
|
@@ -42,11 +42,11 @@ lands on what matters:
|
|
|
42
42
|
|
|
43
43
|
| The operator… | Event | `notify` |
|
|
44
44
|
|---|---|---|
|
|
45
|
-
| must decide or act
|
|
46
|
-
| lost work
|
|
47
|
-
| will lose work soon
|
|
45
|
+
| must decide or act: a choice, an approval, a key to enter | kind says it: `job.awaiting_choice`, `plan.awaiting_approval`, `human_step.opened`; level `notice` | `true` |
|
|
46
|
+
| lost work: a job failed after its retries, a key expired | level `error`; kind `*.failed`, `*.expired` | `true` |
|
|
47
|
+
| will lose work soon: a degraded source that blocks orders | level `warning`, `service.degraded`, **once when it starts** | `true` |
|
|
48
48
|
| asked to be told when a long job finishes | `job.delivered`, level `notice` | `true` only if that person asked; a host may still keep it in Activity |
|
|
49
|
-
| only needs the record
|
|
49
|
+
| only needs the record: progress, retries, recoveries, syncs | `job.started`, `service.recovered`, `*.cleared`, level `info` or `notice` | `false` |
|
|
50
50
|
|
|
51
51
|
- **One episode, one request.** Notify on the transition, never on each poll: a source that
|
|
52
52
|
flaps between degraded and healthy sends `service.degraded` with `notify: true` once, and later
|
|
@@ -4,14 +4,14 @@ Normative source: the Fabric Agent Contract's `docs/specification/interop.md` (D
|
|
|
4
4
|
at the commit this plugin pins. This page says how the kit implements it; where the two
|
|
5
5
|
differ, the contract is right.
|
|
6
6
|
|
|
7
|
-
A service that other agents
|
|
7
|
+
A service that other agents (and Fabric) call does five things. Each has one helper in
|
|
8
8
|
`scripts/fabric_interop.py` (Python) and `scripts/fabric-interop.mjs` (Node).
|
|
9
9
|
|
|
10
10
|
| Rule | What the service does | Helper |
|
|
11
11
|
|---|---|---|
|
|
12
|
-
| C3.1 capability = tool | serves each `mcp` capability of its manifest as the MCP tool of the same name, with the manifest's input schema unchanged, its output schema unchanged
|
|
12
|
+
| C3.1 capability = tool | serves each `mcp` capability of its manifest as the MCP tool of the same name, with the manifest's input schema unchanged, its output schema unchanged (or, for a job, wrapped as `oneOf[result envelope, job handle]`) and annotations from the effect | `tool_for_capability` / `toolForCapability`, `job_tool_output_schema`, `expected_annotations` |
|
|
13
13
|
| C3.2 long work = job | a capability whose work can outlive one request declares `"job": true` in its interop block, returns `{"job": {"id", "status": "working"}}`, and serves `fabric.job.get` and `fabric.job.cancel` | `JobStore`, `McpToolServer` (Python), `unknown_job_result` |
|
|
14
|
-
| C3.2 result | a completed job carries the full result envelope
|
|
14
|
+
| C3.2 result | a completed job carries the full result envelope, the shape a synchronous call returns: `id`, `contractVersion`, `outcome`, `done`, `proof`, `scope`, `notVerified`, `artifacts`, `createdAt`, `producer`, `output`, `usage`, and its `trace` | `result_envelope` / `resultEnvelope` |
|
|
15
15
|
| C3.3 a person decides | the job goes `input_required` with an elicitation: a titled single-select in form mode, and URL mode for anything secret | `choice_request`, `form_request`, `url_request` |
|
|
16
16
|
| C3.4 trace | every call runs as a child span of the caller's `_meta.traceparent`; outgoing calls carry the same trace; the result envelope records it; events about traced work carry `traceId` and `spanId`, events about untraced work none | `child_traceparent`, `trace_ids`, `make_event(..., trace_id=, span_id=)` |
|
|
17
17
|
|
|
@@ -61,7 +61,7 @@ response = server.handle(json_rpc_message) # POST /mcp body in, JSON re
|
|
|
61
61
|
open with a handshake, and a server that refuses it is marked failed), `server/discover`,
|
|
62
62
|
`tools/list` and `tools/call` with JSON responses. Every tool's `outputSchema` must be
|
|
63
63
|
rooted at `type: object` (DEC-0018): `add_tool` refuses any other root, because a client may
|
|
64
|
-
drop the whole tool list over one bad schema
|
|
64
|
+
drop the whole tool list over one bad schema; an SDK-level test will not show it, so check
|
|
65
65
|
with the real client (below). A service already on an MCP SDK keeps
|
|
66
66
|
the SDK and uses only the helpers. The Node kit has the helpers and the same job file
|
|
67
67
|
format, without the dispatcher. `scripts/sample_service.py` is the worked example:
|
|
@@ -73,7 +73,7 @@ DEC-0017 amended by DEC-0018), so its `structuredContent` always conforms; an ev
|
|
|
73
73
|
untraced work carries no trace pair.
|
|
74
74
|
|
|
75
75
|
**Check with a real client**, never only an SDK: `FABRIC_REAL_CLIENT=1 python3 -m unittest
|
|
76
|
-
test.test_real_client` in the adapter repository, or by hand
|
|
76
|
+
test.test_real_client` in the adapter repository, or by hand: a throwaway directory, a
|
|
77
77
|
temporary `--mcp-config` (mode 600, the token in a header) and `--strict-mcp-config`, so
|
|
78
78
|
the operator's own configuration is not touched:
|
|
79
79
|
|
|
@@ -105,7 +105,9 @@ As a provider:
|
|
|
105
105
|
`limit_holds=False`, a `limit-reached` job once `approval_granted=True`, and an `outcome-unknown` job never.
|
|
106
106
|
- **Usage you did not measure is `null`, never 0,** but only toward a caller whose request `_meta.protocols` names
|
|
107
107
|
`fabric-interop/0.2`: pass `request_meta` to `result_envelope` (`usage_toward`). Toward any other caller the kit
|
|
108
|
-
writes the measured lower bound, as before.
|
|
108
|
+
writes the measured lower bound, as before. Either way, record that call's usage receipt with
|
|
109
|
+
`tokens_measured=False` / `tokensMeasured: false` and the tokens you have, so your own usage report counts it in
|
|
110
|
+
`unmeasuredCalls` and does not show the lower bound as complete (DEC-0091, [usage](usage.md)).
|
|
109
111
|
|
|
110
112
|
As a caller: send `request_meta(traceparent)` as your `_meta` (it names `fabric-interop/0.1` and `0.2`), act on every
|
|
111
113
|
`fabric.job.get` answer as `job_caller_action(answer, now)` says, and resend only under
|
package/plugins/fabric-agent-adapter/skills/building-fabric-services/references/lifecycle.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Lifecycle
|
|
1
|
+
# Lifecycle: supervisor, install, release layout, state
|
|
2
2
|
|
|
3
3
|
**This page is the rule** for anyone who builds, installs or runs a `fabric-service/0.1` service with this
|
|
4
4
|
skill. Everything you must follow is stated here or in the public Fabric Agent Contract's
|
|
@@ -56,17 +56,17 @@ that document until `service.id` matches (at most 40 s) before it calls the serv
|
|
|
56
56
|
| Id | Rule | Here | Kit (Python / Node) |
|
|
57
57
|
|---|---|---|---|
|
|
58
58
|
| LC-01 | **Quit reaches exit within a deadline.** Every trigger (`SIGTERM`, `SIGINT`, logout, the app's own quit) ends the process: within 5 s idle, within 10 s with work in flight, then a hard exit. Nothing starts after quit begins | [Shutdown](#shutdown) | `Drain` / `Drain` |
|
|
59
|
-
| LC-02 | **Every child has an owner, a deadline and a process group.** No subprocess without a timeout; on timeout or the parent's exit the whole group goes; no orphan survives. Locks and shared resources are released in `finally` | your own code |
|
|
59
|
+
| LC-02 | **Every child has an owner, a deadline and a process group.** No subprocess without a timeout; on timeout or the parent's exit the whole group goes; no orphan survives. Locks and shared resources are released in `finally` | your own code | none |
|
|
60
60
|
| LC-03 | **A job is bounded and exclusive.** One copy holds `service.lock`; a scheduled job has a watchdog shorter than its interval, shares its lock with every manual entry point, bounds every network call and records each run's outcome. Long work is journalled before it starts | [One copy under a supervisor](#one-copy-under-a-supervisor) | `hold_single_instance` / `holdSingleInstance` |
|
|
61
|
-
| LC-04 | **Credentials are silent after setup.** No background prompt; a credential read that is denied or absent is cached and backs off until a person acts | [Directories](#directories) (secret files 0600) |
|
|
62
|
-
| LC-05 | **Identity is stable across updates.** The supervisor runs a stable executable inside a release directory, never an interpreter by a versioned package-manager path; signed builds are pinned by team and identifier | [launchd plist](#launchd-plist-generate-it-with-launchd_plist-or-launchdplist-both-kits-write-the-same-bytes) |
|
|
61
|
+
| LC-04 | **Credentials are silent after setup.** No background prompt; a credential read that is denied or absent is cached and backs off until a person acts | [Directories](#directories) (secret files 0600) | none |
|
|
62
|
+
| LC-05 | **Identity is stable across updates.** The supervisor runs a stable executable inside a release directory, never an interpreter by a versioned package-manager path; signed builds are pinned by team and identifier | [launchd plist](#launchd-plist-generate-it-with-launchd_plist-or-launchdplist-both-kits-write-the-same-bytes) | none |
|
|
63
63
|
| LC-09 | **The footprint is declared.** The service's `AGENTS.md` names every resident process, its supervisor label, unit or task and its port, who starts each and who stops it | the descriptor and the supervisor file | `write_descriptor`, `launchd_plist`, `systemd_unit` / `systemdUnit`, `task_xml` / `taskXml` |
|
|
64
64
|
| LC-11 | **An update is a lifecycle event.** An upgrade writes a new immutable release and restarts through the supervisor; the previous release is kept for rollback, older ones are pruned | [Install, upgrade, uninstall](#install-upgrade-uninstall) | `prune_releases` / `pruneReleases` |
|
|
65
65
|
| LC-12 | **Every file is bounded.** Logs rotate by size (5 × 5 MB), mode 0600, never in `/tmp`; temporary leftovers are swept at start | [Logs](#logs) | `RotatingLog`, `cap_stdout_log` / `RotatingLog`, `capStdoutLog` |
|
|
66
66
|
| LC-14 | **The operator's intent wins; uninstall is symmetric.** No install or upgrade re-enables what the operator turned off; uninstall removes what install added (supervisor file, override, descriptor), and data goes only on an explicit purge | [Install, upgrade, uninstall](#install-upgrade-uninstall), [Linux and Windows](#linux-and-windows) | `launchd_install` / `launchdInstall`, `launchd_uninstall` / `launchdUninstall`; `systemd_install` / `systemdInstall`, `task_install` / `taskInstall` and their uninstalls |
|
|
67
67
|
| LC-15 | **Builds clean up after themselves.** At most the current release and the one before it remain; the prune runs inside the installer, not later | [Install, upgrade, uninstall](#install-upgrade-uninstall) | `prune_releases` / `pruneReleases` |
|
|
68
68
|
| LC-21 | **A secret never travels in a command line.** Keys reach the process through its environment, a 0600 file or a vault, never argv; a supervisor file carries no secret | [launchd plist](#launchd-plist-generate-it-with-launchd_plist-or-launchdplist-both-kits-write-the-same-bytes), [Linux and Windows](#linux-and-windows) | the supervisor-file writers refuse a secret-shaped value |
|
|
69
|
-
| LC-22 | **Work survives a restart.** Work started but not finished is journalled on disk, without secrets, before it starts; the restarted service takes it back or cleans it up | [Shutdown](#shutdown) |
|
|
69
|
+
| LC-22 | **Work survives a restart.** Work started but not finished is journalled on disk, without secrets, before it starts; the restarted service takes it back or cleans it up | [Shutdown](#shutdown) | none (the service's own journal) |
|
|
70
70
|
|
|
71
71
|
## launchd plist (generate it with `launchd_plist` or `launchdPlist`; both kits write the same bytes)
|
|
72
72
|
|
|
@@ -78,8 +78,8 @@ that document until `service.id` matches (at most 40 s) before it calls the serv
|
|
|
78
78
|
| `KeepAlive` | `true` | `{SuccessfulExit:false}` leaves a cleanly exited service down |
|
|
79
79
|
| `ThrottleInterval` | `10` | bounds a crash loop |
|
|
80
80
|
| `ExitTimeOut` | above the drain and its hard exit (15 s default; `Drain` ends by 10 s) | SIGKILL arrives after it, so it must never come first |
|
|
81
|
-
| `ProcessType` | `Standard
|
|
82
|
-
| `EnvironmentVariables` | `PATH` set explicitly; `*_FILE` paths to secrets; `FABRIC_SERVICE_SUPERVISOR=launchd` | never a secret value
|
|
81
|
+
| `ProcessType` | `Standard`, never `Background`, and no `Nice` > 0 or `LowPriorityIO` | a host probes the service and agents call it while the Mac is busy; a background job is starved for tens of seconds under load and every host reports an outage that never happened (the probe's `lifecycle.priority` rule fails it) |
|
|
82
|
+
| `EnvironmentVariables` | `PATH` set explicitly; `*_FILE` paths to secrets; `FABRIC_SERVICE_SUPERVISOR=launchd` | never a secret value: the plist is world-readable in backups; the supervisor marker is how the lock knows to back off (the probe's `lifecycle.supervisor-marker` rule fails a plist without it: a copy that finds the lock held would exit 75 at once into a respawn every `ThrottleInterval`) |
|
|
83
83
|
| `StandardOutPath`/`StandardErrorPath` | `~/Library/Logs/<id>/service.log` | one place the host tails |
|
|
84
84
|
|
|
85
85
|
## Install, upgrade, uninstall
|
|
@@ -103,13 +103,13 @@ that document until `service.id` matches (at most 40 s) before it calls the serv
|
|
|
103
103
|
rewrites the plist, so the new release is what starts once they turn it back on, and
|
|
104
104
|
answers `{"disabled": true, ...}` instead of the well-known document. `force_enable=True`
|
|
105
105
|
is for an operator who asked for the service to be switched on. The service never
|
|
106
|
-
implements these verbs itself
|
|
106
|
+
implements these verbs itself; its CLI calls launchctl the same way.
|
|
107
107
|
|
|
108
108
|
**Uninstall is symmetric.** `launchd_uninstall` boots the job out and **waits** until
|
|
109
109
|
launchd reports it gone (it raises, removing nothing, if the job is still loaded at the
|
|
110
110
|
timeout), removes the plist, and resets the override to `enabled`. launchctl has no verb
|
|
111
111
|
that deletes an override, and a leftover `disabled` would make a later fresh install stay
|
|
112
|
-
off. Tests use a throwaway label or a fake `launchctl` first on `PATH
|
|
112
|
+
off. Tests use a throwaway label or a fake `launchctl` first on `PATH`, never the
|
|
113
113
|
operator's real jobs.
|
|
114
114
|
|
|
115
115
|
## One copy under a supervisor
|
|
@@ -118,7 +118,7 @@ Started by hand, a copy that finds `service.lock` held prints one sentence namin
|
|
|
118
118
|
holder (or saying the holder is unknown, when its pid cannot be read) and exits 75 at once.
|
|
119
119
|
Under launchd that exit is a respawn every `ThrottleInterval` (10 s), forever, and under
|
|
120
120
|
systemd one every `RestartSec`. So a copy its supervisor started, and that says so with the
|
|
121
|
-
**supervisor marker**, backs off in-process
|
|
121
|
+
**supervisor marker**, backs off in-process (0.5 s doubling to 30 s, 300 s in all), takes over
|
|
122
122
|
if the holder leaves, and exits 75 only when the wait runs out: a few starts an hour instead of
|
|
123
123
|
360. It touches nothing while it waits. Two installs sharing one data directory are still the
|
|
124
124
|
defect to remove; the back-off only stops the loop from costing the machine.
|
|
@@ -136,8 +136,8 @@ never infers supervision from its parent process.
|
|
|
136
136
|
`supervised` (with the manager), `manual` or `conflict`. Only an empty variable counts as no
|
|
137
137
|
marker; a bare `--fabric-supervisor` (followed by nothing, by `--` or by another `--…` flag,
|
|
138
138
|
none of which it consumes) names no manager.
|
|
139
|
-
- Markers that disagree
|
|
140
|
-
twice, or a bare or empty argument beside the variable
|
|
139
|
+
- Markers that disagree (the variable and the argument with different values, the argument
|
|
140
|
+
twice, or a bare or empty argument beside the variable) exit 75 at once, before the lock and
|
|
141
141
|
whether or not it is held, naming both markers.
|
|
142
142
|
- A service's own argument parser accepts the flag in both spellings and ignores it: in Python,
|
|
143
143
|
`add_supervisor_argument(parser)` (argparse otherwise exits 2 on an unknown flag); the sample
|
|
@@ -152,8 +152,8 @@ never infers supervision from its parent process.
|
|
|
152
152
|
`"lifecycle": {"manager": "person", "app": "<the installed bundle or executable>"}`, `installedBy {by: "person", role,
|
|
153
153
|
tool}` and no `origin`: it says the app is installed, never that it runs. The installer writes it; where there is none
|
|
154
154
|
(a macOS app dragged into Applications), the app writes it on a start when `app_descriptor_action` /
|
|
155
|
-
`appDescriptorAction` answers `write`
|
|
156
|
-
`lifecycle.app`
|
|
155
|
+
`appDescriptorAction` answers `write` (no descriptor yet, another version in `installedBy.tool`, or another path than
|
|
156
|
+
`lifecycle.app`), and never from an App Translocation path. Its live origin and process id go in its own liveness file,
|
|
157
157
|
rewritten on every start and removed on quit; a caller that sends anything reads that file and checks the process.
|
|
158
158
|
`write_descriptor` claims no port for it, and a reader that finds `lifecycle.app` gone treats the descriptor as stale.
|
|
159
159
|
|
|
@@ -179,8 +179,8 @@ anything the operator would miss belongs in data.
|
|
|
179
179
|
|
|
180
180
|
## Logs
|
|
181
181
|
|
|
182
|
-
One structured log (JSON lines) rotated by size
|
|
183
|
-
5 × 5 MB by default, files 0600 in a 0700 directory
|
|
182
|
+
One structured log (JSON lines) rotated by size (`RotatingLog(dirs["logs"] / "service.jsonl")`,
|
|
183
|
+
5 × 5 MB by default, files 0600 in a 0700 directory), plus the launchd stdout file, which
|
|
184
184
|
`cap_stdout_log` copies to `.1` and truncates at start once it passes 5 MB (launchd holds it
|
|
185
185
|
open for append, so it is truncated in place, never renamed). Configure logging once, in the
|
|
186
186
|
entry point. Never log a token, a cookie, a login code or a request body that may carry one.
|
|
@@ -189,7 +189,7 @@ entry point. Never log a token, a cookie, a login code or a request body that ma
|
|
|
189
189
|
|
|
190
190
|
On `SIGTERM`: stop accepting new work, append a `service.stopping` event, drain
|
|
191
191
|
in-flight work, persist what was interrupted so the next start resumes it, release the
|
|
192
|
-
lock, exit 0
|
|
192
|
+
lock, exit 0, within 10 s with work in flight (LC-01). `Drain` does the timing:
|
|
193
193
|
|
|
194
194
|
```python
|
|
195
195
|
drain = fs.Drain() # drain 8 s, hard exit 2 s later (EXIT_HARD_STOP, 70)
|
|
@@ -208,8 +208,8 @@ A host may run a lifecycle broker: one always-on per-user service that agents as
|
|
|
208
208
|
stop and restart products, instead of launching or killing them themselves. A product it manages
|
|
209
209
|
has to survive being driven from outside:
|
|
210
210
|
|
|
211
|
-
- **Quit reaches exit through both doors.** A broker asks the platform's own quit first
|
|
212
|
-
macOS `NSRunningApplication.terminate()`, the path Cmd+Q and the Dock take
|
|
211
|
+
- **Quit reaches exit through both doors.** A broker asks the platform's own quit first (on
|
|
212
|
+
macOS `NSRunningApplication.terminate()`, the path Cmd+Q and the Dock take) and `SIGTERM` a few
|
|
213
213
|
seconds later. Handle both and exit inside the deadline (LC-01). A desktop app
|
|
214
214
|
that answers `SIGTERM` by closing its window and staying alive is stopped late or not at all.
|
|
215
215
|
- **A background launch stays in the background.** A broker opens the app non-activating
|
|
@@ -219,8 +219,8 @@ has to survive being driven from outside:
|
|
|
219
219
|
- **Identity is the designated requirement.** A broker pins the app by team + bundle id, so an
|
|
220
220
|
update signed by the same team keeps working and anything else is refused (LC-05). Never ship an
|
|
221
221
|
ad-hoc or differently signed build to a machine that pins you.
|
|
222
|
-
- **Starting is not ready.** Expose readiness the broker can probe without a person
|
|
223
|
-
well-known document for a service, a process-level answer for a plain app
|
|
222
|
+
- **Starting is not ready.** Expose readiness the broker can probe without a person (the
|
|
223
|
+
well-known document for a service, a process-level answer for a plain app) and keep it honest
|
|
224
224
|
while the app is still starting.
|
|
225
225
|
|
|
226
226
|
## Linux and Windows
|
|
@@ -230,7 +230,7 @@ Both kits write and install the supervisor file the contract names (DEC-0032, se
|
|
|
230
230
|
secret: the writers refuse a credential-shaped argument, environment name or value, and any
|
|
231
231
|
control character (a line break would end a unit line early).
|
|
232
232
|
|
|
233
|
-
**Linux
|
|
233
|
+
**Linux: a systemd user unit.** `systemd_unit(unit, argv, working_directory=…)` /
|
|
234
234
|
`systemdUnit(unit, argv, {workingDirectory})` writes `Restart=always`, `RestartSec=10`,
|
|
235
235
|
`TimeoutStopSec` above the drain (15 s default), `KillMode=mixed`, `WantedBy=default.target`
|
|
236
236
|
and `FABRIC_SERVICE_SUPERVISOR=systemd` (always, whatever the caller passed), quoting every argument (`%` → `%%`, `$` → `$$`).
|
|
@@ -247,7 +247,7 @@ descriptor says `"lifecycle": {"manager": "systemd", "unit": "<id>.<instance>.se
|
|
|
247
247
|
A user unit runs while the person is logged in; one that must run without a session needs
|
|
248
248
|
`loginctl enable-linger <user>`, which is the operator's decision, not the installer's.
|
|
249
249
|
|
|
250
|
-
**Windows
|
|
250
|
+
**Windows: a per-user Scheduled Task.** `task_xml(task, argv, working_directory=…)` /
|
|
251
251
|
`taskXml(task, argv, {workingDirectory})` writes a task with a logon trigger for the current
|
|
252
252
|
user, `InteractiveToken` and `LeastPrivilege` (no administrator rights), restart on failure
|
|
253
253
|
every minute, no execution time limit and `MultipleInstancesPolicy` `IgnoreNew`, its settings in the
|
|
@@ -269,16 +269,16 @@ starting a second copy. Measured (FAA-38, [report](https://github.com/passioncod
|
|
|
269
269
|
that still exits 75 stays down until the next logon.
|
|
270
270
|
|
|
271
271
|
**One copy on each system.** The Python kit takes `flock` (Linux) or a locked byte
|
|
272
|
-
(Windows); the Node kit cannot, so it holds a name instead
|
|
272
|
+
(Windows); the Node kit cannot, so it holds a name instead: an abstract unix socket on Linux,
|
|
273
273
|
a named pipe on Windows (`lock_name` / `lockName`), each gone with the process. The Python kit
|
|
274
274
|
holds the same name beside its file lock, so the two kits exclude each other everywhere, and
|
|
275
275
|
`check_service.py` reports the lock held when either is. The probe only looks (`/proc/net/unix`,
|
|
276
276
|
`WaitNamedPipeW`); it never takes the name, so it cannot make a service that is starting fail.
|
|
277
277
|
|
|
278
278
|
**Token files on Windows.** The privacy of `service.token` is its ACL (service.md *Windows
|
|
279
|
-
token files*): the kits write a protected list
|
|
279
|
+
token files*): the kits write a protected list: the user, SYSTEM and Administrators, set before the
|
|
280
280
|
token's bytes go in, any entry already there dropped. On read, `windows_token_acl_problem` /
|
|
281
|
-
`windowsTokenAclProblem` decide over what was read
|
|
281
|
+
`windowsTokenAclProblem` decide over what was read: the file's flags, its owner SID and each ACE
|
|
282
282
|
as `{type, sid, mask}` (DEC-0057, `FAC-SEM-079`, held to the contract's
|
|
283
283
|
`fixtures/vectors/windows-token.json`): a reparse point, a directory, a real path outside the
|
|
284
284
|
profile, another owner, an allow ACE with a non-zero mask for any other SID, an ACE of another type
|
|
@@ -8,7 +8,7 @@ Order matters: each step leaves the service answering.
|
|
|
8
8
|
2. **Add the well-known route and the build identity.** Read-only, no risk.
|
|
9
9
|
3. **Add the events view** over the existing log, then the login-code routes. Keep the
|
|
10
10
|
service's old login path until the operator has switched.
|
|
11
|
-
4. **Move the lock to the top of startup
|
|
11
|
+
4. **Move the lock to the top of startup**, before the startup hook that resumes jobs.
|
|
12
12
|
Test: a second copy exits 75 and the first copy's running jobs are untouched.
|
|
13
13
|
5. **Move state out of the code tree** if it lives there: copy to the OS data
|
|
14
14
|
directory, switch the paths, keep the old tree read-only for one release, then
|