@rightkit/release 0.6.40 → 0.6.43

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 +110 -11
  2. package/admission-files.mjs +40 -0
  3. package/admission-host.mjs +2 -1
  4. package/app-check.mjs +303 -16
  5. package/app-closure.mjs +6 -4
  6. package/bin/rightkit-gate.mjs +180 -32
  7. package/cargo-contract.mjs +17 -31
  8. package/cargo-license-notices.mjs +129 -19
  9. package/cargo-target-shim.mjs +14 -0
  10. package/carried-cargo.mjs +2 -4
  11. package/cli/right-release.mjs +24 -2
  12. package/cross-targets.mjs +24 -0
  13. package/deterministic-scans.mjs +150 -58
  14. package/development-signing.mjs +25 -2
  15. package/development.mjs +34 -1
  16. package/direct-release-command.mjs +154 -0
  17. package/disk-policy.mjs +16 -0
  18. package/feature-coverage.mjs +134 -0
  19. package/gate-coverage.mjs +38 -0
  20. package/gate-stages.mjs +1 -0
  21. package/ghsa-audit.mjs +95 -0
  22. package/install-app.mjs +33 -5
  23. package/install-channels.mjs +301 -0
  24. package/interactive-session-run.mjs +105 -0
  25. package/legal-contract.mjs +10 -1
  26. package/legion-freeze-consumer.mjs +241 -0
  27. package/linux-publish.mjs +136 -0
  28. package/local-publish.mjs +31 -8
  29. package/nsis-pack.mjs +95 -0
  30. package/nsis-upgrade-template.mjs +93 -0
  31. package/outdated-command.mjs +19 -0
  32. package/ownership-class-rules.mjs +32 -10
  33. package/ownership-mandatory-set.json +23 -0
  34. package/ownership-mandatory-set.mjs +66 -8
  35. package/package-recipe-targets.mjs +54 -19
  36. package/package.json +1 -1
  37. package/payload-root-install.mjs +123 -0
  38. package/plugin-delivery.mjs +141 -0
  39. package/prebuild-gates.mjs +8 -4
  40. package/preflight.mjs +6 -1
  41. package/provision-model-bundle.mjs +172 -0
  42. package/pub-upload.mjs +1 -1
  43. package/publish-local-npm.mjs +34 -9
  44. package/publish-retention.mjs +106 -0
  45. package/publish-update.mjs +15 -8
  46. package/qa-build-features.mjs +24 -15
  47. package/qa-contract.mjs +5 -6
  48. package/qa-control-scan.mjs +14 -0
  49. package/qa-web-pairing.mjs +76 -0
  50. package/r2-s3-multipart.mjs +190 -0
  51. package/r2-verified-upload.mjs +28 -16
  52. package/recipe-build.mjs +53 -3
  53. package/release-checks.mjs +53 -2
  54. package/release-config.mjs +8 -3
  55. package/release-invocation.mjs +12 -2
  56. package/release-pin-floor.mjs +44 -0
  57. package/release-qa-audit.mjs +18 -2
  58. package/release-qa-command.mjs +17 -1
  59. package/release-qa-policy.mjs +30 -3
  60. package/release-switch-cfg.mjs +271 -0
  61. package/release-switch-registry.json +60 -1
  62. package/release-switch-scan.mjs +398 -23
  63. package/release.mjs +97 -6
  64. package/render-views.mjs +141 -0
  65. package/rightkit-registry-resolver.mjs +1 -1
  66. package/rightkit-versions.json +140 -103
  67. package/runtime-artifact-manifest.mjs +9 -0
  68. package/runtime-manifest-refresh.mjs +88 -0
  69. package/rustright-stage.mjs +197 -0
  70. package/scan-digest.mjs +15 -9
  71. package/scan-tool-enrolment.mjs +1 -1
  72. package/security-policy.mjs +196 -0
  73. package/shell-contract.mjs +32 -0
  74. package/snapshot-broker.mjs +8 -1
  75. package/snapshot-check.mjs +59 -1
  76. package/snapshot-identity.mjs +48 -0
  77. package/snapshot-request.mjs +25 -2
  78. package/snapshot.mjs +69 -9
  79. package/stage-commands.mjs +33 -4
  80. package/stage-ledger.mjs +5 -0
  81. package/stage-receipt.mjs +115 -0
  82. package/stage-sidecar.mjs +188 -17
  83. package/stage-xcframework.mjs +118 -0
  84. package/suite-api.generated.mjs +16 -1
  85. package/unit-gate.mjs +14 -2
  86. package/upload-large.mjs +4 -4
  87. package/upload-release.mjs +6 -0
  88. package/win-package-recipe.mjs +26 -4
