pi-daddy 0.18.1 → 0.20.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 +201 -0
- package/README.md +136 -23
- 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/contracts/ledger/v3/README.md +36 -0
- package/contracts/ledger/v3/fixtures/capability-decision.json +98 -0
- package/contracts/ledger/v3/fixtures/check-receipt.json +42 -0
- package/contracts/ledger/v3/fixtures/child-lifecycle.json +45 -0
- package/contracts/ledger/v3/fixtures/workflow-fact.json +41 -0
- package/contracts/ledger/v3/fixtures/workspace-lease.json +43 -0
- package/contracts/ledger/v3/ledger-event.schema.json +930 -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 +90 -0
- package/dist/capabilities.d.ts.map +1 -1
- package/dist/capabilities.js +114 -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 +19 -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/correlation.d.ts.map +1 -1
- package/dist/correlation.js +10 -0
- package/dist/correlation.js.map +1 -1
- package/dist/dashboard-cli.d.ts +18 -0
- package/dist/dashboard-cli.d.ts.map +1 -0
- package/dist/dashboard-cli.js +154 -0
- package/dist/dashboard-cli.js.map +1 -0
- package/dist/dashboard-handshake.d.ts +37 -0
- package/dist/dashboard-handshake.d.ts.map +1 -0
- package/dist/dashboard-handshake.js +127 -0
- package/dist/dashboard-handshake.js.map +1 -0
- package/dist/dashboard-herdr.d.ts +54 -0
- package/dist/dashboard-herdr.d.ts.map +1 -0
- package/dist/dashboard-herdr.js +286 -0
- package/dist/dashboard-herdr.js.map +1 -0
- package/dist/dashboard-projection.d.ts +73 -0
- package/dist/dashboard-projection.d.ts.map +1 -0
- package/dist/dashboard-projection.js +294 -0
- package/dist/dashboard-projection.js.map +1 -0
- package/dist/dashboard-render.d.ts +10 -0
- package/dist/dashboard-render.d.ts.map +1 -0
- package/dist/dashboard-render.js +208 -0
- package/dist/dashboard-render.js.map +1 -0
- package/dist/definitions.d.ts.map +1 -1
- package/dist/definitions.js +7 -1
- package/dist/definitions.js.map +1 -1
- package/dist/delegate-types.d.ts +6 -2
- package/dist/delegate-types.d.ts.map +1 -1
- package/dist/delegate-types.js.map +1 -1
- package/dist/delegate.d.ts.map +1 -1
- package/dist/delegate.js +34 -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/execution-id.d.ts +6 -0
- package/dist/execution-id.d.ts.map +1 -0
- package/dist/execution-id.js +13 -0
- package/dist/execution-id.js.map +1 -0
- 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 +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -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 +59 -15
- package/dist/ledger-events.d.ts.map +1 -1
- package/dist/ledger-events.js +67 -5
- package/dist/ledger-events.js.map +1 -1
- package/dist/ledger-identifiers.d.ts +7 -0
- package/dist/ledger-identifiers.d.ts.map +1 -0
- package/dist/ledger-identifiers.js +20 -0
- package/dist/ledger-identifiers.js.map +1 -0
- package/dist/ledger-report.d.ts +5 -2
- package/dist/ledger-report.d.ts.map +1 -1
- package/dist/ledger-report.js +38 -14
- package/dist/ledger-report.js.map +1 -1
- package/dist/ledger-v3-validation.d.ts +11 -0
- package/dist/ledger-v3-validation.d.ts.map +1 -0
- package/dist/ledger-v3-validation.js +265 -0
- package/dist/ledger-v3-validation.js.map +1 -0
- package/dist/ledger.d.ts +27 -9
- package/dist/ledger.d.ts.map +1 -1
- package/dist/ledger.js +38 -6
- package/dist/ledger.js.map +1 -1
- package/dist/propagation.d.ts +19 -1
- package/dist/propagation.d.ts.map +1 -1
- package/dist/propagation.js +23 -1
- 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 +1 -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 +27 -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/run-child.d.ts +3 -1
- package/dist/run-child.d.ts.map +1 -1
- package/dist/run-child.js +30 -2
- package/dist/run-child.js.map +1 -1
- package/dist/run-herdr.d.ts +2 -0
- package/dist/run-herdr.d.ts.map +1 -1
- package/dist/run-herdr.js +8 -0
- package/dist/run-herdr.js.map +1 -1
- 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/workflow-fact-id.d.ts +4 -0
- package/dist/workflow-fact-id.d.ts.map +1 -0
- package/dist/workflow-fact-id.js +14 -0
- package/dist/workflow-fact-id.js.map +1 -0
- package/dist/workflow-facts.d.ts +34 -0
- package/dist/workflow-facts.d.ts.map +1 -0
- package/dist/workflow-facts.js +43 -0
- package/dist/workflow-facts.js.map +1 -0
- 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/chain-ledger.ts +4 -0
- package/extensions/chain-plan.ts +98 -0
- package/extensions/delegate-chain.ts +63 -122
- package/extensions/delegation-ledger.ts +60 -0
- package/extensions/delegation.ts +20 -14
- package/extensions/execute-child.ts +85 -21
- package/extensions/execution-occurrence.ts +20 -0
- package/extensions/grants-command.ts +33 -4
- package/extensions/grants.ts +50 -1
- package/extensions/init-command.ts +33 -2
- package/extensions/run-delegation.ts +36 -56
- package/extensions/session-report.ts +13 -20
- package/extensions/session.ts +16 -3
- package/extensions/workspace-runtime.ts +44 -4
- package/herdr-plugin/herdr-plugin.toml +18 -0
- package/package.json +22 -5
- package/src/approval-prompt.ts +2 -1
- package/src/approval.ts +4 -2
- package/src/capabilities.ts +120 -4
- package/src/catalog.ts +62 -4
- package/src/check-runner.ts +24 -8
- package/src/cli.ts +24 -1
- package/src/correlation.ts +11 -0
- package/src/dashboard-cli.ts +171 -0
- package/src/dashboard-handshake.ts +185 -0
- package/src/dashboard-herdr.ts +355 -0
- package/src/dashboard-projection.ts +390 -0
- package/src/dashboard-render.ts +254 -0
- package/src/definitions.ts +7 -1
- package/src/delegate-types.ts +6 -2
- package/src/delegate.ts +43 -4
- package/src/delegation-approval.ts +37 -12
- package/src/execution-id.ts +18 -0
- package/src/executor.ts +2 -1
- package/src/grant-env.ts +39 -7
- package/src/index.ts +26 -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 +116 -28
- package/src/ledger-identifiers.ts +21 -0
- package/src/ledger-report.ts +40 -19
- package/src/ledger-v3-validation.ts +266 -0
- package/src/ledger.ts +75 -12
- package/src/propagation.ts +24 -1
- package/src/refusals.ts +1 -0
- package/src/resolve.ts +29 -3
- package/src/routing-authority.ts +121 -0
- package/src/run-child.ts +35 -3
- package/src/run-herdr.ts +9 -0
- package/src/skill-packages.ts +20 -13
- package/src/workflow-fact-id.ts +16 -0
- package/src/workflow-facts.ts +65 -0
- package/src/workspace-lease.ts +84 -24
- package/src/workspace.ts +179 -6
package/dist/ledger.d.ts
CHANGED
|
@@ -26,18 +26,26 @@ import type { PromptOutcomeKind } from "./approval-prompt.ts";
|
|
|
26
26
|
import type { CorrelationMetadata } from "./correlation.ts";
|
|
27
27
|
import type { StructuredRefusal } from "./refusals.ts";
|
|
28
28
|
import type { RuntimeLedgerEvent } from "./ledger-events.ts";
|
|
29
|
-
export declare const LEDGER_VERSION:
|
|
29
|
+
export declare const LEDGER_VERSION: 3;
|
|
30
|
+
export declare const LEDGER_EVENT_KINDS: readonly ["capability_decision", "workspace_lease", "child_lifecycle", "check_receipt", "workflow_fact"];
|
|
31
|
+
export type LedgerEventKind = typeof LEDGER_EVENT_KINDS[number];
|
|
32
|
+
export declare const LEDGER_GATE_OUTCOMES: readonly ["declined", "dismissed", "no-ui", "error"];
|
|
33
|
+
export type LedgerGateOutcome = typeof LEDGER_GATE_OUTCOMES[number];
|
|
30
34
|
export interface LedgerEventBase {
|
|
31
|
-
/** Optional only on the legacy-compatible `GrantRecord` public type; every
|
|
35
|
+
/** Optional only on the legacy-compatible `GrantRecord` public type; every v3 event builder writes it. */
|
|
32
36
|
ledgerVersion?: typeof LEDGER_VERSION;
|
|
33
|
-
event?:
|
|
37
|
+
event?: LedgerEventKind;
|
|
34
38
|
ts: string;
|
|
39
|
+
/** Unique execution occurrence. Optional only for legacy, unversioned GrantRecord values. */
|
|
40
|
+
executionId?: string;
|
|
41
|
+
/** Explicit execution parent; null means the delegating session is not itself a governed child. */
|
|
42
|
+
parentExecutionId?: string | null;
|
|
35
43
|
childId?: string;
|
|
36
44
|
correlation?: CorrelationMetadata;
|
|
37
45
|
}
|
|
38
46
|
export interface GrantRecord extends LedgerEventBase {
|
|
39
47
|
/**
|
|
40
|
-
* Present only when a trusted `taskDigest` was supplied — that is what makes a line
|
|
48
|
+
* Present only when a trusted `taskDigest` was supplied — that is what makes a line v3. `buildRecord`
|
|
41
49
|
* does NOT always emit it, and the comment here used to say it did while the emission site 200 lines
|
|
42
50
|
* down said the opposite. Two comments asserting contradictory facts about one field is R-28's shape.
|
|
43
51
|
*/
|
|
@@ -98,7 +106,7 @@ export interface GrantRecord extends LedgerEventBase {
|
|
|
98
106
|
/** Present only when the source was a live prompt, and only when one scope covers the whole set. */
|
|
99
107
|
approvalScope?: ApprovalScope;
|
|
100
108
|
/** A human was asked and declined. Distinct from `denied`, which is an escalation attempt. */
|
|
101
|
-
humanDenied?:
|
|
109
|
+
humanDenied?: true;
|
|
102
110
|
/**
|
|
103
111
|
* WHY a gate went unsatisfied, when the answer was not a yes.
|
|
104
112
|
*
|
|
@@ -114,9 +122,10 @@ export interface GrantRecord extends LedgerEventBase {
|
|
|
114
122
|
* say *"nobody was there to ask"* and be believed, so it is recorded rather than inferred.
|
|
115
123
|
*
|
|
116
124
|
* **Privacy is unchanged**: this is a fixed five-member enum, not text — nothing model-authored, nothing
|
|
117
|
-
* a task could carry.
|
|
125
|
+
* a task could carry. The prompt has five outcomes, but `granted` is deliberately omitted from the
|
|
126
|
+
* four-member ledger enum because the approval source/scope fields already record a yes.
|
|
118
127
|
*/
|
|
119
|
-
gateOutcome?:
|
|
128
|
+
gateOutcome?: LedgerGateOutcome;
|
|
120
129
|
/**
|
|
121
130
|
* WHICH operator-authored instructions this child was given (ADR-0018).
|
|
122
131
|
*
|
|
@@ -152,6 +161,8 @@ export interface GrantRecord extends LedgerEventBase {
|
|
|
152
161
|
* `definitionDigest` names its instructions, and neither says where the TASK came from.
|
|
153
162
|
*/
|
|
154
163
|
taskFrom?: string;
|
|
164
|
+
/** Unique occurrence whose output composed this task; taskFrom remains the readable logical position. */
|
|
165
|
+
taskFromExecutionId?: string;
|
|
155
166
|
/** Trusted SHA-256 of the exact task; task text remains forbidden (ADR-0034). */
|
|
156
167
|
taskDigest?: string;
|
|
157
168
|
/** Stable machine-readable refusal accompanying `reason`. */
|
|
@@ -174,6 +185,10 @@ export interface LedgerOptions {
|
|
|
174
185
|
onFailure?: (error: unknown) => void;
|
|
175
186
|
}
|
|
176
187
|
export declare function buildRecord(args: {
|
|
188
|
+
/** Required whenever taskDigest makes this an explicit v3 event. */
|
|
189
|
+
executionId?: string;
|
|
190
|
+
/** Required (including explicit null) whenever taskDigest makes this an explicit v3 event. */
|
|
191
|
+
parentExecutionId?: string | null;
|
|
177
192
|
parentId: string;
|
|
178
193
|
childId: string;
|
|
179
194
|
depth: number;
|
|
@@ -196,8 +211,10 @@ export declare function buildRecord(args: {
|
|
|
196
211
|
definitionDigest?: DefinitionDigest;
|
|
197
212
|
/** Where the child ran (ADR-0031). Required: the probe's answer survives nowhere else. */
|
|
198
213
|
executor: ExecutorKind;
|
|
199
|
-
/** The child whose output composed this task (ADR-0033).
|
|
214
|
+
/** The logical child whose output composed this task (ADR-0033). */
|
|
200
215
|
taskFrom?: string;
|
|
216
|
+
/** The unique occurrence whose output composed this task. */
|
|
217
|
+
taskFromExecutionId?: string;
|
|
201
218
|
taskDigest?: string;
|
|
202
219
|
correlation?: CorrelationMetadata;
|
|
203
220
|
refusal?: StructuredRefusal;
|
|
@@ -209,5 +226,6 @@ export declare function appendLedgerEvent(options: LedgerOptions, event: Runtime
|
|
|
209
226
|
export declare function appendRecord(options: LedgerOptions, record: GrantRecord): Promise<void>;
|
|
210
227
|
/** True when this record shows an agent asking for more than it holds. */
|
|
211
228
|
export declare function isEscalationAttempt(record: GrantRecord): boolean;
|
|
212
|
-
export { buildChildLifecycleEvent, buildWorkspaceLeaseEvent, type ChildLifecycleEvent, type CheckReceiptLedgerEvent, type RuntimeLedgerEvent, type WorkspaceLeaseEvent, type WorkspaceLeaseOutcome, } from "./ledger-events.ts";
|
|
229
|
+
export { CHILD_LIFECYCLE_STATES, CHILD_PROCESS_SIGNALS, WORKSPACE_ACCESSES, WORKSPACE_LEASE_OUTCOMES, WORKSPACE_RECOVERY_VALUES, buildCheckReceiptLedgerEvent, buildChildLifecycleEvent, buildWorkspaceLeaseEvent, type CapabilityDecisionEvent, type ChildLifecycleEvent, type ChildLifecycleState, type ChildProcessSignal, type CheckReceiptLedgerEvent, type RuntimeLedgerEvent, type WorkspaceAccess, type WorkspaceLeaseEvent, type WorkspaceLeaseOutcome, type WorkspaceRecovery, } from "./ledger-events.ts";
|
|
230
|
+
export { WORKFLOW_FACT_KINDS, WORKFLOW_FACT_PROVENANCE, WORKFLOW_FACT_STATES, buildWorkflowFactEvent, type WorkflowFactEvent, type WorkflowFactKind, type WorkflowFactProvenance, type WorkflowFactState, } from "./workflow-facts.ts";
|
|
213
231
|
//# sourceMappingURL=ledger.d.ts.map
|
package/dist/ledger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ledger.d.ts","sourceRoot":"","sources":["../src/ledger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAKH,OAAO,KAAK,EAAE,UAAU,EAAE,a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Y,CAAC,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAE7F;AAED,0EAA0E;AAC1E,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAEhE;AAED,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,kBAAkB,EAClB,wBAAwB,EACxB,yBAAyB,EACzB,4BAA4B,EAC5B,wBAAwB,EACxB,wBAAwB,EACxB,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,GACvB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,oBAAoB,EACpB,sBAAsB,EACtB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,GACvB,MAAM,qBAAqB,CAAC"}
|
package/dist/ledger.js
CHANGED
|
@@ -22,18 +22,45 @@ import { appendFile, mkdir, readFile } from "node:fs/promises";
|
|
|
22
22
|
import { withFileLock } from "./file-lock.js";
|
|
23
23
|
import { dirname } from "node:path";
|
|
24
24
|
import { DELEGATE_SUBJECT } from "./approval.js";
|
|
25
|
-
|
|
25
|
+
import { assertExecutionId } from "./execution-id.js";
|
|
26
|
+
import { assertLedgerV3Wire } from "./ledger-v3-validation.js";
|
|
27
|
+
export const LEDGER_VERSION = 3;
|
|
28
|
+
export const LEDGER_EVENT_KINDS = [
|
|
29
|
+
"capability_decision", "workspace_lease", "child_lifecycle", "check_receipt", "workflow_fact",
|
|
30
|
+
];
|
|
31
|
+
export const LEDGER_GATE_OUTCOMES = ["declined", "dismissed", "no-ui", "error"];
|
|
26
32
|
export function buildRecord(args) {
|
|
33
|
+
if (args.taskDigest !== undefined) {
|
|
34
|
+
if (!/^[a-f0-9]{64}$/i.test(args.taskDigest))
|
|
35
|
+
throw new TypeError("taskDigest must be a SHA-256 hex digest");
|
|
36
|
+
assertExecutionId(args.executionId);
|
|
37
|
+
if (args.parentExecutionId !== null)
|
|
38
|
+
assertExecutionId(args.parentExecutionId, "parentExecutionId");
|
|
39
|
+
if (args.parentExecutionId === args.executionId)
|
|
40
|
+
throw new TypeError("an execution cannot be its own parent");
|
|
41
|
+
if (args.taskFromExecutionId !== undefined)
|
|
42
|
+
assertExecutionId(args.taskFromExecutionId, "taskFromExecutionId");
|
|
43
|
+
}
|
|
44
|
+
if (args.definitionDigest && !/^[a-f0-9]{64}$/i.test(args.definitionDigest.sha256)) {
|
|
45
|
+
throw new TypeError("definitionDigest.sha256 must be a SHA-256 hex digest");
|
|
46
|
+
}
|
|
27
47
|
// R-46: the scalar is a SUMMARY, emitted only when it cannot mislead. `buildRecord` derives it rather
|
|
28
48
|
// than accepting it, so a call site cannot supply one that disagrees with the map beside it.
|
|
29
49
|
const sources = args.approvalSources ?? {};
|
|
30
50
|
const distinct = [...new Set(Object.values(sources))];
|
|
31
51
|
const scopes = args.approvalScopes ?? {};
|
|
32
52
|
const distinctScopes = [...new Set(Object.values(scopes))];
|
|
33
|
-
|
|
34
|
-
// A trusted task digest is what distinguishes a
|
|
53
|
+
const record = {
|
|
54
|
+
// A trusted task digest is what distinguishes a v3 capability event from the legacy construction API.
|
|
35
55
|
// Production delegation always supplies it; old TypeScript callers remain able to append legacy lines.
|
|
36
|
-
...(args.taskDigest
|
|
56
|
+
...(args.taskDigest !== undefined
|
|
57
|
+
? {
|
|
58
|
+
ledgerVersion: LEDGER_VERSION,
|
|
59
|
+
event: "capability_decision",
|
|
60
|
+
executionId: args.executionId,
|
|
61
|
+
parentExecutionId: args.parentExecutionId,
|
|
62
|
+
}
|
|
63
|
+
: {}),
|
|
37
64
|
ts: args.now.toISOString(),
|
|
38
65
|
parentId: args.parentId,
|
|
39
66
|
childId: args.childId,
|
|
@@ -41,7 +68,8 @@ export function buildRecord(args) {
|
|
|
41
68
|
agentType: args.agentType,
|
|
42
69
|
executor: args.executor,
|
|
43
70
|
...(args.taskFrom ? { taskFrom: args.taskFrom } : {}),
|
|
44
|
-
...(args.
|
|
71
|
+
...(args.taskFromExecutionId ? { taskFromExecutionId: args.taskFromExecutionId } : {}),
|
|
72
|
+
...(args.taskDigest !== undefined ? { taskDigest: args.taskDigest } : {}),
|
|
45
73
|
...(args.correlation ? { correlation: structuredClone(args.correlation) } : {}),
|
|
46
74
|
...(args.refusal ? { refusal: structuredClone(args.refusal) } : {}),
|
|
47
75
|
requested: args.requested,
|
|
@@ -68,6 +96,9 @@ export function buildRecord(args) {
|
|
|
68
96
|
...(args.gateOutcome && args.gateOutcome !== "granted" ? { gateOutcome: args.gateOutcome } : {}),
|
|
69
97
|
...(args.definitionDigest ? { definitionDigest: args.definitionDigest } : {}),
|
|
70
98
|
};
|
|
99
|
+
if (args.taskDigest !== undefined)
|
|
100
|
+
assertLedgerV3Wire(record);
|
|
101
|
+
return record;
|
|
71
102
|
}
|
|
72
103
|
// R-49: the lock moved to `src/file-lock.ts` so the approvals store could use the SAME one rather than
|
|
73
104
|
// grow a second copy. Re-exported because `./ledger` is a published subpath and these were part of it.
|
|
@@ -110,5 +141,6 @@ export async function appendRecord(options, record) {
|
|
|
110
141
|
export function isEscalationAttempt(record) {
|
|
111
142
|
return record.denied.length > 0;
|
|
112
143
|
}
|
|
113
|
-
export { buildChildLifecycleEvent, buildWorkspaceLeaseEvent, } from "./ledger-events.js";
|
|
144
|
+
export { CHILD_LIFECYCLE_STATES, CHILD_PROCESS_SIGNALS, WORKSPACE_ACCESSES, WORKSPACE_LEASE_OUTCOMES, WORKSPACE_RECOVERY_VALUES, buildCheckReceiptLedgerEvent, buildChildLifecycleEvent, buildWorkspaceLeaseEvent, } from "./ledger-events.js";
|
|
145
|
+
export { WORKFLOW_FACT_KINDS, WORKFLOW_FACT_PROVENANCE, WORKFLOW_FACT_STATES, buildWorkflowFactEvent, } from "./workflow-facts.js";
|
|
114
146
|
//# sourceMappingURL=ledger.js.map
|
package/dist/ledger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ledger.js","sourceRoot":"","sources":["../src/ledger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"ledger.js","sourceRoot":"","sources":["../src/ledger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAOjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,MAAM,CAAC,MAAM,cAAc,GAAG,CAAU,CAAC;AACzC,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,qBAAqB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,eAAe,EAAE,eAAe;CACrF,CAAC;AAEX,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,CAAU,CAAC;AA4JzF,MAAM,UAAU,WAAW,CAAC,IAgC3B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
|
|
|
41
41
|
* Without it every level restarts at `d0` and the ledger cannot be joined into a tree across processes.
|
|
42
42
|
*/
|
|
43
43
|
export declare const ENV_PARENT_ID = "PI_GRANTS_PARENT_ID";
|
|
44
|
+
/** Unique identity of this governed execution occurrence; unlike ENV_PARENT_ID it is never reused. */
|
|
45
|
+
export declare const ENV_EXECUTION_ID = "PI_GRANTS_EXECUTION_ID";
|
|
44
46
|
export declare const ENV_DEPTH = "PI_GRANTS_DEPTH";
|
|
45
47
|
export declare const ENV_MAX_DEPTH = "PI_GRANTS_MAX_DEPTH";
|
|
46
48
|
export declare const ENV_GATED = "PI_GRANTS_GATED";
|
|
@@ -53,7 +55,7 @@ export declare const ENV_APPROVED = "PI_GRANTS_APPROVED";
|
|
|
53
55
|
* environment into a child's — a governance variable a child inherits by accident is one nobody decided
|
|
54
56
|
* to give it.
|
|
55
57
|
*/
|
|
56
|
-
export declare const GRANT_ENV_KEYS: readonly ["PI_GRANTS_GRANT", "PI_GRANTS_DEPTH", "PI_GRANTS_MAX_DEPTH", "PI_GRANTS_GATED", "PI_GRANTS_LEDGER", "PI_GRANTS_APPROVED", "PI_GRANTS_FANOUT", "PI_GRANTS_PARENT_ID"];
|
|
58
|
+
export declare const GRANT_ENV_KEYS: readonly ["PI_GRANTS_GRANT", "PI_GRANTS_DEPTH", "PI_GRANTS_MAX_DEPTH", "PI_GRANTS_GATED", "PI_GRANTS_LEDGER", "PI_GRANTS_APPROVED", "PI_GRANTS_FANOUT", "PI_GRANTS_PARENT_ID", "PI_GRANTS_EXECUTION_ID"];
|
|
57
59
|
export declare const parseList: (raw: string | undefined) => Capability[];
|
|
58
60
|
/**
|
|
59
61
|
* Derive this session's own grant from what it inherited and what pi actually gave it.
|
|
@@ -168,6 +170,22 @@ export interface ChildEnvInput {
|
|
|
168
170
|
* empty grant, so they can spawn nothing. That fails closed. It is also unreachable in normal flow,
|
|
169
171
|
* because a session's first provider request always precedes its first tool call.
|
|
170
172
|
*/
|
|
173
|
+
/**
|
|
174
|
+
* The part of a grant a child may inherit: everything but the wildcards that are HELD, never handed down.
|
|
175
|
+
*
|
|
176
|
+
* `tool:*` for R-26's reason — a root that handed it down let every descendant reacquire the full catalog.
|
|
177
|
+
* `workspace:*` for the same reason one namespace over (R-131): a descendant holding it could route anywhere
|
|
178
|
+
* the registry lists, which is the attenuation failure ADR-0035 exists to close. `agent:*` is deliberately
|
|
179
|
+
* NOT stripped — ADR-0023 decided that a session authorised for any definition passes that on, because
|
|
180
|
+
* definitions are ceilings rather than roots.
|
|
181
|
+
*
|
|
182
|
+
* **Exported, and there is exactly one spelling of this rule on purpose.** It shipped as a filter inline in
|
|
183
|
+
* `childEnv` and nowhere else, so a grant travelling the OTHER path — `delegate.ts` building a child's
|
|
184
|
+
* `PI_GRANTS_GRANT` from `result.effective` — carried `workspace:*` straight down. The test written beside
|
|
185
|
+
* that fix exercised `childEnv`, which is not the path a delegated child's grant travels, so it could not
|
|
186
|
+
* catch it. R-28's shape: two routes for one rule, with the guard on the quieter one. Both call this now.
|
|
187
|
+
*/
|
|
188
|
+
export declare function inheritableGrant(grant: readonly Capability[]): Capability[];
|
|
171
189
|
export declare function childEnv(input: ChildEnvInput): Record<string, string>;
|
|
172
190
|
/**
|
|
173
191
|
* The environment for a child this process spawns itself: the parent's environment with every governance
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"propagation.d.ts","sourceRoot":"","sources":["../src/propagation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"propagation.d.ts","sourceRoot":"","sources":["../src/propagation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG/C,OAAO,EAAoB,KAAK,mBAAmB,EAAE,MAAM,eAAe,CAAC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AAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,EAAE,CAGlE;AAED,MAAM,WAAW,aAAa;IAC5B,6EAA6E;IAC7E,QAAQ,EAAE,UAAU,EAAE,CAAC;IACvB,qDAAqD;IACrD,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB;;;;;;OAMG;IACH;;;OAGG;IACH,QAAQ,CAAC,EAAE,mBAAmB,EAAE,CAAC;IACjC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;;;;;GAWG;AACH;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,UAAU,EAAE,GAAG,UAAU,EAAE,CAE3E;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAiBrE;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAC3B,SAAS,EAAE,MAAM,CAAC,UAAU,EAC5B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,MAAM,CAAC,UAAU,CAInB;AAED,2GAA2G;AAC3G,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,EAAE,GAAG,IAAI,CAoBlE"}
|
package/dist/propagation.js
CHANGED
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
* interceptor and pi handed the child more than the parent held, the intersection clamps it back.
|
|
26
26
|
*/
|
|
27
27
|
import { WILDCARD } from "./pi-tools.js";
|
|
28
|
+
import { WORKSPACE_WILDCARD } from "./resolve.js";
|
|
28
29
|
import { inheritApprovals } from "./approval.js";
|
|
29
30
|
import { assertCapabilitiesArePropagatable } from "./capabilities.js";
|
|
30
31
|
export const ENV_GRANT = "PI_GRANTS_GRANT";
|
|
@@ -42,6 +43,8 @@ export const ENV_FANOUT = "PI_GRANTS_FANOUT";
|
|
|
42
43
|
* Without it every level restarts at `d0` and the ledger cannot be joined into a tree across processes.
|
|
43
44
|
*/
|
|
44
45
|
export const ENV_PARENT_ID = "PI_GRANTS_PARENT_ID";
|
|
46
|
+
/** Unique identity of this governed execution occurrence; unlike ENV_PARENT_ID it is never reused. */
|
|
47
|
+
export const ENV_EXECUTION_ID = "PI_GRANTS_EXECUTION_ID";
|
|
45
48
|
export const ENV_DEPTH = "PI_GRANTS_DEPTH";
|
|
46
49
|
export const ENV_MAX_DEPTH = "PI_GRANTS_MAX_DEPTH";
|
|
47
50
|
export const ENV_GATED = "PI_GRANTS_GATED";
|
|
@@ -63,6 +66,7 @@ export const GRANT_ENV_KEYS = [
|
|
|
63
66
|
ENV_APPROVED,
|
|
64
67
|
ENV_FANOUT,
|
|
65
68
|
ENV_PARENT_ID,
|
|
69
|
+
ENV_EXECUTION_ID,
|
|
66
70
|
];
|
|
67
71
|
export const parseList = (raw) => (raw ?? "").split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
68
72
|
/** Does a bare pi tool name correspond to this capability? `read` matches `tool:read` and `ext:pkg/read`. */
|
|
@@ -191,10 +195,28 @@ export function gatedFromEnv(raw) {
|
|
|
191
195
|
* empty grant, so they can spawn nothing. That fails closed. It is also unreachable in normal flow,
|
|
192
196
|
* because a session's first provider request always precedes its first tool call.
|
|
193
197
|
*/
|
|
198
|
+
/**
|
|
199
|
+
* The part of a grant a child may inherit: everything but the wildcards that are HELD, never handed down.
|
|
200
|
+
*
|
|
201
|
+
* `tool:*` for R-26's reason — a root that handed it down let every descendant reacquire the full catalog.
|
|
202
|
+
* `workspace:*` for the same reason one namespace over (R-131): a descendant holding it could route anywhere
|
|
203
|
+
* the registry lists, which is the attenuation failure ADR-0035 exists to close. `agent:*` is deliberately
|
|
204
|
+
* NOT stripped — ADR-0023 decided that a session authorised for any definition passes that on, because
|
|
205
|
+
* definitions are ceilings rather than roots.
|
|
206
|
+
*
|
|
207
|
+
* **Exported, and there is exactly one spelling of this rule on purpose.** It shipped as a filter inline in
|
|
208
|
+
* `childEnv` and nowhere else, so a grant travelling the OTHER path — `delegate.ts` building a child's
|
|
209
|
+
* `PI_GRANTS_GRANT` from `result.effective` — carried `workspace:*` straight down. The test written beside
|
|
210
|
+
* that fix exercised `childEnv`, which is not the path a delegated child's grant travels, so it could not
|
|
211
|
+
* catch it. R-28's shape: two routes for one rule, with the guard on the quieter one. Both call this now.
|
|
212
|
+
*/
|
|
213
|
+
export function inheritableGrant(grant) {
|
|
214
|
+
return grant.filter((c) => c !== WILDCARD && c !== WORKSPACE_WILDCARD);
|
|
215
|
+
}
|
|
194
216
|
export function childEnv(input) {
|
|
195
217
|
if (input.governed === false)
|
|
196
218
|
return {};
|
|
197
|
-
const inheritable = input.ownGrant
|
|
219
|
+
const inheritable = inheritableGrant(input.ownGrant);
|
|
198
220
|
const env = {
|
|
199
221
|
[ENV_GRANT]: (assertCapabilitiesArePropagatable(inheritable), inheritable.join(",")),
|
|
200
222
|
[ENV_DEPTH]: String(input.depth + 1),
|
package/dist/propagation.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"propagation.js","sourceRoot":"","sources":["../src/propagation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAA4B,MAAM,eAAe,CAAC;AAC3E,OAAO,EAAE,iCAAiC,EAAE,MAAM,mBAAmB,CAAC;AAEtE,MAAM,CAAC,MAAM,SAAS,GAAG,iBAAiB,CAAC;AAC3C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,kBAAkB,CAAC;AAC7C;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,qBAAqB,CAAC;AACnD,MAAM,C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AW,CAAC,EAAE,CAAC;QACzC,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAC9B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC;YAAE,SAAS;QACxC,MAAM,KAAK,GAAG,SAAS;aACpB,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;YACb,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;gBAAE,OAAO,SAAS,CAAC;YAC1D,MAAM,CAAC,GAAG,KAAgC,CAAC;YAC3C,2EAA2E;YAC3E,MAAM,MAAM,GAAG,CAAC,CAAC,QAA+C,CAAC;YACjE,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,IAAI,MAAM,EAAE,IAAI,CAAC;YACpC,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;QACrD,CAAC,CAAC;aACD,MAAM,CAAC,CAAC,CAAC,EAAe,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1C,mGAAmG;QACnG,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/refusals.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const REFUSAL_CODES: readonly ["CAPABILITY_ESCALATION", "GRANT_ID_MALFORMED", "DEFINITION_NOT_AUTHORIZED", "UNDECLARED_TOOLS", "UNKNOWN_TOOL", "GATED_UNAPPROVED", "APPROVAL_EXPIRED", "APPROVAL_SCOPE_MISMATCH", "APPROVAL_FLOW_FAILED", "DEPTH_EXCEEDED", "FANOUT_EXCEEDED", "EXECUTOR_UNAVAILABLE", "CHILD_TIMED_OUT", "CHILD_CANCELLED", "CHILD_EXIT_NONZERO", "TASK_MISSING", "UNKNOWN_DEFINITION", "CEILING_PATTERNS_UNRESOLVED", "NARROWING_VIOLATED", "DEFINITION_UNREADABLE", "CORRELATION_TOO_LARGE", "CORRELATION_INVALID", "LEDGER_WRITE_FAILED", "FANOUT_FAILED", "WORKSPACE_NOT_REGISTERED", "WORKSPACE_WRITE_CONFLICT", "WORKSPACE_LEASE_STALE", "CHECK_NOT_CONFIGURED", "CHECK_CONFIGURATION_INVALID", "CHECK_IDENTITY_UNAVAILABLE", "CHECK_IDENTITY_MISMATCH"];
|
|
1
|
+
export declare const REFUSAL_CODES: readonly ["CAPABILITY_ESCALATION", "GRANT_ID_MALFORMED", "DEFINITION_NOT_AUTHORIZED", "UNDECLARED_TOOLS", "UNKNOWN_TOOL", "GATED_UNAPPROVED", "APPROVAL_EXPIRED", "APPROVAL_SCOPE_MISMATCH", "APPROVAL_FLOW_FAILED", "DEPTH_EXCEEDED", "FANOUT_EXCEEDED", "EXECUTOR_UNAVAILABLE", "CHILD_TIMED_OUT", "CHILD_CANCELLED", "CHILD_EXIT_NONZERO", "TASK_MISSING", "UNKNOWN_DEFINITION", "CEILING_PATTERNS_UNRESOLVED", "NARROWING_VIOLATED", "DEFINITION_UNREADABLE", "CORRELATION_TOO_LARGE", "CORRELATION_INVALID", "LEDGER_WRITE_FAILED", "FANOUT_FAILED", "WORKSPACE_NOT_REGISTERED", "WORKSPACE_NOT_AUTHORIZED", "WORKSPACE_WRITE_CONFLICT", "WORKSPACE_LEASE_STALE", "CHECK_NOT_CONFIGURED", "CHECK_CONFIGURATION_INVALID", "CHECK_IDENTITY_UNAVAILABLE", "CHECK_IDENTITY_MISMATCH"];
|
|
2
2
|
export type RefusalCode = (typeof REFUSAL_CODES)[number];
|
|
3
3
|
export interface StructuredRefusal {
|
|
4
4
|
code: RefusalCode;
|
package/dist/refusals.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refusals.d.ts","sourceRoot":"","sources":["../src/refusals.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"refusals.d.ts","sourceRoot":"","sources":["../src/refusals.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,wvBAqChB,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzD,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,WAAW,CAAC;IAClB,8EAA8E;IAC9E,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC,CAAC;CAC5D;AAED,wBAAgB,OAAO,CACrB,IAAI,EAAE,WAAW,EACjB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,iBAAiB,CAAC,SAAS,CAAC,GACrC,iBAAiB,CAEnB;AAED,+GAA+G;AAC/G,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,OAAO,CAAC,EAAE,iBAAiB,CAAC,SAAS,CAAC,CAAC;gBAEpC,KAAK,EAAE,iBAAiB;CAMrC"}
|
package/dist/refusals.js
CHANGED
package/dist/refusals.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refusals.js","sourceRoot":"","sources":["../src/refusals.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,uBAAuB;IACvB,oBAAoB;IACpB,2BAA2B;IAC3B,kBAAkB;IAClB,cAAc;IACd,kBAAkB;IAClB,kBAAkB;IAClB,yBAAyB;IACzB,sBAAsB;IACtB,gBAAgB;IAChB,iBAAiB;IACjB,sBAAsB;IACtB,qGAAqG;IACrG,wFAAwF;IACxF,iBAAiB;IACjB,iBAAiB;IACjB,oBAAoB;IACpB,kGAAkG;IAClG,sEAAsE;IACtE,cAAc;IACd,oBAAoB;IACpB,6BAA6B;IAC7B,oBAAoB;IACpB,uBAAuB;IACvB,uBAAuB;IACvB,qBAA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B,uBAAuB;IACvB,uBAAuB;IACvB,qBAAqB;IACrB,qBAAqB;IACrB,eAAe;IACf,0BAA0B;IAC1B,0BAA0B;IAC1B,0BAA0B;IAC1B,uBAAuB;IACvB,sBAAsB;IACtB,6BAA6B;IAC7B,4BAA4B;IAC5B,yBAAyB;CACjB,CAAC;AAWX,MAAM,UAAU,OAAO,CACrB,IAAiB,EACjB,OAAe,EACf,OAAsC;IAEtC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;AAC/G,CAAC;AAED,+GAA+G;AAC/G,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IACjC,IAAI,CAAc;IAClB,OAAO,CAAgC;IAEhD,YAAY,KAAwB;QAClC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;QAChC,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;IAC/B,CAAC;CACF"}
|
package/dist/resolve.d.ts
CHANGED
|
@@ -49,6 +49,16 @@ export declare function expandSubsumed(grant: Capability[]): Capability[];
|
|
|
49
49
|
* `tool:*` — authority to grant every tool — which made the safe configuration the laborious one.
|
|
50
50
|
*/
|
|
51
51
|
export declare const AGENT_WILDCARD: Capability;
|
|
52
|
+
/**
|
|
53
|
+
* `workspace:*` covers any `workspace:<id>` — ADR-0035, and the second namespace wildcard.
|
|
54
|
+
*
|
|
55
|
+
* Added as a deliberate edit, which is what the comment in `resolve()` below asks for: there is no
|
|
56
|
+
* generalised `<ns>:*` rule, so a namespace does not acquire a wildcard by existing. Unlike `agent:*` this
|
|
57
|
+
* one is **not inheritable** (`childEnv` strips it) — R-26's rule, because a root that handed
|
|
58
|
+
* `workspace:*` down would make routing attenuation meaningless below the root, which is the exact defect
|
|
59
|
+
* R-131 records.
|
|
60
|
+
*/
|
|
61
|
+
export declare const WORKSPACE_WILDCARD: Capability;
|
|
52
62
|
export interface ResolveInput {
|
|
53
63
|
/** What the delegating agent asked to give the child. */
|
|
54
64
|
requested: Capability[];
|
package/dist/resolve.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../src/resolve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,yFAAyF;AACzF,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAEhC;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,EAAE,SAAS,UAAU,EAGvD,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,SAAS,UAAU,EAAE,CAAC,CAU3E,CAAC;AAEF,4DAA4D;AAC5D,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,UAAU,EAAE,CAMhE;AAKD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,cAAc,EAAE,UAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../src/resolve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,yFAAyF;AACzF,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAEhC;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,EAAE,SAAS,UAAU,EAGvD,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,SAAS,UAAU,EAAE,CAAC,CAU3E,CAAC;AAEF,4DAA4D;AAC5D,wBA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edCapability } from "./capabilities.js";
|
|
|
69
69
|
* `tool:*` — authority to grant every tool — which made the safe configuration the laborious one.
|
|
70
70
|
*/
|
|
71
71
|
export const AGENT_WILDCARD = "agent:*";
|
|
72
|
+
/**
|
|
73
|
+
* `workspace:*` covers any `workspace:<id>` — ADR-0035, and the second namespace wildcard.
|
|
74
|
+
*
|
|
75
|
+
* Added as a deliberate edit, which is what the comment in `resolve()` below asks for: there is no
|
|
76
|
+
* generalised `<ns>:*` rule, so a namespace does not acquire a wildcard by existing. Unlike `agent:*` this
|
|
77
|
+
* one is **not inheritable** (`childEnv` strips it) — R-26's rule, because a root that handed
|
|
78
|
+
* `workspace:*` down would make routing attenuation meaningless below the root, which is the exact defect
|
|
79
|
+
* R-131 records.
|
|
80
|
+
*/
|
|
81
|
+
export const WORKSPACE_WILDCARD = "workspace:*";
|
|
72
82
|
const unique = (xs) => [...new Set(xs)].sort();
|
|
73
83
|
/**
|
|
74
84
|
* Resolve a child's grant. Total and side-effect free; every rejected capability is reported rather
|
|
@@ -79,7 +89,10 @@ export function resolve(input) {
|
|
|
79
89
|
const held = new Set(input.parentGrant);
|
|
80
90
|
const parent = input.subsumption === false ? held : new Set(expandSubsumed(input.parentGrant));
|
|
81
91
|
/**
|
|
82
|
-
* `agent:*` covers any `agent:<name>` — ADR-0023
|
|
92
|
+
* `agent:*` covers any `agent:<name>` — ADR-0023. It was the only wildcard rule in this function when
|
|
93
|
+
* that was written; ADR-0035 added a third, so `covered()` now has `tool:*`, `agent:*` and `workspace:*`.
|
|
94
|
+
* There is still no GENERALISED `<ns>:*` rule: each is a deliberate edit, which is the property worth
|
|
95
|
+
* keeping. Corrected because the sentence sat eighty lines above "all THREE wildcards are excluded".
|
|
83
96
|
*
|
|
84
97
|
* `resolve` is otherwise exact-match plus subsumption, deliberately: `tool:*` works not because anything
|
|
85
98
|
* here understands it, but because `deriveOwnGrant` *enumerates* a session's observed tool names beside
|
|
@@ -104,12 +117,15 @@ export function resolve(input) {
|
|
|
104
117
|
* spellings of one rule, and the enforcing one was wrong.
|
|
105
118
|
*/
|
|
106
119
|
const anyCapability = held.has(WILDCARD);
|
|
120
|
+
const anyWorkspace = held.has(WORKSPACE_WILDCARD);
|
|
107
121
|
// A malformed id is never covered — not by an exact hold, and above all not by a wildcard's PREFIX rule,
|
|
108
122
|
// which is how `agent:x,tool:bash` got admitted and then split into two capabilities in the child.
|
|
109
123
|
// Landing in `denied` is the right outcome rather than a throw: it fails closed AND records an
|
|
110
124
|
// escalation attempt, so the ledger shows the attempt instead of a clean line.
|
|
111
125
|
const covered = (c) => isWellFormedCapability(c)
|
|
112
|
-
&& (parent.has(c) || anyCapability
|
|
126
|
+
&& (parent.has(c) || anyCapability
|
|
127
|
+
|| (anyDefinition && c.startsWith("agent:"))
|
|
128
|
+
|| (anyWorkspace && c.startsWith("workspace:")));
|
|
113
129
|
const ceiling = input.ceiling === undefined ? null : new Set(input.ceiling);
|
|
114
130
|
const gated = new Set(input.gated ?? []);
|
|
115
131
|
const approved = new Set(input.approved ?? []);
|
|
@@ -148,7 +164,15 @@ export function resolve(input) {
|
|
|
148
164
|
// F9: capabilities covered by a WILDCARD are not "subsumed" — this field means "the grant is broader
|
|
149
165
|
// than its list suggests", which is the `bash`-covers-`grep` warning. A wildcard holder already knows
|
|
150
166
|
// its grant is broad; listing every id under it would bury the signal the field exists to carry.
|
|
151
|
-
|
|
167
|
+
//
|
|
168
|
+
// All THREE wildcards are excluded. `anyWorkspace` was missing, so a caller holding `workspace:*` saw
|
|
169
|
+
// its own `workspace:prod` reported as subsumed while the `agent:*` holder correctly saw nothing — the
|
|
170
|
+
// field contradicting its own rule, and a false "broader than it looks" flag in the ledger and in
|
|
171
|
+
// `/grants`. Every wildcard added to `covered()` above needs a line here; that is now three for three.
|
|
172
|
+
subsumedBy: effective.filter((c) => !held.has(c)
|
|
173
|
+
&& !anyCapability
|
|
174
|
+
&& !(anyDefinition && c.startsWith("agent:"))
|
|
175
|
+
&& !(anyWorkspace && c.startsWith("workspace:"))),
|
|
152
176
|
};
|
|
153
177
|
}
|
|
154
178
|
/**
|
package/dist/resolve.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.js","sourceRoot":"","sources":["../src/resolve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAA0B;IAC3D,2BAA2B;IAC3B,kBAAkB;CACnB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,WAAW,GAAwD;IAC9E,WAAW,EAAE;QACX,WAAW;QACX,WAAW;QACX,SAAS;QACT,WAAW;QACX,YAAY;QACZ,WAAW;QACX,gBAAgB;KACjB;CACF,CAAC;AAEF,4DAA4D;AAC5D,MAAM,UAAU,cAAc,CAAC,KAAmB;IAChD,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;IAChC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,KAAK,MAAM,OAAO,IAAI,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE;YAAE,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACvE,CAAC;IACD,OAAO,CAAC,GAAG,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC;AAC9B,CAAC;AAED,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAE3D;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,cAAc,GAAe,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"resolve.js","sourceRoot":"","sources":["../src/resolve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAA0B;IAC3D,2BAA2B;IAC3B,kBAAkB;CACnB,CAAC;AAEF;;;;;;;;;;;;GA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AC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC3C,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ADR-0035's three routing guards, and why each one is shaped the way it is.
|
|
3
|
+
*
|
|
4
|
+
* Lifted out of `delegate.ts` when it crossed the 400-line ceiling `test/file-size.test.ts` enforces — the
|
|
5
|
+
* same move `grants.ts` made at 398 and `delegate.ts` itself made at 413. It is a real seam rather than a
|
|
6
|
+
* line-count dodge: all three answer one question, *may this caller route this child to this workspace, and
|
|
7
|
+
* is the id even usable as a capability?*, and none of them looks at anything else in a delegation. The
|
|
8
|
+
* alternative was trimming the rationale below to fit, which is how a codebase loses the reasons for its
|
|
9
|
+
* guards.
|
|
10
|
+
*
|
|
11
|
+
* Each returns a refusal DESCRIPTOR rather than a `Delegation`, so the planner keeps sole ownership of
|
|
12
|
+
* assembling records. `denied` is present exactly when the attempt should count as an escalation.
|
|
13
|
+
*/
|
|
14
|
+
import { type Capability } from "./resolve.ts";
|
|
15
|
+
import type { RefusalCode } from "./refusals.ts";
|
|
16
|
+
export interface RoutingRefusal {
|
|
17
|
+
code: RefusalCode;
|
|
18
|
+
reason: string;
|
|
19
|
+
/**
|
|
20
|
+
* The capability to record in `denied`, when this refusal IS an escalation attempt.
|
|
21
|
+
*
|
|
22
|
+
* Absent for a malformed id, which is a bad request rather than a bid for authority — and seeding `denied`
|
|
23
|
+
* with an id that re-splits into several capabilities would make the one signal `isEscalationAttempt` reads
|
|
24
|
+
* unparseable. Present for an unauthorised route, which is exactly a bid for authority.
|
|
25
|
+
*/
|
|
26
|
+
denied?: Capability[];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* May this caller route a child to `boundWorkspaceId`, and is that id usable as a capability id at all?
|
|
30
|
+
*
|
|
31
|
+
* Checked before anything is said about the target, for the reason `maySpawnDefinition` is: it is a
|
|
32
|
+
* governance question about the SESSION. Before ADR-0035 nothing checked it — the registry inherited into
|
|
33
|
+
* every governed child and a child routed to `staging` could route its grandchild to `prod` (R-131, measured
|
|
34
|
+
* in `docs/probes/g36-workspace-attenuation`).
|
|
35
|
+
*
|
|
36
|
+
* **Well-formedness first, because `workspace_id` is a model-facing tool parameter** and the next step turns
|
|
37
|
+
* it into a capability id. `workspace_id: "prod,tool:bash"` produced a `WORKSPACE_NOT_AUTHORIZED` whose
|
|
38
|
+
* `denied` array held `workspace:prod,tool:bash`: no authority minted, since the refusal is terminal, but
|
|
39
|
+
* `denied` is the channel `isEscalationAttempt` and `/grants ledger` count and an id that re-splits makes it
|
|
40
|
+
* unreadable. 0.18.1 is what happens when a comma goes unremarked.
|
|
41
|
+
*
|
|
42
|
+
* **`!== undefined`, not truthiness.** `workspace_id: ""` is falsy, so it skipped BOTH checks and failed
|
|
43
|
+
* closed much later at `resolveWorkspace` with `denied: []` — an unauthorised routing attempt invisible to
|
|
44
|
+
* every audit query. An empty id is a malformed id, not an absent one.
|
|
45
|
+
*/
|
|
46
|
+
export declare function checkRoutingAuthority(boundWorkspaceId: string | undefined, ownGrant: readonly Capability[]): RoutingRefusal | null;
|
|
47
|
+
/**
|
|
48
|
+
* May `workspace:*` be handed to a child? No — and only its HOLDER gets told so in those words.
|
|
49
|
+
*
|
|
50
|
+
* `workspace:*` is held and never inherited, so a child that "was granted" it would receive an env without
|
|
51
|
+
* it, and the ledger would record an authority the child does not have — the mirror image of R-131 and just
|
|
52
|
+
* as unreadable. `childEnv` strips it from a session's OWN grant because a root legitimately holds it; asking
|
|
53
|
+
* to hand it to a child is a different act and the honest answer is no. `NARROWING_VIOLATED` is the existing
|
|
54
|
+
* code for "this grant would not actually narrow", which is precisely what routing authority over every
|
|
55
|
+
* registered root does.
|
|
56
|
+
*
|
|
57
|
+
* **`tool:*` does NOT reach the same outcome, and an earlier comment claimed it did.** It said
|
|
58
|
+
* `assertNarrowing` produces the equivalent refusal; it does not. `UNIVERSAL_CAPABILITIES` is
|
|
59
|
+
* `["ext:pi-fabric/fabric_exec", "tool:fabric_exec"]`, so `result.universal` is empty for `tool:*` and
|
|
60
|
+
* nothing throws: requesting it for a child is allowed, recorded as granted, and silently stripped from the
|
|
61
|
+
* child env by `inheritableGrant` (R-135). The asymmetry is deliberate — an ungoverned session's own grant IS
|
|
62
|
+
* `tool:*`, so refusing to spawn from one would break governance-is-opt-in, while `workspace:*` only ever
|
|
63
|
+
* appears in `requested` because somebody asked — but it is an asymmetry, not one rule twice.
|
|
64
|
+
*
|
|
65
|
+
* **Only for a holder.** A caller without it is attempting an escalation, and this refusal would tell it the
|
|
66
|
+
* wildcard "is held, never inherited" — false about a session holding nothing of the sort — while leaving
|
|
67
|
+
* `denied` empty, so nothing counted a model probing `tools: ["workspace:*"]`. Returning `null` lets
|
|
68
|
+
* `resolve()` deny it as uncovered, which is what `agent:*` and `tool:*` already do.
|
|
69
|
+
*/
|
|
70
|
+
export declare function checkWorkspaceWildcardRequest(requested: readonly Capability[], ownGrant: readonly Capability[]): RoutingRefusal | null;
|
|
71
|
+
//# sourceMappingURL=routing-authority.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routing-authority.d.ts","sourceRoot":"","sources":["../src/routing-authority.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAsB,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAEnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,WAAW,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,UAAU,EAAE,CAAC;CACvB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,qBAAqB,CACnC,gBAAgB,EAAE,MAAM,GAAG,SAAS,EACpC,QAAQ,EAAE,SAAS,UAAU,EAAE,GAC9B,cAAc,GAAG,IAAI,CA6BvB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,6BAA6B,CAC3C,SAAS,EAAE,SAAS,UAAU,EAAE,EAChC,QAAQ,EAAE,SAAS,UAAU,EAAE,GAC9B,cAAc,GAAG,IAAI,CAUvB"}
|