toolroll 0.9.71 → 0.9.73

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/CHANGELOG.md +155 -0
  2. package/dist/agent-fence.d.ts +10 -2
  3. package/dist/agent-fence.js +47 -9
  4. package/dist/approval-authority.d.ts +20 -0
  5. package/dist/approval-authority.js +67 -0
  6. package/dist/assignment.js +26 -4
  7. package/dist/browser/workspace.css +1 -1
  8. package/dist/browser/workspace.js +28 -28
  9. package/dist/builder.js +48 -6
  10. package/dist/chat-actions.js +13 -8
  11. package/dist/chat-decide.d.ts +47 -1
  12. package/dist/chat-decide.js +186 -5
  13. package/dist/check-access.js +2 -2
  14. package/dist/check-report.d.ts +109 -0
  15. package/dist/check-report.js +205 -0
  16. package/dist/claim.js +1 -1
  17. package/dist/coding-provider.js +4 -2
  18. package/dist/commit-extract.d.ts +111 -0
  19. package/dist/commit-extract.js +514 -0
  20. package/dist/contracts/console-api.d.ts +4 -4
  21. package/dist/contracts/console-api.js +5 -4
  22. package/dist/contracts/flow.d.ts +16 -0
  23. package/dist/contracts/flow.js +3 -0
  24. package/dist/contracts/release-check.d.ts +335 -0
  25. package/dist/contracts/release-check.js +159 -0
  26. package/dist/contracts/release-terms.d.ts +66 -0
  27. package/dist/contracts/release-terms.js +74 -0
  28. package/dist/contracts/verification-receipt.d.ts +42 -8
  29. package/dist/contracts/verification-receipt.js +24 -7
  30. package/dist/contracts/verification-view.d.ts +1 -0
  31. package/dist/deploy-gate.d.ts +17 -0
  32. package/dist/deploy-gate.js +68 -0
  33. package/dist/dispatch.js +3 -10
  34. package/dist/dispose.js +4 -1
  35. package/dist/evidence-pack.d.ts +1 -1
  36. package/dist/evidence-pack.js +20 -2
  37. package/dist/evidence.d.ts +1 -0
  38. package/dist/evidence.js +2 -1
  39. package/dist/exec.d.ts +1 -1
  40. package/dist/exec.js +7 -3
  41. package/dist/flow-engine.js +5 -1
  42. package/dist/flow-gallery-ui.js +4 -2
  43. package/dist/flow-gallery.d.ts +3 -0
  44. package/dist/flow-gallery.js +6 -2
  45. package/dist/flow-pull-request.d.ts +5 -2
  46. package/dist/flow-pull-request.js +14 -5
  47. package/dist/flow-schedule.js +25 -6
  48. package/dist/flow-triggers.d.ts +8 -0
  49. package/dist/flow-triggers.js +15 -0
  50. package/dist/flows-cli.js +13 -3
  51. package/dist/flows-ui.js +7 -1
  52. package/dist/guides.js +10 -1
  53. package/dist/invoke.d.ts +17 -6
  54. package/dist/invoke.js +48 -18
  55. package/dist/kits-ui.js +4 -2
  56. package/dist/kits.d.ts +6 -4
  57. package/dist/kits.js +9 -11
  58. package/dist/lead-status.js +5 -2
  59. package/dist/live-terminal.d.ts +10 -6
  60. package/dist/live-terminal.js +55 -14
  61. package/dist/mcp-connect.d.ts +10 -0
  62. package/dist/mcp-connect.js +2 -0
  63. package/dist/nightly-check.d.ts +104 -0
  64. package/dist/nightly-check.js +362 -0
  65. package/dist/operate.js +39 -2
  66. package/dist/person-proof.d.ts +2 -0
  67. package/dist/person-proof.js +14 -0
  68. package/dist/plan-auto.js +4 -4
  69. package/dist/planner-source.d.ts +1 -1
  70. package/dist/project-delete-ui.js +1 -1
  71. package/dist/project-tools.js +3 -1
  72. package/dist/proof.js +2 -0
  73. package/dist/protected-storage.d.ts +67 -0
  74. package/dist/protected-storage.js +398 -0
  75. package/dist/publish.js +156 -144
  76. package/dist/pull-request-flow.d.ts +2 -0
  77. package/dist/pull-request-flow.js +24 -2
  78. package/dist/release-adapters.d.ts +16 -1
  79. package/dist/release-adapters.js +292 -29
  80. package/dist/release-authority.d.ts +118 -0
  81. package/dist/release-authority.js +135 -0
  82. package/dist/release-card.d.ts +76 -0
  83. package/dist/release-card.js +252 -0
  84. package/dist/release-carry.d.ts +236 -0
  85. package/dist/release-carry.js +664 -0
  86. package/dist/release-cli.d.ts +3 -0
  87. package/dist/release-cli.js +158 -6
  88. package/dist/release-coverage.js +3 -0
  89. package/dist/release-git.d.ts +43 -0
  90. package/dist/release-git.js +106 -0
  91. package/dist/release-recheck.d.ts +146 -0
  92. package/dist/release-recheck.js +657 -0
  93. package/dist/release-view.d.ts +34 -0
  94. package/dist/release-view.js +27 -0
  95. package/dist/release.d.ts +139 -3
  96. package/dist/release.js +641 -250
  97. package/dist/remote-main.d.ts +2 -0
  98. package/dist/remote-main.js +1 -1
  99. package/dist/result-completion.d.ts +6 -0
  100. package/dist/result-completion.js +15 -1
  101. package/dist/result-follow-ups.js +29 -1
  102. package/dist/sandbox-runtime.d.ts +16 -5
  103. package/dist/sandbox-runtime.js +19 -6
  104. package/dist/scope.d.ts +122 -5
  105. package/dist/scope.js +236 -7
  106. package/dist/server/flows.js +40 -10
  107. package/dist/server/render-settings.js +1 -1
  108. package/dist/server/render-tasks.d.ts +8 -0
  109. package/dist/server/render-tasks.js +50 -9
  110. package/dist/server/route-table.js +1 -0
  111. package/dist/server/settings.js +26 -5
  112. package/dist/server/task-views.js +4 -0
  113. package/dist/server/tasks.js +12 -0
  114. package/dist/setup-guide.d.ts +2 -2
  115. package/dist/store.d.ts +230 -5
  116. package/dist/store.js +733 -37
  117. package/dist/subagent-memory.d.ts +1 -0
  118. package/dist/subagent-memory.js +1 -1
  119. package/dist/subagent-tools.d.ts +22 -6
  120. package/dist/subagent-tools.js +44 -8
  121. package/dist/subagent-work.d.ts +2 -0
  122. package/dist/subagent-work.js +5 -2
  123. package/dist/subagents-ui.js +6 -4
  124. package/dist/task-outcome-cli.js +7 -3
  125. package/dist/telegram.d.ts +6 -1
  126. package/dist/telegram.js +58 -6
  127. package/dist/toolroll-update.js +2 -2
  128. package/dist/verification-evidence.d.ts +25 -1
  129. package/dist/verification-evidence.js +57 -2
  130. package/dist/work-index.js +3 -6
  131. package/package.json +1 -1
