@rightkit/release 0.6.63 → 0.6.65
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.
- package/acceptance-cases.json +558 -0
- package/acceptance-cases.mjs +394 -0
- package/acceptance-launch.mjs +28 -11
- package/acceptance-lines.mjs +13 -0
- package/acceptance-run.mjs +129 -0
- package/bin/rightkit-gate.mjs +80 -14
- package/deterministic-scans.mjs +36 -4
- package/gate-seam.mjs +8 -2
- package/package.json +2 -2
- package/rightkit-versions.json +9 -6
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Runs the acceptance cases of acceptance-cases.json against an installed gate and the live broker, and prints the twelve-line verdict (GC-A27; rightkit#1514;
|
|
3
|
+
// Adrian, 2026-11-24: "the 7 fixture cases + 1 real build as the acceptance run").
|
|
4
|
+
//
|
|
5
|
+
// node acceptance-run.mjs --fixture <witness fixture checkout> --out <folder> --gate <installed rightkit-gate.mjs> --managed <managed data root>
|
|
6
|
+
// [--cases 1,2,4,3,5,6,7] [--real <repository>] [--rustright <client>] [--keep-going]
|
|
7
|
+
//
|
|
8
|
+
// What it does to set a case up, and nothing else: removes the fixture's scan store and its history for the case from nothing (both are kept under --out);
|
|
9
|
+
// plants an error in the fixture's working checkout and restores it; makes the case commits as unreferenced commits under refs/witness/acceptance-* and deletes
|
|
10
|
+
// those refs at the end; moves the `license` store files away and puts them back; kills the gate's process tree for the kill case. It hands the gate no variable
|
|
11
|
+
// and no flag beyond the stage. Verdicts come from acceptance-cases.mjs; this file decides nothing.
|
|
12
|
+
import crypto from "node:crypto";
|
|
13
|
+
import fs from "node:fs";
|
|
14
|
+
import os from "node:os";
|
|
15
|
+
import path from "node:path";
|
|
16
|
+
import { execFileSync } from "node:child_process";
|
|
17
|
+
import { fileURLToPath } from "node:url";
|
|
18
|
+
import { cacheStoreDir, launch } from "./acceptance-launch.mjs";
|
|
19
|
+
import { verifierArgv } from "./acceptance-lines.mjs";
|
|
20
|
+
import { decideAll, decideCase, decideRealBuild, factsOfRun } from "./acceptance-cases.mjs";
|
|
21
|
+
|
|
22
|
+
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
23
|
+
const sha256 = (b) => crypto.createHash("sha256").update(b).digest("hex");
|
|
24
|
+
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
|
+
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" };
|
|
26
|
+
|
|
27
|
+
/** An unreferenced commit on `base` with the case's edits (append to a tracked file, or a new file's content), kept alive under refs/witness/acceptance-<name>. No checkout is written. */
|
|
28
|
+
export function caseCommit(repo, base, edits, name, scratch) {
|
|
29
|
+
const idx = path.join(scratch, `index-${name}`); fs.rmSync(idx, { force: true }); const env = { ...process.env, ...IDENT, GIT_INDEX_FILE: idx };
|
|
30
|
+
git(repo, ["read-tree", base], { env });
|
|
31
|
+
for (const e of edits) {
|
|
32
|
+
const body = typeof e.append === "string" ? execFileSync("git", ["-C", repo, "show", `${base}:${e.path}`], { windowsHide: true }).toString("utf8") + e.append : e.content;
|
|
33
|
+
const blob = git(repo, ["hash-object", "-w", "--stdin"], { input: body });
|
|
34
|
+
git(repo, ["update-index", "--add", "--cacheinfo", `100644,${blob},${e.path}`], { env });
|
|
35
|
+
}
|
|
36
|
+
const tree = git(repo, ["write-tree"], { env });
|
|
37
|
+
const commit = git(repo, ["commit-tree", tree, "-p", base, "-m", `acceptance case ${name}`], { env });
|
|
38
|
+
git(repo, ["update-ref", `refs/witness/acceptance-${name}`, commit]); fs.rmSync(idx, { force: true });
|
|
39
|
+
return commit;
|
|
40
|
+
}
|
|
41
|
+
/** The history file the gate keeps for a store (class-a-cache-history.mjs: named after the store's path). */
|
|
42
|
+
export const historyFileOf = (managed, storeDir) => path.join(managed, "runs", "rightkit-class-a-history", `${sha256(path.resolve(storeDir).toLowerCase())}.json`);
|
|
43
|
+
const moveAside = (from, to) => { if (!fs.existsSync(from)) return false; fs.mkdirSync(path.dirname(to), { recursive: true }); fs.renameSync(from, to); return true; };
|
|
44
|
+
/** Ends the gate and every program it started (Windows: the whole tree by pid; elsewhere the process group is the launcher's to signal). */
|
|
45
|
+
const killTree = (pid) => { try { if (process.platform === "win32") execFileSync("taskkill", ["/PID", String(pid), "/T", "/F"], { windowsHide: true, stdio: "ignore" }); else process.kill(pid, "SIGKILL"); } catch { /* already gone */ } };
|
|
46
|
+
|
|
47
|
+
async function main() {
|
|
48
|
+
const argv = process.argv.slice(2); const opt = (n) => { const i = argv.indexOf(n); return i < 0 ? null : argv[i + 1]; };
|
|
49
|
+
const fixture = opt("--fixture"); const out = opt("--out"); const gate = opt("--gate"); const managed = opt("--managed"); const real = opt("--real");
|
|
50
|
+
if (!out || !gate || !managed || (!fixture && !real)) { console.error("usage: acceptance-run.mjs --fixture <dir> --out <dir> --gate <rightkit-gate.mjs> --managed <data root> [--cases 1,2,...] [--real <repo>]"); process.exit(2); }
|
|
51
|
+
const casesFile = path.join(here, "acceptance-cases.json"); const casesBody = fs.readFileSync(casesFile); const cases = JSON.parse(casesBody.toString("utf8"));
|
|
52
|
+
const receiptsDir = path.join(managed, "rightkit-build-control", "receipts");
|
|
53
|
+
const pin = JSON.parse(fs.readFileSync(path.join(managed, "pins", `broker-${process.platform}.json`), "utf8")); const client = opt("--rustright") ?? "rustright";
|
|
54
|
+
const verify = (body) => {
|
|
55
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "rk-verify-")); const file = path.join(dir, "receipt.json"); fs.writeFileSync(file, body);
|
|
56
|
+
const a = verifierArgv({ file, body, key: pin.publicKey, keyId: pin.keyId, host: pin.host, brokerDigest: pin.brokerDigest });
|
|
57
|
+
try { if (!a) return { ok: false, problems: ["the receipt names no job id, nonce or request digest"] }; execFileSync(client, a, { stdio: ["ignore", "pipe", "pipe"], windowsHide: true, shell: process.platform === "win32" }); return { ok: true, problems: [] }; }
|
|
58
|
+
catch (e) { return { ok: false, problems: [String(e.stderr ?? e.message).trim().split(/\r?\n/).pop()] }; }
|
|
59
|
+
finally { fs.rmSync(dir, { recursive: true, force: true }); }
|
|
60
|
+
};
|
|
61
|
+
fs.mkdirSync(out, { recursive: true });
|
|
62
|
+
const record = { schema: "rightkit.acceptance-run/1", casesSha256: sha256(casesBody), gate: path.resolve(gate), startedAt: new Date().toISOString(), cases: {}, realBuild: null };
|
|
63
|
+
const results = {}; const refs = [];
|
|
64
|
+
const one = async (repo, commit, name, { args, kill = false } = {}) => {
|
|
65
|
+
const dir = path.join(out, name); fs.rmSync(dir, { recursive: true, force: true }); fs.mkdirSync(dir, { recursive: true });
|
|
66
|
+
let killed = false; let timer = null;
|
|
67
|
+
const onStart = kill ? ({ child, out: runDir }) => {
|
|
68
|
+
// Killed midway: once the gate says Class A's verdict is written the compile is under way; a little later the whole tree is ended.
|
|
69
|
+
timer = setInterval(() => { let log = ""; try { log = fs.readFileSync(path.join(runDir, "gate.log"), "utf8"); } catch { log = ""; } if (/class A verdict written/i.test(log)) { clearInterval(timer); setTimeout(() => { killed = true; killTree(child.pid); }, 8000); } }, 500);
|
|
70
|
+
} : null;
|
|
71
|
+
const code = await launch({ out: dir, commit, receiptsDir, repo, gate, gateArgs: args, onStart, lock: path.join(out, "acceptance-launch.lock") });
|
|
72
|
+
if (timer) clearInterval(timer);
|
|
73
|
+
let facts = factsOfRun(dir, { repo, receiptsDir, verify, killed });
|
|
74
|
+
// The test programs the receipts sign, hashed now: straight after the run, before anything else can build.
|
|
75
|
+
const imageNow = {};
|
|
76
|
+
for (const j of facts.jobs) for (const exe of Array.isArray(j.testExecutables) ? j.testExecutables : []) { const f = typeof exe === "string" ? exe : exe?.path; if (typeof f !== "string") continue; try { imageNow[f.replace(/^\\\\\?\\/, "").replaceAll("\\", "/").toLowerCase()] = sha256(fs.readFileSync(f.replace(/^\\\\\?\\/, ""))); } catch { /* unreadable: no hash, which fails the line */ } }
|
|
77
|
+
facts = { ...facts, imageNow };
|
|
78
|
+
console.log(` ${name}: exit ${code}${killed ? " (killed)" : ""}, ${Math.round(facts.durationMs / 1000)} s, ${facts.jobs.length} broker job(s), ${facts.starts.length} program(s), ${Array.isArray(facts.cacheWritten) ? facts.cacheWritten.length : "?"} store file(s) written`);
|
|
79
|
+
return facts;
|
|
80
|
+
};
|
|
81
|
+
const lite = (f) => ({ dir: f.dir, commit: f.commit, exit: f.exit, killed: f.killed, durationMs: f.durationMs, jobs: f.jobs.length, programs: f.starts.length, cacheWritten: Array.isArray(f.cacheWritten) ? f.cacheWritten.length : null, processGaps: f.processGaps });
|
|
82
|
+
|
|
83
|
+
if (fixture) {
|
|
84
|
+
const pinned = cases.fixture.commit; if (git(fixture, ["cat-file", "-t", pinned]) !== "commit") throw new Error(`the fixture has no commit ${pinned}`);
|
|
85
|
+
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
|
+
const storeDir = cacheStoreDir(fixture); const args = ["--to", cases.fixture.stage];
|
|
87
|
+
const wanted = (opt("--cases") ?? cases.order.join(",")).split(",").map(Number);
|
|
88
|
+
try {
|
|
89
|
+
for (const id of cases.order.filter((n) => wanted.includes(n))) {
|
|
90
|
+
const def = cases.cases.find((c) => c.id === id); console.log(`case ${id}: ${def.name}`);
|
|
91
|
+
const commit = def.commit === "fixture" ? pinned : caseCommit(fixture, pinned, def.commit.edits, String(id), out);
|
|
92
|
+
if (def.commit !== "fixture") refs.push(`refs/witness/acceptance-${id}`);
|
|
93
|
+
const runs = [];
|
|
94
|
+
if (id === 1) {
|
|
95
|
+
const aside = path.join(out, "set-aside", new Date().toISOString().replace(/[:.]/g, "-"));
|
|
96
|
+
moveAside(storeDir, path.join(aside, "rightkit-gate-cache")); moveAside(historyFileOf(managed, storeDir), path.join(aside, "history.json"));
|
|
97
|
+
const dirty = path.join(fixture, "rk", "crates", "rk-leaf", "src", "lib.rs");
|
|
98
|
+
fs.writeFileSync(dirty, "pub fn leaf() -> u32 { this does not compile\n");
|
|
99
|
+
try { runs.push(await one(fixture, commit, "case1", { args })); } finally { git(fixture, ["checkout", "--", "rk/crates/rk-leaf/src/lib.rs"]); }
|
|
100
|
+
} else if (id === 4) {
|
|
101
|
+
const held = path.join(out, "case4-held"); fs.mkdirSync(held, { recursive: true }); const moved = [];
|
|
102
|
+
for (const n of fs.readdirSync(storeDir).filter((x) => x.endsWith(".json"))) { let d = null; try { d = JSON.parse(fs.readFileSync(path.join(storeDir, n), "utf8")); } catch { d = null; } if (d?.row?.id === "license") { fs.renameSync(path.join(storeDir, n), path.join(held, n)); moved.push(n); } }
|
|
103
|
+
if (!moved.length) throw new Error("case 4: the store holds no result for the row license to delete");
|
|
104
|
+
try { runs.push(await one(fixture, commit, "case4", { args })); } finally { for (const n of moved) if (!fs.existsSync(path.join(storeDir, n))) fs.renameSync(path.join(held, n), path.join(storeDir, n)); }
|
|
105
|
+
} else if (id === 7) {
|
|
106
|
+
runs.push(await one(fixture, commit, "case7-killed", { args, kill: true }));
|
|
107
|
+
runs.push(await one(fixture, commit, "case7-after", { args }));
|
|
108
|
+
} else for (let i = 0; i < (def.runs ?? 1); i += 1) runs.push(await one(fixture, commit, `case${id}${(def.runs ?? 1) > 1 ? `-run${i + 1}` : ""}`, { args }));
|
|
109
|
+
results[id] = decideCase({ ...def, runs }, cases); record.cases[id] = { commit, runs: runs.map(lite), lines: results[id] };
|
|
110
|
+
for (const [line, r] of Object.entries(results[id])) console.log(` ${line} ${r.verdict}: ${r.why}`);
|
|
111
|
+
if (!argv.includes("--keep-going") && runs.some((r) => r.processGaps.length)) console.log(" note: the process record of a run is incomplete; lines that read it fail for that reason");
|
|
112
|
+
}
|
|
113
|
+
} finally { for (const r of refs) { try { git(fixture, ["update-ref", "-d", r]); } catch { /* reported by its absence */ } } }
|
|
114
|
+
}
|
|
115
|
+
let realLines = null;
|
|
116
|
+
if (real) {
|
|
117
|
+
console.log("the real build");
|
|
118
|
+
const commit = git(real, ["rev-parse", "HEAD"]); const facts = await one(real, commit, "real-build", { args: cases.realBuild.args });
|
|
119
|
+
realLines = decideRealBuild(facts, cases); record.realBuild = { repository: real, commit, run: lite(facts), lines: realLines };
|
|
120
|
+
for (const [line, r] of Object.entries(realLines)) console.log(` ${line} ${r.verdict}: ${r.why}`);
|
|
121
|
+
}
|
|
122
|
+
const all = decideAll({ cases, results, realBuild: realLines }); record.endedAt = new Date().toISOString(); record.verdict = all;
|
|
123
|
+
fs.writeFileSync(path.join(out, "verdict.json"), `${JSON.stringify(record, null, 2)}\n`);
|
|
124
|
+
console.log(`\n${all.passed} of ${all.of} lines pass${all.pass ? "; the real build passes its lines: ACCEPTED" : ""}`);
|
|
125
|
+
for (const l of all.lines) console.log(`${l.id} ${l.verdict}${l.verdict === "pass" ? "" : `: ${l.why}`}`.slice(0, 1200));
|
|
126
|
+
for (const l of all.realBuild) console.log(`real build ${l.id} ${l.verdict}${l.verdict === "pass" ? "" : `: ${l.why}`}`.slice(0, 600));
|
|
127
|
+
process.exit(all.pass ? 0 : 1);
|
|
128
|
+
}
|
|
129
|
+
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) main().catch((e) => { console.error(`acceptance-run: ${e.stack ?? e.message}`); process.exit(2); });
|
package/bin/rightkit-gate.mjs
CHANGED
|
@@ -62,11 +62,11 @@
|
|
|
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
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
|
+
// Class A scan concurrency is the host's core count; no caller sets it. 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),
|
|
68
68
|
// so queue time is neither charged to the scan nor bounded by a gate allowance. Only class B suites the broker never sees (npm or node tests run on this host)
|
|
69
|
-
// keep a local limit of 3, one slot per suite. On a host with no broker
|
|
69
|
+
// keep a local limit of 3, one slot per suite. On a host with no broker 3 components' class B scans run at once; one
|
|
70
70
|
// component's scans stay in order (rightkit#1285).
|
|
71
71
|
// A crate whose ci/gate.config.json entry says `quietTests: true` has its test scans run last,
|
|
72
72
|
// one at a time, under the RustRight quiet lease (`rustright quiet acquire`, RUSTRIGHT_QUIET_LEASE in their environment).
|
|
@@ -86,7 +86,7 @@ import { FOREIGN_PRE_COMMIT, retireHooksIn } from "../hook-retirement.mjs";
|
|
|
86
86
|
import { fileURLToPath } from "node:url";
|
|
87
87
|
import { installIdentity, installStateBytes } from "../dependency-identity.mjs";
|
|
88
88
|
import { pnpmVersionAnswer } from "../snapshot-dependency-reuse.mjs";
|
|
89
|
-
import { BIOME_CONFIG_FILES, CHECKER_IDENTITY, OXLINT_CONFIG_FILES, ESLINT_CONFIG_FILES, LOCAL_CLASS_B_JOBS, WORKSPACE_RUST_FILE, ancestorConfigChanged, ancestorDirsOf, canonicalJson, defaultSpawn, defaultSpawnAsync, judgeUnitList, blockedUnitsOf, digestScanSet, fileScanCache, findRustfmt, metadataArgs, planScans, planUnitListScans, publisherRequirementScan, runScans, sidecarBoundCrate, scanToolPolicyFromPipeline, scanDeferrals, scanFailures, seamRunState } from "../deterministic-scans.mjs";
|
|
89
|
+
import { BIOME_CONFIG_FILES, CHECKER_IDENTITY, OXLINT_CONFIG_FILES, ESLINT_CONFIG_FILES, LOCAL_CLASS_B_JOBS, WORKSPACE_RUST_FILE, ancestorConfigChanged, ancestorDirsOf, canonicalJson, defaultSpawn, defaultSpawnAsync, rememberReads, judgeUnitList, blockedUnitsOf, digestScanSet, fileScanCache, findRustfmt, metadataArgs, planScans, planUnitListScans, publisherRequirementScan, runScans, sidecarBoundCrate, scanToolPolicyFromPipeline, scanDeferrals, scanFailures, seamRunState } from "../deterministic-scans.mjs";
|
|
90
90
|
import { changedLockNames, parseLock, reach } from "../lock-graph.mjs";
|
|
91
91
|
import { resolveExecutor } from "../gate-executor.mjs";
|
|
92
92
|
// The gate's own executor: an outer gate's cargo wrapper on PATH is never this gate's cargo (gate-executor.mjs `gateWrappers`).
|
|
@@ -166,7 +166,7 @@ export const MOBILE_PLATFORMS = Object.freeze(new Set(["ios", "android"]));
|
|
|
166
166
|
const CLASS_B_KEY_SCHEMA = "rightkit.class-b-key/3";
|
|
167
167
|
// GC-A24: passing rule-engine verdicts (app rules, RightKit's preflight) of a snapshot, under the checkout's git common directory.
|
|
168
168
|
const RULE_VERDICT_SCHEMA = "rightkit.rule-verdict/1";
|
|
169
|
-
function ruleVerdictCache({ checkout, spawn }) {
|
|
169
|
+
export function ruleVerdictCache({ checkout, spawn }) {
|
|
170
170
|
try {
|
|
171
171
|
const common = spawn("git", ["rev-parse", "--path-format=absolute", "--git-common-dir"], { cwd: checkout });
|
|
172
172
|
if (failed(common) || !text(common).trim()) return null;
|
|
@@ -175,7 +175,8 @@ function ruleVerdictCache({ checkout, spawn }) {
|
|
|
175
175
|
return {
|
|
176
176
|
key: (parts) => createHash("sha256").update(canonicalJson({ schema: RULE_VERDICT_SCHEMA, node: process.version, platform: `${process.platform}-${process.arch}`, ...parts })).digest("hex"),
|
|
177
177
|
passed: (k) => { try { return JSON.parse(fs.readFileSync(file(k), "utf8"))?.status === "pass"; } catch { return false; } },
|
|
178
|
-
|
|
178
|
+
// A pass that is already stored is not written back (GC-A27 NN06: nothing is written for a row whose inputs did not change).
|
|
179
|
+
pass: (k) => { try { if (JSON.parse(fs.readFileSync(file(k), "utf8"))?.status === "pass") return; } catch { /* not stored yet */ } try { fs.mkdirSync(dir, { recursive: true }); const tmp = `${file(k)}.${process.pid}.tmp`; fs.writeFileSync(tmp, JSON.stringify({ schema: RULE_VERDICT_SCHEMA, status: "pass", at: new Date().toISOString() })); fs.renameSync(tmp, file(k)); } catch { /* a cache */ } },
|
|
179
180
|
};
|
|
180
181
|
} catch { return null; }
|
|
181
182
|
}
|
|
@@ -395,11 +396,10 @@ function workspaceMetadata({ root, spawn, cargoCommand, dir, realpath }) {
|
|
|
395
396
|
* Where the gate's own temporary files live (cargo-deny's metadata file and config overlay, read by the broker by absolute path). The
|
|
396
397
|
* RustRight broker refuses paths on the system volume (RK_INTERNAL_DRIVE_REFUSED: agents never write to the internal drive), and
|
|
397
398
|
* os.tmpdir() is on it on every Mac and Dell, so on a host with a disk-policy scratch root (/Volumes/D/scratch, D:\scratch) they go
|
|
398
|
-
* there.
|
|
399
|
+
* there. No caller chooses it; os.tmpdir() is the fallback where no scratch root exists (CI runners, cloud containers). The gate
|
|
399
400
|
* exports nothing and copies no source: this is not a source location (docs/GATE-CONTRACT.md, 2026-10-29: no export or copy).
|
|
400
401
|
*/
|
|
401
402
|
export function gateTmpRoot({ env = process.env, platform = process.platform, exists = fs.existsSync, policy = null } = {}) {
|
|
402
|
-
if (env.RK_GATE_TMPDIR) return env.RK_GATE_TMPDIR;
|
|
403
403
|
try {
|
|
404
404
|
const roots = scratchRoots(policy ?? readDiskPolicy(), { platform, env });
|
|
405
405
|
const found = roots.find((root) => exists(root));
|
|
@@ -2806,6 +2806,57 @@ export function committedSidecarConfigs({ o, git, commit, appDir = ".", base })
|
|
|
2806
2806
|
.filter((f) => { try { return /\bsidecars\b/.test(o.readFile(path.join(base, f))); } catch { return false; } });
|
|
2807
2807
|
}
|
|
2808
2808
|
|
|
2809
|
+
/**
|
|
2810
|
+
* GC-A27 NN07 (a row whose inputs did not change does no work; acceptance case 3 on 0.6.63, 2026-11-24: a one-file edit in another workspace sent the sidecar's
|
|
2811
|
+
* cargo build to the broker on every run). The sources a staging of Cargo-built sidecars reads, from the commit alone: the crate directory of each staged
|
|
2812
|
+
* package and, followed through their manifests, of every path dependency. Null when a staged file is not a cargo-bin, a package is not found, or a path
|
|
2813
|
+
* dependency is not a committed crate: then nothing is skipped.
|
|
2814
|
+
*/
|
|
2815
|
+
export function sidecarSourceDirs({ git, commit, result }) {
|
|
2816
|
+
const files = Array.isArray(result?.files) ? result.files : [];
|
|
2817
|
+
if (!files.length || files.some((f) => f?.kind !== "cargo-bin" || typeof f.package !== "string")) return null;
|
|
2818
|
+
const listed = git("ls-tree", "-r", "-z", commit); if (failed(listed)) return null;
|
|
2819
|
+
const manifests = [];
|
|
2820
|
+
for (const line of text(listed).split("\0").filter(Boolean)) {
|
|
2821
|
+
const tab = line.indexOf("\t"); const p = line.slice(tab + 1); if (!/(^|\/)Cargo\.toml$/.test(p)) continue;
|
|
2822
|
+
const blob = git("cat-file", "-p", line.slice(0, tab).split(" ")[2]); if (failed(blob)) return null;
|
|
2823
|
+
manifests.push({ dir: p.includes("/") ? p.slice(0, p.lastIndexOf("/")) : ".", body: text(blob) });
|
|
2824
|
+
}
|
|
2825
|
+
const nameOf = (body) => { let section = null; for (const l of body.split(/\r?\n/)) { const h = /^\s*\[([^\]]+)\]\s*$/.exec(l); if (h) { section = h[1].trim(); continue; } const n = section === "package" && /^\s*name\s*=\s*"([^"]+)"/.exec(l); if (n) return n[1]; } return null; };
|
|
2826
|
+
// Only the dependency tables name crates: `path =` under [lib] or [[bin]] is a source file.
|
|
2827
|
+
const depPaths = (body) => { const out = []; let deps = false; for (const l of body.split(/\r?\n/)) { const h = /^\s*\[\[?([^\]]+)\]\]?\s*$/.exec(l); if (h) { deps = /(^|\.)(dependencies|dev-dependencies|build-dependencies)(\.|$)|^patch\./.test(h[1].trim()); continue; } if (deps) for (const m of l.matchAll(/\bpath\s*=\s*"([^"]+)"/g)) out.push(m[1]); } return out; };
|
|
2828
|
+
const byName = new Map(manifests.map((m) => [nameOf(m.body), m]).filter(([n]) => n));
|
|
2829
|
+
const queue = [...new Set(files.map((f) => f.package))].map((n) => byName.get(n)); if (queue.some((m) => !m)) return null;
|
|
2830
|
+
const dirs = new Set();
|
|
2831
|
+
while (queue.length) {
|
|
2832
|
+
const m = queue.pop(); if (dirs.has(m.dir)) continue; dirs.add(m.dir);
|
|
2833
|
+
for (const rel of depPaths(m.body)) { const d = path.posix.normalize(path.posix.join(m.dir === "." ? "" : m.dir, rel)).replace(/\/$/, "") || "."; const dep = manifests.find((x) => x.dir === d); if (!dep) return null; queue.push(dep); }
|
|
2834
|
+
}
|
|
2835
|
+
return [...dirs].sort();
|
|
2836
|
+
}
|
|
2837
|
+
/**
|
|
2838
|
+
* The key of those sources: every committed file under the dirs, the Cargo, toolchain and cargo-config files of their ancestors, the release config, the
|
|
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
|
+
* them on every update). Null when the commit cannot be listed.
|
|
2841
|
+
*/
|
|
2842
|
+
export function sidecarSourceKey({ git, commit, config, target, mode, dirs, env = process.env, gateIdentity, nodeVersion = process.version, toolchains = rustupChannelManifests(env) }) {
|
|
2843
|
+
const listed = git("ls-tree", "-r", "-z", commit); if (failed(listed)) return null;
|
|
2844
|
+
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
|
+
const rootFiles = ["Cargo.toml", "Cargo.lock", "rust-toolchain", "rust-toolchain.toml", ".cargo/config", ".cargo/config.toml"];
|
|
2846
|
+
const named = new Set([...ancestors].flatMap((a) => rootFiles.map((f) => (a === "." ? f : `${a}/${f}`))));
|
|
2847
|
+
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
|
+
.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");
|
|
2851
|
+
}
|
|
2852
|
+
function rustupChannelManifests(env) {
|
|
2853
|
+
const home = env?.RUSTUP_HOME || path.join(env?.USERPROFILE || env?.HOME || os.homedir(), ".rustup");
|
|
2854
|
+
try { return fs.readdirSync(path.join(home, "toolchains")).sort().map((n) => { try { const st = fs.statSync(path.join(home, "toolchains", n, "lib", "rustlib", "multirust-channel-manifest.toml")); return [n, st.size, Math.trunc(st.mtimeMs)]; } catch { return [n, null, null]; } }); } catch { return null; }
|
|
2855
|
+
}
|
|
2856
|
+
/** `<managed root>/sidecar-state/<repo key>/<config, target and mode>.json`, beside the snapshot: the key and receipt of the last staging. */
|
|
2857
|
+
const sidecarStateFile = (snapshotPath, { config, target, mode }) => path.join(path.dirname(path.dirname(snapshotPath)), "sidecar-state", path.basename(snapshotPath), `${createHash("sha256").update(JSON.stringify([config, target, mode])).digest("hex").slice(0, 32)}.json`);
|
|
2858
|
+
const fileSha256 = (file) => { try { return createHash("sha256").update(fs.readFileSync(file)).digest("hex"); } catch { return null; } };
|
|
2859
|
+
|
|
2809
2860
|
/**
|
|
2810
2861
|
* Sidecars are staged ONCE per door run, after the sync and before the first stage that builds the Tauri crate. The step is
|
|
2811
2862
|
* right-release's own `stage-sidecar --json` run inside the snapshot (the split); this gate then walks the snapshot itself and the
|
|
@@ -2833,10 +2884,16 @@ export async function stageSidecarsOnce({ o, ds, root, git = null, configs, appD
|
|
|
2833
2884
|
const carrier = await carrierForChildren({ o, ds, root, git, executor, stage, tag, appDir });
|
|
2834
2885
|
if (carrier.refusal) { o.err(`${tag} BLOCKED: ${carrier.refusal}; nothing was staged`); return false; }
|
|
2835
2886
|
const run = startRun({ commonDir, commit, tree, stage, source });
|
|
2887
|
+
// NN07: when the sidecars' own sources are those of the last staging and its receipt is the one in the snapshot, stage-sidecar only checks that every staged
|
|
2888
|
+
// file is still there with its recorded sha256 (--if-stale); nothing is built. Anything else stages as before.
|
|
2889
|
+
const mode = stage === "dev" ? "dev" : "release"; const stateFile = sidecarStateFile(ds.path, { config, target: key, mode });
|
|
2890
|
+
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);
|
|
2836
2893
|
let r;
|
|
2837
2894
|
try {
|
|
2838
|
-
o.out(`${tag} [${stage}] right-release stage-sidecar --config ${path.join(ds.path, config)}${target ? ` --target ${target}` : ""} (from the snapshot ${ds.path})`);
|
|
2839
|
-
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,
|
|
2895
|
+
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})`);
|
|
2896
|
+
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] : []), ...(unchanged ? ["--if-stale"] : []), "--json"], { cwd: snapshotAppRootOf(ds.path, appDir), env: carriedEnv(carrier, { ...cleanEnv, ...run.env, RIGHTKIT_BUILD_MODE: stage === "dev" ? "dev" : "release" }) }); // set, never inherited: the sidecar key names this mode (GC-A27 NN07)
|
|
2840
2897
|
} finally { endRun(run); }
|
|
2841
2898
|
const carriedOk = await carrier.finish({ stage });
|
|
2842
2899
|
if (r?.stderr) o.err(String(r.stderr).trimEnd());
|
|
@@ -2859,6 +2916,12 @@ export async function stageSidecarsOnce({ o, ds, root, git = null, configs, appD
|
|
|
2859
2916
|
ds.ledger = { entries: walked.entries.map((e) => (priorPaths.has(e.path) && priorByPath.get(e.path).sha256 === e.sha256 ? priorByPath.get(e.path) : { ...e, kind: "staged", producer: { stage: "sidecar", step: config } })) };
|
|
2860
2917
|
// Evidence for a later "changed after it was staged": the receipt exactly as this staging wrote it.
|
|
2861
2918
|
if (receiptAbs) { try { (ds.stagedReceipts ??= new Map()).set(receiptAbs, fs.readFileSync(path.join(ds.path, receiptAbs), "utf8")); } catch { /* the close names the change without the field diff */ } }
|
|
2919
|
+
// 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
|
+
try {
|
|
2921
|
+
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); }
|
|
2923
|
+
else fs.rmSync(stateFile, { force: true });
|
|
2924
|
+
} catch (e) { o.out(`${tag} [${stage}] stage-sidecar ${config}: the staging state was not recorded (${e.message}); the next run stages again`); }
|
|
2862
2925
|
}
|
|
2863
2926
|
return true;
|
|
2864
2927
|
}
|
|
@@ -4154,7 +4217,7 @@ export function cargoHomeOf(env, { realpath = fs.realpathSync, homedir = os.home
|
|
|
4154
4217
|
|
|
4155
4218
|
export async function main(argv, io = {}) {
|
|
4156
4219
|
const o = {
|
|
4157
|
-
spawn: defaultSpawn, exists: fs.existsSync, readFile: (f) => fs.readFileSync(f, "utf8"), writeFile: fs.writeFileSync, mkdir: fs.mkdirSync, chmod: fs.chmodSync, readdir: fs.readdirSync,
|
|
4220
|
+
spawn: rememberReads(defaultSpawn), exists: fs.existsSync, readFile: (f) => fs.readFileSync(f, "utf8"), writeFile: fs.writeFileSync, mkdir: fs.mkdirSync, chmod: fs.chmodSync, readdir: fs.readdirSync,
|
|
4158
4221
|
readStdin: () => { try { return process.stdin.isTTY ? "" : fs.readFileSync(0, "utf8"); } catch { return ""; } },
|
|
4159
4222
|
out: (m) => console.log(m), err: (m) => console.error(m), cwd: process.cwd(), env: process.env, platform: process.platform,
|
|
4160
4223
|
// Where this gate runs from (the door puts its own shims first on PATH when it is an installed package: doorPath).
|
|
@@ -5207,7 +5270,7 @@ export async function main(argv, io = {}) {
|
|
|
5207
5270
|
const unit = sel?.replace(/^cargo:/, "");
|
|
5208
5271
|
const quiet = sel?.startsWith("cargo:") ? config.rust?.[unit]?.quietTests === true : false;
|
|
5209
5272
|
// A crate that ci/shards.json lists solo, or that is sidecar-bound, never joins another crate's invocation (planScans' own rule for its rows).
|
|
5210
|
-
const alone = sel?.startsWith("cargo:") && (
|
|
5273
|
+
const alone = sel?.startsWith("cargo:") && (sidecarBoundCrate({ dir: path.join(repo, dirOf.get(sel) ?? `crates/${unit}`), exists: o.exists, readFile: o.readFile }).bound);
|
|
5211
5274
|
return publisherRequirementScan(requirement, { platform: o.platform, cargoCommand: planCargoCommand, cargoLiveRoot, targetDirs, quiet, allowIgnored: verdicts.get(sel)?.allowIgnored === true, batch: !alone });
|
|
5212
5275
|
};
|
|
5213
5276
|
const planned = planUnitListScans({ entries: scoped, planned: plan.scans, normalizedCwds, adapt, blocked });
|
|
@@ -5233,10 +5296,10 @@ export async function main(argv, io = {}) {
|
|
|
5233
5296
|
o.onQualifyOwed?.((plan.qualifyOwed ?? []).filter((x) => x.kind !== "e2e-crate" || plan.scans.some((s) => s.id === x.id)));
|
|
5234
5297
|
// GC-A24: class A lanes default to the host's cores (measured, Mac, cold RK class A rows: 4 lanes 14.4 s, 8 lanes 7.0 s, 12 lanes 5.9 s).
|
|
5235
5298
|
const defaultJobs = typeof os.availableParallelism === "function" ? os.availableParallelism() : os.cpus().length;
|
|
5236
|
-
const jobs = Math.max(1,
|
|
5299
|
+
const jobs = Math.max(1, defaultJobs); // no caller sets it (step F of the Dell sequence, 2026-11-24: RK_GATE_JOBS is not read)
|
|
5237
5300
|
// A broker host has no gate-side build count: the broker decides it. What remains is the local limit on class B processes the broker never sees.
|
|
5238
5301
|
const brokerHost = executor.kind === "broker";
|
|
5239
|
-
const classBJobs =
|
|
5302
|
+
const classBJobs = LOCAL_CLASS_B_JOBS; // on every host; no caller sets it (RK_GATE_CLASS_B_JOBS is not read)
|
|
5240
5303
|
// The broker's live state of a request (queued or running), asked through the executor's own client with an asynchronous spawn: a carried scan's run limit does not tick
|
|
5241
5304
|
// while the broker holds it queued. No client to ask (none resolves): no reader, and a carried scan's limit simply runs, counting its queue time.
|
|
5242
5305
|
// The client is the declared Linux route's, else the managed runtime client, else the executor's own: a broker host whose executor is the `rustright` found on PATH
|
|
@@ -5518,7 +5581,10 @@ export async function main(argv, io = {}) {
|
|
|
5518
5581
|
...(() => { const bt = brokerToolchainOf(o, executor); return bt ? { brokerToolchain: bt } : {}; })(),
|
|
5519
5582
|
// 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.
|
|
5520
5583
|
...(snapshot ? { trackedFiles: files } : {}),
|
|
5521
|
-
classes: stageClasses, ...(classAEarlier ? { classAEarlier: true } : {}), jobs, classBJobs, classBBatching: !o[PRIVATE_SCOPED_COMPILE], groupTests: true,
|
|
5584
|
+
classes: stageClasses, ...(classAEarlier ? { classAEarlier: true } : {}), jobs, classBJobs, classBBatching: !o[PRIVATE_SCOPED_COMPILE], groupTests: true,
|
|
5585
|
+
// GC-A27 NN09 (acceptance case 1 on 0.6.63, 2026-11-24): every carried compile of a workspace is handed to the broker as soon as it is ready, none held until an
|
|
5586
|
+
// earlier job ends. The broker owns the order and runs one build per repository; with two in flight the last command of the fixture went out three minutes late.
|
|
5587
|
+
classBPipeline: Number.POSITIVE_INFINITY, ...(brokerHost ? { brokerHost: true } : {}), ...(brokerLive ? { brokerLive } : {}), signal: ac.signal, ...(cache ? { cache } : {}),
|
|
5522
5588
|
// NN41: the installed broker runtime's identity keys every cached compile failure; null (a direct host, an unreadable manifest) means no failure is cached.
|
|
5523
5589
|
...(brokerHost && cache ? (() => { const identity = brokerRuntimeIdentityText({ clients: [brokerClient, executor?.client, cargoCommand[0]], env: { ...o.env, ...(executor.env ?? {}) }, platform: o.platform }); return identity ? { failureIdentity: identity } : {}; })() : {}),
|
|
5524
5590
|
// 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
|
package/deterministic-scans.mjs
CHANGED
|
@@ -1934,7 +1934,8 @@ export function planScans({
|
|
|
1934
1934
|
// One Clippy scan per batch (row 8.6): the independent batches first, the sidecar-bound ones after them (row 8.8; the compile lane
|
|
1935
1935
|
// drains in plan order). The reason a configuration stays separate is recorded in the plan notes.
|
|
1936
1936
|
const sidecarBound = new Set(clippyEntries.filter((e) => sidecarBoundCrate({ dir: path.join(contentRoot, rustDir(e.name)), exists, readFile }).bound).map((e) => e.name));
|
|
1937
|
-
const plan = clippyBatchPlan(clippyEntries, { solo:
|
|
1937
|
+
const plan = clippyBatchPlan(clippyEntries, { solo: [], separate: clippySeparate, // ci/shards.json `solo` sizes CI jobs; it is no reason to split a compile here (GC-A27 NN09)
|
|
1938
|
+
sidecarBound, toolchain: cargoCommand.join(" ") });
|
|
1938
1939
|
for (const b of plan.batches) add({ id: b.id, class: B, batch: { units: b.units, order: b.order, reason: b.reason }, ...cargoIn(b.ws, ...clippyArgs(b.crates, { features: b.set, locked: true })) });
|
|
1939
1940
|
notes.push(...plan.notes);
|
|
1940
1941
|
}
|
|
@@ -2177,7 +2178,6 @@ export function planScans({
|
|
|
2177
2178
|
let why = null;
|
|
2178
2179
|
if (at < 0 || typeof crate !== "string" || x.args.indexOf("-p", at + 1) >= 0) why = "it does not name exactly one `-p <crate>`";
|
|
2179
2180
|
else if (rest.some((w) => /^(?:--features(?:=.*)?|-F.*)$/.test(w))) why = "its feature set names crate-specific features";
|
|
2180
|
-
else if (shardSolo.includes(unit) || shardSolo.includes(crateOf(unit))) why = "ci/shards.json solo";
|
|
2181
2181
|
else if (clippySeparate instanceof Map && clippySeparate.has(unit)) why = String(clippySeparate.get(unit));
|
|
2182
2182
|
else if (sidecarBoundCrate({ dir: path.join(contentRoot, rustDir(unit)), exists, readFile }).bound) why = "sidecar-bound";
|
|
2183
2183
|
// NN42 (LOCKED 2026-11-06): one check/clippy per stage names every --target. The target is not part of the group key: rows that differ only
|
|
@@ -2293,6 +2293,38 @@ export function defaultSpawn(command, args, options = {}) {
|
|
|
2293
2293
|
return spawnSync(inv.file, inv.args, { encoding: "utf8", windowsHide: true, maxBuffer: 64 * 1024 * 1024, windowsVerbatimArguments: inv.verbatim, ...options, shell: false });
|
|
2294
2294
|
}
|
|
2295
2295
|
|
|
2296
|
+
/**
|
|
2297
|
+
* GC-A27 NN08 (no repeat calls): the answers of read-only commands are kept for the life of the gate process and never asked for twice. Each is a read
|
|
2298
|
+
* whose answer cannot change during a run for the same folder and environment: a file of a commit named by its full sha (`git show <sha>:<path>`), the top
|
|
2299
|
+
* of a checkout (`git rev-parse --show-toplevel`), and `pnpm --version`. Found by the acceptance cases on gate 0.6.63 (2026-11-24): each was started two to
|
|
2300
|
+
* four times in one run. Only a successful answer is kept; anything else is asked again. `store` is injectable for tests.
|
|
2301
|
+
*/
|
|
2302
|
+
const READ_MEMO = new Map();
|
|
2303
|
+
export function isRememberedRead(command, args) {
|
|
2304
|
+
const name = String(command).replaceAll("\\", "/").split("/").pop().replace(/\.(exe|cmd|bat)$/i, "").toLowerCase();
|
|
2305
|
+
const a = (args ?? []).map(String);
|
|
2306
|
+
if (name === "pnpm") return a.length === 1 && a[0] === "--version";
|
|
2307
|
+
if (name !== "git") return false;
|
|
2308
|
+
// git's own leading options (-c key=value, -C dir) are part of the key; the subcommand is what is judged.
|
|
2309
|
+
let i = 0; while (i < a.length && (a[i] === "-c" || a[i] === "-C")) i += 2;
|
|
2310
|
+
const sub = a.slice(i);
|
|
2311
|
+
if (sub.length === 2 && sub[0] === "show" && /^[0-9a-f]{40}:.+/.test(sub[1])) return true;
|
|
2312
|
+
if (sub.length === 3 && sub[0] === "cat-file" && sub[1] === "-p" && /^[0-9a-f]{40}$/.test(sub[2])) return true;
|
|
2313
|
+
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
|
+
return sub.length === 2 && sub[0] === "rev-parse" && sub[1] === "--show-toplevel";
|
|
2315
|
+
}
|
|
2316
|
+
export function rememberReads(spawn, { store = READ_MEMO } = {}) {
|
|
2317
|
+
return (command, args, options = {}) => {
|
|
2318
|
+
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]));
|
|
2321
|
+
if (store.has(key)) return { ...store.get(key) };
|
|
2322
|
+
const r = spawn(command, args, options);
|
|
2323
|
+
if (r && r.status === 0 && !r.error) store.set(key, { status: 0, signal: null, stdout: r.stdout, stderr: r.stderr });
|
|
2324
|
+
return r;
|
|
2325
|
+
};
|
|
2326
|
+
}
|
|
2327
|
+
|
|
2296
2328
|
const OUTPUT_KEEP = 4 * 1024 * 1024;
|
|
2297
2329
|
/**
|
|
2298
2330
|
* defaultSpawn with a deadline (`options.boundedMs`), for short identity probes that must never hang the caller: the command runs
|
|
@@ -3188,7 +3220,7 @@ export function swiftScratchPath({ tmpRoot, roots, id }) {
|
|
|
3188
3220
|
const dir = path.join(real(tmpRoot), "rightkit-swift-scratch", crypto.createHash("sha256").update(repo).digest("hex").slice(0, 16), id.replace(/[^A-Za-z0-9._-]/g, "_"));
|
|
3189
3221
|
for (const root of roots.filter(Boolean)) {
|
|
3190
3222
|
const rel = path.relative(real(root), dir);
|
|
3191
|
-
if (rel === "" || (rel !== ".." && !rel.startsWith(`..${path.sep}`) && !path.isAbsolute(rel))) throw new Error(`the SwiftPM build directory ${dir} would be inside ${real(root)};
|
|
3223
|
+
if (rel === "" || (rel !== ".." && !rel.startsWith(`..${path.sep}`) && !path.isAbsolute(rel))) throw new Error(`the SwiftPM build directory ${dir} would be inside ${real(root)}; the gate's temp folder must lie outside the repository`);
|
|
3192
3224
|
}
|
|
3193
3225
|
return dir;
|
|
3194
3226
|
}
|
|
@@ -3206,7 +3238,7 @@ export function cargoReadTargetDir({ tmpRoot, roots }) {
|
|
|
3206
3238
|
const rel = path.relative(real(root), dir);
|
|
3207
3239
|
if (rel === "" || (rel !== ".." && !rel.startsWith(`..${path.sep}`) && !path.isAbsolute(rel))) {
|
|
3208
3240
|
fs.rmSync(dir, { recursive: true, force: true });
|
|
3209
|
-
throw new Error(`the Cargo output directory ${dir} would be inside ${real(root)};
|
|
3241
|
+
throw new Error(`the Cargo output directory ${dir} would be inside ${real(root)}; the gate's temp folder must lie outside the repository`);
|
|
3210
3242
|
}
|
|
3211
3243
|
}
|
|
3212
3244
|
return dir;
|
package/gate-seam.mjs
CHANGED
|
@@ -106,14 +106,20 @@ export function classAVerdict({ commit, tree, repoKey, workspace, scans, scope =
|
|
|
106
106
|
return { schema: CLASS_A_VERDICT_SCHEMA, commit, tree, repoKey, workspace: ws, scope: normalizeScope(scope), status: "pass", scans: rows };
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
+
/** When this gate process started, a second early: a verdict file written at or after it is this run's own. */
|
|
110
|
+
const RUN_STARTED_MS = Date.now() - Math.ceil(process.uptime() * 1000) - 1000;
|
|
109
111
|
/** Writes a verdict atomically (temp file, rename) with mode 0600 and returns its absolute path. Refuses a relative directory. */
|
|
110
|
-
export function writeClassAVerdict(dir, verdict, { fsApi = fs } = {}) {
|
|
112
|
+
export function writeClassAVerdict(dir, verdict, { fsApi = fs, since = RUN_STARTED_MS } = {}) {
|
|
111
113
|
if (!path.isAbsolute(dir)) throw new SeamError("VERDICT", `verdict directory ${dir} must be absolute`);
|
|
112
114
|
if (verdict?.schema !== CLASS_A_VERDICT_SCHEMA || verdict.status !== "pass") throw new SeamError("VERDICT", "only a passing verdict of the current schema is written");
|
|
113
115
|
fsApi.mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
114
116
|
const file = path.join(dir, verdictFileName({ commit: verdict.commit, scope: verdict.scope ?? "full", workspace: verdict.workspace }));
|
|
117
|
+
const body = `${JSON.stringify(verdict)}\n`;
|
|
118
|
+
// The same verdict this run already wrote is not written again (GC-A27 NN02, NN08): a second write moved the file's time past the submission of a job that
|
|
119
|
+
// named it, so the file no longer showed it was there first (acceptance case 1 on 0.6.63, 2026-11-24). A file an earlier run left is always written afresh.
|
|
120
|
+
try { const st = fsApi.statSync(file); if (st.mtimeMs >= since && fsApi.readFileSync(file, "utf8") === body) return file; } catch { /* not there yet */ }
|
|
115
121
|
const tmp = `${file}.${process.pid}.${crypto.randomBytes(4).toString("hex")}.tmp`;
|
|
116
|
-
fsApi.writeFileSync(tmp,
|
|
122
|
+
fsApi.writeFileSync(tmp, body, { mode: 0o600 });
|
|
117
123
|
fsApi.renameSync(tmp, file);
|
|
118
124
|
return file;
|
|
119
125
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rightkit/release",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.65",
|
|
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 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 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",
|
package/rightkit-versions.json
CHANGED
|
@@ -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.
|
|
52
|
+
"@rightkit/release": "0.6.65",
|
|
53
53
|
"@rightkit/send-ui": "0.1.0",
|
|
54
54
|
"@rightkit/settings-ui": "0.7.5",
|
|
55
55
|
"@rightkit/social-ui": "0.2.1",
|
|
@@ -755,6 +755,7 @@
|
|
|
755
755
|
},
|
|
756
756
|
"registry": {
|
|
757
757
|
"cargo": {
|
|
758
|
+
"rightkit-agent-engine-attention": "0.2.0",
|
|
758
759
|
"rightkit-agent-tools": "0.4.3",
|
|
759
760
|
"rightkit-agents": "0.2.0",
|
|
760
761
|
"rightkit-ai-keys": "0.1.1",
|
|
@@ -764,7 +765,7 @@
|
|
|
764
765
|
"rightkit-app-settings": "0.4.2",
|
|
765
766
|
"rightkit-asr": "0.5.2",
|
|
766
767
|
"rightkit-audio": "0.4.1",
|
|
767
|
-
"rightkit-automation": "0.7.
|
|
768
|
+
"rightkit-automation": "0.7.4",
|
|
768
769
|
"rightkit-browser": "0.3.6",
|
|
769
770
|
"rightkit-cache": "0.2.3",
|
|
770
771
|
"rightkit-channel-memory": "0.2.1",
|
|
@@ -796,6 +797,7 @@
|
|
|
796
797
|
"rightkit-framed-sidecar": "0.2.0",
|
|
797
798
|
"rightkit-fs": "0.5.0",
|
|
798
799
|
"rightkit-fsindex": "0.5.0",
|
|
800
|
+
"rightkit-google-apis": "0.2.1",
|
|
799
801
|
"rightkit-google-identity": "0.2.0",
|
|
800
802
|
"rightkit-hooks": "0.2.0",
|
|
801
803
|
"rightkit-hotkeys": "0.1.6",
|
|
@@ -810,10 +812,11 @@
|
|
|
810
812
|
"rightkit-media": "0.2.6",
|
|
811
813
|
"rightkit-media-control": "0.1.1",
|
|
812
814
|
"rightkit-media-gen-approvals": "0.1.1",
|
|
813
|
-
"rightkit-memory
|
|
815
|
+
"rightkit-memory": "0.3.1",
|
|
816
|
+
"rightkit-memory-store": "0.2.1",
|
|
814
817
|
"rightkit-models": "0.7.2",
|
|
815
818
|
"rightkit-motion": "0.2.0",
|
|
816
|
-
"rightkit-oauth": "0.
|
|
819
|
+
"rightkit-oauth": "0.11.1",
|
|
817
820
|
"rightkit-ocr": "0.2.3",
|
|
818
821
|
"rightkit-onnx": "0.2.7",
|
|
819
822
|
"rightkit-ort": "0.2.3",
|
|
@@ -831,7 +834,7 @@
|
|
|
831
834
|
"rightkit-qts-ggml-sys": "0.1.2",
|
|
832
835
|
"rightkit-record": "0.3.3",
|
|
833
836
|
"rightkit-review": "0.4.0",
|
|
834
|
-
"rightkit-roots": "0.
|
|
837
|
+
"rightkit-roots": "0.3.0",
|
|
835
838
|
"rightkit-sandbox": "0.6.1",
|
|
836
839
|
"rightkit-search": "0.4.0",
|
|
837
840
|
"rightkit-secrets": "0.2.0",
|
|
@@ -846,7 +849,7 @@
|
|
|
846
849
|
"rightkit-tauri": "0.1.3",
|
|
847
850
|
"rightkit-tauri-shell": "0.8.2",
|
|
848
851
|
"rightkit-text-polish": "0.1.3",
|
|
849
|
-
"rightkit-time": "0.1.
|
|
852
|
+
"rightkit-time": "0.1.5",
|
|
850
853
|
"rightkit-transcript": "0.4.0",
|
|
851
854
|
"rightkit-transcript-library": "0.1.7",
|
|
852
855
|
"rightkit-tts": "0.2.3",
|