pi-daddy 0.17.1 → 0.18.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 +54 -0
- package/README.md +54 -25
- package/dist/approval-prompt.d.ts +3 -1
- package/dist/approval-prompt.d.ts.map +1 -1
- package/dist/approval-prompt.js +1 -1
- package/dist/approval-prompt.js.map +1 -1
- package/dist/approval-store.d.ts.map +1 -1
- package/dist/approval-store.js +4 -1
- package/dist/approval-store.js.map +1 -1
- package/dist/approval.d.ts +20 -2
- package/dist/approval.d.ts.map +1 -1
- package/dist/approval.js +26 -6
- package/dist/approval.js.map +1 -1
- package/dist/chain.d.ts +6 -1
- package/dist/chain.d.ts.map +1 -1
- package/dist/chain.js +1 -1
- package/dist/chain.js.map +1 -1
- package/dist/check-runner.d.ts +61 -0
- package/dist/check-runner.d.ts.map +1 -0
- package/dist/check-runner.js +237 -0
- package/dist/check-runner.js.map +1 -0
- package/dist/correlation.d.ts +90 -0
- package/dist/correlation.d.ts.map +1 -0
- package/dist/correlation.js +183 -0
- package/dist/correlation.js.map +1 -0
- package/dist/delegate-types.d.ts +140 -0
- package/dist/delegate-types.d.ts.map +1 -0
- package/dist/delegate-types.js +8 -0
- package/dist/delegate-types.js.map +1 -0
- package/dist/delegate.d.ts +4 -128
- package/dist/delegate.d.ts.map +1 -1
- package/dist/delegate.js +68 -72
- package/dist/delegate.js.map +1 -1
- package/dist/delegation-approval.d.ts +36 -0
- package/dist/delegation-approval.d.ts.map +1 -0
- package/dist/delegation-approval.js +67 -0
- package/dist/delegation-approval.js.map +1 -0
- package/dist/git-identity.d.ts +13 -0
- package/dist/git-identity.d.ts.map +1 -0
- package/dist/git-identity.js +44 -0
- package/dist/git-identity.js.map +1 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/lease-record.d.ts +78 -0
- package/dist/lease-record.d.ts.map +1 -0
- package/dist/lease-record.js +52 -0
- package/dist/lease-record.js.map +1 -0
- package/dist/ledger-events.d.ts +87 -0
- package/dist/ledger-events.d.ts.map +1 -0
- package/dist/ledger-events.js +45 -0
- package/dist/ledger-events.js.map +1 -0
- package/dist/ledger-report.d.ts +19 -12
- package/dist/ledger-report.d.ts.map +1 -1
- package/dist/ledger-report.js +81 -1
- package/dist/ledger-report.js.map +1 -1
- package/dist/ledger.d.ts +44 -1
- package/dist/ledger.d.ts.map +1 -1
- package/dist/ledger.js +20 -2
- package/dist/ledger.js.map +1 -1
- package/dist/refusals.d.ts +16 -0
- package/dist/refusals.d.ts.map +1 -0
- package/dist/refusals.js +51 -0
- package/dist/refusals.js.map +1 -0
- package/dist/run-child.d.ts +4 -0
- package/dist/run-child.d.ts.map +1 -1
- package/dist/run-child.js +21 -1
- package/dist/run-child.js.map +1 -1
- package/dist/run-herdr.d.ts +7 -0
- package/dist/run-herdr.d.ts.map +1 -1
- package/dist/run-herdr.js +41 -12
- package/dist/run-herdr.js.map +1 -1
- package/dist/workspace-lease.d.ts +28 -0
- package/dist/workspace-lease.d.ts.map +1 -0
- package/dist/workspace-lease.js +276 -0
- package/dist/workspace-lease.js.map +1 -0
- package/dist/workspace.d.ts +32 -0
- package/dist/workspace.d.ts.map +1 -0
- package/dist/workspace.js +79 -0
- package/dist/workspace.js.map +1 -0
- package/extensions/approval-banking.ts +66 -0
- package/extensions/approvals.ts +95 -7
- package/extensions/chain-approval-facts.ts +51 -0
- package/extensions/chain-ledger.ts +48 -0
- package/extensions/delegate-chain.ts +115 -81
- package/extensions/delegation.ts +81 -23
- package/extensions/execute-child.ts +289 -0
- package/extensions/fanout-outcome.ts +97 -0
- package/extensions/run-delegation.ts +130 -120
- package/extensions/session.ts +4 -0
- package/extensions/workspace-runtime.ts +165 -0
- package/package.json +17 -1
- package/src/approval-prompt.ts +4 -2
- package/src/approval-store.ts +4 -1
- package/src/approval.ts +47 -14
- package/src/chain.ts +3 -1
- package/src/check-runner.ts +341 -0
- package/src/correlation.ts +260 -0
- package/src/delegate-types.ts +144 -0
- package/src/delegate.ts +80 -179
- package/src/delegation-approval.ts +99 -0
- package/src/git-identity.ts +52 -0
- package/src/index.ts +50 -0
- package/src/lease-record.ts +119 -0
- package/src/ledger-events.ts +138 -0
- package/src/ledger-report.ts +90 -2
- package/src/ledger.ts +68 -3
- package/src/refusals.ts +66 -0
- package/src/run-child.ts +23 -1
- package/src/run-herdr.ts +41 -11
- package/src/workspace-lease.ts +303 -0
- package/src/workspace.ts +135 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type InheritableApproval } from "./approval.ts";
|
|
2
|
+
import { type ApprovalBinding, type CorrelationMetadata } from "./correlation.ts";
|
|
3
|
+
import type { DefinitionDigest, SkillDefinition } from "./definitions.ts";
|
|
4
|
+
import { type Capability, type ResolveResult } from "./resolve.ts";
|
|
5
|
+
/**
|
|
6
|
+
* Resolve the approval half of one delegation after its requested capability set is known.
|
|
7
|
+
*
|
|
8
|
+
* Kept as one function because the ordering is security-relevant: compute the unapproved and potential
|
|
9
|
+
* effective sets first, derive the exact binding from those trusted values, then decide which approvals
|
|
10
|
+
* match. An approval must never define the scope against which it is checked.
|
|
11
|
+
*/
|
|
12
|
+
export declare function resolveDelegationApproval(input: {
|
|
13
|
+
task: string;
|
|
14
|
+
agent?: string;
|
|
15
|
+
requested: Capability[];
|
|
16
|
+
parentGrant: Capability[];
|
|
17
|
+
gated: Capability[];
|
|
18
|
+
approved?: InheritableApproval[];
|
|
19
|
+
spawned?: SkillDefinition;
|
|
20
|
+
definitionDigest?: DefinitionDigest;
|
|
21
|
+
/**
|
|
22
|
+
* Present iff this call is task-bound. Its VALUES never enter the binding — only its presence selects
|
|
23
|
+
* the exact-bound regime over the legacy subject-scoped one.
|
|
24
|
+
*/
|
|
25
|
+
correlation?: CorrelationMetadata;
|
|
26
|
+
/** Trusted: an id that was resolved against the operator registry and leased. Never a caller claim. */
|
|
27
|
+
boundWorkspaceId?: string;
|
|
28
|
+
/** Caller-declared label. Narrows the binding only; asserts nothing about enforcement. */
|
|
29
|
+
boundContextId?: string;
|
|
30
|
+
parentId: string;
|
|
31
|
+
}): {
|
|
32
|
+
result: ResolveResult;
|
|
33
|
+
approvalBinding?: ApprovalBinding;
|
|
34
|
+
bindingMismatch: boolean;
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=delegation-approval.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delegation-approval.d.ts","sourceRoot":"","sources":["../src/delegation-approval.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAE3E,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACzB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAA2B,KAAK,UAAU,EAAE,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAE5F;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,UAAU,EAAE,CAAC;IACxB,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,QAAQ,CAAC,EAAE,mBAAmB,EAAE,CAAC;IACjC,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC;;;OAGG;IACH,WAAW,CAAC,EAAE,mBAAmB,CAAC;IAClC,uGAAuG;IACvG,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,0FAA0F;IAC1F,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG;IAAE,MAAM,EAAE,aAAa,CAAC;IAAC,eAAe,CAAC,EAAE,eAAe,CAAC;IAAC,eAAe,EAAE,OAAO,CAAA;CAAE,CA6DzF"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { DELEGATE_SUBJECT } from "./approval.js";
|
|
2
|
+
import { agentCapability } from "./capabilities.js";
|
|
3
|
+
import { approvalBindingsEqual, buildApprovalBinding, } from "./correlation.js";
|
|
4
|
+
import { AGENT_WILDCARD, resolve } from "./resolve.js";
|
|
5
|
+
/**
|
|
6
|
+
* Resolve the approval half of one delegation after its requested capability set is known.
|
|
7
|
+
*
|
|
8
|
+
* Kept as one function because the ordering is security-relevant: compute the unapproved and potential
|
|
9
|
+
* effective sets first, derive the exact binding from those trusted values, then decide which approvals
|
|
10
|
+
* match. An approval must never define the scope against which it is checked.
|
|
11
|
+
*/
|
|
12
|
+
export function resolveDelegationApproval(input) {
|
|
13
|
+
const subject = input.agent ?? DELEGATE_SUBJECT;
|
|
14
|
+
const unapproved = resolve({
|
|
15
|
+
requested: input.requested,
|
|
16
|
+
parentGrant: input.parentGrant,
|
|
17
|
+
gated: input.gated,
|
|
18
|
+
approved: [],
|
|
19
|
+
});
|
|
20
|
+
// ADR-0024: a definition's authorising id is gated as the PARENT's authority to run it now. It never
|
|
21
|
+
// joins requested/effective, because that would hand the child authority to recursively spawn itself.
|
|
22
|
+
let authorisingCapability;
|
|
23
|
+
if (input.spawned) {
|
|
24
|
+
const authorising = agentCapability(input.spawned.name);
|
|
25
|
+
if (input.gated.includes(authorising) || input.gated.includes(AGENT_WILDCARD)) {
|
|
26
|
+
authorisingCapability = authorising;
|
|
27
|
+
unapproved.gatedBlocked = [...unapproved.gatedBlocked, authorising];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const potential = resolve({
|
|
31
|
+
requested: input.requested,
|
|
32
|
+
parentGrant: input.parentGrant,
|
|
33
|
+
gated: input.gated,
|
|
34
|
+
// If the definition also declares its own authorising `agent:<name>`, the same approval unblocks
|
|
35
|
+
// that requested child capability too; excluding it here would bind a smaller set than we provision.
|
|
36
|
+
approved: unapproved.gatedBlocked,
|
|
37
|
+
});
|
|
38
|
+
const approvalBinding = input.correlation
|
|
39
|
+
? buildApprovalBinding({
|
|
40
|
+
task: input.task,
|
|
41
|
+
requested: input.requested,
|
|
42
|
+
effective: potential.effective,
|
|
43
|
+
definitionSha256: input.definitionDigest?.sha256,
|
|
44
|
+
parentId: input.parentId,
|
|
45
|
+
workspaceId: input.boundWorkspaceId,
|
|
46
|
+
contextId: input.boundContextId,
|
|
47
|
+
})
|
|
48
|
+
: undefined;
|
|
49
|
+
const forSubject = (input.approved ?? []).filter((approval) => approval.subject === subject);
|
|
50
|
+
const approvedCapabilities = forSubject
|
|
51
|
+
.filter((approval) => approvalBinding
|
|
52
|
+
? approvalBindingsEqual(approval.binding, approvalBinding)
|
|
53
|
+
: approval.binding === undefined)
|
|
54
|
+
.map((approval) => approval.capability);
|
|
55
|
+
const bindingMismatch = approvalBinding !== undefined && forSubject.some((approval) => approval.binding !== undefined && !approvalBindingsEqual(approval.binding, approvalBinding));
|
|
56
|
+
const result = resolve({
|
|
57
|
+
requested: input.requested,
|
|
58
|
+
parentGrant: input.parentGrant,
|
|
59
|
+
gated: input.gated,
|
|
60
|
+
approved: approvedCapabilities,
|
|
61
|
+
});
|
|
62
|
+
if (authorisingCapability && !approvedCapabilities.includes(authorisingCapability)) {
|
|
63
|
+
result.gatedBlocked = [...result.gatedBlocked, authorisingCapability];
|
|
64
|
+
}
|
|
65
|
+
return { result, ...(approvalBinding ? { approvalBinding } : {}), bindingMismatch };
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=delegation-approval.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delegation-approval.js","sourceRoot":"","sources":["../src/delegation-approval.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAA4B,MAAM,eAAe,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,mBAA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F,MAAM,CAAC,YAAY,GAAG,CAAC,GAAG,MAAM,CAAC,YAAY,EAAE,qBAAqB,CAAC,CAAC;IACxE,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,eAAe,EAAE,CAAC;AACtF,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ValidatedWorkspace } from "./workspace.ts";
|
|
2
|
+
export interface GitCandidateIdentity {
|
|
3
|
+
headSha: string;
|
|
4
|
+
treeSha: string;
|
|
5
|
+
}
|
|
6
|
+
/** Compute HEAD plus NON-IGNORED tracked/untracked candidate content without changing the real index.
|
|
7
|
+
*
|
|
8
|
+
* NOT the exact working tree: `git add -A` honours `.gitignore`, `core.excludesFile` and
|
|
9
|
+
* `$GIT_DIR/info/exclude`, and records only a gitlink for a submodule. And it is not read-only — it writes
|
|
10
|
+
* blob objects into the real `.git/objects`. `docs/SPEC.md` retracted the word "exact"; this comment said
|
|
11
|
+
* it for one more round. */
|
|
12
|
+
export declare function computeGitCandidateIdentity(workspace: ValidatedWorkspace): Promise<GitCandidateIdentity>;
|
|
13
|
+
//# sourceMappingURL=git-identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-identity.d.ts","sourceRoot":"","sources":["../src/git-identity.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAIzD,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;4BAK4B;AAC5B,wBAAsB,2BAA2B,CAAC,SAAS,EAAE,kBAAkB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA8B9G"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { mkdtemp, rm } from "node:fs/promises";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { promisify } from "node:util";
|
|
6
|
+
import { GovernanceRefusal, refusal } from "./refusals.js";
|
|
7
|
+
const execFileAsync = promisify(execFile);
|
|
8
|
+
/** Compute HEAD plus NON-IGNORED tracked/untracked candidate content without changing the real index.
|
|
9
|
+
*
|
|
10
|
+
* NOT the exact working tree: `git add -A` honours `.gitignore`, `core.excludesFile` and
|
|
11
|
+
* `$GIT_DIR/info/exclude`, and records only a gitlink for a submodule. And it is not read-only — it writes
|
|
12
|
+
* blob objects into the real `.git/objects`. `docs/SPEC.md` retracted the word "exact"; this comment said
|
|
13
|
+
* it for one more round. */
|
|
14
|
+
export async function computeGitCandidateIdentity(workspace) {
|
|
15
|
+
const dir = await mkdtemp(join(tmpdir(), "pi-daddy-index-"));
|
|
16
|
+
const index = join(dir, "index");
|
|
17
|
+
const env = {
|
|
18
|
+
PATH: process.env.PATH,
|
|
19
|
+
HOME: process.env.HOME,
|
|
20
|
+
LANG: process.env.LANG,
|
|
21
|
+
LC_ALL: process.env.LC_ALL,
|
|
22
|
+
TMPDIR: process.env.TMPDIR,
|
|
23
|
+
GIT_INDEX_FILE: index,
|
|
24
|
+
};
|
|
25
|
+
const git = async (args) => (await execFileAsync("git", ["-C", workspace.root, ...args], {
|
|
26
|
+
env, encoding: "utf8", maxBuffer: 16 * 1024 * 1024,
|
|
27
|
+
})).stdout.trim();
|
|
28
|
+
try {
|
|
29
|
+
const headSha = await git(["rev-parse", "HEAD"]);
|
|
30
|
+
await git(["read-tree", "HEAD"]);
|
|
31
|
+
await git(["add", "-A"]);
|
|
32
|
+
const treeSha = await git(["write-tree"]);
|
|
33
|
+
if (!/^[a-f0-9]{40,64}$/i.test(headSha) || !/^[a-f0-9]{40,64}$/i.test(treeSha))
|
|
34
|
+
throw new Error("Git returned an invalid object id");
|
|
35
|
+
return { headSha, treeSha };
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
throw new GovernanceRefusal(refusal("CHECK_IDENTITY_UNAVAILABLE", `could not compute exact Git head/candidate-tree identity for workspace ${workspace.workspaceId} (${String(error)})`, { workspace_id: workspace.workspaceId }));
|
|
39
|
+
}
|
|
40
|
+
finally {
|
|
41
|
+
await rm(dir, { recursive: true, force: true });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=git-identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-identity.js","sourceRoot":"","sources":["../src/git-identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAG3D,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAO1C;;;;;4BAK4B;AAC5B,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAAC,SAA6B;IAC7E,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAC7D,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACjC,MAAM,GAAG,GAAsB;QAC7B,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,IAAI;QACtB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,IAAI;QACtB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,IAAI;QACtB,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,MAAM;QA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I,EAAE,CAAC,CAAC;IAClD,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
export { resolve, assertNarrowing, toPiToolsAllowlist, UNIVERSAL_CAPABILITIES, type Capability, type ResolveInput, type ResolveResult, } from "./resolve.ts";
|
|
2
|
-
export { appendRecord, buildRecord, isEscalationAttempt, type GrantRecord, type LedgerOptions, } from "./ledger.ts";
|
|
2
|
+
export { appendLedgerEvent, appendRecord, buildChildLifecycleEvent, buildRecord, buildWorkspaceLeaseEvent, isEscalationAttempt, LEDGER_VERSION, type CheckReceiptLedgerEvent, type ChildLifecycleEvent, type GrantRecord, type LedgerOptions, type RuntimeLedgerEvent, type WorkspaceLeaseEvent, type WorkspaceLeaseOutcome, } from "./ledger.ts";
|
|
3
3
|
export { planSpawn, type SpawnPlan, type SpawnPlanInput } from "./spawn.ts";
|
|
4
4
|
export { APPROVAL_TTL_DAYS, DELEGATE_SUBJECT, approvalKey, entryVerdict, expiryFor, inheritApprovals, offeredScopes, resolveApprovals, shouldSeekApproval, type ApprovalEntry, type ApprovalPath, type ApprovalScope, type ApprovalSource, type EntryVerdict, type SubjectSnapshot, } from "./approval.ts";
|
|
5
5
|
export { approvalsPath, loadApprovals, revokeAll, revokeApproval, saveApproval, type DroppedApproval, type SubjectLookup, } from "./approval-store.ts";
|
|
6
|
+
export { approvalBindingDigest, approvalBindingsEqual, buildApprovalBinding, digestCapabilities, digestTask, isApprovalBinding, normaliseCorrelation, type ApprovalBinding, type CorrelationMetadata, type JsonValue, } from "./correlation.ts";
|
|
7
|
+
export { GovernanceRefusal, REFUSAL_CODES, refusal, type RefusalCode, type StructuredRefusal, } from "./refusals.ts";
|
|
8
|
+
export { acquireWorkspaceLease, defaultWorkspaceLeaseDir, loadWorkspaceRegistry, resolveWorkspace, validateRegisteredWorkspace, type ValidatedWorkspace, type WorkspaceAccess, type WorkspaceLease, type WorkspaceRegistryFile, } from "./workspace.ts";
|
|
9
|
+
export { buildCheckEnvironment, runNamedCheck, type CheckDefinition, type CheckReceipt, type CheckRegistry, } from "./check-runner.ts";
|
|
6
10
|
export { createApprovalGate, createApprovalGateProvider, timeoutMsFromEnv, type ApprovalGate, type InFlightApprovals, type ApprovalUI, type PromptOutcome, type PromptOutcomeKind, type PromptRequest, } from "./approval-prompt.ts";
|
|
7
11
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,eAAe,EACf,kBAAkB,EAClB,sBAAsB,EACtB,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,aAAa,GACnB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,YAAY,EACZ,WAAW,EACX,mBAAmB,EACnB,KAAK,WAAW,EAChB,KAAK,aAAa,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,eAAe,EACf,kBAAkB,EAClB,sBAAsB,EACtB,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,aAAa,GACnB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,wBAAwB,EACxB,WAAW,EACX,wBAAwB,EACxB,mBAAmB,EACnB,cAAc,EACd,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,GAC3B,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,SAAS,EAAE,KAAK,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5E,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,SAAS,EACT,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,eAAe,GACrB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,aAAa,EACb,aAAa,EACb,SAAS,EACT,cAAc,EACd,YAAY,EACZ,KAAK,eAAe,EACpB,KAAK,aAAa,GACnB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,UAAU,EACV,iBAAiB,EACjB,oBAAoB,EACpB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,SAAS,GACf,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,OAAO,EACP,KAAK,WAAW,EAChB,KAAK,iBAAiB,GACvB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,qBAAqB,EACrB,wBAAwB,EACxB,qBAAqB,EACrB,gBAAgB,EAChB,2BAA2B,EAC3B,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,qBAAqB,GAC3B,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,qBAAqB,EACrB,aAAa,EACb,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,aAAa,GACnB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,kBAAkB,EAClB,0BAA0B,EAC1B,gBAAgB,EAChB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,aAAa,GACnB,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
export { resolve, assertNarrowing, toPiToolsAllowlist, UNIVERSAL_CAPABILITIES, } from "./resolve.js";
|
|
2
|
-
export { appendRecord, buildRecord, isEscalationAttempt, } from "./ledger.js";
|
|
2
|
+
export { appendLedgerEvent, appendRecord, buildChildLifecycleEvent, buildRecord, buildWorkspaceLeaseEvent, isEscalationAttempt, LEDGER_VERSION, } from "./ledger.js";
|
|
3
3
|
export { planSpawn } from "./spawn.js";
|
|
4
4
|
export { APPROVAL_TTL_DAYS, DELEGATE_SUBJECT, approvalKey, entryVerdict, expiryFor, inheritApprovals, offeredScopes, resolveApprovals, shouldSeekApproval, } from "./approval.js";
|
|
5
5
|
export { approvalsPath, loadApprovals, revokeAll, revokeApproval, saveApproval, } from "./approval-store.js";
|
|
6
|
+
export { approvalBindingDigest, approvalBindingsEqual, buildApprovalBinding, digestCapabilities, digestTask, isApprovalBinding, normaliseCorrelation, } from "./correlation.js";
|
|
7
|
+
export { GovernanceRefusal, REFUSAL_CODES, refusal, } from "./refusals.js";
|
|
8
|
+
export { acquireWorkspaceLease, defaultWorkspaceLeaseDir, loadWorkspaceRegistry, resolveWorkspace, validateRegisteredWorkspace, } from "./workspace.js";
|
|
9
|
+
export { buildCheckEnvironment, runNamedCheck, } from "./check-runner.js";
|
|
6
10
|
export { createApprovalGate, createApprovalGateProvider, timeoutMsFromEnv, } from "./approval-prompt.js";
|
|
7
11
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,eAAe,EACf,kBAAkB,EAClB,sBAAsB,GAIvB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,YAAY,EACZ,WAAW,EACX,mBAAmB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,eAAe,EACf,kBAAkB,EAClB,sBAAsB,GAIvB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,wBAAwB,EACxB,WAAW,EACX,wBAAwB,EACxB,mBAAmB,EACnB,cAAc,GAQf,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,SAAS,EAAuC,MAAM,YAAY,CAAC;AAE5E,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,SAAS,EACT,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EAChB,kBAAkB,GAOnB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,aAAa,EACb,aAAa,EACb,SAAS,EACT,cAAc,EACd,YAAY,GAGb,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,UAAU,EACV,iBAAiB,EACjB,oBAAoB,GAIrB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,OAAO,GAGR,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,qBAAqB,EACrB,wBAAwB,EACxB,qBAAqB,EACrB,gBAAgB,EAChB,2BAA2B,GAK5B,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,qBAAqB,EACrB,aAAa,GAId,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,kBAAkB,EAClB,0BAA0B,EAC1B,gBAAgB,GAOjB,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { ValidatedWorkspace, WorkspaceAccess } from "./workspace.ts";
|
|
2
|
+
export interface LeaseMetadata {
|
|
3
|
+
version: 1;
|
|
4
|
+
state: "active" | "released";
|
|
5
|
+
token: string;
|
|
6
|
+
owner_id: string;
|
|
7
|
+
workspace_id: string;
|
|
8
|
+
root: string;
|
|
9
|
+
pid: number;
|
|
10
|
+
acquired_at: string;
|
|
11
|
+
released_at?: string;
|
|
12
|
+
release_reason?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface WorkspaceLease {
|
|
15
|
+
workspace: ValidatedWorkspace;
|
|
16
|
+
access: WorkspaceAccess;
|
|
17
|
+
ownerId: string;
|
|
18
|
+
/**
|
|
19
|
+
* `true` only when the kernel lock was free but metadata said the prior owner never released.
|
|
20
|
+
* `"unknown"` when the prior owner's record could not be read at all — that is not evidence of a
|
|
21
|
+
* clean handover and must not be recorded as one (R-100).
|
|
22
|
+
*/
|
|
23
|
+
recovered: boolean | "unknown";
|
|
24
|
+
/** Attach the governed resource so parent death cleans it before the kernel lock is released. */
|
|
25
|
+
attachProcess(pid: number): void;
|
|
26
|
+
attachHerdrTab(tabId: string): void;
|
|
27
|
+
/** Resolves only when the kernel-lock helper exits before explicit release. */
|
|
28
|
+
lost: Promise<Error>;
|
|
29
|
+
/**
|
|
30
|
+
* NEVER throws. A cleanup function that can throw destroys its caller's return value — a completed
|
|
31
|
+
* child's entire output was discarded this way (R-99) — so the outcome is a VALUE the caller records:
|
|
32
|
+
* `"released"` the kernel lock was handed back and the handover recorded;
|
|
33
|
+
* `"released-unrecorded"` the lock was handed back but the record failed, so the NEXT owner will
|
|
34
|
+
* report a recovery that did not happen unless this is ledgered;
|
|
35
|
+
* `"lost"` the helper was already gone, so this owner never released anything.
|
|
36
|
+
*/
|
|
37
|
+
release(reason?: string): Promise<LeaseReleaseOutcome>;
|
|
38
|
+
/**
|
|
39
|
+
* Record that this lease is being kept deliberately, WITHOUT releasing the kernel lock.
|
|
40
|
+
*
|
|
41
|
+
* Needed because a retained lease never calls `release()`, so the metadata stays `state: "active"` and
|
|
42
|
+
* whoever acquires next reports `recovered: true` — blaming a crash on a known-good path.
|
|
43
|
+
*/
|
|
44
|
+
markRetained(reason?: string): Promise<void>;
|
|
45
|
+
/** Reads the give-up marker the helper leaves when it could not close a herdr writer tab. */
|
|
46
|
+
readCloseFailure(): Promise<{
|
|
47
|
+
reason: string;
|
|
48
|
+
herdr_tab?: string;
|
|
49
|
+
} | null>;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* What a release actually did. Five members rather than three, because the first version conflated facts
|
|
53
|
+
* that call for different responses — and one of them is an alarm:
|
|
54
|
+
* `released` the lock went back and THIS owner wrote its own handover;
|
|
55
|
+
* `released-unrecorded` the lock went back and the record does not say so, so the next owner will report
|
|
56
|
+
* a recovery that never happened unless the caller ledgers this. **The alarm.**
|
|
57
|
+
* `released-superseded` the lock went back and a successor already owns the metadata, so we correctly
|
|
58
|
+
* declined to overwrite it. Healthy, and previously indistinguishable from the
|
|
59
|
+
* alarm above;
|
|
60
|
+
* `not-held` a read lease, which never took a kernel lock — recording it as `released`
|
|
61
|
+
* overstated how many handovers the kernel performed, which is R-105 on the
|
|
62
|
+
* release side of the same defect;
|
|
63
|
+
* `lost` the helper was already gone; this owner released nothing.
|
|
64
|
+
*/
|
|
65
|
+
export type LeaseReleaseOutcome = "released" | "released-unrecorded" | "released-superseded" | "not-held" | "lost";
|
|
66
|
+
export declare function leasePaths(leaseDir: string, root: string): {
|
|
67
|
+
lock: string;
|
|
68
|
+
metadata: string;
|
|
69
|
+
marker: string;
|
|
70
|
+
};
|
|
71
|
+
export declare function atomicMetadata(path: string, value: LeaseMetadata): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* `null` means no prior owner was recorded. `"malformed"` means a record exists and cannot be read,
|
|
74
|
+
* which is strictly LESS evidence than a readable "active" one and must never read as a clean handover
|
|
75
|
+
* (R-100). Absent and unreadable are different facts; conflating them silently erases a real recovery.
|
|
76
|
+
*/
|
|
77
|
+
export declare function readMetadata(path: string): Promise<LeaseMetadata | null | "malformed">;
|
|
78
|
+
//# sourceMappingURL=lease-record.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lease-record.d.ts","sourceRoot":"","sources":["../src/lease-record.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAE1E,MAAM,WAAW,aAAa;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;EAQxD;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAItF;AAED;;;;GAIG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,GAAG,WAAW,CAAC,CAgB5F"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The lease's RECORD: what a workspace lease writes down about who holds it and how they let it go.
|
|
3
|
+
*
|
|
4
|
+
* Split from `./workspace-lease.ts` to stay under the 400-line module ceiling, along the seam this
|
|
5
|
+
* review round kept finding defects on — absent vs unreadable metadata, a swallowed handover write, a
|
|
6
|
+
* successor's token — all of which are about what the record SAYS rather than about the kernel lock.
|
|
7
|
+
*/
|
|
8
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
9
|
+
import { readFile, rename, writeFile } from "node:fs/promises";
|
|
10
|
+
import { join } from "node:path";
|
|
11
|
+
export function leasePaths(leaseDir, root) {
|
|
12
|
+
// Canonical root, never caller-chosen workspace ID: aliases for one worktree must contend.
|
|
13
|
+
const key = createHash("sha256").update(root, "utf8").digest("hex");
|
|
14
|
+
return {
|
|
15
|
+
lock: join(leaseDir, `${key}.lock`),
|
|
16
|
+
metadata: join(leaseDir, `${key}.json`),
|
|
17
|
+
marker: join(leaseDir, `${key}.close-failed.json`),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export async function atomicMetadata(path, value) {
|
|
21
|
+
const temp = `${path}.${process.pid}.${randomUUID()}.tmp`;
|
|
22
|
+
await writeFile(temp, `${JSON.stringify(value, null, 2)}\n`, { encoding: "utf8", flag: "wx", mode: 0o600 });
|
|
23
|
+
await rename(temp, path);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* `null` means no prior owner was recorded. `"malformed"` means a record exists and cannot be read,
|
|
27
|
+
* which is strictly LESS evidence than a readable "active" one and must never read as a clean handover
|
|
28
|
+
* (R-100). Absent and unreadable are different facts; conflating them silently erases a real recovery.
|
|
29
|
+
*/
|
|
30
|
+
export async function readMetadata(path) {
|
|
31
|
+
let raw;
|
|
32
|
+
try {
|
|
33
|
+
raw = await readFile(path, "utf8");
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
return error?.code === "ENOENT" ? null : "malformed";
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
const value = JSON.parse(raw);
|
|
40
|
+
if (value?.version !== 1)
|
|
41
|
+
return "malformed";
|
|
42
|
+
if (value.state !== "active" && value.state !== "released")
|
|
43
|
+
return "malformed";
|
|
44
|
+
if (typeof value.token !== "string" || !value.token)
|
|
45
|
+
return "malformed";
|
|
46
|
+
return value;
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return "malformed";
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=lease-record.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lease-record.js","sourceRoot":"","sources":["../src/lease-record.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAwEjC,MAAM,UAAU,UAAU,CAAC,QAAgB,EAAE,IAAY;IACvD,2FAA2F;IAC3F,MAAM,GAAG,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACpE,OAAO;QACL,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE,GAAG,GAAG,OAAO,CAAC;QACnC,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,GAAG,GAAG,OAAO,CAAC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C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,WAAW,CAAC;IACrB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The v2 runtime-event half of the ledger: workspace leases, child lifecycle and check receipts, with
|
|
3
|
+
* their builders. Split out of `./ledger.ts` only to stay under the 400-line module ceiling this
|
|
4
|
+
* project enforces mechanically; `./ledger.ts` re-exports everything here, so "the ledger module"
|
|
5
|
+
* remains one import.
|
|
6
|
+
*/
|
|
7
|
+
import { LEDGER_VERSION, type LedgerEventBase, type GrantRecord } from "./ledger.ts";
|
|
8
|
+
import type { ExecutorKind } from "./executor.ts";
|
|
9
|
+
import type { CorrelationMetadata } from "./correlation.ts";
|
|
10
|
+
import type { StructuredRefusal } from "./refusals.ts";
|
|
11
|
+
/**
|
|
12
|
+
* `released` is a handover this owner performed. FOUR members were added by the 0.18.0 review pass, and
|
|
13
|
+
* they were not all previously recorded the same way — `uncontended` was recorded as an *acquisition*, and
|
|
14
|
+
* `lost` was recorded as nothing at all, because the old `release()` threw before the append ran:
|
|
15
|
+
* `lost` the kernel lock went away under a live governed writer — NOT the same fact as a user
|
|
16
|
+
* cancelling, which is what it used to be indistinguishable from (R-103);
|
|
17
|
+
* `retained` the lease was deliberately kept because a herdr writer tab would not close, so the
|
|
18
|
+
* successor's `recovered: true` would otherwise blame a healthy path (R-104);
|
|
19
|
+
* `uncontended` a read lease took no kernel lock at all, so counting it as an acquisition
|
|
20
|
+
* overstated how many exclusions the kernel actually performed (R-105).
|
|
21
|
+
*/
|
|
22
|
+
export type WorkspaceLeaseOutcome = "acquired" | "uncontended" | "refused" | "released" | "released-unrecorded" | "lost" | "retained" | "timeout" | "recovered";
|
|
23
|
+
export interface WorkspaceLeaseEvent extends LedgerEventBase {
|
|
24
|
+
ledgerVersion: typeof LEDGER_VERSION;
|
|
25
|
+
event: "workspace_lease";
|
|
26
|
+
childId: string;
|
|
27
|
+
workspaceId: string;
|
|
28
|
+
root: string;
|
|
29
|
+
access: "read" | "write";
|
|
30
|
+
outcome: WorkspaceLeaseOutcome;
|
|
31
|
+
/** `"unknown"` when the prior owner's record was unreadable — not evidence of a clean handover. */
|
|
32
|
+
recovered?: boolean | "unknown";
|
|
33
|
+
releaseReason?: string;
|
|
34
|
+
refusal?: StructuredRefusal;
|
|
35
|
+
}
|
|
36
|
+
export interface ChildLifecycleEvent extends LedgerEventBase {
|
|
37
|
+
ledgerVersion: typeof LEDGER_VERSION;
|
|
38
|
+
event: "child_lifecycle";
|
|
39
|
+
childId: string;
|
|
40
|
+
state: "starting" | "completed" | "failed";
|
|
41
|
+
executor: ExecutorKind;
|
|
42
|
+
exitCode?: number | null;
|
|
43
|
+
signal?: NodeJS.Signals | null;
|
|
44
|
+
timedOut?: boolean;
|
|
45
|
+
aborted?: boolean;
|
|
46
|
+
truncated?: boolean;
|
|
47
|
+
reason?: string;
|
|
48
|
+
}
|
|
49
|
+
export interface CheckReceiptLedgerEvent extends LedgerEventBase {
|
|
50
|
+
ledgerVersion: typeof LEDGER_VERSION;
|
|
51
|
+
event: "check_receipt";
|
|
52
|
+
childId: string;
|
|
53
|
+
receiptId: string;
|
|
54
|
+
workspaceId: string;
|
|
55
|
+
checkId: string;
|
|
56
|
+
treeSha: string;
|
|
57
|
+
}
|
|
58
|
+
export type RuntimeLedgerEvent = (GrantRecord & {
|
|
59
|
+
ledgerVersion: typeof LEDGER_VERSION;
|
|
60
|
+
event: "capability_decision";
|
|
61
|
+
}) | WorkspaceLeaseEvent | ChildLifecycleEvent | CheckReceiptLedgerEvent;
|
|
62
|
+
export declare function buildWorkspaceLeaseEvent(args: {
|
|
63
|
+
childId: string;
|
|
64
|
+
workspaceId: string;
|
|
65
|
+
root: string;
|
|
66
|
+
access: "read" | "write";
|
|
67
|
+
outcome: WorkspaceLeaseOutcome;
|
|
68
|
+
recovered?: boolean | "unknown";
|
|
69
|
+
releaseReason?: string;
|
|
70
|
+
refusal?: StructuredRefusal;
|
|
71
|
+
correlation?: CorrelationMetadata;
|
|
72
|
+
now: Date;
|
|
73
|
+
}): WorkspaceLeaseEvent;
|
|
74
|
+
export declare function buildChildLifecycleEvent(args: {
|
|
75
|
+
childId: string;
|
|
76
|
+
state: "starting" | "completed" | "failed";
|
|
77
|
+
executor: ExecutorKind;
|
|
78
|
+
exitCode?: number | null;
|
|
79
|
+
signal?: NodeJS.Signals | null;
|
|
80
|
+
timedOut?: boolean;
|
|
81
|
+
aborted?: boolean;
|
|
82
|
+
truncated?: boolean;
|
|
83
|
+
reason?: string;
|
|
84
|
+
correlation?: CorrelationMetadata;
|
|
85
|
+
now: Date;
|
|
86
|
+
}): ChildLifecycleEvent;
|
|
87
|
+
//# sourceMappingURL=ledger-events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ledger-events.d.ts","sourceRoot":"","sources":["../src/ledger-events.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,cAAc,EAAE,KAAK,eAAe,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AACrF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD;;;;;;;;;;GAUG;AACH,MAAM,MAAM,qBAAqB,GAC7B,UAAU,GACV,aAAa,GACb,SAAS,GACT,UAAU,GACV,qBAAqB,GACrB,MAAM,GACN,UAAU,GACV,SAAS,GACT,WAAW,CAAC;AAEhB,MAAM,WAAW,mBAAoB,SAAQ,eAAe;IAC1D,aAAa,EAAE,OAAO,cAAc,CAAC;IACrC,KAAK,EAAE,iBAAiB,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,GAAG,OA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I,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;IACzB,OAAO,EAAE,qBAAqB,CAAC;IAC/B,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAChC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B,WAAW,CAAC,EAAE,mBAAmB,CAAC;IAClC,GAAG,EAAE,IAAI,CAAC;CACX,GAAG,mBAAmB,CAmBtB;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,UAAU,GAAG,WAAW,GAAG,QAAQ,CAAC;IAC3C,QAAQ,EAAE,YAAY,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;IAC/B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,mBAAmB,CAAC;IAClC,GAAG,EAAE,IAAI,CAAC;CACX,GAAG,mBAAmB,CAgBtB"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The v2 runtime-event half of the ledger: workspace leases, child lifecycle and check receipts, with
|
|
3
|
+
* their builders. Split out of `./ledger.ts` only to stay under the 400-line module ceiling this
|
|
4
|
+
* project enforces mechanically; `./ledger.ts` re-exports everything here, so "the ledger module"
|
|
5
|
+
* remains one import.
|
|
6
|
+
*/
|
|
7
|
+
import { LEDGER_VERSION } from "./ledger.js";
|
|
8
|
+
export function buildWorkspaceLeaseEvent(args) {
|
|
9
|
+
return {
|
|
10
|
+
ledgerVersion: LEDGER_VERSION,
|
|
11
|
+
event: "workspace_lease",
|
|
12
|
+
ts: args.now.toISOString(),
|
|
13
|
+
childId: args.childId,
|
|
14
|
+
workspaceId: args.workspaceId,
|
|
15
|
+
root: args.root,
|
|
16
|
+
access: args.access,
|
|
17
|
+
outcome: args.outcome,
|
|
18
|
+
// `!== undefined`, not truthiness. `recovered: false` — a POSITIVE assertion that the predecessor
|
|
19
|
+
// handed over cleanly — was dropped while the truthy `"unknown"` survived, so absence meant both
|
|
20
|
+
// "clean" and "never supplied". R-100's whole argument is that absence of evidence is not evidence,
|
|
21
|
+
// and this was the one line discarding the evidence.
|
|
22
|
+
...(args.recovered !== undefined ? { recovered: args.recovered } : {}),
|
|
23
|
+
...(args.releaseReason ? { releaseReason: args.releaseReason } : {}),
|
|
24
|
+
...(args.refusal ? { refusal: structuredClone(args.refusal) } : {}),
|
|
25
|
+
...(args.correlation ? { correlation: structuredClone(args.correlation) } : {}),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export function buildChildLifecycleEvent(args) {
|
|
29
|
+
return {
|
|
30
|
+
ledgerVersion: LEDGER_VERSION,
|
|
31
|
+
event: "child_lifecycle",
|
|
32
|
+
ts: args.now.toISOString(),
|
|
33
|
+
childId: args.childId,
|
|
34
|
+
state: args.state,
|
|
35
|
+
executor: args.executor,
|
|
36
|
+
...(args.exitCode !== undefined ? { exitCode: args.exitCode } : {}),
|
|
37
|
+
...(args.signal !== undefined ? { signal: args.signal } : {}),
|
|
38
|
+
...(args.timedOut ? { timedOut: true } : {}),
|
|
39
|
+
...(args.aborted ? { aborted: true } : {}),
|
|
40
|
+
...(args.truncated ? { truncated: true } : {}),
|
|
41
|
+
...(args.reason ? { reason: args.reason } : {}),
|
|
42
|
+
...(args.correlation ? { correlation: structuredClone(args.correlation) } : {}),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=ledger-events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ledger-events.js","sourceRoot":"","sources":["../src/ledger-events.ts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,CAAC,OAAO;QACrB,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,GAAG,CAAC,IAAI,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACnE,GAAG,CAAC,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7D,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5C,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1C,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9C,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/C,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,eAAe,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAChF,CAAC;AACJ,CAAC"}
|
package/dist/ledger-report.d.ts
CHANGED
|
@@ -14,8 +14,26 @@ import type { ApprovalSource } from "./approval.ts";
|
|
|
14
14
|
export interface LedgerReport {
|
|
15
15
|
/** False when the file is absent — a configuration state, not damage. */
|
|
16
16
|
exists: boolean;
|
|
17
|
-
/**
|
|
17
|
+
/** Capability-decision records (legacy or v2). */
|
|
18
18
|
records: number;
|
|
19
|
+
/** Every parsed ledger event, including lifecycle and lease events. */
|
|
20
|
+
events: number;
|
|
21
|
+
workspaceLeases: {
|
|
22
|
+
acquired: number;
|
|
23
|
+
uncontended: number;
|
|
24
|
+
refused: number;
|
|
25
|
+
released: number;
|
|
26
|
+
releasedUnrecorded: number;
|
|
27
|
+
lost: number;
|
|
28
|
+
retained: number;
|
|
29
|
+
timeout: number;
|
|
30
|
+
recovered: number;
|
|
31
|
+
};
|
|
32
|
+
lifecycle: {
|
|
33
|
+
starting: number;
|
|
34
|
+
completed: number;
|
|
35
|
+
failed: number;
|
|
36
|
+
};
|
|
19
37
|
/** Lines that did not, with 1-based line numbers so the report is actionable. */
|
|
20
38
|
corrupt: Array<{
|
|
21
39
|
line: number;
|
|
@@ -109,16 +127,5 @@ export interface LedgerReport {
|
|
|
109
127
|
};
|
|
110
128
|
ok: boolean;
|
|
111
129
|
}
|
|
112
|
-
/**
|
|
113
|
-
* Read the ledger back and report what is wrong with it.
|
|
114
|
-
*
|
|
115
|
-
* **This is the gap that mattered most.** `appendRecord`'s strict mode catches write *errors*, never
|
|
116
|
-
* corruption, and nothing in this package had ever read a ledger back — so a torn line was silently
|
|
117
|
-
* indistinguishable from a spawn that never happened. An audit trail whose damage is invisible is not a
|
|
118
|
-
* compensating control, and ADR-0008 leans on the ledger as exactly that.
|
|
119
|
-
*
|
|
120
|
-
* Deliberately reports rather than repairs. A corrupt line is evidence; rewriting the file to make it parse
|
|
121
|
-
* would destroy the one artifact an investigation has.
|
|
122
|
-
*/
|
|
123
130
|
export declare function verifyLedger(path: string): Promise<LedgerReport>;
|
|
124
131
|
//# sourceMappingURL=ledger-report.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ledger-report.d.ts","sourceRoot":"","sources":["../src/ledger-report.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;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