@rightkit/release 0.6.46 → 0.6.47
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 +16 -7
- package/build-ownership.mjs +122 -14
- package/cross-targets.mjs +18 -2
- package/deterministic-scans.mjs +21 -13
- package/gate-acceptance.mjs +1443 -0
- package/gate-serve.mjs +66 -4
- package/handle-revocation.mjs +100 -0
- package/handle-revocation.rust-vector.json +1 -0
- package/handle-revocation.vectors.json +53 -0
- package/local-publish.mjs +4 -2
- package/managed-cargo.mjs +11 -0
- package/owner-process-proof.mjs +14 -0
- package/ownership-mark.mjs +10 -1
- package/ownership-recover.mjs +78 -0
- package/package.json +2 -2
- package/rightkit-drift.mjs +4 -3
- package/rightkit-versions.json +1 -1
- package/snapshot-broker.mjs +1 -1
- package/stage-sidecar.mjs +20 -4
- package/stamp-relay.mjs +37 -0
- package/unit-list-compile.mjs +2 -1
package/bin/rightkit-gate.mjs
CHANGED
|
@@ -96,6 +96,13 @@ import { LINUX_BROKER_ROUTE, NO_BROKER_ENV, directCargoPath, directPlatform, lin
|
|
|
96
96
|
import { createBrokerLive } from "../broker-admission.mjs";
|
|
97
97
|
import { bindingOf, compileOutputsRecord, compileReuseProblem, endRun, readReceipt, RECEIPT_SCHEMA, receiptKey, sameBinding, sameSource, sealedFor, stagesTo, startRun, STAGES, STAGE_SOURCES, writeReceipt } from "../gate-stages.mjs";
|
|
98
98
|
import { spawnSync as spawnInherit } from "../background-process.mjs";
|
|
99
|
+
// GC-A21: a run that stamps its own lines also stamps its inherited-output children's lines, through stamp-relay.mjs in front of the child
|
|
100
|
+
// (the launch stays synchronous and the output still streams). Set by main() when the run stamps; off for machine-readable runs.
|
|
101
|
+
let stampChildLines = false;
|
|
102
|
+
const STAMP_RELAY = fileURLToPath(new URL("../stamp-relay.mjs", import.meta.url));
|
|
103
|
+
const inheritLaunch = (cmd, a, opts) => (stampChildLines
|
|
104
|
+
? spawnInherit(process.execPath, [STAMP_RELAY, cmd, ...a], { ...opts, stdio: "inherit" })
|
|
105
|
+
: spawnInherit(cmd, a, { ...opts, stdio: "inherit" }));
|
|
99
106
|
import { readDiskPolicy, scratchRoots } from "../disk-policy.mjs";
|
|
100
107
|
import { buildDirectReceipt, directVerdict, resolveTargetDirectory, verifyDirectReceipt, writeDirectDiagnostics } from "../direct-receipt.mjs";
|
|
101
108
|
import { createFreshnessCensus } from "../freshness-census.mjs";
|
|
@@ -1858,7 +1865,7 @@ async function runStages(o, args, root, git, io) {
|
|
|
1858
1865
|
let childOk = false;
|
|
1859
1866
|
try {
|
|
1860
1867
|
o.out(`${tag} [${stage}] right-release ${cliArgs.join(" ")}${sourceOf ? ` (from the snapshot ${ds.path})` : ""}`);
|
|
1861
|
-
const r = (o.spawnInherit ??
|
|
1868
|
+
const r = (o.spawnInherit ?? inheritLaunch)(process.execPath, [cli, ...cliArgs], { cwd: sourceOf ? snapshotAppRootOf(ds.path, appDir) : appRoot, env: carriedEnv(carrier, { ...o.env, ...run.env }, extraEnv) });
|
|
1862
1869
|
childOk = r.status === 0;
|
|
1863
1870
|
} finally { endRun(run); }
|
|
1864
1871
|
const carriedOk = await carrier.finish({ stage });
|
|
@@ -2469,7 +2476,7 @@ export async function stageWebBuildOnce({ o, ds, root, git = null, appDir, cli,
|
|
|
2469
2476
|
let r = restored ? { status: 0 } : null;
|
|
2470
2477
|
if (!restored) try {
|
|
2471
2478
|
o.out(`${tag} [${stage}] right-release web-build --config ${path.join(ds.path, config)} (from the snapshot ${ds.path}; declared input(s) ${absent().join(", ")} are absent)`);
|
|
2472
|
-
r = (o.spawnInherit ??
|
|
2479
|
+
r = (o.spawnInherit ?? inheritLaunch)(process.execPath, [cli, "web-build", "--config", path.join(ds.path, config)], { cwd: snapshotAppRootOf(ds.path, appDir), env: carriedEnv(carrier, { ...cleanEnv, ...run.env }) });
|
|
2473
2480
|
} finally { endRun(run); }
|
|
2474
2481
|
const carriedOk = await carrier.finish({ stage });
|
|
2475
2482
|
if (!r || r.status !== 0) { o.err(`${tag} [${stage}] web-build for ${config} failed${r?.error ? ` (${r.error.message})` : ""}`); return false; }
|
|
@@ -2743,7 +2750,7 @@ async function runUnitSnapshot(o, args, root, git, io, option) {
|
|
|
2743
2750
|
let own;
|
|
2744
2751
|
try { own = (o.acquireOwnership ?? acquireBuildOwnership)({ file: ownershipFile({ platform: o.platform, beside: o.snapshotRoot, repository: snap.repositoryOf(root).key }), stage: `door:unit:${option("--to")}`, snapshot: path.join(snapshotsAt, snap.repositoryOf(root).key), commit, platform: o.platform, env: o.env }); }
|
|
2745
2752
|
catch (e) { if (e.code !== "busy" && e.code !== "refused") throw e; o.err(`${tag} BLOCKED: ${e.message}; nothing ran${e.code === "refused" ? ", nothing created" : ""}`); return 1; }
|
|
2746
|
-
o.out(`${tag} build ownership ${own.joined ? "joined" : "held"} ${own.handle}`);
|
|
2753
|
+
o.out(`${tag} build ownership ${own.joined ? "joined" : "held"} ${own.handle}${own.reclaimed ? ` (reclaimed from ${own.reclaimed.from}: ${own.reclaimed.proofs.join("; ")})` : ""}`);
|
|
2747
2754
|
try {
|
|
2748
2755
|
let synced;
|
|
2749
2756
|
try { synced = (o.syncSnapshot ?? snap.syncSnapshot)({ checkout: root, rev: commit, root: snapshotsAt }); }
|
|
@@ -3481,7 +3488,7 @@ async function runDevTest(o, args, root, git, io, to, appRoot, appDir) {
|
|
|
3481
3488
|
if (ds && !(await closeSnapshotStage({ o, ds, root, stage: to, step: to, tag })).ok) { o.err(`${tag} --to ${to} stopped: the result covers no known bytes`); return 2; }
|
|
3482
3489
|
return rendered === 0 && carriedRendered ? 0 : 1;
|
|
3483
3490
|
}
|
|
3484
|
-
const r = (o.spawnInherit ??
|
|
3491
|
+
const r = (o.spawnInherit ?? inheritLaunch)(process.execPath, [cli, to, ...passthrough], { cwd: source ? snapshotAppRootOf(ds.path, appDir) : appRoot, env: childEnv });
|
|
3485
3492
|
const carriedOk = await carrier.finish({ stage: to });
|
|
3486
3493
|
if (ds && !(await closeSnapshotStage({ o, ds, root, stage: to, step: to, tag })).ok) { o.err(`${tag} --to ${to} stopped: the result covers no known bytes`); return 2; }
|
|
3487
3494
|
return r.status === 0 && carriedOk ? 0 : 1;
|
|
@@ -3588,8 +3595,10 @@ export async function main(argv, io = {}) {
|
|
|
3588
3595
|
const stampsLines = (args.includes("--to") || args.includes("--full-a") || args.includes("--all"))
|
|
3589
3596
|
&& !args.some((a) => ["--route", "--list", "--print-baseline", "--json", "--plan", "--version", "-v", "--help", "-h"].includes(a));
|
|
3590
3597
|
if (stampsLines) {
|
|
3591
|
-
|
|
3598
|
+
// Every line of a multi-line message carries the stamp, not only its first.
|
|
3599
|
+
const stamped = (write) => (m) => { if (/^rightkit-gate: verdict deterministic/.test(String(m))) return write(m); const at = new Date().toISOString(); return write(String(m).split("\n").map((l) => `${at} ${l}`).join("\n")); };
|
|
3592
3600
|
o.out = stamped(o.out); o.err = stamped(o.err);
|
|
3601
|
+
stampChildLines = true;
|
|
3593
3602
|
}
|
|
3594
3603
|
// The cache bypass is retired (GC-T14; workspace rule: never write or run a no-cache option). Refused by name so an old caller learns why.
|
|
3595
3604
|
if (args.includes("--no-cache") || (io.env ?? process.env).RK_GATE_CACHE === "0") {
|
|
@@ -3758,7 +3767,7 @@ export async function main(argv, io = {}) {
|
|
|
3758
3767
|
if (root && selfRules === 0 && snapshotDir && rightkitRepository && appCheck === 0 && classA === 0) {
|
|
3759
3768
|
// The commit's own preflight reads the commit from the checkout's object database; its exports probe imports from the snapshot,
|
|
3760
3769
|
// whose dependencies class A installed, and reports beside (never over) the commit-bound report publication reads.
|
|
3761
|
-
const launch = o.spawnInherit ??
|
|
3770
|
+
const launch = o.spawnInherit ?? inheritLaunch;
|
|
3762
3771
|
// GC-A24: RightKit's own preflight and exports probe execute the commit's code with its installed dependencies; a pass is reused
|
|
3763
3772
|
// for the same commit tree, installed-dependency bytes, node and platform (and scope), and only a pass.
|
|
3764
3773
|
const effects = path.join(snapshotDir, "scripts", "ci", "exports-import-effects.mjs");
|
|
@@ -3776,7 +3785,7 @@ export async function main(argv, io = {}) {
|
|
|
3776
3785
|
}
|
|
3777
3786
|
if (selfKey && !selfCached && selfRules === 0) ruleCache.pass(selfKey);
|
|
3778
3787
|
} else if (root && selfRules === 0 && !snapshotDir && (rightkitRepository || canon(self).startsWith(canon(root) + path.sep)) && o.exists(path.join(root, "scripts", "preflight.mjs")) && appCheck === 0 && classA === 0) {
|
|
3779
|
-
const launch = o.spawnInherit ??
|
|
3788
|
+
const launch = o.spawnInherit ?? inheritLaunch;
|
|
3780
3789
|
const selector = args.includes("--worktree") ? ["--worktree"] : ["--commit", option("--commit") ?? "HEAD"];
|
|
3781
3790
|
const r = launch(process.execPath, [path.join(root, "scripts", "preflight.mjs"), "--repo", root, ...selector], { cwd: root, env: o.env });
|
|
3782
3791
|
selfRules = r.status === 0 ? 0 : 1;
|
package/build-ownership.mjs
CHANGED
|
@@ -67,7 +67,9 @@ import { spawn as spawnDetachedDefault, spawnSync } from "./background-process.m
|
|
|
67
67
|
import { managedRuntimeClient } from "./managed-cargo.mjs";
|
|
68
68
|
import { resolveManagedRoots } from "./managed-roots.mjs";
|
|
69
69
|
import { requireManagedRoot } from "./managed-root-guard.mjs";
|
|
70
|
-
import {
|
|
70
|
+
import { readEnrolledPins } from "./broker-pins.mjs";
|
|
71
|
+
import { isRevocationEnvelope, readRevocation, revocationFile, verifyRevocation } from "./handle-revocation.mjs";
|
|
72
|
+
import { OWNERSHIP_ENV, OWNERSHIP_FILE_ENV, OwnershipBusy, holds, markBrokerSubmit, markBrokerUnsent, isMarkLockText, markCarriedSend, markLockFile, withMarkLock } from "./ownership-mark.mjs";
|
|
71
73
|
|
|
72
74
|
// The mark itself lives in a leaf module (ownership-mark.mjs): snapshot-broker.mjs records carried sends through it, and importing this
|
|
73
75
|
// file from there would close a cycle (this file -> managed-cargo -> cargo-target-shim -> snapshot-broker).
|
|
@@ -1050,7 +1052,7 @@ function coveredMember(m, owner, { byPid, own }) {
|
|
|
1050
1052
|
* Whether the work `owner` covers, other than the process `self` (the live gate at release, null at reclaim), is proven gone.
|
|
1051
1053
|
* Returns the proofs, or throws a reason that is busy.
|
|
1052
1054
|
*/
|
|
1053
|
-
function coveredWorkGone(owner, { probe, lease, file, selfPid = null, waitMs = 0, timing = null }) {
|
|
1055
|
+
function coveredWorkGone(owner, { probe, lease, file, selfPid = null, waitMs = 0, timing = null, revoked = null, processOnly = false, broker = null }) {
|
|
1054
1056
|
const measure = (name, fn) => { const start = performance.now(); try { return fn(); } finally { if (timing) timing[name] = (timing[name] ?? 0) + performance.now() - start; } };
|
|
1055
1057
|
const proofs = [];
|
|
1056
1058
|
let rebooted = false;
|
|
@@ -1190,7 +1192,9 @@ function coveredWorkGone(owner, { probe, lease, file, selfPid = null, waitMs = 0
|
|
|
1190
1192
|
} else if (!rebooted) {
|
|
1191
1193
|
throw new Error(`the record names no containment (${JSON.stringify(c)})`);
|
|
1192
1194
|
}
|
|
1193
|
-
if (
|
|
1195
|
+
if (processOnly) {
|
|
1196
|
+
proofs.push("broker work NOT judged: a process-only proof (rightkit#1511) says nothing about broker leases");
|
|
1197
|
+
} else if (owner.broker?.submitted) {
|
|
1194
1198
|
// Every submission under this handle must be accounted for by NAME, never by the bare handle (GB-21, GB-23, GB-85). The bare handle answers REAPED when at least one
|
|
1195
1199
|
// member completed and none is held (rustright snapshot.rs `status`), so it proves only that no lease is held now: a completed sibling never stands in for an
|
|
1196
1200
|
// unknown submission. Each recorded sub-handle (broker.handles, recorded before its send) is asked by its exact name and must be one of
|
|
@@ -1201,13 +1205,23 @@ function coveredWorkGone(owner, { probe, lease, file, selfPid = null, waitMs = 0
|
|
|
1201
1205
|
const unsent = owner.broker.unsent && typeof owner.broker.unsent === "object" ? owner.broker.unsent : {};
|
|
1202
1206
|
const waitOptions = waitMs > 0 ? { waitMs } : {};
|
|
1203
1207
|
const settled = (sub) => unsent[sub] && typeof unsent[sub].reason === "string";
|
|
1204
|
-
|
|
1208
|
+
// rightkit#1511: a sub-handle the broker can no longer answer may instead carry the broker's signed revocation of exactly that sub-handle, bound to
|
|
1209
|
+
// this record's bytes (handle-revocation.mjs). It is offered only by a dead owner's reclaim (judgeOwner), never by a release; a bad revocation throws.
|
|
1210
|
+
const revokedOf = new Map();
|
|
1211
|
+
const revocation = (sub) => { if (!revoked) return null; if (!revokedOf.has(sub)) revokedOf.set(sub, revoked(sub)); return revokedOf.get(sub); };
|
|
1212
|
+
// rightkit#1513 (Adrian, 2026-11-05: "It should ideally auto recover"): in a dead owner's reclaim (never a live release), after every process
|
|
1213
|
+
// proof above passed, a sub-handle the broker answers UNKNOWN with no member row was never received when the SAME broker process has run since
|
|
1214
|
+
// before this ownership was acquired: that broker would hold a claim, lease or member row for anything it got, and no process remains to send it.
|
|
1215
|
+
const acquiredMs = Date.parse(owner.acquiredAt);
|
|
1216
|
+
const brokerUpThroughout = selfPid === null && broker && Number.isFinite(broker.startedMs) && Number.isFinite(acquiredMs) && broker.startedMs + 2000 < acquiredMs;
|
|
1217
|
+
const neverReceived = new Set();
|
|
1218
|
+
const everyUnsent = () => handles.length > 0 && handles.every((sub) => settled(sub) || revocation(sub) !== null || brokerUpThroughout);
|
|
1205
1219
|
const status = measure("leaseMs", () => lease({ snapshot: owner.snapshot, handle: owner.handle, ...waitOptions }));
|
|
1206
|
-
if (status.state === "ACTIVE" || (status.state !== "REAPED" && !everyUnsent)) throw new Error(`broker work may exist under this handle and its lease is ${status.state} (${status.why})`);
|
|
1220
|
+
if (status.state === "ACTIVE" || (status.state !== "REAPED" && !everyUnsent())) throw new Error(`broker work may exist under this handle and its lease is ${status.state} (${status.why})`);
|
|
1207
1221
|
if (status.state === "REAPED") proofs.push(`broker lease for ${owner.handle} is REAPED`);
|
|
1208
1222
|
// GB-23: the answer's own member rows account for each recorded sub-handle too: a recorded one that the broker lists and does not list REAPED keeps ownership, whatever the aggregate said.
|
|
1209
1223
|
if (Array.isArray(status.members)) for (const sub of handles) { const row = status.members.find((m) => m.handle === sub); if (row && row.state !== "REAPED") throw new Error(`the broker lists sub-handle ${sub} as ${row.state} among the members of ${owner.handle}`); }
|
|
1210
|
-
let neverStarted = 0;
|
|
1224
|
+
let neverStarted = 0; let revokedCount = 0;
|
|
1211
1225
|
for (const sub of handles) {
|
|
1212
1226
|
if (typeof sub !== "string" || !sub.startsWith(`${owner.handle}#`) || sub.length <= owner.handle.length + 1) throw new Error(`the record lists ${JSON.stringify(sub)}, which is not a sub-handle of ${owner.handle}`);
|
|
1213
1227
|
const one = measure("leaseMs", () => lease({ snapshot: owner.snapshot, handle: sub, ...waitOptions }));
|
|
@@ -1217,13 +1231,45 @@ function coveredWorkGone(owner, { probe, lease, file, selfPid = null, waitMs = 0
|
|
|
1217
1231
|
continue;
|
|
1218
1232
|
}
|
|
1219
1233
|
if (settled(sub) && one.state === "UNKNOWN" && Array.isArray(one.members) && one.members.length === 0) { proofs.push(`${sub} never started (${unsent[sub].reason}) and the broker holds nothing under it`); neverStarted += 1; continue; }
|
|
1234
|
+
// The revocation settles only what the broker cannot answer: UNKNOWN, no member row for it here or in the owner's answer. ACTIVE or a listed member always holds.
|
|
1235
|
+
const listed = Array.isArray(status.members) && status.members.some((m) => m.handle === sub);
|
|
1236
|
+
const rev = one.state === "UNKNOWN" && Array.isArray(one.members) && one.members.length === 0 && !listed ? revocation(sub) : null;
|
|
1237
|
+
if (rev) { proofs.push(`${sub} is UNKNOWN to the broker and revoked by its signed revocation ${rev.file} (proof ${rev.payload.proofSha256})`); revokedCount += 1; continue; }
|
|
1238
|
+
if (brokerUpThroughout && one.state === "UNKNOWN" && Array.isArray(one.members) && one.members.length === 0 && !listed) { neverReceived.add(sub); continue; }
|
|
1220
1239
|
throw new Error(`broker work may exist under sub-handle ${sub} and its lease is ${one.state} (${one.why})`);
|
|
1221
1240
|
}
|
|
1222
|
-
if (
|
|
1241
|
+
if (neverReceived.size) proofs.push(`${neverReceived.size} sub-handle(s) never reached the broker: UNKNOWN with no member row to broker pid ${broker.pid}, up since ${new Date(broker.startedMs).toISOString()}, before this ownership (${owner.acquiredAt}), and no process of the run remains (${[...neverReceived].slice(0, 3).join(", ")}${neverReceived.size > 3 ? ", ..." : ""})`);
|
|
1242
|
+
if (handles.length) proofs.push(neverStarted === 0 && revokedCount === 0 && neverReceived.size === 0 ? `broker lease for each of ${handles.length} sub-handle(s) is REAPED` : `every one of ${handles.length} sub-handle(s) is accounted for: ${handles.length - neverStarted - revokedCount - neverReceived.size} REAPED, ${neverStarted} proven never started, ${neverReceived.size} never reached the broker, ${revokedCount} revoked by the broker`);
|
|
1223
1243
|
}
|
|
1224
1244
|
return proofs;
|
|
1225
1245
|
}
|
|
1226
1246
|
|
|
1247
|
+
/**
|
|
1248
|
+
* rightkit#1511 (rustright#228): the process half of a dead owner's reclaim, for RustRight's offline revocation helper to bind before it signs: the owner pid is
|
|
1249
|
+
* gone (or now runs another process) and every process check of a reclaim passes (detached groups, token holders, snapshot users, containment), with NO broker
|
|
1250
|
+
* lease judged and nothing written. Returns `{ schema, ownerFile, dataRoot, ownerSha256, ownerHandle, snapshot, host, proofs, provedAt }`; throws OwnershipBusy
|
|
1251
|
+
* naming what is still live or unknown. It never stands in for a reclaim: the reclaim still runs every check, the broker's included.
|
|
1252
|
+
*/
|
|
1253
|
+
/** Which RightKit code produced a process proof: this package's name and version and the SHA-256 of build-ownership.mjs itself. */
|
|
1254
|
+
function probeIdentity() {
|
|
1255
|
+
const here = new URL(import.meta.url);
|
|
1256
|
+
const pkg = JSON.parse(fs.readFileSync(new URL("./package.json", here), "utf8"));
|
|
1257
|
+
return { package: pkg.name, version: pkg.version, moduleSha256: crypto.createHash("sha256").update(fs.readFileSync(here)).digest("hex") };
|
|
1258
|
+
}
|
|
1259
|
+
export const OWNER_PROCESS_PROOF_SCHEMA = "rightkit.owner-process-proof/1";
|
|
1260
|
+
export function proveOwnerProcessesGone({ file, platform = process.platform, probe = processProbe({ platform }), host = os.hostname(), now = () => new Date() }) {
|
|
1261
|
+
const observed = readText(file);
|
|
1262
|
+
if (observed === null) throw new OwnershipBusy(`build ownership ${file}: no record`);
|
|
1263
|
+
const noLease = () => { throw new Error("a process-only proof asks the broker nothing"); };
|
|
1264
|
+
const { owner, proofs } = judgeOwner(observed, { file, probe, lease: noLease, host, processOnly: true });
|
|
1265
|
+
if (readText(file) !== observed) throw new OwnershipBusy(`build ownership ${file} changed while its processes were judged`);
|
|
1266
|
+
return {
|
|
1267
|
+
schema: OWNER_PROCESS_PROOF_SCHEMA, ownerFile: fs.realpathSync.native(file), dataRoot: fs.realpathSync.native(dataRootOf(file)),
|
|
1268
|
+
ownerSha256: crypto.createHash("sha256").update(Buffer.from(observed, "utf8")).digest("hex"), ownerHandle: owner.handle, snapshot: owner.snapshot ?? null,
|
|
1269
|
+
host, proofs, provedAt: now().toISOString(), probe: probeIdentity(),
|
|
1270
|
+
};
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1227
1273
|
/**
|
|
1228
1274
|
* Whether the claimant a standing `.reclaim` body names is `"dead"` (proven), `"live"` or `"unknown"`. The body is the claimant's own owner record, so the same identity
|
|
1229
1275
|
* rules as the record's judge apply: another host or an unreadable body is unknown; a reboot since the claimant started, a gone pid, or a pid that now runs a process that
|
|
@@ -1244,7 +1290,7 @@ export function judgeClaimant(text, { probe, host }) {
|
|
|
1244
1290
|
* Why the record `observed` may be reclaimed (`{ owner, proofs }`), or an OwnershipBusy throw naming what is still live or
|
|
1245
1291
|
* unknown. Pure apart from the probes.
|
|
1246
1292
|
*/
|
|
1247
|
-
export function judgeOwner(observed, { file, probe, lease, host = os.hostname() }) {
|
|
1293
|
+
export function judgeOwner(observed, { file, probe, lease, host = os.hostname(), pins = null, processOnly = false, broker = null }) {
|
|
1248
1294
|
let owner = null;
|
|
1249
1295
|
try { owner = JSON.parse(observed); } catch { owner = null; }
|
|
1250
1296
|
const busy = (why, detail = {}) => new OwnershipBusy(`build ownership ${file}: ${why}`, { owner, ...detail });
|
|
@@ -1258,8 +1304,19 @@ export function judgeOwner(observed, { file, probe, lease, host = os.hostname()
|
|
|
1258
1304
|
throw busy(`held by pid ${owner.pid} (${owner.stage ?? "stage"} of ${owner.commit ?? "a commit"}) since ${owner.acquiredAt}`);
|
|
1259
1305
|
}
|
|
1260
1306
|
const proofs = [self.alive ? `owner pid ${owner.pid} now runs another process (started ${new Date(self.startedMs).toISOString()}, owner started ${new Date(owner.startedMs).toISOString()})` : `owner pid ${owner.pid} is gone`];
|
|
1261
|
-
|
|
1262
|
-
|
|
1307
|
+
// rightkit#1511: revocations are judged against the exact bytes judged here; the reclaim rereads both under its claim before it removes anything.
|
|
1308
|
+
const revocations = [];
|
|
1309
|
+
const revoked = pins ? (sub) => {
|
|
1310
|
+
const dataRoot = fs.realpathSync.native(dataRootOf(file));
|
|
1311
|
+
const at = revocationFile(dataRoot, owner.handle, sub, owner.snapshot);
|
|
1312
|
+
const bytes = readRevocation(at);
|
|
1313
|
+
if (bytes === null || !isRevocationEnvelope(bytes)) return null;
|
|
1314
|
+
const payload = verifyRevocation(bytes, pins, { ownerFile: fs.realpathSync.native(file), dataRoot, ownerBytes: Buffer.from(observed, "utf8"), owner, sub });
|
|
1315
|
+
revocations.push({ file: at, bytes });
|
|
1316
|
+
return { file: at, payload };
|
|
1317
|
+
} : null;
|
|
1318
|
+
try { proofs.push(...coveredWorkGone(owner, { probe, lease, file, revoked, processOnly, broker })); } catch (e) { throw busy(`owner pid ${owner.pid} is gone but ${e.message}`); }
|
|
1319
|
+
return { owner, proofs, revocations };
|
|
1263
1320
|
}
|
|
1264
1321
|
|
|
1265
1322
|
/**
|
|
@@ -1280,6 +1337,8 @@ export function acquireBuildOwnership({
|
|
|
1280
1337
|
hooks = {},
|
|
1281
1338
|
managedRoot,
|
|
1282
1339
|
device,
|
|
1340
|
+
brokerPins,
|
|
1341
|
+
brokerIdentity,
|
|
1283
1342
|
} = {}) {
|
|
1284
1343
|
// First, before the environment, the record or any write: the managed root exists (decision D4). `managedRoot` and `device` are
|
|
1285
1344
|
// fixtures' seams; a production caller passes neither.
|
|
@@ -1311,7 +1370,7 @@ export function acquireBuildOwnership({
|
|
|
1311
1370
|
if (!live.alive || (Number.isFinite(owner.startedMs) && Number.isFinite(live.startedMs) && !sameStart(live.startedMs, owner.startedMs))) {
|
|
1312
1371
|
throw new OwnershipBusy(`build ownership ${file}: ${OWNERSHIP_ENV}=${inherited} names a record whose owner pid ${owner.pid} is no longer the process that took it; a nested gate joins only a live owner's record`);
|
|
1313
1372
|
}
|
|
1314
|
-
return { handle: inherited, file, joined: true, reclaimed: null, owner, markBrokerSubmit: (callHandle) => markBrokerSubmit(file, inherited, callHandle), markBrokerUnsent: (callHandle, reason) => markBrokerUnsent(file, inherited, callHandle, reason), held: () => holds(file, inherited), release: () => ({ released: false, joined: true }) };
|
|
1373
|
+
return { handle: inherited, file, joined: true, reclaimed: null, owner, markBrokerSubmit: (callHandle, note) => markBrokerSubmit(file, inherited, callHandle, { note }), markBrokerUnsent: (callHandle, reason) => markBrokerUnsent(file, inherited, callHandle, reason), held: () => holds(file, inherited), release: () => ({ released: false, joined: true }) };
|
|
1315
1374
|
}
|
|
1316
1375
|
throw new OwnershipBusy(`build ownership ${file}: ${OWNERSHIP_ENV}=${inherited} is not the current owner; a nested gate never takes ownership of its own`);
|
|
1317
1376
|
}
|
|
@@ -1395,12 +1454,15 @@ export function acquireBuildOwnership({
|
|
|
1395
1454
|
catch (e) { if (holds(file, handle)) fs.rmSync(file, { force: true }); throw new OwnershipBusy(`build ownership ${file}: the containment could not be recorded (${e.code ?? e.message}: ${e.message})`); }
|
|
1396
1455
|
}
|
|
1397
1456
|
if (exportEnv) { process.env[OWNERSHIP_ENV] = handle; process.env[OWNERSHIP_FILE_ENV] = file; }
|
|
1398
|
-
return { handle, file, joined: false, reclaimed, owner: record, contained: platform === "win32" ? record.containment.contained === true : true, markBrokerSubmit: (callHandle) => markBrokerSubmit(file, handle, callHandle), markBrokerUnsent: (callHandle, reason) => markBrokerUnsent(file, handle, callHandle, reason), held: () => holds(file, handle), release };
|
|
1457
|
+
return { handle, file, joined: false, reclaimed, owner: record, contained: platform === "win32" ? record.containment.contained === true : true, markBrokerSubmit: (callHandle, note) => markBrokerSubmit(file, handle, callHandle, { note }), markBrokerUnsent: (callHandle, reason) => markBrokerUnsent(file, handle, callHandle, reason), held: () => holds(file, handle), release };
|
|
1399
1458
|
};
|
|
1400
1459
|
if (publish(file, body)) return done(null);
|
|
1401
1460
|
const observed = readText(file);
|
|
1402
1461
|
if (observed === null) { if (publish(file, body)) return done(null); throw new OwnershipBusy(`build ownership ${file} was taken by another process`); }
|
|
1403
|
-
|
|
1462
|
+
// GC-A25 is proposed, not operative: RustRight has not frozen the revocation's authoritative path (its f227 completion key fences legacy reuse; a record
|
|
1463
|
+
// only beside this one does not) nor its publication sequence. Until then no production reclaim honours a revocation; only a caller that passes
|
|
1464
|
+
// `brokerPins` explicitly (fixtures) exercises the branch. Enable by defaulting to enrolledPinsFor(file, platform) once GC-A25 is operative.
|
|
1465
|
+
const judged = judgeOwner(observed, { file, probe, lease, pins: brokerPins ?? null, broker: brokerIdentity === undefined ? runningBrokerProcess({ platform }) : brokerIdentity });
|
|
1404
1466
|
hooks.afterJudge?.();
|
|
1405
1467
|
// A reclaim means the previous release was not clean (a crash, or a release that ended held): nothing unreadable is skipped.
|
|
1406
1468
|
record.cleanBefore = null;
|
|
@@ -1418,13 +1480,21 @@ export function acquireBuildOwnership({
|
|
|
1418
1480
|
}
|
|
1419
1481
|
try {
|
|
1420
1482
|
hooks.afterClaim?.(reclaim);
|
|
1483
|
+
// rightkit#1511: the reread, the removal and the new record run under the record's mark lock too, so no submit or unsent mark of the old owner can land
|
|
1484
|
+
// between the reread and the removal (a mark after it finds another handle and refuses). The lock is released by withMarkLock, not removed here.
|
|
1485
|
+
// A mark lock that cannot be read was left by a crash (it is only ever published whole). The owner and every process under it are proven gone and this
|
|
1486
|
+
// reclaim holds the claim, so no marker of this record can exist: that exact debris is removed, compare-by-content, instead of blocking every later gate.
|
|
1487
|
+
const debris = readText(markLockFile(file));
|
|
1488
|
+
if (debris !== null && !isMarkLockText(debris) && readText(markLockFile(file)) === debris) fs.rmSync(markLockFile(file), { force: true });
|
|
1489
|
+
withMarkLock(file, () => {
|
|
1421
1490
|
if (readText(file) !== observed) throw new OwnershipBusy(`build ownership ${file} changed before it could be reclaimed`);
|
|
1491
|
+
for (const r of judged.revocations) { let now = null; try { now = readRevocation(r.file); } catch { now = null; } if (!now || !now.equals(r.bytes)) throw new OwnershipBusy(`build ownership ${file}: the broker revocation ${r.file} changed before the record could be reclaimed`); }
|
|
1422
1492
|
fs.rmSync(file, { force: true });
|
|
1423
|
-
fs.rmSync(markLockFile(file), { force: true });
|
|
1424
1493
|
fs.rmSync(holderFile(file, judged.owner.handle), { force: true });
|
|
1425
1494
|
fs.rmSync(holderScriptFile(holderFile(file, judged.owner.handle)), { force: true });
|
|
1426
1495
|
fs.rmSync(childrenDir(file, judged.owner.handle), { recursive: true, force: true });
|
|
1427
1496
|
if (!publish(file, reclaimBody)) throw new OwnershipBusy(`build ownership ${file} was taken by another process`);
|
|
1497
|
+
});
|
|
1428
1498
|
} finally {
|
|
1429
1499
|
// Token-checked: only this reclaim's own claim is removed (a successor's claim, published after this one was judged dead, stays).
|
|
1430
1500
|
if (readText(reclaim) === reclaimBody) fs.rmSync(reclaim, { force: true });
|
|
@@ -1432,6 +1502,44 @@ export function acquireBuildOwnership({
|
|
|
1432
1502
|
return done({ from: judged.owner.handle, pid: judged.owner.pid, proofs: judged.proofs });
|
|
1433
1503
|
}
|
|
1434
1504
|
|
|
1505
|
+
/**
|
|
1506
|
+
* rightkit#1511: the host's ENROLLED broker pin (`<managed root>/pins/broker-<platform>.json`; the record is `<managed root>/build-ownership/<key>/owner.json`),
|
|
1507
|
+
* or null when none is enrolled or it cannot be read: then no revocation is honoured and the reclaim proofs stand as before. Never the checkout fallback.
|
|
1508
|
+
*/
|
|
1509
|
+
function enrolledPinsFor(file, platform) {
|
|
1510
|
+
try { return readEnrolledPins({ dataRoot: dataRootOf(file), platform }); } catch { return null; }
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1513
|
+
/** The managed data root a record `<root>/build-ownership/<key>/owner.json` lives under. */
|
|
1514
|
+
const dataRootOf = (file) => path.dirname(path.dirname(path.dirname(file)));
|
|
1515
|
+
|
|
1516
|
+
/**
|
|
1517
|
+
* rightkit#1513: the running RustRight broker's pid and start time (epoch ms), from launchd and ps (macOS); null when it cannot be
|
|
1518
|
+
* established. A broker that has run continuously since before an ownership was acquired saw every request of that run.
|
|
1519
|
+
*/
|
|
1520
|
+
export function runningBrokerProcess({ platform = process.platform, run = spawnSync, uid = process.getuid?.() } = {}) {
|
|
1521
|
+
if (platform === "win32") {
|
|
1522
|
+
// The Dell's broker runs as rustright-broker.exe (D:\.rustright\runtime). Exactly one such process, else unknown (fail safe).
|
|
1523
|
+
try {
|
|
1524
|
+
const script = "$p = @(Get-Process -Name rustright-broker -ErrorAction SilentlyContinue); if ($p.Count -eq 1) { \"$($p[0].Id) $($p[0].StartTime.ToUniversalTime().ToString('o'))\" }";
|
|
1525
|
+
const r = run("powershell.exe", ["-NoLogo", "-NoProfile", "-NonInteractive", "-EncodedCommand", Buffer.from(script, "utf16le").toString("base64")], { encoding: "utf8", timeout: 15000, windowsHide: true });
|
|
1526
|
+
const m = /^(\d+) (\S+)\s*$/m.exec(String(r.stdout ?? ""));
|
|
1527
|
+
if (!m) return null;
|
|
1528
|
+
const pid = Number(m[1]); const startedMs = Date.parse(m[2]);
|
|
1529
|
+
return Number.isInteger(pid) && pid > 0 && Number.isFinite(startedMs) ? { pid, startedMs } : null;
|
|
1530
|
+
} catch { return null; }
|
|
1531
|
+
}
|
|
1532
|
+
if (platform !== "darwin") return null;
|
|
1533
|
+
try {
|
|
1534
|
+
const lc = run("launchctl", ["print", `gui/${uid}/dev.rustright.broker`], { encoding: "utf8", timeout: 5000 });
|
|
1535
|
+
const pid = Number(/^\s*pid = (\d+)$/m.exec(String(lc.stdout ?? ""))?.[1]);
|
|
1536
|
+
if (!Number.isInteger(pid) || pid <= 0) return null;
|
|
1537
|
+
const ps = run("ps", ["-o", "lstart=", "-p", String(pid)], { encoding: "utf8", timeout: 5000, env: { ...process.env, LC_ALL: "C", LANG: "C" } });
|
|
1538
|
+
const startedMs = Date.parse(String(ps.stdout ?? "").trim());
|
|
1539
|
+
return Number.isFinite(startedMs) ? { pid, startedMs } : null;
|
|
1540
|
+
} catch { return null; }
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1435
1543
|
/** Replaces the record atomically while it is still `handle`'s. */
|
|
1436
1544
|
function rewriteRecord(file, handle, change) {
|
|
1437
1545
|
const text = readText(file);
|
package/cross-targets.mjs
CHANGED
|
@@ -68,15 +68,31 @@ export function crossCcDir({ env = process.env, exists = fs.existsSync, platform
|
|
|
68
68
|
return dir && exists(dir) ? dir : null;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
/**
|
|
72
|
-
export
|
|
71
|
+
/** The cross-target pkg-config stub's file name in the wrapper directory (scripts/ci/provision-zig.mjs writes it). */
|
|
72
|
+
export const PKG_CONFIG_CROSS = "pkg-config-cross";
|
|
73
|
+
/** The cross-target windres stub (non-Windows hosts; scripts/ci/provision-zig.mjs writes it). */
|
|
74
|
+
export const WINDRES_CROSS = "windres-cross";
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* cc-rs / cmake environment pointing a target's C, C++ and archiver at the provisioned zig wrappers (none when unprovisioned).
|
|
78
|
+
* When the wrapper directory holds the pkg-config stub, a foreign target's pkg-config is that stub (GC-A14): no host has another OS's
|
|
79
|
+
* sysroot, and a cross-target row is a clippy type-check that never links, so a -sys build script (gdk-pixbuf-sys, webkit2gtk-sys under
|
|
80
|
+
* Tauri on Linux) needs pkg-config only to answer, not to locate a library. Measured 2026-11-05: every Tauri consumer's Linux cross row
|
|
81
|
+
* failed on the Mac with "pkg-config has not been configured to support cross-compilation".
|
|
82
|
+
*/
|
|
83
|
+
export function crossCompileEnv(target, dir = crossCcDir(), platform = process.platform, exists = fs.existsSync) {
|
|
73
84
|
if (!dir) return undefined;
|
|
74
85
|
const key = target.replaceAll("-", "_");
|
|
75
86
|
const ext = platform === "win32" ? ".cmd" : "";
|
|
87
|
+
const stub = path.join(dir, `${PKG_CONFIG_CROSS}${ext}`);
|
|
76
88
|
return {
|
|
77
89
|
[`CC_${key}`]: path.join(dir, `cc-${target}${ext}`),
|
|
78
90
|
[`CXX_${key}`]: path.join(dir, `cxx-${target}${ext}`),
|
|
79
91
|
[`AR_${key}`]: path.join(dir, `ar-${target}${ext}`),
|
|
92
|
+
...(exists(stub) ? { [`PKG_CONFIG_${key}`]: stub, [`PKG_CONFIG_ALLOW_CROSS_${key}`]: "1" } : {}),
|
|
93
|
+
// A windows-gnu cross row off Windows: embed-resource (tauri-winres) needs a resource compiler; the stub answers as GNU windres and
|
|
94
|
+
// writes an empty archive (the row never links). Reported by the Pulse lane, 2026-11-05: tauri-winres NotAttempted(x86_64-w64-mingw32-windres).
|
|
95
|
+
...(target.endsWith("-windows-gnu") && exists(path.join(dir, WINDRES_CROSS)) ? { [`RC_${key}`]: path.join(dir, WINDRES_CROSS) } : {}),
|
|
80
96
|
};
|
|
81
97
|
}
|
|
82
98
|
|
package/deterministic-scans.mjs
CHANGED
|
@@ -1410,8 +1410,10 @@ export function planScans({
|
|
|
1410
1410
|
for (const name of withChangelog) add({ id: rustScanId.changelog(name), class: A, internal: "changelog-version", files: [inDir(rustDir(name), "Cargo.toml"), inDir(rustDir(name), "CHANGELOG.md")] });
|
|
1411
1411
|
if (crateDirs.length || pkgDirs.length) {
|
|
1412
1412
|
add({ id: "license", class: A, internal: "license", files: [...crateDirs.map((d) => inDir(d, "Cargo.toml")), ...pkgDirs.map((d) => inDir(d, "package.json"))] });
|
|
1413
|
-
add({ id: "secret-scan", class: A, internal: "secret-scan", dirs: [...crateDirs, ...pkgDirs] });
|
|
1414
1413
|
}
|
|
1414
|
+
// Every tracked file of the commit, not only crate and package directories (GATE-CONTRACT GC-A20 "the commit's tracked files"; a token in
|
|
1415
|
+
// docs/ passed before, found by the GC-A27 acceptance run N02, rightkit#1514). Ignored and stage-written paths are skipped as before.
|
|
1416
|
+
add({ id: "secret-scan", class: A, internal: "secret-scan", dirs: ["."] });
|
|
1415
1417
|
|
|
1416
1418
|
// ---- class B: needs the compiler or runs tests or repository code
|
|
1417
1419
|
// The docs generator is code. It runs only from the TRUSTED checkout (liveRoot), with the exported commit
|
|
@@ -2111,6 +2113,8 @@ export async function runTestBinaries({ scan, binaries, spawn, env, limitMs, sig
|
|
|
2111
2113
|
// ADR-001 C2 (kept by Adrian 2026-11-02, rightkit#1454): the executables run in parallel, `concurrency` at a time (physical cores minus 2), each
|
|
2112
2114
|
// recording into its own slot so the report keeps the listing order.
|
|
2113
2115
|
const slots = new Array(binaries.length);
|
|
2116
|
+
// rightkit#1512: each executable's own stdout/stderr, kept for the row's failure log (the cargo compile output is not the test run's).
|
|
2117
|
+
const outputs = new Array(binaries.length);
|
|
2114
2118
|
const runOne = async (b, index) => {
|
|
2115
2119
|
const executables = { push: (e) => { slots[index] = e; } };
|
|
2116
2120
|
{
|
|
@@ -2123,6 +2127,7 @@ export async function runTestBinaries({ scan, binaries, spawn, env, limitMs, sig
|
|
|
2123
2127
|
try { r = await spawn(b.real, args, { cwd: b.manifestDir, env: childEnv, signal: runSignal, boundedMs: remaining }); } catch (e) { r = { error: e }; }
|
|
2124
2128
|
if (runSignal.aborted && (!r || r.error || r.status !== 0)) { stopped = signal?.aborted ? "CANCELLED" : "TIMEOUT"; executables.push({ label, sha256: b.sha256, status: "not-run" }); return; }
|
|
2125
2129
|
if (r?.error?.code === "ETIMEDOUT" || r?.timedOut === true) { stopped = "TIMEOUT"; executables.push({ label, sha256: b.sha256, status: "fail" }); failures.push(`${label}: killed with its process tree at the run limit`); return; }
|
|
2130
|
+
outputs[index] = { label, exit: r?.status ?? null, signal: r?.signal ?? null, stdout: String(r?.stdout ?? ""), stderr: String(r?.stderr ?? "") };
|
|
2126
2131
|
const summary = parseLibtestSummary(`${r?.stdout ?? ""}\n${r?.stderr ?? ""}`);
|
|
2127
2132
|
if (summary) { total.tests += summary.passed + summary.failed + summary.ignored; total.pass += summary.passed; total.fail += summary.failed; total.skipped += summary.ignored; }
|
|
2128
2133
|
const output = `${r?.stdout ?? ""}\n${r?.stderr ?? ""}`.replace(/\u001b\[[0-9;?]*[ -/]*[@-~]/g, "");
|
|
@@ -2141,12 +2146,12 @@ export async function runTestBinaries({ scan, binaries, spawn, env, limitMs, sig
|
|
|
2141
2146
|
for (const e of slots) if (e) executables.push(e);
|
|
2142
2147
|
} finally { clearTimeout(clock); }
|
|
2143
2148
|
const results = { runner: "libtest", ...total, binaries: executables.length };
|
|
2144
|
-
if (stopped === "CANCELLED") return { status: "not-run", code: "CANCELLED", detail: "cancelled while running", results, executables };
|
|
2145
|
-
if (stopped === "TIMEOUT") return { status: "fail", code: "TIMEOUT", detail: `${scan.id}: its test executables ran longer than the ${Math.round(limitMs / 1000)} s run limit and were killed with their process tree${failures.length ? `; ${failures.slice(0, 3).join(" | ")}` : ""}`, results, executables };
|
|
2146
|
-
if (failures.length) return { status: "fail", code: "TEST_FAILED", detail: `${failures.length} of ${executables.length} test executable(s) failed: ${failures.slice(0, 5).join(" | ")}`.slice(0, 4000), results, executables };
|
|
2149
|
+
if (stopped === "CANCELLED") return { status: "not-run", code: "CANCELLED", detail: "cancelled while running", results, executables, outputs: outputs.filter(Boolean) };
|
|
2150
|
+
if (stopped === "TIMEOUT") return { status: "fail", code: "TIMEOUT", detail: `${scan.id}: its test executables ran longer than the ${Math.round(limitMs / 1000)} s run limit and were killed with their process tree${failures.length ? `; ${failures.slice(0, 3).join(" | ")}` : ""}`, results, executables, outputs: outputs.filter(Boolean) };
|
|
2151
|
+
if (failures.length) return { status: "fail", code: "TEST_FAILED", detail: `${failures.length} of ${executables.length} test executable(s) failed: ${failures.slice(0, 5).join(" | ")}`.slice(0, 4000), results, executables, outputs: outputs.filter(Boolean) };
|
|
2147
2152
|
const problem = testResultsProblem(results);
|
|
2148
|
-
if (problem) return { status: "fail", code: problem.code, detail: `${problem.detail} (summed over ${executables.length} test executable(s) of ${scan.id})`, results, executables };
|
|
2149
|
-
return { status: "pass", results, executables };
|
|
2153
|
+
if (problem) return { status: "fail", code: problem.code, detail: `${problem.detail} (summed over ${executables.length} test executable(s) of ${scan.id})`, results, executables, outputs: outputs.filter(Boolean) };
|
|
2154
|
+
return { status: "pass", results, executables, outputs: outputs.filter(Boolean) };
|
|
2150
2155
|
}
|
|
2151
2156
|
|
|
2152
2157
|
/** The largest inline `run:` script a workflow may carry while the pinned actionlint is 1.7.12 (rhysd/actionlint#702). */
|
|
@@ -2523,9 +2528,9 @@ const INTERNAL = {
|
|
|
2523
2528
|
const named = behind.slice(0, 5).map((e) => `${e.name} ${e.pinned ?? "?"} -> ${e.latest ?? "?"}`).join(", ");
|
|
2524
2529
|
return remember({ advice: `${behind.length} behind latest${named ? ` (${named}${behind.length > 5 ? ", ..." : ""})` : ""}${unjudged ? `; ${unjudged} not judged` : ""}` });
|
|
2525
2530
|
},
|
|
2526
|
-
// The Swift type-check (rightkit#1289): Mac host only, Class A, before any compile stage. SwiftPM
|
|
2527
|
-
// source against the real SDK and the target's dependencies
|
|
2528
|
-
// end of the Xcode compile (Pulse, 2026-10-29, exit 65 after the Rust stages). The committed Package.resolved decides the dependencies (`--disable-automatic-resolution`);
|
|
2531
|
+
// The Swift type-check (rightkit#1289): Mac host only, Class A, before any compile stage. SwiftPM builds the package (`swift build`) into the scratch root:
|
|
2532
|
+
// every source compiles against the real SDK and the target's dependencies, so a labelled-argument order error fails here in seconds instead of at the
|
|
2533
|
+
// end of the Xcode compile (Pulse, 2026-10-29, exit 65 after the Rust stages). Not `-Xswiftc -typecheck`: with Swift 6.4 it writes no object and SwiftPM still links an executable target, so every package with one failed with "unexpected input file" (rightkit#1514 acceptance run). The committed Package.resolved decides the dependencies (`--disable-automatic-resolution`);
|
|
2529
2534
|
// SwiftPM's state lives under the gate's scratch root, never in the snapshot. A pass is exit 0. A failure with Swift diagnostics lists them; a failure with none is the
|
|
2530
2535
|
// build system's (it did not complete) and still fails: never a pass that checked nothing.
|
|
2531
2536
|
"swift-typecheck": async (s, ctx) => {
|
|
@@ -2535,11 +2540,12 @@ const INTERNAL = {
|
|
|
2535
2540
|
fs.mkdirSync(scratch, { recursive: true });
|
|
2536
2541
|
const packageDir = path.join(ctx.contentRoot, s.dir === "." ? "" : s.dir);
|
|
2537
2542
|
let r;
|
|
2538
|
-
try { r = await ctx.deps.spawn("swift", ["build", "--disable-automatic-resolution", "--package-path", packageDir, "--scratch-path", scratch
|
|
2543
|
+
try { r = await ctx.deps.spawn("swift", ["build", "--disable-automatic-resolution", "--package-path", packageDir, "--scratch-path", scratch], { cwd: packageDir, encoding: "utf8", env: { ...ctx.deps.env, ...PNPM_NO_HOOKS_ENV }, timeout: 10 * 60_000, maxBuffer: 1 << 26 }); }
|
|
2539
2544
|
catch (e) { return { code: "TOOL_MISSING", detail: `${s.id}: swift could not be started (${e.message}); the Swift type-check is required on the Mac host and is never skipped` }; }
|
|
2540
2545
|
if (r?.error) return { code: "TOOL_MISSING", detail: `${s.id}: swift could not be started (${r.error.message}); the Swift type-check is required on the Mac host and is never skipped` };
|
|
2541
2546
|
if (r?.status === 0) return [];
|
|
2542
|
-
|
|
2547
|
+
// Swift 6.4 colours its diagnostics even into a pipe; strip the escapes before reading them.
|
|
2548
|
+
const output = `${r?.stdout ?? ""}\n${r?.stderr ?? ""}`.replace(/\x1b\[[0-9;]*m/g, "");
|
|
2543
2549
|
const diagnostics = [...new Set(output.split(/\r?\n/).filter((l) => /\.swift:\d+:\d+: error:/.test(l)).map((l) => l.trim().replace(/^.*?(?=[^/\\\s]+\.swift:\d+:\d+: error:)/, "")))];
|
|
2544
2550
|
if (diagnostics.length) return diagnostics.slice(0, 8).map((d) => `${s.dir === "." ? "" : `${s.dir}: `}${d}`);
|
|
2545
2551
|
return [`${s.dir === "." ? "swift package" : s.dir}: the Swift type-check did not complete (exit ${r?.status ?? "none"}) and printed no Swift diagnostic: ${failureDetail(r)}`];
|
|
@@ -3311,6 +3317,7 @@ export async function runScans(plan, options = {}) {
|
|
|
3311
3317
|
const sentinelEnv = sentinel ? { CARGO_TARGET_DIR: sentinel, CARGO_BUILD_TARGET_DIR: sentinel } : {};
|
|
3312
3318
|
// A Rust test scan's JSON listing (every compiler-artifact record) streams whole to a file of its own: the kept tail of a spawn would lose the early artifact records of a noisy compile.
|
|
3313
3319
|
let listingDir = null; let listingFile = null; let listingText = ""; let listingCut = false;
|
|
3320
|
+
let testOutputs = null;
|
|
3314
3321
|
if (s.runOutside) { listingDir = fs.mkdtempSync(path.join(tmpRoot, "rk-testlist-")); listingFile = path.join(listingDir, "listing.jsonl"); }
|
|
3315
3322
|
try {
|
|
3316
3323
|
// The ownership records this request's sub-handle immediately before it is sent (the reclaim proof reads broker.submitted): a
|
|
@@ -3318,7 +3325,7 @@ export async function runScans(plan, options = {}) {
|
|
|
3318
3325
|
if (carrier) {
|
|
3319
3326
|
const sub = carrier.made.carrier.ownership.handle;
|
|
3320
3327
|
let marked = null; let why = null;
|
|
3321
|
-
try { if (typeof deps.snapshotBroker.markBrokerSubmit !== "function") throw new Error("no build-ownership submit hook"); marked = deps.snapshotBroker.markBrokerSubmit(sub); } catch (e) { why = e.message; }
|
|
3328
|
+
try { if (typeof deps.snapshotBroker.markBrokerSubmit !== "function") throw new Error("no build-ownership submit hook"); marked = deps.snapshotBroker.markBrokerSubmit(sub, s.id); } catch (e) { why = e.message; }
|
|
3322
3329
|
if (marked?.broker?.submitted !== true || marked.handle !== deps.snapshotBroker.handle || !marked.broker.handles?.includes(sub)) {
|
|
3323
3330
|
stopClock(); advisory?.cleanup?.();
|
|
3324
3331
|
return { ...row, status: "fail", code: "SNAPSHOT_REQUEST", detail: `the snapshot request for ${s.id} was not sent: the build ownership did not record the broker submit under ${deps.snapshotBroker.handle}${why ? ` (${why})` : ""}` };
|
|
@@ -3478,6 +3485,7 @@ export async function runScans(plan, options = {}) {
|
|
|
3478
3485
|
else {
|
|
3479
3486
|
const budget = s.quiet === true ? Math.max(1, Math.min(limitMs, QUIET_SCAN_MAX_MS - (Date.now() - scanStartedAt))) : limitMs;
|
|
3480
3487
|
const ran = await runTestBinaries({ scan: s, binaries: contained.accepted, spawn: deps.spawn, env: { ...deps.env, ...s.env, ...(extraEnv ?? {}) }, limitMs: budget, signal, ops, ...(s.publisherRustTest && s.runOutside.args.includes("--test-threads=1") ? { concurrency: 1 } : {}) });
|
|
3488
|
+
testOutputs = ran.outputs ?? null;
|
|
3481
3489
|
row.results = ran.results; row.testRun = { executables: ran.executables, outputTruncated: ran.executables.some((e) => e.outputTruncated), skipMarkers: ran.executables.reduce((n, e) => n + (e.skipMarkers ?? 0), 0) };
|
|
3482
3490
|
if (s.publisherRustTest && row.testRun.outputTruncated) fail("TEST_OUTPUT_TRUNCATED", `${s.id}: test output was truncated; skip evidence is incomplete`);
|
|
3483
3491
|
if (ran.status !== "pass") { status = ran.status; code = ran.code; detail = ran.detail; }
|
|
@@ -3498,7 +3506,7 @@ export async function runScans(plan, options = {}) {
|
|
|
3498
3506
|
if (status === "pass" && !s.allowIgnored && (row.results?.skipped ?? 0) > 0) { status = "fail"; code = "IGNORED_TESTS"; detail = `${row.results.skipped} ignored Rust test(s) require an approved reason`; }
|
|
3499
3507
|
}
|
|
3500
3508
|
if (status === "fail" && options.scanLogDir && r) {
|
|
3501
|
-
try { fs.mkdirSync(options.scanLogDir, { recursive: true }); const file = path.join(options.scanLogDir, `${s.id.replace(/[^A-Za-z0-9._-]+/g, "_")}.log`); fs.writeFileSync(file, `$ ${s.command ?? s.id}\nexit ${r.status}\n--- stdout\n${r.stdout ?? ""}\n--- stderr\n${r.stderr ?? ""}\n`); row.log = file; detail = `${detail} (full output: ${file})`; } catch { /* the tail in the row remains */ }
|
|
3509
|
+
try { fs.mkdirSync(options.scanLogDir, { recursive: true }); const file = path.join(options.scanLogDir, `${s.id.replace(/[^A-Za-z0-9._-]+/g, "_")}.log`); fs.writeFileSync(file, `$ ${s.command ?? s.id}\nexit ${r.status}\n--- ${s.runOutside ? "cargo (compile) " : ""}stdout\n${r.stdout ?? ""}\n--- ${s.runOutside ? "cargo (compile) " : ""}stderr\n${r.stderr ?? ""}\n${s.runOutside ? (testOutputs?.length ? testOutputs.map((o) => `=== test executable ${o.label} (exit ${o.exit ?? "none"}${o.signal ? `, signal ${o.signal}` : ""}) ${s.runOutside.args.join(" ")}\n--- stdout\n${o.stdout}\n--- stderr\n${o.stderr}\n`).join("") : "=== test executables: none ran (the row failed before or without running them)\n") : ""}`); row.log = file; detail = `${detail} (full output: ${file})`; } catch { /* the tail in the row remains */ }
|
|
3502
3510
|
}
|
|
3503
3511
|
if (s.kind === "test" && r && !r.error && r.status === 0) {
|
|
3504
3512
|
// What the suite executed and skipped is evidence, not decoration: a later stage reuses this row only with these counts.
|