@@ -0,0 +1,109 @@
1
+ import { type VerifiedEntry } from "./commit-extract.js";
2
+ import { CHECK_PARTS, type CheckContext, type CheckInventory, type CheckReport, type ObligationSnapshot, type TargetedPlan } from "./contracts/release-check.js";
3
+ import { type Store, type VerifyCommand } from "./store.js";
4
+ /** The sealed artifacts' capture labels: what a reader looks for, by exact name. */
5
+ export declare const CHECK_REPORT_CAPTURE = "release check report v1";
6
+ export declare const CHECK_INVENTORY_CAPTURE = "release check inventory v1";
7
+ export declare const TARGETED_PLAN_CAPTURE = "release check targeted plan v1";
8
+ export declare const OBLIGATION_SNAPSHOT_CAPTURE = "release check obligation snapshot v1";
9
+ export declare const CHECK_CONTEXT_CAPTURE = "release check context v1";
10
+ /** How large a sealed check artifact may be (the report's own bound). */
11
+ export declare const CHECK_ARTIFACT_CAP: number;
12
+ /** The release check's harness, named: the orchestrator, its runners and helpers, Vitest's configuration and setup, and
13
+ * the reporter. These never carry (release-carry.ts). The execution context digests far more (inHarnessDigest). */
14
+ export declare const HARNESS_FILES: readonly string[];
15
+ /** Vitest's include globs (vitest.config.ts), as the plane reads them: a change to that file is a harness change. */
16
+ export declare const UNIT_INCLUDE: readonly RegExp[];
17
+ export declare const isUnitFile: (path: string) => boolean;
18
+ /** The project's own Git directory as Toolroll records it: `<realpath(repo)>/.git`, a real directory. */
19
+ export declare function projectGitDir(repo: string): string | null;
20
+ /** A digest of a payload, over its canonical JSON. */
21
+ export declare const payloadDigest: (value: unknown) => string;
22
+ /**
23
+ * Whether a tree path is part of the harness for the execution context: every file EXCEPT the unit test files
24
+ * themselves, the two journey scripts, docs and Markdown. No import tracing: a harness dependency reached by any road
25
+ * (a `require`, a computed `import()`, a side-effect import, a `src/` helper, a config file) is inside this set, so a
26
+ * change to it always changes the digest (fail closed).
27
+ */
28
+ export declare function inHarnessDigest(path: string): boolean;
29
+ /** What the plane reads from a commit for a check: its tree's entries, its unit files and its harness. */
30
+ export type TreeFacts = {
31
+ tree: string;
32
+ entries: VerifiedEntry[];
33
+ units: string[];
34
+ harness: string[];
35
+ harnessDigest: string;
36
+ lockfile: string | null;
37
+ };
38
+ /** The tree facts of `sha`, from objects hashed here (never the checkout). Null with why when they can't be read. */
39
+ export declare function treeFactsOf(gitDir: string, sha: string): {
40
+ ok: true;
41
+ facts: TreeFacts;
42
+ } | {
43
+ ok: false;
44
+ problem: string;
45
+ };
46
+ /** The execution context a check runs in: what must match for results to stand beside each other. The machine's load
47
+ * budget is left out: it changes how fast a check runs, never what passes (scripts/release-check.mjs checkBudget). */
48
+ export declare function checkContextOf(facts: TreeFacts, command: VerifyCommand, access: string): CheckContext;
49
+ /** The parts a full check selects, as far as the plane knows them before it runs. */
50
+ export declare const FULL_PARTS: readonly (typeof CHECK_PARTS[number])[];
51
+ /** What a check must account for, sealed before it runs: every unit file of the tree, whatever runs (a targeted
52
+ * check accounts for the rest through its base), and the parts it selects. */
53
+ export declare function inventoryOf(facts: TreeFacts, plan: TargetedPlan | null): CheckInventory;
54
+ /** A check about to run: its handshake (written on stdin, then closed) and the facts sealed with it. */
55
+ export type PreparedAttempt = {
56
+ runId: number;
57
+ nonce: string;
58
+ stdin: string;
59
+ mode: "full" | "targeted";
60
+ inventory: CheckInventory;
61
+ context: CheckContext;
62
+ plan: TargetedPlan | null;
63
+ snapshot: ObligationSnapshot | null;
64
+ /** The identities the check was asked to report one by one (required ones). */
65
+ watch: string[];
66
+ };
67
+ /**
68
+ * Seal a check's attempt row before its command is spawned: intended mode, nonce hash, inventory and context (and for a
69
+ * targeted check its plan and obligation snapshot, sealed as artifacts first). Null when the plane can't read the
70
+ * commit, which leaves the check running exactly as it always has, with no handshake.
71
+ */
72
+ export declare function prepareCheckAttempt(store: Store, root: string, input: {
73
+ runId: number;
74
+ repo: string;
75
+ head: string;
76
+ command: VerifyCommand;
77
+ access: string;
78
+ authority?: number | null;
79
+ plan?: TargetedPlan | null;
80
+ snapshot?: ObligationSnapshot | null;
81
+ watch?: readonly string[];
82
+ }, now: Date): PreparedAttempt | null;
83
+ /** Seal one JSON payload as a structured-output artifact under its capture label. */
84
+ export declare function sealJson(store: Store, root: string, runId: number, name: string, value: unknown, capture: string, now: Date): number;
85
+ /**
86
+ * The check's report from its output: the LAST `TOOLROLL_CHECK_REPORT <json>` line carrying this nonce, at most 256 KiB,
87
+ * that matches the contract. Lines without the nonce (a test's print, a leftover process's write) are passed over.
88
+ */
89
+ export declare function reportFromOutput(stdout: string, nonce: string): {
90
+ ok: true;
91
+ report: CheckReport;
92
+ raw: string;
93
+ } | {
94
+ ok: false;
95
+ problem: string;
96
+ };
97
+ /**
98
+ * After the check: seal its report (when it gave a valid one) and the inventory artifact. `exitCode` is the check's own
99
+ * exit; a report that disagrees with it is no report. Returns the report, or null.
100
+ */
101
+ export declare function sealCheckOutcome(store: Store, root: string, attempt: PreparedAttempt, output: {
102
+ stdout: string;
103
+ exitCode: number | null;
104
+ }, now: Date): CheckReport | null;
105
+ /** One sealed check artifact of a run, read back and verified, or null (missing, ambiguous, cut short or changed). */
106
+ export declare function readSealedJson(store: Store, root: string, runId: number, capture: string): {
107
+ value: unknown;
108
+ digest: string;
109
+ } | null;
@@ -0,0 +1,205 @@
1
+ /**
2
+ * The release check's structured report, on the plane's side (docs/plans/release-once.md, part 2 and rollout phase A).
3
+ *
4
+ * Before a Full check of a prepared candidate runs, the builder seals a `release_check_attempt` row: the intended mode
5
+ * (`full`, or `targeted` with its plan and obligation snapshot), the hash of a fresh nonce, the inventory the check must
6
+ * account for (the unit files, from the verified tree and Vitest's include globs, and the parts selected) and the
7
+ * execution context. It then writes `{"nonce","mode","plan","watch"}` on the check's stdin and closes it.
8
+ *
9
+ * After the check, the report is the last `TOOLROLL_CHECK_REPORT <json>` line of its output that carries that nonce
10
+ * (a line a test prints, or one a leftover process writes, has no nonce and is ignored). It is read strictly and sealed
11
+ * as `check-report.json`, beside `check-inventory.json` (what was sealed, and the groups and versions the check
12
+ * declared). A run with no valid report still passes or fails as before; it just can't be the base of a targeted check.
13
+ *
14
+ * Coverage trusts test code (the trust decision in the plan). Nothing here decides who may release or deploy.
15
+ */
16
+ import { createHash, randomBytes } from "node:crypto";
17
+ import { lstatSync, realpathSync } from "node:fs";
18
+ import { join } from "node:path";
19
+ import { readVerifiedCommit, verifiedTreeEntries } from "./commit-extract.js";
20
+ import { CHECK_PARTS, CHECK_REPORT_MAX_BYTES, CHECK_REPORT_PREFIX, readCheckReport, } from "./contracts/release-check.js";
21
+ import { readVerifiedArtifact, storeEvidence } from "./evidence.js";
22
+ import { checkAttemptOf, recordCheckAttempt } from "./store.js";
23
+ /** The sealed artifacts' capture labels: what a reader looks for, by exact name. */
24
+ export const CHECK_REPORT_CAPTURE = "release check report v1";
25
+ export const CHECK_INVENTORY_CAPTURE = "release check inventory v1";
26
+ export const TARGETED_PLAN_CAPTURE = "release check targeted plan v1";
27
+ export const OBLIGATION_SNAPSHOT_CAPTURE = "release check obligation snapshot v1";
28
+ export const CHECK_CONTEXT_CAPTURE = "release check context v1";
29
+ /** How large a sealed check artifact may be (the report's own bound). */
30
+ export const CHECK_ARTIFACT_CAP = CHECK_REPORT_MAX_BYTES;
31
+ /** The release check's harness, named: the orchestrator, its runners and helpers, Vitest's configuration and setup, and
32
+ * the reporter. These never carry (release-carry.ts). The execution context digests far more (inHarnessDigest). */
33
+ export const HARNESS_FILES = Object.freeze([
34
+ "scripts/release-check.mjs", "scripts/release-check-ci.mjs", "scripts/suite-lifecycle.mjs", "scripts/provider-gate.mjs",
35
+ "scripts/e2e-parallel.mjs", "scripts/e2e-kit.mjs", "scripts/upgrade-path.mjs", "scripts/check-results.mjs",
36
+ "vitest.config.ts", "test/attacks/vitest.config.ts",
37
+ "test/setup-state.ts", "test/fresh-store.ts", "test/temp-root.ts", "test/ensure-build.ts", "test/release-reporter.ts",
38
+ ]);
39
+ /** Vitest's include globs (vitest.config.ts), as the plane reads them: a change to that file is a harness change. */
40
+ export const UNIT_INCLUDE = Object.freeze([/^src\/.+\.test\.ts$/, /^test\/attacks\/.+\.test\.ts$/]);
41
+ export const isUnitFile = (path) => UNIT_INCLUDE.some(one => one.test(path));
42
+ /** The project's own Git directory as Toolroll records it: `<realpath(repo)>/.git`, a real directory. */
43
+ export function projectGitDir(repo) {
44
+ try {
45
+ const named = join(realpathSync(repo), ".git");
46
+ return lstatSync(named).isDirectory() ? realpathSync(named) : null;
47
+ }
48
+ catch {
49
+ return null;
50
+ }
51
+ }
52
+ const sha256 = (value) => createHash("sha256").update(value).digest("hex");
53
+ /** A digest of a payload, over its canonical JSON. */
54
+ export const payloadDigest = (value) => sha256(JSON.stringify(value));
55
+ /**
56
+ * Whether a tree path is part of the harness for the execution context: every file EXCEPT the unit test files
57
+ * themselves, the two journey scripts, docs and Markdown. No import tracing: a harness dependency reached by any road
58
+ * (a `require`, a computed `import()`, a side-effect import, a `src/` helper, a config file) is inside this set, so a
59
+ * change to it always changes the digest (fail closed).
60
+ */
61
+ export function inHarnessDigest(path) {
62
+ if (isUnitFile(path))
63
+ return false;
64
+ if (path === "scripts/app-e2e.mjs" || path === "scripts/flows-e2e.mjs")
65
+ return false;
66
+ if (path.startsWith("docs/") || path.endsWith(".md"))
67
+ return false;
68
+ return true;
69
+ }
70
+ /** The tree facts of `sha`, from objects hashed here (never the checkout). Null with why when they can't be read. */
71
+ export function treeFactsOf(gitDir, sha) {
72
+ const commit = readVerifiedCommit(gitDir, sha);
73
+ if (!commit.ok)
74
+ return { ok: false, problem: commit.message };
75
+ const entries = verifiedTreeEntries(gitDir, commit.value.tree);
76
+ if (!entries.ok)
77
+ return { ok: false, problem: entries.message };
78
+ const harness = entries.value.filter(one => inHarnessDigest(one.path)).map(one => one.path).sort();
79
+ const ids = new Map(entries.value.map(one => [one.path, one.id]));
80
+ return { ok: true, facts: {
81
+ tree: commit.value.tree,
82
+ entries: entries.value,
83
+ units: entries.value.filter(one => (one.mode === "100644" || one.mode === "100755") && isUnitFile(one.path)).map(one => one.path).sort(),
84
+ harness,
85
+ harnessDigest: payloadDigest(entries.value.filter(one => inHarnessDigest(one.path)).map(one => [one.path, one.mode, one.id])),
86
+ lockfile: ids.get("package-lock.json") ?? null,
87
+ } };
88
+ }
89
+ /** The execution context a check runs in: what must match for results to stand beside each other. The machine's load
90
+ * budget is left out: it changes how fast a check runs, never what passes (scripts/release-check.mjs checkBudget). */
91
+ export function checkContextOf(facts, command, access) {
92
+ return { version: 1, node: process.version, platform: process.platform, arch: process.arch, lockfile: facts.lockfile, harness: facts.harnessDigest, grant: { id: command.id, digest: command.digest }, access };
93
+ }
94
+ /** The parts a full check selects, as far as the plane knows them before it runs. */
95
+ export const FULL_PARTS = CHECK_PARTS;
96
+ /** What a check must account for, sealed before it runs: every unit file of the tree, whatever runs (a targeted
97
+ * check accounts for the rest through its base), and the parts it selects. */
98
+ export function inventoryOf(facts, plan) {
99
+ return { version: 1, units: facts.units, parts: plan === null ? [...FULL_PARTS] : ["typecheck", "build", ...plan.parts.filter(one => one !== "typecheck" && one !== "build")] };
100
+ }
101
+ /**
102
+ * Seal a check's attempt row before its command is spawned: intended mode, nonce hash, inventory and context (and for a
103
+ * targeted check its plan and obligation snapshot, sealed as artifacts first). Null when the plane can't read the
104
+ * commit, which leaves the check running exactly as it always has, with no handshake.
105
+ */
106
+ export function prepareCheckAttempt(store, root, input, now) {
107
+ if (checkAttemptOf(store, input.runId) !== null)
108
+ return null;
109
+ const gitDir = projectGitDir(input.repo);
110
+ if (gitDir === null)
111
+ return null;
112
+ const read = treeFactsOf(gitDir, input.head);
113
+ if (!read.ok)
114
+ return null;
115
+ const plan = input.plan ?? null, snapshot = input.snapshot ?? null;
116
+ const inventory = inventoryOf(read.facts, plan);
117
+ const context = checkContextOf(read.facts, input.command, input.access);
118
+ const nonce = randomBytes(32).toString("hex");
119
+ const mode = plan === null ? "full" : "targeted";
120
+ sealJson(store, root, input.runId, "check-context.json", context, CHECK_CONTEXT_CAPTURE, now);
121
+ if (plan !== null)
122
+ sealJson(store, root, input.runId, "targeted-plan.json", plan, TARGETED_PLAN_CAPTURE, now);
123
+ if (snapshot !== null)
124
+ sealJson(store, root, input.runId, "obligation-snapshot.json", snapshot, OBLIGATION_SNAPSHOT_CAPTURE, now);
125
+ recordCheckAttempt(store, {
126
+ run: input.runId, authority: input.authority ?? null, mode, baseRun: plan?.base ?? null,
127
+ planDigest: plan === null ? null : payloadDigest(plan), snapshotDigest: snapshot === null ? null : payloadDigest(snapshot),
128
+ inventoryDigest: payloadDigest(inventory), contextDigest: payloadDigest(context), nonceHash: sha256(nonce),
129
+ }, now);
130
+ // The command's own limit rides along, so the check ends itself (logs and report printed) before the plane stops it.
131
+ const stdin = JSON.stringify({ nonce, mode, plan, watch: [...(input.watch ?? [])], limitMs: input.command.timeoutMs });
132
+ return { runId: input.runId, nonce, stdin, mode, inventory, context, plan, snapshot, watch: [...(input.watch ?? [])] };
133
+ }
134
+ /** Seal one JSON payload as a structured-output artifact under its capture label. */
135
+ export function sealJson(store, root, runId, name, value, capture, now) {
136
+ const bytes = Buffer.from(JSON.stringify(value), "utf8");
137
+ if (bytes.length > CHECK_ARTIFACT_CAP)
138
+ throw new Error(`${name} is over ${CHECK_ARTIFACT_CAP} bytes`);
139
+ return storeEvidence(store, root, runId, "structured-output", name, bytes, capture, now, { captureStatus: "ok", cap: CHECK_ARTIFACT_CAP });
140
+ }
141
+ /**
142
+ * The check's report from its output: the LAST `TOOLROLL_CHECK_REPORT <json>` line carrying this nonce, at most 256 KiB,
143
+ * that matches the contract. Lines without the nonce (a test's print, a leftover process's write) are passed over.
144
+ */
145
+ export function reportFromOutput(stdout, nonce) {
146
+ const lines = stdout.split("\n");
147
+ for (let at = lines.length - 1; at >= 0; at--) {
148
+ const line = lines[at];
149
+ if (!line.startsWith(CHECK_REPORT_PREFIX))
150
+ continue;
151
+ if (Buffer.byteLength(line) > CHECK_REPORT_MAX_BYTES)
152
+ continue;
153
+ const raw = line.slice(CHECK_REPORT_PREFIX.length);
154
+ let parsed;
155
+ try {
156
+ parsed = JSON.parse(raw);
157
+ }
158
+ catch {
159
+ continue;
160
+ }
161
+ if (parsed === null || typeof parsed !== "object" || parsed["nonce"] !== nonce)
162
+ continue;
163
+ const read = readCheckReport(parsed);
164
+ if (!read.ok)
165
+ return { ok: false, problem: `The check's report doesn't match its contract: ${read.issues.slice(0, 3).map(one => one.line).join("; ")}` };
166
+ return { ok: true, report: read.value, raw };
167
+ }
168
+ return { ok: false, problem: "The check gave no report for this run." };
169
+ }
170
+ /**
171
+ * After the check: seal its report (when it gave a valid one) and the inventory artifact. `exitCode` is the check's own
172
+ * exit; a report that disagrees with it is no report. Returns the report, or null.
173
+ */
174
+ export function sealCheckOutcome(store, root, attempt, output, now) {
175
+ const read = reportFromOutput(output.stdout, attempt.nonce);
176
+ const report = read.ok && read.report.mode === attempt.mode && read.report.exitCode === output.exitCode &&
177
+ read.report.planDigest === (attempt.plan === null ? null : payloadDigest(attempt.plan)) ? read.report : null;
178
+ const declared = report === null ? { groups: [], versions: [] } : {
179
+ groups: report.journeys.map(one => ({ script: one.script, kind: one.kind, groups: one.groups.map(group => group.group) })),
180
+ versions: report.upgrades?.versions.map(one => one.version) ?? [],
181
+ };
182
+ const sealedInventory = { version: 1, sealed: attempt.inventory, declared };
183
+ sealJson(store, root, attempt.runId, "check-inventory.json", sealedInventory, CHECK_INVENTORY_CAPTURE, now);
184
+ if (report !== null)
185
+ sealJson(store, root, attempt.runId, "check-report.json", report, CHECK_REPORT_CAPTURE, now);
186
+ return report;
187
+ }
188
+ /** One sealed check artifact of a run, read back and verified, or null (missing, ambiguous, cut short or changed). */
189
+ export function readSealedJson(store, root, runId, capture) {
190
+ const found = store.artifactsFor(runId).filter(one => one.kind === "structured-output" && one.capture === capture);
191
+ if (found.length !== 1)
192
+ return null;
193
+ const artifact = found[0];
194
+ if (artifact.truncated || artifact.redacted || artifact.captureStatus !== "ok")
195
+ return null;
196
+ const read = readVerifiedArtifact(root, artifact);
197
+ if (!read.ok)
198
+ return null;
199
+ try {
200
+ return { value: JSON.parse(read.content.toString("utf8")), digest: artifact.sha256 };
201
+ }
202
+ catch {
203
+ return null;
204
+ }
205
+ }
package/dist/claim.js CHANGED
@@ -128,7 +128,7 @@ function acquireLocked(store, taskRef, runner, options) {
128
128
  return {
129
129
  ok: false,
130
130
  reason: "mode-ended",
131
- message: "the operating mode that approved this has ended — the approval falls back to a person",
131
+ message: "the approval it was sealed with no longer stands (an ended mode or flow grant, or an approval that wasn't a person's) — a person approves it again",
132
132
  };
133
133
  }
