pi-daddy 0.18.0 → 0.19.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.
- package/CHANGELOG.md +154 -0
- package/README.md +46 -2
- package/contracts/ledger/v2/README.md +59 -0
- package/contracts/ledger/v2/fixtures/capability-decision.json +95 -0
- package/contracts/ledger/v2/fixtures/check-receipt.json +40 -0
- package/contracts/ledger/v2/fixtures/child-lifecycle.json +42 -0
- package/contracts/ledger/v2/fixtures/workspace-lease.json +41 -0
- package/contracts/ledger/v2/ledger-event.schema.json +633 -0
- package/dist/approval-prompt.d.ts +2 -1
- package/dist/approval-prompt.d.ts.map +1 -1
- package/dist/approval-prompt.js +9 -0
- package/dist/approval-prompt.js.map +1 -1
- package/dist/approval.d.ts +4 -2
- package/dist/approval.d.ts.map +1 -1
- package/dist/approval.js +4 -0
- package/dist/approval.js.map +1 -1
- package/dist/capabilities.d.ts +105 -0
- package/dist/capabilities.d.ts.map +1 -1
- package/dist/capabilities.js +161 -3
- package/dist/capabilities.js.map +1 -1
- package/dist/catalog.d.ts +15 -1
- package/dist/catalog.d.ts.map +1 -1
- package/dist/catalog.js +54 -3
- package/dist/catalog.js.map +1 -1
- package/dist/check-runner.d.ts.map +1 -1
- package/dist/check-runner.js +5 -7
- package/dist/check-runner.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +21 -1
- package/dist/cli.js.map +1 -1
- package/dist/definitions.d.ts.map +1 -1
- package/dist/definitions.js +7 -1
- package/dist/definitions.js.map +1 -1
- package/dist/delegate.d.ts.map +1 -1
- package/dist/delegate.js +32 -4
- package/dist/delegate.js.map +1 -1
- package/dist/delegation-approval.d.ts.map +1 -1
- package/dist/delegation-approval.js +37 -12
- package/dist/delegation-approval.js.map +1 -1
- package/dist/executor.d.ts +2 -1
- package/dist/executor.d.ts.map +1 -1
- package/dist/executor.js +1 -0
- package/dist/executor.js.map +1 -1
- package/dist/grant-env.d.ts +2 -0
- package/dist/grant-env.d.ts.map +1 -1
- package/dist/grant-env.js +26 -3
- package/dist/grant-env.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/init.d.ts +13 -1
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +35 -2
- package/dist/init.js.map +1 -1
- package/dist/lease-helper.d.ts +58 -0
- package/dist/lease-helper.d.ts.map +1 -0
- package/dist/lease-helper.js +94 -0
- package/dist/lease-helper.js.map +1 -0
- package/dist/lease-record.d.ts +15 -3
- package/dist/lease-record.d.ts.map +1 -1
- package/dist/lease-record.js.map +1 -1
- package/dist/ledger-events.d.ts +35 -14
- package/dist/ledger-events.d.ts.map +1 -1
- package/dist/ledger-events.js +41 -0
- package/dist/ledger-events.js.map +1 -1
- package/dist/ledger.d.ts +10 -5
- package/dist/ledger.d.ts.map +1 -1
- package/dist/ledger.js +13 -3
- package/dist/ledger.js.map +1 -1
- package/dist/propagation.d.ts +16 -0
- package/dist/propagation.d.ts.map +1 -1
- package/dist/propagation.js +22 -2
- package/dist/propagation.js.map +1 -1
- package/dist/refusals.d.ts +1 -1
- package/dist/refusals.d.ts.map +1 -1
- package/dist/refusals.js +2 -0
- package/dist/refusals.js.map +1 -1
- package/dist/resolve.d.ts +10 -0
- package/dist/resolve.d.ts.map +1 -1
- package/dist/resolve.js +33 -3
- package/dist/resolve.js.map +1 -1
- package/dist/routing-authority.d.ts +71 -0
- package/dist/routing-authority.d.ts.map +1 -0
- package/dist/routing-authority.js +100 -0
- package/dist/routing-authority.js.map +1 -0
- package/dist/skill-packages.d.ts +11 -5
- package/dist/skill-packages.d.ts.map +1 -1
- package/dist/skill-packages.js +20 -11
- package/dist/skill-packages.js.map +1 -1
- package/dist/workspace-lease.d.ts +15 -3
- package/dist/workspace-lease.d.ts.map +1 -1
- package/dist/workspace-lease.js +81 -24
- package/dist/workspace-lease.js.map +1 -1
- package/dist/workspace.d.ts +25 -0
- package/dist/workspace.d.ts.map +1 -1
- package/dist/workspace.js +142 -5
- package/dist/workspace.js.map +1 -1
- package/extensions/delegation.ts +7 -1
- package/extensions/grants-command.ts +11 -1
- package/extensions/grants.ts +6 -1
- package/extensions/init-command.ts +33 -2
- package/extensions/session-report.ts +13 -20
- package/extensions/session.ts +9 -1
- package/extensions/workspace-runtime.ts +34 -4
- package/package.json +8 -3
- package/src/approval-prompt.ts +2 -1
- package/src/approval.ts +4 -2
- package/src/capabilities.ts +173 -4
- package/src/catalog.ts +62 -4
- package/src/check-runner.ts +8 -8
- package/src/cli.ts +24 -1
- package/src/definitions.ts +7 -1
- package/src/delegate.ts +42 -4
- package/src/delegation-approval.ts +37 -12
- package/src/executor.ts +2 -1
- package/src/grant-env.ts +39 -7
- package/src/index.ts +1 -0
- package/src/init.ts +40 -2
- package/src/lease-helper.ts +97 -0
- package/src/lease-record.ts +15 -3
- package/src/ledger-events.ts +66 -22
- package/src/ledger.ts +30 -6
- package/src/propagation.ts +23 -2
- package/src/refusals.ts +2 -0
- package/src/resolve.ts +35 -3
- package/src/routing-authority.ts +121 -0
- package/src/skill-packages.ts +20 -13
- package/src/workspace-lease.ts +84 -24
- package/src/workspace.ts +179 -6
package/dist/approval.d.ts
CHANGED
|
@@ -11,9 +11,11 @@
|
|
|
11
11
|
import type { Capability, ResolveResult } from "./resolve.ts";
|
|
12
12
|
import { type ApprovalBinding } from "./correlation.ts";
|
|
13
13
|
/** How far a single yes reaches in time. */
|
|
14
|
-
export
|
|
14
|
+
export declare const APPROVAL_SCOPES: readonly ["once", "session", "always"];
|
|
15
|
+
export type ApprovalScope = typeof APPROVAL_SCOPES[number];
|
|
15
16
|
/** Where a yes came from, for the ledger. These call for different follow-ups, so they stay distinct. */
|
|
16
|
-
export
|
|
17
|
+
export declare const APPROVAL_SOURCES: readonly ["prompt", "session", "persisted", "inherited"];
|
|
18
|
+
export type ApprovalSource = typeof APPROVAL_SOURCES[number];
|
|
17
19
|
/** Which call site is asking. Determines the scopes offered — see `offeredScopes`. */
|
|
18
20
|
export type ApprovalPath = "definition" | "delegate";
|
|
19
21
|
/**
|
package/dist/approval.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"approval.d.ts","sourceRoot":"","sources":["../src/approval.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAyB,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAE/E,4CAA4C;AAC5C,MAAM,MAAM,aAAa,GAAG,
|
|
1
|
+
{"version":3,"file":"approval.d.ts","sourceRoot":"","sources":["../src/approval.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAyB,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAE/E,4CAA4C;AAC5C,eAAO,MAAM,eAAe,wCAAyC,CAAC;AACtE,MAAM,MAAM,aAAa,GAAG,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC;AAE3D,yGAAyG;AACzG,eAAO,MAAM,gBAAgB,0DAA2D,CAAC;AACzF,MAAM,MAAM,cAAc,GAAG,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC;AAE7D,sFAAsF;AACtF,MAAM,MAAM,YAAY,GAAG,YAAY,GAAG,UAAU,CAAC;AAErD;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,eAAe,CAAC;AAE7C;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAIpC,gEAAgE;AAChE,wBAAgB,WAAW,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAE3E;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,aAAa,GAAG,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IAC9B,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;IAC5C,MAAM,EAAE,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;IAC1C,SAAS,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;CACvC;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,sBAAsB,CAwCrF"}
|
package/dist/approval.js
CHANGED
|
@@ -10,6 +10,10 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import { WILDCARD } from "./pi-tools.js";
|
|
12
12
|
import { approvalBindingsEqual } from "./correlation.js";
|
|
13
|
+
/** How far a single yes reaches in time. */
|
|
14
|
+
export const APPROVAL_SCOPES = ["once", "session", "always"];
|
|
15
|
+
/** Where a yes came from, for the ledger. These call for different follow-ups, so they stay distinct. */
|
|
16
|
+
export const APPROVAL_SOURCES = ["prompt", "session", "persisted", "inherited"];
|
|
13
17
|
/**
|
|
14
18
|
* Subject used for delegate-path approvals.
|
|
15
19
|
*
|
package/dist/approval.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"approval.js","sourceRoot":"","sources":["../src/approval.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,qBAAqB,EAAwB,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"approval.js","sourceRoot":"","sources":["../src/approval.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,qBAAqB,EAAwB,MAAM,kBAAkB,CAAC;AAE/E,4CAA4C;AAC5C,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,QAAQ,CA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C;YAAC,OAAO,CAAC,UAAU,CAAC,GAAG,WAAW,CAAC;YAAC,MAAM,CAAC,UAAU,CAAC,GAAG,SAAS,CAAC;QAC/F,CAAC;aAAM,IAAI,oBAAoB,IAAI,mBAAmB,EAAE,CAAC;YACvD,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAAC,OAAO,CAAC,UAAU,CAAC,GAAG,SAAS,CAAC;YAAC,MAAM,CAAC,UAAU,CAAC,GAAG,SAAS,CAAC;QAC7F,CAAC;aAAM,IAAI,gBAAgB,EAAE,CAAC;YAC5B,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAAC,OAAO,CAAC,UAAU,CAAC,GAAG,WAAW,CAAC;YAAC,MAAM,CAAC,UAAU,CAAC,GAAG,QAAQ,CAAC;YAC5F,SAAS,CAAC,UAAU,CAAC,GAAG,SAAU,CAAC,SAAS,CAAC;QAC/C,CAAC;aAAM,CAAC;YACN,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAC7B,IAAI,KAAK,CAAC,WAAW,EAAE,GAAG,CAAC,GAAG,CAAC;gBAAE,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;iBACrD,IAAI,QAAQ,KAAK,SAAS,IAAI,CAAC,cAAc,KAAK,SAAS,IAAI,SAAS,KAAK,SAAS,IAAI,KAAK,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;gBAChI,eAAe,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YACnC,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,eAAe,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;AACzF,CAAC"}
|
package/dist/capabilities.d.ts
CHANGED
|
@@ -26,6 +26,111 @@ export declare const agentCapability: (name: string) => Capability;
|
|
|
26
26
|
export declare function maySpawnDefinition(ownGrant: Capability[], name: string): boolean;
|
|
27
27
|
/** The tool name that confers the ability to delegate further. */
|
|
28
28
|
export declare const DELEGATE_CAPABILITY: Capability;
|
|
29
|
+
/**
|
|
30
|
+
* Every namespace a capability id may carry, as its literal prefix.
|
|
31
|
+
*
|
|
32
|
+
* **One list, because there were three and adding a namespace only updated some of them.** ADR-0035 taught
|
|
33
|
+
* `normaliseCapability` about `workspace:` and left `ceilingForDefinition` (which mangled it into
|
|
34
|
+
* `tool:workspace:<id>`) and `isSafeCapability` (which called it malformed) behind. The two places that parse
|
|
35
|
+
* an id's namespace read this, so a fifth namespace is one entry rather than a third divergence.
|
|
36
|
+
*
|
|
37
|
+
* **Not every prefix decision in the package.** Inline `startsWith("` tests on a capability namespace are
|
|
38
|
+
* scattered across `src/` and `extensions/`; this list is read by two of them. **No number is written here,
|
|
39
|
+
* and the history is why:** SPEC first claimed the list was "what every site reads"; a correction said "six"
|
|
40
|
+
* while its own enumeration listed seven; this docstring then said "nine" in the sentence claiming it gave no
|
|
41
|
+
* number; and the correction to *that* said "fourteen", which counted every file containing any
|
|
42
|
+
* `startsWith("` — CLI flags, `git worktree list` parsing, an assurance sentinel and node_modules entries
|
|
43
|
+
* among them. Four numbers, four wrong. The command, so nobody has to quote a predecessor:
|
|
44
|
+
*
|
|
45
|
+
* grep -rl 'startsWith("\(tool:\|ext:\|agent:\|skill:\|workspace:\)' src extensions
|
|
46
|
+
*
|
|
47
|
+
* Consolidating the sites is a separate change, and a count nobody re-derives is the defect this list exists
|
|
48
|
+
* to prevent.
|
|
49
|
+
*
|
|
50
|
+
* `docs/SPEC.md`'s grammar section is the prose statement of the same list and is kept in step with it.
|
|
51
|
+
*/
|
|
52
|
+
export declare const CAPABILITY_NAMESPACE_PREFIXES: readonly ["tool:", "ext:", "skill:", "agent:", "workspace:"];
|
|
29
53
|
/** Accept `read` or `tool:read` or `ext:pkg/tool` and normalise to a capability id. */
|
|
30
54
|
export declare function normaliseCapability(raw: string): Capability;
|
|
55
|
+
/** The capability that authorises routing a child to one registered workspace (ADR-0035). */
|
|
56
|
+
export declare function workspaceCapability(workspaceId: string): Capability;
|
|
57
|
+
/**
|
|
58
|
+
* May this session route a child to workspace `id`?
|
|
59
|
+
*
|
|
60
|
+
* Mirrors `maySpawnDefinition` deliberately — same shape, same wildcard handling, same reason. Routing was
|
|
61
|
+
* the one governance dimension that did not attenuate (R-131, measured in
|
|
62
|
+
* `docs/probes/g36-workspace-attenuation`): the registry inherited into every child and nothing checked the
|
|
63
|
+
* caller's authority, so a child routed to `staging` could route its grandchild to `prod`.
|
|
64
|
+
*
|
|
65
|
+
* `tool:*` satisfies it because governance is opt-in — an ungoverned session holds the wildcard and must
|
|
66
|
+
* keep working exactly as before.
|
|
67
|
+
*/
|
|
68
|
+
export declare function mayRouteToWorkspace(ownGrant: readonly Capability[], workspaceId: string): boolean;
|
|
69
|
+
/** False when an id would be read as more than one capability by any channel that carries it. */
|
|
70
|
+
export declare function isWellFormedCapability(id: string): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* The STRICT grammar: a whitelist of what a capability id may look like, not a blocklist of what it may not.
|
|
73
|
+
*
|
|
74
|
+
* **Two consumers, and they are two different reasons for the same rule.** It lives here rather than in
|
|
75
|
+
* either of them because it shipped in one and was needed by both:
|
|
76
|
+
*
|
|
77
|
+
* 1. `skill-packages.ts` — the boundary that GENERATES a grant. R-77/R-78: a package declaring
|
|
78
|
+
* `allowed-tools: Read,ext:x";touch /tmp/pwned;PI_GRANTS_GRANT="` produced a `.pi/grants.env` that ran
|
|
79
|
+
* arbitrary code the moment an operator sourced the line `init` prints.
|
|
80
|
+
* 2. `workspace.ts` — the operator registry, since ADR-0035 made a registry id the tail of a capability id
|
|
81
|
+
* (`workspace:<id>`). That made the registry an input to this grammar, and it got the LOOSE
|
|
82
|
+
* `isWellFormedCapability` blocklist instead, which review showed costs three things:
|
|
83
|
+
* an id of literally `*` loaded and minted `WORKSPACE_WILDCARD`, so an operator naming ONE worktree held
|
|
84
|
+
* routing authority over every id in the registry including ones added later;
|
|
85
|
+
* an id containing a space became TWO capabilities, because `ceilingForDefinition` splits `allowed-tools`
|
|
86
|
+
* on `[\s,]+` — `allowed-tools: read, workspace:prod bash` measured as
|
|
87
|
+
* `['tool:bash','tool:read','workspace:prod']`, i.e. routing over production plus a shell, neither typed
|
|
88
|
+
* by anyone (0.18.1's comma, one namespace over);
|
|
89
|
+
* and quote/`$()`/backtick ids reached the `ROUTABLE WORKSPACES` block of the generated file, whose own
|
|
90
|
+
* instructions tell the operator to paste them into `PI_GRANTS_GRANT`.
|
|
91
|
+
*
|
|
92
|
+
* **A blocklist was the wrong shape for this and the comment on `isWellFormedCapability` says why it is the
|
|
93
|
+
* right shape THERE**: that one guards the enforcement path, which must keep accepting whatever ids operators
|
|
94
|
+
* already have. A registry is a file the operator writes and can rename, so refusing a hostile id costs
|
|
95
|
+
* nothing — and `grant-env.ts`'s standing warning applies to it exactly: *"the third channel — whatever it
|
|
96
|
+
* turns out to be — should cost a refusal rather than an injection."* The registry was the third channel.
|
|
97
|
+
*/
|
|
98
|
+
/**
|
|
99
|
+
* A workspace registry id, which is NOT a tool name and needed its own rule.
|
|
100
|
+
*
|
|
101
|
+
* `isSafeCapability` was reused here first, and that was the error: it is the grammar for a *tool* name, and
|
|
102
|
+
* it refused ids that published 0.18.1 accepted — `feature/x` above all. Git worktrees are routinely named
|
|
103
|
+
* after their branch, so a slash is the ordinary case, and a slash splits nothing: not the comma-separated
|
|
104
|
+
* grant, not `allowed-tools`' `[\s,]+`. Refusing it bought no safety and broke the common setup.
|
|
105
|
+
*
|
|
106
|
+
* What is refused, and why each one earns it:
|
|
107
|
+
* - **whitespace** — `ceilingForDefinition` splits `allowed-tools` on `[\s,]+`, so `workspace:prod bash`
|
|
108
|
+
* measured as `['tool:bash','tool:read','workspace:prod']`: routing over production plus a shell, neither
|
|
109
|
+
* typed by anyone. 0.18.1's comma, one namespace over.
|
|
110
|
+
* - **comma, CR, LF, NUL** — split a grant.
|
|
111
|
+
* - **`*`** — collides with `WORKSPACE_WILDCARD`, so registering a worktree as `*` and granting
|
|
112
|
+
* `workspace:*` believing it named that one root minted routing authority over the whole registry.
|
|
113
|
+
* - **quotes, `$`, backticks, `;`, `&`, `|`, `<`, `>`, `(`, `)`, `\`, `#`** — reach the ROUTABLE WORKSPACES
|
|
114
|
+
* block of a generated `.pi/grants.env`, whose own instructions tell the operator to paste the id into
|
|
115
|
+
* `PI_GRANTS_GRANT`. Sourcing the file was safe; following its instructions executed. R-77/R-78.
|
|
116
|
+
* - **control characters and non-ASCII** — the generated file is reviewed in an editor and `/grants` prints
|
|
117
|
+
* these; backspace and ANSI escapes let one id render as another. This is the one refusal that costs a
|
|
118
|
+
* legitimate user something (a non-English worktree name), and it is a deliberate trade recorded as
|
|
119
|
+
* breaking rather than asserted to cost nothing.
|
|
120
|
+
*/
|
|
121
|
+
export declare function isSafeWorkspaceId(id: string): boolean;
|
|
122
|
+
export declare function isSafeCapability(id: Capability): boolean;
|
|
123
|
+
/**
|
|
124
|
+
* The write-side backstop, for every channel that joins capabilities into one string.
|
|
125
|
+
*
|
|
126
|
+
* `covered()` already refuses to GRANT a malformed id, so this should be unreachable — which is exactly
|
|
127
|
+
* why it exists. `grant-env.ts` says it better than I can: "the third channel — whatever it turns out to
|
|
128
|
+
* be — should cost a refusal rather than an injection. A guard that depends on my enumeration being
|
|
129
|
+
* complete is not a guard." The propagation channel turned out to be that third channel, and it had no
|
|
130
|
+
* backstop while the file-writing channel did.
|
|
131
|
+
*
|
|
132
|
+
* Loud rather than silently filtered: a malformed id here means something upstream admitted one, and
|
|
133
|
+
* dropping it quietly would hide the defect that produced it.
|
|
134
|
+
*/
|
|
135
|
+
export declare function assertCapabilitiesArePropagatable(grant: readonly Capability[]): void;
|
|
31
136
|
//# sourceMappingURL=capabilities.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../src/capabilities.ts"],"names":[],"mappings":"AAAA;;;;;;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+11,9 @@
|
|
|
11
11
|
* concern living in the wrong file: *what an id means and who may use it* is a different question from
|
|
12
12
|
* *what one delegation does*.
|
|
13
13
|
*/
|
|
14
|
-
import { AGENT_WILDCARD } from "./resolve.js";
|
|
14
|
+
import { AGENT_WILDCARD, WORKSPACE_WILDCARD } from "./resolve.js";
|
|
15
15
|
import { WILDCARD } from "./pi-tools.js";
|
|
16
|
+
import { GovernanceRefusal, refusal } from "./refusals.js";
|
|
16
17
|
/** The capability that authorises spawning a definition (ADR-0017). `tool:*` satisfies any of them. */
|
|
17
18
|
export const agentCapability = (name) => `agent:${name}`;
|
|
18
19
|
/**
|
|
@@ -34,12 +35,169 @@ export function maySpawnDefinition(ownGrant, name) {
|
|
|
34
35
|
}
|
|
35
36
|
/** The tool name that confers the ability to delegate further. */
|
|
36
37
|
export const DELEGATE_CAPABILITY = "tool:delegate";
|
|
38
|
+
/**
|
|
39
|
+
* Every namespace a capability id may carry, as its literal prefix.
|
|
40
|
+
*
|
|
41
|
+
* **One list, because there were three and adding a namespace only updated some of them.** ADR-0035 taught
|
|
42
|
+
* `normaliseCapability` about `workspace:` and left `ceilingForDefinition` (which mangled it into
|
|
43
|
+
* `tool:workspace:<id>`) and `isSafeCapability` (which called it malformed) behind. The two places that parse
|
|
44
|
+
* an id's namespace read this, so a fifth namespace is one entry rather than a third divergence.
|
|
45
|
+
*
|
|
46
|
+
* **Not every prefix decision in the package.** Inline `startsWith("` tests on a capability namespace are
|
|
47
|
+
* scattered across `src/` and `extensions/`; this list is read by two of them. **No number is written here,
|
|
48
|
+
* and the history is why:** SPEC first claimed the list was "what every site reads"; a correction said "six"
|
|
49
|
+
* while its own enumeration listed seven; this docstring then said "nine" in the sentence claiming it gave no
|
|
50
|
+
* number; and the correction to *that* said "fourteen", which counted every file containing any
|
|
51
|
+
* `startsWith("` — CLI flags, `git worktree list` parsing, an assurance sentinel and node_modules entries
|
|
52
|
+
* among them. Four numbers, four wrong. The command, so nobody has to quote a predecessor:
|
|
53
|
+
*
|
|
54
|
+
* grep -rl 'startsWith("\(tool:\|ext:\|agent:\|skill:\|workspace:\)' src extensions
|
|
55
|
+
*
|
|
56
|
+
* Consolidating the sites is a separate change, and a count nobody re-derives is the defect this list exists
|
|
57
|
+
* to prevent.
|
|
58
|
+
*
|
|
59
|
+
* `docs/SPEC.md`'s grammar section is the prose statement of the same list and is kept in step with it.
|
|
60
|
+
*/
|
|
61
|
+
export const CAPABILITY_NAMESPACE_PREFIXES = ["tool:", "ext:", "skill:", "agent:", "workspace:"];
|
|
37
62
|
/** Accept `read` or `tool:read` or `ext:pkg/tool` and normalise to a capability id. */
|
|
38
63
|
export function normaliseCapability(raw) {
|
|
39
64
|
const value = raw.trim();
|
|
40
|
-
if (
|
|
65
|
+
if (CAPABILITY_NAMESPACE_PREFIXES.some((prefix) => value.startsWith(prefix)))
|
|
41
66
|
return value;
|
|
42
|
-
}
|
|
43
67
|
return `tool:${value}`;
|
|
44
68
|
}
|
|
69
|
+
/** The capability that authorises routing a child to one registered workspace (ADR-0035). */
|
|
70
|
+
export function workspaceCapability(workspaceId) {
|
|
71
|
+
return `workspace:${workspaceId}`;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* May this session route a child to workspace `id`?
|
|
75
|
+
*
|
|
76
|
+
* Mirrors `maySpawnDefinition` deliberately — same shape, same wildcard handling, same reason. Routing was
|
|
77
|
+
* the one governance dimension that did not attenuate (R-131, measured in
|
|
78
|
+
* `docs/probes/g36-workspace-attenuation`): the registry inherited into every child and nothing checked the
|
|
79
|
+
* caller's authority, so a child routed to `staging` could route its grandchild to `prod`.
|
|
80
|
+
*
|
|
81
|
+
* `tool:*` satisfies it because governance is opt-in — an ungoverned session holds the wildcard and must
|
|
82
|
+
* keep working exactly as before.
|
|
83
|
+
*/
|
|
84
|
+
export function mayRouteToWorkspace(ownGrant, workspaceId) {
|
|
85
|
+
const held = new Set(ownGrant);
|
|
86
|
+
return held.has(WILDCARD)
|
|
87
|
+
|| held.has(WORKSPACE_WILDCARD)
|
|
88
|
+
|| held.has(workspaceCapability(workspaceId));
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Characters that make a capability id mean something OTHER than one capability.
|
|
92
|
+
*
|
|
93
|
+
* A capability id is never a list. `PI_GRANTS_GRANT` is comma-separated and `parseList` trims and splits
|
|
94
|
+
* it, so a comma inside a single id means the child reads it as several — including ones nothing granted.
|
|
95
|
+
* Newlines are here for the same reason one level out: the grant travels through an environment variable
|
|
96
|
+
* and, via `assertGrantIsWritable`, a shell-sourced file.
|
|
97
|
+
*
|
|
98
|
+
* **Measured, on the published 0.18.0.** A root holding `agent:*` (or `tool:*`) that requested
|
|
99
|
+
* `agent:x,tool:bash` had it admitted by the wildcard's prefix rule, written verbatim into the child's
|
|
100
|
+
* grant, and split by the child into `agent:x` + `tool:bash` — minting a capability the root never held,
|
|
101
|
+
* with `denied: []` so nothing recorded an escalation and the ledger line looked clean.
|
|
102
|
+
*
|
|
103
|
+
* Deliberately a blocklist of structurally dangerous characters rather than the full grammar whitelist in
|
|
104
|
+
* `isSafeCapability`. That whitelist is right where it lives — the boundary that GENERATES a grant — but
|
|
105
|
+
* this is the enforcement path, which must keep accepting whatever ids operators already have. A security
|
|
106
|
+
* patch to a released version should close the hole without inventing a new way to refuse a legitimate
|
|
107
|
+
* setup. `grant-env.ts` predicted this channel: "the third channel — whatever it turns out to be — should
|
|
108
|
+
* cost a refusal rather than an injection."
|
|
109
|
+
*/
|
|
110
|
+
const CAPABILITY_ID_SEPARATORS = /[,\r\n\0]/;
|
|
111
|
+
/** False when an id would be read as more than one capability by any channel that carries it. */
|
|
112
|
+
export function isWellFormedCapability(id) {
|
|
113
|
+
return id.length > 0 && !CAPABILITY_ID_SEPARATORS.test(id) && id.trim() === id;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* The STRICT grammar: a whitelist of what a capability id may look like, not a blocklist of what it may not.
|
|
117
|
+
*
|
|
118
|
+
* **Two consumers, and they are two different reasons for the same rule.** It lives here rather than in
|
|
119
|
+
* either of them because it shipped in one and was needed by both:
|
|
120
|
+
*
|
|
121
|
+
* 1. `skill-packages.ts` — the boundary that GENERATES a grant. R-77/R-78: a package declaring
|
|
122
|
+
* `allowed-tools: Read,ext:x";touch /tmp/pwned;PI_GRANTS_GRANT="` produced a `.pi/grants.env` that ran
|
|
123
|
+
* arbitrary code the moment an operator sourced the line `init` prints.
|
|
124
|
+
* 2. `workspace.ts` — the operator registry, since ADR-0035 made a registry id the tail of a capability id
|
|
125
|
+
* (`workspace:<id>`). That made the registry an input to this grammar, and it got the LOOSE
|
|
126
|
+
* `isWellFormedCapability` blocklist instead, which review showed costs three things:
|
|
127
|
+
* an id of literally `*` loaded and minted `WORKSPACE_WILDCARD`, so an operator naming ONE worktree held
|
|
128
|
+
* routing authority over every id in the registry including ones added later;
|
|
129
|
+
* an id containing a space became TWO capabilities, because `ceilingForDefinition` splits `allowed-tools`
|
|
130
|
+
* on `[\s,]+` — `allowed-tools: read, workspace:prod bash` measured as
|
|
131
|
+
* `['tool:bash','tool:read','workspace:prod']`, i.e. routing over production plus a shell, neither typed
|
|
132
|
+
* by anyone (0.18.1's comma, one namespace over);
|
|
133
|
+
* and quote/`$()`/backtick ids reached the `ROUTABLE WORKSPACES` block of the generated file, whose own
|
|
134
|
+
* instructions tell the operator to paste them into `PI_GRANTS_GRANT`.
|
|
135
|
+
*
|
|
136
|
+
* **A blocklist was the wrong shape for this and the comment on `isWellFormedCapability` says why it is the
|
|
137
|
+
* right shape THERE**: that one guards the enforcement path, which must keep accepting whatever ids operators
|
|
138
|
+
* already have. A registry is a file the operator writes and can rename, so refusing a hostile id costs
|
|
139
|
+
* nothing — and `grant-env.ts`'s standing warning applies to it exactly: *"the third channel — whatever it
|
|
140
|
+
* turns out to be — should cost a refusal rather than an injection."* The registry was the third channel.
|
|
141
|
+
*/
|
|
142
|
+
/**
|
|
143
|
+
* A workspace registry id, which is NOT a tool name and needed its own rule.
|
|
144
|
+
*
|
|
145
|
+
* `isSafeCapability` was reused here first, and that was the error: it is the grammar for a *tool* name, and
|
|
146
|
+
* it refused ids that published 0.18.1 accepted — `feature/x` above all. Git worktrees are routinely named
|
|
147
|
+
* after their branch, so a slash is the ordinary case, and a slash splits nothing: not the comma-separated
|
|
148
|
+
* grant, not `allowed-tools`' `[\s,]+`. Refusing it bought no safety and broke the common setup.
|
|
149
|
+
*
|
|
150
|
+
* What is refused, and why each one earns it:
|
|
151
|
+
* - **whitespace** — `ceilingForDefinition` splits `allowed-tools` on `[\s,]+`, so `workspace:prod bash`
|
|
152
|
+
* measured as `['tool:bash','tool:read','workspace:prod']`: routing over production plus a shell, neither
|
|
153
|
+
* typed by anyone. 0.18.1's comma, one namespace over.
|
|
154
|
+
* - **comma, CR, LF, NUL** — split a grant.
|
|
155
|
+
* - **`*`** — collides with `WORKSPACE_WILDCARD`, so registering a worktree as `*` and granting
|
|
156
|
+
* `workspace:*` believing it named that one root minted routing authority over the whole registry.
|
|
157
|
+
* - **quotes, `$`, backticks, `;`, `&`, `|`, `<`, `>`, `(`, `)`, `\`, `#`** — reach the ROUTABLE WORKSPACES
|
|
158
|
+
* block of a generated `.pi/grants.env`, whose own instructions tell the operator to paste the id into
|
|
159
|
+
* `PI_GRANTS_GRANT`. Sourcing the file was safe; following its instructions executed. R-77/R-78.
|
|
160
|
+
* - **control characters and non-ASCII** — the generated file is reviewed in an editor and `/grants` prints
|
|
161
|
+
* these; backspace and ANSI escapes let one id render as another. This is the one refusal that costs a
|
|
162
|
+
* legitimate user something (a non-English worktree name), and it is a deliberate trade recorded as
|
|
163
|
+
* breaking rather than asserted to cost nothing.
|
|
164
|
+
*/
|
|
165
|
+
export function isSafeWorkspaceId(id) {
|
|
166
|
+
return /^[A-Za-z0-9][A-Za-z0-9._/-]*$/.test(id);
|
|
167
|
+
}
|
|
168
|
+
export function isSafeCapability(id) {
|
|
169
|
+
const segment = "[A-Za-z0-9][A-Za-z0-9._-]*";
|
|
170
|
+
// `workspace:` delegates to the WORKSPACE grammar rather than reusing `segment`, and that is the fifth
|
|
171
|
+
// site of the same defect. `isSafeWorkspaceId` allows a slash because a git worktree is routinely named
|
|
172
|
+
// after its branch; `segment` does not, so this function refused `workspace:feature/x` — dropping the whole
|
|
173
|
+
// definition, exiting 1, and telling the operator "a capability id is tool:/skill:/agent:<name> or
|
|
174
|
+
// ext:<pkg>/<tool>", which does not even mention the namespace. Meanwhile the CHANGELOG told them slashes
|
|
175
|
+
// are fine. **The boundary that GENERATES grants could not emit the id shape the release advertises**, so
|
|
176
|
+
// the migration path for a breaking change was closed by the commit that documented it as open.
|
|
177
|
+
if (id.startsWith("workspace:"))
|
|
178
|
+
return isSafeWorkspaceId(id.slice("workspace:".length));
|
|
179
|
+
return (new RegExp(`^(tool|skill|agent):${segment}$`).test(id) ||
|
|
180
|
+
new RegExp(`^ext:(@${segment}/)?${segment}/${segment}$`).test(id));
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* The write-side backstop, for every channel that joins capabilities into one string.
|
|
184
|
+
*
|
|
185
|
+
* `covered()` already refuses to GRANT a malformed id, so this should be unreachable — which is exactly
|
|
186
|
+
* why it exists. `grant-env.ts` says it better than I can: "the third channel — whatever it turns out to
|
|
187
|
+
* be — should cost a refusal rather than an injection. A guard that depends on my enumeration being
|
|
188
|
+
* complete is not a guard." The propagation channel turned out to be that third channel, and it had no
|
|
189
|
+
* backstop while the file-writing channel did.
|
|
190
|
+
*
|
|
191
|
+
* Loud rather than silently filtered: a malformed id here means something upstream admitted one, and
|
|
192
|
+
* dropping it quietly would hide the defect that produced it.
|
|
193
|
+
*/
|
|
194
|
+
export function assertCapabilitiesArePropagatable(grant) {
|
|
195
|
+
const malformed = grant.filter((c) => !isWellFormedCapability(c));
|
|
196
|
+
if (malformed.length === 0)
|
|
197
|
+
return;
|
|
198
|
+
throw new GovernanceRefusal(refusal("GRANT_ID_MALFORMED", `refusing to build a child environment: ${JSON.stringify(malformed)} contain characters that are not ` +
|
|
199
|
+
`part of a capability id. The grant is comma-separated, so a child would read these as several ` +
|
|
200
|
+
`capabilities — including ones nothing granted. Report this: a malformed id reached propagation, ` +
|
|
201
|
+
`which means a guard upstream admitted it.`, { malformed: malformed.join(" ") }));
|
|
202
|
+
}
|
|
45
203
|
//# sourceMappingURL=capabilities.js.map
|
package/dist/capabilities.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capabilities.js","sourceRoot":"","sources":["../src/capabilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,cAAc,EAAmB,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"capabilities.js","sourceRoot":"","sources":["../src/capabilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAmB,MAAM,cAAc,CAAC;AACnF,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAE3D,uGAAuG;AACvG,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAY,EAAc,EAAE,CAAC,SAAS,IAAI,EAAE,CAAC;AAE7E;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CAAC,QAAsB,EAAE,IAAY;IACrE,mGAAmG;IACnG,wGAAwG;IACxG,mGAAmG;IACnG,OAAO,CACL,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAC3B,QAAQ,CAAC,QAAQ,CAAC,cAAc,CAAC;QACjC,QAAQ,CAAC,QAAQ,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CACzC,CAAC;AACJ,CAAC;AAED,kEAAkE;AAClE,MAAM,CAAC,MAAM,mBAAmB,GAAe,eAAe,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,OAAO,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AAC;AAED,MAAM,UAAU,gBAAgB,CAAC,EAAc;IAC7C,MAAM,OAAO,GAAG,4BAA4B,CAAC;IAC7C,uGAAuG;IACvG,wGAAwG;IACxG,4GAA4G;IAC5G,mGAAmG;IACnG,0GAA0G;IAC1G,0GAA0G;IAC1G,gGAAgG;IAChG,IAAI,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC;QAAE,OAAO,iBAAiB,CAAC,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC;IACzF,OAAO,CACL,IAAI,MAAM,CAAC,uBAAuB,OAAO,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;QACtD,IAAI,MAAM,CAAC,UAAU,OAAO,MAAM,OAAO,IAAI,OAAO,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAClE,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,iCAAiC,CAAC,KAA4B;IAC5E,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC;IAClE,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IACnC,MAAM,IAAI,iBAAiB,CAAC,OAAO,CACjC,oBAAoB,EACpB,0CAA0C,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,mCAAmC;QACtG,gGAAgG;QAChG,kGAAkG;QAClG,2CAA2C,EAC3C,EAAE,SAAS,EAAE,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CACnC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/catalog.d.ts
CHANGED
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
*/
|
|
20
20
|
import { type SkillDefinition } from "./definitions.ts";
|
|
21
21
|
import { type Capability } from "./resolve.ts";
|
|
22
|
-
|
|
22
|
+
import { type WorkspaceRegistryFile } from "./workspace.ts";
|
|
23
|
+
export type CapabilityKind = "builtin" | "extension" | "skill" | "agentType" | "workspace";
|
|
23
24
|
export interface CatalogEntry {
|
|
24
25
|
capability: Capability;
|
|
25
26
|
kind: CapabilityKind;
|
|
@@ -54,12 +55,25 @@ export declare function loadSkills(cwd: string): Promise<CatalogEntry[]>;
|
|
|
54
55
|
* `agent:review` means "may spawn a child running them", and a grant can hold either without the other.
|
|
55
56
|
*/
|
|
56
57
|
export declare function definitionEntries(definitions: Map<string, SkillDefinition>): CatalogEntry[];
|
|
58
|
+
/**
|
|
59
|
+
* Registered workspaces, as `workspace:<id>` capabilities (ADR-0035).
|
|
60
|
+
*
|
|
61
|
+
* For DISPLAY and SCAFFOLDING only — `/grants` listing what this session may route to, and `init` offering
|
|
62
|
+
* the ids without choosing among them (ADR-0028). It is deliberately **not** what `unknownCapabilities`
|
|
63
|
+
* checks against; see the comment there.
|
|
64
|
+
*
|
|
65
|
+
* The operator registry is the authority on which ids exist, exactly as it is at `resolveWorkspace`. This
|
|
66
|
+
* enumerates it; it does not decide anything.
|
|
67
|
+
*/
|
|
68
|
+
export declare function workspaceEntries(registry: WorkspaceRegistryFile, source?: string): CatalogEntry[];
|
|
57
69
|
/** Assemble a catalog from parts. Pure, so it is testable without a filesystem. */
|
|
58
70
|
export declare function makeCatalog(entries: CatalogEntry[]): Catalog;
|
|
59
71
|
/** Build the live catalog. `observedTools` comes from a provider payload; null when not yet seen. */
|
|
60
72
|
export declare function buildCatalog(input: {
|
|
61
73
|
cwd: string;
|
|
62
74
|
observedTools: string[] | null;
|
|
75
|
+
/** Operator workspace registry (`PI_GRANTS_WORKSPACE_REGISTRY`). Absent or unreadable yields no entries. */
|
|
76
|
+
registryPath?: string;
|
|
63
77
|
}): Promise<Catalog>;
|
|
64
78
|
/**
|
|
65
79
|
* Capabilities requested that the catalog does not contain.
|
package/dist/catalog.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["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AC,MAAM,EAAE,eAAe,CAAC,GAAG,YAAY,EAAE,CAM3F;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,qBAAqB,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,YAAY,EAAE,CAIjG;AAED,mFAAmF;AACnF,wBAAgB,WAAW,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,OAAO,CAY5D;AAED,qGAAqG;AACrG,wBAAsB,YAAY,CAAC,KAAK,EAAE;IACxC,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAC/B,4GAA4G;IAC5G,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,OAAO,CAAC,OAAO,CAAC,CAgCnB;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,UAAU,EAAE,EAAE,OAAO,EAAE,OAAO,GAAG,UAAU,EAAE,CAgC3F;AA6DD;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,GAAG,UAAU,GAAG,IAAI,CAuB1F;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAO9E"}
|
package/dist/catalog.js
CHANGED
|
@@ -22,7 +22,9 @@ import { homedir } from "node:os";
|
|
|
22
22
|
import { join } from "node:path";
|
|
23
23
|
import { loadDefinitions } from "./definitions.js";
|
|
24
24
|
import { PI_BUILTIN_TOOLS, WILDCARD } from "./pi-tools.js";
|
|
25
|
-
import { AGENT_WILDCARD } from "./resolve.js";
|
|
25
|
+
import { AGENT_WILDCARD, WORKSPACE_WILDCARD } from "./resolve.js";
|
|
26
|
+
import { loadWorkspaceRegistry } from "./workspace.js";
|
|
27
|
+
import { isSafeWorkspaceId } from "./capabilities.js";
|
|
26
28
|
/** Split observed tool names into pi built-ins and extension-provided tools. */
|
|
27
29
|
export function classifyToolNames(observed) {
|
|
28
30
|
const builtins = new Set(PI_BUILTIN_TOOLS);
|
|
@@ -92,6 +94,21 @@ export function definitionEntries(definitions) {
|
|
|
92
94
|
source: d.source,
|
|
93
95
|
}));
|
|
94
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* Registered workspaces, as `workspace:<id>` capabilities (ADR-0035).
|
|
99
|
+
*
|
|
100
|
+
* For DISPLAY and SCAFFOLDING only — `/grants` listing what this session may route to, and `init` offering
|
|
101
|
+
* the ids without choosing among them (ADR-0028). It is deliberately **not** what `unknownCapabilities`
|
|
102
|
+
* checks against; see the comment there.
|
|
103
|
+
*
|
|
104
|
+
* The operator registry is the authority on which ids exist, exactly as it is at `resolveWorkspace`. This
|
|
105
|
+
* enumerates it; it does not decide anything.
|
|
106
|
+
*/
|
|
107
|
+
export function workspaceEntries(registry, source) {
|
|
108
|
+
return Object.keys(registry.workspaces)
|
|
109
|
+
.sort()
|
|
110
|
+
.map((id) => ({ capability: `workspace:${id}`, kind: "workspace", ...(source ? { source } : {}) }));
|
|
111
|
+
}
|
|
95
112
|
/** Assemble a catalog from parts. Pure, so it is testable without a filesystem. */
|
|
96
113
|
export function makeCatalog(entries) {
|
|
97
114
|
const deduped = new Map();
|
|
@@ -110,7 +127,17 @@ export function makeCatalog(entries) {
|
|
|
110
127
|
}
|
|
111
128
|
/** Build the live catalog. `observedTools` comes from a provider payload; null when not yet seen. */
|
|
112
129
|
export async function buildCatalog(input) {
|
|
113
|
-
const [skills, definitions] = await Promise.all([
|
|
130
|
+
const [skills, definitions, workspaces] = await Promise.all([
|
|
131
|
+
loadSkills(input.cwd),
|
|
132
|
+
loadDefinitions(input.cwd),
|
|
133
|
+
// Fails SOFT, and only because nothing here is an authority. A malformed registry must not stop a
|
|
134
|
+
// session from starting — `loadWorkspaceRegistry` throws a GovernanceRefusal naming the file, and that
|
|
135
|
+
// refusal is the operator's signal at the point of USE, where routing actually depends on it. Swallowing
|
|
136
|
+
// it there would be unsafe; swallowing it here costs a display list.
|
|
137
|
+
input.registryPath
|
|
138
|
+
? loadWorkspaceRegistry(input.registryPath).then((r) => workspaceEntries(r, input.registryPath), () => [])
|
|
139
|
+
: Promise.resolve([]),
|
|
140
|
+
]);
|
|
114
141
|
return makeCatalog([
|
|
115
142
|
// pi's built-ins are seeded unconditionally, because they are known statically and the catalog is
|
|
116
143
|
// consulted BEFORE any provider request has happened — `/grants` runs at that point. Without this,
|
|
@@ -126,6 +153,7 @@ export async function buildCatalog(input) {
|
|
|
126
153
|
...(input.observedTools ? classifyToolNames(input.observedTools) : []),
|
|
127
154
|
...skills,
|
|
128
155
|
...definitionEntries(definitions),
|
|
156
|
+
...workspaces,
|
|
129
157
|
]);
|
|
130
158
|
}
|
|
131
159
|
/**
|
|
@@ -142,7 +170,30 @@ export function unknownCapabilities(requested, catalog) {
|
|
|
142
170
|
// refused it BEFORE `resolve` could apply ADR-0023's rule. That made the ADR's "a parent holding
|
|
143
171
|
// `agent:*` may hand down `agent:*`" false, and made a definition declaring `allowed-tools: agent:*`
|
|
144
172
|
// unspawnable from any grant. The wildcard is live only at the root without this.
|
|
145
|
-
|
|
173
|
+
//
|
|
174
|
+
// `workspace:` is exempt as a NAMESPACE, not merely at its wildcard, and that asymmetry is deliberate.
|
|
175
|
+
// ADR-0035 minted the namespace and taught `normaliseCapability`, `resolve` and `childEnv` about it, but
|
|
176
|
+
// not this line — so with a catalog present (and `delegationContext` always supplies one) every requested
|
|
177
|
+
// `workspace:<id>` was refused UNKNOWN_TOOL as *"a typo, or an uninstalled package"*. A child could
|
|
178
|
+
// therefore never be granted a workspace capability at all, which made routing stop dead below the root
|
|
179
|
+
// instead of attenuating, and made the ADR's own "two authorities, not one" unreachable in production.
|
|
180
|
+
//
|
|
181
|
+
// Exempt rather than catalogued-and-checked because the operator registry is the authority and it is
|
|
182
|
+
// consulted where it matters: `resolveWorkspace` refuses an unregistered id with WORKSPACE_NOT_REGISTERED,
|
|
183
|
+
// naming the registry. A second, weaker check here can only turn that precise refusal into a misleading
|
|
184
|
+
// one — and it would do so for reasons that have nothing to do with the id, like a registry this session
|
|
185
|
+
// cannot read. `buildCatalog` still ENUMERATES workspaces, for `/grants` and for `init`'s scaffold; that
|
|
186
|
+
// is display, and display is not authority. Same trade-off the built-ins comment above states and accepts.
|
|
187
|
+
// The workspace exemption requires a WELL-FORMED id, not merely the prefix. A bare `workspace:` names
|
|
188
|
+
// nothing, and exempting it let it reach a child's grant and the ledger as authority over no workspace at
|
|
189
|
+
// all — an exemption for ids the registry is authoritative about should not also cover ids no registry
|
|
190
|
+
// could contain.
|
|
191
|
+
// `WORKSPACE_WILDCARD` is listed with the other two because it is GRAMMAR, and `isSafeCapability` refuses
|
|
192
|
+
// wildcards by design — so folding it into the namespace test below un-exempts it. Caught by the tests for
|
|
193
|
+
// the previous two fixes, which is the checklist paying for itself.
|
|
194
|
+
const exempt = (c) => c === WILDCARD || c === AGENT_WILDCARD || c === WORKSPACE_WILDCARD
|
|
195
|
+
|| (c.startsWith("workspace:") && isSafeWorkspaceId(c.slice("workspace:".length)));
|
|
196
|
+
return requested.filter((c) => !exempt(c) && !catalog.has(c)).sort();
|
|
146
197
|
}
|
|
147
198
|
/**
|
|
148
199
|
* Tool names that exist in OTHER harnesses' vocabularies, mapped to the pi tool that does the same job.
|
package/dist/catalog.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../src/catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,eAAe,EAAwB,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,Q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,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AAC7C,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAAgB;IACpD,MAAM,KAAK,GAA2B,EAAE,CAAC;IACzC,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpC,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM;YAAE,SAAS;QACtD,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC;IAChE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check-runner.d.ts","sourceRoot":"","sources":["../src/check-runner.ts"],"names":[],"mappings":"AAIA,OAAO,EAAwB,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"check-runner.d.ts","sourceRoot":"","sources":["../src/check-runner.ts"],"names":[],"mappings":"AAIA,OAAO,EAAwB,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AASlF,OAAO,EAGL,KAAK,kBAAkB,EACvB,KAAK,eAAe,EAGrB,MAAM,gBAAgB,CAAC;AAExB,MAAM,WAAW,eAAe;IAC9B,gGAAgG;IAChG,UAAU,EAAE,MAAM,CAAC;IACnB,yDAAyD;IACzD,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,8CAA8C;IAC9C,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,mEAAmE;IACnE,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,+EAA+E;IAC/E,gBAAgB,CAAC,EAAE,eAAe,CAAC;CACpC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AE,WAAW,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,OAAO,CAAC;IACV,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;IAC9B,OAAO,EAAE,YAAY,CAAC;CACvB,CAAC,CAsND"}
|
package/dist/check-runner.js
CHANGED
|
@@ -3,7 +3,7 @@ import { chmod, mkdtemp, readFile, realpath, rm, stat, writeFile } from "node:fs
|
|
|
3
3
|
import { tmpdir } from "node:os";
|
|
4
4
|
import { basename, isAbsolute, join } from "node:path";
|
|
5
5
|
import { normaliseCorrelation } from "./correlation.js";
|
|
6
|
-
import { appendLedgerEvent,
|
|
6
|
+
import { appendLedgerEvent, buildCheckReceiptLedgerEvent, buildWorkspaceLeaseEvent, } from "./ledger.js";
|
|
7
7
|
import { computeGitCandidateIdentity } from "./git-identity.js";
|
|
8
8
|
import { runChild } from "./run-child.js";
|
|
9
9
|
import { GovernanceRefusal, refusal } from "./refusals.js";
|
|
@@ -168,12 +168,10 @@ export async function runNamedCheck(input) {
|
|
|
168
168
|
};
|
|
169
169
|
const receipt = { receipt_id: receiptId(body), ...body };
|
|
170
170
|
if (input.ledgerPath) {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
};
|
|
176
|
-
await appendLedgerEvent({ path: input.ledgerPath, strict: true }, event);
|
|
171
|
+
await appendLedgerEvent({ path: input.ledgerPath, strict: true }, buildCheckReceiptLedgerEvent({
|
|
172
|
+
childId: ownerId, receiptId: receipt.receipt_id, workspaceId: input.workspace.workspaceId,
|
|
173
|
+
checkId: input.checkId, treeSha: receipt.tree_sha, correlation, now: ended,
|
|
174
|
+
}));
|
|
177
175
|
}
|
|
178
176
|
return { output: result.text, exitCode: result.code, signal: result.signal ?? null, receipt };
|
|
179
177
|
}
|