@@ -88,7 +88,10 @@ const gateResolveExecutor = (args) => resolveExecutor({ ...args, gateWrappers: t
88
88
  import { ALL_UNITS_ERRORS, ALL_UNITS_EXCEPTIONS_FILE, BROKER_EXCEPTIONS_FILE, BROKER_EXCEPTION_ERRORS, CARGO_WORKSPACE_LIST_FILE, CARGO_WORKSPACE_LIST_KEY, RIGHTKIT_IDENTITY_FILE, authorizeAllUnits, authorizeNoBroker, checkCargoWorkspaceList, describeAllUnitsException, describeBrokerException, isRightKitIdentity, unitsOfSelector } from "../broker-exception.mjs";
89
89
  import { SIGNING_REFUSAL_CODES, suiteSigningRefusals } from "../suite-signing-policy.mjs";
90
90
  import { gitListRustFiles } from "../signing-files.mjs";
91
- import { LINUX_BROKER_ROUTE, NO_BROKER_ENV, directCargoPath, directPlatform, linuxBrokerDeclared, managedRuntimeClient, realCargoOf } from "../managed-cargo.mjs";
91
+ import { nativeHelpersFromConfig } from "../native-helpers.mjs";
92
+ import { buildCoverageReport, seconds, writeCoverageReport } from "../gate-coverage.mjs";
93
+ import { renderViews, renderViewsOf } from "../render-views.mjs";
94
+ import { LINUX_BROKER_ROUTE, NO_BROKER_ENV, directCargoPath, directPlatform, linuxBrokerDeclared, managedRuntimeClient, realCargoOf, runCargoSync } from "../managed-cargo.mjs";
92
95
  import { createBrokerLive } from "../broker-admission.mjs";
93
96
  import { bindingOf, compileOutputsRecord, compileReuseProblem, endRun, readReceipt, RECEIPT_SCHEMA, receiptKey, sameBinding, sameSource, sealedFor, stagesTo, startRun, STAGES, STAGE_SOURCES, writeReceipt } from "../gate-stages.mjs";
94
97
  import { spawnSync as spawnInherit } from "../background-process.mjs";
@@ -141,7 +144,7 @@ function directCargoBinOf(o) {
141
144
  return null;
142
145
  }
143
146
 
144
- const USAGE = `usage: rightkit-gate --to check|compile|package|qualify|release [--platform mac|win|ios|android] [--tier patch|update] [--receipt-in <file>] [--receipt-out <file>] | rightkit-gate --to check|compile|package|qualify|release --unit npm:@rightkit/<name>|cargo:rightkit-<name> [--receipt-out <file>] | rightkit-gate --to tool --unit cargo:rightkit-qa|cargo:rightkit-credentials [--no-broker <exception-id>] [--receipt-out <file>] [--commit <rev>] (builds the unit's release binary from the commit and enrols it: cargo:rightkit-qa as the managed rightkit-qa runner, cargo:rightkit-credentials as the managed OS credential provider updater signing runs; Mac and Windows) | rightkit-gate --to check|compile|package|qualify --units-file <json {"units":[<selector>,...]} written for this run> | rightkit-gate --to check|compile|package|qualify --all-units-exception <id> (RightKit only: its unit is named on every run, or every unit by Adrian's entry in ci/all-units-exceptions.json of the commit) | rightkit-gate --to check|compile|package|qualify [--unit <selector>] --no-broker <exception-id> (Mac and Dell only; Adrian's recorded exception in .rightkit/broker-exceptions.json of the commit) | rightkit-gate --to dev|test [--commit <rev>] [-- <right-release args>] | rightkit-gate --to check|compile|package|qualify|dev|test --route [--platform mac|win|ios|android] [--commit <rev>] | rightkit-gate stage --platform mac|win [--tier patch|update] | rightkit-gate [--base <ref>] [--plan] | rightkit-gate install-hook | rightkit-gate env-digest | rightkit-gate snapshot [--commit <rev>] [--verify [--env <sha256>]] [--json] | rightkit-gate live-scans --repo <root> | rightkit-gate clippy [<cargo clippy args>] | rightkit-gate env-digest [--snapshot <dir> --commit <sha>] | rightkit-gate check [--repo <dir>] [--commit <rev> | --worktree] [--rule-tier compile|release] [--only <rule,...>] [--list] [--print-baseline] [--baseline <file>] | rightkit-gate check --commit <sha> --full-a --snapshot <dir> | --version`;
147
+ const USAGE = `usage: rightkit-gate --to check|compile|package|qualify|release [--platform mac|win|ios|android] [--tier patch|update] [--receipt-in <file>] [--receipt-out <file>] | rightkit-gate --to check|compile|package|qualify|release --unit npm:@rightkit/<name>|cargo:rightkit-<name> [--receipt-out <file>] | rightkit-gate --to tool --unit cargo:rightkit-qa|cargo:rightkit-credentials [--no-broker <exception-id>] [--receipt-out <file>] [--commit <rev>] (builds the unit's release binary from the commit and enrols it: cargo:rightkit-qa as the managed rightkit-qa runner, cargo:rightkit-credentials as the managed OS credential provider updater signing runs; Mac and Windows) | rightkit-gate --to check|compile|package|qualify --units-file <json {"units":[<selector>,...]} written for this run> | rightkit-gate --to check|compile|package|qualify --all-units-exception <id> (RightKit only: its unit is named on every run, or every unit by Adrian's entry in ci/all-units-exceptions.json of the commit) | rightkit-gate --to check|compile|package|qualify [--unit <selector>] --no-broker <exception-id> (Mac and Dell only; Adrian's recorded exception in .rightkit/broker-exceptions.json of the commit) | rightkit-gate --to dev|test [--commit <rev>] [-- <right-release args>] | rightkit-gate --to render [--commit <rev>] (builds the app's declared renderViews target from ci/gate.config.json through the carrier, runs it headless and stores the PNGs and a hashed receipt) | rightkit-gate --to check|compile|package|qualify|dev|test --route [--platform mac|win|ios|android] [--commit <rev>] | rightkit-gate stage --platform mac|win [--tier patch|update] | rightkit-gate [--base <ref>] [--plan] | rightkit-gate install-hook | rightkit-gate env-digest | rightkit-gate snapshot [--commit <rev>] [--verify [--env <sha256>]] [--json] | rightkit-gate live-scans --repo <root> | rightkit-gate clippy [<cargo clippy args>] | rightkit-gate env-digest [--snapshot <dir> --commit <sha>] | rightkit-gate check [--repo <dir>] [--commit <rev> | --worktree] [--rule-tier compile|release] [--only <rule,...>] [--list] [--print-baseline] [--baseline <file>] | rightkit-gate check --commit <sha> --full-a --snapshot <dir> | --version`;
145
148
  /** The host platform (process.platform) that constructs each platform's artifact; a platform missing here (android) builds on any host. */
146
149
  const STAGE_NATIVE_HOST = Object.freeze({ mac: "darwin", ios: "darwin", win: "win32" });
147
150
 
@@ -486,25 +489,51 @@ export function pnpmPinOf(packageJsonText) {
486
489
  }
487
490
 
488
491
  /**
489
- * Class A runs the pnpm it bound, never a pnpm that relaunches another one: a pnpm older than a package's `packageManager` pin switches
490
- * itself to the pinned version through a nested shell (on Windows `cmd /d /s /c` with ^-escaped text), which the class A launch guard
491
- * refuses mid-row as an unreadable launch. This compares the pnpm on PATH, asked from a directory with no package.json so it cannot
492
- * switch, with every pnpm pin of the checked tree BEFORE any class A row launches, and returns a typed problem naming both versions
493
- * and the fix, or null. Nothing is admitted: the guard keeps refusing any relaunch.
492
+ * Class A runs the pnpm it bound, never a pnpm that relaunches another one through a shell: on Windows a pnpm older than a package's
493
+ * `packageManager` pin switches itself to the pinned version through `cmd /d /s /c` with ^-escaped text, which the class A launch guard
494
+ * refuses mid-row as an unreadable launch. This checks every pnpm pin of the checked tree BEFORE any class A row launches and returns a
495
+ * typed problem naming both versions and the fix, or null. Nothing is admitted: the guard keeps refusing any relaunch.
496
+ *
497
+ * Pins under a declared fixture directory (ci/gate.config.json `fixtures`) are not the repository's own: a fixture's pnpm pin is
498
+ * evidence content that every other scan skips, so this check skips it too (rightkit#1468).
499
+ *
500
+ * Policy for a repository pinned differently from the host default (rightkit#1468): the pnpm on PATH is first asked from a directory
501
+ * with no package.json (it cannot switch there). When it differs from a pin, the pinned version is probed directly, by running
502
+ * `pnpm --version` inside the pinning package's own directory, where pnpm's packageManager self-switch (or corepack) resolves the pin;
503
+ * the pin is admitted only when that probe prints exactly the pinned version. Only when the probe fails does the check refuse, with the
504
+ * migration path. On Windows the self-switch itself is the refused shell relaunch, so there the pin must equal the neutral version.
494
505
  */
495
- export function pnpmPinProblem({ root, files, spawn = defaultSpawn, readFile = (f) => fs.readFileSync(f, "utf8"), neutralCwd = os.tmpdir() }) {
506
+ export function pnpmPinProblem({ root, files, spawn = defaultSpawn, readFile = (f) => fs.readFileSync(f, "utf8"), neutralCwd = os.tmpdir(), fixtures = [], platform = process.platform }) {
507
+ const fixtureDirs = fixtures.map((d) => String(d).replace(/\\/g, "/").replace(/\/+$/, "")).filter(Boolean);
508
+ const underFixture = (f) => fixtureDirs.some((d) => f === d || f.startsWith(`${d}/`));
496
509
  const pins = new Map();
497
- for (const f of files.filter((x) => /(^|\/)package\.json$/.test(x))) {
510
+ for (const f of files.filter((x) => /(^|\/)package\.json$/.test(x) && !underFixture(x))) {
498
511
  let pin = null; try { pin = pnpmPinOf(readFile(path.join(root, f))); } catch { pin = null; }
499
512
  if (pin) pins.set(f, pin);
500
513
  }
501
514
  if (!pins.size) return null;
502
515
  const r = spawn("pnpm", ["--version"], { cwd: neutralCwd, boundedMs: PNPM_PROBE_TIMEOUT_MS });
503
516
  const onPath = failed(r) ? "" : text(r).trim();
504
- const fix = (pin) => `install the pinned pnpm as the pnpm on PATH (for example \`pnpm self-update ${pin}\`) and run again`;
505
- if (!onPath) { const [pin] = new Set(pins.values()); return { code: PNPM_PIN_REFUSAL, message: `${PNPM_PIN_REFUSAL}: cannot read the version of the pnpm on PATH (${r?.error ? r.error.code ?? r.error.message : why(r)}); ${fix(pin)}` }; }
517
+ const fix = (pin) => `install the pinned pnpm as the pnpm on PATH (for example \`pnpm self-update ${pin}\`), or make the repository's own pin resolvable (corepack enable, network access to the pnpm release), and run again`;
506
518
  const bad = [...pins].filter(([, pin]) => pin !== onPath);
507
519
  if (!bad.length) return null;
520
+ if (platform !== "win32") {
521
+ // One probe per distinct pin, from the first package.json that carries it: the self-switch is per directory.
522
+ const probed = new Map(); const unresolved = [];
523
+ for (const [file, pin] of bad) {
524
+ if (!probed.has(pin)) {
525
+ const dir = path.join(root, path.dirname(file));
526
+ const pr = spawn("pnpm", ["--version"], { cwd: dir, boundedMs: PNPM_PROBE_TIMEOUT_MS });
527
+ probed.set(pin, failed(pr) ? null : text(pr).trim());
528
+ }
529
+ if (probed.get(pin) !== pin) unresolved.push([file, pin]);
530
+ }
531
+ if (!unresolved.length) return null;
532
+ const [file, pin] = unresolved[0];
533
+ const got = probed.get(pin);
534
+ return { code: PNPM_PIN_REFUSAL, message: `${PNPM_PIN_REFUSAL}: ${file} pins packageManager pnpm@${pin} and the pnpm on PATH is ${onPath || "unreadable"}; running pnpm inside ${path.dirname(file)} to resolve the pin ${got ? `printed ${got}` : "failed"}${unresolved.length > 1 ? ` (${unresolved.length} package.json files differ)` : ""}; ${fix(pin)}` };
535
+ }
536
+ if (!onPath) { const [, pin] = bad[0]; return { code: PNPM_PIN_REFUSAL, message: `${PNPM_PIN_REFUSAL}: cannot read the version of the pnpm on PATH (${r?.error ? r.error.code ?? r.error.message : why(r)}); ${fix(pin)}` }; }
508
537
  const [file, pin] = bad[0];
509
538
  return { code: PNPM_PIN_REFUSAL, message: `${PNPM_PIN_REFUSAL}: the pnpm on PATH is ${onPath} but ${file} pins packageManager pnpm@${pin}${bad.length > 1 ? ` (${bad.length} package.json files differ)` : ""}; a different pnpm relaunches the pinned one through a shell, which class A refuses (RK_CLASS_A_COMPILE_LAUNCH); ${fix(pin)}` };
510
539
  }
@@ -944,8 +973,7 @@ const plainRelative = (p) => typeof p === "string" && p !== "" && !path.posix.is
944
973
  * (externalInputs `leavesCrate`: workspace root, current_dir, a bare "..", the manifest directory's parent) keys the scan on the
945
974
  * whole HEAD tree, since its tests may read anything.
946
975
  * - An npm package scan (test:npm, tsc, eslint, biome) keys on the package's workspace closure (every dependency that is a workspace
947
- * package, whatever its spec, transitively, by package name) and the root npm inputs; test:scripts-ci on scripts/, ci/, .github/, packages/release and the
948
- * root install graph. Every other class B scan (generated-docs, swift-build) uses the whole tree.
976
+ * package, whatever its spec, transitively, by package name) and the root npm inputs; (the scripts/ci self-test scan no longer exists: Adrian, 2026-11-03, end-to-end tests only). Every other class B scan (generated-docs, swift-build) uses the whole tree.
949
977
  * - Class A: pnpm-lockfile and advisory-exceptions are never cached (live answers). cargo-deny, cargo-audit and pnpm-audit are cached by
950
978
  * their inputs and the identity of the advisory data they read (rightkit#1464, ADR-001 C5; advisoryKey below): a Cargo workspace's lock
951
979
  * blob, every Cargo.toml of the commit, the deny and cargo configuration files, and the pinned RustSec commit (cargo-deny and cargo-audit
@@ -961,7 +989,6 @@ const SHARED_NPM_INPUTS = ["package.json", "pnpm-lock.yaml", "pnpm-workspace.yam
961
989
  // name than the shared list above) is part of a package's key only when the commit has it, so a repository without one keeps the key it had.
962
990
  const LINT_CONFIG_NAMES = [...ESLINT_CONFIG_FILES, ...BIOME_CONFIG_FILES];
963
991
  // The gate's own test suite reads the CI scripts, the gate config and the release package it imports from.
964
- const SCRIPTS_CI_INPUTS = ["scripts", "ci", ".github", "packages/release", "package.json", "pnpm-lock.yaml"];
965
992
 
966
993
  /** ci/shards.json `solo` (crate names that always get an invocation of their own), read from the gated tree; empty when the file is absent or unreadable. */
967
994
  function shardSoloOf(o, repo) {
@@ -1109,7 +1136,6 @@ export function buildCacheDigest({ objectId, headTree, rustUnits = [], npmUnits
1109
1136
  if (unresolved) return whole();
1110
1137
  return canonicalJson({ kind: "npm", id: scan.id, members: members.map((m) => [m.name, m.dir, idOf(m.dir)]), shared: sharedNpmInputs(members) });
1111
1138
  }
1112
- if (scan.id === "test:scripts-ci") return canonicalJson({ kind: "dirs", id: scan.id, inputs: SCRIPTS_CI_INPUTS.map((p) => [p, idOf(p)]) });
1113
1139
  return whole();
1114
1140
  }
1115
1141
  const keyed = rustUnitKey(unit, scan);
@@ -1452,9 +1478,10 @@ async function runStages(o, args, root, git, io) {
1452
1478
  const to = option("--to");
1453
1479
  // dev and test are door stages like the rest: the same commit-only route (select a commit, sync its snapshot under ownership, class A
1454
1480
  // of the snapshot), then right-release dev|test with the snapshot's app root as its cwd. They have no stage list of their own.
1455
- const devTest = to === "dev" || to === "test";
1481
+ // render (rightkit#1288) is a door stage of the same family: class A of the snapshot, then the app's declared view-render target built through the carrier and run headless.
1482
+ const devTest = to === "dev" || to === "test" || to === "render";
1456
1483
  let stages = devTest ? [] : stagesTo(to);
1457
- if (!stages) { o.err(`${tag} --to must be one of ${[...STAGES, "dev", "test"].join(", ")}${to === "tool" ? " (--to tool builds one named tool unit: --to tool --unit cargo:rightkit-qa or --to tool --unit cargo:rightkit-credentials)" : ""}`); return 2; }
1484
+ if (!stages) { o.err(`${tag} --to must be one of ${[...STAGES, "dev", "test", "render"].join(", ")}${to === "tool" ? " (--to tool builds one named tool unit: --to tool --unit cargo:rightkit-qa or --to tool --unit cargo:rightkit-credentials)" : ""}`); return 2; }
1458
1485
  // Every stage the door runs has a row naming where it reads its source from (gate-stages.mjs STAGE_SOURCES, drift-tested in
1459
1486
  // door-stages.test.mjs); a stage added without one is refused rather than run with an unstated source.
1460
1487
  if (!STAGE_SOURCES[to]) { o.err(`${tag} BLOCKED: stage ${to} has no STAGE_SOURCES row naming its source; nothing ran`); return 2; }
@@ -1525,6 +1552,7 @@ async function runStages(o, args, root, git, io) {
1525
1552
  try { synced = (o.syncSnapshot ?? snap.syncSnapshot)({ checkout: root, rev: selected.commit, root: snapshotsAt }); }
1526
1553
  catch (e) { o.err(`${tag} ${e.code === "error" ? "RK_CHECK_ERROR" : "BLOCKED"}: snapshot ${e.message}; nothing ran`); return e.code === "error" ? 2 : 1; }
1527
1554
  o.out(`${tag} snapshot ${synced.path} is commit ${synced.commit} tree ${synced.tree} (written=${synced.written} removed=${synced.removed} unchanged=${synced.unchanged})`);
1555
+ if (synced.identity) o.out(`${tag} source identity ${synced.identity.file}: ${synced.identity.written ? "written" : synced.identity.kept ? "kept" : `not written (${synced.identity.reason})`}`);
1528
1556
  return await runStages({ ...o, buildOwnership: own, doorSnapshot: { own, path: synced.path, commit: synced.commit, tree: synced.tree, root: snapshotsAt, ledger: { entries: [] } } }, args, root, git, { ...io, buildOwnership: own });
1529
1557
  } finally {
1530
1558
  const r = own.release();
@@ -1643,6 +1671,24 @@ async function runStages(o, args, root, git, io) {
1643
1671
  const publisherUploadOnly = to === "release" && !mobile;
1644
1672
  // GB-15: a nested app's Class A runs its executing scans for that app's dependency closure; an app at the repository root is the repository.
1645
1673
  const appScope = appDir === "." ? [] : ["--scope", appDir];
1674
+ // rightkit#1491: an app whose own @rightkit/release is below the host gate's floor (DIRECT_ROUTE_RELEASE_FLOOR) is refused before any compile
1675
+ // on a broker host: its child would carry the non-compiling cargo calls to the broker, which refuses them (GC-A11). The pin is judged from the
1676
+ // commit's package.json before the check stage; the version installed in the snapshot (Class A installs it) before the compile stage.
1677
+ const appPackageJson = () => { const shown = git("show", `${commit}:${appDir === "." ? "" : `${appDir}/`}package.json`); return failed(shown) ? null : text(shown); };
1678
+ const pinFloor = async (installed) => {
1679
+ if (executor.kind !== "broker" || !stages.includes("compile") || !ds) return null;
1680
+ const packageJsonText = appPackageJson();
1681
+ if (packageJsonText === null) return null;
1682
+ const { releasePinFloorProblem } = await import("../release-pin-floor.mjs");
1683
+ let installedVersion = null;
1684
+ if (installed) {
1685
+ for (const dir of new Set([snapshotAppRootOf(ds.path, appDir), ds.path])) {
1686
+ try { installedVersion = JSON.parse(fs.readFileSync(path.join(dir, "node_modules", "@rightkit", "release", "package.json"), "utf8")).version ?? null; break; } catch { /* not installed here */ }
1687
+ }
1688
+ }
1689
+ return releasePinFloorProblem({ packageJsonText, installedVersion, where: appDir === "." ? "package.json" : `${appDir}/package.json` });
1690
+ };
1691
+ const phaseTimings = [];
1646
1692
  for (const stage of stages) {
1647
1693
  if (stage === "check" && publisherUploadOnly && receipt.stages.check?.ok && tierAtLeast(receipt.stages.check.ruleTier ?? "compile", earlyTier)) { o.out(`${tag} [check] already passed (${receipt.stages.check.ruleTier ?? "compile"} tier) for this exact input (commit, tree, lockfiles, gate, toolchain)`); continue; }
1648
1694
  if (stage === "compile" && receipt.stages.compile?.ok) {
@@ -1673,16 +1719,25 @@ async function runStages(o, args, root, git, io) {
1673
1719
  }
1674
1720
  // The start of every stage: the snapshot is exactly tree + dependencies + the ledger of the stages before it (7.08, decision 2 Q1).
1675
1721
  if (ds && !(await openSnapshotStage({ o, ds, root, stage, tag }))) { receipt.stages[stage] = { ok: false, at: new Date().toISOString(), snapshot: { path: ds.path, tree: ds.tree, intactAfter: false }, ownership: ds.own.handle }; save(); o.err(`${tag} --to ${to} stopped before ${stage}: the snapshot is not the commit's bytes plus the ledger; nothing ran`); return 2; }
1676
- let ok = false; const at = new Date().toISOString(); let extra = {}; let directReceipt = null;
1722
+ let ok = false; const at = new Date().toISOString(); const stageStartedMs = Date.now(); let extra = {}; let directReceipt = null;
1677
1723
  if (stage === "check") {
1724
+ { const problem = await pinFloor(false); if (problem) { o.err(`${tag} BLOCKED: ${problem.message}; no class A row ran and nothing compiled`); return 1; } }
1678
1725
  ok = (await (o.runCheck ?? (() => main(["check", "--commit", ds ? commit : "HEAD", "--full-a", ...(ds ? ["--snapshot", ds.path] : []), ...appScope, "--rule-tier", earlyTier], { ...io, cwd: root, ...(ds ? { buildOwnership: ds.own } : {}) })))(earlyTier)) === 0;
1679
1726
  extra = { ruleTier: earlyTier };
1680
1727
  }
1681
1728
  else if (stage === "compile") {
1729
+ { const problem = await pinFloor(true); if (problem) { o.err(`${tag} BLOCKED: ${problem.message}; nothing compiled`); return 1; } }
1682
1730
  // A Tauri crate with externalBin needs its sidecars in src-tauri/binaries before it compiles (its build script refuses
1683
1731
  // otherwise), so every release config that declares `sidecars` is staged first, through right-release under this door run.
1684
1732
  const sidecarConfigs = sidecarConfigsOf();
1685
1733
  ok = true;
1734
+ // rightkit#1462 (ADR-001 section 7): a run that goes on to package runs the release admission, read-only, before anything compiles: the same rows `right-release build`
1735
+ // runs at its start (files: config and inputs; host: tools, credentials, signing hosts; network: pin freshness against the registries), asked through its own
1736
+ // `--dry-run`, which prints the rows and exits non-zero on a finding before any lock, cache, install or child build exists. A refusal then costs seconds, not a class B.
1737
+ if (stages.includes("package") && !mobile && PLATFORMS.includes(platform)) {
1738
+ o.out(`${tag} [compile] release admission dry-run for ${platform} before any compile (right-release build --platform ${platform} --dry-run)`);
1739
+ if (!await rightRelease(stage, ["build", "--platform", platform, "--dry-run"])) { o.err(`${tag} BLOCKED: [compile] the release admission (pin freshness, host tools, credentials, signing hosts) refused ${platform}; nothing compiled`); ok = false; }
1740
+ }
1686
1741
  // On the snapshot route the sidecars are staged from the snapshot's own config and sources through right-release's source split
1687
1742
  // (the staged files and receipt land beside the sources the compile reads; the caches and build trees stay the checkout's), before
1688
1743
  // `main --all` compiles. A broker host's stage-sidecar child reaches Cargo through the stage's carrier (carried-cargo.mjs).
@@ -1839,9 +1894,12 @@ async function runStages(o, args, root, git, io) {
1839
1894
  }
1840
1895
  receipt.stages[stage] = { ok, at, ...extra };
1841
1896
  save();
1842
- if (!ok) { o.err(`${tag} --to ${to} stopped at ${stage}: nothing after it ran`); return 1; }
1897
+ // rightkit#1463: each stage's own wall-clock time, and the run's phases in one line at the end.
1898
+ phaseTimings.push(`${stage} ${seconds(Date.now() - stageStartedMs)}${ok ? "" : " (failed)"}`);
1899
+ o.out(`${tag} [${stage}] ${ok ? "passed" : "failed"} in ${seconds(Date.now() - stageStartedMs)}`);
1900
+ if (!ok) { o.err(`${tag} --to ${to} stopped at ${stage}: nothing after it ran; phase timings: ${phaseTimings.join(", ")}`); return 1; }
1843
1901
  }
1844
- o.out(`${tag} --to ${to} passed: ${stages.join(", ")}`);
1902
+ o.out(`${tag} --to ${to} passed: ${stages.join(", ")}; phase timings: ${phaseTimings.join(", ") || "none ran"}`);
1845
1903
  return 0;
1846
1904
  }
1847
1905
 
@@ -2465,6 +2523,7 @@ async function runUnitSnapshot(o, args, root, git, io, option) {
2465
2523
  try { synced = (o.syncSnapshot ?? snap.syncSnapshot)({ checkout: root, rev: commit, root: snapshotsAt }); }
2466
2524
  catch (e) { o.err(`${tag} ${e.code === "error" ? "RK_CHECK_ERROR" : "BLOCKED"}: snapshot ${e.message}; nothing ran`); return e.code === "error" ? 2 : 1; }
2467
2525
  o.out(`${tag} snapshot ${synced.path} is commit ${synced.commit} tree ${synced.tree} (written=${synced.written} removed=${synced.removed} unchanged=${synced.unchanged})`);
2526
+ if (synced.identity) o.out(`${tag} source identity ${synced.identity.file}: ${synced.identity.written ? "written" : synced.identity.kept ? "kept" : `not written (${synced.identity.reason})`}`);
2468
2527
  const ds = { own, path: synced.path, commit: synced.commit, tree: synced.tree, root: snapshotsAt, ledger: { entries: [] } };
2469
2528
  // A unit's test or pack that reaches Cargo must never write `target/` into the snapshot (npm units included): see bindUnitCargo.
2470
2529
  // A check starts no unit command: its own Class A path binds read-only Cargo calls. Resolving every unit's compile output
@@ -2555,9 +2614,11 @@ export function snapshotRouteRefusal(o) {
2555
2614
  /** The refusal codes a route probe can answer with: the codes the stages themselves print (`BLOCKED: <code>: ...`). */
2556
2615
  export const ROUTE_REFUSAL_CODES = Object.freeze(["RK_TAURI_CONFIG_OVERRIDE", "RK_STAGE_HOST_MISMATCH", "RK_SNAPSHOT_BROKER_UNAVAILABLE", "RK_SNAPSHOT_CARRIER_NOT_WIRED", "RK_BROKER_CAPABILITY_MISSING", "RK_BROKER_UNAVAILABLE",
2557
2616
  // One signing identity per product (rightkit#1303): the Mac and the Dell refuse an unsigned, ad hoc or re-identified test or dev build.
2558
- ...SIGNING_REFUSAL_CODES]);
2617
+ ...SIGNING_REFUSAL_CODES,
2618
+ // The Mac's shared native helper list (targets.mac.macPackage.nativeHelpers) must validate before a Mac test, dev or package stage runs (rightkit#1308).
2619
+ "NATIVE_HELPERS_INVALID"]);
2559
2620
  /** The stages `--route` can answer for (`release` writes to the publisher and has no route of its own on a host). */
2560
- export const ROUTE_PROBE_STAGES = Object.freeze(["check", "compile", "package", "qualify", "dev", "test"]);
2621
+ export const ROUTE_PROBE_STAGES = Object.freeze(["check", "compile", "package", "qualify", "dev", "test", "render"]);
2561
2622
  export const ROUTE_SCHEMA = "rightkit-gate.route/1";
2562
2623
 
2563
2624
  /**
@@ -2675,14 +2736,30 @@ export function routePlan(o, { to, stages, devTest, executor, capabilities = nul
2675
2736
  }
2676
2737
  // One signing identity per product, every build (rightkit#1303): on the Mac and the Dell a test or dev build that would run unsigned, ad hoc or under
2677
2738
  // another identifier is refused here, from the commit's own config, so `--route` and a real run decide alike. Linux and hosted CI are exempt.
2678
- if (snapshot && appConfig?.config && (devTest || to === "test" || to === "dev")) {
2739
+ if (snapshot && appConfig?.config && (to === "test" || to === "dev")) {
2679
2740
  const [first] = suiteSigningRefusals({ config: appConfig.config, platform: o.platform, env: o.env, to, devPlatform: appConfig.devPlatform ?? null, readFile: appConfig.readFile, listFiles: appConfig.listFiles ?? null });
2680
2741
  if (first) return { route, refusal: refuse(first.code, to, first.message) };
2681
2742
  }
2743
+ // rightkit#1308: the shared native helper list is validated at run time by the Mac qa-sign step (suite-signing -> development-signing), the dev install
2744
+ // (development.mjs) and the Mac package recipe (package-recipe-targets.mjs), where a retired `sharedPackage` refuses NATIVE_HELPERS_INVALID mid-run. The
2745
+ // route says so before anything runs, on a Mac, for a test or dev run (whose platform is mac) and a mac package.
2746
+ if (snapshot && appConfig?.config && o.platform === "darwin") {
2747
+ const macRun = (to === "test" || to === "dev") ? (appConfig.devPlatform ?? "mac") === "mac" : stages.includes("package") && stagePlatform === "mac";
2748
+ if (macRun) {
2749
+ const problem = nativeHelpersRefusalText(appConfig.config);
2750
+ if (problem) return { route, refusal: refuse("NATIVE_HELPERS_INVALID", to, problem) };
2751
+ }
2752
+ }
2682
2753
  if (executor?.kind === "refuse") return { route, refusal: refuse("RK_BROKER_UNAVAILABLE", to, executor.problem) };
2683
2754
  return { route, refusal: null };
2684
2755
  }
2685
2756
 
2757
+ /** The message validateNativeHelpers refuses `config.targets.mac.macPackage.nativeHelpers` with (NATIVE_HELPERS_INVALID), or null when the list is absent or valid. */
2758
+ export function nativeHelpersRefusalText(config) {
2759
+ try { nativeHelpersFromConfig(config); return null; }
2760
+ catch (error) { if (error?.code === "NATIVE_HELPERS_INVALID") return String(error.message); throw error; }
2761
+ }
2762
+
2686
2763
  /**
2687
2764
  * The app config of the selected commit for the route's signing refusals, read from the object database (never the checkout): `{ config, readFile }`,
2688
2765
  * `readFile(rel)` being an app-relative file of the commit (text or null). Null when the commit has no readable JSON config (class A judges that).
@@ -2975,6 +3052,35 @@ export function cargoOutputPin({ o, git, root, commit, executor, snapshot, manif
2975
3052
  return { dir: workspaces.size ? [...workspaces.values()][0] : null, workspaces, dirs: [...workspaces.values()] };
2976
3053
  }
2977
3054
 
3055
+ /**
3056
+ * `--to render`'s stage (rightkit#1288): the app's declared `renderViews` target (the commit's ci/gate.config.json, read from the verified snapshot) is built
3057
+ * through the stage's carrier and run headless outside the broker, one case at a time; the images and a hashed receipt are stored under the host's run-output
3058
+ * root (`rightkit-gate-render/<repo>-<commit>-<time>/`). Returns 0 or 1; every refusal is named and nothing is partially passed.
3059
+ */
3060
+ export async function runRenderStage({ o, ds, root, appDir, commit, tree, env, pinnedTarget = null, targetDirs = {}, tag = "rightkit-gate:" }) {
3061
+ let gateConfig = null;
3062
+ try { gateConfig = JSON.parse(o.readFile(path.join(ds.path, GATE_CONFIG))); } catch { gateConfig = null; }
3063
+ const declared = renderViewsOf(gateConfig, appDir);
3064
+ if (declared.problems) { for (const p of declared.problems) o.err(`${tag} BLOCKED: [render] ${p}`); o.err(`${tag} nothing compiled`); return 1; }
3065
+ if (declared.none) { o.err(`${tag} BLOCKED: [render] ${appDir === "." ? "the repository" : appDir} declares no renderViews target in ${GATE_CONFIG}; nothing compiled`); return 1; }
3066
+ const stamp = new Date().toISOString().replace(/[:.]/g, "-");
3067
+ let outDir;
3068
+ try { outDir = path.join(gateRunsRoot({ env: o.env, platform: o.platform }), "rightkit-gate-render", `${path.basename(root)}-${commit.slice(0, 12)}-${stamp}-${process.pid}`); }
3069
+ catch (error) { o.err(`${tag} BLOCKED: [render] no run-output root to store the images in (${error.message}); nothing compiled`); return 1; }
3070
+ o.out(`${tag} [render] ${declared.package}:${declared.bin}, ${declared.cases.length} case(s): ${declared.cases.join(", ")}; evidence in ${outDir}`);
3071
+ const result = renderViews({
3072
+ target: declared, snapshotRoot: ds.path, commit, tree, outDir, env, platform: o.platform, arch: process.arch,
3073
+ targetDir: targetDirs[declared.cargoDir] ?? pinnedTarget,
3074
+ runCargo: (cargoArgs, options) => runCargoSync(cargoArgs, { ...options, encoding: "utf8", maxBuffer: 512 * 1024 * 1024 }),
3075
+ runExecutable: (exe, exeArgs, options) => o.spawn(exe, exeArgs, { cwd: options.cwd, env: options.env, boundedMs: options.timeoutMs }),
3076
+ log: (m) => o.out(`${tag} [render] ${m}`),
3077
+ });
3078
+ if (!result.ok) { for (const p of result.problems) o.err(`${tag} BLOCKED: [render] ${p}`); return 1; }
3079
+ for (const c of result.receipt.cases) o.out(`${tag} [render] ${c.name}: ${c.png} ${c.width}x${c.height} sha256 ${c.sha256}`);
3080
+ o.out(`${tag} [render] receipt ${result.receiptFile} (${result.receipt.cases.length} image(s); executable sha256 ${result.receipt.executable.sha256})`);
3081
+ return 0;
3082
+ }
3083
+
2978
3084
  /**
2979
3085
  * rightkit-gate --to dev|test [--commit <rev>] [-- <right-release dev|test arguments>]: the local compiles, on a commit like every other
2980
3086
  * stage (docs/GATE-CONTRACT.md "Commit-only build": `--to dev` and `--to test` build a commit; `--worktree` never admits a build). The
@@ -3053,7 +3159,15 @@ async function runDevTest(o, args, root, git, io, to, appRoot, appDir) {
3053
3159
  // The door's own RightKit runs every sub-step: a dev target's `right-release web-build|stage-sidecar` steps resolve `right-release`
3054
3160
  // on PATH, which found the app's node_modules copy (HeardRight on the Dell, 2026-10-27: the app's 0.6.8 guard refused what the
3055
3161
  // door's 0.6.9 admitted). An installed gate (node_modules/@rightkit/release/bin) has its package's bin shims two levels up.
3056
- const r = (o.spawnInherit ?? ((cmd, a, opts) => spawnInherit(cmd, a, { ...opts, stdio: "inherit" })))(process.execPath, [cli, to, ...passthrough], { cwd: source ? snapshotAppRootOf(ds.path, appDir) : appRoot, env: carriedEnv(carrier, { ...o.env, ...run.env }, { ...doorPath({ ...o, env: { ...o.env, ...carrier.env } }), ...(pin.dir ? { CARGO_TARGET_DIR: pin.dir } : (pinMulti?.env ?? {})) }) });
3162
+ const childEnv = carriedEnv(carrier, { ...o.env, ...run.env }, { ...doorPath({ ...o, env: { ...o.env, ...carrier.env } }), ...(pin.dir ? { CARGO_TARGET_DIR: pin.dir } : (pinMulti?.env ?? {})) });
3163
+ // rightkit#1288: `--to render` builds the app's declared view-render target through the carrier and runs it headless; no right-release child is involved.
3164
+ if (to === "render") {
3165
+ const rendered = ds ? await runRenderStage({ o, ds, root, appDir, commit, tree, env: childEnv, pinnedTarget: pin.dir ?? null, targetDirs: pinMulti?.targetDirs ?? {}, tag }) : (o.err(`${tag} BLOCKED: --to render runs on the snapshot route only; nothing compiled`), 1);
3166
+ const carriedRendered = await carrier.finish({ stage: to });
3167
+ if (ds && !(await closeSnapshotStage({ o, ds, root, stage: to, step: to, tag })).ok) { o.err(`${tag} --to ${to} stopped: the result covers no known bytes`); return 2; }
3168
+ return rendered === 0 && carriedRendered ? 0 : 1;
3169
+ }
3170
+ const r = (o.spawnInherit ?? ((cmd, a, opts) => spawnInherit(cmd, a, { ...opts, stdio: "inherit" })))(process.execPath, [cli, to, ...passthrough], { cwd: source ? snapshotAppRootOf(ds.path, appDir) : appRoot, env: childEnv });
3057
3171
  const carriedOk = await carrier.finish({ stage: to });
3058
3172
  if (ds && !(await closeSnapshotStage({ o, ds, root, stage: to, step: to, tag })).ok) { o.err(`${tag} --to ${to} stopped: the result covers no known bytes`); return 2; }
3059
3173
  return r.status === 0 && carriedOk ? 0 : 1;
@@ -3103,7 +3217,7 @@ export function stageArgsProblem(args) {
3103
3217
  if (STAGE_BOOLEAN_FLAGS.includes(a)) continue;
3104
3218
  if (STAGE_VALUE_FLAGS.includes(a)) {
3105
3219
  const value = gate[i + 1];
3106
- if (value === undefined || value.startsWith("--")) return a === "--to" ? `--to needs a stage (${[...STAGES, "dev", "test"].join("|")})` : `${a} needs a value`;
3220
+ if (value === undefined || value.startsWith("--")) return a === "--to" ? `--to needs a stage (${[...STAGES, "dev", "test", "render"].join("|")})` : `${a} needs a value`;
3107
3221
  if (seen.has(a)) return `${a} was given twice`;
3108
3222
  seen.add(a); i += 1; continue;
3109
3223
  }
@@ -3121,6 +3235,15 @@ export async function main(argv, io = {}) {
3121
3235
  gateFile: fileURLToPath(import.meta.url), ...io,
3122
3236
  };
3123
3237
  const args = [...argv];
3238
+ // rightkit#1463: a run that does work (a door stage, or a class A / full pass) stamps every log line with its UTC time, so phase times no longer have to be
3239
+ // rebuilt from broker receipts. Machine-readable output is never stamped: the --route JSON, a list or baseline, --json, the version, and the one
3240
+ // `verdict deterministic` marker line other tools read.
3241
+ const stampsLines = (args.includes("--to") || args.includes("--full-a") || args.includes("--all"))
3242
+ && !args.some((a) => ["--route", "--list", "--print-baseline", "--json", "--plan", "--version", "-v", "--help", "-h"].includes(a));
3243
+ if (stampsLines) {
3244
+ const stamped = (write) => (m) => write(/^rightkit-gate: verdict deterministic/.test(String(m)) ? m : `${new Date().toISOString()} ${m}`);
3245
+ o.out = stamped(o.out); o.err = stamped(o.err);
3246
+ }
3124
3247
  // The cache bypass is retired (GC-T14; workspace rule: never write or run a no-cache option). Refused by name so an old caller learns why.
3125
3248
  if (args.includes("--no-cache") || (io.env ?? process.env).RK_GATE_CACHE === "0") {
3126
3249
  (io.err ?? console.error)("rightkit-gate: --no-cache and RK_GATE_CACHE=0 are retired: results are reused only under a key naming every input they read, so a changed input always reruns (GC-T14)");
@@ -3184,6 +3307,7 @@ export async function main(argv, io = {}) {
3184
3307
  try { synced = (o.syncSnapshot ?? snap.syncSnapshot)({ checkout, rev: selected.commit, root: snapshotsAt }); }
3185
3308
  catch (e) { o.err(`rightkit-gate: ${e.code === "error" ? sc.CHECK_ERROR : "BLOCKED"}: snapshot ${e.message}; nothing ran`); return e.code === "error" ? 2 : 1; }
3186
3309
  o.out(`rightkit-gate: snapshot ${synced.path} is commit ${synced.commit} tree ${synced.tree} (written=${synced.written} removed=${synced.removed} unchanged=${synced.unchanged})`);
3310
+ if (synced.identity) o.out(`rightkit-gate: source identity ${synced.identity.file}: ${synced.identity.written ? "written" : synced.identity.kept ? "kept" : `not written (${synced.identity.reason})`}`);
3187
3311
  const next = [...argv]; const ci = next.indexOf("--commit");
3188
3312
  if (ci >= 0) next.splice(ci, 2, "--commit", synced.commit); else next.push("--commit", synced.commit);
3189
3313
  next.push("--snapshot", synced.path);
@@ -3926,8 +4050,8 @@ export async function main(argv, io = {}) {
3926
4050
  e2eCrateDirs, swiftPackages,
3927
4051
  rustUnits: rust.units, npmUnits: npm, npmRoots, cargoDir: ".", rustLocks, crateFeatures, crateDependents, externalInputs,
3928
4052
  // B1 (rightkit#1458): compile scans of one Cargo workspace run as one cargo invocation per configuration; ci/shards.json `solo` crates never join one.
3929
- // Batching is opt-in (RK_GATE_CLASS_B_BATCH=1) until the batch-equivalence run (GATE-CONTRACT GC-I11) shows a batch passes exactly when each crate passes alone: one cargo call unifies the members' features.
3930
- classBBatching: o.env.RK_GATE_CLASS_B_BATCH === "1", shardSolo: shardSoloOf(o, repo),
4053
+ // Batching is on (RK_GATE_CLASS_B_BATCH=0 turns it off): the batch-equivalence run (GATE-CONTRACT GC-I11; Pulse 3b31b4ca, 2026-11-03) gave the same verdict on all 193 scans batched and per crate.
4054
+ classBBatching: o.env.RK_GATE_CLASS_B_BATCH !== "0", shardSolo: shardSoloOf(o, repo),
3931
4055
  // The broker (or, on a direct host, the gate itself) admits compiles; no separate grant file decides it here.
3932
4056
  localCompile: true,
3933
4057
  exists: o.exists, readFile: o.readFile, platform: o.platform,
@@ -3996,6 +4120,8 @@ export async function main(argv, io = {}) {
3996
4120
  }
3997
4121
  // The result cache keys on the gated commit's object ids; the stdin check above made HEAD the pushed commit.
3998
4122
  let cache = null;
4123
+ // rightkit#1463: the input key each scan was looked up under, for the coverage report (gate-coverage.mjs).
4124
+ const scanKeys = new Map();
3999
4125
  // Full class A on the working tree (the door, and broker admission of the live checkout) caches on the LIVE bytes: every
4000
4126
  // tracked and untracked (not ignored) file is hashed raw, so the door's run and a repeat admission of the same bytes hit the
4001
4127
  // cache, and any edit misses it.
@@ -4047,6 +4173,16 @@ export async function main(argv, io = {}) {
4047
4173
  const installed = sc.installSnapshotDependencies({ checkout, snapshot: snapshotA, ...ct, roots: installRoots, ...(closure ? { packageDirs: npm.filter((u) => closure.npm.has(u.name)).map((u) => u.dir) } : {}), env: o.env, spawn: o.spawn });
4048
4174
  for (const r of installed) o.out(`${tag} ${sc.describeInstall(r)}`);
4049
4175
  } catch (error) { o.err(`${tag} ${error.code === "RK_CHECK_ERROR" ? "RK_CHECK_ERROR" : "BLOCKED"}: ${error.message}`); return error.code === "RK_CHECK_ERROR" ? 2 : 1; }
4176
+ } else if (classAOnly && snapshotA && !planOnly && npmRoots.length) {
4177
+ // A content check (no --full-a) installs nothing, so a package the offline store lacks in one of the commit's pnpm roots showed only at the
4178
+ // compile stage's install (ViewRight workers/waitlist, workerd, rightkit#1488). Every root's lockfile is proved against the store here, with no
4179
+ // install: `pnpm fetch --offline` into a scratch virtual store, the snapshot verified unchanged after.
4180
+ const sc = await import("../snapshot-check.mjs");
4181
+ try {
4182
+ const checkout = fs.realpathSync.native(root);
4183
+ const ct = sc.commitOf(checkout, String(snapshot), o.spawn);
4184
+ for (const r of sc.verifySnapshotStore({ checkout, snapshot: snapshotA, ...ct, roots: npmRoots, tmpRoot: gateTmpRoot({ env: o.env, platform: o.platform, exists: o.exists }), env: o.env, spawn: o.spawn })) o.out(`${tag} ${sc.describeStoreCheck(r)}`);
4185
+ } catch (error) { o.err(`${tag} ${error.code === "RK_CHECK_ERROR" ? "RK_CHECK_ERROR" : "BLOCKED"}: ${error.message}`); return error.code === "RK_CHECK_ERROR" ? 2 : 1; }
4050
4186
  }
4051
4187
  const liveSnapshot = live?.digest ?? null;
4052
4188
  // The environment, installed dependencies included, is bound at the start and compared at the end, so a dependency that
@@ -4057,7 +4193,10 @@ export async function main(argv, io = {}) {
4057
4193
  if (boundFullA) {
4058
4194
  const orphans = orphanedPnpmStores({ root: liveBase, files: live.files });
4059
4195
  if (orphans.length) { o.err(`${tag} BLOCKED: orphaned nested pnpm store(s) ${orphans.join(", ")}: left by a standalone install in a workspace member; they can hold stale dependencies and make concurrent vitest runs clear their shared module cache under each other. Move them aside (or reinstall) and run again.`); return 1; }
4060
- const pinProblem = pnpmPinProblem({ root: liveBase, files: live.files, spawn: o.spawn, readFile: o.readFile });
4196
+ // ci/gate.config.json `fixtures`: their package.json pins are evidence content, skipped here as every other scan skips them (rightkit#1468).
4197
+ let pinFixtures = [];
4198
+ try { const f = JSON.parse(o.readFile(path.join(liveBase, GATE_CONFIG))).fixtures; if (Array.isArray(f)) pinFixtures = f.filter((d) => typeof d === "string"); } catch { /* no config: no fixtures */ }
4199
+ const pinProblem = pnpmPinProblem({ root: liveBase, files: live.files, spawn: o.spawn, readFile: o.readFile, fixtures: pinFixtures, platform: o.platform });
4061
4200
  if (pinProblem) { o.err(`${tag} BLOCKED: ${pinProblem.message}; no class A row ran`); return 1; }
4062
4201
  try { envAtStart = classAEnvironmentDigest({ root: liveBase, gatePackage: o.gatePackage, files: live.files, spawn: o.spawn, includeCaches: false }); envStartWithCaches = classAEnvironmentDigest({ root: liveBase, gatePackage: o.gatePackage, files: live.files, spawn: o.spawn }); cachesAtStart = toolCacheManifest({ root: liveBase, files: live.files }); }
4063
4202
  catch (error) { o.err(`${tag} BLOCKED: ${error.message}`); return 1; }
@@ -4085,7 +4224,7 @@ export async function main(argv, io = {}) {
4085
4224
  // A row field that shapes what the scan checks without changing its id or command is part of its key: a tsc row's tscWorkspace
4086
4225
  // (the sibling packages its check project maps; scopeScans narrows it per scope) changes the verdict on the same tree.
4087
4226
  const rowShape = (scan) => (scan.tscWorkspace ? `:tscws=${createHash("sha256").update(canonicalJson([...scan.tscWorkspace].sort())).digest("hex")}` : "");
4088
- cache = { ...store, digest: (scan) => { if (/^build-helpers(:|$)/.test(scan.id)) return null; const key = digest(scan); return key === null ? null : `${key}:${environment}${rowShape(scan)}`; } };
4227
+ cache = { ...store, digest: (scan) => { if (/^build-helpers(:|$)/.test(scan.id)) return null; const key = digest(scan); const full = key === null ? null : `${key}:${environment}${rowShape(scan)}`; scanKeys.set(scan.id, full); return full; } };
4089
4228
  } catch { cache = null; }
4090
4229
  }
4091
4230
  if (!classAOnly) {
@@ -4114,7 +4253,7 @@ export async function main(argv, io = {}) {
4114
4253
  // The gate's identity is part of every class B key: a changed check or key logic never reuses an older verdict.
4115
4254
  const rowDigest = buildCacheDigest({ objectId, headTree: treeId, rustUnits: rust.units, npmUnits: npm, cargoDir: ".", rustLocks, crateFeatures, listFiles, readBlob });
4116
4255
  const gateIdentity = gateCodeIdentity();
4117
- cache = { ...store, digest: (scan) => { const key = rowDigest(scan); return key === null ? null : `${key}:${gateIdentity}`; } };
4256
+ cache = { ...store, digest: (scan) => { const key = rowDigest(scan); const full = key === null ? null : `${key}:${gateIdentity}`; scanKeys.set(scan.id, full); return full; } };
4118
4257
  }
4119
4258
  } catch { cache = null; }
4120
4259
  }
@@ -4140,7 +4279,9 @@ export async function main(argv, io = {}) {
4140
4279
  directTiming.cargoStart = Date.now();
4141
4280
  census?.start();
4142
4281
  const scanResult = await (o.runScans ?? runScans)(plan, {
4143
- classes: classAOnly ? ["A"] : classAEarlier ? ["B"] : ["A", "B"], ...(classAEarlier ? { classAEarlier: true } : {}), jobs, testJobs, classBJobs, classBBatching: o.env.RK_GATE_CLASS_B_BATCH === "1", classBPipeline: Math.max(1, Number(o.env.RK_GATE_CLASS_B_PIPELINE ?? 2) || 2), ...(brokerHost ? { brokerHost: true } : {}), ...(brokerLive ? { brokerLive } : {}), signal: ac.signal, ...(cache ? { cache } : {}),
4282
+ // The commit's own files (rightkit#1393): a snapshot is not a git toplevel, so the secret scan needs this list to judge tracked files only and never what a stage wrote there.
4283
+ ...(snapshot ? { trackedFiles: files } : {}),
4284
+ classes: classAOnly ? ["A"] : classAEarlier ? ["B"] : ["A", "B"], ...(classAEarlier ? { classAEarlier: true } : {}), jobs, testJobs, classBJobs, classBBatching: o.env.RK_GATE_CLASS_B_BATCH !== "0", classBPipeline: Math.max(1, Number(o.env.RK_GATE_CLASS_B_PIPELINE ?? 2) || 2), ...(brokerHost ? { brokerHost: true } : {}), ...(brokerLive ? { brokerLive } : {}), signal: ac.signal, ...(cache ? { cache } : {}),
4144
4285
  ...(census ? { spawn: census.wrapSpawn(defaultSpawnAsync) } : {}),
4145
4286
  // The declared Linux broker route: the scans are planned with the logical `rustright`, which this spawn (and scanSpawn's pass-through below) starts as the
4146
4287
  // executor's validated client, never a PATH lookup (withDeclaredClient).
@@ -4178,7 +4319,7 @@ export async function main(argv, io = {}) {
4178
4319
  return path.join(base, "rightkit-gate-scan-logs", `${path.basename(root)}-${stamp}-${process.pid}`);
4179
4320
  } catch { return null; }
4180
4321
  })(),
4181
- onResult: (row, p) => o.out(`${tag} [${p.done}/${p.total}] ${(row.cached ? "cached" : row.status).padEnd(7)} ${row.id} (${p.seconds}s)${row.batchedWith ? ` [batch of ${row.batchedWith.units.length}]` : ""}${row.status === "fail" ? ` :: ${String(row.detail ?? "").slice(0, 300)}` : ""}`),
4322
+ onResult: (row, p) => o.out(`${tag} [${p.done}/${p.total}] ${(row.cached ? "cached" : row.status).padEnd(7)} ${row.id} (${p.seconds}s)${row.batchedWith ? ` [batch of ${row.batchedWith.units.length}]` : ""}${row.status === "fail" ? ` :: ${String(row.detail ?? "").slice(0, 300)}` : row.advice ? ` :: ${String(row.advice).slice(0, 300)}` : ""}`),
4182
4323
  });
4183
4324
  directTiming.cargoEnd = Date.now();
4184
4325
  const freshness = census ? census.finish() : null;
@@ -4194,6 +4335,13 @@ export async function main(argv, io = {}) {
4194
4335
  const deferrals = scanDeferrals(scanResult);
4195
4336
  for (const line of deferrals) failures.push(`DEFERRED ${line}`);
4196
4337
  for (const note of scanResult.notes) o.out(`${tag} ${note}`);
4338
+ // rightkit#1463: the per-scan coverage report (hit / ran / skipped, with the cache key and the reason), written beside the scan logs; a cache that never hits shows here.
4339
+ try {
4340
+ const report = buildCoverageReport({ plan, scanResult, keys: scanKeys, classes: classAOnly ? ["A"] : classAEarlier ? ["B"] : ["A", "B"], commit: snapshotBCommit?.commit ?? snapshotCommitId?.commit ?? hostedCommitA?.commit ?? null, startedAt: new Date(directTiming.cargoStart).toISOString(), endedAt: new Date(directTiming.cargoEnd).toISOString() });
4341
+ const base = gateRunsRoot({ env: o.env, platform: o.platform });
4342
+ const file = (o.writeCoverage ?? writeCoverageReport)({ dir: path.join(base, "rightkit-gate-coverage"), name: `${path.basename(root)}-${new Date().toISOString().replace(/[:.]/g, "-")}-${process.pid}`, report });
4343
+ o.out(`${tag} coverage report ${file}: ${report.totals.planned} planned scan(s), ${report.totals.hit} hit, ${report.totals.ran} ran, ${report.totals.skipped} skipped; scans took ${seconds(directTiming.cargoEnd - directTiming.cargoStart)}`);
4344
+ } catch (error) { o.out(`${tag} note: the coverage report could not be written (${error.message})`); }
4197
4345
  // What a full class A verdict binds, green or red: the bytes it judged, unchanged from start to end, and the environment it judged
4198
4346
  // in (gate, tools, installed dependencies, tool caches), unchanged too. A verdict whose binding moved covers nothing: a green one is
4199
4347
  // refused and a red one names no reusable deterministic cause (rightkit#1257). Returns { env, notes } or { prefix, problem, exit }.
@@ -1,7 +1,7 @@
1
- import { existsSync, mkdtempSync, readdirSync, rmSync } from "node:fs";
1
+ import { existsSync, mkdtempSync, readFileSync, readdirSync, rmSync } from "node:fs";
2
+ import { createRequire } from "node:module";
2
3
  import { tmpdir } from "node:os";
3
4
  import path from "node:path";
4
- import { spawnSync } from "./background-process.mjs";
5
5
  import { directPlatform, gateNoBroker, linuxBrokerDeclared, managedRuntimeClient, runCargoSync } from "./managed-cargo.mjs";
6
6
 
7
7
  const SKIP_DIRECTORIES = new Set([".audit", ".cache", ".git", ".claude", ".right-release", ".worktrees", "node_modules", "target", "vendor"]);
@@ -157,36 +157,22 @@ function assertNoRightKitOverrides(parsed, label, source) {
157
157
  }
158
158
  }
159
159
 
160
- // `tomllib` is Python 3.11+. Windows pins `py -3.11`, but a bare `python3` on macOS is the system
161
- // 3.9, which has no tomllib — so every app's release:doctor died on a stock Mac, and reported the
162
- // manifest as invalid TOML when the real problem was the interpreter. Probe for one that can.
163
- let tomlRunner;
164
- function resolveTomlRunner() {
165
- if (tomlRunner) return tomlRunner;
166
- const probe = "import sys,tomllib";
167
- const candidates =
168
- process.platform === "win32"
169
- ? [["py", ["-3.11"]], ["py", ["-3"]], ["python", []]]
170
- : [["python3.13", []], ["python3.12", []], ["python3.11", []], ["python3", []]];
171
- for (const [command, prefix] of candidates) {
172
- const check = spawnSync(command, [...prefix, "-c", probe], { encoding: "utf8", windowsHide: true });
173
- if (check.status === 0) {
174
- tomlRunner = { command, prefix };
175
- return tomlRunner;
176
- }
177
- }
178
- throw new Error(
179
- "no Python with tomllib found (needs 3.11+). Install one, or put it on PATH: the release " +
180
- "contract reads Cargo manifests through it.",
181
- );
182
- }
183
-
160
+ // Manifests and .cargo/config files are parsed in-process with smol-toml (a dependency of this package), so the same table
161
+ // results on win32, darwin and linux and no host Python is read or spawned (#919). smol-toml loads on first parse, like
162
+ // rightkit-registry-resolver, so a CI job whose closure only imports this module needs no install.
163
+ let smolTomlParse;
184
164
  function readToml(file, label) {
185
- const script = "import json,pathlib,sys,tomllib; json.dump(tomllib.loads(pathlib.Path(sys.argv[1]).read_text(encoding='utf-8')),sys.stdout,default=str)";
186
- const { command, prefix } = resolveTomlRunner();
187
- const result = spawnSync(command, [...prefix, "-c", script, file], { encoding: "utf8", windowsHide: true });
188
- if (result.status !== 0) throw new Error(`${label} is not valid TOML: ${String(result.stderr ?? "").trim()}`);
189
- return JSON.parse(result.stdout);
165
+ let text;
166
+ try {
167
+ text = readFileSync(file, "utf8");
168
+ } catch (error) {
169
+ throw new Error(`${label} could not be read: ${error.message}`);
170
+ }
171
+ try {
172
+ return (smolTomlParse ??= createRequire(import.meta.url)("smol-toml").parse)(text);
173
+ } catch (error) {
174
+ throw new Error(`${label} is not valid TOML: ${error.message}`);
175
+ }
190
176
  }
191
177
 
192
178
  // Not product code: SwiftPM `.build` (dependency checkouts and build products), throwaway probe dirs (`*-probe`, `pdfprobe2`), `tmp`, and