134
134
  // A LEAD SWEEP'S LIMIT, inside this write transaction so two runners can't both take the last slot: at most
@@ -10,6 +10,7 @@ import { createContainer, currentContainment } from "./containment.js";
10
10
  import { processMayBeAlive } from "./process-liveness.js";
11
11
  import { observeProcessTree, sampleProcessTree, stopProcessTree } from "./process-tree.js";
12
12
  import { isOwnEnv } from "./names.js";
13
+ import { isProtectedEnvName } from "./protected-storage.js";
13
14
  import { sleep } from "./sleep.js";
14
15
  /** A response from the server, distinct from an ambiguous transport failure. */
15
16
  export class CodingProviderRequestError extends Error {
@@ -54,8 +55,9 @@ export function codingEnvironment() {
54
55
  // Preserve native Codex auth, HOME, PATH, CODEX_HOME and project config.
55
56
  // A parent desktop session's control pipe and identity do not belong to
56
57
  // this independent native client. Keep install/runtime paths such as
57
- // CODEX_MCP_NODE_PATH. Service credentials stay with the web service.
58
- if (isOwnEnv(key) || /^(TELEGRAM|SLACK|DISCORD)_.*(TOKEN|SECRET|KEY)$/i.test(key) || /^CODEX_APP_TOOLS_/.test(key) || invokingSession.has(key) || key === "NODE_OPTIONS" || key === "NODE_PATH")
58
+ // CODEX_MCP_NODE_PATH. Service credentials stay with the web service; no chat or vault variable reaches it
59
+ // (protected-storage.ts).
60
+ if (isOwnEnv(key) || isProtectedEnvName(key) || /^CODEX_APP_TOOLS_/.test(key) || invokingSession.has(key) || key === "NODE_OPTIONS" || key === "NODE_PATH")
59
61
  delete env[key];
60
62
  }
61
63
  return env;
@@ -0,0 +1,111 @@
1
+ export type Extraction = {
2
+ ok: true;
3
+ files: number;
4
+ } | {
5
+ ok: false;
6
+ message: string;
7
+ };
8
+ /** What one extraction may hold, all checked before anything is written: the bytes written (every path, a blob shared
9
+ * by many paths counted once per path), the files, the tree entries walked and how deep the trees nest. */
10
+ export type ExtractionLimits = {
11
+ bytes: number;
12
+ files: number;
13
+ entries: number;
14
+ depth: number;
15
+ };
16
+ export declare const EXTRACTION_LIMITS: ExtractionLimits;
17
+ /** A tree path that stays where it says: relative, no empty, `.` or `..` part, no backslash or control character. */
18
+ export declare function normalizedTreePath(path: string): boolean;
19
+ /** The object id Git gives `<type> <size>\0<bytes>` in this repository's object format. */
20
+ export declare const objectIdOf: (format: "sha1" | "sha256", type: string, bytes: Buffer) => string;
21
+ type TreeEntry = {
22
+ mode: string;
23
+ name: string;
24
+ id: string;
25
+ };
26
+ /** A tree object's entries, parsed from its verified bytes: `<mode> <name>\0<raw id>` each. Null when malformed. */
27
+ export declare function parseTree(bytes: Buffer, idBytes: number): TreeEntry[] | null;
28
+ /** Write commit `sha` of the repository whose Git directory is `gitDir` (a realpath Toolroll took from its own
29
+ * records) into `dest`, an empty folder this process made. Every object on the way — the commit, each tree, each
30
+ * blob — is hashed here and must be the id that names it: Git's own answer about an id is never taken on trust, so a
31
+ * corrupted or replaced object in a store a build could write to refuses the extraction. */
32
+ export declare function extractCommit(gitDir: string, sha: string, dest: string, limits?: ExtractionLimits): Extraction;
33
+ /** A commit read from its verified bytes: its tree and its parents, in order. */
34
+ export type VerifiedCommit = {
35
+ id: string;
36
+ tree: string;
37
+ parents: string[];
38
+ message: string;
39
+ };
40
+ /** One entry of a verified tree, at its full path: a file (100644, 100755), a symlink (120000) or a submodule (160000). */
41
+ export type VerifiedEntry = {
42
+ path: string;
43
+ mode: string;
44
+ id: string;
45
+ };
46
+ /** One path that differs between two verified trees, with its line counts when both sides are text. */
47
+ export type TreeChange = {
48
+ path: string;
49
+ kind: "added" | "modified" | "deleted";
50
+ before: VerifiedEntry | null;
51
+ after: VerifiedEntry | null;
52
+ added: number;
53
+ deleted: number;
54
+ binary: boolean;
55
+ };
56
+ export type Verified<T> = {
57
+ ok: true;
58
+ value: T;
59
+ } | {
60
+ ok: false;
61
+ message: string;
62
+ };
63
+ /** Which Git runs and with what environment: the release path's fixed absolute Git and its own environment, or by
64
+ * default the checkout Git environment's. The hardening settings are added over either. */
65
+ export type GitRunner = {
66
+ git?: string;
67
+ env?: NodeJS.ProcessEnv;
68
+ };
69
+ /** One commit, hashed here and parsed from its own bytes. */
70
+ export declare function readVerifiedCommit(gitDir: string, sha: string): Verified<VerifiedCommit>;
71
+ /**
72
+ * The commits from `from` back to `until` along first parents, newest first, `until` itself left out. Refuses when
73
+ * `until` isn't reached within `max` commits (it isn't an ancestor, or too much lies between), and hands back each
74
+ * commit's full parent list so a caller can refuse merges.
75
+ */
76
+ export declare function verifiedFirstParentWalk(gitDir: string, from: string, until: string, max?: number): Verified<VerifiedCommit[]>;
77
+ /** Every entry of a verified tree at its full path, symlinks and submodules included (a caller decides on them). An
78
+ * unnormalized path, or one a tree lists twice, refuses the whole read. */
79
+ export declare function verifiedTreeEntries(gitDir: string, tree: string, limits?: ExtractionLimits): Verified<VerifiedEntry[]>;
80
+ /** Whether bytes look binary: a NUL in the first 8000 bytes, as Git judges. */
81
+ export declare const looksBinary: (bytes: Buffer) => boolean;
82
+ /** The lines added and deleted from `before` to `after`, by the shortest edit (Myers): each counted once, stopped at
83
+ * `cap` total edits (the counts then add up to more than `cap`, which every limit here refuses). */
84
+ export declare function lineChanges(before: Buffer, after: Buffer, cap?: number): {
85
+ added: number;
86
+ deleted: number;
87
+ };
88
+ /**
89
+ * What differs between two verified trees, path by path (no rename pairing: a moved file is a deletion and an
90
+ * addition). Text files get their added and deleted lines; a binary side, a symlink or a submodule is marked so a caller
91
+ * can refuse it.
92
+ */
93
+ export declare function verifiedTreeDiff(gitDir: string, beforeTree: string, afterTree: string): Verified<TreeChange[]>;
94
+ /** The ids of verified blobs at these paths of a tree (absent paths left out): a digest's inputs, read without
95
+ * running anything. */
96
+ export declare function verifiedBlobs(gitDir: string, tree: string, paths: readonly string[]): Verified<Map<string, {
97
+ id: string;
98
+ bytes: Buffer;
99
+ }>>;
100
+ /**
101
+ * The commits reachable from `to` and not from `from`, as Git lists them (newest first), each read from its own verified
102
+ * bytes: what a release card says changed (release-card.ts). Git only names them. Each is hashed here and its parents
103
+ * checked against Git's listing; every commit the range stops at (a parent outside it) must be reached from `from`
104
+ * through verified parents within `reach` commits, so history a build rewrote around the objects can't shorten the
105
+ * list. A shallow boundary, grafts or replacement refs refuse (verifiedReader), as does a range longer than `max`.
106
+ */
107
+ export declare function verifiedRange(gitDir: string, from: string, to: string, options?: GitRunner & {
108
+ max?: number;
109
+ reach?: number;
110
+ }): Verified<VerifiedCommit[]>;
111
+ export {};