@rightkit/release 0.6.67 → 0.6.68
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.mjs +8 -6
- package/bin/rightkit-gate.mjs +5 -3
- package/deterministic-scans.mjs +23 -1
- package/package.json +1 -1
- package/rightkit-versions.json +1 -1
package/acceptance-cases.mjs
CHANGED
|
@@ -59,9 +59,11 @@ const firstSubmission = (run) => Math.min(...run.jobs.map((j) => j.submitted).fi
|
|
|
59
59
|
|
|
60
60
|
// ---- the checks one run can be given, whatever the case ---------------------------------------------------------------------------------------------------
|
|
61
61
|
/** NN01, every run: each broker receipt verifies, names the selected commit and its tree, and says the snapshot was unchanged. */
|
|
62
|
-
|
|
62
|
+
/** A job the broker refused before it started (no signed start, not a success) built nothing: a run killed under it leaves one (case 7 on 0.6.67). Skipped in the kill case only: anywhere else an unstarted refusal may be a job sent before Class A, which NN02 must see. */
|
|
63
|
+
export const neverRan = (j) => !Number.isFinite(j.started) && j.status !== "SUCCEEDED";
|
|
64
|
+
export function receiptsNameTheCommit(run, { skipNeverRan = false } = {}) {
|
|
63
65
|
const fails = [];
|
|
64
|
-
for (const j of run.jobs) {
|
|
66
|
+
for (const j of run.jobs.filter((x) => !(skipNeverRan && neverRan(x)))) {
|
|
65
67
|
if (!j.verified) { fails.push(`${jobName(j)}: its receipt does not verify (${(j.problems ?? []).join("; ") || "no reason given"})`); continue; }
|
|
66
68
|
if (j.gate?.commit !== run.commit) fails.push(`${jobName(j)} is signed for commit ${String(j.gate?.commit).slice(0, 12)}, not the selected ${String(run.commit).slice(0, 12)}`);
|
|
67
69
|
if (!run.tree || j.gate?.tree !== run.tree) fails.push(`${jobName(j)} is signed for tree ${String(j.gate?.tree).slice(0, 12)}, not the selected commit's ${String(run.tree).slice(0, 12)}`);
|
|
@@ -70,8 +72,8 @@ export function receiptsNameTheCommit(run) {
|
|
|
70
72
|
return fails;
|
|
71
73
|
}
|
|
72
74
|
/** NN02, a run that reached the broker: the Class A verdict file the receipts name is older than the first signed submission, and every Class A program ended before it. */
|
|
73
|
-
export function classABeforeBroker(run) {
|
|
74
|
-
const fails = []; if (!run.jobs.length) return ["no broker receipt exists, so the order of Class A and the first submission cannot be shown"];
|
|
75
|
+
export function classABeforeBroker(run, { skipNeverRan = false } = {}) {
|
|
76
|
+
const fails = []; if (skipNeverRan) { run = { ...run, jobs: run.jobs.filter((x) => !neverRan(x)) }; if (!run.jobs.length) return []; } else if (!run.jobs.length) return ["no broker receipt exists, so the order of Class A and the first submission cannot be shown"];
|
|
75
77
|
const first = firstSubmission(run); if (!Number.isFinite(first)) return ["no broker receipt signs a usable start time and waits, so the first submission time is not known"];
|
|
76
78
|
// Each job against the verdict file its own receipt names: that file, as the launcher lists it after the run, must be older than the job's signed submission.
|
|
77
79
|
// A file written later was not this run's verdict when the job was sent (an older run's file of the same name was what the broker read).
|
|
@@ -174,7 +176,7 @@ const noCacheWrite = (run, label) => (!Array.isArray(run.cacheWritten) ? [`${lab
|
|
|
174
176
|
const LINES = {
|
|
175
177
|
// Only the selected commit is built.
|
|
176
178
|
NN01(c, cases) {
|
|
177
|
-
const fails = c.runs.flatMap(receiptsNameTheCommit);
|
|
179
|
+
const fails = c.runs.flatMap((r) => receiptsNameTheCommit(r, { skipNeverRan: c.id === 7 }));
|
|
178
180
|
if (c.id === 1) fails.push(...passedRun(c.runs[0], "the run with an error planted in the checkout that the commit does not hold"));
|
|
179
181
|
if (c.id === 5) c.runs.forEach((r, i) => fails.push(...failedRun(r, `run ${i + 1} of the commit that holds the error, with a clean checkout`)));
|
|
180
182
|
return verdict(fails, c.id === 1 ? "an error in the checkout that is not in the commit did not fail the run, and every receipt names the selected commit and tree with the snapshot unchanged" : c.id === 5 ? "an error in the commit failed the run with a clean checkout" : `${c.runs.reduce((n, r) => n + r.jobs.length, 0)} receipt(s), each naming the selected commit and tree with the snapshot unchanged`);
|
|
@@ -182,7 +184,7 @@ const LINES = {
|
|
|
182
184
|
// Class A finishes before anything goes to the broker. If it fails, nothing goes.
|
|
183
185
|
NN02(c) {
|
|
184
186
|
if (c.id === 5) return verdict(c.runs.flatMap((r, i) => [...failedRun(r, `run ${i + 1}`), ...noReceipt(r, `run ${i + 1}`)]), "a failing Class A check ended the run with a failing exit and no broker receipt, twice");
|
|
185
|
-
return verdict(c.runs.filter((r) => r.jobs.length).flatMap(classABeforeBroker), "the Class A verdict file is older than the first signed submission, and every Class A program had ended by then");
|
|
187
|
+
return verdict(c.runs.filter((r) => r.jobs.length).flatMap((r) => classABeforeBroker(r, { skipNeverRan: c.id === 7 })), "the Class A verdict file is older than the first signed submission, and every Class A program had ended by then");
|
|
186
188
|
},
|
|
187
189
|
// Class A starts ready, independent work whenever an eligible lane is free.
|
|
188
190
|
NN03(c, cases) {
|
package/bin/rightkit-gate.mjs
CHANGED
|
@@ -2867,6 +2867,8 @@ function rustupChannelManifests(env) {
|
|
|
2867
2867
|
/** `<managed root>/sidecar-state/<repo key>/<config, target and mode>.json`, beside the snapshot: the key and receipt of the last staging. */
|
|
2868
2868
|
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`);
|
|
2869
2869
|
const fileSha256 = (file) => { try { return createHash("sha256").update(fs.readFileSync(file)).digest("hex"); } catch { return null; } };
|
|
2870
|
+
/** What a staging receipt stages: each file's path and sha256, not when it was written (the time changes on every staging; acceptance cases on 0.6.67). Null when unreadable. */
|
|
2871
|
+
export const stagedFilesDigest = (file) => { try { const r = JSON.parse(fs.readFileSync(file, "utf8")); if (!Array.isArray(r?.files)) return null; return createHash("sha256").update(JSON.stringify(r.files.map((x) => [x?.path ?? null, x?.sha256 ?? null]).sort())).digest("hex"); } catch { return null; } };
|
|
2870
2872
|
|
|
2871
2873
|
/**
|
|
2872
2874
|
* Sidecars are staged ONCE per door run, after the sync and before the first stage that builds the Tauri crate. The step is
|
|
@@ -2903,7 +2905,7 @@ export async function stageSidecarsOnce({ o, ds, root, git = null, configs, appD
|
|
|
2903
2905
|
const keyOf = (parts) => (parts ? createHash("sha256").update(JSON.stringify(parts)).digest("hex") : null);
|
|
2904
2906
|
const keyNow = (dirs) => keyOf(partsNow(dirs));
|
|
2905
2907
|
const nowParts = prior?.schema === 2 ? partsNow(prior.dirs) : null;
|
|
2906
|
-
const receiptNow = prior?.schema === 2 && typeof prior.receipt === "string" ?
|
|
2908
|
+
const receiptNow = prior?.schema === 2 && typeof prior.receipt === "string" ? stagedFilesDigest(path.join(ds.path, prior.receipt)) : null;
|
|
2907
2909
|
const unchanged = Boolean(prior?.schema === 2 && nowParts && keyOf(nowParts) === prior.key && receiptNow === prior.receiptSha256);
|
|
2908
2910
|
// Why it stages again, in one line, so a missed reuse can be traced from the run's own output.
|
|
2909
2911
|
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"));
|
|
@@ -2935,7 +2937,7 @@ export async function stageSidecarsOnce({ o, ds, root, git = null, configs, appD
|
|
|
2935
2937
|
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 */ } }
|
|
2936
2938
|
// 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.
|
|
2937
2939
|
try {
|
|
2938
|
-
const dirs = git ? sidecarSourceDirs({ git, commit, result }) : null; const k = dirs ? keyNow(dirs) : null; const sha = receiptAbs ?
|
|
2940
|
+
const dirs = git ? sidecarSourceDirs({ git, commit, result }) : null; const k = dirs ? keyNow(dirs) : null; const sha = receiptAbs ? stagedFilesDigest(path.join(ds.path, receiptAbs)) : null;
|
|
2939
2941
|
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); }
|
|
2940
2942
|
else fs.rmSync(stateFile, { force: true });
|
|
2941
2943
|
} catch (e) { o.out(`${tag} [${stage}] stage-sidecar ${config}: the staging state was not recorded (${e.message}); the next run stages again`); }
|
|
@@ -4268,7 +4270,7 @@ export function ignoredCallerVariable(name, platform = process.platform) {
|
|
|
4268
4270
|
}
|
|
4269
4271
|
export async function main(argv, io = {}) {
|
|
4270
4272
|
const o = {
|
|
4271
|
-
spawn:
|
|
4273
|
+
spawn: defaultSpawn, exists: fs.existsSync, // remembers its read-only answers itself (deterministic-scans.mjs isRememberedRead); a wrapper here switched off the pnpm answers kept across runs, which test `spawn === defaultSpawn` readFile: (f) => fs.readFileSync(f, "utf8"), writeFile: fs.writeFileSync, mkdir: fs.mkdirSync, chmod: fs.chmodSync, readdir: fs.readdirSync,
|
|
4272
4274
|
readStdin: () => { try { return process.stdin.isTTY ? "" : fs.readFileSync(0, "utf8"); } catch { return ""; } },
|
|
4273
4275
|
out: (m) => console.log(m), err: (m) => console.error(m), cwd: process.cwd(), env: process.env, platform: process.platform,
|
|
4274
4276
|
// Where this gate runs from (the door puts its own shims first on PATH when it is an installed package: doorPath).
|
package/deterministic-scans.mjs
CHANGED
|
@@ -2287,6 +2287,16 @@ export function cmdShimEntry(shim, { readFile = (f) => fs.readFileSync(f, "utf8"
|
|
|
2287
2287
|
|
|
2288
2288
|
/** Default spawn: synchronous, no console window, never `shell: true`. */
|
|
2289
2289
|
export function defaultSpawn(command, args, options = {}) {
|
|
2290
|
+
if (isRememberedRead(command, args) && options.input === undefined && options.stdio === undefined) {
|
|
2291
|
+
const key = readMemoKey(command, args, options);
|
|
2292
|
+
if (READ_MEMO.has(key)) return { ...READ_MEMO.get(key) };
|
|
2293
|
+
const r = rawSpawn(command, args, options);
|
|
2294
|
+
if (r && r.status === 0 && !r.error) READ_MEMO.set(key, { status: 0, signal: null, stdout: r.stdout, stderr: r.stderr });
|
|
2295
|
+
return r;
|
|
2296
|
+
}
|
|
2297
|
+
return rawSpawn(command, args, options);
|
|
2298
|
+
}
|
|
2299
|
+
function rawSpawn(command, args, options = {}) {
|
|
2290
2300
|
if (options.boundedMs) return boundedSpawn(command, args, options);
|
|
2291
2301
|
const inv = resolveInvocation(command, args, { env: options.env ?? process.env });
|
|
2292
2302
|
if (inv.error) return { status: null, stdout: "", stderr: "", error: inv.error };
|
|
@@ -2317,7 +2327,19 @@ export function isRememberedRead(command, args) {
|
|
|
2317
2327
|
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;
|
|
2318
2328
|
return sub.length === 2 && sub[0] === "rev-parse" && sub[1] === "--show-toplevel";
|
|
2319
2329
|
}
|
|
2320
|
-
const readMemoKey = (command, args, options = {}) => {
|
|
2330
|
+
const readMemoKey = (command, args, options = {}) => {
|
|
2331
|
+
const a = (args ?? []).map(String); let i = 0; while (i < a.length && (a[i] === "-c" || a[i] === "-C")) i += 2;
|
|
2332
|
+
const sub = a.slice(i);
|
|
2333
|
+
// git show <sha>:<path>, ls-tree <sha>, cat-file -p <sha>: content-addressed, the same answer wherever it is asked (a repository without the object fails, and a failure is not kept).
|
|
2334
|
+
if (/(^|[\\/])git(\.exe)?$/i.test(String(command)) && sub[0] !== "rev-parse") return sha256(JSON.stringify(["object", sub]));
|
|
2335
|
+
// A tool's own version is the version of the binary that runs: the program as the environment resolves it.
|
|
2336
|
+
if (a.length === 1 || (a.length === 2 && a[1] === "--version")) {
|
|
2337
|
+
let file = String(command); try { file = resolveInvocation(command, args, { env: options.env ?? process.env }).file ?? file; } catch { /* as given */ }
|
|
2338
|
+
return sha256(JSON.stringify(["version", String(file).toLowerCase(), a]));
|
|
2339
|
+
}
|
|
2340
|
+
const env = options.env ? Object.keys(options.env).sort().map((k) => `${k}=${options.env[k]}`).join("\0") : "";
|
|
2341
|
+
return sha256(JSON.stringify([String(command), a, path.resolve(options.cwd ?? process.cwd()), env]));
|
|
2342
|
+
};
|
|
2321
2343
|
export function rememberReads(spawn, { store = READ_MEMO } = {}) {
|
|
2322
2344
|
return (command, args, options = {}) => {
|
|
2323
2345
|
if (!isRememberedRead(command, args) || options.input !== undefined || options.stdio !== undefined) return spawn(command, args, options);
|
package/package.json
CHANGED
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.68",
|
|
53
53
|
"@rightkit/send-ui": "0.1.0",
|
|
54
54
|
"@rightkit/settings-ui": "0.7.5",
|
|
55
55
|
"@rightkit/social-ui": "0.2.1",
|