@rightkit/release 0.6.57 → 0.6.62

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 (71) hide show
  1. package/README.md +4 -0
  2. package/acceptance-admission.mjs +104 -0
  3. package/acceptance-launch.mjs +234 -0
  4. package/acceptance-lines.mjs +1254 -0
  5. package/acceptance-result.mjs +77 -0
  6. package/acceptance-rows.mjs +47 -0
  7. package/admission-files.mjs +2 -0
  8. package/affected-units.mjs +17 -0
  9. package/app-check.mjs +6 -2
  10. package/app-closure.mjs +3 -1
  11. package/bin/rightkit-gate.mjs +552 -124
  12. package/broker-admission.mjs +45 -2
  13. package/broker-pins.mjs +11 -1
  14. package/broker-toolchain.mjs +113 -0
  15. package/cargo-profile-contract.mjs +7 -2
  16. package/class-a-cache-history.mjs +170 -0
  17. package/cli/right-release.mjs +0 -0
  18. package/code-closure.mjs +24 -0
  19. package/config-inspect.mjs +6 -0
  20. package/consumer-contracts.mjs +3 -1
  21. package/contract-nn.json +166 -0
  22. package/deterministic-scans.mjs +835 -112
  23. package/feature-coverage.mjs +109 -82
  24. package/feature-partition.mjs +76 -0
  25. package/forbidden-literals.mjs +78 -0
  26. package/gate/calls.mjs +121 -0
  27. package/gate/compile.mjs +190 -0
  28. package/gate/crate-results.mjs +127 -0
  29. package/gate/run-calls.mjs +241 -0
  30. package/gate/tests.mjs +234 -0
  31. package/gate-coverage.mjs +12 -3
  32. package/gate-release-admission.mjs +200 -0
  33. package/gate-seam.mjs +100 -4
  34. package/gate-serve.mjs +179 -34
  35. package/gate-stages.mjs +59 -0
  36. package/legacy-contract-receipt.mjs +809 -0
  37. package/local-publish.mjs +2 -4
  38. package/local-runtime.mjs +2 -2
  39. package/nsis-payload.mjs +4 -3
  40. package/ownership-applicability.mjs +5 -0
  41. package/ownership-class-rules.mjs +19 -8
  42. package/ownership-mandatory-set.json +15 -21
  43. package/ownership-mandatory-set.mjs +19 -4
  44. package/package.json +14 -8
  45. package/probe-memo.mjs +252 -0
  46. package/publication-artifacts.mjs +56 -2
  47. package/publish-local-npm.mjs +3 -0
  48. package/publish-update.mjs +2 -2
  49. package/receipt-signature.mjs +40 -0
  50. package/release.mjs +47 -29
  51. package/resident-answers.mjs +66 -0
  52. package/rightkit-ownership.json +20 -11
  53. package/rightkit-versions.json +349 -183
  54. package/runtime-bundle-stage.mjs +146 -0
  55. package/scan-digest.mjs +28 -4
  56. package/seam-broker.mjs +8 -1
  57. package/shell-contract.mjs +23 -2
  58. package/snapshot-changes.mjs +106 -0
  59. package/snapshot-check.mjs +17 -13
  60. package/snapshot-dependency-reuse.mjs +186 -14
  61. package/snapshot-git.mjs +17 -1
  62. package/snapshot-metadata.mjs +155 -3
  63. package/snapshot.mjs +89 -12
  64. package/spawn-ledger.mjs +21 -2
  65. package/stage-sidecar.mjs +231 -19
  66. package/suite-trust-roots.mjs +2 -2
  67. package/test-env.mjs +26 -0
  68. package/tool-version-memo.mjs +46 -0
  69. package/win-package-recipe.mjs +11 -0
  70. package/bin/darwin/rightkit-swap +0 -0
  71. package/gate-acceptance.mjs +0 -3362
