@rightkit/release 0.6.66 → 0.6.67

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.
@@ -231,7 +231,9 @@ export async function launch({ out, commit, kind = null, receiptsDir, limits = n
231
231
  record.cacheStore = { dir: storeDir, beforeKnown: storeBefore !== null, afterKnown: storeAfter !== null }; record.snapshotStat = { root: snaps.root, folders: Object.keys(snaps.dirs), known: snaps.known };
232
232
  save();
233
233
  try { fs.closeSync(logFd); } catch { /* closed */ }
234
- // The operating system's record of the run's programs, a little either side of the gate's own span.
234
+ // The operating system's record of the run's programs, a little either side of the gate's own span. Windows writes an exit event shortly after the
235
+ // process ends; the record is read two seconds after the gate's exit so a late one is in it (case 7 on 0.6.66, 2026-11-24: one git exit was missing).
236
+ if (!exportProcesses && platform === "win32") await new Promise((resolve) => setTimeout(resolve, 2000));
235
237
  const from = new Date(Date.parse(record.startedAt) - 2000).toISOString(); const to = new Date(Date.now() + 2000).toISOString();
236
238
  const exported = exportProcesses ? exportProcesses(from, to) : platform === "win32" ? exportWindowsProcesses(from, to) : { kind: null, from, to, newest: null, continuous: false, events: [], problems: [`no process record is collected on ${platform} yet (eslogger on the Mac)`] };
237
239
  fs.writeFileSync(path.join(out, "processes.json"), `${JSON.stringify(exported)}\n`);
@@ -20,6 +20,8 @@ import { verifierArgv } from "./acceptance-lines.mjs";
20
20
  import { decideAll, decideCase, decideRealBuild, factsOfRun } from "./acceptance-cases.mjs";
21
21
 
22
22
  const here = path.dirname(fileURLToPath(import.meta.url));
23
+ /** The error case 1 plants in the working checkout (never in the commit). */
24
+ const PLANTED = "pub fn leaf() -> u32 { this does not compile\n";
23
25
  const sha256 = (b) => crypto.createHash("sha256").update(b).digest("hex");
24
26
  const git = (repo, args, opts = {}) => String(execFileSync("git", ["-C", repo, ...args], { encoding: "utf8", windowsHide: true, stdio: ["pipe", "pipe", "pipe"], maxBuffer: 64 * 1024 * 1024, ...opts })).trim();
25
27
  const IDENT = { GIT_AUTHOR_NAME: "acceptance", GIT_AUTHOR_EMAIL: "acceptance@rightkit.invalid", GIT_COMMITTER_NAME: "acceptance", GIT_COMMITTER_EMAIL: "acceptance@rightkit.invalid", GIT_AUTHOR_DATE: "2026-11-24T00:00:00Z", GIT_COMMITTER_DATE: "2026-11-24T00:00:00Z" };
@@ -82,6 +84,9 @@ async function main() {
82
84
 
83
85
  if (fixture) {
84
86
  const pinned = cases.fixture.commit; if (git(fixture, ["cat-file", "-t", pinned]) !== "commit") throw new Error(`the fixture has no commit ${pinned}`);
87
+ // A run killed during case 1 cannot put back the error it planted: the next run does, and only when that is the one change (anything else refuses).
88
+ { const planted = path.join(fixture, "rk", "crates", "rk-leaf", "src", "lib.rs"); let body = ""; try { body = fs.readFileSync(planted, "utf8"); } catch { body = ""; }
89
+ if (body === PLANTED && git(fixture, ["status", "--porcelain", "--untracked-files=no"]).trim() === "M rk/crates/rk-leaf/src/lib.rs") { git(fixture, ["checkout", "--", "rk/crates/rk-leaf/src/lib.rs"]); console.log("note: the error a killed case 1 planted was still in the checkout; it was put back"); } }
85
90
  if (git(fixture, ["status", "--porcelain", "--untracked-files=no"])) throw new Error("the fixture's working checkout has changes to tracked files; the cases need it clean to start");
86
91
  const storeDir = cacheStoreDir(fixture); const args = ["--to", cases.fixture.stage];
87
92
  const wanted = (opt("--cases") ?? cases.order.join(",")).split(",").map(Number);
@@ -2032,7 +2032,7 @@ export async function rightkitDoorRule(o, args, root, git, io, { unitsFileFlag,
2032
2032
  const id = option("--all-units-exception");
2033
2033
  let granted;
2034
2034
  try {
2035
- const shown = git("show", `${pinned.commit}:${ALL_UNITS_EXCEPTIONS_FILE}`);
2035
+ const shown = git("show", `${PROTECTED_RECORD_REF}:${ALL_UNITS_EXCEPTIONS_FILE}`); // F2: the protected branch's record, never one an agent's own commit adds
2036
2036
  granted = authorizeAllUnits({ id, record: failed(shown) ? null : text(shown), now: o.now ? o.now() : Date.now() });
2037
2037
  } catch (e) {
2038
2038
  if (!e.code?.startsWith("RK_ALL_UNITS_")) throw e;
@@ -2839,15 +2839,26 @@ export function sidecarSourceDirs({ git, commit, result }) {
2839
2839
  * target, the build mode, the gate's own code, Node, the Cargo and Rust variables, and the installed Rust toolchains' channel manifests (rustup rewrites
2840
2840
  * them on every update). Null when the commit cannot be listed.
2841
2841
  */
2842
- export function sidecarSourceKey({ git, commit, config, target, mode, dirs, env = process.env, gateIdentity, nodeVersion = process.version, toolchains = rustupChannelManifests(env) }) {
2842
+ export function sidecarSourceKey(args) { const p = sidecarSourceKeyParts(args); return p ? createHash("sha256").update(JSON.stringify(p)).digest("hex") : null; }
2843
+ export function sidecarSourceKeyParts({ git, commit, config, target, mode, dirs, env = process.env, gateIdentity, nodeVersion = process.version, toolchains = rustupChannelManifests(env) }) {
2843
2844
  const listed = git("ls-tree", "-r", "-z", commit); if (failed(listed)) return null;
2844
2845
  const ancestors = new Set(); for (const d of dirs) { let a = d; for (;;) { ancestors.add(a); if (a === "." || !a.includes("/")) { ancestors.add("."); break; } a = a.slice(0, a.lastIndexOf("/")); } }
2845
2846
  const rootFiles = ["Cargo.toml", "Cargo.lock", "rust-toolchain", "rust-toolchain.toml", ".cargo/config", ".cargo/config.toml"];
2846
2847
  const named = new Set([...ancestors].flatMap((a) => rootFiles.map((f) => (a === "." ? f : `${a}/${f}`))));
2847
2848
  const files = text(listed).split("\0").filter(Boolean).map((l) => { const tab = l.indexOf("\t"); return [l.slice(tab + 1), l.slice(0, tab).split(" ")[2]]; })
2848
2849
  .filter(([p]) => p === config || named.has(p) || dirs.some((d) => d === "." || p.startsWith(`${d}/`)));
2849
- const rustEnv = Object.entries(env ?? {}).filter(([k]) => /^(CARGO_|RUSTFLAGS$|RUSTDOCFLAGS$|RUSTC|RUSTUP_TOOLCHAIN$)/i.test(k)).sort(([a], [b]) => (a < b ? -1 : 1));
2850
- return createHash("sha256").update(JSON.stringify({ schema: "rightkit.sidecar-source/1", config, target, mode, node: nodeVersion, gate: gateIdentity ?? null, env: rustEnv, toolchains, files })).digest("hex");
2850
+ return sidecarKeyParts({ config, target, mode, nodeVersion, gateIdentity, env, toolchains, files });
2851
+ }
2852
+ /**
2853
+ * The parts of the sidecar key, each digested on its own, so a staging that runs again can say which part changed. Only variables that change what Cargo
2854
+ * builds are read: the flags, the toolchain choice, and the profile and build settings. A path the gate or the run picks (a target or home folder, a
2855
+ * wrapper) is left out: it changes on every run without changing the binary (acceptance cases on 0.6.66, 2026-11-24: the key never matched).
2856
+ */
2857
+ export const SIDECAR_KEY_ENV = /^(RUSTFLAGS|RUSTDOCFLAGS|CARGO_ENCODED_RUSTFLAGS|CARGO_BUILD_RUSTFLAGS|CARGO_BUILD_TARGET|RUSTUP_TOOLCHAIN|CARGO_PROFILE_[A-Z0-9_]+)$/i;
2858
+ export function sidecarKeyParts({ config, target, mode, nodeVersion, gateIdentity, env, toolchains, files }) {
2859
+ const d = (v) => createHash("sha256").update(JSON.stringify(v ?? null)).digest("hex").slice(0, 16);
2860
+ const rustEnv = Object.entries(env ?? {}).filter(([k]) => SIDECAR_KEY_ENV.test(k)).sort(([a], [b]) => (a < b ? -1 : 1));
2861
+ return { schema: "rightkit.sidecar-source/2", config: d(config), target: d(target), mode: d(mode), node: d(nodeVersion), gate: d(gateIdentity), env: d(rustEnv), toolchains: d(toolchains), files: d(files) };
2851
2862
  }
2852
2863
  function rustupChannelManifests(env) {
2853
2864
  const home = env?.RUSTUP_HOME || path.join(env?.USERPROFILE || env?.HOME || os.homedir(), ".rustup");
@@ -2888,8 +2899,14 @@ export async function stageSidecarsOnce({ o, ds, root, git = null, configs, appD
2888
2899
  // file is still there with its recorded sha256 (--if-stale); nothing is built. Anything else stages as before.
2889
2900
  const mode = stage === "dev" ? "dev" : "release"; const stateFile = sidecarStateFile(ds.path, { config, target: key, mode });
2890
2901
  let prior = null; try { prior = JSON.parse(fs.readFileSync(stateFile, "utf8")); } catch { prior = null; }
2891
- const keyNow = (dirs) => (git && Array.isArray(dirs) ? sidecarSourceKey({ git, commit, config, target: key, mode, dirs, env: o.env, gateIdentity: gatePackageIdentity(o.gatePackage) }) : null);
2892
- const unchanged = Boolean(prior?.schema === 1 && typeof prior.key === "string" && typeof prior.receipt === "string" && keyNow(prior.dirs) === prior.key && fileSha256(path.join(ds.path, prior.receipt)) === prior.receiptSha256);
2902
+ const partsNow = (dirs) => (git && Array.isArray(dirs) ? sidecarSourceKeyParts({ git, commit, config, target: key, mode, dirs, env: o.env, gateIdentity: gatePackageIdentity(o.gatePackage) }) : null);
2903
+ const keyOf = (parts) => (parts ? createHash("sha256").update(JSON.stringify(parts)).digest("hex") : null);
2904
+ const keyNow = (dirs) => keyOf(partsNow(dirs));
2905
+ const nowParts = prior?.schema === 2 ? partsNow(prior.dirs) : null;
2906
+ const receiptNow = prior?.schema === 2 && typeof prior.receipt === "string" ? fileSha256(path.join(ds.path, prior.receipt)) : null;
2907
+ const unchanged = Boolean(prior?.schema === 2 && nowParts && keyOf(nowParts) === prior.key && receiptNow === prior.receiptSha256);
2908
+ // Why it stages again, in one line, so a missed reuse can be traced from the run's own output.
2909
+ if (!unchanged) o.out(tag + " [" + stage + "] stage-sidecar " + config + " builds: " + (prior?.schema !== 2 ? "no earlier staging is recorded" : !nowParts ? "its sources cannot be read from the commit" : keyOf(nowParts) !== prior.key ? "changed since the last staging: " + (Object.keys(nowParts).filter((k) => nowParts[k] !== prior.parts?.[k]).join(", ") || "unknown part") : "the staged receipt is not the one recorded"));
2893
2910
  let r;
2894
2911
  try {
2895
2912
  o.out(`${tag} [${stage}] right-release stage-sidecar --config ${path.join(ds.path, config)}${target ? ` --target ${target}` : ""}${unchanged ? " --if-stale (its sources are those of the last staging: the staged files are checked, nothing is built)" : ""} (from the snapshot ${ds.path})`);
@@ -2919,7 +2936,7 @@ export async function stageSidecarsOnce({ o, ds, root, git = null, configs, appD
2919
2936
  // The sources this staging was built from, for the next run (NN07). Not recordable (a sidecar not built by Cargo, a package not found): the state is removed.
2920
2937
  try {
2921
2938
  const dirs = git ? sidecarSourceDirs({ git, commit, result }) : null; const k = dirs ? keyNow(dirs) : null; const sha = receiptAbs ? fileSha256(path.join(ds.path, receiptAbs)) : null;
2922
- if (k && sha) { fs.mkdirSync(path.dirname(stateFile), { recursive: true }); const tmp = `${stateFile}.${process.pid}.tmp`; fs.writeFileSync(tmp, `${JSON.stringify({ schema: 1, key: k, dirs, receipt: receiptAbs, receiptSha256: sha })}\n`); fs.renameSync(tmp, stateFile); }
2939
+ if (k && sha) { fs.mkdirSync(path.dirname(stateFile), { recursive: true }); const tmp = `${stateFile}.${process.pid}.tmp`; fs.writeFileSync(tmp, `${JSON.stringify({ schema: 2, key: k, parts: partsNow(dirs), dirs, receipt: receiptAbs, receiptSha256: sha })}\n`); fs.renameSync(tmp, stateFile); }
2923
2940
  else fs.rmSync(stateFile, { force: true });
2924
2941
  } catch (e) { o.out(`${tag} [${stage}] stage-sidecar ${config}: the staging state was not recorded (${e.message}); the next run stages again`); }
2925
2942
  }
@@ -4215,6 +4232,40 @@ export function cargoHomeOf(env, { realpath = fs.realpathSync, homedir = os.home
4215
4232
  return home;
4216
4233
  }
4217
4234
 
4235
+ /** Marks the gate's calls of itself (an io key no command line can set). */
4236
+ export const GATE_SELF = Symbol.for("rightkit-gate.self-call");
4237
+ /** Where Adrian's exception records are read from (F2): the protected branch as last fetched. An agent's commit cannot add one; no fetched branch, no record. */
4238
+ export const PROTECTED_RECORD_REF = "refs/remotes/origin/main";
4239
+ /**
4240
+ * A genuine GitHub-hosted run: GitHub sets all three, and no managed broker runtime is installed on its runners. A variable set by hand on a broker host
4241
+ * does not make one (F3: `GITHUB_ACTIONS=true` alone selected the hosted route, which builds the working checkout with no snapshot).
4242
+ */
4243
+ export function genuineGithubRun({ env = {}, platform = process.platform, exists = fs.existsSync } = {}) {
4244
+ if (env.GITHUB_ACTIONS !== "true" || !env.GITHUB_RUN_ID || !env.RUNNER_OS) return false;
4245
+ const runtime = platform === "win32" ? "D:\\.rustright\\runtime" : platform === "darwin" ? "/Volumes/D/.rustright/runtime" : null;
4246
+ return !(runtime && exists(runtime));
4247
+ }
4248
+ /**
4249
+ * Why a caller's run is refused, or null. `--worktree` reads the working folder, not the commit (F5); `--class-a`, `--all` and `--snapshot` are the gate's
4250
+ * own calls of itself (F6; the git pre-push route, which names none of them, is not touched); `GITHUB_ACTIONS=true` outside a genuine GitHub run selects the
4251
+ * hosted route (F3); `--receipt-in` hands the gate a stage receipt and is the publisher job's only (F7).
4252
+ */
4253
+ export function callerRefusal({ args, env = {}, platform = process.platform, exists = fs.existsSync, selfCall = false }) {
4254
+ if (selfCall) return null;
4255
+ if (args.includes("--worktree")) return "--worktree is refused: the gate checks and builds the selected commit only, never the working folder (GC-A27 NN01)";
4256
+ const own = ["--class-a", "--all", "--snapshot"].filter((f) => args.includes(f));
4257
+ if (own.length) return `${own.join(", ")} ${own.length > 1 ? "are" : "is"} the gate's own call of itself and cannot be passed by a caller; run a stage with --to`;
4258
+ const github = genuineGithubRun({ env, platform, exists });
4259
+ if (env.GITHUB_ACTIONS === "true" && !github) return "GITHUB_ACTIONS=true is refused outside a genuine GitHub-hosted run (GITHUB_RUN_ID and RUNNER_OS set, no managed broker on the host): the hosted route builds the working checkout";
4260
+ if (args.includes("--receipt-in") && !github) return "--receipt-in is refused outside the publisher's GitHub run: a stage receipt is not taken from a caller on this host";
4261
+ return null;
4262
+ }
4263
+ /** Variables the gate drops from a caller's environment: the roots on Mac and Windows (F1), and on every host the scratch root and two guards (step F). */
4264
+ export function ignoredCallerVariable(name, platform = process.platform) {
4265
+ const n = String(name).toUpperCase();
4266
+ if (n === "RIGHTKIT_SCRATCH_ROOT" || n === "RIGHTKIT_STAGE_SIDECAR_ALLOW_NESTED" || n === "RUSTRIGHT_OPERATION_DEADLINE_MS") return true;
4267
+ return (platform === "win32" || platform === "darwin") && /^(RUSTRIGHT|RIGHTKIT)_(DATA_ROOT|MANAGED_ROOT|EXTERNAL_ROOT|GATE_ROOT|CONTROL_ROOT|RUNTIME_ROOT)$/.test(n);
4268
+ }
4218
4269
  export async function main(argv, io = {}) {
4219
4270
  const o = {
4220
4271
  spawn: rememberReads(defaultSpawn), exists: fs.existsSync, readFile: (f) => fs.readFileSync(f, "utf8"), writeFile: fs.writeFileSync, mkdir: fs.mkdirSync, chmod: fs.chmodSync, readdir: fs.readdirSync,
@@ -4224,6 +4275,17 @@ export async function main(argv, io = {}) {
4224
4275
  gateFile: fileURLToPath(import.meta.url), ...io,
4225
4276
  };
4226
4277
  const args = [...argv];
4278
+ // Step F of the Dell sequence (status file 11.7, settled with Gemini, 2026-11-24): what a caller may not choose. The gate's own calls of itself carry
4279
+ // GATE_SELF; a caller's do not.
4280
+ const selfCall = io[GATE_SELF] === true;
4281
+ io = { ...io, [GATE_SELF]: true };
4282
+ {
4283
+ const refused = callerRefusal({ args, env: o.env, platform: o.platform, exists: o.exists, selfCall });
4284
+ if (refused) { o.err(`rightkit-gate: ${refused}`); return 2; }
4285
+ // Variables that move the gate's state or loosen a guard are not read from a caller: they are dropped from the run's environment before anything reads it.
4286
+ const dropped = Object.keys(o.env ?? {}).filter((k) => ignoredCallerVariable(k, o.platform));
4287
+ if (dropped.length) { o.env = Object.fromEntries(Object.entries(o.env).filter(([k]) => !ignoredCallerVariable(k, o.platform))); if (!selfCall) o.err(`rightkit-gate: note: ignored from the environment: ${dropped.join(", ")} (the gate's roots and guards are fixed on this host)`); }
4288
+ }
4227
4289
  if (args.includes("--ci-proof-out")) {
4228
4290
  try {
4229
4291
  const problem = stageArgsProblem(args);
@@ -4625,7 +4687,7 @@ export async function main(argv, io = {}) {
4625
4687
  let record = null; let inRightKit = true;
4626
4688
  if (typeof brokerId === "string" && !brokerId.startsWith("--")) {
4627
4689
  const pinned = (await import("../snapshot.mjs")).resolveCommit(root, option("--commit") ?? "HEAD");
4628
- const shown = git("show", `${pinned.commit}:${BROKER_EXCEPTIONS_FILE}`);
4690
+ const shown = git("show", `${PROTECTED_RECORD_REF}:${BROKER_EXCEPTIONS_FILE}`); // F2: the protected branch's record, never one an agent's own commit adds
4629
4691
  record = failed(shown) ? null : text(shown);
4630
4692
  // The repository identity of the commit decides what an exception must name: RightKit's units, or (every other repository, built whole) nothing.
4631
4693
  inRightKit = rightkitIdentityAt(git, pinned.commit);
@@ -5493,11 +5555,18 @@ export async function main(argv, io = {}) {
5493
5555
  const treeId = text(git("rev-parse", `${headSha}^{tree}`)).trim();
5494
5556
  const common = git("rev-parse", "--git-common-dir");
5495
5557
  if (headSha && treeId && !failed(common) && text(common).trim()) {
5558
+ // Every blob and tree id of the commit from one listing, read the first time an id is asked for (GC-A27 "no waste": one `git ls-tree <sha> -- <path>`
5559
+ // per path was 545 processes a fixture run, 23 s on a quiet Dell and three minutes on a busy one; the commit's ids cannot change during the run).
5560
+ let treeIds = null;
5496
5561
  const objectId = (p) => {
5497
- const r = git("ls-tree", headSha, "--", p);
5498
- if (failed(r)) throw new Error(`git ls-tree failed: ${why(r)}`);
5499
- const line = text(r).split(/\r?\n/).find(Boolean);
5500
- return line ? (line.split("\t")[0].split(/\s+/)[2] ?? null) : null;
5562
+ if (!treeIds) {
5563
+ const r = git("ls-tree", "-r", "-t", "-z", headSha);
5564
+ if (failed(r)) throw new Error(`git ls-tree failed: ${why(r)}`);
5565
+ treeIds = new Map();
5566
+ for (const entry of text(r).split("\0").filter(Boolean)) { const tab = entry.indexOf("\t"); treeIds.set(entry.slice(tab + 1), entry.slice(0, tab).split(/\s+/)[2] ?? null); }
5567
+ }
5568
+ const key = String(p).replaceAll("\\", "/").replace(/^\.\//, "").replace(/\/+$/, "");
5569
+ return key === "" || key === "." ? treeId : (treeIds.get(key) ?? null);
5501
5570
  };
5502
5571
  const storeDir = path.join(path.resolve(root, text(common).trim()), "rightkit-gate-cache");
5503
5572
  if (needsForecast) classBHistory = openClassBHistory({ historyRoot: path.join(gateRunsRoot({ env: o.env, platform: o.platform }), "rightkit-class-a-history"), storeDir, onRestart: cacheRestartNote(o) });
@@ -5870,6 +5939,8 @@ export async function main(argv, io = {}) {
5870
5939
  if (notRun.length) o.out(`${tag} class A partial: ${notRun.length} check(s) that execute repository code (tests, typecheck, lint, generated docs) run in the full gate, not in check: ${notRun.slice(0, 8).join(", ")}${notRun.length > 8 ? ", …" : ""}`);
5871
5940
  if (!recordHistory()) return 1;
5872
5941
  o.out(`${tag} class A content pass: ${scanResult.scans.length} deterministic scan(s) over ${changed.length} file(s) of ${base}`);
5942
+ // F4 (step F, 2026-11-24): a check that skipped the scans that execute repository code is not a pass. Exit 3, as --only's partial run does.
5943
+ if (notRun.length) { o.out(`${tag} PARTIAL: ${notRun.length} executing check(s) did not run; run it with --full-a, or run the stage with --to`); return 3; }
5873
5944
  return 0;
5874
5945
  }
5875
5946
  if (!recordHistory()) return 1;
@@ -2303,7 +2303,11 @@ const READ_MEMO = new Map();
2303
2303
  export function isRememberedRead(command, args) {
2304
2304
  const name = String(command).replaceAll("\\", "/").split("/").pop().replace(/\.(exe|cmd|bat)$/i, "").toLowerCase();
2305
2305
  const a = (args ?? []).map(String);
2306
- if (name === "pnpm") return a.length === 1 && a[0] === "--version";
2306
+ // A tool's own version, asked with nothing else (each lane and pass asked again: acceptance cases on 0.6.66, 2026-11-24).
2307
+ if (a.length === 1 && ["--version", "-version", "-V", "version"].includes(a[0])) return true;
2308
+ if (name === "cargo-audit" && a.length === 2 && a[0] === "audit" && a[1] === "--version") return true;
2309
+ // pnpm's resolved configuration of a folder (its .npmrc chain), which nothing in a run writes.
2310
+ if (name === "pnpm") return (a.length === 2 && a[0] === "config" && a[1] === "list") || (a.length === 3 && a[0] === "config" && a[1] === "list" && a[2] === "--json") || (a.length === 3 && a[0] === "config" && a[1] === "get" && /^[a-z-]+$/i.test(a[2]));
2307
2311
  if (name !== "git") return false;
2308
2312
  // git's own leading options (-c key=value, -C dir) are part of the key; the subcommand is what is judged.
2309
2313
  let i = 0; while (i < a.length && (a[i] === "-c" || a[i] === "-C")) i += 2;
@@ -2313,11 +2317,11 @@ export function isRememberedRead(command, args) {
2313
2317
  if (sub[0] === "ls-tree" && sub.length >= 2 && /^[0-9a-f]{40}$/.test(sub[sub.length - 1]) && sub.slice(1, -1).every((a) => /^-[a-z]$|^--name-only$|^--full-tree$/.test(a))) return true;
2314
2318
  return sub.length === 2 && sub[0] === "rev-parse" && sub[1] === "--show-toplevel";
2315
2319
  }
2320
+ const readMemoKey = (command, args, options = {}) => { const env = options.env ? Object.keys(options.env).sort().map((k) => `${k}=${options.env[k]}`).join("\0") : ""; return sha256(JSON.stringify([String(command), args, path.resolve(options.cwd ?? process.cwd()), env])); };
2316
2321
  export function rememberReads(spawn, { store = READ_MEMO } = {}) {
2317
2322
  return (command, args, options = {}) => {
2318
2323
  if (!isRememberedRead(command, args) || options.input !== undefined || options.stdio !== undefined) return spawn(command, args, options);
2319
- const env = options.env ? Object.keys(options.env).sort().map((k) => `${k}=${options.env[k]}`).join("\0") : "";
2320
- const key = sha256(JSON.stringify([String(command), args, path.resolve(options.cwd ?? process.cwd()), options.encoding ?? null, env]));
2324
+ const key = readMemoKey(command, args, options);
2321
2325
  if (store.has(key)) return { ...store.get(key) };
2322
2326
  const r = spawn(command, args, options);
2323
2327
  if (r && r.status === 0 && !r.error) store.set(key, { status: 0, signal: null, stdout: r.stdout, stderr: r.stderr });
@@ -2380,6 +2384,15 @@ export function killProcessTree(child, { platform = process.platform, run = spaw
2380
2384
  * With `options.stdoutFile`, stdout is written to that file whole instead of kept in memory.
2381
2385
  */
2382
2386
  export function defaultSpawnAsync(command, args, options = {}) {
2387
+ // GC-A27 NN08: the reads rememberReads keeps are answered from the same memory here, and an answer this path gets is kept for both.
2388
+ if (isRememberedRead(command, args) && options.input === undefined && options.stdio === undefined && !options.stdoutFile && !options.onSpawn && !options.signal) {
2389
+ const key = readMemoKey(command, args, options);
2390
+ if (READ_MEMO.has(key)) return Promise.resolve({ ...READ_MEMO.get(key) });
2391
+ return rawSpawnAsync(command, args, options).then((r) => { if (r && r.status === 0 && !r.error) READ_MEMO.set(key, { status: 0, signal: null, stdout: r.stdout, stderr: r.stderr }); return r; });
2392
+ }
2393
+ return rawSpawnAsync(command, args, options);
2394
+ }
2395
+ function rawSpawnAsync(command, args, options = {}) {
2383
2396
  const { signal, stdoutFile, stdoutKeep = OUTPUT_KEEP, onSpawn, ...rest } = options;
2384
2397
  const inv = resolveInvocation(command, args, { env: rest.env ?? process.env });
2385
2398
  if (inv.error) return Promise.resolve({ status: null, stdout: "", stderr: "", error: inv.error });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rightkit/release",
3
- "version": "0.6.66",
3
+ "version": "0.6.67",
4
4
  "description": "Portable release CLI/SDK with fail-closed public GitHub Releases and private R2 + RightApps distribution.",
5
5
  "license": "MIT OR Apache-2.0",
6
6
  "type": "module",
@@ -91,7 +91,7 @@
91
91
  ],
92
92
  "sideEffects": false,
93
93
  "scripts": {
94
- "test": "node --test acceptance-admission.test.mjs acceptance-lines.test.mjs acceptance-cases.test.mjs rule-verdict-cache.test.mjs class-b-dispatch.test.mjs remember-reads.test.mjs sidecar-source.test.mjs class-a-cache-history.test.mjs gate-fixed-levers.test.mjs broker-toolchain.test.mjs snapshot-changes.test.mjs gate-serve-changes.test.mjs gate-serve-helper.test.mjs resident-answers.test.mjs probe-memo-kept.test.mjs class-a-lanes.test.mjs feature-partition-targets.test.mjs class-b-target-groups.test.mjs unit-list-lock.test.mjs cargo-profile-check.test.mjs cargo-home-real-path.test.mjs class-a-cache-admission.test.mjs class-b-cache-admission.test.mjs shellcheck-cache-inputs.test.mjs implicit-features.test.mjs test-group-failure-cache.test.mjs sealed-listing-store.test.mjs gate/gate.test.mjs package-files.test.mjs host-gate.test.mjs publish-local-cargo.test.mjs affected-units.test.mjs batch-workspace.test.mjs unit-list-plan.test.mjs compile-inputs.test.mjs snapshot-dependency-reuse.test.mjs publisher-requirement-scan.test.mjs node-check-cache.test.mjs preparation-diagnostics.test.mjs gate-coverage-timing.test.mjs ci-compile-admission.test.mjs qualification-verify.test.mjs test-run-output.test.mjs feature-partition.test.mjs feature-sets.test.mjs gate-seam.test.mjs serial-row.test.mjs seam-repairs.test.mjs snapshot-lock.test.mjs lock-identity.test.mjs stamp-relay.test.mjs install-tauri-authenticode.test.mjs gate-stage-binding.test.mjs tool-output.test.mjs publication-gate.test.mjs gate-release-admission.test.mjs cache-key-explain.test.mjs external-inputs.test.mjs built-bins.test.mjs probe-memo.test.mjs gate-serve-ask.test.mjs double-pass.test.mjs tool-version-memo.test.mjs workspace-manifests.test.mjs test-failure-cache.test.mjs served-metadata.test.mjs windows-pnpm-identity.test.mjs",
94
+ "test": "node --test acceptance-admission.test.mjs acceptance-lines.test.mjs acceptance-cases.test.mjs rule-verdict-cache.test.mjs class-b-dispatch.test.mjs remember-reads.test.mjs sidecar-source.test.mjs caller-levers.test.mjs class-a-cache-history.test.mjs gate-fixed-levers.test.mjs broker-toolchain.test.mjs snapshot-changes.test.mjs gate-serve-changes.test.mjs gate-serve-helper.test.mjs resident-answers.test.mjs probe-memo-kept.test.mjs class-a-lanes.test.mjs feature-partition-targets.test.mjs class-b-target-groups.test.mjs unit-list-lock.test.mjs cargo-profile-check.test.mjs cargo-home-real-path.test.mjs class-a-cache-admission.test.mjs class-b-cache-admission.test.mjs shellcheck-cache-inputs.test.mjs implicit-features.test.mjs test-group-failure-cache.test.mjs sealed-listing-store.test.mjs gate/gate.test.mjs package-files.test.mjs host-gate.test.mjs publish-local-cargo.test.mjs affected-units.test.mjs batch-workspace.test.mjs unit-list-plan.test.mjs compile-inputs.test.mjs snapshot-dependency-reuse.test.mjs publisher-requirement-scan.test.mjs node-check-cache.test.mjs preparation-diagnostics.test.mjs gate-coverage-timing.test.mjs ci-compile-admission.test.mjs qualification-verify.test.mjs test-run-output.test.mjs feature-partition.test.mjs feature-sets.test.mjs gate-seam.test.mjs serial-row.test.mjs seam-repairs.test.mjs snapshot-lock.test.mjs lock-identity.test.mjs stamp-relay.test.mjs install-tauri-authenticode.test.mjs gate-stage-binding.test.mjs tool-output.test.mjs publication-gate.test.mjs gate-release-admission.test.mjs cache-key-explain.test.mjs external-inputs.test.mjs built-bins.test.mjs probe-memo.test.mjs gate-serve-ask.test.mjs double-pass.test.mjs tool-version-memo.test.mjs workspace-manifests.test.mjs test-failure-cache.test.mjs served-metadata.test.mjs windows-pnpm-identity.test.mjs",
95
95
  "test:registry-parity": "node registry-parity.mjs --allow-unpublished",
96
96
  "test:signer:windows": "node sign-release-manifest.integration.mjs",
97
97
  "prepublishOnly": "pnpm test:signer:windows && pnpm test:registry-parity",
@@ -49,7 +49,7 @@
49
49
  "@rightkit/qa": "0.7.0",
50
50
  "@rightkit/qa-chrome": "0.1.12",
51
51
  "@rightkit/react-shell": "0.7.6",
52
- "@rightkit/release": "0.6.66",
52
+ "@rightkit/release": "0.6.67",
53
53
  "@rightkit/send-ui": "0.1.0",
54
54
  "@rightkit/settings-ui": "0.7.5",
55
55
  "@rightkit/social-ui": "0.2.1",