@rightkit/release 0.6.47 → 0.6.49

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.
@@ -17,7 +17,7 @@ import os from "node:os";
17
17
  import { spawnSync } from "./background-process.mjs";
18
18
 
19
19
  export const ARTIFACT_MARKER_SCHEMA = 1;
20
- export const DEFAULT_MANAGED_ROOT = resolveManagedRoots().dataRoot;
20
+ export const DEFAULT_MANAGED_ROOT = resolveManagedRoots().gateRoot;
21
21
 
22
22
  const SAFE_COMPONENT = /^[A-Za-z0-9][A-Za-z0-9._+-]{0,159}$/;
23
23
 
@@ -37,7 +37,7 @@ export function canonicalManagedRoot(root, { realpath = realpathSync.native } =
37
37
  }
38
38
 
39
39
  export function resolveManagedRoot({ env = process.env, exists = existsSync } = {}) {
40
- if (env.RIGHTKIT_DATA_ROOT || env.RIGHTKIT_MANAGED_ROOT || env.RIGHTKIT_EXTERNAL_ROOT) return path.resolve(resolveManagedRoots({ env }).dataRoot);
40
+ if (env.RIGHTKIT_DATA_ROOT || env.RIGHTKIT_MANAGED_ROOT || env.RIGHTKIT_EXTERNAL_ROOT) return path.resolve(resolveManagedRoots({ env }).gateRoot);
41
41
  // Workstation default only when its drive exists; hosted CI runners fall back to RUNNER_TEMP, then the system temp dir.
42
42
  const volume = process.platform === "win32" ? "D:\\" : "/Volumes/D";
43
43
  if (exists(volume)) return path.resolve(DEFAULT_MANAGED_ROOT);
package/assembled-app.mjs CHANGED
@@ -277,8 +277,13 @@ export function resolveNestedApp({ root, entry, spec, profile, deps = {} }) {
277
277
  return app;
278
278
  }
279
279
 
280
- /** CFBundleVersion: the commit count of the source revision. A shallow clone is refused (no network, so no unshallow). */
280
+ /**
281
+ * CFBundleVersion: the commit count of the source revision. A shallow clone is refused (no network, so no unshallow).
282
+ * Inside the door's source split `root` is the snapshot, whose `.git` is a config-only stub that cannot answer: the gate counts the commit in the
283
+ * checkout and hands the number down as RIGHT_BUILD_NUMBER (docs/GATE-CONTRACT.md [GC-A28]); a positive integer there is used as given, anything else falls through to git.
284
+ */
281
285
  export function commitCount({ root, env = process.env, run = spawnSync }) {
286
+ if (/^[1-9][0-9]*$/.test(env.RIGHT_BUILD_NUMBER ?? "")) return env.RIGHT_BUILD_NUMBER;
282
287
  const git = (args) => {
283
288
  const result = run("git", args, { cwd: root, env, encoding: "utf8", windowsHide: true, shell: false });
284
289
  if (result.error || result.status !== 0) refuse("ASSEMBLY_VERSION_UNAVAILABLE", `git ${args.join(" ")} failed (${result.status ?? result.error?.message})`);
@@ -61,7 +61,7 @@
61
61
  // path the closure's sources include from outside their crate; the whole HEAD tree for Rust tests unless ci/gate.config.json
62
62
  // rust.<crate>.testInputs lists the paths they read, for npm, node and docs scans, and whenever a reference cannot be resolved
63
63
  // statically) are all identical. Stored in <git common dir>/rightkit-gate-cache; a hit prints
64
- // `cached` and is listed in the result's cacheHits. Failures, deferrals and class A scans are never cached.
64
+ // `cached` and is listed in the result's cacheHits. A deterministic failure (NN41: a compile's authenticated or diagnosed failure, a file-only rule's violations) is cached too and prints `cached-fail`; timeouts, aborts, refusals, infrastructure errors and test runs never are.
65
65
  // RK_GATE_JOBS (default 4) sets class A scan concurrency. Class B on a broker host (rightkit#1367 step 2): the gate does not count builds; every
66
66
  // component's broker-carried scans (cargo, rustright, carried Swift, and npm suites that declare a broker call) start without a limit, each component in plan order,
67
67
  // and the broker queues and orders them. A carried scan's run limit is a stopwatch that stops while the broker holds all its requests QUEUED (broker-admission.mjs),
@@ -81,7 +81,7 @@ import { hostTarget } from "../cross-targets.mjs";
81
81
  import { FOREIGN_PRE_COMMIT, retireHooksIn } from "../hook-retirement.mjs";
82
82
  import { fileURLToPath } from "node:url";
83
83
  import { installIdentity, installStateBytes } from "../dependency-identity.mjs";
84
- import { BIOME_CONFIG_FILES, CHECKER_IDENTITY, ESLINT_CONFIG_FILES, LOCAL_CLASS_B_JOBS, WORKSPACE_RUST_FILE, ancestorConfigChanged, ancestorDirsOf, canonicalJson, defaultSpawn, defaultSpawnAsync, digestScanSet, fileScanCache, findRustfmt, metadataArgs, planScans, runScans, scanToolPolicyFromPipeline, scanDeferrals, scanFailures } from "../deterministic-scans.mjs";
84
+ import { BIOME_CONFIG_FILES, CHECKER_IDENTITY, OXLINT_CONFIG_FILES, ESLINT_CONFIG_FILES, LOCAL_CLASS_B_JOBS, WORKSPACE_RUST_FILE, ancestorConfigChanged, ancestorDirsOf, canonicalJson, defaultSpawn, defaultSpawnAsync, digestScanSet, fileScanCache, findRustfmt, metadataArgs, planScans, runScans, scanToolPolicyFromPipeline, scanDeferrals, scanFailures } from "../deterministic-scans.mjs";
85
85
  import { changedLockNames, parseLock, reach } from "../lock-graph.mjs";
86
86
  import { resolveExecutor } from "../gate-executor.mjs";
87
87
  // The gate's own executor: an outer gate's cargo wrapper on PATH is never this gate's cargo (gate-executor.mjs `gateWrappers`).
@@ -112,6 +112,7 @@ import { createRequire } from "node:module";
112
112
  import { nativeToolRefusal, nativeToolUses } from "../native-tool-planning.mjs";
113
113
  import { BUILD_CONTROL_PROTOCOL, HANDSHAKE_PROBE_ID, RUNTIME_MANIFEST_FILE, mergeCapabilityViews, parseRuntimeIdentity, queryBrokerHandshake } from "../broker-handshake.mjs";
114
114
  import net from "node:net";
115
+ import { installSpawnLedger } from "../spawn-ledger.mjs";
115
116
  import { cargoWidthRouteProblem, cargoWidthScanProblem, cargoWidthUnitsProblem, parseCargoWidth, validateCargoWidthPool } from "../cargo-width.mjs";
116
117
 
117
118
  const PRIVATE_SCOPED_COMPILE = Symbol("private scoped compile");
@@ -1074,7 +1075,8 @@ export function buildCacheDigest({ objectId, headTree, rustUnits = [], npmUnits
1074
1075
  // so it is reused for a rerun of the same commit and nothing else.
1075
1076
  const liveScan = (id) => /^(cargo-deny|cargo-audit|pnpm-audit|pnpm-lockfile|advisory-exceptions)(:|$)/.test(id);
1076
1077
  // GC-A24: pnpm-lockfile asks the registry as pnpm-audit does, so it takes the same day-bounded key (GC-A19).
1077
- const ADVISORY_SCAN = /^(cargo-deny|cargo-audit|pnpm-audit|pnpm-lockfile)(:|$)/;
1078
+ // GC-A24 table: ghsa-audit and advisory-exceptions take GC-A19 keys (their inputs plus the UTC day) like cargo-deny and cargo-audit.
1079
+ const ADVISORY_SCAN = /^(cargo-deny|cargo-audit|pnpm-audit|pnpm-lockfile|ghsa-audit|advisory-exceptions)(:|$)/;
1078
1080
  // The key of an advisory scan (rightkit#1464), or null when an input cannot be identified (the scan then runs). Every input that decides the
1079
1081
  // verdict and is not in the scan's id, command or environment is here; the advisory database's commit (cargo) is in the scan's own environment
1080
1082
  // (RK_ADVISORY_DB_COMMIT) and its pin object, the gate's code and advisory-db.json are in the environment digest the caller appends.
@@ -1089,6 +1091,18 @@ export function buildCacheDigest({ objectId, headTree, rustUnits = [], npmUnits
1089
1091
  const manifests = all.filter((f) => /(^|\/)package\.json$/.test(f) && (dir === "." || f === inWs(dir, "package.json") || f.startsWith(`${dir}/`)));
1090
1092
  return canonicalJson({ kind: "pnpm-audit", id: scan.id, day: today(), inputs: idsOf([lock, inWs(dir, "pnpm-workspace.yaml"), inWs(dir, ".npmrc"), ".npmrc", ...manifests]) });
1091
1093
  }
1094
+ if (scan.internal === "ghsa-audit") {
1095
+ // The verdict reads the committed lockfile and OSV's answer of the day (ghsa-audit.mjs); its rule code is the checker identity.
1096
+ if (typeof scan.lockFile !== "string" || idOf(scan.lockFile) === null || idOf(scan.lockFile) === undefined) return null;
1097
+ return canonicalJson({ kind: "ghsa-audit", id: scan.id, day: today(), inputs: idsOf([scan.lockFile]) });
1098
+ }
1099
+ if (scan.internal === "advisory-exceptions") {
1100
+ // Exceptions must match deny.toml, .cargo/audit.toml and the locked versions, and an expired one fails, so the day is part of the key.
1101
+ const at = typeof scan.dir === "string" && scan.dir !== "" ? scan.dir : ".";
1102
+ const files = [inWs(at, "deny.toml"), inWs(at, ".cargo/audit.toml"), inWs(at, "Cargo.lock"), "ci/advisory-exceptions.json"];
1103
+ if (typeof scan.exceptionsFile === "string") files.push(inWs(at, scan.exceptionsFile));
1104
+ return canonicalJson({ kind: "advisory-exceptions", id: scan.id, day: today(), inputs: idsOf(files) });
1105
+ }
1092
1106
  const lock = inWs(dir, "Cargo.lock");
1093
1107
  if (idOf(lock) === null || idOf(lock) === undefined) return null;
1094
1108
  const ancestors = ancestorDirsOf(dir);
@@ -1104,12 +1118,37 @@ export function buildCacheDigest({ objectId, headTree, rustUnits = [], npmUnits
1104
1118
  const configs = new Set(); for (const f of rs) for (const d of ancestorDirsOf(path.posix.dirname(f))) for (const c of ["rustfmt.toml", ".rustfmt.toml"]) configs.add(inWs(d, c));
1105
1119
  return [...rs, ...configs];
1106
1120
  }
1121
+ if (/^cargo-metadata(:|$)/.test(scan.id) && typeof listFiles === "function") {
1122
+ // GC-A24 table: every Cargo.toml, Cargo.lock, .cargo and toolchain file of the workspace and its ancestors, so an edit in one
1123
+ // workspace never reruns another's metadata (GC-A19; acceptance run 3 saw app/engine rerun for an rk edit).
1124
+ const ws = typeof scan.cwd === "string" && scan.cwd !== "" ? scan.cwd : ".";
1125
+ const cargoFile = (f) => /(^|\/)(Cargo\.toml|Cargo\.lock|rust-toolchain|rust-toolchain\.toml)$/.test(f) || /(^|\/)\.cargo\//.test(f);
1126
+ const own = listFiles(ws).filter(cargoFile);
1127
+ const above = ancestorDirsOf(ws).flatMap((d) => ["Cargo.toml", "Cargo.lock", "rust-toolchain", "rust-toolchain.toml", ".cargo/config", ".cargo/config.toml"].map((f) => inWs(d, f)));
1128
+ return [...own, ...above];
1129
+ }
1130
+ // feature-coverage reads each planned crate's Cargo.toml and the sets ci/gate.config.json declares for it.
1131
+ if (scan.internal === "feature-coverage" && Array.isArray(scan.crates)) return [...scan.crates.map((c) => c.manifest).filter((m) => typeof m === "string"), "ci/gate.config.json"];
1132
+ if (/^oxlint:/.test(scan.id) && typeof listFiles === "function" && typeof scan.cwd === "string" && scan.cwd !== "") {
1133
+ // Oxlint reads the package's own files and the nearest config at or above it; the enrolled binary is in the row's tool identity.
1134
+ return [...listFiles(scan.cwd), ...ancestorDirsOf(scan.cwd).flatMap((d) => OXLINT_CONFIG_FILES.map((f) => inWs(d, f)))];
1135
+ }
1107
1136
  if (/^node-check:/.test(scan.id)) { const f = scan.id.slice("node-check:".length); return [f, ...ancestorDirsOf(path.posix.dirname(f)).map((d) => inWs(d, "package.json"))]; }
1108
1137
  if (scan.internal === "secret-scan" && Array.isArray(scan.dirs) && typeof listFiles === "function") return [...new Set(scan.dirs.flatMap((d) => listFiles(d)))];
1109
1138
  if (scan.id === "shellcheck") return [...args.filter((x) => /\.(sh|bash)$/.test(x)), ".shellcheckrc"];
1110
1139
  if (scan.id === "actionlint") return [...args.filter((x) => /\.ya?ml$/.test(x)), ".github/actionlint.yaml"];
1111
1140
  return null;
1112
1141
  };
1142
+ // npm package scans (class A tsc, eslint, biome; class B test:npm): the package's workspace closure plus the root npm inputs, or
1143
+ // undefined when the scan is not one of them or its closure does not resolve (the caller then keys on the whole tree).
1144
+ const npmScanKey = (scan) => {
1145
+ if (typeof readBlob !== "function") return undefined;
1146
+ const npmMatch = /^(test:npm|tsc|eslint|biome):(.+)$/.exec(scan.id);
1147
+ if (!npmMatch || !npmByUnit.has(npmMatch[2])) return undefined;
1148
+ const { members, unresolved } = npmClosure(npmByUnit.get(npmMatch[2]));
1149
+ if (unresolved) return undefined;
1150
+ return canonicalJson({ kind: "npm", id: scan.id, members: members.map((m) => [m.name, m.dir, idOf(m.dir)]), shared: sharedNpmInputs(members) });
1151
+ };
1113
1152
  const unitKeyMemo = new Map();
1114
1153
  return (scan) => {
1115
1154
  if (scan.class === "A") {
@@ -1128,7 +1167,8 @@ export function buildCacheDigest({ objectId, headTree, rustUnits = [], npmUnits
1128
1167
  try { manifest = manifestCompileProjection(readBlob(manifestPath)); } catch { manifest = ["raw", manifestPath, idOf(manifestPath)]; }
1129
1168
  return canonicalJson({ kind: "package-list", unit, dir: [head.dir, idOf(head.dir)], manifest, lock: [[crateOf(head), lock.get(crateOf(head))?.signatures ?? []]] });
1130
1169
  }
1131
- return whole();
1170
+ // GC-A24: a package's tsc, eslint and biome rows are keyed on its workspace closure, not the whole tree (acceptance S3 saw tsc rerun for an rk edit).
1171
+ return npmScanKey(scan) ?? whole();
1132
1172
  } catch (error) { onKeyError?.(scan, error); return null; }
1133
1173
  }
1134
1174
  if (scan.class !== "B") return null;
@@ -1137,21 +1177,13 @@ export function buildCacheDigest({ objectId, headTree, rustUnits = [], npmUnits
1137
1177
  // every member it names: each member's own compile key, in member order, plus the batch's own id and command (its member list, target and
1138
1178
  // environment). Any member that falls back to the whole tree makes the batch fall back too. A changed member changes the key, so the
1139
1179
  // batch runs again as a whole (cargo is incremental); no member's result is ever taken from another invocation's.
1140
- if (/^(?:clippy|check):batch:/.test(String(scan.id)) && Array.isArray(scan.batch?.units) && scan.batch.units.length && scan.batch.units.every((n) => known.has(n))) {
1180
+ if (/^(?:clippy|check|doc):batch:/.test(String(scan.id)) && Array.isArray(scan.batch?.units) && scan.batch.units.length && scan.batch.units.every((n) => known.has(n))) {
1141
1181
  const keys = scan.batch.units.map((n) => rustUnitKey(n, scan));
1142
1182
  return keys.includes(undefined) ? whole() : canonicalJson({ kind: "rust-batch", id: scan.id, units: scan.batch.units.map((n, i) => [n, keys[i]]) });
1143
1183
  }
1144
1184
  const unit = rustUnitOfScanId(scan.id, known);
1145
1185
  if (!unit) {
1146
- if (typeof readBlob !== "function") return whole();
1147
- // npm package scans: the package's workspace closure plus the root npm inputs.
1148
- const npmMatch = /^(test:npm|tsc|eslint|biome):(.+)$/.exec(scan.id);
1149
- if (npmMatch && npmByUnit.has(npmMatch[2])) {
1150
- const { members, unresolved } = npmClosure(npmByUnit.get(npmMatch[2]));
1151
- if (unresolved) return whole();
1152
- return canonicalJson({ kind: "npm", id: scan.id, members: members.map((m) => [m.name, m.dir, idOf(m.dir)]), shared: sharedNpmInputs(members) });
1153
- }
1154
- return whole();
1186
+ return npmScanKey(scan) ?? whole();
1155
1187
  }
1156
1188
  const keyed = rustUnitKey(unit, scan);
1157
1189
  return keyed === undefined ? whole() : keyed;
@@ -2334,6 +2366,9 @@ export function committedSidecarConfigs({ o, git, commit, appDir = ".", base })
2334
2366
  * staged files become immutable `staged` ledger entries. Returns true when nothing is owed or staging passed.
2335
2367
  */
2336
2368
  export async function stageSidecarsOnce({ o, ds, root, git = null, configs, appDir, cli, commonDir, commit, tree, stage, executor = null, tag = "rightkit-gate:", target = null }) {
2369
+ // The `dev` stage stages in dev mode (RIGHTKIT_BUILD_MODE=dev, the mode `right-release dev` gives every step it runs): the app's own `stage-sidecar` step in its dev build then finds the
2370
+ // same mode, features and bytes already staged and changes nothing. Staged in release mode first, its dev re-stage rewrote pulse-engine, membrane and the receipt, which the ledger refuses as a
2371
+ // changed staged entry (Pulse Mac dev install, 2026-11-06; docs/GATE-CONTRACT.md [GC-A28]).
2337
2372
  // Once per door run PER TARGET TRIPLE: `target` null is the host (the compile stage: stage-sidecar's own default, no `--target` passed), anything else is the triple the
2338
2373
  // package recipe stages for (universal-apple-darwin on a Mac recipe with `stageSidecars`), passed to stage-sidecar as `--target`. stage-sidecar is a no-op for a target whose
2339
2374
  // receipt and files are already current, so the recipe's own prepare step afterwards changes nothing.
@@ -2354,7 +2389,7 @@ export async function stageSidecarsOnce({ o, ds, root, git = null, configs, appD
2354
2389
  let r;
2355
2390
  try {
2356
2391
  o.out(`${tag} [${stage}] right-release stage-sidecar --config ${path.join(ds.path, config)}${target ? ` --target ${target}` : ""} (from the snapshot ${ds.path})`);
2357
- r = (o.spawnCapture ?? ((cmd, a, opts) => spawnInherit(cmd, a, { ...opts, encoding: "utf8", maxBuffer: 1 << 26 })))(process.execPath, [cli, "stage-sidecar", "--config", path.join(ds.path, config), ...(target ? ["--target", target] : []), "--json"], { cwd: snapshotAppRootOf(ds.path, appDir), env: carriedEnv(carrier, { ...cleanEnv, ...run.env }) });
2392
+ r = (o.spawnCapture ?? ((cmd, a, opts) => spawnInherit(cmd, a, { ...opts, encoding: "utf8", maxBuffer: 1 << 26 })))(process.execPath, [cli, "stage-sidecar", "--config", path.join(ds.path, config), ...(target ? ["--target", target] : []), "--json"], { cwd: snapshotAppRootOf(ds.path, appDir), env: carriedEnv(carrier, { ...cleanEnv, ...run.env, ...(stage === "dev" ? { RIGHTKIT_BUILD_MODE: "dev" } : {}) }) });
2358
2393
  } finally { endRun(run); }
2359
2394
  const carriedOk = await carrier.finish({ stage });
2360
2395
  if (r?.stderr) o.err(String(r.stderr).trimEnd());
@@ -3199,6 +3234,35 @@ export function readAnsweringRoots({ endpoint, identity, connect = (target) => n
3199
3234
  });
3200
3235
  }
3201
3236
 
3237
+ /**
3238
+ * NN41: the installed broker runtime's identity as one string (`<version>:<brokerDigest>:<clientDigest>` from the `runtime-manifest.json` beside the client), or null when it cannot
3239
+ * be read. A cached compile failure is keyed on it, so a broker or toolchain change inside the runtime reruns the failure; with no identity no failure is ever cached.
3240
+ * `clients` are tried in order; a bare name is looked up on PATH (a .exe/.cmd/.bat on win32).
3241
+ */
3242
+ export function brokerRuntimeIdentityText({ clients, env = {}, platform = process.platform, readFile = (f) => fs.readFileSync(f, "utf8"), realpath = (f) => fs.realpathSync.native(f), exists = fs.existsSync } = {}) {
3243
+ const sep = platform === "win32" ? ";" : ":";
3244
+ const pathKey = Object.keys(env).find((k) => k.toLowerCase() === "path") ?? "PATH";
3245
+ const candidates = (client) => {
3246
+ const name = String(client ?? ""); if (!name) return [];
3247
+ if (/[\\/]/.test(name)) return [name];
3248
+ const exts = platform === "win32" ? ["", ".exe", ".cmd", ".bat"] : [""];
3249
+ return String(env[pathKey] ?? "").split(sep).filter(Boolean).flatMap((dir) => exts.map((e) => path.join(dir, `${name}${e}`)));
3250
+ };
3251
+ for (const client of clients ?? []) {
3252
+ for (const candidate of candidates(client)) {
3253
+ try {
3254
+ if (!exists(candidate)) continue;
3255
+ let file = candidate;
3256
+ try { file = resolveBrokerClient(candidate, { platform, readFile }).file; } catch { continue; }
3257
+ let real = file; try { real = realpath(file); } catch { real = file; }
3258
+ const identity = parseRuntimeIdentity(readFile(path.join(path.dirname(real), RUNTIME_MANIFEST_FILE)));
3259
+ if (identity.ok) return `${identity.identity.version}:${identity.identity.brokerDigest}:${identity.identity.clientDigest}`;
3260
+ } catch { /* the next candidate */ }
3261
+ }
3262
+ }
3263
+ return null;
3264
+ }
3265
+
3202
3266
  /** The declared Linux broker's data root: what it reports on the wire (the validated client, its runtime manifest, the declared endpoint), `{ ok, dataRoot }` or `{ ok: false, problem }`. */
3203
3267
  export async function queryBrokerDataRoot(o, executor) {
3204
3268
  try {
@@ -3456,6 +3520,16 @@ async function runDevTest(o, args, root, git, io, to, appRoot, appDir) {
3456
3520
  }
3457
3521
  const commonDir = path.resolve(root, common);
3458
3522
  const source = ds ? sourceSplitOf({ root, ds, appDir }) : null;
3523
+ // The snapshot's `.git` is a config-only stub, so right-release cannot count commits there (assembled-app.mjs commitCount, ASSEMBLY_VERSION_UNAVAILABLE): the gate
3524
+ // counts the commit in the checkout and hands the number down (docs/GATE-CONTRACT.md [GC-A28]). A shallow history or an unreadable count hands down nothing and says
3525
+ // so; only an app whose build stamps CFBundleVersion needs the number, and right-release refuses there (it cannot count in the stub either).
3526
+ let buildNumber = {};
3527
+ if (ds) {
3528
+ const shallow = git("rev-parse", "--is-shallow-repository");
3529
+ const count = failed(shallow) || text(shallow).trim() === "true" ? null : git("rev-list", "--count", commit);
3530
+ if (count && !failed(count) && /^[1-9][0-9]*$/.test(text(count).trim())) buildNumber = { RIGHT_BUILD_NUMBER: text(count).trim() };
3531
+ else o.out(`${tag} note: no build number for ${commit.slice(0, 12)} (the checkout is shallow or cannot count its history); an app that stamps CFBundleVersion will refuse with ASSEMBLY_VERSION_UNAVAILABLE`);
3532
+ }
3459
3533
  // GB-58 (GATE dev/test exact stage; E19): the selected app's declared sidecars are staged ONCE under this snapshot's ownership before the dependent
3460
3534
  // build, through the same planner and ledger as the compile and package stages (a Tauri crate with externalBin refuses to build without them). The
3461
3535
  // app's own prepare step may stage them too; the ledger's attribution check, not an environment marker, is what keeps that single and exact.
@@ -3480,7 +3554,7 @@ async function runDevTest(o, args, root, git, io, to, appRoot, appDir) {
3480
3554
  // The door's own RightKit runs every sub-step: a dev target's `right-release web-build|stage-sidecar` steps resolve `right-release`
3481
3555
  // 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
3482
3556
  // door's 0.6.9 admitted). An installed gate (node_modules/@rightkit/release/bin) has its package's bin shims two levels up.
3483
- const childEnv = carriedEnv(carrier, { ...o.env, ...run.env }, { ...doorPath({ ...o, env: { ...o.env, ...carrier.env } }), ...(pin.dir ? { CARGO_TARGET_DIR: pin.dir } : (pinMulti?.env ?? {})) });
3557
+ const childEnv = carriedEnv(carrier, { ...o.env, ...run.env, ...buildNumber }, { ...doorPath({ ...o, env: { ...o.env, ...carrier.env } }), ...(pin.dir ? { CARGO_TARGET_DIR: pin.dir } : (pinMulti?.env ?? {})) });
3484
3558
  // 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.
3485
3559
  if (to === "render") {
3486
3560
  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);
@@ -4762,7 +4836,7 @@ export async function main(argv, io = {}) {
4762
4836
  let scanTools;
4763
4837
  try {
4764
4838
  scanTools = await (o.loadScanToolPolicy ?? (async (q) => (await import("../scan-tool-enrolment.mjs")).loadScanToolPolicy(q)))({
4765
- dataRoot: resolveManagedRoots({ env: o.env, platform: o.platform }).dataRoot, platform: o.platform, gateFile: callingGatePath(), checkout: root, fromPipeline: scanToolPolicyFromPipeline, // reads the gate's own repository with real git, never the run's (possibly injected) spawn
4839
+ dataRoot: resolveManagedRoots({ env: o.env, platform: o.platform }).gateRoot, platform: o.platform, gateFile: callingGatePath(), checkout: root, fromPipeline: scanToolPolicyFromPipeline, // reads the gate's own repository with real git, never the run's (possibly injected) spawn
4766
4840
  });
4767
4841
  } catch (error) { o.err(`${tag} BLOCKED: ${error.code ?? "RK_SCAN_TOOLS"}: ${error.message}; no scan ran`); return 1; }
4768
4842
  const enrolledTools = Object.keys(scanTools?.policy ?? {});
@@ -4780,6 +4854,8 @@ export async function main(argv, io = {}) {
4780
4854
  // 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.
4781
4855
  ...(snapshot ? { trackedFiles: files } : {}),
4782
4856
  classes: classAOnly ? ["A"] : classAEarlier ? ["B"] : ["A", "B"], ...(classAEarlier ? { classAEarlier: true } : {}), jobs, testJobs, classBJobs, classBBatching: !o[PRIVATE_SCOPED_COMPILE] && 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 } : {}),
4857
+ // NN41: the installed broker runtime's identity keys every cached compile failure; null (a direct host, an unreadable manifest) means no failure is cached.
4858
+ ...(brokerHost && cache ? (() => { const identity = brokerRuntimeIdentityText({ clients: [brokerClient, executor?.client, cargoCommand[0]], env: { ...o.env, ...(executor.env ?? {}) }, platform: o.platform }); return identity ? { failureIdentity: identity } : {}; })() : {}),
4783
4859
  ...(census ? { spawn: census.wrapSpawn(defaultSpawnAsync) } : {}),
4784
4860
  // 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
4785
4861
  // executor's validated client, never a PATH lookup (withDeclaredClient).
@@ -4818,7 +4894,7 @@ export async function main(argv, io = {}) {
4818
4894
  } catch { return null; }
4819
4895
  })(),
4820
4896
  ...(unionScheduler ? { scheduleClassB: unionScheduler } : {}),
4821
- 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)}` : ""}`),
4897
+ onResult: (row, p) => o.out(`${tag} [${p.done}/${p.total}] ${(row.cached ? (row.status === "pass" ? "cached" : "cached-fail") : row.status).padEnd(11)} ${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)}` : ""}`),
4822
4898
  });
4823
4899
  if (nodeCheckRejects.size) o.out(`${tag} node-check cache misses: ${[...nodeCheckRejects].sort(([a], [b]) => a.localeCompare(b)).map(([reason, count]) => `${reason}=${count}`).join(", ")}`);
4824
4900
  if (snapFullA && o.env.RIGHTKIT_PREPARATION_DIAGNOSTIC_DIR && nodeCheckDiagnosticId) o.out(`${tag} node-check diagnostic row: ${nodeCheckDiagnosticState}`);
@@ -5037,6 +5113,8 @@ const invokedDirectly = (() => {
5037
5113
  * path (rustright reads it from RUSTRIGHT_CALLING_GATE; a missing or different path is refused). */
5038
5114
  export const callingGatePath = () => fs.realpathSync(fileURLToPath(import.meta.url));
5039
5115
  if (invokedDirectly) {
5116
+ // GC-A27 NN07-NN12: with RK_GATE_SPAWN_LEDGER set, every child process of this run is recorded (spawn-ledger.mjs). Off otherwise.
5117
+ installSpawnLedger();
5040
5118
  // Every child this run starts that can reach rustright (scans, unit stages, right-release dev/test, their builds) inherits it.
5041
5119
  process.env.RUSTRIGHT_CALLING_GATE = callingGatePath();
5042
5120
  delete process.env.RIGHTKIT_CALLING_GATE; // one spelling, never both
@@ -133,7 +133,7 @@ function mainWith(argv, { env, platform, run, log, err, judged = new Set(), conf
133
133
  const at = rest.indexOf("--manifest-path");
134
134
  const manifestPath = at >= 0 ? rest[at + 1] : undefined;
135
135
  if (platform !== "darwin" && platform !== "win32") { log(`right-release build-helpers ${sub}: nothing to do on ${platform}; only broker hosts (Mac, Dell) vet build helpers`); return 0; }
136
- const listFile = hostListPath(resolveManagedRoots({ env, platform }).dataRoot, platform);
136
+ const listFile = hostListPath(resolveManagedRoots({ env, platform }).gateRoot, platform);
137
137
  let inv;
138
138
  try { inv = inventory({ manifestPath, run, platform }); } catch (e) { err(`right-release build-helpers: ${e.message}`); return 2; }
139
139
  // The host's own list and the repository's committed list (.rightkit/build-helper-trace.json): CI and every host read the same reviewed
@@ -121,7 +121,7 @@ export function ownershipFile({ platform = process.platform, home, beside, repos
121
121
  if (typeof beside !== "string" || beside === "") throw new TypeError(`ownershipFile: beside must be a path (${JSON.stringify(beside)})`);
122
122
  return paths.join(paths.dirname(beside), OWNERSHIP_DIRNAME, repository, "owner.json");
123
123
  }
124
- if (platform === "darwin" || platform === "win32") return paths.join(resolveManagedRoots({ env: {}, platform, home: "" }).dataRoot, OWNERSHIP_DIRNAME, repository, "owner.json");
124
+ if (platform === "darwin" || platform === "win32") return paths.join(resolveManagedRoots({ env: {}, platform, home: "" }).gateRoot, OWNERSHIP_DIRNAME, repository, "owner.json");
125
125
  let base = home;
126
126
  if (base === undefined) {
127
127
  try { base = os.userInfo().homedir; } catch (e) { throw new OwnershipBusy(`build ownership: this account's home directory cannot be read (${e.message}), so the repository's owner record has no location`); }
@@ -138,7 +138,7 @@ export function ownershipFile({ platform = process.platform, home, beside, repos
138
138
  */
139
139
  function guardManagedRoot(file, { platform, managedRoot, device }) {
140
140
  if (platform !== "darwin" && platform !== "win32") return;
141
- const root = managedRoot ?? resolveManagedRoots({ env: {}, platform, home: "" }).dataRoot;
141
+ const root = managedRoot ?? resolveManagedRoots({ env: {}, platform, home: "" }).gateRoot;
142
142
  if (managedRoot === undefined) {
143
143
  const paths = platform === "win32" ? path.win32 : path.posix;
144
144
  const fold = (x) => paths.resolve(x).toLowerCase(); // both volumes are case-insensitive by default
@@ -22,7 +22,7 @@ export function managedCargoShimOnPath(env = process.env, platform = process.pla
22
22
  for (const extension of extensions) {
23
23
  const candidate = pathApi.join(directory, `cargo${extension.toLowerCase()}`);
24
24
  if (!exists(candidate)) continue;
25
- return /(?:^|\/)(?:\.rightkit-managed|rightkitmanagedagent|rightkit\/build-control)\/agent-bin\/cargo(?:\.[^/]*)?$/i
25
+ return /(?:^|\/)(?:\.rightkit-managed|\.rustright|rightkitmanagedagent|rightkit\/build-control|rustright\/build-control)\/agent-bin\/cargo(?:\.[^/]*)?$/i
26
26
  .test(candidate.replaceAll("\\", "/"));
27
27
  }
28
28
  }
package/cargo-guard.mjs CHANGED
@@ -137,7 +137,7 @@ export function resolveRealRustc({ env = process.env, run = spawnSync } = {}) {
137
137
  export function resolveManagedCargoShim({ env = process.env, platform = process.platform, exists = existsSync } = {}) {
138
138
  const win = platform === "win32" || platform === "win";
139
139
  const delimiter = win ? ";" : ":";
140
- const agentBin = /(?:^|[\\/])(?:\.rightkit-managed|rightkitmanagedagent|rightkit[\\/]build-control)[\\/]agent-bin[\\/]?$/i;
140
+ const agentBin = /(?:^|[\\/])(?:\.rightkit-managed|\.rustright|rightkitmanagedagent|rightkit[\\/]build-control|rustright[\\/]build-control)[\\/]agent-bin[\\/]?$/i;
141
141
  // Every extension cargo-contract.mjs managedCargoShimOnPath accepts (PATHEXT, else .COM;.EXE;.BAT;.CMD), so a shim that predicate sees is a shim this finds.
142
142
  const extensions = win ? String(env.PATHEXT ?? ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean).map((extension) => extension.toLowerCase()) : [""];
143
143
  for (const directory of String(env.PATH ?? "").split(delimiter).filter(Boolean)) {
@@ -3,6 +3,7 @@ import path from "node:path";
3
3
  import { spawn } from "../background-process.mjs";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import { assertReleaseExecutionAllowed } from "../execution-policy.mjs";
6
+ import { installSpawnLedger } from "../spawn-ledger.mjs";
6
7
  import { hostUploadRefusalMessage } from "../host-upload-refusal.mjs";
7
8
 
8
9
  const packageRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
@@ -63,6 +64,7 @@ const commands = new Map([
63
64
  ["ios-credentials", "ios-credentials-command.mjs"],
64
65
  ]);
65
66
 
67
+ installSpawnLedger(); // GC-A27: record children when RK_GATE_SPAWN_LEDGER is set
66
68
  const args = process.argv.slice(2);
67
69
  const first = args[0];
68
70
  // The commands that compile, package, sign, ship or inspect a release run the app check (../app-check.mjs, CHECKED_COMMANDS) in this
@@ -146,7 +146,7 @@ export function resolveCredentialProvider({ dataRoot, platform }) {
146
146
  export function updaterCredentialProvider({ env = process.env, hostPlatform = process.platform, dataRoot, resolve = resolveCredentialProvider } = {}) {
147
147
  const platform = providerPlatformOf(hostPlatform);
148
148
  if (!platform) return { file: "rightkit-credentials", managed: false };
149
- return { file: resolve({ dataRoot: dataRoot ?? resolveManagedRoots({ env, platform: hostPlatform }).dataRoot, platform }).file, managed: true };
149
+ return { file: resolve({ dataRoot: dataRoot ?? resolveManagedRoots({ env, platform: hostPlatform }).gateRoot, platform }).file, managed: true };
150
150
  }
151
151
 
152
152
  /** `node credential-provider.mjs enroll --platform mac|win --binary <built rightkit-credentials> --version <v> [--data-root <dir>] [--rotate]` or `show`. */
@@ -155,7 +155,7 @@ export function main(argv, { out = (m) => process.stdout.write(`${m}\n`), err =
155
155
  const opt = (name) => { const i = rest.indexOf(name); return i < 0 ? undefined : rest[i + 1]; };
156
156
  try {
157
157
  const platform = opt("--platform") ?? HOST_PLATFORM[process.platform];
158
- const dataRoot = opt("--data-root") ?? resolveManagedRoots({ env }).dataRoot;
158
+ const dataRoot = opt("--data-root") ?? resolveManagedRoots({ env }).gateRoot;
159
159
  if (command === "enroll") {
160
160
  const r = enrollCredentialProvider({ dataRoot, platform, binary: opt("--binary") && path.resolve(opt("--binary")), version: opt("--version"), rotate: rest.includes("--rotate"), ...(spawn ? { spawn } : {}) });
161
161
  out(`enrolled rightkit-credentials ${r.entry.version} for ${platform} (sha256 ${r.entry.sha256}) at ${r.providerFile}${r.rotated ? " (rotation)" : ""}`);