package/gate/tests.mjs ADDED
@@ -0,0 +1,234 @@
1
+ // Runs the test programs a test-build call produced (design section 11). They run outside the broker.
2
+ //
3
+ // Input: the `testExecutables` list of the broker's signed receipt: [{ path, sha256, package_id, target, kind }].
4
+ // A program is run only when the file on disk has the sha256 the receipt lists. Results are per crate.
5
+ import crypto from "node:crypto";
6
+ import fs from "node:fs";
7
+ import os from "node:os";
8
+ import { spawn as nodeSpawn, spawnSync } from "node:child_process";
9
+ import { packageNameOf } from "./crate-results.mjs";
10
+ import { testKeyEnv, testProgramEnv } from "../test-env.mjs";
11
+ import { recordLockChild } from "../snapshot.mjs";
12
+
13
+ /**
14
+ * Reads a test program's output as it arrives and counts what the standard harness says, over the WHOLE stream: nothing is decided from a kept
15
+ * tail, so an ignored or failed count, or a run that started and never reported, cannot disappear behind later output. One scanner per stream
16
+ * (stdout and stderr interleave by chunk, not by line). `push(chunk)` takes text in any chunking; `stats()` closes the last line and returns
17
+ * { started, results, unread, failedWord, passed, failed, ignored }.
18
+ */
19
+ export function libtestScanner() {
20
+ const st = { started: 0, results: 0, unread: 0, failedWord: false, passed: 0, failed: 0, ignored: 0 };
21
+ let rest = "";
22
+ const line = (raw) => {
23
+ const text = raw.trim();
24
+ if (/^running \d+ tests?$/.test(text)) { st.started += 1; return; }
25
+ if (!text.startsWith("test result:")) return;
26
+ st.results += 1;
27
+ const m = /^test result: (ok|FAILED)\. (\d+) passed; (\d+) failed; (\d+) ignored/.exec(text);
28
+ if (!m) { st.unread += 1; return; }
29
+ if (m[1] === "FAILED") st.failedWord = true;
30
+ st.passed += Number(m[2]); st.failed += Number(m[3]); st.ignored += Number(m[4]);
31
+ };
32
+ return {
33
+ push(chunk) {
34
+ rest += String(chunk);
35
+ let at;
36
+ while ((at = rest.indexOf("\n")) >= 0) { line(rest.slice(0, at)); rest = rest.slice(at + 1); }
37
+ // A line with no end yet: the patterns are at the start of a line, so its first 4096 characters are all that is ever needed.
38
+ if (rest.length > 8192) rest = rest.slice(0, 4096);
39
+ },
40
+ stats() { if (rest) { line(rest); rest = ""; } return { ...st }; },
41
+ };
42
+ }
43
+ const scanText = (text) => { const sc = libtestScanner(); sc.push(String(text ?? "")); return sc.stats(); };
44
+ const addStats = (a, b) => ({ started: a.started + b.started, results: a.results + b.results, unread: a.unread + b.unread, failedWord: a.failedWord || b.failedWord, passed: a.passed + b.passed, failed: a.failed + b.failed, ignored: a.ignored + b.ignored });
45
+
46
+ /** Sum of the `test result:` lines a libtest program printed; null when it printed none. Takes the output text or a scanner's stats. */
47
+ export function libtestSummary(textOrStats) {
48
+ const st = typeof textOrStats === "object" && textOrStats !== null ? textOrStats : scanText(textOrStats);
49
+ const lines = st.results - st.unread;
50
+ return lines ? { passed: st.passed, failed: st.failed, ignored: st.ignored, lines } : null;
51
+ }
52
+
53
+ /**
54
+ * Why a program that exited 0 still cannot be counted as passed, from what it printed (the output text or a scanner's stats); null when
55
+ * nothing contradicts the exit code.
56
+ * - a `test result:` line that cannot be read (its counts are unknown, so they are not taken as zero);
57
+ * - more `running N tests` headers than `test result:` lines (a run started and never reported);
58
+ * - a summary that says FAILED or reports failed tests.
59
+ * A program that prints neither a header nor a result line (a custom harness, or one with nothing to say) is judged by its exit code alone, and a
60
+ * libtest run of zero tests prints its own "0 passed" line: both still qualify.
61
+ */
62
+ export function libtestProblem(textOrStats) {
63
+ const st = typeof textOrStats === "object" && textOrStats !== null ? textOrStats : scanText(textOrStats);
64
+ if (st.unread) return `${st.unread} "test result:" line(s) could not be read, so the counts are not known`;
65
+ if (st.failedWord || st.failed) return `its summary reports ${st.failed} failed test(s)${st.failedWord ? " (FAILED)" : ""} although it exited 0`;
66
+ if (st.started > st.results) return `${st.started} test run(s) started and ${st.results} reported a result: the output ended before the summary`;
67
+ return null;
68
+ }
69
+
70
+ const sha256File = (file) => crypto.createHash("sha256").update(fs.readFileSync(file)).digest("hex");
71
+
72
+ /**
73
+ * Asks the system to stop `child` and everything it started: taskkill /T /F on Windows (bounded to `killMs`), the child's own process
74
+ * group elsewhere (it is spawned detached there). Returns { ok, detail }: ok is true only when the request was accepted or the target was already gone.
75
+ */
76
+ export function stopTree(child, { platform = process.platform, run = spawnSync, kill = (pid, sig) => process.kill(pid, sig), killMs = 10000 } = {}) {
77
+ if (!child?.pid) return { ok: false, detail: "the program has no process id" };
78
+ if (platform === "win32") {
79
+ let r;
80
+ try { r = run("taskkill", ["/T", "/F", "/PID", String(child.pid)], { windowsHide: true, stdio: "ignore", timeout: killMs }); } catch (error) { return { ok: false, detail: `taskkill could not be started (${error.message})` }; }
81
+ if (r?.error) return { ok: false, detail: `taskkill did not finish (${r.error.code ?? r.error.message})` };
82
+ return r?.status === 0 || r?.status === 128 ? { ok: true, detail: "" } : { ok: false, detail: `taskkill exited ${r?.status}` };
83
+ }
84
+ try { kill(-child.pid, "SIGKILL"); return { ok: true, detail: "" }; }
85
+ catch (error) { return error?.code === "ESRCH" ? { ok: true, detail: "" } : { ok: false, detail: `the process group could not be signalled (${error?.code ?? error?.message})` }; }
86
+ }
87
+
88
+ /**
89
+ * Whether the process group `child` leads is gone. POSIX: true only when signalling the group answers "no such process".
90
+ * That is not proof for the whole tree: a process it started can leave the group (setsid, setpgid) and nothing here follows it.
91
+ * So no answer of this function lets a timed-out program count as stopped; it only says how far the stop is known to have got.
92
+ * Windows: null, always. The end of the program and a clean taskkill do not prove that a process it started (one that left the tree) is gone,
93
+ * and nothing here can ask. The gate's lock-holder job (snapshot.mjs) is what proves it later, when the lock is reclaimed.
94
+ */
95
+ export function treeGone(child, { platform = process.platform, kill = (pid, sig) => process.kill(pid, sig) } = {}) {
96
+ if (platform === "win32") return null;
97
+ try { kill(-child.pid, 0); return false; } catch (error) { return error?.code === "ESRCH"; }
98
+ }
99
+
100
+ /**
101
+ * Runs one program. On a timeout its process tree is asked to stop and the result waits (up to `reapMs`) for the group to go.
102
+ * A timed-out program is always `unreaped: true`: on no host can this code prove that nothing it started is left (a process can
103
+ * leave the group on POSIX and the tree on Windows). The same when its record beside the snapshot lock cannot be written.
104
+ */
105
+ function runOne({ file, args, cwd, env, timeoutMs, spawn, platform = process.platform, stop = stopTree, gone = treeGone, record = recordLockChild, reapMs = 15000, pollMs = 100 }) {
106
+ return new Promise((resolve) => {
107
+ let out = ""; let done = false; let timedOut = false; let closed = false; let poll = null;
108
+ // `output` is the kept tail, for a person to read. `summary` is counted over everything the program wrote.
109
+ const scanOut = libtestScanner(); const scanErr = libtestScanner();
110
+ const finish = (r) => { if (!done) { done = true; clearInterval(poll); resolve({ ...r, output: out.slice(-20000), summary: addStats(scanOut.stats(), scanErr.stats()) }); } };
111
+ const late = `timed out after ${Math.round(timeoutMs / 1000)} s`;
112
+ let child;
113
+ try { child = spawn(file, args, { cwd, env, stdio: ["ignore", "pipe", "pipe"], windowsHide: true, ...(platform === "win32" ? {} : { detached: true }) }); }
114
+ catch (error) { finish({ exit: null, error: String(error.message ?? error) }); return; }
115
+ // A detached group no longer dies with the gate: it is recorded beside the held snapshot lock, so a crashed gate's leftover keeps the lock (snapshot.mjs).
116
+ // If that record cannot be written the program is running unrecorded: it is asked to stop, and it is unreaped whatever the stop answers.
117
+ try { record(child, { platform }); }
118
+ catch (error) { const asked = stop(child, { platform }); finish({ exit: null, unreaped: true, error: `${String(error.message ?? error)}; it is not proven stopped${asked.ok ? "" : ` (${asked.detail})`}` }); return; }
119
+ const timer = setTimeout(() => {
120
+ timedOut = true;
121
+ const deadline = Date.now() + reapMs; // the clock starts before the stop request, so a slow taskkill is inside it
122
+ const asked = stop(child, { platform });
123
+ const unproven = (why) => finish({ exit: null, unreaped: true, error: `${late}; what it started is not proven stopped (${why})` });
124
+ const look = () => {
125
+ if (!asked.ok) { unproven(asked.detail); return; }
126
+ const empty = gone(child, { platform });
127
+ if (empty === true) { unproven("its process group is gone, but a process that left the group cannot be ruled out"); return; }
128
+ if (empty === null && closed) { unproven("the program ended, and Windows gives no proof for the processes it started"); return; }
129
+ if (Date.now() >= deadline) unproven(empty === null ? `the program had not ended ${Math.round(reapMs / 1000)} s after the stop` : `its process group still answered ${Math.round(reapMs / 1000)} s after the stop`);
130
+ };
131
+ poll = setInterval(look, pollMs); look();
132
+ }, timeoutMs);
133
+ child.stdout.on("data", (d) => { scanOut.push(d); out += d; if (out.length > 400000) out = out.slice(-200000); });
134
+ child.stderr.on("data", (d) => { scanErr.push(d); out += d; if (out.length > 400000) out = out.slice(-200000); });
135
+ child.on("error", (error) => { clearTimeout(timer); closed = true; if (!timedOut) finish({ exit: null, error: String(error.message ?? error) }); });
136
+ child.on("close", (code, signal) => { clearTimeout(timer); closed = true; if (!timedOut) finish({ exit: code, signal }); });
137
+ });
138
+ }
139
+
140
+ /**
141
+ * How many test programs run at once: the host's cores minus 2, at least 1. The same rule as the per-crate rows (deterministic-scans.mjs
142
+ * testRunConcurrency; ADR-001 C2, kept by Adrian 2026-11-02; a test keeps the two equal). Before this the build-together path started one
143
+ * program per core, and each program runs its own tests on as many threads as there are cores.
144
+ */
145
+ export function testProgramsAtOnce({ cpus = os.cpus().length } = {}) { return Math.max(1, cpus - 2); }
146
+
147
+ /**
148
+ * The test work of one run, held to 80% of the machine (the owner's rule of 2026-11-04 for how much of a host builds may use, so the
149
+ * machine stays usable). A test program runs its own tests on as many threads as there are cores unless told otherwise, so programs at once
150
+ * times threads each is what has to stay inside the budget.
151
+ * `programs`: how many are waiting to run side by side. Returns { budget, atOnce, threads }: budget = 80% of the cores (at least 1); atOnce = the
152
+ * programs run side by side (never more than the budget, nor than cores minus 2, nor than `jobs` when given); threads = the test threads each of
153
+ * them gets, so that atOnce * threads <= budget. One program alone gets the whole budget.
154
+ */
155
+ export function testWidth({ cpus = os.cpus().length, programs, jobs = testProgramsAtOnce({ cpus }) } = {}) {
156
+ const budget = Math.max(1, Math.floor(cpus * 0.8));
157
+ const atOnce = Math.max(1, Math.min(budget, jobs, Math.max(1, programs ?? budget)));
158
+ return { budget, atOnce, threads: Math.max(1, Math.floor(budget / atOnce)) };
159
+ }
160
+
161
+ /**
162
+ * Runs every listed program and returns { byCrate: { crate: { result: "passed"|"failed"|"unknown", detail, programs, passed, failed, ignored } }, counts: { programs, ran, cached, unreaped } }.
163
+ * `executables`: the receipt list (null means the broker listed none: every crate in `crates` is unknown).
164
+ * `crates`: [{ name, dir, quiet?: boolean, serialToo?: boolean, allowIgnored?: boolean, assetGated?: boolean }] the crates whose tests are owed; `dir` is the crate's directory in the snapshot.
165
+ * `store`: run-calls.mjs fileStore or null; a passed program is remembered under `scope`, its crate, its sha256, its arguments and the
166
+ * whole environment it is given (test-env.mjs testKeyEnv, which carries the asset rule). `scope` is required with a store: the caller's
167
+ * hash of commit, toolchain, host, broker and gate code. A pass is therefore never reused on another commit: the files a test reads at
168
+ * run time, the binaries it starts and the crates it depends on are all fixed by the commit, and nothing narrower is known here.
169
+ * Each program runs in testProgramEnv (test-env.mjs): no credential-named variable, assets required unless the crate is `assetGated`.
170
+ * A program past `timeoutMs` is asked to stop as a tree and is always counted in `unreaped`; after that no further program starts.
171
+ * Quiet crates run last, one program at a time. `serialToo` crates run a second time with one test thread.
172
+ */
173
+ export async function runTests({ executables, crates, env = process.env, cpus = os.cpus().length, jobs = testProgramsAtOnce({ cpus }), timeoutMs = 30 * 60 * 1000, store = null, scope = null, spawn = nodeSpawn, hashOf = sha256File, platform = process.platform, stop = stopTree, gone = treeGone, record = recordLockChild, reapMs = 15000, pollMs = 100 }) {
174
+ if (store && (typeof scope !== "string" || !scope)) throw new TypeError("runTests: a store needs a scope; a test pass cannot be remembered without the commit and gate it belongs to");
175
+ const byCrate = {}; const counts = { programs: 0, ran: 0, cached: 0, unreaped: 0 };
176
+ if (!Array.isArray(executables)) {
177
+ for (const c of crates) byCrate[c.name] = { result: "unknown", detail: "the test build's receipt listed no test programs", programs: 0, passed: 0, failed: 0, ignored: 0 };
178
+ return { byCrate, counts };
179
+ }
180
+ const owed = new Map(crates.map((c) => [c.name, c]));
181
+ const work = [];
182
+ for (const exe of executables) {
183
+ const crate = owed.get(packageNameOf(exe.package_id));
184
+ if (!crate) continue;
185
+ work.push({ exe, crate, args: [] });
186
+ if (crate.serialToo) work.push({ exe, crate, args: ["--test-threads=1"] });
187
+ }
188
+ counts.programs = work.length;
189
+ const runs = new Map(crates.map((c) => [c.name, []]));
190
+ // Threads per program for the side-by-side part and for the one-at-a-time part (testWidth). A run that names its own thread count keeps it.
191
+ const sideBySide = testWidth({ cpus, programs: work.filter((w) => !w.crate.quiet).length, jobs }); const alone = testWidth({ cpus, programs: 1, jobs: 1 });
192
+ const one = async ({ exe, crate, args }) => {
193
+ const threads = args.some((a) => a.startsWith("--test-threads")) ? null : (crate.quiet ? alone.threads : sideBySide.threads);
194
+ const programEnv = { ...testProgramEnv(env, crate.assetGated === true), CARGO_MANIFEST_DIR: crate.dir, ...(threads === null ? {} : { RUST_TEST_THREADS: String(threads) }) };
195
+ const key = `test-${crypto.createHash("sha256").update(JSON.stringify({ v: 2, scope, crate: crate.name, program: exe.sha256, args, env: testKeyEnv(programEnv) })).digest("hex")}`;
196
+ // After a program that is not proven stopped, no further program is started: it may still be using the shared build folder.
197
+ if (counts.unreaped) { runs.get(crate.name).push({ ok: false, skipped: true, program: exe.target, detail: "not run: an earlier test program is not proven stopped" }); return; }
198
+ const remembered = store?.get(key);
199
+ if (remembered) { counts.cached += 1; runs.get(crate.name).push({ ...remembered.run, cached: true }); return; }
200
+ let run;
201
+ let actual = null;
202
+ try { actual = hashOf(exe.path); } catch (error) { actual = null; run = { ok: false, program: exe.target, detail: `the listed program cannot be read (${error.message})` }; }
203
+ if (!run && actual !== exe.sha256) run = { ok: false, program: exe.target, detail: "the program on disk is not the one the receipt lists (sha256 differs)" };
204
+ if (!run) {
205
+ counts.ran += 1;
206
+ const r = await runOne({ file: exe.path, args, cwd: crate.dir, env: programEnv, timeoutMs, spawn, platform, stop, gone, record, reapMs, pollMs });
207
+ if (r.unreaped) counts.unreaped += 1;
208
+ const sum = libtestSummary(r.summary);
209
+ // Exit 0 is not enough: what the program printed must not contradict it (libtestProblem). Only a run with no such contradiction is remembered.
210
+ const contradiction = r.exit === 0 ? libtestProblem(r.summary) : null;
211
+ run = { ok: r.exit === 0 && !contradiction, program: exe.target, args, passed: sum?.passed ?? 0, failed: sum?.failed ?? 0, ignored: sum?.ignored ?? 0, detail: r.exit !== 0 ? (r.error ?? `exit ${r.exit}${r.signal ? ` (${r.signal})` : ""}: ${r.output.slice(-1500)}`) : contradiction ? `exited 0 but ${contradiction}` : "" };
212
+ if (run.ok) store?.put(key, { run: { ok: true, program: run.program, args, passed: run.passed, failed: run.failed, ignored: run.ignored, detail: "" } });
213
+ }
214
+ runs.get(crate.name).push(run);
215
+ };
216
+ // Loud crates in parallel, then quiet crates one program at a time.
217
+ const loud = work.filter((w) => !w.crate.quiet); const quiet = work.filter((w) => w.crate.quiet);
218
+ let next = 0;
219
+ await Promise.all(Array.from({ length: Math.min(sideBySide.atOnce, loud.length) }, async () => { while (next < loud.length) { const w = loud[next]; next += 1; await one(w); } }));
220
+ for (const w of quiet) await one(w);
221
+ for (const c of crates) {
222
+ const list = runs.get(c.name);
223
+ const passed = list.reduce((n, r) => n + (r.passed ?? 0), 0); const failed = list.reduce((n, r) => n + (r.failed ?? 0), 0); const ignored = list.reduce((n, r) => n + (r.ignored ?? 0), 0);
224
+ const bad = list.filter((r) => !r.ok);
225
+ let result = "passed"; let detail = "";
226
+ if (bad.length && bad.every((r) => r.skipped)) { result = "unknown"; detail = bad[0].detail; }
227
+ else if (bad.length) { result = "failed"; detail = bad.map((r) => `${r.program}: ${r.detail}`).join(" | ").slice(0, 4000); }
228
+ // GATE-CONTRACT GC-A08: an ignored test blocks its unit unless the unit is named (ci/gate.config.json rust.<crate>.allowIgnored, a written reason),
229
+ // whatever else passed. A unit with no test at all, and none ignored, qualifies. The per-crate rows judge the same way (local-publish.mjs judgeUnit).
230
+ else if (ignored > 0 && !c.allowIgnored) { result = "failed"; detail = `${ignored} test(s) ignored and this crate is not named as allowed to ignore tests (${passed} passed; summed over ${list.length} program run(s))`; }
231
+ byCrate[c.name] = { result, detail, programs: list.length, passed, failed, ignored };
232
+ }
233
+ return { byCrate, counts };
234
+ }
package/gate-coverage.mjs CHANGED
@@ -13,13 +13,21 @@ function timingOf(value) {
13
13
  }
