@rightkit/release 0.6.38 → 0.6.40
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/bin/rightkit-gate.mjs +70 -14
- package/deterministic-scans.mjs +132 -14
- package/local-publish.mjs +29 -3
- package/package.json +1 -1
- package/publish-local-cargo.mjs +20 -4
- package/rightkit-versions.json +508 -450
- package/snapshot-metadata.mjs +12 -3
- package/stage-ledger.mjs +6 -1
package/bin/rightkit-gate.mjs
CHANGED
|
@@ -946,7 +946,12 @@ const plainRelative = (p) => typeof p === "string" && p !== "" && !path.posix.is
|
|
|
946
946
|
* - An npm package scan (test:npm, tsc, eslint, biome) keys on the package's workspace closure (every dependency that is a workspace
|
|
947
947
|
* package, whatever its spec, transitively, by package name) and the root npm inputs; test:scripts-ci on scripts/, ci/, .github/, packages/release and the
|
|
948
948
|
* root install graph. Every other class B scan (generated-docs, swift-build) uses the whole tree.
|
|
949
|
-
* - Class A:
|
|
949
|
+
* - Class A: pnpm-lockfile and advisory-exceptions are never cached (live answers). cargo-deny, cargo-audit and pnpm-audit are cached by
|
|
950
|
+
* their inputs and the identity of the advisory data they read (rightkit#1464, ADR-001 C5; advisoryKey below): a Cargo workspace's lock
|
|
951
|
+
* blob, every Cargo.toml of the commit, the deny and cargo configuration files, and the pinned RustSec commit (cargo-deny and cargo-audit
|
|
952
|
+
* read exactly that commit); a pnpm root's lock, manifests and npm configuration. cargo-deny also reads the crate index (yanked
|
|
953
|
+
* versions) and pnpm audit asks the registry, neither of which a commit pins, so those keys carry the UTC day: a rerun the same day is a
|
|
954
|
+
* hit, the next day is a run. A changed pin, lock, manifest or configuration is a different key; rustfmt,
|
|
950
955
|
* node-check, actionlint and the parse scans key on their files' blob ids; cargo-package-list on the crate, the manifest projection
|
|
951
956
|
* and its lock entry; the rest on the whole tree.
|
|
952
957
|
*/
|
|
@@ -958,7 +963,15 @@ const LINT_CONFIG_NAMES = [...ESLINT_CONFIG_FILES, ...BIOME_CONFIG_FILES];
|
|
|
958
963
|
// The gate's own test suite reads the CI scripts, the gate config and the release package it imports from.
|
|
959
964
|
const SCRIPTS_CI_INPUTS = ["scripts", "ci", ".github", "packages/release", "package.json", "pnpm-lock.yaml"];
|
|
960
965
|
|
|
961
|
-
|
|
966
|
+
/** ci/shards.json `solo` (crate names that always get an invocation of their own), read from the gated tree; empty when the file is absent or unreadable. */
|
|
967
|
+
function shardSoloOf(o, repo) {
|
|
968
|
+
try {
|
|
969
|
+
const solo = JSON.parse(o.readFile(path.join(repo, "ci", "shards.json"))).solo;
|
|
970
|
+
return Array.isArray(solo) ? solo.filter((n) => typeof n === "string") : [];
|
|
971
|
+
} catch { return []; }
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
export function buildCacheDigest({ objectId, headTree, rustUnits = [], npmUnits = [], cargoDir = ".", rustLock = null, rustLocks = null, crateFeatures = {}, listFiles = null, readBlob = null, today = () => new Date().toISOString().slice(0, 10) }) {
|
|
962
975
|
const memo = new Map(); const reachMemos = new Map(); const externalMemo = new Map();
|
|
963
976
|
const idOf = (p) => { if (!memo.has(p)) memo.set(p, p === "." ? headTree : objectId(p)); return memo.get(p); };
|
|
964
977
|
// npm: a package's test, tsc and eslint scans read the package, every workspace package it depends on (package.json
|
|
@@ -1026,6 +1039,28 @@ export function buildCacheDigest({ objectId, headTree, rustUnits = [], npmUnits
|
|
|
1026
1039
|
// projection and its own lock entry; anything else (cargo metadata, licence, ownership catalog, secret scan) on the whole tree,
|
|
1027
1040
|
// so it is reused for a rerun of the same commit and nothing else.
|
|
1028
1041
|
const liveScan = (id) => /^(cargo-deny|cargo-audit|pnpm-audit|pnpm-lockfile|advisory-exceptions)(:|$)/.test(id);
|
|
1042
|
+
const ADVISORY_SCAN = /^(cargo-deny|cargo-audit|pnpm-audit)(:|$)/;
|
|
1043
|
+
// The key of an advisory scan (rightkit#1464), or null when an input cannot be identified (the scan then runs). Every input that decides the
|
|
1044
|
+
// verdict and is not in the scan's id, command or environment is here; the advisory database's commit (cargo) is in the scan's own environment
|
|
1045
|
+
// (RK_ADVISORY_DB_COMMIT) and its pin object, the gate's code and advisory-db.json are in the environment digest the caller appends.
|
|
1046
|
+
const advisoryKey = (scan) => {
|
|
1047
|
+
if (typeof listFiles !== "function") return null;
|
|
1048
|
+
const dir = typeof scan.cwd === "string" && scan.cwd !== "" ? scan.cwd : ".";
|
|
1049
|
+
const idsOf = (paths) => [...new Set(paths)].sort().map((p) => [p, idOf(p) ?? null]);
|
|
1050
|
+
const all = listFiles(".");
|
|
1051
|
+
if (/^pnpm-audit(:|$)/.test(scan.id)) {
|
|
1052
|
+
const lock = inWs(dir, "pnpm-lock.yaml");
|
|
1053
|
+
if (idOf(lock) === null || idOf(lock) === undefined) return null;
|
|
1054
|
+
const manifests = all.filter((f) => /(^|\/)package\.json$/.test(f) && (dir === "." || f === inWs(dir, "package.json") || f.startsWith(`${dir}/`)));
|
|
1055
|
+
return canonicalJson({ kind: "pnpm-audit", id: scan.id, day: today(), inputs: idsOf([lock, inWs(dir, "pnpm-workspace.yaml"), inWs(dir, ".npmrc"), ".npmrc", ...manifests]) });
|
|
1056
|
+
}
|
|
1057
|
+
const lock = inWs(dir, "Cargo.lock");
|
|
1058
|
+
if (idOf(lock) === null || idOf(lock) === undefined) return null;
|
|
1059
|
+
const ancestors = ancestorDirsOf(dir);
|
|
1060
|
+
const config = [dir, ...ancestors].flatMap((d) => [".cargo", "deny.toml", "audit.toml", "rust-toolchain", "rust-toolchain.toml"].map((f) => inWs(d, f)));
|
|
1061
|
+
const manifests = all.filter((f) => /(^|\/)Cargo\.toml$/.test(f));
|
|
1062
|
+
return canonicalJson({ kind: scan.id.startsWith("cargo-deny") ? "cargo-deny" : "cargo-audit", id: scan.id, day: today(), pin: scan.advisoryPin ?? null, inputs: idsOf([lock, ...manifests, ...config]) });
|
|
1063
|
+
};
|
|
1029
1064
|
const fileList = (scan) => {
|
|
1030
1065
|
if (Array.isArray(scan.files) && scan.files.length) return scan.files;
|
|
1031
1066
|
const args = Array.isArray(scan.args) ? scan.args : [];
|
|
@@ -1036,8 +1071,9 @@ export function buildCacheDigest({ objectId, headTree, rustUnits = [], npmUnits
|
|
|
1036
1071
|
};
|
|
1037
1072
|
return (scan) => {
|
|
1038
1073
|
if (scan.class === "A") {
|
|
1039
|
-
if (liveScan(scan.id)) return null;
|
|
1074
|
+
if (liveScan(scan.id) && !ADVISORY_SCAN.test(scan.id)) return null;
|
|
1040
1075
|
try {
|
|
1076
|
+
if (ADVISORY_SCAN.test(scan.id)) return advisoryKey(scan);
|
|
1041
1077
|
const files = fileList(scan);
|
|
1042
1078
|
if (files) return canonicalJson({ kind: "files", id: scan.id, files: [...new Set(files)].sort().map((p) => [p, idOf(p)]) });
|
|
1043
1079
|
if (/^cargo-package-list:/.test(scan.id)) {
|
|
@@ -1055,9 +1091,11 @@ export function buildCacheDigest({ objectId, headTree, rustUnits = [], npmUnits
|
|
|
1055
1091
|
}
|
|
1056
1092
|
if (scan.class !== "B") return null;
|
|
1057
1093
|
try {
|
|
1058
|
-
// A batched
|
|
1059
|
-
// own compile key, in member order
|
|
1060
|
-
|
|
1094
|
+
// A batched compile (clippy:batch:*, from planScans `clippyBatching` or runScans' class B batching, and check:batch:*) is keyed on the inputs of
|
|
1095
|
+
// every member it names: each member's own compile key, in member order, plus the batch's own id and command (its member list, target and
|
|
1096
|
+
// environment). Any member that falls back to the whole tree makes the batch fall back too. A changed member changes the key, so the
|
|
1097
|
+
// batch runs again as a whole (cargo is incremental); no member's result is ever taken from another invocation's.
|
|
1098
|
+
if (/^(?:clippy|check):batch:/.test(String(scan.id)) && Array.isArray(scan.batch?.units) && scan.batch.units.length && scan.batch.units.every((n) => known.has(n))) {
|
|
1061
1099
|
const keys = scan.batch.units.map((n) => rustUnitKey(n, scan));
|
|
1062
1100
|
return keys.includes(undefined) ? whole() : canonicalJson({ kind: "rust-batch", id: scan.id, units: scan.batch.units.map((n, i) => [n, keys[i]]) });
|
|
1063
1101
|
}
|
|
@@ -1079,7 +1117,17 @@ export function buildCacheDigest({ objectId, headTree, rustUnits = [], npmUnits
|
|
|
1079
1117
|
} catch { return null; }
|
|
1080
1118
|
};
|
|
1081
1119
|
// The cache key of one Rust unit's compile or test scan, or undefined when the scan must fall back to the whole tree.
|
|
1120
|
+
// A unit's key is a function of the unit, whether the scan is a test scan and the commit; it never names the scan, so the 5 to 10 scans of one
|
|
1121
|
+
// crate share one computation (B7: per-job prep, one git read of the manifest and one closure walk per scan before).
|
|
1122
|
+
const unitKeyMemo = new Map();
|
|
1082
1123
|
function rustUnitKey(unit, scan) {
|
|
1124
|
+
const memoKey = `${unit}\0${/^test:rust(?:-serial)?:/.test(scan.id) ? "test" : "compile"}`;
|
|
1125
|
+
if (unitKeyMemo.has(memoKey)) return unitKeyMemo.get(memoKey);
|
|
1126
|
+
const keyed = rustUnitKeyOf(unit, scan);
|
|
1127
|
+
unitKeyMemo.set(memoKey, keyed);
|
|
1128
|
+
return keyed;
|
|
1129
|
+
}
|
|
1130
|
+
function rustUnitKeyOf(unit, scan) {
|
|
1083
1131
|
const head = byName.get(unit);
|
|
1084
1132
|
const ws = wsOf(head); const lock = lockFor(ws);
|
|
1085
1133
|
if (!lock || typeof listFiles !== "function" || typeof readBlob !== "function") return undefined;
|
|
@@ -1588,8 +1636,8 @@ async function runStages(o, args, root, git, io) {
|
|
|
1588
1636
|
const tierAtLeast = (have, need) => have === "release" || need === "compile";
|
|
1589
1637
|
// GB-12 (GATE 36/44/86, E18): Class A admission runs at every stage boundary a door run crosses; an outer receipt boolean or an intact
|
|
1590
1638
|
// sealed set never stands in for it. The deterministic scans reuse through their own complete result-cache key (never this receipt's
|
|
1591
|
-
// coarse binding, which names the entry file only), and the live scans (
|
|
1592
|
-
//
|
|
1639
|
+
// coarse binding, which names the entry file only), and the live scans (pnpm-lockfile, advisory-exceptions) are never cached; cargo-deny, cargo-audit
|
|
1640
|
+
// and pnpm-audit are keyed on lock, configuration, advisory identity and the UTC day (GC-A19), and the door's `live-scans` refresh re-asks the registry. The one exception is the trusted
|
|
1593
1641
|
// publisher's upload (`--to release` on a desktop platform): it runs no build environment, only uploads bytes whose earlier stages
|
|
1594
1642
|
// (Class A included) another job of the same pipeline recorded in the receipt it imported (--receipt-in).
|
|
1595
1643
|
const publisherUploadOnly = to === "release" && !mobile;
|
|
@@ -3631,8 +3679,11 @@ export async function main(argv, io = {}) {
|
|
|
3631
3679
|
const pathKey = o.platform === "win32" ? (Object.keys(o.env).find((k) => k.toUpperCase() === "PATH") ?? "Path") : "PATH";
|
|
3632
3680
|
const direct = directCargoPath({ env: { ...o.env, PATH: o.env[pathKey] }, exists: o.exists, platform: o.platform, gateWrappers: true });
|
|
3633
3681
|
const readOpts = { cargoCommand: planCargoCommand, snapshotRoot: repo, directPath: direct.path, pathKey, tmpRoot: gateTmpRoot({ env: o.env, platform: o.platform, exists: o.exists }), env: o.env, err: o.err };
|
|
3634
|
-
|
|
3635
|
-
|
|
3682
|
+
// One memo for the run (rightkit#1460): the unit discovery's `metadata --no-deps --locked` and the Class A `cargo-metadata` scan of the same
|
|
3683
|
+
// workspace are the same call on the same verified snapshot, so the scan reuses the discovery's result instead of running Cargo again.
|
|
3684
|
+
const readMemo = new Map();
|
|
3685
|
+
snapshotSpawn = directReadSpawn({ spawn: withDeclaredClient((c, a, opts) => o.spawn(c, a, opts)), ...readOpts, memo: readMemo });
|
|
3686
|
+
scanSpawn = directReadSpawn({ spawn: withDeclaredClient(defaultSpawnAsync), ...readOpts, memo: readMemo, isAsync: true });
|
|
3636
3687
|
}
|
|
3637
3688
|
npm = discoverNpmUnits({ root: repo, tracked, readFile: readSnap, exists: o.exists });
|
|
3638
3689
|
npmRoots = discoverPnpmRoots({ root: repo, tracked, exists: o.exists });
|
|
@@ -3874,6 +3925,9 @@ export async function main(argv, io = {}) {
|
|
|
3874
3925
|
quietTests: fullA || o.env.RK_GATE_QUIET_TESTS === "local" ? "local" : "ci", packageFeatures, liveExecution: (fullA && (args.includes("--worktree") || Boolean(snapshotA))) || Boolean(snapshotB),
|
|
3875
3926
|
e2eCrateDirs, swiftPackages,
|
|
3876
3927
|
rustUnits: rust.units, npmUnits: npm, npmRoots, cargoDir: ".", rustLocks, crateFeatures, crateDependents, externalInputs,
|
|
3928
|
+
// B1 (rightkit#1458): compile scans of one Cargo workspace run as one cargo invocation per configuration; ci/shards.json `solo` crates never join one.
|
|
3929
|
+
// Batching is opt-in (RK_GATE_CLASS_B_BATCH=1) until the batch-equivalence run (GATE-CONTRACT GC-I11) shows a batch passes exactly when each crate passes alone: one cargo call unifies the members' features.
|
|
3930
|
+
classBBatching: o.env.RK_GATE_CLASS_B_BATCH === "1", shardSolo: shardSoloOf(o, repo),
|
|
3877
3931
|
// The broker (or, on a direct host, the gate itself) admits compiles; no separate grant file decides it here.
|
|
3878
3932
|
localCompile: true,
|
|
3879
3933
|
exists: o.exists, readFile: o.readFile, platform: o.platform,
|
|
@@ -4021,7 +4075,9 @@ export async function main(argv, io = {}) {
|
|
|
4021
4075
|
// The verdict also depends on what is not in the tree: the gate's own code and advisory data, the node and pnpm that run
|
|
4022
4076
|
// the checks, the installed dependencies (pnpm's install state) and the platform. Any change there is a cache miss.
|
|
4023
4077
|
// Tool caches (vitest, tsc build info, ...) are left out: the scans write them themselves, so keying on them made every rerun miss.
|
|
4024
|
-
|
|
4078
|
+
// A6: the digest bound at the start of this run is this very computation (same root, gate package, files and tool-cache setting), so it is
|
|
4079
|
+
// reused: each call walks every installed dependency file, and the run made three of these walks before its first scan.
|
|
4080
|
+
const environment = envAtStart ?? classAEnvironmentDigest({ root: liveBase, gatePackage: o.gatePackage, files, spawn: o.spawn, includeCaches: false });
|
|
4025
4081
|
const digest = buildCacheDigest({ objectId, headTree: digestOf(files), rustUnits: rust.units, npmUnits: npm, cargoDir: ".", rustLocks, crateFeatures, listFiles, readBlob });
|
|
4026
4082
|
// A row's key is its own inputs plus the environment; the run's scope and scan set are not inputs of one row, and keying on them
|
|
4027
4083
|
// missed every row whenever one file joined or left the plan. build-helpers is never reused: it reads the host's trace list,
|
|
@@ -4084,7 +4140,7 @@ export async function main(argv, io = {}) {
|
|
|
4084
4140
|
directTiming.cargoStart = Date.now();
|
|
4085
4141
|
census?.start();
|
|
4086
4142
|
const scanResult = await (o.runScans ?? runScans)(plan, {
|
|
4087
|
-
classes: classAOnly ? ["A"] : classAEarlier ? ["B"] : ["A", "B"], ...(classAEarlier ? { classAEarlier: true } : {}), jobs, testJobs, classBJobs, ...(brokerHost ? { brokerHost: true } : {}), ...(brokerLive ? { brokerLive } : {}), signal: ac.signal, ...(cache ? { cache } : {}),
|
|
4143
|
+
classes: classAOnly ? ["A"] : classAEarlier ? ["B"] : ["A", "B"], ...(classAEarlier ? { classAEarlier: true } : {}), jobs, testJobs, classBJobs, classBBatching: o.env.RK_GATE_CLASS_B_BATCH === "1", classBPipeline: Math.max(1, Number(o.env.RK_GATE_CLASS_B_PIPELINE ?? 2) || 2), ...(brokerHost ? { brokerHost: true } : {}), ...(brokerLive ? { brokerLive } : {}), signal: ac.signal, ...(cache ? { cache } : {}),
|
|
4088
4144
|
...(census ? { spawn: census.wrapSpawn(defaultSpawnAsync) } : {}),
|
|
4089
4145
|
// 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
|
|
4090
4146
|
// executor's validated client, never a PATH lookup (withDeclaredClient).
|
|
@@ -4122,7 +4178,7 @@ export async function main(argv, io = {}) {
|
|
|
4122
4178
|
return path.join(base, "rightkit-gate-scan-logs", `${path.basename(root)}-${stamp}-${process.pid}`);
|
|
4123
4179
|
} catch { return null; }
|
|
4124
4180
|
})(),
|
|
4125
|
-
onResult: (row, p) => o.out(`${tag} [${p.done}/${p.total}] ${(row.cached ? "cached" : row.status).padEnd(7)} ${row.id} (${p.seconds}s)${row.status === "fail" ? ` :: ${String(row.detail ?? "").slice(0, 300)}` : ""}`),
|
|
4181
|
+
onResult: (row, p) => o.out(`${tag} [${p.done}/${p.total}] ${(row.cached ? "cached" : row.status).padEnd(7)} ${row.id} (${p.seconds}s)${row.batchedWith ? ` [batch of ${row.batchedWith.units.length}]` : ""}${row.status === "fail" ? ` :: ${String(row.detail ?? "").slice(0, 300)}` : ""}`),
|
|
4126
4182
|
});
|
|
4127
4183
|
directTiming.cargoEnd = Date.now();
|
|
4128
4184
|
const freshness = census ? census.finish() : null;
|
|
@@ -4208,7 +4264,7 @@ export async function main(argv, io = {}) {
|
|
|
4208
4264
|
}
|
|
4209
4265
|
const outputWorkspaces = (snapshotBroker ? scanResult.scans.map((r) => r.snapshotEvidence?.outputDir) : Object.values(targetDirs ?? {})).filter(Boolean).map((dir) => [dir]);
|
|
4210
4266
|
o.onCompileOutputs?.(outputWorkspaces.map(([dir]) => dir), builtBins);
|
|
4211
|
-
if (snapshotBroker) o.out(`${tag} broker compile: ${scanResult.scans.
|
|
4267
|
+
if (snapshotBroker) o.out(`${tag} broker compile: ${new Set(scanResult.scans.map((r) => r.snapshotEvidence?.requestId).filter(Boolean)).size} carried request(s) with verified signed receipts (${scanResult.scans.filter((r) => r.snapshotEvidence).length} scan row(s)); no direct receipt on a broker host`);
|
|
4212
4268
|
else {
|
|
4213
4269
|
// The direct host's own receipt (GATE-CONTRACT "Broker interface", row 7.18): the contract's returned-evidence names minus the
|
|
4214
4270
|
// broker-only ones (admission, queue, reusedFrom): the run, the commit, the snapshot's tree at start and exit, the declared
|
package/deterministic-scans.mjs
CHANGED
|
@@ -938,6 +938,12 @@ export function planScans({
|
|
|
938
938
|
// planner emits one scan per compatible batch and no per-crate Clippy scan for a crate that belongs to one (row 8.15).
|
|
939
939
|
// `shardSolo` is ci/shards.json `solo`; `clippySeparate` maps a unit name to the reason equivalence found batching changed it.
|
|
940
940
|
clippyBatching = false, shardSolo = [], clippySeparate = new Map(),
|
|
941
|
+
// Class B execution batching (B1, rightkit#1458): the compile scans (check, check-features, check-dependent, clippy, each cross target) of
|
|
942
|
+
// one Cargo workspace that differ only in their `-p <crate>` are marked `batchable`, and runScans runs each group as ONE cargo invocation
|
|
943
|
+
// (`-p a -p b ...`). Unlike clippyBatching above, ids, commands and the scan-set digest are unchanged: the plan still lists one scan per
|
|
944
|
+
// crate and configuration, so required ids (GC-A14's three targets, scan-receipt) and GC-T14 keys are untouched; only the run is shared.
|
|
945
|
+
// `shardSolo` and `clippySeparate` keep a crate out of every group, as they do for clippyBatching. Off unless the caller (rightkit-gate) asks.
|
|
946
|
+
classBBatching = false,
|
|
941
947
|
} = {}) {
|
|
942
948
|
if (!contentRoot) throw new TypeError("planScans: contentRoot is required");
|
|
943
949
|
if (!Array.isArray(cargoCommand) || cargoCommand.length === 0 || !["rustright", "cargo"].includes(cargoCommand[0]) || cargoCommand.slice(1).some((a) => a !== "cargo")) {
|
|
@@ -1232,7 +1238,9 @@ export function planScans({
|
|
|
1232
1238
|
const dir = ws === "." ? "" : ws;
|
|
1233
1239
|
// A non-empty list only: `[^\]\s]` is one character that is neither whitespace nor the closing bracket, so `ignore = []` followed by
|
|
1234
1240
|
// a later `]` (the next table header) is not an ignore (Pulse, 2026-10-27: `\S` matched the `]` itself).
|
|
1235
|
-
|
|
1241
|
+
// Comments go first: the @rightkit/config template keeps a commented example inside an empty `ignore = [ ... ]`, which is no
|
|
1242
|
+
// ignore (CutRight, 2026-11-03).
|
|
1243
|
+
const ignores = ["deny.toml", ".cargo/audit.toml"].some((f) => { try { return /\bignore\s*=\s*\[[^\]]*[^\]\s][^\]]*\]/s.test(stripTomlComments(readFile(path.join(contentRoot, dir, f)))); } catch { return false; } });
|
|
1236
1244
|
if (ignores && !(dir === "" && exists(path.join(contentRoot, "ci/advisory-exceptions.json")))) add({ id: `advisory-exceptions${dir ? `:${wsLabel(ws)}` : ""}`, class: A, internal: "advisory-exceptions", dir, exceptionsFile: ".rightkit/advisory-exceptions.json" });
|
|
1237
1245
|
}
|
|
1238
1246
|
// Like generated-docs, planned only when a changed file is one of the contract's inputs or projections. The generator runs from
|
|
@@ -1329,10 +1337,10 @@ export function planScans({
|
|
|
1329
1337
|
const ws = wsOf(name); const crate = crateOf(name);
|
|
1330
1338
|
// `cargo clippy --all-targets` type-checks exactly what `cargo check --all-targets` does: the default
|
|
1331
1339
|
// check runs only when no clippy set covers default features.
|
|
1332
|
-
if (defaultCheck) add({ id: rustScanId.check(name), class: B, ...cargoIn(ws, ...checkArgs(crate, { locked: true })) });
|
|
1333
|
-
checkSets.forEach((set, i) => add({ id: rustScanId.checkFeatures(name, i), class: B, ...cargoIn(ws, ...checkArgs(crate, { features: set, locked: true })) }));
|
|
1340
|
+
if (defaultCheck) add({ id: rustScanId.check(name), class: B, batchUnit: name, ...cargoIn(ws, ...checkArgs(crate, { locked: true })) });
|
|
1341
|
+
checkSets.forEach((set, i) => add({ id: rustScanId.checkFeatures(name, i), class: B, batchUnit: name, ...cargoIn(ws, ...checkArgs(crate, { features: set, locked: true })) }));
|
|
1334
1342
|
if (clippyBatching) lintSets.forEach((set) => clippyEntries.push({ name, crate, ws, set, count: lintSets.length, env: targetDirs?.[ws] ?? null }));
|
|
1335
|
-
else lintSets.forEach((set, i) => add({ id: rustScanId.clippy(name, lintSets.length, i), class: B, ...cargoIn(ws, ...clippyArgs(crate, { features: set, locked: true })) }));
|
|
1343
|
+
else lintSets.forEach((set, i) => add({ id: rustScanId.clippy(name, lintSets.length, i), class: B, batchUnit: name, ...cargoIn(ws, ...clippyArgs(crate, { features: set, locked: true })) }));
|
|
1336
1344
|
// The other two OS targets, every lint set, -D warnings, on every host (cross-targets.mjs; Adrian 2026-11-02/03, no skip). The zig C
|
|
1337
1345
|
// toolchain must be provisioned (crossCcDir); without it the scan fails naming the fix, never skipped. On a broker host the broker must
|
|
1338
1346
|
// admit the cross target and its CC_/CXX_/AR_ variables; a refusal there fails the scan.
|
|
@@ -1342,7 +1350,7 @@ export function planScans({
|
|
|
1342
1350
|
const id = `${rustScanId.clippy(name, lintSets.length, i)}@${target}`;
|
|
1343
1351
|
if (!crossEnv) { add({ id, class: B, tool: "node", args: ["-e", `console.error("RK_CROSS_CC_UNPROVISIONED: the zig C toolchain for ${target} is not provisioned; run node scripts/ci/provision-zig.mjs <managed data root>/zig (or set RIGHTKIT_CROSS_CC_DIR)"); process.exit(1)`] }); return; }
|
|
1344
1352
|
const scan = cargoIn(ws, ...clippyArgs(crate, { features: set, locked: true, target }));
|
|
1345
|
-
add({ id, class: B, ...scan, env: { ...(scan.env ?? {}), ...crossEnv } });
|
|
1353
|
+
add({ id, class: B, batchUnit: name, ...scan, env: { ...(scan.env ?? {}), ...crossEnv } });
|
|
1346
1354
|
});
|
|
1347
1355
|
}
|
|
1348
1356
|
// rustdoc flags go after `--` for this crate's library only: the broker owns RUSTDOCFLAGS and refuses
|
|
@@ -1369,13 +1377,13 @@ export function planScans({
|
|
|
1369
1377
|
const scoped = crateNames.filter((n) => wsOf(n) === ws).map(crateOf);
|
|
1370
1378
|
const workspace = (rustMap ? [...rustMap.keys()] : listDir(path.join(contentRoot, "crates"))).filter((n) => wsOf(n) === ws);
|
|
1371
1379
|
const dependents = safeUnits(workspace.filter((n) => !inScope.has(n) && exists(path.join(contentRoot, rustDir(n), "Cargo.toml")) && scoped.some((t) => reach(lock, crateOf(n), memo).has(t))).sort(), "crate");
|
|
1372
|
-
for (const name of dependents) { planned.add(name); add({ id: `check-dependent:${name}`, class: B, ...cargoIn(ws, ...checkArgs(crateOf(name), { locked: true })) }); }
|
|
1380
|
+
for (const name of dependents) { planned.add(name); add({ id: `check-dependent:${name}`, class: B, batchUnit: name, ...cargoIn(ws, ...checkArgs(crateOf(name), { locked: true })) }); }
|
|
1373
1381
|
}
|
|
1374
1382
|
// Across Cargo workspaces (one workspace and lock per crate): a unit that path-depends on a unit in scope, transitively, is judged by
|
|
1375
1383
|
// the manifests' path dependencies, since no lock holds both.
|
|
1376
1384
|
if (typeof crateDependents === "function" && rustMap && crateNames.length) {
|
|
1377
1385
|
const across = [...crateDependents(new Set(crateNames))].filter((n) => !inScope.has(n) && !planned.has(n) && rustMap.has(n) && exists(path.join(contentRoot, rustDir(n), "Cargo.toml"))).sort();
|
|
1378
|
-
for (const name of safeUnits(across, "crate")) add({ id: `check-dependent:${name}`, class: B, ...cargoIn(wsOf(name), ...checkArgs(crateOf(name), { locked: true })) });
|
|
1386
|
+
for (const name of safeUnits(across, "crate")) add({ id: `check-dependent:${name}`, class: B, batchUnit: name, ...cargoIn(wsOf(name), ...checkArgs(crateOf(name), { locked: true })) });
|
|
1379
1387
|
}
|
|
1380
1388
|
// A linter config in the unit's directory or any ancestor of it (a repository-level config covers every unit, as the tools look it up).
|
|
1381
1389
|
const hasConfig = (dir, names) => ancestorDirsOf(dir).some((d) => names.some((f) => exists(path.join(liveRoot, inDir(d, f)))));
|
|
@@ -1575,7 +1583,8 @@ export function planScans({
|
|
|
1575
1583
|
// The suite is the exported commit's test files, named explicitly: an untracked WIP test in the live
|
|
1576
1584
|
// checkout is never run and can neither block nor pass a push.
|
|
1577
1585
|
const suite = listDir(path.join(contentRoot, "scripts", "ci")).filter((n) => n.endsWith(".test.mjs")).sort().map((n) => `scripts/ci/${n}`);
|
|
1578
|
-
|
|
1586
|
+
// End-to-end tests only (Adrian, 2026-11-03): a repo that removed its scripts/ci unit tests has no suite to run, and no row is planned.
|
|
1587
|
+
if (suite.length) add({ id: "test:scripts-ci", class: B, kind: "test", executes: true, classReason: "tests execute project code and run after class A", tool: "node", args: ["--test", ...suite] });
|
|
1579
1588
|
}
|
|
1580
1589
|
}
|
|
1581
1590
|
|
|
@@ -1591,6 +1600,35 @@ export function planScans({
|
|
|
1591
1600
|
});
|
|
1592
1601
|
if (deferred.length) notes.push(`deferred, not passed (no local compile grant): ${deferred.join(", ")}`);
|
|
1593
1602
|
}
|
|
1603
|
+
// Class B execution batching (see classBBatching above). A scan is batchable only when it is a carried-or-direct cargo compile with exactly one
|
|
1604
|
+
// `-p <crate>`, names no crate-specific feature (`--features`: unifying them across crates changes what compiles; the same rule as
|
|
1605
|
+
// clippyBatchPlan's crate-specific feature sets), is not a solo, separate or sidecar-bound crate, and is not deferred. Its group key is the
|
|
1606
|
+
// scan with the `-p` pair removed (tool, directory, root, environment, remaining argv, and where the pair sat), so only identical
|
|
1607
|
+
// configurations of one workspace and target share an invocation. The plan carries no argv for the group: runScans rebuilds it from members.
|
|
1608
|
+
const batchNotes = new Map(); const groupCount = new Map();
|
|
1609
|
+
scans = scans.map((x) => {
|
|
1610
|
+
if (x.batchUnit === undefined) return x;
|
|
1611
|
+
const { batchUnit: unit, ...plain } = x;
|
|
1612
|
+
if (!classBBatching || x.deferred || !Array.isArray(x.args) || (x.tool !== "rustright" && x.tool !== "cargo")) return plain;
|
|
1613
|
+
const at = x.args.indexOf("-p");
|
|
1614
|
+
const crate = at >= 0 ? x.args[at + 1] : null;
|
|
1615
|
+
const rest = at >= 0 ? [...x.args.slice(0, at), ...x.args.slice(at + 2)] : [];
|
|
1616
|
+
let why = null;
|
|
1617
|
+
if (at < 0 || typeof crate !== "string" || x.args.indexOf("-p", at + 1) >= 0) why = "it does not name exactly one `-p <crate>`";
|
|
1618
|
+
else if (rest.some((w) => /^(?:--features(?:=.*)?|-F.*)$/.test(w))) why = "its feature set names crate-specific features";
|
|
1619
|
+
else if (shardSolo.includes(unit) || shardSolo.includes(crateOf(unit))) why = "ci/shards.json solo";
|
|
1620
|
+
else if (clippySeparate instanceof Map && clippySeparate.has(unit)) why = String(clippySeparate.get(unit));
|
|
1621
|
+
else if (sidecarBoundCrate({ dir: path.join(contentRoot, rustDir(unit)), exists, readFile }).bound) why = "sidecar-bound";
|
|
1622
|
+
if (why) { batchNotes.set(why, (batchNotes.get(why) ?? 0) + 1); return plain; }
|
|
1623
|
+
const key = sha256(canonicalJson({ tool: x.tool, cwd: x.cwd ?? ".", root: x.root, env: x.env, rest, at })).slice(0, 16);
|
|
1624
|
+
groupCount.set(key, (groupCount.get(key) ?? 0) + 1);
|
|
1625
|
+
return { ...plain, batchable: { key, at, crate, unit } };
|
|
1626
|
+
});
|
|
1627
|
+
if (groupCount.size) {
|
|
1628
|
+
const grouped = [...groupCount.values()].filter((n) => n > 1);
|
|
1629
|
+
notes.push(`class B batching: ${scans.filter((x) => x.batchable).length} compile scan(s) in ${groupCount.size} configuration group(s); each group of one Cargo workspace and target runs as one cargo invocation (${grouped.reduce((a, n) => a + n, 0)} scan(s) in ${grouped.length} shared group(s)), a failed group is bisected to the crate that fails, every row keeps its own id and command; the batch-equivalence run (GATE-CONTRACT GC-I11, item 8 row 8.7) has NOT been run, so a crate whose own features differ when unified with its group's can pass here and fail alone`);
|
|
1630
|
+
for (const [why, n] of batchNotes) notes.push(`class B batching: ${n} compile scan(s) stay their own invocation: ${why}`);
|
|
1631
|
+
}
|
|
1594
1632
|
const ids = scans.map((s) => s.id);
|
|
1595
1633
|
const dup = ids.find((id, i) => ids.indexOf(id) !== i);
|
|
1596
1634
|
if (dup) throw new Error(`planScans: duplicate scan id ${dup}`);
|
|
@@ -1773,6 +1811,20 @@ export function defaultSpawnAsync(command, args, options = {}) {
|
|
|
1773
1811
|
* `Tests N passed | M skipped | K failed (T)` line. Null when neither is present. Several node:test summaries (a script that runs
|
|
1774
1812
|
* the runner more than once) are summed. */
|
|
1775
1813
|
/** null when a test summary is evidence of a pass; otherwise { code, detail }. Used for fresh and cached test rows alike. */
|
|
1814
|
+
/** TOML text without its comments: a `#` outside a basic or literal string starts one (a `#` inside quotes is kept). */
|
|
1815
|
+
export function stripTomlComments(text) {
|
|
1816
|
+
return String(text).split("\n").map((line) => {
|
|
1817
|
+
let quote = null;
|
|
1818
|
+
for (let i = 0; i < line.length; i += 1) {
|
|
1819
|
+
const ch = line[i];
|
|
1820
|
+
if (quote) { if (ch === "\\" && quote === '"') i += 1; else if (ch === quote) quote = null; }
|
|
1821
|
+
else if (ch === '"' || ch === "'") quote = ch;
|
|
1822
|
+
else if (ch === "#") return line.slice(0, i);
|
|
1823
|
+
}
|
|
1824
|
+
return line;
|
|
1825
|
+
}).join("\n");
|
|
1826
|
+
}
|
|
1827
|
+
|
|
1776
1828
|
export function testResultsProblem(results) {
|
|
1777
1829
|
if (!results) return { code: "NO_TEST_SUMMARY", detail: "no test counts recorded" };
|
|
1778
1830
|
// End-to-end tests only (Adrian, 2026-11-03: "End to end tests ONLY any unit tests need strict approval along with evidence and
|
|
@@ -2086,7 +2138,7 @@ export function classBChainKey(scan, carried) {
|
|
|
2086
2138
|
* every chain started at once. A broker-carried scan starts without a count; the broker queues and orders it. A scan the broker never sees (an npm or node suite) holds one
|
|
2087
2139
|
* of `localJobs` local slots while it runs. `run(index)` runs one scan and never rejects.
|
|
2088
2140
|
*/
|
|
2089
|
-
export async function scheduleBrokerHostClassB({ scans, lanes, carried, localJobs, run }) {
|
|
2141
|
+
export async function scheduleBrokerHostClassB({ scans, lanes, carried, localJobs, run, pipeline = 1 }) {
|
|
2090
2142
|
const chains = new Map();
|
|
2091
2143
|
for (const lane of ["compile", "doc", "tests"]) {
|
|
2092
2144
|
for (const i of lanes[lane] ?? []) { const key = classBChainKey(scans[i], carried(scans[i])); if (!chains.has(key)) chains.set(key, []); chains.get(key).push(i); }
|
|
@@ -2095,12 +2147,27 @@ export async function scheduleBrokerHostClassB({ scans, lanes, carried, localJob
|
|
|
2095
2147
|
let held = 0; const waiters = [];
|
|
2096
2148
|
const take = async () => { while (held >= limit) await new Promise((resolve) => waiters.push(resolve)); held += 1; };
|
|
2097
2149
|
const free = () => { held -= 1; waiters.shift()?.(); };
|
|
2150
|
+
// B4 (rightkit#1458 audit): with `pipeline` 1 a chain runs one scan at a time, so the gate's work after one job (receipt read, signed-evidence
|
|
2151
|
+
// verification, ledger check) and before the next (cache key, request file) was dead time at the broker (about 10.6 s a job on the Dell). With
|
|
2152
|
+
// `pipeline` n, up to n carried scans of one chain are in flight: the next is submitted while the previous is still running or being verified, and the
|
|
2153
|
+
// broker (which owns ordering and holds one build per repository) queues it. Starts stay in plan order; a scan the broker never sees keeps its
|
|
2154
|
+
// local slot and runs alone, after the carried scans started before it have finished.
|
|
2155
|
+
const depth = Math.max(1, Number(pipeline) || 1);
|
|
2098
2156
|
await Promise.all([...chains.values()].map(async (chain) => {
|
|
2157
|
+
const flight = new Set();
|
|
2099
2158
|
for (const i of chain) {
|
|
2100
2159
|
const local = !carried(scans[i]);
|
|
2101
|
-
if (local)
|
|
2102
|
-
|
|
2160
|
+
if (local) {
|
|
2161
|
+
await Promise.all(flight);
|
|
2162
|
+
await take();
|
|
2163
|
+
try { await run(i); } finally { free(); }
|
|
2164
|
+
continue;
|
|
2165
|
+
}
|
|
2166
|
+
while (flight.size >= depth) await Promise.race(flight);
|
|
2167
|
+
const job = run(i).finally(() => flight.delete(job));
|
|
2168
|
+
flight.add(job);
|
|
2103
2169
|
}
|
|
2170
|
+
await Promise.all(flight);
|
|
2104
2171
|
}));
|
|
2105
2172
|
}
|
|
2106
2173
|
|
|
@@ -2630,6 +2697,57 @@ export async function runScans(plan, options = {}) {
|
|
|
2630
2697
|
// broker queues and orders them. A scan the broker never sees (an npm or node test suite) is a process of this host: those keep the local limit.
|
|
2631
2698
|
const bJobs = Math.max(1, Number(options.classBJobs ?? (brokerHost ? LOCAL_CLASS_B_JOBS : 1)) || 1);
|
|
2632
2699
|
const failedRow = (i, error) => ({ id: bScans[i].id, class: bScans[i].class, command: bScans[i].command, tool: bScans[i].tool ?? null, toolVersion: null, status: "fail", code: "SCAN_ERROR", detail: String(error?.message ?? error) });
|
|
2700
|
+
// Class B batching (B1, rightkit#1458; planScans `classBBatching`). The compile scans of one Cargo workspace that differ only in their `-p <crate>`
|
|
2701
|
+
// are one group; a group of two or more runs as ONE cargo invocation naming every member (`-p a -p b ...`) and the invocation's verdict becomes each
|
|
2702
|
+
// member's row, under the member's own id and command (so required scan ids and the scan-set digest are what the plan said). The invocation is a scan
|
|
2703
|
+
// of its own for everything else: it takes its own cache entry (the gate keys it on every member's inputs, `check:batch:` / `clippy:batch:`), cargo
|
|
2704
|
+
// ledger token, signed broker receipt and run limit. A cargo failure (code EXIT: a compile diagnostic) is bisected, never reported for the group: each
|
|
2705
|
+
// half runs again as a smaller invocation, down to one crate, which runs as its own per-crate scan, so a failure always names the crate that fails and
|
|
2706
|
+
// the crates that pass still pass. Any other failure (a refused or unverified receipt, a timeout, a missing tool) is the group's and is not retried:
|
|
2707
|
+
// running it N times would repeat it N times. Equivalence caveat (GC-I11): one invocation unifies features across its crates, so a pass here is not
|
|
2708
|
+
// proof that every member passes alone; the plan notes say the equivalence run has not been done.
|
|
2709
|
+
const groupOf = new Map();
|
|
2710
|
+
if (options.classBBatching === true) {
|
|
2711
|
+
const byKey = new Map();
|
|
2712
|
+
bScans.forEach((s, i) => { if (s.batchable && !s.deferred && laneOf(s) === "compile") { if (!byKey.has(s.batchable.key)) byKey.set(s.batchable.key, []); byKey.get(s.batchable.key).push(i); } });
|
|
2713
|
+
for (const members of byKey.values()) if (members.length > 1) { const group = { members, promise: null }; for (const i of members) groupOf.set(i, group); }
|
|
2714
|
+
}
|
|
2715
|
+
const batchScanOf = (idx) => {
|
|
2716
|
+
const lead = bScans[idx[0]];
|
|
2717
|
+
const { batchable: _batchable, ...plain } = lead; void _batchable;
|
|
2718
|
+
const args = [...lead.args.slice(0, lead.batchable.at), ...idx.flatMap((i) => ["-p", bScans[i].batchable.crate]), ...lead.args.slice(lead.batchable.at + 2)];
|
|
2719
|
+
const units = idx.map((i) => bScans[i].batchable.unit);
|
|
2720
|
+
const id = `${/^clippy/.test(lead.id) ? "clippy" : "check"}:batch:${sha256(`${lead.batchable.key}\0${units.join("\0")}`).slice(0, 8)}`;
|
|
2721
|
+
return { ...plain, id, args, command: commandText({ ...plain, args }), batch: { units, members: idx.map((i) => bScans[i].id) } };
|
|
2722
|
+
};
|
|
2723
|
+
const runGroup = async (idx, extraEnv) => {
|
|
2724
|
+
if (idx.length === 1) { const i = idx[0]; slots[i] = await runOne(bScans[i], extraEnv).catch((error) => failedRow(i, error)); return; }
|
|
2725
|
+
const started = Date.now();
|
|
2726
|
+
const bs = batchScanOf(idx);
|
|
2727
|
+
let row;
|
|
2728
|
+
try { row = await scanRow(bs, extraEnv); } catch (error) { row = { id: bs.id, status: "fail", code: "SCAN_ERROR", detail: String(error?.message ?? error) }; }
|
|
2729
|
+
if (row.status === "fail" && row.code === "EXIT" && !signal?.aborted) {
|
|
2730
|
+
const half = Math.ceil(idx.length / 2);
|
|
2731
|
+
await runGroup(idx.slice(0, half), extraEnv);
|
|
2732
|
+
await runGroup(idx.slice(half), extraEnv);
|
|
2733
|
+
return;
|
|
2734
|
+
}
|
|
2735
|
+
for (const i of idx) {
|
|
2736
|
+
const m = bScans[i];
|
|
2737
|
+
const own = { id: m.id, class: m.class, command: m.command, tool: m.tool ?? null, toolVersion: row.toolVersion ?? null, status: row.status, ...(row.code ? { code: row.code } : {}), ...(row.detail ? { detail: row.status === "fail" ? `${row.id} (${idx.length} crates: ${bs.batch.units.join(", ")}): ${row.detail}` : row.detail } : {}), ...(row.cached ? { cached: true } : {}), batchedWith: { id: row.id, units: bs.batch.units }, ...(row.snapshotEvidence ? { snapshotEvidence: row.snapshotEvidence } : {}), ...(row.identities ? { identities: row.identities } : {}), ...(row.log ? { log: row.log } : {}) };
|
|
2738
|
+
slots[i] = own; done += 1;
|
|
2739
|
+
try { onResult(own, { done, total, seconds: Math.round((Date.now() - started) / 1000) }); } catch { /* reporting never fails a scan */ }
|
|
2740
|
+
}
|
|
2741
|
+
};
|
|
2742
|
+
// The one entry both schedulers use: a scan outside every group runs as before; the first member of a group to start runs the whole group, and a later
|
|
2743
|
+
// member (same component, so it starts after) finds its row already in place.
|
|
2744
|
+
const runB = async (i, extraEnv = null) => {
|
|
2745
|
+
const group = groupOf.get(i);
|
|
2746
|
+
if (!group) return runOne(bScans[i], extraEnv);
|
|
2747
|
+
if (!group.promise) group.promise = runGroup(group.members, extraEnv);
|
|
2748
|
+
await group.promise;
|
|
2749
|
+
return slots[i] ?? failedRow(i, "its batched invocation produced no row");
|
|
2750
|
+
};
|
|
2633
2751
|
const drain = async (queue, extraEnv = null) => {
|
|
2634
2752
|
const busy = new Set(); const running = new Set();
|
|
2635
2753
|
const keyOf = (i) => bScans[i].cwd ?? ".";
|
|
@@ -2638,7 +2756,7 @@ export async function runScans(plan, options = {}) {
|
|
|
2638
2756
|
if (at === -1) { await Promise.race(running); continue; }
|
|
2639
2757
|
const [i] = queue.splice(at, 1); const key = keyOf(i); busy.add(key);
|
|
2640
2758
|
// A scan that throws becomes a failed row: with several components in flight, a rejection must not abandon the others.
|
|
2641
|
-
const job =
|
|
2759
|
+
const job = runB(i, extraEnv)
|
|
2642
2760
|
.catch((error) => failedRow(i, error))
|
|
2643
2761
|
.then((row) => { slots[i] = row; }).finally(() => { busy.delete(key); running.delete(job); });
|
|
2644
2762
|
running.add(job);
|
|
@@ -2646,8 +2764,8 @@ export async function runScans(plan, options = {}) {
|
|
|
2646
2764
|
};
|
|
2647
2765
|
if (brokerHost) {
|
|
2648
2766
|
await scheduleBrokerHostClassB({
|
|
2649
|
-
scans: bScans, lanes, localJobs: bJobs, carried: (scan) => isBrokerScheduledScan(scan, carriedCtx),
|
|
2650
|
-
run: async (i) => { try { slots[i] = await
|
|
2767
|
+
scans: bScans, lanes, localJobs: bJobs, carried: (scan) => isBrokerScheduledScan(scan, carriedCtx), pipeline: options.classBPipeline ?? 1,
|
|
2768
|
+
run: async (i) => { try { slots[i] = await runB(i); } catch (error) { slots[i] = failedRow(i, error); } },
|
|
2651
2769
|
});
|
|
2652
2770
|
} else {
|
|
2653
2771
|
await drain(lanes.compile);
|
package/local-publish.mjs
CHANGED
|
@@ -77,6 +77,31 @@ export class LocalPublishError extends Error {
|
|
|
77
77
|
}
|
|
78
78
|
const refuse = (message) => { throw new LocalPublishError(message); };
|
|
79
79
|
|
|
80
|
+
/** Lines of a failed step's output kept in its refusal: the tail, where test failures and the final errors are. */
|
|
81
|
+
export const STEP_FAILURE_LINES = 400;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* A failed step's output as a refusal can carry it. cargo's `--message-format=json-render-diagnostics` stdout is mostly
|
|
85
|
+
* compiler-artifact and build-script records (megabytes for a large crate); embedded whole, the refusal was cut off as the
|
|
86
|
+
* process exited and the test failures after them never reached the log. Artifact, build-script and build-finished records are
|
|
87
|
+
* dropped, a compiler message keeps its rendered text, and only the last STEP_FAILURE_LINES lines are kept, with a count of
|
|
88
|
+
* what was cut.
|
|
89
|
+
*/
|
|
90
|
+
export function stepFailureOutput(text, limit = STEP_FAILURE_LINES) {
|
|
91
|
+
const lines = [];
|
|
92
|
+
for (const line of String(text ?? "").split("\n")) {
|
|
93
|
+
if (line.startsWith("{\"reason\":")) {
|
|
94
|
+
let record;
|
|
95
|
+
try { record = JSON.parse(line); } catch { lines.push(line); continue; }
|
|
96
|
+
if (record.reason === "compiler-message" && typeof record.message?.rendered === "string") lines.push(...record.message.rendered.replace(/\n$/, "").split("\n"));
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
lines.push(line);
|
|
100
|
+
}
|
|
101
|
+
if (lines.length <= limit) return lines.join("\n");
|
|
102
|
+
return `[${lines.length - limit} earlier line(s) cut]\n${lines.slice(-limit).join("\n")}`;
|
|
103
|
+
}
|
|
104
|
+
|
|
80
105
|
export const DEFAULT_CONCURRENCY = 4;
|
|
81
106
|
const MAX_CONCURRENCY = 8;
|
|
82
107
|
const CRATE_NAME = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
@@ -724,7 +749,7 @@ async function* publishUnitStages(parsed, deps, batch) {
|
|
|
724
749
|
const row = { command: commandText, ok: false, isTest: step.test && TEST_COMMAND.test(commandText) };
|
|
725
750
|
if (result.error || result.status !== 0) {
|
|
726
751
|
steps.push(row);
|
|
727
|
-
refuse(`${plan.id} step failed (${result.error?.message ?? `exit ${result.status}`}): ${commandText}\nstdout:\n${result.stdout
|
|
752
|
+
refuse(`${plan.id} step failed (${result.error?.message ?? `exit ${result.status}`}): ${commandText}\nstdout:\n${stepFailureOutput(result.stdout)}\nstderr:\n${stepFailureOutput(result.stderr)}`);
|
|
728
753
|
}
|
|
729
754
|
row.ok = true;
|
|
730
755
|
// GATE-CONTRACT GC-A08: a broker compiles a `cargo test` and never runs it. Its reply names that; the executables its JSON listing
|
|
@@ -749,9 +774,10 @@ async function* publishUnitStages(parsed, deps, batch) {
|
|
|
749
774
|
}
|
|
750
775
|
steps.push(row);
|
|
751
776
|
}
|
|
752
|
-
const verdict = judgeUnit({ name: unit, steps: steps.map((s) => ({ ...s, unit: plan.id })), allowIgnored: ignoredAllowed ? [unit] : [], allowMissingAssets: isAssetGated ? [unit] : [] });
|
|
777
|
+
const verdict = judgeUnit({ name: unit, steps: steps.map((s) => ({ ...s, unit: plan.id })), allowNoTests: kind === "cargo", allowIgnored: ignoredAllowed ? [unit] : [], allowMissingAssets: isAssetGated ? [unit] : [] });
|
|
753
778
|
if (verdict.status === "fail" || steps.some((s) => s.failed > 0)) refuse(`${plan.id} not qualified: ${verdict.problems.join("; ") || "failed tests reported"}`);
|
|
754
|
-
|
|
779
|
+
// End-to-end tests only (Adrian, 2026-11-03): a crate with no test of its own publishes; an npm unit still needs its test script to run.
|
|
780
|
+
if (kind !== "cargo" && !(verdict.executed > 0)) refuse(`${plan.id} executed no test`);
|
|
755
781
|
log(`[right-release] ${plan.id}: ${verdict.executed} passed, 0 failed, ${verdict.skipped} skipped, ${verdict.ignored} ignored${isAssetGated ? " (asset-gated: RIGHTKIT_REQUIRE_ASSETS=0, skips recorded)" : ""}`);
|
|
756
782
|
const packageEnv = yield { stage: "compile", kind, name: unit, version, commit: head, brokerRequests: brokerRequests.splice(0) };
|
|
757
783
|
if (packageEnv) Object.assign(env, testEnv({ env: packageEnv }, isAssetGated));
|
package/package.json
CHANGED
package/publish-local-cargo.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// `right-release publish-local cargo --crate <name> --commit <sha> --compile-report <file>`: the local crates route (Adrian, 2026-11-03,
|
|
3
|
-
// rightkit#1471: "the npm and crates are both local ... feel free to push but no ci"). The crates.io token is cargo's own,
|
|
4
|
-
//
|
|
3
|
+
// rightkit#1471: "the npm and crates are both local ... feel free to push but no ci"). The crates.io token is cargo's own,
|
|
4
|
+
// stored by cargo's macOS Keychain provider; on the Mac this command reads it through /usr/bin/security and hands it to its one `cargo publish`
|
|
5
|
+
// call (cargo's own provider is admitted per program path, which the broker's pinned toolchain changes).
|
|
5
6
|
//
|
|
6
7
|
// It publishes exactly one commit's crate, and only when:
|
|
7
8
|
// 1. the commit is on origin/main;
|
|
@@ -23,6 +24,11 @@ import { directCargoPath } from "./managed-cargo.mjs";
|
|
|
23
24
|
|
|
24
25
|
export const UNIT_REPORT_SCHEMA = "rightkit.unit-gate-report/1";
|
|
25
26
|
|
|
27
|
+
/** The Keychain item cargo's macOS provider stores the crates.io token under. */
|
|
28
|
+
export const CARGO_KEYCHAIN_SERVICE = "cargo-registry:https://github.com/rust-lang/crates.io-index";
|
|
29
|
+
const KEYCHAIN_READ_MS = 60_000;
|
|
30
|
+
const PUBLISH_CALL_MS = 10 * 60_000;
|
|
31
|
+
|
|
26
32
|
function fail(message) { throw new Error(message); }
|
|
27
33
|
|
|
28
34
|
export function parseArgs(argv) {
|
|
@@ -115,8 +121,18 @@ export async function publishLocalCargo(argv, { run = spawnSync, log = console.l
|
|
|
115
121
|
const sha256 = crypto.createHash("sha256").update(fs.readFileSync(crateFile)).digest("hex");
|
|
116
122
|
log(`publish-local: packaged ${name}-${version}.crate sha256 ${sha256}`);
|
|
117
123
|
|
|
118
|
-
|
|
119
|
-
|
|
124
|
+
// Mac: cargo's own Keychain provider is admitted per program path, and the broker's pinned toolchain moves that path with every
|
|
125
|
+
// toolchain, so a background publish waited on an approval prompt nobody saw. The token is read here through /usr/bin/security (one
|
|
126
|
+
// fixed path, as the npm route reads its token), bounded so a refusal fails instead of hanging, and handed to this one cargo call only.
|
|
127
|
+
const publishEnv = { ...cargoEnv };
|
|
128
|
+
if (platform === "darwin") {
|
|
129
|
+
const read = run("/usr/bin/security", ["find-generic-password", "-s", CARGO_KEYCHAIN_SERVICE, "-w"], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"], timeout: KEYCHAIN_READ_MS });
|
|
130
|
+
const token = read.status === 0 ? String(read.stdout ?? "").trim() : "";
|
|
131
|
+
if (!token) fail(`the crates.io token could not be read from the Keychain item ${CARGO_KEYCHAIN_SERVICE} within ${KEYCHAIN_READ_MS / 1000} s (${read.error?.code === "ETIMEDOUT" ? "waiting for an access approval: allow /usr/bin/security on that item once in Keychain Access" : "missing or refused"})`);
|
|
132
|
+
Object.assign(publishEnv, { CARGO_REGISTRY_TOKEN: token, CARGO_REGISTRY_GLOBAL_CREDENTIAL_PROVIDERS: "cargo:token" });
|
|
133
|
+
}
|
|
134
|
+
const pub = run("cargo", ["publish", "--no-verify", "--locked", "--manifest-path", manifestPath, "--target-dir", targetDir], { encoding: "utf8", env: publishEnv, timeout: PUBLISH_CALL_MS });
|
|
135
|
+
if (pub.status !== 0) fail(`cargo publish failed${pub.error?.code === "ETIMEDOUT" ? ` (no answer within ${PUBLISH_CALL_MS / 60000} min)` : ""}: ${String(pub.stderr ?? "").trim().split(/\r?\n/).slice(-4).join(" | ")}`);
|
|
120
136
|
|
|
121
137
|
let entry = null;
|
|
122
138
|
for (let i = 0; i < 20 && !entry; i += 1) { entry = await indexEntry(name, version, fetchImpl); if (!entry) await sleep(15000); }
|