@rightkit/release 0.6.52 → 0.6.54

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 (88) hide show
  1. package/README.md +1 -1
  2. package/adapter-env.mjs +16 -105
  3. package/admission-host.mjs +14 -1
  4. package/bin/darwin/rightkit-swap +0 -0
  5. package/bin/rightkit-gate.mjs +585 -404
  6. package/broker-admission.mjs +122 -2
  7. package/build-launch.mjs +52 -58
  8. package/build-release.mjs +2 -2
  9. package/cargo-ledger.mjs +24 -5
  10. package/cargo-target-shim.mjs +54 -23
  11. package/cargo-target.mjs +2 -2
  12. package/carried-adapter-run.mjs +7 -8
  13. package/carried-cargo-run.mjs +1 -1
  14. package/ci-compile-admission.mjs +1 -1
  15. package/clippy-route.mjs +65 -18
  16. package/compile-inputs.mjs +91 -15
  17. package/cross-targets.mjs +5 -3
  18. package/deps-cargo-lock.mjs +1 -1
  19. package/deterministic-scans.mjs +789 -259
  20. package/development.mjs +33 -7
  21. package/direct-receipt.mjs +3 -5
  22. package/feature-coverage.mjs +45 -9
  23. package/feature-partition.mjs +204 -0
  24. package/feature-sets.mjs +113 -0
  25. package/gate-acceptance.mjs +187 -115
  26. package/gate-seam.mjs +352 -0
  27. package/gate-serve.mjs +34 -2
  28. package/gate-stages.mjs +6 -2
  29. package/ghsa-audit.mjs +19 -4
  30. package/heavy-command.mjs +5 -4
  31. package/install-tauri-authenticode.mjs +73 -4
  32. package/ios-dev.mjs +3 -3
  33. package/ios-package-recipe.mjs +6 -6
  34. package/linux-setup.mjs +3 -2
  35. package/local-publish.mjs +113 -17
  36. package/lock-identity.mjs +24 -100
  37. package/managed-cargo.mjs +3 -3
  38. package/managed-root-guard.mjs +2 -2
  39. package/managed-roots.mjs +3 -3
  40. package/native-adapters.mjs +41 -244
  41. package/native-helpers.mjs +1 -1
  42. package/pack-digest.mjs +1 -1
  43. package/package-recipe-targets.mjs +3 -3
  44. package/package.json +2 -2
  45. package/publication-gate.mjs +29 -6
  46. package/publish-cargo.mjs +4 -5
  47. package/publish-local-cargo.mjs +77 -1
  48. package/qualification-verify.mjs +76 -49
  49. package/receipt-signature.mjs +104 -0
  50. package/release-switch-registry.json +4 -0
  51. package/release-switch-scan.mjs +13 -10
  52. package/rightkit-versions.json +126 -113
  53. package/scan-digest.mjs +43 -14
  54. package/seam-broker.mjs +168 -0
  55. package/snapshot-check.mjs +4 -1
  56. package/snapshot-dependency-reuse.mjs +1 -1
  57. package/snapshot-metadata.mjs +24 -35
  58. package/snapshot.mjs +328 -49
  59. package/stage-commands.mjs +59 -5
  60. package/stage-ledger.mjs +2 -2
  61. package/{carried-cargo.mjs → stage-seam.mjs} +118 -70
  62. package/stage-sidecar.mjs +3 -3
  63. package/tauri-bundle-marker.mjs +5 -2
  64. package/tauri-locked.mjs +1 -1
  65. package/tool-build.mjs +8 -6
  66. package/unit-gate.mjs +40 -10
  67. package/broker-handshake.mjs +0 -160
  68. package/broker-wire.mjs +0 -278
  69. package/build-ownership.mjs +0 -1578
  70. package/cargo-shapes.mjs +0 -332
  71. package/cargo-width.mjs +0 -49
  72. package/carrier-census.mjs +0 -124
  73. package/clippy-equivalence.mjs +0 -202
  74. package/freshness-census.mjs +0 -405
  75. package/handle-revocation.mjs +0 -100
  76. package/handle-revocation.rust-vector.json +0 -1
  77. package/handle-revocation.vectors.json +0 -53
  78. package/legion-freeze-consumer.mjs +0 -241
  79. package/linux-qualifier.mjs +0 -83
  80. package/native-tool-planning.mjs +0 -94
  81. package/owner-process-proof.mjs +0 -14
  82. package/ownership-mark.mjs +0 -191
  83. package/ownership-recover.mjs +0 -78
  84. package/pnpm-adapter-grammar.mjs +0 -226
  85. package/provenance-verify.mjs +0 -413
  86. package/snapshot-broker.mjs +0 -808
  87. package/snapshot-request.mjs +0 -722
  88. package/unit-list-compile.mjs +0 -356
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  // End-to-end acceptance runner for the gate (rightkit#1514). It drives the real gate against the witness fixture and asserts every operative clause of
3
- // docs/GATE-CONTRACT.md from that run's OWN artifacts: the door receipt (--receipt-out), the per-scan coverage reports, the log, the owner record and
3
+ // docs/GATE-CONTRACT.md from that run's OWN artifacts: the door receipt (--receipt-out), the per-scan coverage reports, the log, the snapshot lock and
4
4
  // git. Spec: /Volumes/D/scratch/gate-acceptance/criteria.md (clause table, run sequence S0-S9, negatives, kill-and-recover).
5
5
  //
6
6
  // node gate-acceptance.mjs --fixture <dir> [--host mac|dell] [--steps S0,S1,...] [--out <dir>] [--plan] [--gate <path>] [--commit <sha>] [--allow-install]
@@ -26,8 +26,7 @@ import os from "node:os";
26
26
  import path from "node:path";
27
27
  import { fileURLToPath } from "node:url";
28
28
  import { keyPath, repoKey } from "./snapshot.mjs";
29
- import { ownershipFile, runningBrokerProcess } from "./build-ownership.mjs";
30
- import { RUNTIME_MANIFEST_FILE } from "./broker-handshake.mjs";
29
+ import { RUNTIME_MANIFEST_FILE } from "./seam-broker.mjs";
31
30
  import { resolveBrokerClient } from "./broker-client.mjs";
32
31
  import { managedRuntimeClient } from "./managed-roots.mjs";
33
32
 
@@ -36,7 +35,6 @@ export const COVERAGE_SCHEMA = "rightkit.gate-coverage/1";
36
35
  export const RECEIPT_SCHEMA = "rightkit.gate-receipt/1";
37
36
  export const SOURCE_IDENTITY_SCHEMA = "rightkit.source-identity.v1";
38
37
  export const RENDER_RECEIPT_SCHEMA = "rightkit.render-views/1";
39
- export const OWNERSHIP_SCHEMA = "rightkit.build-ownership/1";
40
38
 
41
39
  const here = path.dirname(fileURLToPath(import.meta.url));
42
40
  const sha256 = (data) => createHash("sha256").update(data).digest("hex");
@@ -201,13 +199,13 @@ export function coveragePaths(text) {
201
199
  return [...String(text).matchAll(/coverage report (.+?): \d+ planned scan/g)].map((m) => m[1]);
202
200
  }
203
201
 
204
- /** The reclaim line of a gate: "build ownership held <handle> (reclaimed from <from>: <proofs>)". null when the run reclaimed nothing. */
202
+ /** The reclaim line of a gate: "snapshot lock held <token> (reclaimed from <owner>: <proof>)". null when the run reclaimed nothing. */
205
203
  export function reclaimLine(text) {
206
- const m = /build ownership (held|joined) (\S+) \(reclaimed from (.+?): (.*)\)\s*$/m.exec(String(text));
207
- return m ? { mode: m[1], handle: m[2], from: m[3].trim(), proofs: m[4] } : null;
204
+ const m = /snapshot lock held (\S+) \(reclaimed from (.+?): (.*)\)\s*$/m.exec(String(text));
205
+ return m ? { token: m[1], from: m[2].trim(), proof: m[3] } : null;
208
206
  }
209
207
 
210
- const STAGE_FIELDS = ["ok", "at", "ruleTier", "direct", "qualifyOwed", "outputs", "snapshot", "ownership", "platform", "sealed", "manifestSha256", "voided", "track", "qaReceiptDigest", "tier"];
208
+ const STAGE_FIELDS = ["ok", "at", "ruleTier", "direct", "qualifyOwed", "outputs", "snapshot", "snapshotLock", "platform", "sealed", "manifestSha256", "voided", "track", "qaReceiptDigest", "tier"];
211
209
  const BINDING_FIELDS = ["tree", "locks", "gate", "toolchain", "executor"];
212
210
 
213
211
  /**
@@ -504,22 +502,21 @@ export function exitedBySignal({ signal, exit, killSignal, platform = process.pl
504
502
  }
505
503
 
506
504
  /**
507
- * Kill-and-recover (K01, SIGKILL; also the SIGINT variant): `before` is the owner record read right after the kill (or null when none), `dry` the
508
- * ownership-recover.mjs dry-run `{ exit, text }`, `next` the following gate run `{ exit, text }`, `after` the owner record read after it (null: removed).
509
- * Pass when the next run starts without any operator step and either reclaims (log names the reclaim, handle replaced) or finds nothing held
510
- * (SIGINT released it). A record that survives a SIGKILL must be explained by the dry run and reclaimed by the next run.
505
+ * Kill-and-recover (K01, SIGKILL; also the SIGINT variant): `before` is the snapshot lock read right after the kill (or null when none), `next` the following gate
506
+ * run `{ exit, text }`, `after` the lock read after it (null: released). Pass when the next run starts without any operator step and either reclaims the dead owner's
507
+ * lock on the stale-owner rule (the log names the reclaim, the token is replaced) or finds nothing held (SIGINT released it). A lock that survives a SIGKILL stays
508
+ * until the next run: its body names the dead owner (`pid`, `token`), and nothing but that run's reclaim removes it.
511
509
  */