14
14
  function telemetryOf(row) {
15
15
  const attempts = Array.isArray(row?.batchAttempts) ? row.batchAttempts.filter((entry) => entry && typeof entry.id === "string" && typeof entry.status === "string").map((entry) => ({ id: entry.id, status: entry.status, timing: timingOf(entry.timing) })) : [];
16
- return { timing: timingOf(row?.timing), scanElapsedMs: duration(row?.scanElapsedMs), retryTiming: timingOf(row?.retried?.timing), batchAttempts: attempts };
16
+ // `group`: the batched invocation that answered this row (runScans' projection of a group onto its members, batchedWith), so a member that missed at
17
+ // lookup and was then answered by its group's stored result is visible as such (contract test S17; astra62 review 8, 2026-11-18).
18
+ const group = typeof row?.batchedWith?.id === "string" && row.batchedWith.id ? { group: row.batchedWith.id } : {};
19
+ return { timing: timingOf(row?.timing), scanElapsedMs: duration(row?.scanElapsedMs), retryTiming: timingOf(row?.retried?.timing), batchAttempts: attempts, ...group };
17
20
  }
18
21
 
19
22
  /**
20
23
  * The report for `plan` (the planned scans, `plan.scans`) and `scanResult` (runScans' rows). `keys` is a Map of scan id -> the input key the cache
21
24
  * looked the scan up under (null or absent: the scan is never cached or no key could be formed). `classes` are the classes this pass runs.
22
25
  */
