@rightkit/release 0.6.51 → 0.6.54
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/README.md +1 -1
- package/adapter-env.mjs +16 -105
- package/admission-host.mjs +14 -1
- package/bin/darwin/rightkit-swap +0 -0
- package/bin/rightkit-gate.mjs +609 -404
- package/broker-admission.mjs +122 -2
- package/build-launch.mjs +52 -58
- package/build-release.mjs +2 -2
- package/cargo-ledger.mjs +24 -5
- package/cargo-target-shim.mjs +54 -23
- package/cargo-target.mjs +2 -2
- package/carried-adapter-run.mjs +7 -8
- package/carried-cargo-run.mjs +1 -1
- package/ci-compile-admission.mjs +1 -1
- package/clippy-route.mjs +65 -18
- package/compile-inputs.mjs +91 -15
- package/cross-targets.mjs +5 -3
- package/deps-cargo-lock.mjs +1 -1
- package/deterministic-scans.mjs +789 -259
- package/development.mjs +33 -7
- package/direct-receipt.mjs +3 -5
- package/feature-coverage.mjs +45 -9
- package/feature-partition.mjs +204 -0
- package/feature-sets.mjs +113 -0
- package/gate-acceptance.mjs +187 -115
- package/gate-seam.mjs +352 -0
- package/gate-serve.mjs +34 -2
- package/gate-stages.mjs +6 -2
- package/ghsa-audit.mjs +19 -4
- package/heavy-command.mjs +5 -4
- package/install-tauri-authenticode.mjs +73 -4
- package/ios-dev.mjs +3 -3
- package/ios-package-recipe.mjs +6 -6
- package/linux-setup.mjs +3 -2
- package/local-publish.mjs +113 -17
- package/lock-identity.mjs +24 -100
- package/managed-cargo.mjs +3 -3
- package/managed-root-guard.mjs +2 -2
- package/managed-roots.mjs +3 -3
- package/native-adapters.mjs +41 -244
- package/native-helpers.mjs +1 -1
- package/pack-digest.mjs +1 -1
- package/package-recipe-targets.mjs +3 -3
- package/package.json +2 -2
- package/publication-gate.mjs +29 -6
- package/publish-cargo.mjs +4 -5
- package/publish-local-cargo.mjs +77 -1
- package/qualification-verify.mjs +76 -49
- package/receipt-signature.mjs +104 -0
- package/release-switch-registry.json +4 -0
- package/release-switch-scan.mjs +13 -10
- package/rightkit-versions.json +126 -113
- package/scan-digest.mjs +43 -14
- package/seam-broker.mjs +168 -0
- package/snapshot-check.mjs +4 -1
- package/snapshot-dependency-reuse.mjs +1 -1
- package/snapshot-metadata.mjs +24 -35
- package/snapshot.mjs +328 -49
- package/stage-commands.mjs +59 -5
- package/stage-ledger.mjs +2 -2
- package/{carried-cargo.mjs → stage-seam.mjs} +118 -70
- package/stage-sidecar.mjs +3 -3
- package/tauri-bundle-marker.mjs +5 -2
- package/tauri-locked.mjs +1 -1
- package/tool-build.mjs +8 -6
- package/unit-gate.mjs +40 -10
- package/web-build.mjs +6 -0
- package/broker-handshake.mjs +0 -160
- package/broker-wire.mjs +0 -278
- package/build-ownership.mjs +0 -1578
- package/cargo-shapes.mjs +0 -332
- package/cargo-width.mjs +0 -49
- package/carrier-census.mjs +0 -124
- package/clippy-equivalence.mjs +0 -202
- package/freshness-census.mjs +0 -405
- package/handle-revocation.mjs +0 -100
- package/handle-revocation.rust-vector.json +0 -1
- package/handle-revocation.vectors.json +0 -53
- package/legion-freeze-consumer.mjs +0 -241
- package/linux-qualifier.mjs +0 -83
- package/native-tool-planning.mjs +0 -94
- package/owner-process-proof.mjs +0 -14
- package/ownership-mark.mjs +0 -191
- package/ownership-recover.mjs +0 -78
- package/pnpm-adapter-grammar.mjs +0 -226
- package/provenance-verify.mjs +0 -413
- package/snapshot-broker.mjs +0 -808
- package/snapshot-request.mjs +0 -722
- package/unit-list-compile.mjs +0 -356
package/cargo-target-shim.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// The runtime cargo wrapper of a commit-snapshot compile (item 7, GATE-CONTRACT §1 "Broker interface", output directory). Two modes:
|
|
3
3
|
// direct the DIRECT POSIX (Linux) host: each call runs the real cargo bound to its workspace's checkout target directory.
|
|
4
|
-
// broker the Mac
|
|
5
|
-
//
|
|
4
|
+
// broker the Mac and the Dell: each compile goes through the RustRight client as a seam call (seam-broker.mjs runSeamCargoCall: the client's `cargo` command in the snapshot
|
|
5
|
+
// with RUSTRIGHT_GATE_COMMIT and RUSTRIGHT_CLASS_A); nothing compiles outside the broker, and a compile with no seam variables is refused (RK_CARGO_NO_SEAM).
|
|
6
6
|
// Both modes append every call to the gate-owned ledger (cargo-ledger.mjs) before and after it acts, and the gate fails the scan on any
|
|
7
7
|
// refused, unverified or unfinished call even when the test ignored the exit status. On a Windows host there is no wrapper: a child
|
|
8
8
|
// started without a shell finds only an .exe, so the static walk (deterministic-scans.mjs cargoReachOf) is the fail-closed baseline
|
|
@@ -32,14 +32,13 @@ import { createHash, randomBytes } from "node:crypto";
|
|
|
32
32
|
import { spawnSync } from "./background-process.mjs";
|
|
33
33
|
import { spawnBrokerClient } from "./broker-client.mjs";
|
|
34
34
|
import { fileURLToPath } from "node:url";
|
|
35
|
-
import { SCAN_TOKEN_ENV, appendLedger } from "./cargo-ledger.mjs";
|
|
36
|
-
import { BROKER_REFUSAL_STATUS, runBrokerCargo } from "./snapshot-broker.mjs";
|
|
35
|
+
import { CARGO_REFUSAL_STATUS, SCAN_TOKEN_ENV, appendLedger } from "./cargo-ledger.mjs";
|
|
37
36
|
import { carriedScanRefusal } from "./snapshot-metadata.mjs";
|
|
38
|
-
import {
|
|
37
|
+
import { runSeamCargoCall, seamEnvPresent } from "./seam-broker.mjs";
|
|
39
38
|
|
|
40
39
|
export const SHIM_MAP_SCHEMA = "rightkit.cargo-target-shim/3";
|
|
41
40
|
// Exit status of a refusal: cargo's own error status, so every caller reads it as a failed cargo.
|
|
42
|
-
export const SHIM_REFUSAL_STATUS =
|
|
41
|
+
export const SHIM_REFUSAL_STATUS = CARGO_REFUSAL_STATUS;
|
|
43
42
|
// Cargo commands that compile or report on a workspace: run bound to its checkout target directory.
|
|
44
43
|
const COMPILE = new Set(["build", "b", "check", "c", "test", "t", "bench", "run", "r", "doc", "d", "rustc", "rustdoc", "clippy", "metadata", "package"]);
|
|
45
44
|
// Commands that only read a workspace but may resolve and write its Cargo.lock: bound, and only with --locked or --frozen.
|
|
@@ -56,6 +55,34 @@ export const WRAPPER_COMMANDS = Object.freeze({ get bound() { return [...BOUND];
|
|
|
56
55
|
// Cargo's built-in command aliases. The broker classifies only the full names (command_policy.rs: b, c, t, r, d are RK_UNKNOWN_COMMAND), so a
|
|
57
56
|
// broker-mode call is expanded to the full name BEFORE it is classified and sent (the signed argv digest is over the argv as sent).
|
|
58
57
|
const ALIASES = Object.freeze({ b: "build", c: "check", t: "test", r: "run", d: "doc" });
|
|
58
|
+
/** `argv` with the standard alias at the subcommand position replaced by its full name; every other word is kept as sent. */
|
|
59
|
+
export function expandCargoAliases(argv) {
|
|
60
|
+
const out = [...argv];
|
|
61
|
+
const at = cargoCommandIndex(out);
|
|
62
|
+
if (at !== null && Object.hasOwn(ALIASES, out[at])) out[at] = ALIASES[out[at]];
|
|
63
|
+
return out;
|
|
64
|
+
}
|
|
65
|
+
// Where the subcommand sits in an argv, read as the broker reads it (rustright command_policy.rs `command_index`): after an optional `+toolchain` and the global
|
|
66
|
+
// options (the ones that take a value are skipped with it), before any `--`; `--version`, `-V` and `-vV` are the command. null when there is none. The gate's own
|
|
67
|
+
// planners (stage-commands.mjs, build-launch.mjs) need only this position; the broker, not the gate, judges what the command may be.
|
|
68
|
+
const BROKER_VALUE_GLOBALS = new Set(["--manifest-path", "--config", "-C", "-Z", "--color", "--target-dir"]);
|
|
69
|
+
const BROKER_PLAIN_GLOBALS = new Set(["--locked", "--frozen", "--offline", "--quiet", "-q", "--verbose", "-v"]);
|
|
70
|
+
const BROKER_VERSION_FLAGS = new Set(["--version", "-V", "-vV"]);
|
|
71
|
+
export function cargoCommandIndex(argv) {
|
|
72
|
+
let i = 0;
|
|
73
|
+
while (i < argv.length) {
|
|
74
|
+
const v = argv[i];
|
|
75
|
+
i += 1;
|
|
76
|
+
if (v === "--") break;
|
|
77
|
+
if (v.startsWith("+") && v.length > 1) continue;
|
|
78
|
+
if (BROKER_VERSION_FLAGS.has(v)) return i - 1;
|
|
79
|
+
if (BROKER_VALUE_GLOBALS.has(v)) { i += 1; continue; }
|
|
80
|
+
if (BROKER_PLAIN_GLOBALS.has(v)) continue;
|
|
81
|
+
if (v.startsWith("-")) continue;
|
|
82
|
+
return i - 1;
|
|
83
|
+
}
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
59
86
|
// The only requests the broker lets run uncarried inside a snapshot (command_policy.rs uncarried_snapshot_probe: VERSION_ARGUMENTS and `version`).
|
|
60
87
|
const VERSION_PROBES = Object.freeze([["-V"], ["--version"], ["-vV"], ["-Vv"], ["--version", "--verbose"], ["-V", "--verbose"], ["-v", "-V"], ["version"]]);
|
|
61
88
|
// The read-only commands the broker admits to a carried request only in carriedScanRefusal's exact shapes (snapshot-metadata.mjs).
|
|
@@ -75,7 +102,7 @@ export function readOnlyCargo(args) {
|
|
|
75
102
|
/**
|
|
76
103
|
* Whether a cargo call of a snapshot stage runs directly (GC-A11) instead of being carried to the broker: the first word is the subcommand
|
|
77
104
|
* itself (no `+toolchain` or global option in front), it compiles nothing, it is one of carriedScanRefusal's exact non-writing shapes, and a
|
|
78
|
-
* `package` call is `--list` with `--locked` or `--frozen`. The ONE definition of that shape:
|
|
105
|
+
* `package` call is `--list` with `--locked` or `--frozen`. The ONE definition of that shape: stage-seam.mjs runs a call by it and
|
|
79
106
|
* stage-commands.mjs (via it) tells the receipt collection and the hosted admission to expect no broker receipt for such a command.
|
|
80
107
|
*/
|
|
81
108
|
export function directCargoShape(words) {
|
|
@@ -156,12 +183,6 @@ export function decideCargoInvocation({ args, cwd, env, map, locate, realpath =
|
|
|
156
183
|
// output: a manifest path or a target directory of the caller's has no place in a broker call.
|
|
157
184
|
if (broker && manifestPath !== undefined) return refusal("RK_CARGO_BROKER_MANIFEST_PATH", `\`cargo ${sub}\` passes --manifest-path; a broker call runs from the workspace's own directory (the client refuses to rewrite the invocation), so run it there`);
|
|
158
185
|
if (broker && valueOf("--target-dir") !== undefined) return refusal("RK_CARGO_REDIRECT", `\`cargo ${sub}\` passes --target-dir; the broker pins a snapshot compile's output directory`);
|
|
159
|
-
// GB-01: in broker mode the one command-shape table (cargo-shapes.mjs) decides what the broker would admit inside a snapshot, before anything is
|
|
160
|
-
// sent: tree, pkgid and verify-project (no non-writing policy at RustRight), a bare metadata and the other shapes it refuses are refused here, typed.
|
|
161
|
-
if (broker) {
|
|
162
|
-
const decision = carriedShapeDecision(words);
|
|
163
|
-
if (!decision.ok) return refusal(decision.code, decision.message);
|
|
164
|
-
}
|
|
165
186
|
let workspace;
|
|
166
187
|
try {
|
|
167
188
|
const manifest = locate(manifestPath === undefined ? null : path.resolve(cwd, manifestPath), cwd, toolchain);
|
|
@@ -218,8 +239,8 @@ export function installCargoShim({ base, snapshotRoot, targetDirs, broker = null
|
|
|
218
239
|
const self = fileURLToPath(import.meta.url);
|
|
219
240
|
const sorted = Object.fromEntries(Object.entries(workspaces).sort(([a], [b]) => (a < b ? -1 : 1)));
|
|
220
241
|
const identityHash = createHash("sha256").update(JSON.stringify({ realCargo: realCargo ?? null, node, workspaces: sorted, ...(broker ? { mode, section: broker.section } : {}) })).update(fs.readFileSync(self));
|
|
221
|
-
// The broker half of the wrapper is part of its identity: any change to the code that
|
|
222
|
-
if (broker) for (const name of ["
|
|
242
|
+
// The broker half of the wrapper is part of its identity: any change to the code that sends and judges a call is another wrapper.
|
|
243
|
+
if (broker) for (const name of ["seam-broker.mjs", "gate-seam.mjs", "snapshot-metadata.mjs", "cargo-ledger.mjs"]) identityHash.update(fs.readFileSync(new URL(`./${name}`, import.meta.url)));
|
|
223
244
|
if (trampoline) identityHash.update(`\0client:${clientSha256}`);
|
|
224
245
|
const identity = identityHash.digest("hex");
|
|
225
246
|
const dir = path.join(base, `rk-cargo-shim-${identity.slice(0, 16)}`);
|
|
@@ -323,11 +344,16 @@ export function runShim(argv, { env = process.env, cwd = process.cwd(), spawn =
|
|
|
323
344
|
const token = env[SCAN_TOKEN_ENV];
|
|
324
345
|
const id = `${process.pid}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
|
325
346
|
const broker = map.mode === "broker";
|
|
326
|
-
|
|
347
|
+
// The seam (reset plan section 3): on a broker host whose environment carries the two seam variables (an npm or node suite with a broker call on a seam run), a compile
|
|
348
|
+
// goes through `rustright cargo` in the snapshot, never the carrier the broker refuses under the seam lock. Its row is an unsettled seam call from the moment it is
|
|
349
|
+
// filed, so a wrapper killed during the call keeps the door's lock; an outcome that submitted nothing (a refusal, a direct read, a version probe) settles it.
|
|
350
|
+
const seam = broker && seamEnvPresent(env);
|
|
351
|
+
const base = { id, mode: seam ? "seam" : broker ? "broker" : "direct", cwd, argv: words, ...(seam ? { settled: false } : {}) };
|
|
352
|
+
const unsent = seam ? { settled: true } : {};
|
|
327
353
|
// A call that cannot be recorded does not run: the ledger is how the gate learns what a test did, whatever the test does with the status.
|
|
328
354
|
const record = (entry) => appendLedger(map.ledgerDir, token, entry);
|
|
329
355
|
try { record({ ...base, status: "pending" }); } catch (error) { err(`rightkit-gate: RK_CARGO_LEDGER_ERROR: the call cannot be recorded (${error.message}); it does not run`); return SHIM_REFUSAL_STATUS; }
|
|
330
|
-
const refuse = (why) => { record({ ...base, status: "refused", code: why.code, message: why.message }); err(`rightkit-gate: ${why.code}: ${why.message}`); return SHIM_REFUSAL_STATUS; };
|
|
356
|
+
const refuse = (why) => { record({ ...base, ...unsent, status: "refused", code: why.code, message: why.message }); err(`rightkit-gate: ${why.code}: ${why.message}`); return SHIM_REFUSAL_STATUS; };
|
|
331
357
|
// locate-project runs the real cargo with CARGO pointing at it, never at the wrapper (direct mode). Broker mode reads the files only.
|
|
332
358
|
const locateEnv = { ...env, CARGO: map.realCargo };
|
|
333
359
|
const locate = broker ? (manifestPath, from) => locateWorkspaceByWalk(manifestPath, from) : (manifestPath, from, toolchain) => {
|
|
@@ -349,24 +375,29 @@ export function runShim(argv, { env = process.env, cwd = process.cwd(), spawn =
|
|
|
349
375
|
try { r = spawn(map.realCargo, decision.exec.args, { cwd, env: { ...rest, CARGO: map.realCargo, CARGO_TARGET_DIR: scratch }, stdio: "inherit" }); }
|
|
350
376
|
finally { try { fs.rmSync(scratch, { recursive: true, force: true }); } catch { /* scratch under the wrapper's own directory */ } }
|
|
351
377
|
if (r.error) return refuse({ code: "RK_CARGO_SHIM_ERROR", message: `${map.realCargo} did not start (${r.error.message})` });
|
|
352
|
-
record({ ...base, status: "ran", direct: true, exit: r.status ?? null });
|
|
378
|
+
record({ ...base, ...unsent, status: "ran", direct: true, exit: r.status ?? null });
|
|
353
379
|
return r.status ?? (r.signal ? 128 : SHIM_REFUSAL_STATUS);
|
|
354
380
|
}
|
|
355
|
-
if (
|
|
356
|
-
//
|
|
357
|
-
|
|
381
|
+
if (seam && decision.exec.workspace) {
|
|
382
|
+
// One `rustright cargo` in the call's own directory, judged by its result line and receipt (seam-broker.mjs); the outcome replaces the pending row (same id).
|
|
383
|
+
const { result, ledger } = runSeamCargoCall(decision.exec.args, { cwd, env, stdio: "inherit", client: map.broker.client, spawnSync: spawn });
|
|
384
|
+
if (result.stderr) err(String(result.stderr).replace(/\n$/, ""));
|
|
385
|
+
try { record({ ...base, ...ledger }); } catch (error) { err(`rightkit-gate: RK_CARGO_LEDGER_ERROR: the seam call's outcome cannot be recorded (${error.message})`); return result.status === 0 ? SHIM_REFUSAL_STATUS : result.status; }
|
|
386
|
+
return result.status;
|
|
358
387
|
}
|
|
388
|
+
// A compile on a broker host reaches the broker only through the seam: without the two seam variables nothing is sent and the call is refused.
|
|
389
|
+
if (broker && decision.exec.workspace) return refuse({ code: "RK_CARGO_NO_SEAM", message: `\`cargo ${words.join(" ")}\` compiles, and this environment carries neither RUSTRIGHT_GATE_COMMIT nor RUSTRIGHT_CLASS_A; nothing was sent` });
|
|
359
390
|
// A call that reads no workspace (version, help) runs as it is: the real cargo in direct mode, the host's cargo or the client in broker mode.
|
|
360
391
|
const viaClient = broker && !map.realCargo;
|
|
361
392
|
const command = viaClient ? map.broker.client : map.realCargo;
|
|
362
393
|
const spawnOpts = { cwd, env: decision.exec.env, stdio: "inherit" };
|
|
363
394
|
const r = viaClient ? spawnBrokerClient(spawn, command, ["cargo", ...decision.exec.args], spawnOpts, { platform: map.broker.platform }) : spawn(command, decision.exec.args, spawnOpts);
|
|
364
395
|
if (r.error) return refuse({ code: "RK_CARGO_SHIM_ERROR", message: `${command} did not start (${r.error.message})` });
|
|
365
|
-
record({ ...base, status: "ran", exit: r.status ?? null });
|
|
396
|
+
record({ ...base, ...unsent, status: "ran", exit: r.status ?? null });
|
|
366
397
|
return r.status ?? (r.signal ? 128 : SHIM_REFUSAL_STATUS);
|
|
367
398
|
}
|
|
368
399
|
|
|
369
|
-
// Run as the wrapper only when this file is the entry. Imported by another module (
|
|
400
|
+
// Run as the wrapper only when this file is the entry. Imported by another module (stage-seam.mjs, through managed-cargo.mjs), the entry
|
|
370
401
|
// may be anything, `node -e` arguments included, so a path that cannot be resolved is no wrapper run.
|
|
371
402
|
const invokedAsWrapper = (() => { try { return Boolean(process.argv[1]) && fs.realpathSync(process.argv[1]) === fs.realpathSync(fileURLToPath(import.meta.url)); } catch { return false; } })();
|
|
372
403
|
if (invokedAsWrapper) process.exit(runShim(process.argv.slice(2)));
|
package/cargo-target.mjs
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
// `.rightkit-qa-bin` stash) and run from there.
|
|
20
20
|
import { realpathSync } from "node:fs";
|
|
21
21
|
import { execFileSync } from "./background-process.mjs";
|
|
22
|
-
import { carriedOutputDir } from "./
|
|
22
|
+
import { carriedOutputDir } from "./stage-seam.mjs";
|
|
23
23
|
import { runCargoSync } from "./managed-cargo.mjs";
|
|
24
24
|
import path from "node:path";
|
|
25
25
|
import { fileURLToPath } from "node:url";
|
|
@@ -38,7 +38,7 @@ export function resolveTargetRoot(manifestPath, options = {}) {
|
|
|
38
38
|
const result = runCargoSync(args, { cwd: path.dirname(manifestPath), encoding: "utf8", maxBuffer: 64 * 1024 * 1024 });
|
|
39
39
|
if (result.error) throw result.error;
|
|
40
40
|
if (result.status !== 0) throw new Error(String(result.stderr ?? "").trim() || `exited ${result.status}`);
|
|
41
|
-
// A carried call (a snapshot stage's,
|
|
41
|
+
// A carried call (a snapshot stage's, stage-seam.mjs): the output directory is the signed receipt's, not what the call prints.
|
|
42
42
|
if (typeof result.outputDir === "string") return path.resolve(result.outputDir);
|
|
43
43
|
output = result.stdout;
|
|
44
44
|
}
|
package/carried-adapter-run.mjs
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// `node carried-adapter-run.mjs <adapter> -- <args>`: one pnpm, node or QA step of a snapshot stage on a broker host, carried
|
|
3
|
-
// (
|
|
4
|
-
// to the RustRight client, so the step is one
|
|
5
|
-
// counterpart of carried-cargo-run.mjs for Cargo.
|
|
3
|
+
// (stage-seam.mjs runStageAdapter) from this process's working directory. build-launch.mjs hands such a step to this entry instead of
|
|
4
|
+
// to the RustRight client, so the step is one seam adapter call, filed in the stage's ledger, with its compiles under it, the
|
|
5
|
+
// counterpart of carried-cargo-run.mjs for Cargo. Both are the process entries of the stage seam (stage-seam.mjs).
|
|
6
6
|
//
|
|
7
7
|
// The step's own environment arrives in this process's environment: build-launch.mjs sets RUSTRIGHT_ADAPTER_ENV to exactly the names the step
|
|
8
|
-
// declares (adapter-env.mjs adapterEnvLaunch) and those variables' values
|
|
9
|
-
//
|
|
10
|
-
// gate recomputes. A step that declares no env has no RUSTRIGHT_ADAPTER_ENV, so the request carries an empty environment.
|
|
8
|
+
// declares (adapter-env.mjs adapterEnvLaunch) and those variables' values; runStageAdapter sends that environment to the client unchanged and
|
|
9
|
+
// the broker judges it. A step that declares no env has no RUSTRIGHT_ADAPTER_ENV, so the request carries an empty environment.
|
|
11
10
|
//
|
|
12
11
|
// `node carried-adapter-run.mjs --skip-install <pnpm args>` runs nothing: a snapshot stage's dependencies were installed by the gate, so a
|
|
13
12
|
// step that only installs them is skipped with a log line (build-launch.mjs snapshotInstallSkip).
|
|
14
|
-
import { carriedCargoMapOf,
|
|
13
|
+
import { carriedCargoMapOf, runStageAdapter } from "./stage-seam.mjs";
|
|
15
14
|
|
|
16
15
|
const [first, ...rest] = process.argv.slice(2);
|
|
17
16
|
if (first === "--skip-install") {
|
|
@@ -26,6 +25,6 @@ if (!adapter || separator !== 0 || !carried?.map) {
|
|
|
26
25
|
process.stderr.write(`rightkit-gate: RK_ADAPTER_CARRIER_MISSING: ${!adapter || separator !== 0 ? "usage: carried-adapter-run.mjs <adapter> -- <args>" : (carried?.error ?? "no carried map in the environment")}; a snapshot stage's step is never sent to the client around its carrier\n`);
|
|
27
26
|
process.exit(101);
|
|
28
27
|
}
|
|
29
|
-
const result =
|
|
28
|
+
const result = runStageAdapter(adapter, args, { cwd: process.cwd(), env: process.env, stdio: "inherit" }, { map: carried.map });
|
|
30
29
|
if (result.error) process.stderr.write(`rightkit-gate: ${result.error.message}\n`);
|
|
31
30
|
process.exit(result.status ?? 1);
|
package/carried-cargo-run.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// `node carried-cargo-run.mjs <cargo args>`: one Cargo call of a snapshot stage on a broker host,
|
|
2
|
+
// `node carried-cargo-run.mjs <cargo args>`: one Cargo call of a snapshot stage on a broker host, through the stage seam (stage-seam.mjs, by way of managed-cargo.mjs runCargoSync) from
|
|
3
3
|
// this process's working directory. build-launch.mjs hands a configured `cargo` or `rustright cargo` step to this entry instead of
|
|
4
4
|
// to the RustRight client, so a config step is carried the same way on every platform (Windows included: no .cmd or shim is involved).
|
|
5
5
|
import { runCargoSync } from "./managed-cargo.mjs";
|
package/ci-compile-admission.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Compile-only CI admission for one named Rust fixture. This is not a publication qualification.
|
|
2
2
|
// Local Class A is enforced by the gate; hosted CI independently repeats Class A.
|
|
3
3
|
import { createHash } from "node:crypto";
|
|
4
|
-
import { canonicalJson } from "./
|
|
4
|
+
import { canonicalJson } from "./receipt-signature.mjs";
|
|
5
5
|
import { verifyCiCompileReceipts } from "./qualification-verify.mjs";
|
|
6
6
|
|
|
7
7
|
export const CI_SCOPE = "rust:rightkit-decimal";
|
package/clippy-route.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// The Clippy route: `rightkit-gate clippy [<cargo clippy args>]` (GATE-CONTRACT §1 "Clippy route & batching", E13 to E15; item 8 of
|
|
2
2
|
// the joint plan, rows 8.1 to 8.16 of the signed map). A gate-owned destination for a request such as
|
|
3
3
|
// `cargo clippy --workspace --all-targets -- -D warnings`: it builds HEAD's commit (never the checkout) from the gate-owned
|
|
4
|
-
// snapshot, under the repository's
|
|
4
|
+
// snapshot, under the repository's snapshot lock, after FULL class A (D8-2), and stops after diagnostics. It has no stage chain, runs no
|
|
5
5
|
// package, sign, publish or release stage, and writes nothing a door receipt, qualification or the full gate could take as stage
|
|
6
6
|
// evidence (row 8.5).
|
|
7
7
|
//
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
// (a relative one resolves inside the snapshot and may not leave it) and any word that is not an option of
|
|
13
13
|
// `cargo clippy` (a subcommand).
|
|
14
14
|
// sidecars a requested package that declares sidecars (Tauri `bundle.externalBin`) refuses the whole request, BLOCKED with
|
|
15
|
-
// RK_CLIPPY_SIDECAR_BOUND, before
|
|
15
|
+
// RK_CLIPPY_SIDECAR_BOUND, before the lock, class A, the sync or any compile, until item 7 row 7.05 stages sidecars
|
|
16
16
|
// from a snapshot. The request is never rewritten to leave such a package out (signed D8-1: three additions only).
|
|
17
17
|
// Linux direct, through the item 7 cargo wrapper (cargo-target-shim.mjs): every cargo launch is bound to the checkout's own
|
|
18
18
|
// target directory or refused, so nothing is written under the snapshot (row 8.12).
|
|
@@ -31,8 +31,7 @@ import { resolveExecutor as defaultResolveExecutor } from "./gate-executor.mjs";
|
|
|
31
31
|
import { directPlatform, realCargoOf } from "./managed-cargo.mjs";
|
|
32
32
|
import { defaultSpawnAsync, sidecarBoundCrate } from "./deterministic-scans.mjs";
|
|
33
33
|
import { gateStateDir } from "./gate-stages.mjs";
|
|
34
|
-
import { ProvenanceError
|
|
35
|
-
import { isToolchainUnknown } from "./snapshot-request.mjs";
|
|
34
|
+
import { ProvenanceError } from "./receipt-signature.mjs";
|
|
36
35
|
|
|
37
36
|
export const ROUTE_RECEIPT_SCHEMA = "rightkit.gate-clippy-route-receipt/1";
|
|
38
37
|
export const ROUTE_DIAGNOSTICS_SCHEMA = "rightkit.gate-clippy-route-diagnostics/1";
|
|
@@ -46,6 +45,53 @@ export const ROUTE_CODES = Object.freeze({
|
|
|
46
45
|
});
|
|
47
46
|
|
|
48
47
|
const sha256 = (v) => crypto.createHash("sha256").update(v).digest("hex");
|
|
48
|
+
const refuse = (code, message) => { throw new ProvenanceError(code, message); };
|
|
49
|
+
const isRecord = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
|
|
50
|
+
const isU64 = (v) => Number.isSafeInteger(v) && v >= 0;
|
|
51
|
+
/** The toolchain a receipt could not name: `{ state: "UNKNOWN", reason }` (snapshot-request.mjs, deleted at plan step 5, held it). */
|
|
52
|
+
const isToolchainUnknown = (v) => v !== null && typeof v === "object" && !Array.isArray(v) && Object.keys(v).length === 2 && v.state === "UNKNOWN" && typeof v.reason === "string" && v.reason !== "";
|
|
53
|
+
|
|
54
|
+
// ---- GB-50: the full attribution a Clippy (or check) route needs, read from the signed detail descriptor, never from the compact counts ----
|
|
55
|
+
const STAGE_EVIDENCE_SCHEMA = "rustright.stage-evidence/1";
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* `rustright_protocol::attestation::verify_attribution_detail(receipt, file_bytes)`, case for case (vector attribution-detail-vectors.v1.json). `receipt` is a
|
|
59
|
+
* receipt `verifyReceiptStrict` already accepted (so its compact `attribution`, `toolchain` and the descriptor's sha256 are signed) and `bytes` the evidence file the
|
|
60
|
+
* descriptor names. Checks in order: the descriptor is present and `bytes` hash to its sha256 (`detail`); the schema is rustright.stage-evidence/1 (`schema`); the
|
|
61
|
+
* file's `id` is this receipt's request (`job`) and its `toolchain` the receipt's (`evidence`); its attribution is available, `truncated` is exactly 0 in the file and in
|
|
62
|
+
* the compact twin (`truncated`); every row names package, target and kind with numeric errors and warnings; the compact `units`, `packages`, `errors`, `warnings`,
|
|
63
|
+
* `otherMessages` and `freshUnits` equal the values recomputed from the rows. Returns `{ rows, failedUnits }`. Counts alone never pass.
|
|
64
|
+
*/
|
|
65
|
+
function verifyAttributionDetail(receipt, bytes) {
|
|
66
|
+
const compact = receipt?.attribution;
|
|
67
|
+
if (!isRecord(compact)) refuse("evidence", "the receipt carries no attribution");
|
|
68
|
+
const descriptor = compact.detail;
|
|
69
|
+
if (!isRecord(descriptor) || typeof descriptor.sha256 !== "string" || typeof descriptor.path !== "string") refuse("detail", "the attribution names no evidence file");
|
|
70
|
+
if (sha256(bytes) !== descriptor.sha256) refuse("detail", "the evidence file is not the one the receipt signed");
|
|
71
|
+
let document;
|
|
72
|
+
try { document = JSON.parse(Buffer.from(bytes).toString("utf8")); } catch { refuse("malformed", "the evidence file is not JSON"); }
|
|
73
|
+
if (!isRecord(document) || document.schema !== STAGE_EVIDENCE_SCHEMA) refuse("schema", "unknown stage evidence schema");
|
|
74
|
+
if (typeof document.id !== "string" || document.id !== receipt.id) refuse("job", "the evidence file is for another request");
|
|
75
|
+
if (typeof document.toolchain !== "string" || document.toolchain !== receipt.toolchain) refuse("evidence", "the evidence file names another toolchain than the receipt");
|
|
76
|
+
const attribution = document.attribution;
|
|
77
|
+
if (!isRecord(attribution) || attribution.available !== true) refuse("evidence", "the evidence file holds no available attribution");
|
|
78
|
+
if (!isU64(attribution.truncated)) refuse("evidence", "the evidence file does not say whether the attribution is complete");
|
|
79
|
+
if (attribution.truncated !== 0 || compact.truncated !== 0) refuse("truncated", "the attribution is truncated or its completeness is not stated");
|
|
80
|
+
const rows = attribution.units;
|
|
81
|
+
if (!Array.isArray(rows)) refuse("evidence", "the evidence file holds no unit rows");
|
|
82
|
+
const packages = new Set(); let errors = 0; let warnings = 0; let other = 0; let fresh = 0; let failedUnits = 0;
|
|
83
|
+
for (const row of rows) {
|
|
84
|
+
const text = (name) => (isRecord(row) && typeof row[name] === "string" && row[name] !== "" ? row[name] : null);
|
|
85
|
+
const count = (name) => (isRecord(row) && isU64(row[name]) ? row[name] : null);
|
|
86
|
+
const [pkg, target, kind, e, w] = [text("package"), text("target"), text("kind"), count("errors"), count("warnings")];
|
|
87
|
+
if (pkg === null || target === null || kind === null || e === null || w === null) refuse("evidence", "a unit row lacks its package, target, kind, errors or warnings");
|
|
88
|
+
packages.add(pkg); errors += e; warnings += w; other += count("otherMessages") ?? 0; fresh += row.fresh === true ? 1 : 0; failedUnits += e > 0 ? 1 : 0;
|
|
89
|
+
}
|
|
90
|
+
const derived = { units: rows.length, packages: packages.size, errors, warnings, otherMessages: other, freshUnits: fresh };
|
|
91
|
+
for (const [name, value] of Object.entries(derived)) if (compact[name] !== value) refuse("evidence", `the receipt's compact attribution ${name} disagrees with the evidence file's rows`);
|
|
92
|
+
return { rows, failedUnits };
|
|
93
|
+
}
|
|
94
|
+
|
|
49
95
|
const posix = (p) => String(p).replaceAll("\\", "/");
|
|
50
96
|
const text = (r) => String(r?.stdout ?? "");
|
|
51
97
|
const failed = (r) => !r || Boolean(r.error) || r.status !== 0;
|
|
@@ -318,8 +364,8 @@ const resultLine = (o, tag, value) => o.out(`${tag} clippy route result ${JSON.s
|
|
|
318
364
|
/**
|
|
319
365
|
* `rightkit-gate clippy`: the entry. `args` are the words after `clippy`. `deps` (from the gate's main): `main` (the gate entry, for
|
|
320
366
|
* the door's own full class A), `io` (its overrides), `absoluteEnv` (the inherited locations a snapshot compile requires absolute),
|
|
321
|
-
* and, for tests, overrides of `resolveExecutor`, `snapshot` (snapshot.mjs), `snapshotCheck` (snapshot-check.mjs), `
|
|
322
|
-
*
|
|
367
|
+
* and, for tests, overrides of `resolveExecutor`, `snapshot` (snapshot.mjs), `snapshotCheck` (snapshot-check.mjs), `takeSnapshotLock`,
|
|
368
|
+
* `syncSnapshot`, `runClassA`, `runCargo` and `shim` (cargo-target-shim.mjs).
|
|
323
369
|
*/
|
|
324
370
|
export async function clippyCommand(o, args, deps = {}) {
|
|
325
371
|
const tag = "rightkit-gate:";
|
|
@@ -361,7 +407,6 @@ export async function clippyCommand(o, args, deps = {}) {
|
|
|
361
407
|
|
|
362
408
|
const snap = deps.snapshot ?? await import("./snapshot.mjs");
|
|
363
409
|
const sc = deps.snapshotCheck ?? await import("./snapshot-check.mjs");
|
|
364
|
-
const ownershipApi = deps.ownership ?? await import("./build-ownership.mjs");
|
|
365
410
|
let selected; let snapshotsAt; let snapshotDir; let repoKey;
|
|
366
411
|
try {
|
|
367
412
|
selected = snap.resolveCommit(root, "HEAD");
|
|
@@ -379,7 +424,7 @@ export async function clippyCommand(o, args, deps = {}) {
|
|
|
379
424
|
const relative = (deps.absoluteEnv ?? []).filter((n) => typeof o.env[n] === "string" && o.env[n] !== "" && !path.isAbsolute(o.env[n]));
|
|
380
425
|
if (relative.length) { o.err(`${tag} BLOCKED: ${relative.map((n) => `${n}=${o.env[n]}`).join(", ")} ${relative.length > 1 ? "are" : "is"} relative; a snapshot compile inherits CARGO_HOME, sccache and temp only as absolute paths; nothing ran`); return BLOCKED; }
|
|
381
426
|
|
|
382
|
-
// Sidecar-bound scope, refused BEFORE
|
|
427
|
+
// Sidecar-bound scope, refused BEFORE the lock, the sync, class A or any compile (row 8.8, lead decision 2026-10-29). Each Tauri
|
|
383
428
|
// configuration is read from HEAD's commit, never from the checkout's files. A commit that declares no sidecar anywhere needs no
|
|
384
429
|
// further look (no cargo process starts before class A). Otherwise the requested packages come from the checkout's
|
|
385
430
|
// `cargo metadata --no-deps --offline --locked` (no compile, nothing written) and the request is refused when one of them declares
|
|
@@ -400,11 +445,13 @@ export async function clippyCommand(o, args, deps = {}) {
|
|
|
400
445
|
if (preBound.length) { o.err(sidecarRefusal(tag, preBound, "read from the commit")); resultLine(o, tag, { result: "BLOCKED", code: ROUTE_CODES.sidecarBound, blockedOn: ["item7:7.05"], bound: preBound, launched: false }); return BLOCKED; }
|
|
401
446
|
|
|
402
447
|
const timings = {}; const lap = (name, since) => { timings[name] = Date.now() - since; };
|
|
403
|
-
//
|
|
404
|
-
|
|
405
|
-
|
|
448
|
+
// The snapshot lock first (E6, reset plan section 3): held from before the sync until the diagnostics are written. This route runs only on a host with no broker, so it is
|
|
449
|
+
// the legacy lock, reclaimed when its holder is proven gone. A busy repository runs nothing and syncs nothing.
|
|
450
|
+
let lock;
|
|
451
|
+
try { lock = (deps.takeSnapshotLock ?? snap.takeSnapshotLock)({ checkout: root, root: snapshotsAt }); }
|
|
406
452
|
catch (e) { if (e.code !== "busy" && e.code !== "refused") throw e; o.err(`${tag} BLOCKED: ${e.message}; ${e.code === "refused" ? "nothing ran, nothing created" : "the route never re-syncs a snapshot another request holds; nothing ran"}`); return BLOCKED; }
|
|
407
|
-
o.out(`${tag}
|
|
453
|
+
o.out(`${tag} snapshot lock held ${lock.token}${lock.reclaimed ? ` (reclaimed from ${lock.reclaimed.from}: ${lock.reclaimed.proof})` : ""}`);
|
|
454
|
+
const lockView = snap.lockView(lock);
|
|
408
455
|
const abort = o.abort ?? new AbortController();
|
|
409
456
|
let shimDir = null; let messagesFile = null;
|
|
410
457
|
const stopped = []; const onSignal = (sig) => () => { stopped.push(sig); abort.abort(); };
|
|
@@ -413,14 +460,14 @@ export async function clippyCommand(o, args, deps = {}) {
|
|
|
413
460
|
try {
|
|
414
461
|
let t = Date.now();
|
|
415
462
|
let synced;
|
|
416
|
-
try { synced = (deps.syncSnapshot ?? snap.syncSnapshot)({ checkout: root, rev: selected.commit, root: snapshotsAt }); }
|
|
463
|
+
try { synced = (deps.syncSnapshot ?? snap.syncSnapshot)({ checkout: root, rev: selected.commit, root: snapshotsAt, lock: { held: lockView } }); }
|
|
417
464
|
catch (e) { o.err(`${tag} ${e.code === "error" ? "RK_CHECK_ERROR" : "BLOCKED"}: snapshot ${e.message}; nothing ran`); return e.code === "error" ? REFUSED_EXIT : BLOCKED; }
|
|
418
465
|
lap("sync", t);
|
|
419
466
|
o.out(`${tag} snapshot ${synced.path} is commit ${synced.commit} tree ${synced.tree} (written=${synced.written} removed=${synced.removed} unchanged=${synced.unchanged})`);
|
|
420
467
|
|
|
421
468
|
// FULL class A first (D8-2, E1): the door's own check of the snapshot. A red class A starts no Clippy.
|
|
422
469
|
t = Date.now();
|
|
423
|
-
const classA = await (deps.runClassA ?? (() => deps.main(["check", "--commit", synced.commit, "--full-a", "--snapshot", synced.path, "--rule-tier", "release"], { ...(deps.io ?? {}), cwd: root,
|
|
470
|
+
const classA = await (deps.runClassA ?? (() => deps.main(["check", "--commit", synced.commit, "--full-a", "--snapshot", synced.path, "--rule-tier", "release"], { ...(deps.io ?? {}), cwd: root, snapshotLock: lockView })))();
|
|
424
471
|
lap("classA", t);
|
|
425
472
|
if (classA !== 0) { o.err(`${tag} FAILED: class A is red for ${synced.commit.slice(0, 12)}; Clippy was not started`); resultLine(o, tag, { result: "FAILED", reason: "class-a", exit: classA, commit: synced.commit, clippyStarted: false }); return classA === REFUSED_EXIT ? REFUSED_EXIT : BLOCKED; }
|
|
426
473
|
|
|
@@ -495,7 +542,7 @@ export async function clippyCommand(o, args, deps = {}) {
|
|
|
495
542
|
try { treeAtExit = sc.verifySnapshotDir({ checkout: realCheckout, dir: synced.path, commit: synced.commit, tree: synced.tree, when: "after Clippy" }); }
|
|
496
543
|
catch (e) { fs.rmSync(messagesFile, { force: true }); o.err(`${tag} RK_CHECK_ERROR: ${e.message}; the diagnostics are discarded, they cover no known bytes`); resultLine(o, tag, { result: "FAILED", code: "RK_CHECK_ERROR", discarded: true, commit: synced.commit }); return REFUSED_EXIT; }
|
|
497
544
|
lap("afterExitBind", t);
|
|
498
|
-
if (!
|
|
545
|
+
if (!lock.held()) { fs.rmSync(messagesFile, { force: true }); o.err(`${tag} RK_CHECK_ERROR: the snapshot lock ${lock.token} is no longer held; the diagnostics are discarded`); return REFUSED_EXIT; }
|
|
499
546
|
|
|
500
547
|
t = Date.now();
|
|
501
548
|
const summary = summarizeRun({ ...run, scope });
|
|
@@ -507,7 +554,7 @@ export async function clippyCommand(o, args, deps = {}) {
|
|
|
507
554
|
schema: ROUTE_RECEIPT_SCHEMA, requestId, executor: "direct", issuedAt: new Date().toISOString(),
|
|
508
555
|
commit: { sha: synced.commit, tree: synced.tree },
|
|
509
556
|
snapshot: { path: synced.path, treeAtStart, treeAtExit },
|
|
510
|
-
|
|
557
|
+
snapshotLock: { token: lock.token },
|
|
511
558
|
outputDir, outputDirs: { [cargoDir]: outputDir },
|
|
512
559
|
cargoWrapper: { identity: shim.identity, workspaces: shim.workspaces },
|
|
513
560
|
toolchain,
|
|
@@ -524,8 +571,8 @@ export async function clippyCommand(o, args, deps = {}) {
|
|
|
524
571
|
} finally {
|
|
525
572
|
for (const [sig, h] of handlers) process.off(sig, h);
|
|
526
573
|
if (shimDir) fs.rmSync(shimDir, { recursive: true, force: true });
|
|
527
|
-
|
|
528
|
-
|
|
574
|
+
// This route submits no broker job, so its lock is released whatever the run's outcome.
|
|
575
|
+
lock();
|
|
529
576
|
}
|
|
530
577
|
}
|
|
531
578
|
|
package/compile-inputs.mjs
CHANGED
|
@@ -1,17 +1,92 @@
|
|
|
1
|
-
// The declared compile inputs a
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
1
|
+
// The declared compile inputs of a gate snapshot: the ignored paths (a built `dist`, generated assets, a Windows identity package) the commit does not hold,
|
|
2
|
+
// listed in the snapshot's `.rustright/compile-inputs.json` (or the legacy `.rightkit/compile-inputs.json`) and produced into the snapshot by the gate's own producer
|
|
3
|
+
// steps. The gate reads them from the snapshot and judges exactly those bytes (judgeCompileInputs). The broker captures no declared input (the seam carries none:
|
|
4
|
+
// docs/BUILD.md section 2 "Request", reset plan section 4 row `stage-ledger.mjs, compile-inputs.mjs`), so there is no broker-captured tree to judge here.
|
|
5
5
|
import crypto from "node:crypto";
|
|
6
6
|
import fs from "node:fs";
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
import { spawnSync } from "./background-process.mjs";
|
|
9
9
|
import { SECRET_PATTERNS } from "./publish-cargo.mjs";
|
|
10
|
-
import { COMPILE_INPUTS_CANONICAL, COMPILE_INPUTS_LEGACY, SnapshotRequestError, readDeclaredInputs } from "./snapshot-request.mjs";
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
// ---- the declared compile inputs, read and digested the way the broker does (moved here from snapshot-request.mjs, deleted at plan step 5) ----
|
|
12
|
+
/**
|
|
13
|
+
* Where the declared compile inputs are listed, as read from the snapshot (the broker's COMPILE_INPUTS; GB-49): `.rustright/compile-inputs.json` first,
|
|
14
|
+
* `.rightkit/compile-inputs.json` ONLY when the canonical file is absent. A present but invalid canonical declaration is an error, never a fallback.
|
|
15
|
+
*/
|
|
16
|
+
export const COMPILE_INPUTS_CANONICAL = ".rustright/compile-inputs.json";
|
|
17
|
+
export const COMPILE_INPUTS_LEGACY = ".rightkit/compile-inputs.json";
|
|
18
|
+
export const COMPILE_INPUT_DECLARATIONS = Object.freeze([COMPILE_INPUTS_CANONICAL, COMPILE_INPUTS_LEGACY]);
|
|
19
|
+
export const MAX_DECLARATION_BYTES = 4 * 1024 * 1024;
|
|
20
|
+
|
|
21
|
+
export class SnapshotRequestError extends Error {
|
|
22
|
+
constructor(code, message) { super(message); this.name = "SnapshotRequestError"; this.code = code; }
|
|
23
|
+
}
|
|
24
|
+
const fail = (code, message) => { throw new SnapshotRequestError(code, message); };
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
// ---- declared compile inputs, read and digested the way the broker does (check_admission.rs declared_inputs / snapshot_inputs) ----
|
|
28
|
+
|
|
29
|
+
const lstatOrNull = (p) => { try { return fs.lstatSync(p); } catch (e) { if (e.code === "ENOENT") return null; throw e; } };
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The declared inputs of a snapshot, read FROM THE SNAPSHOT, never the checkout, by the one rule every RightKit reader shares (the broker's, vector
|
|
33
|
+
* docs/contracts/declared-inputs.fixtures.json): `.rustright/compile-inputs.json` when it exists, else `.rightkit/compile-inputs.json`, else none. Either file
|
|
34
|
+
* is judged by the same checks: no link on its path, a regular file of at most 4 MiB, JSON with `inputs` a list of plain relative paths (not absolute, no `.`,
|
|
35
|
+
* `..` or empty component, not inside `.git`) and no input that is, or holds, either declaration file. A present but invalid canonical declaration is an
|
|
36
|
+
* error: it is never read as the legacy one.
|
|
37
|
+
*/
|
|
38
|
+
/** Host platform names a declared input may scope itself to (`{ path, platforms }`). */
|
|
39
|
+
export const DECLARED_INPUT_PLATFORMS = Object.freeze({ darwin: "mac", win32: "win", linux: "linux" });
|
|
40
|
+
|
|
41
|
+
export function readDeclaredInputs(snapshotRoot, { platform = process.platform } = {}) {
|
|
42
|
+
let file = null; let at = null; let meta = null;
|
|
43
|
+
for (const candidate of COMPILE_INPUT_DECLARATIONS) {
|
|
44
|
+
let here = snapshotRoot; let found = true;
|
|
45
|
+
for (const part of candidate.split("/")) {
|
|
46
|
+
here = path.join(here, part);
|
|
47
|
+
const m = lstatOrNull(here);
|
|
48
|
+
if (m === null) { found = false; break; }
|
|
49
|
+
if (m.isSymbolicLink()) fail("declared-inputs", `${candidate} runs through a link at ${here}`);
|
|
50
|
+
meta = m;
|
|
51
|
+
}
|
|
52
|
+
if (found) { file = candidate; at = here; break; }
|
|
53
|
+
}
|
|
54
|
+
if (file === null) return [];
|
|
55
|
+
if (!meta.isFile()) fail("declared-inputs", `${file} is not a regular file`);
|
|
56
|
+
if (meta.size > MAX_DECLARATION_BYTES) fail("declared-inputs", `${file} is larger than ${MAX_DECLARATION_BYTES} bytes`);
|
|
57
|
+
let value;
|
|
58
|
+
try { value = JSON.parse(fs.readFileSync(at, "utf8")); } catch (e) { fail("declared-inputs", `${file} is not JSON (${e.message})`); }
|
|
59
|
+
if (!value || typeof value !== "object" || !Array.isArray(value.inputs)) fail("declared-inputs", `${file}: \`inputs\` must be a list of paths`);
|
|
60
|
+
// An entry is a path (every platform) or { path, platforms }: a platform-scoped input (a Windows-only identity package) is declared
|
|
61
|
+
// only on the hosts it names, so another host neither requires nor digests it. Unknown keys or platform names refuse.
|
|
62
|
+
const host = DECLARED_INPUT_PLATFORMS[platform] ?? platform;
|
|
63
|
+
const kept = [];
|
|
64
|
+
for (const entry of value.inputs) {
|
|
65
|
+
let input = entry;
|
|
66
|
+
if (entry && typeof entry === "object" && !Array.isArray(entry)) {
|
|
67
|
+
const extra = Object.keys(entry).filter((k) => k !== "path" && k !== "platforms");
|
|
68
|
+
if (extra.length) fail("declared-inputs", `${file}: an input object has only path and platforms (found ${extra.join(", ")})`);
|
|
69
|
+
const names = Object.values(DECLARED_INPUT_PLATFORMS);
|
|
70
|
+
if (!Array.isArray(entry.platforms) || !entry.platforms.length || entry.platforms.some((x) => !names.includes(x))) fail("declared-inputs", `${file}: ${JSON.stringify(entry.path)}: platforms must be a non-empty list of ${names.join(", ")}`);
|
|
71
|
+
input = entry.path;
|
|
72
|
+
}
|
|
73
|
+
if (typeof input !== "string" || !input) fail("declared-inputs", `${file}: every input is a non-empty relative path`);
|
|
74
|
+
const here = !(entry && typeof entry === "object") || entry.platforms.includes(host);
|
|
75
|
+
const components = input.split(/[\\/]/);
|
|
76
|
+
if (path.isAbsolute(input) || path.posix.isAbsolute(input) || path.win32.isAbsolute(input) || components.some((c) => c === "" || c === "." || c === "..")) fail("declared-inputs", `${file}: ${input} is not a plain relative path inside the snapshot`);
|
|
77
|
+
if (components.some((c) => c.toLowerCase() === ".git")) fail("declared-inputs", `${file}: ${input} is inside .git; repository metadata is never a compile input`);
|
|
78
|
+
for (const declaration of COMPILE_INPUT_DECLARATIONS) {
|
|
79
|
+
const parts = declaration.split("/");
|
|
80
|
+
if (components.length <= parts.length && components.every((c, i) => c === parts[i])) fail("declared-inputs", `${file}: ${input} overlaps the declaration file itself (${declaration})`);
|
|
81
|
+
}
|
|
82
|
+
if (here) kept.push(input);
|
|
83
|
+
}
|
|
84
|
+
return kept;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
/** The canonical declaration (GB-49); the legacy `.rightkit/compile-inputs.json` is read only when it is absent (readDeclaredInputs below, the one reader). */
|
|
13
89
|
export const COMPILE_INPUTS_FILE = COMPILE_INPUTS_CANONICAL;
|
|
14
|
-
export { COMPILE_INPUTS_LEGACY };
|
|
15
90
|
|
|
16
91
|
/** Files of one declared input in the broker's order (children by name), refusing links; [{ name, abs }]. */
|
|
17
92
|
function inputFiles(root, input) {
|
|
@@ -28,21 +103,22 @@ function inputFiles(root, input) {
|
|
|
28
103
|
}
|
|
29
104
|
|
|
30
105
|
/**
|
|
31
|
-
* Judges the
|
|
106
|
+
* Judges the declared inputs under `root` (the gate's snapshot): each declared path must exist without links; every `.js/.mjs/.cjs`
|
|
32
107
|
* file parses (`node --check`), every `.json` file parses, and no file carries a secret. Returns { inputs: [{ path, sha256,
|
|
33
|
-
* files }], findings: [string] }
|
|
34
|
-
*
|
|
108
|
+
* files }], findings: [string], missing: [string], malformed: string|null }: `sha256` is computed over each file's name, NUL, bytes, NUL in order, so a
|
|
109
|
+
* ledger cross-check (stage-ledger.mjs declaredInputProblems) and the direct receipt name the same bytes; `missing` is the subset of `findings` that
|
|
110
|
+
* only say a declared path is not in the tree; `malformed` is the declaration's own problem (the run refuses on it).
|
|
35
111
|
*/
|
|
36
112
|
export function judgeCompileInputs(root, { spawn = spawnSync, execPath = process.execPath } = {}) {
|
|
37
|
-
const findings = [];
|
|
113
|
+
const findings = []; const missing = [];
|
|
38
114
|
// One reader for every consumer: canonical first, legacy only when the canonical file is absent, shared link, size, path and overlap checks.
|
|
39
115
|
let declared;
|
|
40
|
-
try { declared = readDeclaredInputs(root); } catch (e) { if (e instanceof SnapshotRequestError) return { inputs: [], findings: [e.message] }; throw e; }
|
|
41
|
-
if (declared.length === 0) return { inputs: [], findings };
|
|
116
|
+
try { declared = readDeclaredInputs(root); } catch (e) { if (e instanceof SnapshotRequestError) return { inputs: [], findings: [e.message], missing, malformed: e.message }; throw e; }
|
|
117
|
+
if (declared.length === 0) return { inputs: [], findings, missing, malformed: null };
|
|
42
118
|
const inputs = [];
|
|
43
119
|
for (const input of declared) {
|
|
44
120
|
let files;
|
|
45
|
-
try { files = inputFiles(root, input.split(/[\\/]/).join("/")); } catch (e) {
|
|
121
|
+
try { files = inputFiles(root, input.split(/[\\/]/).join("/")); } catch (e) { const finding = `${input}: ${e.code === "ENOENT" ? "missing from the snapshot" : e.message}`; findings.push(finding); if (e.code === "ENOENT") missing.push(finding); continue; }
|
|
46
122
|
const hash = crypto.createHash("sha256");
|
|
47
123
|
for (const f of files) {
|
|
48
124
|
const bytes = fs.readFileSync(f.abs);
|
|
@@ -59,5 +135,5 @@ export function judgeCompileInputs(root, { spawn = spawnSync, execPath = process
|
|
|
59
135
|
}
|
|
60
136
|
inputs.push({ path: input, sha256: hash.digest("hex"), files: files.length });
|
|
61
137
|
}
|
|
62
|
-
return { inputs, findings };
|
|
138
|
+
return { inputs, findings, missing, malformed: null };
|
|
63
139
|
}
|
package/cross-targets.mjs
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
// Shared by local-publish.mjs (unit plans and batch clippy), deterministic-scans.mjs (the gate's class B scans), stage-sidecar.mjs and
|
|
7
7
|
// scripts/ci/gate.mjs. Imports only node:fs and node:path.
|
|
8
8
|
import fs from "node:fs";
|
|
9
|
+
import os from "node:os";
|
|
9
10
|
import path from "node:path";
|
|
10
11
|
|
|
11
12
|
export const CROSS_TARGETS = Object.freeze({ linux: "x86_64-unknown-linux-gnu", darwin: "aarch64-apple-darwin", win32: "x86_64-pc-windows-gnu" });
|
|
@@ -59,11 +60,12 @@ export function scopedCrossTargets(entry = {}, platform = "darwin") {
|
|
|
59
60
|
|
|
60
61
|
/**
|
|
61
62
|
* The provisioned zig wrapper directory: RIGHTKIT_CROSS_CC_DIR, else `<managed data root>/zig/cross-cc` (where scripts/ci/provision-zig.mjs
|
|
62
|
-
* writes on a Mac or Dell
|
|
63
|
+
* writes on a Mac or Dell; on Linux the account's state directory, `$XDG_STATE_HOME/rightkit`, else `~/.local/state/rightkit`, as
|
|
64
|
+
* managed-roots.mjs resolves it), else null. Linux had no default (cloud 2026-11-06: zig provisioned at ~/.local/state/rightkit/zig was not found).
|
|
63
65
|
*/
|
|
64
|
-
export function crossCcDir({ env = process.env, exists = fs.existsSync, platform = process.platform } = {}) {
|
|
66
|
+
export function crossCcDir({ env = process.env, exists = fs.existsSync, platform = process.platform, home = os.homedir() } = {}) {
|
|
65
67
|
if (env[CROSS_CC_ENV]) return env[CROSS_CC_ENV];
|
|
66
|
-
const managed = platform === "win32" ? "D:\\.rightkit-managed" : platform === "darwin" ? "/Volumes/D/.rightkit-managed" :
|
|
68
|
+
const managed = platform === "win32" ? "D:\\.rightkit-managed" : platform === "darwin" ? "/Volumes/D/.rightkit-managed" : path.join(env.XDG_STATE_HOME || path.join(home, ".local", "state"), "rightkit");
|
|
67
69
|
const dir = managed ? path.join(managed, "zig", "cross-cc") : null;
|
|
68
70
|
return dir && exists(dir) ? dir : null;
|
|
69
71
|
}
|
package/deps-cargo-lock.mjs
CHANGED
|
@@ -16,7 +16,7 @@ import { existsSync, readFileSync, realpathSync, rmSync, statSync, writeFileSync
|
|
|
16
16
|
import path from "node:path";
|
|
17
17
|
import { spawnSync } from "./background-process.mjs";
|
|
18
18
|
import { runCargoSync } from "./managed-cargo.mjs";
|
|
19
|
-
import { CARRIED_CARGO_MAP_ENV } from "./
|
|
19
|
+
import { CARRIED_CARGO_MAP_ENV } from "./stage-seam.mjs";
|
|
20
20
|
import { CHECKOUT_ENV } from "./gate-stages.mjs";
|
|
21
21
|
|
|
22
22
|
export const LOCK_UPDATE_CODES = Object.freeze({
|