512
- export function assertRecovery({ signal, before, dry, next, after, exitedBySignal = true }) {
510
+ export function assertRecovery({ signal, before, next, after, exitedBySignal = true }) {
513
511
  const problems = [];
514
512
  if (!exitedBySignal) problems.push(`the gate was not stopped by ${signal}`);
515
- if (signal === "SIGKILL" && !before) problems.push("no owner record stood after SIGKILL: the gate released nothing, so it must have been killed before acquiring; the case proved nothing");
513
+ if (signal === "SIGKILL" && !before) problems.push("no snapshot lock stood after SIGKILL: the gate released nothing, so it must have been killed before taking it; the case proved nothing");
516
514
  if (before) {
517
- if (!isObject(before) || typeof before.handle !== "string" || !Number.isInteger(before.pid)) problems.push("the owner record is malformed (no handle or pid)");
518
- if (dry?.exit !== 0 || !/recover: recoverable:/.test(dry?.text ?? "")) problems.push(`ownership-recover.mjs dry run did not explain a recoverable record (exit ${dry?.exit}): ${(dry?.text ?? "").split("\n").filter((l) => /recover:/.test(l)).slice(-2).join(" | ").slice(0, 240)}`);
515
+ if (!isObject(before) || typeof before.token !== "string" || !Number.isInteger(before.pid)) problems.push("the snapshot lock is malformed (no token or pid)");
519
516
  const claim = reclaimLine(next?.text ?? "");
520
517
  if (!claim) problems.push("the next run's log has no 'reclaimed from' line");
521
- else if (isObject(before) && claim.handle === before.handle) problems.push("the next run holds the dead owner's own handle: the record was not replaced");
522
- if (isObject(before) && isObject(after) && after.handle === before.handle) problems.push("the owner record still carries the dead handle after the next run");
518
+ else if (isObject(before) && claim.token === before.token) problems.push("the next run holds the dead owner's own token: the lock was not replaced");
519
+ if (isObject(before) && isObject(after) && after.token === before.token) problems.push("the snapshot lock still carries the dead token after the next run");
523
520
  }
524
521
  if (next?.exit !== 0) problems.push(`the next run exited ${next?.exit}`);
525
522
  return { ok: problems.length === 0, problems };
@@ -625,7 +622,7 @@ export const NN = Object.freeze([
625
622
  { id: "NN10", steps: ["S2"], title: "Inside a snapshot the resident gate answers cargo metadata", evidence: "spawn ledger of the warm runs" },
626
623
  { id: "NN11", steps: ["S1", "S2"], title: "A warm run proves the snapshot from the resident index, without re-hashing it", evidence: "gate log (`snapshot proof:` line)" },
627
624
  { id: "NN12", steps: ["S2"], title: "Installed dependencies are identified by pnpm's install record and reused", evidence: "gate log (reuse-match=hit), spawn ledger, env digest" },
628
- { id: "NN13", steps: ["S1", "S2", "S3", "S4", "S10"], title: "Class A takes no build-ownership lease", evidence: "gate log of every --to check" },
625
+ { id: "NN13", steps: ["S1", "S2", "S3", "S4", "S10"], title: "Class A takes no exclusion of its own: one snapshot lock, no build-ownership lease", evidence: "gate log of every --to check" },
629
626
  { id: "NN14", steps: ["S2"], title: "Preflight and app rules run once per tree", evidence: "gate log of the warm runs" },
630
627
  { id: "NN15", steps: ["S2"], title: "Advice scans are cached per lock set and UTC day or hour", evidence: "warm coverage" },
631
628
  { id: "NN16", steps: ["S10"], title: "A unit list shares one Class A and runs no per-unit format check", evidence: "--units-file log, spawn ledger" },
@@ -641,14 +638,14 @@ export const NN_EXT = Object.freeze([
641
638
  { id: "NN22", steps: ["S2"], title: "A warm snapshot sync writes and removes nothing", evidence: "sync lines and spawn ledger of the warm runs" },
642
639
  { id: "NN23", steps: ["S13"], title: "A gate upgrade that changes no key-relevant code keeps every hit", evidence: "coverage of the previous and the newest sealed gate" },
643
640
  { id: "NN24", steps: ["S14"], title: "The cache survives the resident gate's restart and idle exit", evidence: "coverage of a run after the resident gate was killed" },
644
- { id: "NN25", steps: ["S2"], title: "A warm run starts no git-after-proof, version probe, pnpm, ownership probe or real cargo", evidence: "spawn ledger of the warm runs" },
641
+ { id: "NN25", steps: ["S2"], title: "A warm run starts no git-after-proof, version probe, pnpm, process probe or real cargo", evidence: "spawn ledger of the warm runs" },
645
642
  { id: "NN26", steps: ["S2"], title: "The gate asks the resident gate over its socket, in process", evidence: "spawn ledger" },
646
643
  { id: "NN27", steps: ["S1"], title: "Never two compiler passes over one crate, target and feature set", evidence: "S1 compile coverage" },
647
644
  { id: "NN28", steps: ["S2"], title: "Change detection comes from RightKit's file index and watcher", evidence: "gate log (change-source), spawn ledger" },
648
645
  { id: "NN29", steps: ["S16"], title: "Per-run identities never enter a key or a reuse record", evidence: "coverage keys of a run with different identities" },
649
- { id: "NN30", steps: ["S0"], always: true, title: "Both hosts pass", evidence: "the other host's contract-test receipt" },
646
+ { id: "NN30", steps: ["S0"], always: true, title: "The releasing host passes (per host)", evidence: "this host's own run; another host's receipt is never required" },
650
647
  { id: "NN31", steps: ["S0"], always: true, title: "No gate is released or installed as trusted without a passing contract test", evidence: "release and install tooling calls --verify-release" },
651
- { id: "NN32", steps: ["S8"], title: "A killed run's ownership recovers by itself on both hosts", evidence: "S8 kill cases" },
648
+ { id: "NN32", steps: ["S8"], title: "A killed run's snapshot lock is reclaimed by the next run on both hosts", evidence: "S8 kill cases" },
652
649
  { id: "NN33", steps: ["S0"], always: true, title: "The contract and the test match", evidence: "docs/GATE-CONTRACT.md NN table" },
653
650
  { id: "NN34", steps: ["S0"], always: true, post: true, title: "Missing evidence fails; a partial run never passes", evidence: "the finished result" },
654
651
  { id: "NN35", steps: ["S0"], always: true, post: true, title: "The verdict shows coverage, and a release needs all of it", evidence: "the finished result, receipt" },
@@ -690,9 +687,9 @@ export const NEGATIVES_UNCHECKED = Object.freeze({
690
687
  N25: NEEDS_FIXTURE, N28: NEEDS_FIXTURE, N29: NEEDS_FIXTURE, N30: NEEDS_FIXTURE, N31: NEEDS_FIXTURE, N33: NEEDS_FIXTURE, N34: NEEDS_FIXTURE, N35: NEEDS_FIXTURE, N36: NEEDS_FIXTURE, N37: NEEDS_FIXTURE,
691
688
  });
692
689
  export const KILLS = Object.freeze([
693
- { id: "K01", signal: "SIGKILL", at: "owner record exists (build ownership held) plus --kill-after-ms, during --to compile", clauses: ["GC-T06"] },
690
+ { id: "K01", signal: "SIGKILL", at: "snapshot lock exists (held) plus --kill-after-ms, during --to compile", clauses: ["GC-T06"] },
694
691
  { id: "K01-int", signal: "SIGINT", at: "same point as K01", clauses: ["GC-T06"] },
695
- { id: "K02", signal: "SIGKILL", at: "during --to check, after the owner record exists (ownership is held across Class A by design, build-ownership.mjs:3-4)", clauses: ["GC-A24"] },
692
+ { id: "K02", signal: "SIGKILL", at: "during --to check, after the snapshot lock exists (the lock is held across Class A by design, reset plan section 3)", clauses: ["GC-A24"] },
696
693
  { id: "K02-int", signal: "SIGINT", at: "same point as K02", clauses: ["GC-A24"] },
697
694
  ]);
698
695
  export const KILLS_UNCHECKED = Object.freeze({
@@ -708,7 +705,7 @@ export const STEPS = Object.freeze([
708
705
  { id: "S5", nn: nnForStep("S5"), title: "lock edit", runs: [], clauses: ["GC-A19", "GC-A24"], note: "unchecked by design: a lock edit needs the fixture's own resolver; not generated by this runner", byDesignUnchecked: true },
709
706
  { id: "S6", nn: nnForStep("S6"), title: "dirty checkout", runs: ["--to compile"], clauses: ["GC-A02", "GC-A04", "GC-T06"], note: "refuses a dirty fixture; ephemeral commit (a compile not yet recorded) built while the checkout has a dirty tracked edit, an untracked file and a pushed stash; the snapshot is compared with the commit; the checkout and the stash list are restored exactly" },
710
707
  { id: "S7", nn: nnForStep("S7"), title: "negatives", runs: NEGATIVES.map((n) => n.id), clauses: ["GC-T05", "GC-A01", "GC-T14", "GC-A15", "GC-1A-R2", "GC-1A-R4"], note: "ephemeral commits under refs/witness/*; the rest listed unchecked with their reason" },
711
- { id: "S8", nn: nnForStep("S8"), title: "kill and recover", runs: KILLS.map((k) => k.id), clauses: ["GC-T06", "GC-A24"], note: "SIGKILL (during compile and during Class A) and SIGINT; ownership-recover.mjs dry run must explain the record; the next run reclaims it and passes" },
708
+ { id: "S8", nn: nnForStep("S8"), title: "kill and recover", runs: KILLS.map((k) => k.id), clauses: ["GC-T06", "GC-A24"], note: "SIGKILL (during compile and during Class A) and SIGINT; the lock stays after SIGKILL; the next run reclaims it on the stale-owner rule and passes" },
712
709
  { id: "S10", nn: nnForStep("S10"), title: "unit list (--units-file, two fixture units)", runs: ["--to check --units-file"], clauses: [], note: "NN16: the list shares one Class A and runs no cargo fmt -p; needs two units of the gate's unit grammar (crates/rightkit-<x>, packages/<x>) in the fixture, else NN16 fails naming the gap" },
713
710
  { id: "S11", nn: nnForStepAll("S11"), title: "cold run (the gate's cache dir moved aside under scratch, then restored)", runs: ["--to check", "--to compile"], clauses: [], note: "NN18 cold budgets; real-condition controls that NN01, NN02, NN03, NN04, NN14, NN15, NN20, NN21, NN24, NN29 fail on a run where every row really ran" },
714
711
  { id: "S12", nn: nnForStepAll("S12"), title: "compile-side edits: one crate, one lockfile, one manifest", runs: ["--to compile (crate edit)", "--to check (lock edit)", "--to compile (manifest edit)"], clauses: [], note: "ephemeral commits under refs/witness/*; NN20, NN21, NN04 on --to compile" },
@@ -762,6 +759,35 @@ const needRun = (ctx, label) => ctx.runs[label] ?? null;
762
759
  const expectedFailure = (r) => Boolean(r.negative) || r.refusal !== undefined;
763
760
  const firstRows = (ctx, ...labels) => { for (const l of labels) if (ctx.runs[l]?.rows) return ctx.runs[l]; return null; };
764
761
 
762
+ /**
763
+ * The running broker's `{ pid, startedMs }` for GC-I15 (S0 and S9 compare it), or null when it cannot be established (fail safe). Mac: exactly one of the two launchd
764
+ * entries the broker alternates between at a cutover (`dev.rustright.broker`, `dev.rustright.broker.b`) is running. Windows: exactly one `rustright-broker` process.
765
+ * Linux has no broker. `run` and `uid` are test seams.
766
+ */
767
+ export function runningBrokerProcess({ platform = process.platform, run = spawnSync, uid = process.getuid?.() } = {}) {
768
+ if (platform === "win32") {
769
+ try {
770
+ const script = "$p = @(Get-Process -Name rustright-broker -ErrorAction SilentlyContinue); if ($p.Count -eq 1) { \"$($p[0].Id) $($p[0].StartTime.ToUniversalTime().ToString('o'))\" }";
771
+ const r = run("powershell.exe", ["-NoLogo", "-NoProfile", "-NonInteractive", "-EncodedCommand", Buffer.from(script, "utf16le").toString("base64")], { encoding: "utf8", timeout: 15000, windowsHide: true });
772
+ const m = /^(\d+) (\S+)\s*$/m.exec(String(r.stdout ?? ""));
773
+ if (!m) return null;
774
+ const pid = Number(m[1]); const startedMs = Date.parse(m[2]);
775
+ return Number.isInteger(pid) && pid > 0 && Number.isFinite(startedMs) ? { pid, startedMs } : null;
776
+ } catch { return null; }
777
+ }
778
+ if (platform !== "darwin") return null;
779
+ try {
780
+ const pids = ["dev.rustright.broker", "dev.rustright.broker.b"]
781
+ .map((label) => Number(/^\s*pid = (\d+)$/m.exec(String(run("launchctl", ["print", `gui/${uid}/${label}`], { encoding: "utf8", timeout: 5000 }).stdout ?? ""))?.[1]))
782
+ .filter((pid) => Number.isInteger(pid) && pid > 0);
783
+ if (pids.length !== 1) return null;
784
+ const pid = pids[0];
785
+ const ps = run("ps", ["-o", "lstart=", "-p", String(pid)], { encoding: "utf8", timeout: 5000, env: { ...process.env, LC_ALL: "C", LANG: "C" } });
786
+ const startedMs = Date.parse(String(ps.stdout ?? "").trim());
787
+ return Number.isFinite(startedMs) ? { pid, startedMs } : null;
788
+ } catch { return null; }
789
+ }
790
+
765
791
  /** GC-I15: the broker process (pid and start) is the same at S0 and S9; the gate launched none. */
766
792
  export function brokerUnchanged(a, b) {
767
793
  if (!a || !b) return { ok: false, problems: ["the broker process was not established at S0 or at S9"] };
@@ -926,10 +952,18 @@ export function assertDigestStable(a, b) {
926
952
  return da.env === db.env ? { ok: true, problems: [] } : { ok: false, problems: [`the dependency digest differs between identical runs: ${da.env.slice(0, 12)} vs ${db.env.slice(0, 12)}`] };
927
953
  }
928
954
 
929
- /** NN13: a `--to check` log never reports build ownership held or joined. */
930
- export function assertNoOwnershipOnCheck(log) {
931
- const lines = String(log).split(/\r?\n/).filter((l) => /build ownership (held|joined) /.test(l));
932
- return lines.length === 0 ? { ok: true, problems: [] } : { ok: false, problems: [`--to check took the build-ownership lease: ${lines[0].replace(/^\S+ /, "").slice(0, 120)}`] };
955
+ /**
956
+ * NN13: a `--to check` log takes exactly one exclusion, the snapshot lock (one `snapshot lock held` line, the door's), and never reports the retired build ownership
957
+ * (`build ownership held|joined`); a nested check joins the door's lock silently and takes none of its own.
958
+ */
959
+ export function assertOneExclusionOnCheck(log) {
960
+ const lines = String(log).split(/\r?\n/);
961
+ const retired = lines.filter((l) => /build ownership (held|joined) /.test(l));
962
+ const locks = lines.filter((l) => /snapshot lock held /.test(l));
963
+ const problems = [];
964
+ if (retired.length) problems.push(`--to check took a build-ownership lease, which the gate no longer has: ${retired[0].replace(/^\S+ /, "").slice(0, 120)}`);
965
+ if (locks.length !== 1) problems.push(`--to check took ${locks.length} snapshot lock(s), expected exactly the door's one${locks[1] ? `: ${locks[1].replace(/^\S+ /, "").slice(0, 100)}` : ""}`);
966
+ return problems.length === 0 ? { ok: true, problems: [] } : { ok: false, problems };
933
967
  }
934
968
 
935
969
  /** NN14: a warm run reports the app rules cached, and any preflight line it prints says cached too. */
@@ -1088,11 +1122,11 @@ export function assertOtherWorkspacesIdle(next, { workspace, workspaces = [], cr
1088
1122
  const stampOf = (line) => { const m = /^(\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.\d+)?Z) /.exec(line); return m ? Date.parse(m[1]) : null; };
1089
1123
  /**
1090
1124
  * Stage durations from the stamped log. The line pairs (also written into ci/gate-acceptance-budgets.json):
1091
- * ownership run start (the runner's launch time) -> first `build ownership held|joined` line; 0 when the run takes no lease (a `--to check`, NN13)
1092
- * snapshotSync ownership line (else run start) -> `snapshot <dir> is commit <sha> tree <sha> (written=...` line
1125
+ * ownership (the key keeps its budget name) run start (the runner's launch time) -> first `snapshot lock held` line; 0 when the run takes no lock
1126
+ * snapshotSync lock line (else run start) -> `snapshot <dir> is commit <sha> tree <sha> (written=...` line
1093
1127
  * planning `rightkit-gate: --to <stage> for <sha12>: ...` line -> `<n> scan(s) for <m> changed file(s) vs <sha12>; class A scans <j> at a time` line
1094
1128
  * dependencyStep that plan line -> the first `snapshot dependencies root=` line (a compile prints a second one later, after Class A)
1095
- * A named line that is missing is a problem (the stage cannot be timed), except the ownership line, whose absence is the stage being 0.
1129
+ * A named line that is missing is a problem (the stage cannot be timed), except the lock line, whose absence is the stage being 0.
1096
1130
  */
1097
1131
  export function stageMarks(log, startedMs) {
1098
1132
  const lines = String(log).split(/\r?\n/);
@@ -1100,7 +1134,7 @@ export function stageMarks(log, startedMs) {
1100
1134
  const last = (re) => [...lines].reverse().find((l) => re.test(l));
1101
1135
  const problems = [];
1102
1136
  const t = (line, what) => { const ms = line ? stampOf(line) : null; if (ms === null) problems.push(`no stamped \`${what}\` line`); return ms; };
1103
- const own = first(/build ownership (held|joined) /);
1137
+ const own = first(/snapshot lock held /);
1104
1138
  const ownT = own ? stampOf(own) : null;
1105
1139
  const sync = t(first(/snapshot \S+ is commit [0-9a-f]{40} tree [0-9a-f]{40} \(written=/), "snapshot ... is commit ... (written=");
1106
1140
  const stageStart = t(first(/rightkit-gate: --to \w+ for [0-9a-f]{12}/), "--to <stage> for <sha>");
@@ -1240,12 +1274,12 @@ const fileSha = (f) => { try { return sha256(fs.readFileSync(f)); } catch { retu
1240
1274
  // ---- NN25 / NN07 allowlists: EMPTY by decision. An entry needs Adrian's approval (GC-A27 NN25: "a probe that must run names its reason in the runner's
1241
1275
  // allowlist, which Adrian approves"; NN07 likewise). Do not add one without his approval by name in the commit message.
1242
1276
  export const NN25_ALLOWLIST = Object.freeze([]);
1243
- const OWNERSHIP_PROBES = new Set(["ps", "lsof", "launchctl", "sysctl"]);
1277
+ const PROCESS_PROBES = new Set(["ps", "lsof", "launchctl", "sysctl"]);
1244
1278
  const VERSION_ARG = /^(--version|-V|-v|version)$/;
1245
1279
  const TREE_WALKERS = new Set(["find", "rsync", "du"]);
1246
1280
  const GIT_TREE_VERBS = new Set(["ls-files", "ls-tree", "archive", "status", "diff", "diff-files", "diff-index", "update-index"]);
1247
1281
 
1248
- /** NN25: no child of the forbidden families on a warm run (git after the resident proof, version probes, pnpm, ownership probes, real cargo). */
1282
+ /** NN25: no child of the forbidden families on a warm run (git after the resident proof, version probes, pnpm, process probes, real cargo). */
1249
1283
  export function assertWarmNoFamilies(entries, { log = "", allow = NN25_ALLOWLIST } = {}) {
1250
1284
  const problems = [];
1251
1285
  const proofLine = String(log).split(/\r?\n/).find((l) => /snapshot proof:|resident proof|\(verified before/.test(l));
@@ -1261,7 +1295,7 @@ export function assertWarmNoFamilies(entries, { log = "", allow = NN25_ALLOWLIST
1261
1295
  if (n.args.length <= 2 && n.args.some((a) => VERSION_ARG.test(a))) fam = "tool version probe";
1262
1296
  else if (n.program === "git" && (proofAt === null || at >= proofAt)) fam = proofAt === null ? "git (the log carries no resident-proof time, so every git start counts)" : "git after the resident proof";
1263
1297
  else if (n.program === "pnpm") fam = "pnpm";
1264
- else if (OWNERSHIP_PROBES.has(n.program)) fam = `ownership probe (${n.program})`;
1298
+ else if (PROCESS_PROBES.has(n.program)) fam = `process probe (${n.program})`;
1265
1299
  else if (call && call.via !== "rustright") fam = "real cargo";
1266
1300
  if (fam) { const k = `${fam}\u0000${n.program} ${shortArgs(n.args)}`; found.set(k, (found.get(k) ?? 0) + 1); }
1267
1301
  }
@@ -1458,10 +1492,10 @@ export function assertLedgerAgreesWithProof(log, entries) {
1458
1492
  if (walks === 0 && seen > 0) problems.push(`the log says verify-walks=0 and the ledger shows ${seen} tree-walking start(s)`);
1459
1493
  return { ok: problems.length === 0, problems };
1460
1494
  }
1461
- /** NN13 (probe half): a `--to check` run starts no ownership probe. */
1462
- export function assertNoOwnershipProbe(entries) {
1495
+ /** NN13 (probe half): a `--to check` run starts no process probe (ps, lsof, launchctl, sysctl). */
1496
+ export function assertNoProcessProbe(entries) {
1463
1497
  const problems = [];
1464
- for (const n of entries.map(normalizeSpawn)) if (OWNERSHIP_PROBES.has(n.program)) problems.push(`--to check started an ownership probe: ${n.program} ${shortArgs(n.args)}`);
1498
+ for (const n of entries.map(normalizeSpawn)) if (PROCESS_PROBES.has(n.program)) problems.push(`--to check started a process probe: ${n.program} ${shortArgs(n.args)}`);
1465
1499
  return { ok: problems.length === 0, problems };
1466
1500
  }
1467
1501
 
@@ -1471,7 +1505,7 @@ export const WORKLOADS = Object.freeze(["fixture", "rightkit", "heardright", "pu
1471
1505
  export const PROFILES = Object.freeze(["warm-check", "warm-compile", "edited-check", "edited-compile", "cold-check", "cold-compile"]);
1472
1506
  /**
1473
1507
  * Consecutive windows that tile the run from the runner's launch to the gate's exit, each named by the log line that closes it:
1474
- * startup (launch -> first stamped line), ownership (-> `build ownership held|joined`; 0 when the run takes no lease), snapshotSync (-> the sync line),
1508
+ * startup (launch -> first stamped line), ownership (-> `snapshot lock held`; 0 when the run takes no lock), snapshotSync (-> the sync line),
1475
1509
  * stageStart (-> `--to <stage> for <sha>`), snapshotVerify (-> `(verified before`), appRules (-> `app rules:`), planning (-> the plan line),
1476
1510
  * dependencyStep (-> `snapshot dependencies root=`), scans (-> the last `[n/N]` result line) and finish (-> exit). Optional markers that are absent
1477
1511
  * fold into the next window; a required marker that is absent or stamped out of order makes the run untimeable.
@@ -1484,7 +1518,7 @@ export function windowMarks(log, startedMs, endMs) {
1484
1518
  const firstLine = lines.map(stampOf).find((t) => t !== null);
1485
1519
  const seq = [
1486
1520
  ["startup", firstLine, true],
1487
- ["ownership", stamp(/build ownership (held|joined) /, "build ownership", false), false],
1521
+ ["ownership", stamp(/snapshot lock held /, "snapshot lock", false), false],
1488
1522
  ["snapshotSync", stamp(/snapshot \S+ is commit [0-9a-f]{40} tree [0-9a-f]{40} \(written=/, "snapshot ... (written=", true), true],
1489
1523
  ["stageStart", stamp(/rightkit-gate: --to \w+ for [0-9a-f]{12}/, "--to <stage> for <sha>", true), true],
1490
1524
  ["snapshotVerify", stamp(/snapshot \S+ is commit [0-9a-f]{40} tree [0-9a-f]{40} \(verified/, "snapshot ... (verified", false), false],
@@ -1507,7 +1541,7 @@ export function windowMarks(log, startedMs, endMs) {
1507
1541
  export const budgetKeyOf = (label) => (/^S2:/.test(label) ? "warm" : /^S11:/.test(label) ? "cold" : "edited");
1508
1542
  /**
1509
1543
  * NN18 over the windows: `runs` is `[{ label, workload, profile, ms, windows, rows }]`. A missing or null budget fails ("no budget measured"); an
1510
- * ownership window is budgeted on compile profiles only (a lease on a check is NN13's failure and must be 0 here). A cargo-metadata row that hit must
1544
+ * snapshot-lock window is budgeted on compile profiles only (a check's lock is counted by NN13, and its time is inside the total). A cargo-metadata row that hit must
1511
1545
  * report `scanElapsedMs` within `metadataHitMs`.
1512
1546
  */
1513
1547
  export function assertWindowBudgets({ host, budgets, runs }) {
@@ -1522,7 +1556,7 @@ export function assertWindowBudgets({ host, budgets, runs }) {
1522
1556
  const unbudgeted = [];
1523
1557
  for (const w of WINDOWS) {
1524
1558
  const v = r.windows?.[w];
1525
- if (w === "ownership" && r.profile.endsWith("-check")) { if (v !== 0 && v !== null && v !== undefined) problems.push(`${where}: a check took ${v} ms of build-ownership time`); continue; }
1559
+ if (w === "ownership" && r.profile.endsWith("-check")) continue; // a check takes the door's one snapshot lock like a compile; NN13 judges that count, and the sync and total budgets bound its time
1526
1560
  if (v === null || v === undefined) { problems.push(`${where}: window ${w} could not be timed`); continue; }
1527
1561
  const b = prof.windows?.[w];
1528
1562
  if (b === null || b === undefined) unbudgeted.push(w); else if (v > b) problems.push(`${where}: window ${w} took ${v} ms, budget ${b} ms`);
@@ -1537,7 +1571,9 @@ export function assertWindowBudgets({ host, budgets, runs }) {
1537
1571
  return { ok: problems.length === 0, problems };
1538
1572
  }
1539
1573
  /** The required (workload, profile) cells of a full run: the fixture warm/edited/cold, RightKit and HeardRight warm check, the Pulse compile. */
1540
- export const REQUIRED_CELLS = Object.freeze([["fixture", "warm-check"], ["fixture", "warm-compile"], ["fixture", "edited-check"], ["fixture", "edited-compile"], ["fixture", "cold-check"], ["fixture", "cold-compile"], ["rightkit", "warm-check"], ["heardright", "warm-check"], ["pulse", "cold-compile"]]);
1574
+ // The fixture's cold cells are not measured here: a cold run stops for Adrian's approval and the test proves that stop (Adrian 2026-11-07: "Test checks
1575
+ // the stop"); cold budgets are measured from cold runs he approves.
1576
+ export const REQUIRED_CELLS = Object.freeze([["fixture", "warm-check"], ["fixture", "warm-compile"], ["fixture", "edited-check"], ["fixture", "edited-compile"], ["rightkit", "warm-check"], ["heardright", "warm-check"], ["pulse", "cold-compile"]]);
1541
1577
 
1542
1578
  // ---- NN19 / NN30 / NN31: the receipt ---------------------------------------------------------------------------------------------------------------
1543
1579
  export const CONTRACT_RECEIPT_SCHEMA = "rightkit.contract-test-receipt/1";
@@ -1545,12 +1581,13 @@ export function buildContractReceipt({ host, commit, gate, contractSha256, runne
1545
1581
  return { schema: CONTRACT_RECEIPT_SCHEMA, host, commit, gate, contractSha256, runnerSha256, budgetsSha256, fixtureCommit, startedAt: result.startedAt, endedAt: result.endedAt, verdict: result.verdict, ok: result.ok, nn: Object.fromEntries(result.nonNegotiables.map((n) => [n.id, n.status])), uncheckedClauses: result.clauses.filter((c) => c.status === "unchecked").map((c) => c.id), waivers: result.waivers ?? [] };
1546
1582
  }
1547
1583
  export const validWaiver = (w) => isObject(w) && typeof w.clause === "string" && /^GC-/.test(w.clause) && w.by === "Adrian" && typeof w.words === "string" && w.words.trim().length > 0;
1548
- /** `--verify-release`: both receipts pass, for one gate commit and one sealed gate, with the contract and runner they were judged by. */
1549
- export function verifyReleaseReceipts(a, b, { commit = null, contractSha256 = null, runnerSha256 = null, waivers = [] } = {}) {
1584
+ /** `--verify-release`: the receipt of the host that releases or installs passes, for the gate commit and sealed gate, with the contract and runner it was
1585
+ * judged by. Per host (Adrian 2026-11-07: "why would both machines be tied to each other in such a way for anything?"): one host's receipt never
1586
+ * stands for or blocks the other. `b` is optional; when given, each receipt is judged on its own. */
1587
+ export function verifyReleaseReceipts(a, b = null, { commit = null, contractSha256 = null, runnerSha256 = null, waivers = [], host = null } = {}) {
1550
1588
  const problems = [];
1551
- const hosts = [a?.host, b?.host].sort().join("+");
1552
- if (hosts !== "dell+mac") problems.push(`the two receipts are from ${hosts || "no host"}, expected one from the mac and one from the dell`);
1553
- for (const [name, r] of [["first", a], ["second", b]]) {
1589
+ if (host && a?.host !== host) problems.push(`the receipt is from ${a?.host ?? "no host"}, this host is ${host}`);
1590
+ for (const [name, r] of (b ? [["first", a], ["second", b]] : [["the", a]])) {
1554
1591
  const w = `${name} receipt (${r?.host})`;
1555
1592
  if (!isObject(r) || r.schema !== CONTRACT_RECEIPT_SCHEMA) { problems.push(`${w}: not a ${CONTRACT_RECEIPT_SCHEMA}`); continue; }
1556
1593
  if (r.ok !== true || !/^PASS /.test(String(r.verdict))) problems.push(`${w}: verdict ${JSON.stringify(r.verdict)} is not a PASS`);
@@ -1561,12 +1598,10 @@ export function verifyReleaseReceipts(a, b, { commit = null, contractSha256 = nu
1561
1598
  const open = (r.uncheckedClauses ?? []).filter((id) => !waivers.some((x) => validWaiver(x) && x.clause === id));
1562
1599
  if (open.length) problems.push(`${w}: ${open.length} operative clause(s) unchecked and not waived by Adrian by name (${open.slice(0, 8).join(", ")}${open.length > 8 ? ", ..." : ""})`);
1563
1600
  }
1564
- if (isObject(a) && isObject(b)) {
1565
- for (const k of ["commit", "contractSha256", "runnerSha256", "fixtureCommit"]) if (a[k] !== b[k]) problems.push(`the receipts differ in ${k}: ${a[k]} vs ${b[k]}`);
1566
- if (a.gate?.sealedSha256 !== b.gate?.sealedSha256) problems.push("the receipts name different sealed gates");
1567
- if (commit && a.commit !== commit) problems.push(`the receipts are for commit ${a.commit}, the release is ${commit}`);
1568
- if (contractSha256 && a.contractSha256 !== contractSha256) problems.push("the contract changed after the receipts were written");
1569
- if (runnerSha256 && a.runnerSha256 !== runnerSha256) problems.push("the runner changed after the receipts were written");
1601
+ for (const r of (b ? [a, b] : [a]).filter(isObject)) {
1602
+ if (commit && r.commit !== commit) problems.push(`the ${r.host} receipt is for commit ${r.commit}, the release is ${commit}`);
1603
+ if (contractSha256 && r.contractSha256 !== contractSha256) problems.push(`the contract changed after the ${r.host} receipt was written`);
1604
+ if (runnerSha256 && r.runnerSha256 !== runnerSha256) problems.push(`the runner changed after the ${r.host} receipt was written`);
1570
1605
  }
1571
1606
  return { ok: problems.length === 0, problems };
1572
1607
  }
@@ -1732,7 +1767,37 @@ export function assertCrossTargetsOneCommand(log, entries, rows, { label = "" }
1732
1767
  * NN41: run 1 and run 2 are the same commit; every row that really failed in run 1 must be a cache hit that still says fail in run 2. Run 3 changes the
1733
1768
  * toolchain identity; every such row must run again (a cached failure is never reused after the identity changed, an environment fix must rerun it).
1734
1769
  */
1735
- export function assertCachedFailure(first, second, third, { identity = "" } = {}) {
1770
+ /** The miss report a gate run names when it stops on RK_CACHE_MISS (its log line "report <file> (digest ...)"), parsed; null when none. */
1771
+ export function missReportOf(log, read = (f) => JSON.parse(fs.readFileSync(f, "utf8"))) {
1772
+ const m = /cache lookup: [^\n]*?report (\S+\.json) \(digest [0-9a-f]{64}\)/.exec(String(log ?? ""));
1773
+ if (!m) return null;
1774
+ try { return { file: m[1], ...read(m[1]) }; } catch (e) { return { file: m[1], error: e.message }; }
1775
+ }
1776
+ /**
1777
+ * Adrian 2026-11-07 ("Test checks the stop"): a cold run (S11) and a run after a toolchain change (S17's third run) must stop on RK_CACHE_MISS before
1778
+ * anything runs, every miss with the expected cause, and the rows named in `ids` must be in the report (a failure reused across a toolchain change would
1779
+ * be a hit instead). `cause` is "new" (no stored result) or "changed" (inputs or environment changed).
1780
+ */
1781
+ export function assertMissStop(run, report, { cause, ids = [] } = {}) {
1782
+ const problems = []; const log = String(run?.log ?? "");
1783
+ if (!run) return { ok: false, problems: ["the run did not happen"] };
1784
+ if (run.exit === 0) problems.push("the run exited 0: it did not stop for Adrian's approval");
1785
+ if (!/BLOCKED: RK_CACHE_MISS/.test(log)) problems.push("the run did not stop on RK_CACHE_MISS");
1786
+ if (/\] (pass|fail) +\S+ \(\d+s\)/.test(log)) problems.push("rows ran before or despite the stop");
1787
+ if (!report) problems.push("no miss report is named in the run's output");
1788
+ else if (report.error) problems.push(`the miss report ${report.file} cannot be read (${report.error})`);
1789
+ else {
1790
+ const want = cause === "new" ? /^no stored result/ : /^inputs or environment changed/;
1791
+ const wrong = (report.rows ?? []).filter((r) => !want.test(String(r.cause)));
1792
+ if (cause === "new" && wrong.length) problems.push(`${wrong.length} miss(es) are not "no stored result" on a cold run (first: ${wrong[0].id}: ${wrong[0].cause})`);
1793
+ const named = new Set((report.rows ?? []).filter((r) => want.test(String(r.cause))).map((r) => r.id));
1794
+ for (const id of ids) if (!named.has(id)) problems.push(`${id}: not in the stop report with cause ${cause}: the gate would have reused it`);
1795
+ if (cause === "new" && (report.hit ?? 0) > 0) problems.push(`${report.hit} row(s) hit on a run whose cache was moved aside`);
1796
+ }
1797
+ return { ok: problems.length === 0, problems };
1798
+ }
1799
+
1800
+ export function assertCachedFailure(first, second, third, { identity = "", thirdStop = null } = {}) {
1736
1801
  const problems = [];
1737
1802
  const failed = first ? [...first.values()].filter((r) => r.class === "B" && r.coverage === "ran" && r.status === "fail") : [];
1738
1803
  if (failed.length === 0) problems.push("the failing commit's first run has no Class B row that ran and failed: the fixture did not fail deterministically, so no cached failure can be judged");
@@ -1743,7 +1808,8 @@ export function assertCachedFailure(first, second, third, { identity = "" } = {}
1743
1808
  else if (r.status !== "fail") problems.push(`${f.id}: a cached failure came back with status ${r.status}`);
1744
1809
  else if (f.key && r.key && f.key !== r.key) problems.push(`${f.id}: the key changed between two identical runs`);
1745
1810
  }
1746
- if (!third) problems.push(`no third run with a changed toolchain identity (${identity || "none chosen"}): the reuse after an identity change cannot be judged; the evidence needed is a second installed toolchain the gate keys on (RUSTUP_TOOLCHAIN)`);
1811
+ if (thirdStop) { if (!thirdStop.ok) problems.push(...thirdStop.problems.map((p) => `third run (${identity}): ${p}`)); }
1812
+ else if (!third) problems.push(`no third run with a changed toolchain identity (${identity || "none chosen"}): the reuse after an identity change cannot be judged; the evidence needed is a second installed toolchain the gate keys on (RUSTUP_TOOLCHAIN)`);
1747
1813
  else for (const f of failed) {
1748
1814
  const r = third.get(f.id);
1749
1815
  if (!r) problems.push(`${f.id}: absent from the run with a changed toolchain identity`);
@@ -1768,16 +1834,9 @@ const NN_EVAL_EXT = {
1768
1834
  NN27: (ctx) => { const out = []; for (const label of ["S1:compile", "S11:compile"].filter((l) => ctx.runs[l])) { const r = usableRun(ctx, label, RED); out.push(r.fail ?? checkFor(label, assertNoDoublePass(r.run.rows), r.run.coveragePaths)); } return out.length ? out : [bad("S1:compile", ["no compile run"])]; },
1769
1835
  NN28: (ctx) => warmRuns(ctx, RED).map((w) => { if (w.fail) return w.fail; const l = ledgerOf(w.run, w.label); return l.fail ?? checkFor(w.label, assertChangeSource(w.run.log, l.entries), [w.run.logPath, w.run.ledgerPath]); }),
1770
1836
  NN29: (ctx) => { const a = usableRun(ctx, "S2:check2", RED); const b = usableRun(ctx, "S16:ident", RED); if (a.fail || b.fail) return [a.fail ?? b.fail]; return [checkFor("S16:ident", assertIdentityIndependent(a.run.rows, b.run.rows), [...a.run.coveragePaths, ...b.run.coveragePaths])]; },
1771
- NN30: (ctx) => {
1772
- const other = ctx.otherReceipt;
1773
- if (!other) return [bad("other host", [`no passing receipt from the ${ctx.host === "mac" ? "dell" : "mac"} for this commit was given (--other-receipt <file>); a release needs both hosts`])];
1774
- if (other.error) return [bad("other host", [other.error])];
1775
- const own = { ...other }; const problems = [];
1776
- if (other.host === ctx.host) problems.push(`the other receipt is from this host (${ctx.host})`);
1777
- if (other.ok !== true) problems.push(`the ${other.host} receipt is not a pass (${other.verdict})`);
1778
- if (other.commit !== ctx.gateCommit) problems.push(`the ${other.host} receipt is for ${other.commit}, this run is for ${ctx.gateCommit}`);
1779
- return [{ label: `${other.host} receipt`, ok: problems.length === 0, problems, evidence: [ctx.otherReceiptPath ?? "--other-receipt"] , own }];
1780
- },
1837
+ // Per host (Adrian 2026-11-07: "why would both machines be tied to each other in such a way for anything?"): this run IS the host's evidence;
1838
+ // its verdict is the receipt --verify-release reads on this host. No other host's receipt is asked for.
1839
+ NN30: (ctx) => [{ label: `${ctx.host} (this run)`, ok: true, problems: [], evidence: ["this run's own receipt"] }],
1781
1840
  NN31: (ctx) => {
1782
1841
  const calling = ctx.tooling?.calling ?? [];
1783
1842
  if (calling.length) return [{ label: "tooling", ok: true, problems: [], evidence: calling }];
@@ -1820,7 +1879,11 @@ const NN_EVAL_EXT = {
1820
1879
  NN41: (ctx) => {
1821
1880
  const a = usableRun(ctx, "S17:fail1", RED); const b = usableRun(ctx, "S17:fail2", RED); if (a.fail || b.fail) return [a.fail ?? b.fail];
1822
1881
  const c = ctx.runs["S17:fail3"] ? usableRun(ctx, "S17:fail3", RED) : null; if (c?.fail) return [c.fail];
1823
- return [checkFor("S17", assertCachedFailure(a.run.rows, b.run.rows, c?.run.rows ?? null, { identity: ctx.identityChange ?? "" }), [...a.run.coveragePaths, ...b.run.coveragePaths, ...(c?.run.coveragePaths ?? [])])];
1882
+ // The third run stops for Adrian's approval (a toolchain change); its miss report must name every failing row (none reused).
1883
+ const stop = ctx.runs["S17:fail3-stop"];
1884
+ const failedIds = [...(a.run.rows?.values() ?? [])].filter((r) => r.class === "B" && r.coverage === "ran" && r.status === "fail").map((r) => r.id);
1885
+ const thirdStop = stop ? assertMissStop(stop, missReportOf(stop.log), { cause: "changed", ids: failedIds }) : null;
1886
+ return [checkFor("S17", assertCachedFailure(a.run.rows, b.run.rows, c?.run.rows ?? null, { identity: ctx.identityChange ?? "", thirdStop }), [...a.run.coveragePaths, ...b.run.coveragePaths, ...(c?.run.coveragePaths ?? [])])];
1824
1887
  },
1825
1888
  NN42: (ctx) => {
1826
1889
  const labels = Object.keys(ctx.runs).filter((l) => ctx.runs[l].stage === "compile" && ctx.runs[l].ladder && !ctx.runs[l].kill && /^(S1|S2|S11):compile\d?$/.test(l));
@@ -1921,10 +1984,10 @@ const NN_EVAL = {
1921
1984
  },
1922
1985
  NN13: (ctx) => {
1923
1986
  const out = Object.entries(ctx.runs).filter(([, r]) => r.stage === "check" && r.ledgerPath !== undefined && !r.kill).flatMap(([label, r]) => {
1924
- const a = checkFor(label, assertNoOwnershipOnCheck(r.log), [r.logPath]);
1987
+ const a = checkFor(label, assertOneExclusionOnCheck(r.log), [r.logPath]);
1925
1988
  if (!ctx.extended) return [a];
1926
1989
  const l = ledgerOf(r, label);
1927
- return [a, l.fail ?? checkFor(`${label} ledger`, assertNoOwnershipProbe(l.entries), [r.ledgerPath])];
1990
+ return [a, l.fail ?? checkFor(`${label} ledger`, assertNoProcessProbe(l.entries), [r.ledgerPath])];
1928
1991
  });
1929
1992
  return out;
1930
1993
  },
@@ -2123,9 +2186,9 @@ export const CHECKS = {
2123
2186
  },
2124
2187
  "GC-T06": (ctx) => {
2125
2188
  const out = [];
2126
- for (const [label, run] of Object.entries(ctx.runs)) if (run.recovery) out.push({ label, ...verdict(run.recovery, [run.logPath, run.ownerPath ?? "owner.json"]) });
2189
+ for (const [label, run] of Object.entries(ctx.runs)) if (run.recovery) out.push({ label, ...verdict(run.recovery, [run.logPath, run.lockPath ?? "snapshot.lock"]) });
2127
2190
  if (ctx.s6?.fresh && ctx.s6.proof) out.push({ label: "S6", ...verdict(ctx.s6.proof, ["S6: a dirty tree and an unpushed commit build the commit's bytes"]) });
2128
- if (ctx.s9) out.push({ ...verdict(ctx.s9.ownerClean, [ctx.s9.ownerPath]) });
2191
+ if (ctx.s9) out.push({ ...verdict(ctx.s9.lockClean, [ctx.s9.lockPath]) });
2129
2192
  return out.length ? out : unchecked("S6, S8 and S9 did not run");
2130
2193
  },
2131
2194
  "GC-A19": (ctx) => {
@@ -2477,7 +2540,7 @@ function runGate({ gate, cwd, args, env = process.env, timeoutMs = 3_600_000 })
2477
2540
  });
2478
2541
  }
2479
2542
 
2480
- /** Starts the gate, waits for `waitFor()` to return truthy (the owner record) plus `afterMs`, then signals its process group. */
2543
+ /** Starts the gate, waits for `waitFor()` to return truthy (the snapshot lock) plus `afterMs`, then signals its process group. */
2481
2544
  function killDuring({ gate, cwd, args, signal, waitFor, afterMs }) {
2482
2545
  return new Promise((resolve) => {
2483
2546
  let log = ""; let done = false; let child;
@@ -2491,14 +2554,14 @@ function killDuring({ gate, cwd, args, signal, waitFor, afterMs }) {
2491
2554
  if (armedAt === null && waitFor()) armedAt = Date.now();
2492
2555
  if (armedAt !== null && Date.now() - armedAt >= afterMs) { clearInterval(poll); signalGroup(child, signal); }
2493
2556
  }, 100);
2494
- const cap = setTimeout(() => { if (!done) signalGroup(child, "SIGKILL"); }, 30 * 60_000); // the owner record never appeared: the case proves nothing
2557
+ const cap = setTimeout(() => { if (!done) signalGroup(child, "SIGKILL"); }, 30 * 60_000); // the snapshot lock never appeared: the case proves nothing
2495
2558
  });
2496
2559
  }
2497
2560
 
2498
2561
  function readJson(file) { try { return { value: JSON.parse(fs.readFileSync(file, "utf8")) }; } catch (e) { return { error: `${file}: ${e.message}` }; } }
2499
2562
  const readOrNull = (file) => { try { return fs.readFileSync(file); } catch { return null; } };
2500
2563
 
2501
- /** The installed broker's runtime manifest and the gate's pins record. The client and its manifest are found the way the gate finds them (broker-handshake.mjs): `managedRuntimeClient`, the agent shim resolved, the manifest beside the real client. */
2564
+ /** The installed broker's runtime manifest and the gate's pins record. The client and its manifest are found the way the gate finds them (seam-broker.mjs brokerControlTarget): `managedRuntimeClient`, the agent shim resolved, the manifest beside the real client. */
2502
2565
  function brokerIdentity(host, managedRoot) {
2503
2566
  const platform = host === "dell" ? "win32" : "darwin";
2504
2567
  const pinsPath = path.join(managedRoot, "pins", `broker-${platform}.json`);
@@ -2656,9 +2719,10 @@ async function executeRun({ fixture, host, wanted, gate, gateArg, budgetsFile, o
2656
2719
  Object.assign(ctx, { wanted, host, budgets: budgetLoad.budgets, budgetProblem: budgetLoad.problem, cores: typeof os.availableParallelism === "function" ? os.availableParallelism() : os.cpus().length, jobsEnv: process.env.RK_GATE_JOBS });
2657
2720
 
2658
2721
  const key = repositoryKey(g.canonical, platform);
2659
- const ownerFile = ownershipFile({ platform, repository: key });
2660
- const readOwner = () => { try { return JSON.parse(fs.readFileSync(ownerFile, "utf8")); } catch { return null; } };
2661
2722
  const snapRoot = path.join(managedRoot, "snapshots");
2723
+ // The snapshot lock of the fixture repository (snapshot.mjs): `<snapshots>/<repo-key>.lock`, its body `{ pid, identity, commit, token }` (broker host) or `{ pid, host, startedAt, token }`.
2724
+ const lockFile = path.join(snapRoot, `${key}.lock`);
2725
+ const readLock = () => { try { return JSON.parse(fs.readFileSync(lockFile, "utf8")); } catch { return null; } };
2662
2726
 
2663
2727
  /** A step-only check: it feeds the step status AND the verdict (stepChecks), so it can never be dropped. */
2664
2728
  const check = (step, name, res) => {
@@ -2697,12 +2761,12 @@ async function executeRun({ fixture, host, wanted, gate, gateArg, budgetsFile, o
2697
2761
  // S0 -------------------------------------------------------------------------------------------------------------------------------------
2698
2762
  if (wanted.includes("S0") || wanted.includes("S9")) {
2699
2763
  const brokerNow = runningBrokerProcess() ?? null;
2700
- ctx.s0 = { stash: g.stash(), status: g.status(), worktree: g.worktrees(), broker: brokerNow, owner: readOwner(), snapshots: listDirs(snapRoot) };
2764
+ ctx.s0 = { stash: g.stash(), status: g.status(), worktree: g.worktrees(), broker: brokerNow, lock: readLock(), snapshots: listDirs(snapRoot) };
2701
2765
  }
2702
2766
  if (wanted.includes("S0")) {
2703
2767
  for (const id of ["GC-I22", "GC-I18", "GC-I01"]) { const r = CHECKS[id](ctx); for (const c of Array.isArray(r) ? r : [r]) { clauseChecks[id].push(c); if (id !== "GC-I01") { stepOf("S0").checks.push(c.status === "unchecked" ? "unchecked" : c.status); stepChecks.push({ step: "S0", name: id, ok: c.status === "pass", problems: c.problems }); } } }
2704
2768
  check("S0", "the fixture checkout is clean", ctx.s0.status.trim() === "" ? { ok: true, problems: [] } : { ok: false, problems: [`fixture checkout is not clean: ${ctx.s0.status.trim().split("\n")[0]}`] });
2705
- check("S0", "no owner record stands before the run", ctx.s0.owner ? { ok: false, problems: [`an owner record stands before the run: ${JSON.stringify({ handle: ctx.s0.owner.handle, pid: ctx.s0.owner.pid })}`] } : { ok: true, problems: [] });
2769
+ check("S0", "no snapshot lock stands before the run", ctx.s0.lock ? { ok: false, problems: [`a snapshot lock stands before the run: ${JSON.stringify({ token: ctx.s0.lock.token, pid: ctx.s0.lock.pid })}`] } : { ok: true, problems: [] });
2706
2770
  }
2707
2771
 
2708
2772
  // S1 --------------------------------------------------------------------------------------------------------------------------------------
@@ -2806,21 +2870,20 @@ async function executeRun({ fixture, host, wanted, gate, gateArg, budgetsFile, o
2806
2870
  }
2807
2871
 
2808
2872
  // S8 kill and recover ---------------------------------------------------------------------------------------------------------------------
2809
- // Build ownership is held across Class A by design (build-ownership.mjs:3-4), so a SIGKILL during --to check leaves a record exactly like one
2810
- // during --to compile: every case asserts that the NEXT run reclaims it (the log's reclaim line) and passes.
2873
+ // The snapshot lock is held across Class A by design (reset plan section 3), so a SIGKILL during --to check leaves the lock exactly like one
2874
+ // during --to compile: every case asserts that the NEXT run reclaims it on the stale-owner rule (the log's reclaim line) and passes.
2811
2875
  if (wanted.includes("S8")) for (const k of KILLS.filter((x) => !killsFilter || killsFilter.includes(x.id))) {
2812
2876
  const label = `S8:${k.id}`; const logPath = path.join(outDir, `${label.replace(/[^\w.-]/g, "_")}.log`);
2813
2877
  const stage = k.id.startsWith("K02") ? "check" : "compile"; const receiptPath = path.join(outDir, `${label.replace(/[^\w.-]/g, "_")}.receipt.json`);
2814
- const killed = await killDuring({ gate, cwd: g.canonical, args: ["--to", stage, "--commit", commit, "--receipt-out", receiptPath], signal: k.signal, waitFor: readOwner, afterMs: killAfterMs });
2878
+ const killed = await killDuring({ gate, cwd: g.canonical, args: ["--to", stage, "--commit", commit, "--receipt-out", receiptPath], signal: k.signal, waitFor: readLock, afterMs: killAfterMs });
2815
2879
  fs.writeFileSync(logPath, killed.log);
2816
- const before = readOwner();
2817
- const dry = before ? runDry(ownerFile) : { exit: null, text: "" };
2880
+ const before = readLock();
2818
2881
  const next = await doRun({ label: `${label}:next`, stage, ladder: true, step: "S8" });
2819
- const after = readOwner();
2820
- // A fixture compile exits 1 for reasons that are not ownership (its Class B rows fail); a compile that reclaimed the dead record and reached planning passed the recovery.
2821
- const reached = stage === "compile" && /class A scans \d+ at a time/.test(next.log) && !/build ownership [^\n]*(busy|refused)|RK_CHECK_ERROR/.test(next.log);
2822
- const recovery = assertRecovery({ signal: k.signal, before, dry, next: { exit: reached ? 0 : next.exit, text: next.log }, after, exitedBySignal: exitedBySignal({ signal: killed.signal, exit: killed.exit, killSignal: k.signal, platform: process.platform }) || (k.signal === "SIGINT" && !killed.signal && killed.exit !== null && killed.exit !== 0) });
2823
- runs[label] = { label, kill: k.id, killSignal: process.platform === "win32" ? "terminate" : k.signal, stage, recovery, logPath, ownerPath: ownerFile, exit: killed.exit, signal: killed.signal, log: killed.log, ladder: false, args: [] };
2882
+ const after = readLock();
2883
+ // A fixture compile exits 1 for reasons that are not the lock (its Class B rows fail); a compile that reclaimed the dead owner's lock and reached planning passed the recovery.
2884
+ const reached = stage === "compile" && /class A scans \d+ at a time/.test(next.log) && !/snapshot lock [^\n]*(busy|is held|refused)|RK_CHECK_ERROR|BLOCKED: snapshot/.test(next.log);
2885
+ const recovery = assertRecovery({ signal: k.signal, before, next: { exit: reached ? 0 : next.exit, text: next.log }, after, exitedBySignal: exitedBySignal({ signal: killed.signal, exit: killed.exit, killSignal: k.signal, platform: process.platform }) || (k.signal === "SIGINT" && !killed.signal && killed.exit !== null && killed.exit !== 0) });
2886
+ runs[label] = { label, kill: k.id, killSignal: process.platform === "win32" ? "terminate" : k.signal, stage, recovery, logPath, lockPath: lockFile, exit: killed.exit, signal: killed.signal, log: killed.log, ladder: false, args: [] };
2824
2887
  check("S8", `${k.id} ${k.signal}: dead owner reclaimed by the next run, which passes`, recovery);
2825
2888
  }
2826
2889
 
@@ -2857,7 +2920,13 @@ async function executeRun({ fixture, host, wanted, gate, gateArg, budgetsFile, o
2857
2920
  try {
2858
2921
  if (fs.existsSync(cacheDir)) { fs.renameSync(cacheDir, aside); moved = true; }
2859
2922
  check("S11", `the gate cache dir ${cacheDir} was moved aside to ${aside}`, { ok: moved, problems: moved ? [] : [`${cacheDir} does not exist: the run is not proven cold`] });
2860
- for (const stage of (s11ChecksOnly ? ["check"] : ["check", "compile"])) { const r = await doRun({ label: `S11:${stage}`, stage, ladder: true, step: "S11", profile: `cold-${stage}` }); check("S11", `cold --to ${stage} wrote coverage`, { ok: r.rows !== null, problems: [`exit ${r.exit}, no readable coverage`] }); }
2923
+ // Adrian 2026-11-07 ("Test checks the stop"): a cold run is a miss nothing explains, so the gate stops it for his approval before anything runs;
2924
+ // the test proves that stop (every row "no stored result", nothing ran). Cold budgets and cold parallelism are measured from cold runs he approves.
2925
+ for (const stage of (s11ChecksOnly ? ["check"] : ["check", "compile"])) {
2926
+ const r = await doRun({ label: `S11:${stage}-stop`, stage, ladder: false, step: "S11" });
2927
+ check("S11", `cold --to ${stage} stops on RK_CACHE_MISS with every row "no stored result" and nothing run`, assertMissStop(r, missReportOf(r.log), { cause: "new" }));
2928
+ ctx.cellWhy[`fixture:cold-${stage}`] = "a cold run stops for Adrian's approval (Adrian 2026-11-07: \"Test checks the stop\"); its budget is measured from a cold run he approves, not from this test";
2929
+ }
2861
2930
  } finally {
2862
2931
  let restored = !moved;
2863
2932
  if (moved) { try { if (fs.existsSync(cacheDir)) fs.renameSync(cacheDir, path.join(asideRoot, "created-during-the-cold-run")); fs.renameSync(aside, cacheDir); restored = true; } catch (e) { check("S11", "the gate cache dir is restored", { ok: false, problems: [e.message] }); } }
@@ -2929,7 +2998,8 @@ async function executeRun({ fixture, host, wanted, gate, gateArg, budgetsFile, o
2929
2998
  if (wanted.includes("S15")) {
2930
2999
  for (const [wl, dir] of [["rightkit", workspaceRootOf() + "/rightkit"], ["heardright", workspaceRootOf() + "/heardright"]]) {
2931
3000
  if (!fs.existsSync(dir)) { ctx.cellWhy[`${wl}:warm-check`] = `${dir} does not exist`; check("S15", `${wl} checkout exists`, { ok: false, problems: [`${dir} does not exist`] }); continue; }
2932
- const r = await doRun({ label: `S15:${wl}`, stage: "check", commit: "HEAD", cwd: dir, receipt: false, ladder: false, step: "S15", profile: "warm-check", workload: wl });
3001
+ // RightKit names its unit on every run (RK_UNIT_NOT_NAMED); the warm check names one small, stable crate so the measured window is the same each time.
3002
+ const r = await doRun({ label: `S15:${wl}`, stage: "check", commit: "HEAD", cwd: dir, receipt: false, ladder: false, step: "S15", profile: "warm-check", workload: wl, args: wl === "rightkit" ? ["--unit", "cargo:rightkit-time"] : [] });
2933
3003
  check("S15", `${wl} --to check exits 0`, exitOk(r));
2934
3004
  }
2935
3005
  if (pulseCompile) {
@@ -2942,7 +3012,10 @@ async function executeRun({ fixture, host, wanted, gate, gateArg, budgetsFile, o
2942
3012
  // S16 per-run identities ------------------------------------------------------------------------------------------------------------------
2943
3013
  if (wanted.includes("S16")) {
2944
3014
  const tmp = fs.mkdtempSync(path.join(scratch, "ident-tmp-"));
2945
- const r = await doRun({ label: "S16:ident", stage: "check", ladder: true, step: "S16", env: { CODEX_TOOL_CALL_ID: `fake-call-${Date.now()}`, TERM_SESSION_ID: `fake-session-${process.pid}`, TMPDIR: tmp, RK_GATE_RUN_NOTE: `identity-${Date.now()}` } });
3015
+ const r = await doRun({ label: "S16:ident", stage: "check", ladder: true, step: "S16", env: { CODEX_TOOL_CALL_ID: `fake-call-${Date.now()}`, TERM_SESSION_ID: `fake-session-${process.pid}`, TMPDIR: tmp, RK_GATE_RUN_NOTE: `identity-${Date.now()}`,
3016
+ // A restarted app or a changed shell (Mac 2026-11-07: PNPM_HOME, CLAUDE_*, BAGGAGE and PATH order moved and every stored pass missed): none of these is an input of a row.
3017
+ PNPM_HOME: path.join(tmp, "pnpm-home"), CLAUDE_PID: String(process.pid + 1), CLAUDE_CODE_MESSAGING_SOCKET: path.join(tmp, "claude.sock"), CLAUDE_CODE_ACCOUNT_UUID: `fake-account-${Date.now()}`, BAGGAGE: `fake=${Date.now()}`, LC_CTYPE: "C",
3018
+ PATH: String(process.env.PATH ?? "").split(path.delimiter).reverse().join(path.delimiter) } });
2946
3019
  check("S16", "the run with different per-run identities wrote coverage", { ok: r.rows !== null, problems: [`exit ${r.exit}, no readable coverage`] });
2947
3020
  }
2948
3021
 
@@ -2961,20 +3034,22 @@ async function executeRun({ fixture, host, wanted, gate, gateArg, budgetsFile, o
2961
3034
  if (!other) { ctx.identityChange = "no second installed toolchain found under RUSTUP_HOME/toolchains"; check("S17", "a second installed toolchain exists to change the identity", { ok: false, problems: [ctx.identityChange] }); }
2962
3035
  else {
2963
3036
  ctx.identityChange = `RUSTUP_TOOLCHAIN=${other}`;
2964
- await doRun({ label: "S17:fail3", stage: "compile", commit: cf, ladder: true, step: "S17", profile: "edited-compile", env: { RUSTUP_TOOLCHAIN: other } });
3037
+ // A toolchain change is not the run's own files: the gate stops it for Adrian's approval (Adrian 2026-11-07: "Test checks the stop").
3038
+ const f3 = await doRun({ label: "S17:fail3-stop", stage: "compile", commit: cf, ladder: false, step: "S17", env: { RUSTUP_TOOLCHAIN: other } });
3039
+ check("S17", "the run with a changed toolchain stops on RK_CACHE_MISS before anything runs", { ok: f3.exit !== 0 && /BLOCKED: RK_CACHE_MISS/.test(String(f3.log ?? "")), problems: [`exit ${f3.exit}; the run did not stop on RK_CACHE_MISS`] });
2965
3040
  }
2966
3041
  }
2967
3042
  }
2968
3043
 
2969
3044
  // S9 ---------------------------------------------------------------------------------------------------------------------------------------
2970
3045
  if (wanted.includes("S9")) {
2971
- const brokerEnd = runningBrokerProcess() ?? null; const owner = readOwner();
3046
+ const brokerEnd = runningBrokerProcess() ?? null; const lock = readLock();
2972
3047
  const snapshotDirCheck = snapshotDirProblems({ key, before: ctx.s0?.snapshots ?? null, after: listDirs(snapRoot) });
2973
- ctx.s9 = { stash: g.stash(), status: g.status(), worktree: g.worktrees(), snapshotDirCheck, broker: brokerEnd, ownerPath: ownerFile, ownerClean: { ok: owner === null, problems: owner === null ? [] : [`owner record stands after the run: handle ${owner.handle}, pid ${owner.pid}`] } };
3048
+ ctx.s9 = { stash: g.stash(), status: g.status(), worktree: g.worktrees(), snapshotDirCheck, broker: brokerEnd, lockPath: lockFile, lockClean: { ok: lock === null, problems: lock === null ? [] : [`a snapshot lock stands after the run: token ${lock.token}, pid ${lock.pid}`] } };
2974
3049
  check("S9", "git status --short equals S0", sameListing("git status --short", ctx.s0.status, ctx.s9.status));
2975
3050
  check("S9", "git worktree list equals S0", sameListing("git worktree list", ctx.s0.worktree, ctx.s9.worktree));
2976
3051
  check("S9", "git stash list equals S0", sameListing("git stash list", ctx.s0.stash, ctx.s9.stash));
2977
- check("S9", "no owner record stands", ctx.s9.ownerClean);
3052
+ check("S9", "no snapshot lock stands", ctx.s9.lockClean);
2978
3053
  check("S9", "one snapshot dir for the repository and no new one", snapshotDirCheck);
2979
3054
  check("S9", "the broker process is the one of S0", brokerUnchanged(ctx.s0.broker, brokerEnd));
2980
3055
  const markers = Object.values(runs).flatMap((r) => publicationMarkers(r.log ?? ""));
@@ -3030,20 +3105,22 @@ async function executeRun({ fixture, host, wanted, gate, gateArg, budgetsFile, o
3030
3105
  // ---------------------------------------------------------------------------------------------------------------------------------------------
3031
3106
  // --verify-release and --prove
3032
3107
  // ---------------------------------------------------------------------------------------------------------------------------------------------
3033
- /** `node gate-acceptance.mjs --verify-release <receipt-mac> <receipt-dell> [--commit <gate commit>]`: exit 0 only when both hosts' receipts pass for one gate commit (NN30, NN31, NN35). Release, upload and trusted-gate promotion tooling must call this. */
3108
+ /** `node gate-acceptance.mjs --verify-release <receipt> [--host mac|dell|linux] [--commit <gate commit>]`: exit 0 only when THIS host's receipt passes for the
3109
+ * gate commit (NN30, NN31, NN35, per host). Release, upload and trusted-gate install tooling must call this. */
3034
3110
  function verifyReleaseCli(argv) {
3035
3111
  const i = argv.indexOf("--verify-release");
3036
- const files = [argv[i + 1], argv[i + 2]];
3037
- if (!files[0] || !files[1] || files.some((f) => f.startsWith("--"))) { console.error("usage: node gate-acceptance.mjs --verify-release <receipt-mac> <receipt-dell> [--commit <sha>]"); return 64; }
3112
+ const files = [argv[i + 1]];
3113
+ if (!files[0] || files[0].startsWith("--")) { console.error("usage: node gate-acceptance.mjs --verify-release <receipt> [--host mac|dell|linux] [--commit <sha>]"); return 64; }
3038
3114
  const read = files.map((f) => readJson(f));
3039
3115
  const problems = read.filter((r) => r.error).map((r) => r.error);
3040
3116
  const j = argv.indexOf("--commit");
3041
3117
  if (!problems.length) {
3042
3118
  const budgets = loadBudgets().budgets;
3043
3119
  const waivers = (Array.isArray(budgets?.waivers) ? budgets.waivers : []).filter(validWaiver);
3044
- problems.push(...verifyReleaseReceipts(read[0].value, read[1].value, { commit: j < 0 ? null : argv[j + 1], contractSha256: fileSha(CONTRACT_FILE), runnerSha256: fileSha(RUNNER_FILE), waivers }).problems);
3120
+ const h = argv.indexOf("--host");
3121
+ problems.push(...verifyReleaseReceipts(read[0].value, null, { commit: j < 0 ? null : argv[j + 1], contractSha256: fileSha(CONTRACT_FILE), runnerSha256: fileSha(RUNNER_FILE), waivers, host: h < 0 ? null : argv[h + 1] }).problems);
3045
3122
  }
3046
- console.log(problems.length ? `verify-release REFUSED (${problems.length} problem(s))` : "verify-release OK: both hosts pass for one gate commit");
3123
+ console.log(problems.length ? `verify-release REFUSED (${problems.length} problem(s))` : "verify-release OK: this host's receipt passes for the gate commit");
3047
3124
  for (const p of problems) console.log(` ${p}`);
3048
3125
  return problems.length ? 1 : 0;
3049
3126
  }
@@ -3060,7 +3137,7 @@ export const MUTANTS = Object.freeze([
3060
3137
  { nn: "NN08", steps: "S2", what: "the gate runs the whole-workspace format check through cargo", inject: [spawnLine(CARGO, ["fmt", "--all", "--check"])], expect: /cargo fmt started/ },
3061
3138
  { nn: "NN09", steps: "S2", what: "the gate asks the broker for a metadata read (`rustright cargo metadata`)", inject: [spawnLine("rustright", [CARGO, "metadata", "--no-deps"])], expect: /went through the broker/ },
3062
3139
  { nn: "NN10", steps: "S2", what: "the gate starts a real metadata read on a warm run", inject: [spawnLine(CARGO, ["metadata", "--no-deps", "--format-version", "1"])], expect: /real cargo metadata/ },
3063
- { nn: "NN13", steps: "S2", what: "a --to check starts an ownership probe (`ps`)", inject: [spawnLine("ps", ["-p", "1"])], expect: /ownership probe/ },
3140
+ { nn: "NN13", steps: "S2", what: "a --to check starts a process probe (`ps`)", inject: [spawnLine("ps", ["-p", "1"])], expect: /process probe/ },
3064
3141
  { nn: "NN16", steps: "S10", what: "a unit-list run starts the per-unit format check through cargo", inject: [spawnLine(CARGO, ["fmt", "-p", "rk-core", "--check"])], expect: /cargo fmt started for a unit list/ },
3065
3142
  { nn: "NN22", steps: "S2", what: "a warm run walks the tree with `find`", inject: [spawnLine("find", [".", "-maxdepth", "1"])], expect: /tree walk/ },
3066
3143
  { nn: "NN25", steps: "S2", what: "a warm run starts `pnpm --version`", inject: [spawnLine("pnpm", ["--version"])], expect: /pnpm|version probe/ },
@@ -3071,7 +3148,7 @@ export const MUTANTS = Object.freeze([
3071
3148
  { nn: "NN06", steps: "S2", what: "every Class A row is environment-bound, so non-executing keys carry the environment digest", patch: { find: "function classAEnvironmentBound(scan) { return scan.executes === true || scan.tool === \"pnpm\"; }", replace: "function classAEnvironmentBound(scan) { return true; }" }, expect: /carries the environment digest/ },
3072
3149
  { nn: "NN12", steps: "S2", what: "a warm run starts `pnpm install`", inject: [spawnLine("pnpm", ["install", "--offline"])], expect: /pnpm install started/ },
3073
3150
  { nn: "NN29", steps: "S2,S16", what: "the tool-call id of the environment enters every Class A row key", patch: { find: "${rowShape(scan)}`; scanKeys.set(scan.id, full);", replace: "${rowShape(scan)}:${process.env.CODEX_TOOL_CALL_ID ?? \"\"}`; scanKeys.set(scan.id, full);" }, expect: /key differs between identical runs|reuse miss/ },
3074
- { nn: "NN32", steps: "S8", extra: ["--kills", "K02,K02-int"], what: "a dead owner's record is never judged reclaimable (judgeOwner always refuses)", patch: { file: "build-ownership.mjs", find: "if (owner.host !== host) throw busy(`held by pid ${owner.pid} on ${owner.host}`);", replace: "if (true) throw busy(`held by pid ${owner.pid} (MUTANT: a dead owner is never judged reclaimable)`);" }, expect: /reclaimed from|exited/ },
3151
+ { nn: "NN32", steps: "S8", extra: ["--kills", "K02,K02-int"], what: "a dead owner's snapshot lock is never judged reclaimable (the stale-owner rule always refuses)", patch: { file: "snapshot.mjs", find: "if (probe !== \"ESRCH\") throw busy(`snapshot lock holder pid ${holder.pid} cannot be proven gone (${probe})`);", replace: "if (true) throw busy(`snapshot lock holder pid ${holder.pid} is gone (MUTANT: a dead owner is never judged reclaimable)`);" }, expect: /reclaimed from|exited/ },
3075
3152
  { nn: "NN40", steps: "S2", compile: true, control: true, what: "the gate starts per-crate `cargo rustdoc` again (two crates of the fixture workspace, two starts)", inject: [spawnLine("rustright", ["cargo", "rustdoc", "-p", "rk-core", "--lib", "--help"]), spawnLine("rustright", ["cargo", "rustdoc", "-p", "rk-util", "--lib", "--help"])], expect: /a cargo rustdoc started/ },
3076
3153
  { nn: "NN41", steps: "S17", control: true, what: "the gate refuses to reuse a cached failure (every failing cache entry is dropped before the run)", inject: ['try { const __fs = process.getBuiltinModule("node:fs"); const __p = process.getBuiltinModule("node:path"); const __d = __p.join(process.cwd(), ".git", "rightkit-gate-cache"); for (const __f of __fs.readdirSync(__d)) { const __x = __p.join(__d, __f); try { if (JSON.parse(__fs.readFileSync(__x, "utf8"))?.row?.status === "fail") __fs.rmSync(__x); } catch { /* not an entry */ } } } catch { /* no cache dir */ }'], expect: /^S17: (clippy|check|check-features|doc):\S+: failed, .*ran again \(a failure must be a cache hit\)/ },
3077
3154
  { nn: "NN42", steps: "S2", compile: true, control: true, what: "the stage sends one broker command per cross target (two single-target commands of one configuration)", inject: [spawnLine("rustright", ["cargo", "check", "--help", "--target", "aarch64-unknown-linux-gnu"]), spawnLine("rustright", ["cargo", "check", "--help", "--target", "x86_64-pc-windows-msvc"])], expect: /one per target/ },
@@ -3214,14 +3291,14 @@ async function proveMain({ fixture, host, out }) {
3214
3291
  const budgets = loadBudgets().budgets;
3215
3292
  const mk = (h, over = {}) => ({ ...buildContractReceipt({ host: h, commit: "a".repeat(40), gate: { kind: "installed", version: inst?.version ?? "0", sealedPath: inst?.entry ?? null, sealedSha256: inst?.sealedSha256 ?? "b".repeat(64) }, contractSha256: fileSha(CONTRACT_FILE), runnerSha256: fileSha(RUNNER_FILE), budgetsSha256: fileSha(BUDGETS_FILE), fixtureCommit: budgets?.fixture?.commit ?? "c".repeat(40), result: cres }), ...over });
3216
3293
  const w = (name, r) => { const f = path.join(root, `receipt-${name}.json`); fs.writeFileSync(f, `${JSON.stringify(r, null, 2)}\n`); return f; };
3217
- const verify = async (a, b) => runRunner(["--verify-release", a, b], { cwd: here });
3218
- const real1 = await verify(w("mac-real", mk("mac")), path.join(root, "receipt-dell-missing.json"));
3219
- note("NN30", "--verify-release with the Dell receipt missing", real1.code === 1 && /ENOENT|cannot read/.test(real1.out), real1.out.split("\n").slice(0, 2).join(" | ").slice(0, 200));
3220
- const real2 = await verify(w("mac-fail", mk("mac")), w("dell-fail", mk("dell")));
3221
- note("NN30", "--verify-release with a failing receipt from each host (the real run's NOT PASSED result)", real2.code === 1 && /not a PASS/.test(real2.out), (real2.out.split("\n")[1] ?? "").trim().slice(0, 200));
3294
+ const verify = async (a) => runRunner(["--verify-release", a, "--host", "mac"], { cwd: here });
3295
+ const real1 = await verify(w("dell-for-mac", mk("dell")));
3296
+ note("NN30", "--verify-release on the mac with a receipt from another host", real1.code === 1 && /this host is mac/.test(real1.out), real1.out.split("\n").slice(0, 2).join(" | ").slice(0, 200));
3297
+ const real2 = await verify(w("mac-fail", mk("mac")));
3298
+ note("NN30", "--verify-release with this host's failing receipt (the real run's NOT PASSED result)", real2.code === 1 && /not a PASS/.test(real2.out), (real2.out.split("\n")[1] ?? "").trim().slice(0, 200));
3222
3299
  note("NN31", "--verify-release refuses a release whose receipts are not passes (what release, upload and promotion must call)", real2.code === 1 && /REFUSED/.test(real2.out), (real2.out.split("\n")[0] ?? "").slice(0, 200));
3223
3300
  const allPass = Object.fromEntries(NN_ALL_IDS.map((id) => [id, "pass"]));
3224
- const unw = await verify(w("mac-unchecked", mk("mac", { ok: true, verdict: "PASS (forced for the proof)", nn: allPass })), w("dell-unchecked", mk("dell", { ok: true, verdict: "PASS (forced for the proof)", nn: allPass })));
3301
+ const unw = await verify(w("mac-unchecked", mk("mac", { ok: true, verdict: "PASS (forced for the proof)", nn: allPass })));
3225
3302
  note("NN35", "--verify-release with passing receipts that leave operative clauses unchecked and unwaived", unw.code === 1 && /unchecked and not waived by Adrian/.test(unw.out), (unw.out.split("\n")[1] ?? "").trim().slice(0, 200));
3226
3303
  }
3227
3304
  // NN36 and NN37: real commits in a scratch clone of rightkit.
@@ -3261,7 +3338,7 @@ async function proveMain({ fixture, host, out }) {
3261
3338
  log.push(`NN37 control: with an independent review recorded the check is ${n37c?.status}`);
3262
3339
  } catch (e) { log.push(`lockproof failed: ${e.message}`); note("NN36", "scratch clone", false, e.message.slice(0, 200)); note("NN37", "scratch clone", false, e.message.slice(0, 200)); }
3263
3340
  }
3264
- // NN32: the unmutated gate recovers real kills (information), after the mutant above left a stale record: reclaimed by this run.
3341
+ // NN32: the unmutated gate recovers real kills (information), after the mutant above left a stale lock: reclaimed by this run.
3265
3342
  {
3266
3343
  const o = path.join(root, "kills-real");
3267
3344
  await runRunner([...common, "--steps", "S8", "--nn", "NN32", "--gate", base.entry, "--kills", "K01,K01-int,K02,K02-int", "--out", o], { cwd: here });
@@ -3280,11 +3357,6 @@ async function proveMain({ fixture, host, out }) {
3280
3357
  return summary.ok ? 0 : 1;
3281
3358
  }
3282
3359
 
3283
- function runDry(ownerFile) {
3284
- const r = spawnSync(process.execPath, [path.join(here, "ownership-recover.mjs"), ownerFile], { encoding: "utf8" });
3285
- return { exit: r.status, text: `${r.stdout ?? ""}${r.stderr ?? ""}` };
3286
- }
3287
-
3288
3360
  if (process.argv[1] && fs.realpathSync(process.argv[1]) === fileURLToPath(import.meta.url)) {
3289
3361
  main(process.argv.slice(2)).then((code) => process.exit(code), (e) => { console.error(`gate-acceptance: ${e.stack ?? e}`); process.exit(2); });
3290
3362
  }