26
+ /** A cross-target row (id `<scan>@<target triple>`): a type check against stand-ins that never links, so limited evidence (GC-A14, NN38). */
27
+ export const isCrossTargetRow = (id) => /@[^@:]+$/.test(String(id));
28
+ /** The rows of a coverage report that are limited evidence, for the receipt's `stages.compile.limitedEvidence`. */
29
+ export const limitedEvidenceOf = (report) => (report?.scans ?? []).filter((r) => r.evidence === "type-check-only").map((r) => ({ id: r.id, evidence: r.evidence }));
30
+
23
31
  export function buildCoverageReport({ plan, scanResult, keys = new Map(), keyErrors = new Map(), cacheDisabled = null, classes = ["A", "B"], commit = null, startedAt = null, endedAt = null }) {
24
32
  const rows = new Map((scanResult?.scans ?? []).map((row) => [row.id, row]));
25
33
  const scans = (plan?.scans ?? []).map((scan) => {
@@ -27,8 +35,9 @@ export function buildCoverageReport({ plan, scanResult, keys = new Map(), keyErr
27
35
  const key = keys.get(scan.id) ?? null;
28
36
  const telemetry = telemetryOf(row);
29
37
  if (row) {
30
- if (row.cached === true) return { id: scan.id, class: scan.class, ...telemetry, coverage: "hit", status: row.status, key, reason: row.detail ?? "answered from the result cache" };
31
- if (row.status === "pass" || row.status === "fail") return { id: scan.id, class: scan.class, ...telemetry, coverage: "ran", status: row.status, key, reason: key === null ? ((keyErrors.get(scan.id) ?? row.cacheKeyError) ? `no cache key: ${keyErrors.get(scan.id) ?? row.cacheKeyError}` : cacheDisabled ?? "no cache key (this scan is never cached, or no key could be formed)") : "no cached result for this key", ...(row.code ? { code: row.code } : {}) };
38
+ const limited = isCrossTargetRow(scan.id) ? { evidence: "type-check-only" } : {};
39
+ if (row.cached === true) return { id: scan.id, class: scan.class, ...telemetry, ...limited, coverage: "hit", status: row.status, key, reason: row.detail ?? "answered from the result cache" };
40
+ if (row.status === "pass" || row.status === "fail") return { id: scan.id, class: scan.class, ...telemetry, ...limited, coverage: "ran", status: row.status, key, reason: key === null ? ((keyErrors.get(scan.id) ?? row.cacheKeyError) ? `no cache key: ${keyErrors.get(scan.id) ?? row.cacheKeyError}` : cacheDisabled ?? "no cache key (this scan is never cached, or no key could be formed)") : "no cached result for this key", ...(row.code ? { code: row.code } : {}) };
32
41
  return { id: scan.id, class: scan.class, ...telemetry, coverage: "skipped", status: row.status, key, reason: row.detail ?? row.status };
33
42
  }
34
43
  return { id: scan.id, class: scan.class, ...telemetry, coverage: "skipped", status: "not-in-pass", key, reason: classes.includes(scan.class) ? "planned but no result was returned" : `class ${scan.class} is not part of this pass (classes ${classes.join("+")})` };
@@ -0,0 +1,200 @@
1
+ // The twelve-line result (rightkit.acceptance-result/1, acceptance-admission.mjs) is admitted first; what follows describes the old contract-test receipt, still read against the
2
+ // hashes contract-nn.json keeps of the retired runner (`retiredRunner`; the runner itself was deleted in rightkit#1514 step 9).
3
+ // Admission of a gate-package release (docs/GATE-CONTRACT.md NN31: no gate is released without a passing contract test; loop matrix G21, G26).
4
+ //
5
+ // Run where the package archive is about to be published. It has no broker and is not the host that ran the test, so it judges only what it is
6
+ // handed: the host's contract-test receipt, the folder of job claims beside it, the archive in question, and this checkout at the release
7
+ // commit. A job claim is the small statement the broker signs to leave the host ({ id, publication }; rustright GB-104): the key, the host name,
8
+ // the broker build, the job id, the nonce, the commit, the result and the kind of command. The whole receipts and their full signed part name
9
+ // the environment variables the broker dropped and the host's paths; they stay on the host. This repository and its CI are public. It refuses unless every one of the following holds.
10
+ // 1. The receipt passes the release check (legacy-contract-receipt.mjs verifyReleaseReceipts) for this commit, with the contract, budgets and runner
11
+ // files of this checkout, the exact rule set, and names exactly the archive in question. It is a candidate's receipt.
12
+ // 1b. The archive is tied to the tested gate by the seal itself, not by the receipt's statement: the manifest handed over hashes to the seal (and the
13
+ // seal is inside every signed job nonce, rule 3); that manifest lists the installer's source record; the record handed over hashes to that
14
+ // line and names exactly the archive in question (legacy-contract-receipt.mjs archiveOfSeal).
15
+ // 2. The host is one this repository trusts: ci/rk-pipeline.json attestation.<platform> gives its key, host name and broker build. The receipt's
16
+ // broker is that build (loop matrix C9: a host whose installed broker is not the committed one cannot be admitted until that list is updated).
17
+ // 3. The run's broker jobs: the list is not empty; every listed job's claim is in the bundle with the listed hash, carries the broker's
18
+ // signature for that key, host and broker build, is for that job id, and its signed nonce is the one computed from the run id, the sealed gate,
19
+ // the step and the call (gate-seam.mjs contractJobNonce).
20
+ // 4. The launches this checkout's contract-nn.json seals in `signedLaunches` (the launches that cannot be cache hits): each must show a
21
+ // verified job of one of its commands; every verified job of the launch must have the expected signed result and name one same signed
22
+ // commit, which is not the fixture commit when the launch runs on a commit the runner made. A job filed under a launch's label that is
23
+ // another kind of work, another result or another commit does not count and is a problem.
24
+ // What this proves, and no more (rustright attested-runs.md section 5): real jobs of this run, for this gate, went through that host's broker.
25
+ // The key is readable by the account the broker runs as, so this is not a defence against a hostile program on that host. The receipt's verdict
26
+ // itself is the runner's own judgement (`nnBasis`), and the result says so.
27
+ import fs from "node:fs";
28
+ import path from "node:path";
29
+ import { fileURLToPath } from "node:url";
30
+ import { createHash } from "node:crypto";
31
+ import { CONTRACT_FILE, archiveIdentity, archiveOfSeal, verifyReleaseReceipts } from "./legacy-contract-receipt.mjs";
32
+ import { contractJobNonce } from "./gate-seam.mjs";
33
+ import { verifyPublicationClaim } from "./receipt-signature.mjs";
34
+ import { ACCEPTANCE_RESULT_SCHEMA, admitAcceptanceResult, judgeFileHashes } from "./acceptance-admission.mjs";
35
+ import { execFileSync } from "node:child_process";
36
+
37
+ const sha256 = (bytes) => createHash("sha256").update(bytes).digest("hex");
38
+ /** The tree id of a commit in this checkout. */
39
+ const defaultTreeOf = (commit) => String(execFileSync("git", ["-C", path.dirname(CONTRACT_FILE), "rev-parse", `${commit}^{tree}`], { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"], windowsHide: true })).trim();
40
+ const PLATFORM_OF = Object.freeze({ mac: "darwin", dell: "win32" });
41
+ const stepIdOf = (label) => String(label).split(":")[0];
42
+
43
+ /**
44
+ * `receipt`: the contract-test receipt (parsed). `readJob(requestId)`: the bytes of that job's claim from the bundle (throws when absent).
45
+ * `archiveBytes`: the package archive in question. `commit`: the release commit. `pipeline`: ci/rk-pipeline.json (parsed). `sealed`: this
46
+ * checkout's contract-nn.json (parsed). `contractSha256`, `budgetsSha256`, `runnerSha256`, `runnerFiles`: of this checkout. `waivers`: valid waivers.
47
+ * Returns { ok, problems, facts }.
48
+ */
49
+ export function admitGateRelease({ receipt, readJob, archiveBytes, commit, pipeline, sealed, contractSha256, budgetsSha256, runnerSha256, runnerFiles, waivers = [], manifestBytes = null, sourceBytes = null }) {
50
+ const problems = [];
51
+ const facts = { host: receipt?.host ?? null, version: receipt?.gate?.version ?? null, sealedSha256: receipt?.gate?.sealedSha256 ?? null, archiveSha256: null, jobsListed: 0, jobsVerified: 0, signedSteps: [], nnBasis: receipt?.nnBasis ?? null };
52
+ const platform = PLATFORM_OF[receipt?.host];
53
+ const pins = platform ? pipeline?.attestation?.[platform] : null;
54
+ if (!platform) problems.push(`the receipt is from ${JSON.stringify(receipt?.host)}, not a host this repository names`);
55
+ else if (!pins || typeof pins.publicKey !== "string" || typeof pins.keyId !== "string" || typeof pins.host !== "string" || typeof pins.brokerDigest !== "string") problems.push(`ci/rk-pipeline.json has no complete attestation.${platform} (publicKey, keyId, host, brokerDigest)`);
56
+ let archive = null;
57
+ try { archive = archiveIdentity(archiveBytes); facts.archiveSha256 = archive.sha256; } catch (e) { problems.push(`the archive in question cannot be hashed (${e.message})`); }
58
+ if (receipt?.gate?.kind !== "candidate") problems.push(`the receipt is a ${JSON.stringify(receipt?.gate?.kind)} gate's, not a candidate's: only a candidate's receipt names the archive it was installed from`);
59
+ // 1 and the broker half of 2: the release check, with everything this checkout and the committed list know.
60
+ problems.push(...verifyReleaseReceipts(receipt, null, { commit, contractSha256, runnerSha256, budgetsSha256, runnerFiles, waivers, sealedSha256: receipt?.gate?.sealedSha256 ?? null, brokerRuntimeDigest: pins?.brokerDigest ?? null, archive: archive ?? { sha256: null, integrity: null } }).problems);
61
+ // 1b: the seal accounts for the archive.
62
+ if (!manifestBytes || !sourceBytes) problems.push("the tested gate's manifest and source record were not handed over, so nothing ties the archive to the seal but the receipt's own statement");
63
+ else {
64
+ const linked = archiveOfSeal({ sealedSha256: receipt?.gate?.sealedSha256, manifestBytes, sourceBytes });
65
+ for (const p of linked.problems) problems.push(`seal to archive: ${p}`);
66
+ if (linked.ok && archive && (linked.archive.sha256 !== archive.sha256 || linked.archive.integrity !== archive.integrity)) problems.push(`seal to archive: the tested gate was installed from the archive ${linked.archive.sha256}, the archive in question is ${archive.sha256}`);
67
+ if (linked.ok && receipt?.gate?.version !== undefined && linked.archive.version !== receipt.gate.version) problems.push(`seal to archive: the source record is for version ${linked.archive.version}, the receipt says ${receipt.gate.version}`);
68
+ }
69
+ if (!commit) problems.push("no release commit was given");
70
+ // 3: the run's broker jobs.
71
+ const jobs = Array.isArray(receipt?.jobs) ? receipt.jobs : null;
72
+ if (typeof receipt?.runId !== "string" || !/^[0-9a-f]{64}$/.test(receipt.runId)) problems.push("the receipt carries no run id, so its jobs cannot be tied to it");
73
+ if (!jobs) problems.push("the receipt lists no broker jobs (jobs is missing)");
74
+ else if (jobs.length === 0) problems.push("the receipt lists no broker job at all: nothing in it is signed");
75
+ const verified = []; // { label, payload } of every job whose claim verified for this run, gate, step and call
76
+ for (const [i, job] of (jobs ?? []).entries()) {
77
+ facts.jobsListed += 1;
78
+ const name = `job ${job?.requestId ?? `#${i + 1}`} (${job?.step})`;
79
+ if (typeof job?.requestId !== "string" || !job.requestId) continue; // refused before it existed: proves nothing, counts for nothing
80
+ if (!/^[A-Za-z0-9._-]{1,128}$/.test(job.requestId)) { problems.push(`${name}: its job id cannot name a file`); continue; }
81
+ if (typeof job.claimSha256 !== "string") { problems.push(`${name}: it carries no publication claim (its broker made none), so nothing about it may be checked here`); continue; }
82
+ let bytes; try { bytes = readJob(job.requestId); } catch (e) { problems.push(`${name}: its claim is not in the bundle (${e.code ?? e.message})`); continue; }
83
+ if (sha256(bytes) !== job.claimSha256) { problems.push(`${name}: the claim in the bundle is not the one listed (sha256 differs)`); continue; }
84
+ let doc; try { doc = JSON.parse(String(bytes)); } catch { problems.push(`${name}: its claim is not JSON`); continue; }
85
+ if (Object.keys(doc ?? {}).some((k) => k !== "id" && k !== "publication")) { problems.push(`${name}: the bundle holds more than the claim (only id and publication may be handed over)`); continue; }
86
+ let payload;
87
+ try { payload = verifyPublicationClaim(doc, pins, job.requestId); } catch (e) { problems.push(`${name}: ${e.code ? `${e.code}: ` : ""}${e.message}`); continue; }
88
+ let want = null; try { want = contractJobNonce({ runId: receipt.runId, sealedSha256: receipt.gate?.sealedSha256, step: job.step, call: job.call }); } catch { /* reported next */ }
89
+ if (want === null || payload.nonce !== want) { problems.push(`${name}: the nonce the broker signed is not this run's for this gate, step and call`); continue; }
90
+ facts.jobsVerified += 1; verified.push({ label: job.step, name, payload });
91
+ }
92
+ facts.signedSteps = [...new Set(verified.map((v) => stepIdOf(v.label)))].sort();
93
+ // 4: the sealed launches. What each must show comes from this checkout's sealed list, never from the receipt.
94
+ const launches = Array.isArray(sealed?.signedLaunches) ? sealed.signedLaunches : null;
95
+ facts.launchesProven = [];
96
+ if (!launches || launches.length === 0) problems.push("this checkout's contract-nn.json seals no launches that must show signed jobs (signedLaunches)");
97
+ else for (const launch of launches) {
98
+ const mine = verified.filter((v) => v.label === launch.label);
99
+ const where = `launch ${launch.label}`;
100
+ if (!mine.length) { problems.push(`${where} cannot be served from a cache and shows no verified broker job`); continue; }
101
+ const bad = [];
102
+ for (const v of mine) {
103
+ const exit = v.payload.result?.exitCode;
104
+ if (exit !== launch.exitCode) bad.push(`${v.name} ended with exit ${exit ?? "(not stated)"}, the launch requires ${launch.exitCode}`);
105
+ // The broker's own word for how the job ended (rustright job.rs JobState::wire). Exit 0 with another word exists: a check after the process
106
+ // did not let the result stand. Cancelled and timed-out jobs never satisfy a launch.
107
+ const word = launch.exitCode === 0 ? "SUCCEEDED" : "FAILED";
108
+ if (v.payload.result?.status !== word) bad.push(`${v.name} ended as ${v.payload.result?.status ?? "(not stated)"}, expected ${word}`);
109
+ if (typeof v.payload.gate?.commit !== "string" || !/^[0-9a-f]{40}$/.test(v.payload.gate.commit)) bad.push(`${v.name} names no commit`);
110
+ }
111
+ const commits = [...new Set(mine.map((v) => v.payload.gate?.commit ?? null))];
112
+ if (commits.length !== 1) bad.push(`its jobs name ${commits.length} different commits`);
113
+ else if (launch.commit === "any" && commits[0] === receipt?.fixtureCommit) bad.push("its jobs ran on the fixture commit, not on a commit made for this launch");
114
+ else if (launch.commit === "fixture" && commits[0] !== receipt?.fixtureCommit) bad.push("its jobs did not run on the fixture commit the receipt states");
115
+ if (!mine.some((v) => Array.isArray(launch.commands) && launch.commands.includes(v.payload.command))) bad.push(`none of its jobs is one of ${(launch.commands ?? []).join(", ")} (found: ${[...new Set(mine.map((v) => String(v.payload.command)))].join(", ")})`);
116
+ if (bad.length) problems.push(...bad.map((b) => `${where}: ${b}`)); else facts.launchesProven.push(launch.label);
117
+ }
118
+ return { ok: problems.length === 0, problems, facts };
119
+ }
120
+
121
+ /**
122
+ * Admission from files on disk: the receipt, the archive in question, the release commit and the committed pipeline file. The folders
123
+ * `job-claims` and `gate-seal` must sit beside the receipt. Returns { ok, problems, facts }; never throws for a missing or bad input.
124
+ */
125
+ export function admitFromFiles({ receiptFile, archiveFile, commit, pipelineFile = null, treeOf = defaultTreeOf }) {
126
+ const here = path.dirname(fileURLToPath(import.meta.url));
127
+ const problems = [];
128
+ if (!receiptFile) problems.push("no contract-test receipt was named");
129
+ if (!archiveFile) problems.push("no package archive was named");
130
+ if (!commit || !/^[0-9a-f]{40}$/.test(commit)) problems.push("no 40-hex release commit was given");
131
+ const read = (label, f, parse) => { try { const b = fs.readFileSync(f); return parse ? JSON.parse(String(b)) : b; } catch (e) { problems.push(`${label} ${f} cannot be read (${e.code ?? e.message})`); return null; } };
132
+ const receipt = receiptFile ? read("the receipt", receiptFile, true) : null;
133
+ const archiveBytes = archiveFile ? read("the archive", archiveFile, false) : null;
134
+ const pipeline = read("the pipeline file", pipelineFile ?? path.resolve(here, "..", "..", "ci", "rk-pipeline.json"), true);
135
+ const sealed = read("contract-nn.json", path.join(here, "contract-nn.json"), true);
136
+ if (problems.length) return { ok: false, problems, facts: null };
137
+ // A twelve-line result (GC-A27) is admitted by its own rules; any other record is the old contract-test receipt, read as before so results sealed earlier stay readable.
138
+ if (receipt.schema === ACCEPTANCE_RESULT_SCHEMA) {
139
+ if (receipt.jobClaims !== "job-claims") return { ok: false, problems: [`the result names its job claims folder as ${JSON.stringify(receipt.jobClaims)}, expected "job-claims"`], facts: null };
140
+ const dir = path.dirname(path.resolve(receiptFile));
141
+ const orNull = (f) => { try { return fs.readFileSync(f); } catch { return null; } };
142
+ const seal = receipt.gateSeal === "gate-seal" ? path.join(dir, "gate-seal") : null;
143
+ let tree = null; try { tree = treeOf(commit); } catch (e) { problems.push(`the tree of ${commit} cannot be read (${e.message})`); }
144
+ const contractText = String(fs.readFileSync(CONTRACT_FILE));
145
+ const admitted = admitAcceptanceResult({ result: receipt, readJob: (id) => fs.readFileSync(path.join(dir, "job-claims", `${id}.json`)), archiveBytes, commit, tree, pipeline, contractText, contractSha256: sha256(contractText), judgeFiles: judgeFileHashes(),
146
+ manifestBytes: seal ? orNull(path.join(seal, "manifest.txt")) : null, sourceBytes: seal ? orNull(path.join(seal, "trusted-gate-source.json")) : null });
147
+ return { ...admitted, ok: admitted.ok && problems.length === 0, problems: [...problems, ...admitted.problems] };
148
+ }
149
+ if (receipt.jobClaims !== "job-claims") return { ok: false, problems: [`the receipt names its job claims folder as ${JSON.stringify(receipt.jobClaims)}, expected "job-claims"`], facts: null };
150
+ const beside = path.dirname(path.resolve(receiptFile));
151
+ const readOrNull = (f) => { try { return fs.readFileSync(f); } catch { return null; } };
152
+ const seal = receipt.gateSeal === "gate-seal" ? path.join(beside, "gate-seal") : null;
153
+ // The old test's runner, budgets and contract text are gone from the tree; what an old receipt is judged against is what contract-nn.json recorded of them (`retiredRunner`).
154
+ const retired = sealed?.retiredRunner;
155
+ if (!retired || typeof retired.runnerSha256 !== "string" || typeof retired.budgetsSha256 !== "string" || typeof retired.contractSha256 !== "string" || !Array.isArray(retired.runnerFiles)) return { ok: false, problems: ["this checkout's contract-nn.json records no retired runner (retiredRunner), so a contract-test receipt cannot be read"], facts: null };
156
+ const result = admitGateRelease({ manifestBytes: seal ? readOrNull(path.join(seal, "manifest.txt")) : null, sourceBytes: seal ? readOrNull(path.join(seal, "trusted-gate-source.json")) : null, receipt,
157
+ readJob: (id) => fs.readFileSync(path.join(beside, "job-claims", `${id}.json`)), archiveBytes, commit, pipeline, sealed: retired, contractSha256: retired.contractSha256, budgetsSha256: retired.budgetsSha256, runnerSha256: retired.runnerSha256, runnerFiles: retired.runnerFiles,
158
+ waivers: [] });
159
+ return result;
160
+ }
161
+
162
+ /** The package this rule is about, and the variable a publish entry is handed the receipt through. */
163
+ export const GATE_PACKAGE = "@rightkit/release";
164
+ export const GATE_RECEIPT_ENV = "RK_GATE_CONTRACT_RECEIPT";
165
+ /**
166
+ * NN31 at a publication entry point. Every place that is about to publish an npm archive calls this with the package name, the exact file it
167
+ * is about to publish and the commit it was packed from, BEFORE it starts npm. For any other package it does nothing. For the gate package it
168
+ * throws unless a contract-test receipt was handed over (RK_GATE_CONTRACT_RECEIPT names it; `job-claims` and `gate-seal` sit beside it) and
169
+ * admits exactly that file. There is no flag that skips it.
170
+ */
171
+ export function gateReleaseGuard({ name, archiveFile, commit, env = process.env, admit = admitFromFiles, pipelineFile = null }) {
172
+ if (name !== GATE_PACKAGE) return { required: false };
173
+ const receiptFile = env?.[GATE_RECEIPT_ENV];
174
+ if (typeof receiptFile !== "string" || !receiptFile) throw new Error(`${GATE_PACKAGE} is not published without a passing contract-test receipt for this exact archive (GATE-CONTRACT NN31): ${GATE_RECEIPT_ENV} names no receipt`);
175
+ const result = admit({ receiptFile, archiveFile, commit, pipelineFile });
176
+ if (!result.ok) throw new Error(`${GATE_PACKAGE} is not published: its contract-test receipt does not admit this archive (${result.problems.length} problem(s)): ${result.problems.slice(0, 6).join("; ")}${result.problems.length > 6 ? "; ..." : ""}`);
177
+ return { required: true, facts: result.facts };
178
+ }
179
+
180
+ /** `node gate-release-admission.mjs --receipt <file> --archive <package archive> --commit <sha> [--pipeline <ci/rk-pipeline.json>]`: exit 0 only when admitted; with `--record <file>` it then writes the admission record a credentialed upload step requires. The folders `job-claims` and `gate-seal` must sit beside the receipt. */
181
+ export function main(argv = process.argv.slice(2), { out = console.log } = {}) {
182
+ const opt = (name) => { const i = argv.indexOf(name); return i < 0 ? undefined : argv[i + 1]; };
183
+ const known = new Set(["--receipt", "--archive", "--commit", "--pipeline", "--record"]);
184
+ for (const a of argv) if (a.startsWith("--") && !known.has(a)) { out(`gate-release-admission REFUSED: unknown option ${a}`); return 64; }
185
+ const problems = [];
186
+ if (!opt("--receipt")) problems.push("--receipt <contract-test receipt> is required");
187
+ if (!opt("--archive")) problems.push("--archive <package archive in question> is required");
188
+ if (!opt("--commit") || !/^[0-9a-f]{40}$/.test(opt("--commit"))) problems.push("--commit <40-hex release commit> is required");
189
+ let result = null;
190
+ if (!problems.length || opt("--receipt") || opt("--archive")) { result = admitFromFiles({ receiptFile: opt("--receipt"), archiveFile: opt("--archive"), commit: opt("--commit"), pipelineFile: opt("--pipeline") ?? null }); if (!problems.length) problems.push(...result.problems); else problems.push(...result.problems.filter((p) => /cannot be read/.test(p))); }
191
+ if (problems.length) { out(`gate-release-admission REFUSED (${problems.length} problem(s))`); for (const p of problems) out(` ${p}`); return 1; }
192
+ const f = result.facts;
193
+ // --record <file>: the record a credentialed upload step reads (scripts/ci/upload.mjs gateAdmissionProblem). Written only here, only when admitted.
194
+ if (opt("--record")) fs.writeFileSync(opt("--record"), `${JSON.stringify({ schema: "rightkit.gate-release-admission/1", ok: true, unit: GATE_PACKAGE, version: f.version, archiveSha256: f.archiveSha256, commit: opt("--commit"), host: f.host, sealedSha256: f.sealedSha256, jobsVerified: f.jobsVerified, signedSteps: f.signedSteps, nnBasis: f.nnBasis }, null, 2)}\n`);
195
+ out(`gate-release-admission OK: host ${f.host}, sealed gate ${f.sealedSha256}, archive ${f.archiveSha256}; ${f.jobsVerified} of ${f.jobsListed} listed broker job(s) verified, in step(s) ${f.signedSteps.join(", ")}; sealed launch(es) proven from signed claims: ${f.launchesProven.join(", ")}`);
196
+ out(` every other assertion of the verdict rests on: ${f.nnBasis ?? "not stated"} (the signed claims prove those launches ran on that host's broker for this gate, with that command, result and commit; they do not re-derive the rest)`);
197
+ return 0;
198
+ }
199
+
200
+ if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) process.exit(main());