@rightkit/release 0.6.90 → 0.6.92
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/acceptance-run.mjs +33 -4
- package/app-check.mjs +53 -4
- package/bin/rightkit-gate.mjs +22 -12
- package/clippy-route.mjs +116 -50
- package/gate/compile.mjs +3 -2
- package/lint-waivers.mjs +140 -0
- package/package.json +1 -1
- package/release.mjs +7 -1
- package/rightkit-versions.json +25 -16
- package/seam-broker.mjs +21 -12
package/acceptance-run.mjs
CHANGED
|
@@ -40,11 +40,40 @@ export function caseCommit(repo, base, edits, name, scratch) {
|
|
|
40
40
|
git(repo, ["update-ref", `refs/witness/acceptance-${name}`, commit]); fs.rmSync(idx, { force: true });
|
|
41
41
|
return commit;
|
|
42
42
|
}
|
|
43
|
-
/** The history file the gate keeps for a store (class-a-cache-history.mjs: named after the store's path). */
|
|
44
|
-
export const historyFileOf = (managed, storeDir) => path.join(managed, "runs", "rightkit-class-a-history", `${sha256(path.resolve(storeDir).toLowerCase())}.json`);
|
|
43
|
+
/** The history file the gate keeps for a store (class-a-cache-history.mjs: named after the store's path, lowercased on Windows only). */
|
|
44
|
+
export const historyFileOf = (managed, storeDir) => path.join(managed, "runs", "rightkit-class-a-history", `${sha256(process.platform === "win32" ? path.resolve(storeDir).toLowerCase() : path.resolve(storeDir))}.json`);
|
|
45
45
|
const moveAside = (from, to) => { if (!fs.existsSync(from)) return false; fs.mkdirSync(path.dirname(to), { recursive: true }); fs.renameSync(from, to); return true; };
|
|
46
|
-
/**
|
|
47
|
-
const
|
|
46
|
+
/** Every live process as { pid, ppid, startMs } (Windows), or null when the list cannot be read. */
|
|
47
|
+
const windowsProcesses = () => {
|
|
48
|
+
try {
|
|
49
|
+
const text = execFileSync("powershell", ["-NoProfile", "-NonInteractive", "-Command", "Get-CimInstance Win32_Process | ForEach-Object { '{0} {1} {2}' -f $_.ProcessId, $_.ParentProcessId, $_.CreationDate.ToUniversalTime().ToString('o') }"], { encoding: "utf8", windowsHide: true, stdio: ["ignore", "pipe", "ignore"] });
|
|
50
|
+
return text.split(/\r?\n/).filter(Boolean).map((l) => { const [pid, ppid, t] = l.trim().split(" "); return { pid: Number(pid), ppid: Number(ppid), startMs: Date.parse(t) }; }).filter((p) => Number.isInteger(p.pid) && Number.isInteger(p.ppid) && Number.isFinite(p.startMs));
|
|
51
|
+
} catch { return null; }
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Ends the gate and every program it started. Elsewhere the process group is the launcher's to signal. On Windows `taskkill /T` walks the tree once, so a
|
|
55
|
+
* child the gate starts in the milliseconds of the kill is not in the walk and lives on as an orphan (0.6.92 acceptance, 27 Nov: `cargo tree` started 3 ms
|
|
56
|
+
* before the gate died, case 7 NN08). So the walk is repeated: every live process descended from a process of this tree (by parent pid, started no earlier
|
|
57
|
+
* than the gate, so a reused pid is not taken) is ended, until a walk finds none, bounded at 10 s.
|
|
58
|
+
*/
|
|
59
|
+
export const killTree = (pid) => {
|
|
60
|
+
if (process.platform !== "win32") { try { process.kill(pid, "SIGKILL"); } catch { /* already gone */ } return; }
|
|
61
|
+
const before = windowsProcesses(); const root = before?.find((p) => p.pid === pid) ?? null;
|
|
62
|
+
const since = root ? root.startMs - 1000 : Date.now() - 24 * 3600 * 1000;
|
|
63
|
+
const tree = new Set([pid]);
|
|
64
|
+
// The tree as it stood just before the kill, so an orphan whose parent the kill ended is still known by that parent's pid.
|
|
65
|
+
const grow = (list) => { let grew = true; while (grew) { grew = false; for (const p of list) if (!tree.has(p.pid) && tree.has(p.ppid) && p.startMs >= since) { tree.add(p.pid); grew = true; } } };
|
|
66
|
+
grow(before ?? []);
|
|
67
|
+
try { execFileSync("taskkill", ["/PID", String(pid), "/T", "/F"], { windowsHide: true, stdio: "ignore" }); } catch { /* already gone */ }
|
|
68
|
+
const deadline = Date.now() + 10_000;
|
|
69
|
+
while (Date.now() < deadline) {
|
|
70
|
+
const live = windowsProcesses(); if (!live) return;
|
|
71
|
+
grow(live);
|
|
72
|
+
const left = live.filter((p) => tree.has(p.pid) && p.startMs >= since);
|
|
73
|
+
if (!left.length) return;
|
|
74
|
+
for (const p of left) { try { execFileSync("taskkill", ["/PID", String(p.pid), "/T", "/F"], { windowsHide: true, stdio: "ignore" }); } catch { /* already gone */ } }
|
|
75
|
+
}
|
|
76
|
+
};
|
|
48
77
|
|
|
49
78
|
/**
|
|
50
79
|
* The machine's total CPU load, sampled every two seconds for the whole acceptance run (Adrian, 2026-11-25: "run the 7 cases on a quiet machine with CPU load
|
package/app-check.mjs
CHANGED
|
@@ -34,6 +34,8 @@
|
|
|
34
34
|
// (a per-version or hand-written entry; rightkit#1476)
|
|
35
35
|
// commit-citations G28 (release tier) a commit this push adds that cites no issue, or changes code without a `Contract: <file>#<section>`
|
|
36
36
|
// line (rightkit#1268); no baseline excuses it
|
|
37
|
+
// lint-waiver-added G30 (compile tier) a Rust file holding more lint waivers (allow/expect attributes, cfg_attr waivers, [lints] "allow",
|
|
38
|
+
// lint-disabling rustflags) than at the merge-base with origin/main (first parent for a commit already there); rightkit#1830
|
|
37
39
|
//
|
|
38
40
|
// Suite trust roots (lane C3; logic in suite-trust-roots.mjs). The licence and updater public keys have one owner,
|
|
39
41
|
// contracts/right-suite-api.v1.json (generated into suite-api.generated.mjs):
|
|
@@ -111,6 +113,7 @@ import { OWNERSHIP_CLASS_RULES } from "./ownership-class-rules.mjs";
|
|
|
111
113
|
import { SOURCE_CLOSURE_RULES } from "./source-closure-rules.mjs";
|
|
112
114
|
import { SHELL_CONTRACT_RULES } from "./shell-contract.mjs";
|
|
113
115
|
import { neutralIgnored } from "./stage-ledger.mjs";
|
|
116
|
+
import { waiverKindOf, waiversIn } from "./lint-waivers.mjs";
|
|
114
117
|
import { CONSUMER_SOURCE_RULES } from "./consumer-source-contracts.mjs";
|
|
115
118
|
import { CONSUMER_POLICY_RULES } from "./consumer-policy.mjs";
|
|
116
119
|
import { engineRecordStore, suiteKeyLiteral, suiteUpdaterKey } from "./suite-trust-roots.mjs";
|
|
@@ -130,6 +133,19 @@ function git(args, { cwd, input, env = gitEnv(), encoding = "utf8", maxBuffer =
|
|
|
130
133
|
return r.stdout;
|
|
131
134
|
}
|
|
132
135
|
|
|
136
|
+
// Read-only git lookups that several rules ask with the same words in the same folder (the object type of the checked commit, its merge-base with
|
|
137
|
+
// origin/main) start once per process: the answer, or the error, is remembered. GATE-CONTRACT GC-A27 NN08 refuses a run that starts the same program
|
|
138
|
+
// with the same arguments in the same folder twice (0.6.91 acceptance, 27 Nov: `git merge-base <commit> origin/main` from baselineAtMergeBase and
|
|
139
|
+
// lint-waiver-added's anchor). Only these two lookups are remembered; nothing that writes or depends on the working files is.
|
|
140
|
+
const gitLookups = new Map();
|
|
141
|
+
function gitLookup(args, { cwd }) {
|
|
142
|
+
const key = JSON.stringify([cwd, args]);
|
|
143
|
+
if (!gitLookups.has(key)) { try { gitLookups.set(key, { out: git(args, { cwd }) }); } catch (error) { gitLookups.set(key, { error }); } }
|
|
144
|
+
const hit = gitLookups.get(key);
|
|
145
|
+
if (hit.error) throw hit.error;
|
|
146
|
+
return hit.out;
|
|
147
|
+
}
|
|
148
|
+
|
|
133
149
|
/** The git top-level directory of `dir`, or null when it is not inside a work tree. */
|
|
134
150
|
export function repoRoot(dir) {
|
|
135
151
|
const r = spawnSync("git", ["rev-parse", "--show-toplevel"], { cwd: dir, env: gitEnv(), encoding: "utf8" });
|
|
@@ -1162,11 +1178,11 @@ const NOT_CODE = /(?:\.(?:md|mdx|txt|lock|svg|png|jpe?g|gif|ico|webp|pdf)$|(?:^|
|
|
|
1162
1178
|
/** The non-merge commits this push adds (oldest first), or [] when none are pending or there is no anchor. */
|
|
1163
1179
|
function pendingCommits(repo, commit, env = process.env) {
|
|
1164
1180
|
try {
|
|
1165
|
-
if (
|
|
1181
|
+
if (gitLookup(["cat-file", "-t", commit], { cwd: repo }).trim() !== "commit") return [];
|
|
1166
1182
|
const named = String(env.RK_PUSH_BEFORE ?? "").trim();
|
|
1167
1183
|
let base = null;
|
|
1168
1184
|
if (/^[0-9a-f]{40,64}$/.test(named) && !/^0+$/.test(named)) { try { git(["cat-file", "-e", `${named}^{commit}`], { cwd: repo }); base = named; } catch { base = null; } }
|
|
1169
|
-
base ??=
|
|
1185
|
+
base ??= gitLookup(["merge-base", commit, "origin/main"], { cwd: repo }).trim();
|
|
1170
1186
|
if (!base) return [];
|
|
1171
1187
|
return git(["rev-list", "--no-merges", "--reverse", `${base}..${commit}`], { cwd: repo }).split("\n").filter(Boolean);
|
|
1172
1188
|
} catch { return []; }
|
|
@@ -1332,7 +1348,38 @@ function qaStashIgnored({ root, files }) {
|
|
|
1332
1348
|
return out;
|
|
1333
1349
|
}
|
|
1334
1350
|
|
|
1351
|
+
// G30 (bogusyogi/rightkit#1830, first slice; Adrian 2026-11-27: "Where's The fucking Rk enforcement I clearly asked for"): Rust lint waivers
|
|
1352
|
+
// (lint-waivers.mjs, ported from Legion's check-waivers; self-contained, no gate internals, so it can move to a dedicated lint package). One rule over every tracked .rs, Cargo.toml and .cargo/config(.toml) outside fixture trees:
|
|
1353
|
+
// lint-waiver-added (compile tier) a file holds more waivers than it did at the anchor: the merge-base with origin/main, or, for a commit already on
|
|
1354
|
+
// origin/main, its first parent. No file is stored or approved; a new file counts from zero. Moving a waiver to another file is adding one.
|
|
1355
|
+
// With no anchor (no origin/main, no common history) it fails: it cannot tell what was added.
|
|
1356
|
+
// A release-tier rule refusing any waiver at all follows once each repository reports zero (Neon, 27 Nov: option B; Pulse's Mac qualify is not stopped meanwhile).
|
|
1357
|
+
const waiverFiles = (files) => files.filter((f) => scanned(f) && waiverKindOf(f));
|
|
1358
|
+
function waiverAnchor(repo, commit) {
|
|
1359
|
+
try {
|
|
1360
|
+
const tip = gitLookup(["cat-file", "-t", commit], { cwd: repo }).trim() === "commit" ? commit : git(["rev-parse", "HEAD"], { cwd: repo }).trim();
|
|
1361
|
+
const base = gitLookup(["merge-base", tip, "origin/main"], { cwd: repo }).trim();
|
|
1362
|
+
if (!base) return { anchor: null, why: "git merge-base with origin/main printed nothing" };
|
|
1363
|
+
if (base !== tip) return { anchor: base, how: "the merge-base with origin/main" };
|
|
1364
|
+
try { return { anchor: gitLookup(["rev-parse", tip + "^1"], { cwd: repo }).trim(), how: "its first parent (the commit is already on origin/main)" }; } catch { return { anchor: null, why: "the commit is on origin/main and has no parent" }; }
|
|
1365
|
+
} catch (error) { return { anchor: null, why: String(error.message).split("\n")[0] }; }
|
|
1366
|
+
}
|
|
1367
|
+
function lintWaiversAdded({ root, commit, files, repo }) {
|
|
1368
|
+
const at = waiverAnchor(repo, commit);
|
|
1369
|
+
if (!at.anchor) return [{ subject: "anchor", problem: "cannot tell which lint waivers this commit adds: " + at.why, fix: "fetch origin/main into this repository, then check again" }];
|
|
1370
|
+
const out = [];
|
|
1371
|
+
for (const file of waiverFiles(files)) {
|
|
1372
|
+
const now = waiversIn(readText(root, file) ?? "", waiverKindOf(file));
|
|
1373
|
+
if (!now.length) continue;
|
|
1374
|
+
let before = 0;
|
|
1375
|
+
try { before = waiversIn(git(["cat-file", "blob", at.anchor + ":" + file], { cwd: repo }), waiverKindOf(file)).length; } catch { before = 0; }
|
|
1376
|
+
if (now.length > before) out.push({ file, subject: file, problem: file + " holds " + now.length + " lint waiver(s), " + before + " at " + at.anchor.slice(0, 12) + " (" + at.how + "): " + (now.length - before) + " added (" + now.map((w) => "line " + w.line + ": " + w.reason).join("; ") + ")", fix: "remove the added waiver and fix what the lint points at; existing waivers are cleaned up by the repository's own chat and none may be added meanwhile" });
|
|
1377
|
+
}
|
|
1378
|
+
return out;
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1335
1381
|
export const RULES = Object.freeze([
|
|
1382
|
+
{ id: "lint-waiver-added", gap: "G30", run: lintWaiversAdded },
|
|
1336
1383
|
{ id: "eol-policy", gap: "G04", run: eolPolicy },
|
|
1337
1384
|
{ id: "qa-stash-ignored", gap: "G29", run: qaStashIgnored },
|
|
1338
1385
|
{ id: "file-url", gap: "G12", run: fileUrls },
|
|
@@ -1377,6 +1424,8 @@ export const COMPILE_TIER_IDS = Object.freeze(new Set([
|
|
|
1377
1424
|
"qa-dev-server", "ffmpeg-release-escape", "switches-inventory", "speech-link", "e2e-under-cargo-test",
|
|
1378
1425
|
// rightkit#1221 asks for a compile-tier rule: the primary-checkout rule is Adrian's standing one, and a script that clones is refused before any compile.
|
|
1379
1426
|
"scratch-checkout",
|
|
1427
|
+
// bogusyogi/rightkit#1830: no new lint waiver from the first compile on. It is true in every app on the day it ships (it judges only what a commit adds).
|
|
1428
|
+
"lint-waiver-added",
|
|
1380
1429
|
]));
|
|
1381
1430
|
/** The tier a rule runs from: compile for the 0.6.6 set, release for everything added since. */
|
|
1382
1431
|
export const tierOf = (rule) => (COMPILE_TIER_IDS.has(rule.id) ? "compile" : "release");
|
|
@@ -1540,8 +1589,8 @@ export const BASELINE_GROWTH_RULE = "a baseline entry added since the merge-base
|
|
|
1540
1589
|
*/
|
|
1541
1590
|
export function baselineAtMergeBase(dir, rev, file) {
|
|
1542
1591
|
try {
|
|
1543
|
-
const tip =
|
|
1544
|
-
const anchor =
|
|
1592
|
+
const tip = gitLookup(["cat-file", "-t", rev], { cwd: dir }).trim() === "commit" ? rev : "HEAD";
|
|
1593
|
+
const anchor = gitLookup(["merge-base", tip, "origin/main"], { cwd: dir }).trim();
|
|
1545
1594
|
if (!anchor) return { anchor: null, why: "git merge-base printed nothing" };
|
|
1546
1595
|
let text = null;
|
|
1547
1596
|
try { text = git(["cat-file", "blob", `${anchor}:${file}`], { cwd: dir }); } catch { text = null; }
|
package/bin/rightkit-gate.mjs
CHANGED
|
@@ -125,7 +125,7 @@ import { buildDirectReceipt, directVerdict, resolveTargetDirectory, verifyDirect
|
|
|
125
125
|
import { platformDirOf } from "../platform-dir.mjs";
|
|
126
126
|
import { buildInventory, classifyUnitResults, dependencyFirstOrder, selectAffectedAcrossInventories, classifyUnitRows, unitListReport } from "../affected-units.mjs";
|
|
127
127
|
import { createRequire } from "node:module";
|
|
128
|
-
import { BUILD_CONTROL_PROTOCOL, HANDSHAKE_PROBE_ID, RUNTIME_MANIFEST_FILE, brokerControlTarget, parseRuntimeIdentity } from "../seam-broker.mjs";
|
|
128
|
+
import { BUILD_CONTROL_PROTOCOL, HANDSHAKE_PROBE_ID, RUNTIME_MANIFEST_FILE, brokerControlTarget, parseRuntimeIdentity, runtimeManifestPathOf } from "../seam-broker.mjs";
|
|
129
129
|
import { snapshotReclaimJudge } from "../seam-broker.mjs";
|
|
130
130
|
import net from "node:net";
|
|
131
131
|
import { installSpawnLedger } from "../spawn-ledger.mjs";
|
|
@@ -2479,7 +2479,9 @@ async function runStages(o, args, root, git, io) {
|
|
|
2479
2479
|
else if (packageMulti.note) o.out(`${tag} [package] ${packageMulti.note}`);
|
|
2480
2480
|
}
|
|
2481
2481
|
const packageEnv = packagePin.dir ? { CARGO_TARGET_DIR: packagePin.dir } : (packageMulti?.env ?? {});
|
|
2482
|
-
|
|
2482
|
+
// GC-A28 for the package stage: right-release runs inside the snapshot, whose `.git` stub cannot count commits (assemble-app stamps CFBundleVersion).
|
|
2483
|
+
const packageBuildNumber = ok && ds ? buildNumberOf({ o, git, commit, tag }) : {};
|
|
2484
|
+
ok = ok && await rightRelease(stage, ["build", "--platform", platform], { ...packageEnv, ...packageBuildNumber, ...(doorRegistryAdmissionFile ? { RK_DOOR_REGISTRY_ADMISSION: doorRegistryAdmissionFile } : {}) });
|
|
2483
2485
|
const sealed = ok ? (o.sealedFor ?? sealedFor)({ root: releaseRoot, commit, platform }) : null;
|
|
2484
2486
|
if (ok && !sealed) { o.err(`${tag} [package] the build reported success but sealed nothing for ${commit.slice(0, 8)} on ${platform}`); ok = false; }
|
|
2485
2487
|
if (sealed) extra = { platform, sealed: sealed.id, manifestSha256: sealed.digest };
|
|
@@ -3944,8 +3946,8 @@ export function brokerRuntimeIdentityText({ clients, env = {}, platform = proces
|
|
|
3944
3946
|
if (!exists(candidate)) continue;
|
|
3945
3947
|
let file = candidate;
|
|
3946
3948
|
try { file = resolveBrokerClient(candidate, { platform, readFile }).file; } catch { continue; }
|
|
3947
|
-
|
|
3948
|
-
const identity = parseRuntimeIdentity(readFile(
|
|
3949
|
+
// The POSIX agent shim is followed to the client it starts (seam-broker.mjs runtimeManifestPathOf): on the Mac the manifest was looked for in agent-bin.
|
|
3950
|
+
const identity = parseRuntimeIdentity(readFile(runtimeManifestPathOf(file, { platform, read: readFile, realpath })));
|
|
3949
3951
|
if (identity.ok) return `${identity.identity.version}:${identity.identity.brokerDigest}:${identity.identity.clientDigest}`;
|
|
3950
3952
|
} catch { /* the next candidate */ }
|
|
3951
3953
|
}
|
|
@@ -4164,6 +4166,20 @@ export async function runRenderStage({ o, ds, root, appDir, commit, tree, env, p
|
|
|
4164
4166
|
return 0;
|
|
4165
4167
|
}
|
|
4166
4168
|
|
|
4169
|
+
/**
|
|
4170
|
+
* The build number a snapshot child cannot count itself (docs/GATE-CONTRACT.md [GC-A28]): the snapshot's `.git` is a config-only stub, so
|
|
4171
|
+
* assembled-app.mjs commitCount refuses ASSEMBLY_VERSION_UNAVAILABLE there unless RIGHT_BUILD_NUMBER is handed down. Counted in the checkout for the
|
|
4172
|
+
* selected commit. A shallow history or an unreadable count hands down nothing and says so. Used by the dev/test route and, since rightkit#1754
|
|
4173
|
+
* (Pulse Mac feb5769f, package stage), by the door's package stage.
|
|
4174
|
+
*/
|
|
4175
|
+
function buildNumberOf({ o, git, commit, tag }) {
|
|
4176
|
+
const shallow = git("rev-parse", "--is-shallow-repository");
|
|
4177
|
+
const count = failed(shallow) || text(shallow).trim() === "true" ? null : git("rev-list", "--count", commit);
|
|
4178
|
+
if (count && !failed(count) && /^[1-9][0-9]*$/.test(text(count).trim())) return { RIGHT_BUILD_NUMBER: text(count).trim() };
|
|
4179
|
+
o.out(`${tag} note: no build number for ${commit.slice(0, 12)} (the checkout is shallow or cannot count its history); an app that stamps CFBundleVersion will refuse with ASSEMBLY_VERSION_UNAVAILABLE`);
|
|
4180
|
+
return {};
|
|
4181
|
+
}
|
|
4182
|
+
|
|
4167
4183
|
/**
|
|
4168
4184
|
* rightkit-gate --to dev|test [--commit <rev>] [-- <right-release dev|test arguments>]: the local compiles, on a commit like every other
|
|
4169
4185
|
* stage (docs/GATE-CONTRACT.md "Commit-only build": `--to dev` and `--to test` build a commit; `--worktree` never admits a build). The
|
|
@@ -4228,13 +4244,7 @@ async function runDevTest(o, args, root, git, io, to, appRoot, appDir) {
|
|
|
4228
4244
|
// The snapshot's `.git` is a config-only stub, so right-release cannot count commits there (assembled-app.mjs commitCount, ASSEMBLY_VERSION_UNAVAILABLE): the gate
|
|
4229
4245
|
// counts the commit in the checkout and hands the number down (docs/GATE-CONTRACT.md [GC-A28]). A shallow history or an unreadable count hands down nothing and says
|
|
4230
4246
|
// so; only an app whose build stamps CFBundleVersion needs the number, and right-release refuses there (it cannot count in the stub either).
|
|
4231
|
-
|
|
4232
|
-
if (ds) {
|
|
4233
|
-
const shallow = git("rev-parse", "--is-shallow-repository");
|
|
4234
|
-
const count = failed(shallow) || text(shallow).trim() === "true" ? null : git("rev-list", "--count", commit);
|
|
4235
|
-
if (count && !failed(count) && /^[1-9][0-9]*$/.test(text(count).trim())) buildNumber = { RIGHT_BUILD_NUMBER: text(count).trim() };
|
|
4236
|
-
else o.out(`${tag} note: no build number for ${commit.slice(0, 12)} (the checkout is shallow or cannot count its history); an app that stamps CFBundleVersion will refuse with ASSEMBLY_VERSION_UNAVAILABLE`);
|
|
4237
|
-
}
|
|
4247
|
+
const buildNumber = ds ? buildNumberOf({ o, git, commit, tag }) : {};
|
|
4238
4248
|
// GB-58 (GATE dev/test exact stage; E19): the selected app's declared sidecars are staged ONCE under this snapshot's ownership before the dependent
|
|
4239
4249
|
// build, through the same planner and ledger as the compile and package stages (a Tauri crate with externalBin refuses to build without them). The
|
|
4240
4250
|
// app's own prepare step may stage them too; the ledger's attribution check, not an environment marker, is what keeps that single and exact.
|
|
@@ -4457,7 +4467,7 @@ export async function main(argv, io = {}) {
|
|
|
4457
4467
|
// flags below because everything after `clippy` is cargo's own argv, verbatim (`-v`, `-h` and `--version` are cargo's).
|
|
4458
4468
|
// `candidate-receipt` (GB-73): the candidate build receipt the RustRight installer takes in place of a clean primary checkout.
|
|
4459
4469
|
if (args[0] === "candidate-receipt") return (await import("../candidate-receipt-command.mjs")).candidateReceiptCommand(o, args.slice(1));
|
|
4460
|
-
if (args[0] === "clippy") return (await import("../clippy-route.mjs")).clippyCommand(o, args.slice(1), { main, io, absoluteEnv: SNAPSHOT_ABSOLUTE_ENV });
|
|
4470
|
+
if (args[0] === "clippy") return (await import("../clippy-route.mjs")).clippyCommand(o, args.slice(1), { main, io, absoluteEnv: SNAPSHOT_ABSOLUTE_ENV, seamLockFor });
|
|
4461
4471
|
if (args.includes("--version") || args.includes("-v")) {
|
|
4462
4472
|
o.out(JSON.parse(fs.readFileSync(new URL("../package.json", import.meta.url), "utf8")).version);
|
|
4463
4473
|
return 0;
|
package/clippy-route.mjs
CHANGED
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
// from a snapshot. The request is never rewritten to leave such a package out (signed D8-1: three additions only).
|
|
17
17
|
// Linux direct, through the item 7 cargo wrapper (cargo-target-shim.mjs): every cargo launch is bound to the checkout's own
|
|
18
18
|
// target directory or refused, so nothing is written under the snapshot (row 8.12).
|
|
19
|
-
// Mac and Dell the
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
// `routeFromBrokerReceipt` below
|
|
19
|
+
// Mac and Dell through the seam (rightkit#1811): `rustright cargo clippy ...` from the snapshot with RUSTRIGHT_GATE_COMMIT and RUSTRIGHT_CLASS_A naming
|
|
20
|
+
// this run's class A verdict, as the door's class B clippy rows run. The broker pins the output directory and adds --keep-going
|
|
21
|
+
// itself, so the gate adds neither there; non-compiling reads use the real toolchain cargo (GC-A11). Never direct cargo for the
|
|
22
|
+
// compile. `routeFromBrokerReceipt` below (the signed attribution detail) is not wired yet: results come from cargo's JSON stream.
|
|
23
23
|
// result FAILED when any unit failed; diagnostics by package and target from cargo's JSON messages; a unit that never ran
|
|
24
24
|
// because a dependency failed is reported blocked and the result claims no completeness (row 8.4).
|
|
25
25
|
// exit 0 PASSED, 1 FAILED or BLOCKED, 2 refused or could not run (RK_CHECK_ERROR: the snapshot moved).
|
|
@@ -32,6 +32,9 @@ import { directPlatform, realCargoOf } from "./managed-cargo.mjs";
|
|
|
32
32
|
import { defaultSpawnAsync, sidecarBoundCrate } from "./deterministic-scans.mjs";
|
|
33
33
|
import { gateStateDir } from "./gate-stages.mjs";
|
|
34
34
|
import { ProvenanceError } from "./receipt-signature.mjs";
|
|
35
|
+
import { resolveBrokerClient as defaultResolveBrokerClient } from "./broker-client.mjs";
|
|
36
|
+
import { directCargoPath } from "./managed-cargo.mjs";
|
|
37
|
+
import { seamEnv, verdictForRun } from "./gate-seam.mjs";
|
|
35
38
|
|
|
36
39
|
export const ROUTE_RECEIPT_SCHEMA = "rightkit.gate-clippy-route-receipt/1";
|
|
37
40
|
export const ROUTE_DIAGNOSTICS_SCHEMA = "rightkit.gate-clippy-route-diagnostics/1";
|
|
@@ -40,7 +43,7 @@ export const CLIPPY_USAGE = "usage: rightkit-gate clippy [<cargo clippy args>]
|
|
|
40
43
|
export const ROUTE_CODES = Object.freeze({
|
|
41
44
|
notClippy: "RK_CLIPPY_NOT_CLIPPY", messageFormat: "RK_CLIPPY_MESSAGE_FORMAT", targetDir: "RK_CLIPPY_TARGET_DIR", config: "RK_CLIPPY_CONFIG", toolchain: "RK_CLIPPY_TOOLCHAIN_OVERRIDE",
|
|
42
45
|
fix: "RK_CLIPPY_FIX", unstable: "RK_CLIPPY_UNSTABLE", chdir: "RK_CLIPPY_CHDIR", manifestAbsolute: "RK_CLIPPY_MANIFEST_ABSOLUTE", manifestEscapes: "RK_CLIPPY_MANIFEST_ESCAPES",
|
|
43
|
-
outputInSnapshot: "RK_CLIPPY_OUTPUT_IN_SNAPSHOT",
|
|
46
|
+
outputInSnapshot: "RK_CLIPPY_OUTPUT_IN_SNAPSHOT", brokerUnavailable: "RK_CLIPPY_BROKER_UNAVAILABLE", hostUnsupported: "RK_CLIPPY_HOST_UNSUPPORTED",
|
|
44
47
|
sidecarBound: "RK_CLIPPY_SIDECAR_BOUND", receiptEvidence: "RK_CLIPPY_RECEIPT_EVIDENCE", toolchainUnreadable: "RK_CLIPPY_TOOLCHAIN_UNREADABLE",
|
|
45
48
|
});
|
|
46
49
|
|
|
@@ -316,7 +319,7 @@ export function summarizeRun({ messages, stderr = "", exit = null, signal = null
|
|
|
316
319
|
* this receipt's, it is available and not truncated, every row is well formed and the compact counts equal the rows. Counts alone never pass (`units: 2` with exit 0
|
|
317
320
|
* and no matching detail is FAILED). Missing or unverifiable evidence makes the route result FAILED, never a partial success:
|
|
318
321
|
* `{ aggregate, code, units, failedUnits, problems, toolchain, complete }`. A unit with errors, or a nonzero exit, is a failure.
|
|
319
|
-
*
|
|
322
|
+
* Not wired yet: on a broker host the route's per-unit results come from cargo's own JSON stream (rightkit#1811), not from this signed detail.
|
|
320
323
|
*/
|
|
321
324
|
export function routeFromBrokerReceipt(receipt, detailBytes = null) {
|
|
322
325
|
const problems = [];
|
|
@@ -395,12 +398,22 @@ export async function clippyCommand(o, args, deps = {}) {
|
|
|
395
398
|
resultLine(o, tag, { result: "BLOCKED", code: ROUTE_CODES.brokerUnavailable, launched: false });
|
|
396
399
|
return BLOCKED;
|
|
397
400
|
}
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
401
|
+
// Mac and Dell (rightkit#1811): the Clippy request is carried by the broker through the seam, as the door's class B clippy rows are
|
|
402
|
+
// (`rustright cargo clippy ...` from the snapshot with RUSTRIGHT_GATE_COMMIT and RUSTRIGHT_CLASS_A naming this run's class A verdict). The broker pins the
|
|
403
|
+
// output directory, adds --keep-going itself (BR29) and keeps everything from `--` on verbatim. Non-compiling reads (locate-project, metadata, -vV) use the
|
|
404
|
+
// real toolchain cargo (GC-A11). The client and that cargo are resolved here, before the lock: a host missing either runs nothing.
|
|
405
|
+
const brokerHost = executor.kind === "broker";
|
|
406
|
+
let brokerClient = null; let readCargo = "cargo"; let readRustc = "rustc";
|
|
407
|
+
if (brokerHost) {
|
|
408
|
+
const found = executor.route && executor.client ? executor.client : which("rustright").find((c) => path.isAbsolute(c));
|
|
409
|
+
try { brokerClient = found ? (deps.resolveBrokerClient ?? defaultResolveBrokerClient)(found, { platform: o.platform }).file : null; } catch (e) { brokerClient = null; o.err(`${tag} ${e.message}`); }
|
|
410
|
+
if (!brokerClient) { o.err(`${tag} BLOCKED: ${ROUTE_CODES.brokerUnavailable}: no RustRight client by absolute path on this broker host; nothing ran`); resultLine(o, tag, { result: "BLOCKED", code: ROUTE_CODES.brokerUnavailable, launched: false }); return BLOCKED; }
|
|
411
|
+
const direct = (deps.directCargo ?? directToolchainCargo)(o);
|
|
412
|
+
if (!direct) { o.err(`${tag} BLOCKED: no real toolchain cargo for the non-compiling reads on this broker host (GC-A11); nothing ran`); return BLOCKED; }
|
|
413
|
+
readCargo = direct;
|
|
414
|
+
readRustc = path.join(path.dirname(direct), o.platform === "win32" ? "rustc.exe" : "rustc");
|
|
415
|
+
o.out(`${tag} broker host: Clippy is carried by the broker through the seam (client ${brokerClient}); non-compiling reads use ${readCargo}`);
|
|
416
|
+
} else if (!directPlatform(o.platform) || o.env.GITHUB_ACTIONS === "true") {
|
|
404
417
|
o.err(`${tag} BLOCKED: ${ROUTE_CODES.hostUnsupported}: the route builds a gate-owned commit snapshot on a Linux execution host; hosted CI runs Clippy through its own workflow; nothing ran`);
|
|
405
418
|
return BLOCKED;
|
|
406
419
|
}
|
|
@@ -437,7 +450,7 @@ export async function clippyCommand(o, args, deps = {}) {
|
|
|
437
450
|
const commitDeclaresSidecars = confDirs.some((d) => d === "" || sidecarBoundCrate({ dir: d, exists: commitExists, readFile: commitRead }).bound);
|
|
438
451
|
let preBound = [];
|
|
439
452
|
if (commitDeclaresSidecars) {
|
|
440
|
-
const preMeta = o.spawn(
|
|
453
|
+
const preMeta = o.spawn(readCargo, ["metadata", "--no-deps", "--offline", "--locked", "--format-version", "1", ...(parsed.manifestPath ? ["--manifest-path", parsed.manifestPath] : [])], { cwd: cwdReal, env: o.env });
|
|
441
454
|
let preScope = null;
|
|
442
455
|
try { if (!failed(preMeta)) preScope = resolveScope({ before: parsed.before, metadata: JSON.parse(text(preMeta)), directory: parsed.manifestPath ? path.dirname(path.resolve(cwdReal, parsed.manifestPath)) : cwdReal }); } catch { preScope = null; }
|
|
443
456
|
preBound = sidecarBoundMembers({ scope: preScope, dirOf: (p) => posix(path.relative(root, path.dirname(p.manifest_path))) || ".", exists: commitExists, readFile: commitRead });
|
|
@@ -445,15 +458,22 @@ export async function clippyCommand(o, args, deps = {}) {
|
|
|
445
458
|
if (preBound.length) { o.err(sidecarRefusal(tag, preBound, "read from the commit")); resultLine(o, tag, { result: "BLOCKED", code: ROUTE_CODES.sidecarBound, blockedOn: ["item7:7.05"], bound: preBound, launched: false }); return BLOCKED; }
|
|
446
459
|
|
|
447
460
|
const timings = {}; const lap = (name, since) => { timings[name] = Date.now() - since; };
|
|
448
|
-
// The snapshot lock first (E6, reset plan section 3): held from before the sync until the diagnostics are written.
|
|
461
|
+
// The snapshot lock first (E6, reset plan section 3): held from before the sync until the diagnostics are written. The same lock on every host (the door's own snapshot routes take it too), so it is
|
|
449
462
|
// the legacy lock, reclaimed when its holder is proven gone. A busy repository runs nothing and syncs nothing.
|
|
450
463
|
let lock;
|
|
451
|
-
|
|
464
|
+
// A broker host's lock carries the seam body (this process's identity and the commit) the broker reads before it carries a request, and a dead holder's lock is
|
|
465
|
+
// reclaimed only on the broker's proof (rightkit-gate.mjs seamLockFor, the same lock the door takes). No body on a broker host: nothing runs.
|
|
466
|
+
let seamLock = { lock: {}, body: null };
|
|
467
|
+
if (brokerHost) {
|
|
468
|
+
seamLock = deps.seamLockFor ? deps.seamLockFor({ o, root, snapshotsAt, commit: selected.commit, snap, tag }) : { refusal: `${tag} BLOCKED: RK_SEAM: the gate gave the route no seam lock; nothing ran` };
|
|
469
|
+
if (seamLock.refusal) { o.err(seamLock.refusal); return BLOCKED; }
|
|
470
|
+
}
|
|
471
|
+
try { lock = (deps.takeSnapshotLock ?? snap.takeSnapshotLock)({ checkout: root, root: snapshotsAt, ...(brokerHost ? { lock: seamLock.lock } : {}) }); }
|
|
452
472
|
catch (e) { if (e.code !== "busy" && e.code !== "refused") throw e; o.err(`${tag} BLOCKED: ${e.message}; ${e.code === "refused" ? "nothing ran, nothing created" : "the route never re-syncs a snapshot another request holds; nothing ran"}`); return BLOCKED; }
|
|
453
473
|
o.out(`${tag} snapshot lock held ${lock.token}${lock.reclaimed ? ` (reclaimed from ${lock.reclaimed.from}: ${lock.reclaimed.proof})` : ""}`);
|
|
454
474
|
const lockView = snap.lockView(lock);
|
|
455
475
|
const abort = o.abort ?? new AbortController();
|
|
456
|
-
let shimDir = null; let messagesFile = null;
|
|
476
|
+
let shimDir = null; let messagesFile = null; let carriedSettled = true;
|
|
457
477
|
const stopped = []; const onSignal = (sig) => () => { stopped.push(sig); abort.abort(); };
|
|
458
478
|
const handlers = o.abort ? [] : [["SIGINT", onSignal("SIGINT")], ["SIGTERM", onSignal("SIGTERM")]];
|
|
459
479
|
for (const [sig, h] of handlers) process.on(sig, h);
|
|
@@ -480,39 +500,43 @@ export async function clippyCommand(o, args, deps = {}) {
|
|
|
480
500
|
// The snapshot's working directory for the request, and the Cargo workspace it names, resolved from the commit's own manifests.
|
|
481
501
|
const snapCwd = relCwd ? path.join(synced.path, ...relCwd.split("/")) : synced.path;
|
|
482
502
|
if (!fs.existsSync(snapCwd)) { o.err(`${tag} BLOCKED: the working directory ${relCwd} is not in commit ${synced.commit.slice(0, 12)}; run from a directory the commit holds; nothing compiled`); return BLOCKED; }
|
|
483
|
-
const realCargo = realCargoOf(which("cargo"));
|
|
484
|
-
if (!realCargo) { o.err(`${tag} BLOCKED: no cargo on PATH to wrap for the snapshot compile; nothing compiled`); return BLOCKED; }
|
|
485
|
-
const located = o.spawn(
|
|
503
|
+
const realCargo = brokerHost ? null : realCargoOf(which("cargo"));
|
|
504
|
+
if (!brokerHost && !realCargo) { o.err(`${tag} BLOCKED: no cargo on PATH to wrap for the snapshot compile; nothing compiled`); return BLOCKED; }
|
|
505
|
+
const located = o.spawn(readCargo, ["locate-project", "--workspace", "--message-format", "plain", ...(parsed.manifestPath ? ["--manifest-path", parsed.manifestPath] : [])], { cwd: snapCwd, env: o.env });
|
|
486
506
|
if (failed(located) || !path.isAbsolute(text(located).trim())) { o.err(`${tag} BLOCKED: the request's Cargo workspace cannot be resolved in the snapshot (${why(located) || "no manifest"}); nothing compiled`); return BLOCKED; }
|
|
487
507
|
const workspaceDir = fs.realpathSync.native(path.dirname(text(located).trim()));
|
|
488
508
|
if (!inside(workspaceDir, realSnapshot)) { o.err(`${tag} BLOCKED: the Cargo workspace ${workspaceDir} is outside the snapshot; nothing compiled`); return BLOCKED; }
|
|
489
509
|
const cargoDir = posix(path.relative(realSnapshot, workspaceDir)) || ".";
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
510
|
+
// Direct (Linux) host: the checkout's output directory and the item 7 cargo wrapper. A broker host has neither: the broker pins its outputs.
|
|
511
|
+
let outputDir = null; let shim = null; let scanEnv = o.env;
|
|
512
|
+
if (!brokerHost) {
|
|
513
|
+
const checkoutManifest = path.join(root, ...(cargoDir === "." ? [] : cargoDir.split("/")), "Cargo.toml");
|
|
514
|
+
if (!(o.exists ?? fs.existsSync)(checkoutManifest)) { o.err(`${tag} BLOCKED: the checkout has no ${posix(path.relative(root, checkoutManifest))}, so the output directory of workspace ${cargoDir} cannot be resolved; nothing compiled`); return BLOCKED; }
|
|
515
|
+
// The same resolution the door's snapshot compile makes (bin/rightkit-gate.mjs, "output directory for workspace").
|
|
516
|
+
const metaOut = o.spawn("cargo", ["metadata", "--offline", "--format-version", "1", "--no-deps", "--manifest-path", checkoutManifest], { cwd: path.dirname(checkoutManifest), env: o.env });
|
|
517
|
+
outputDir = null;
|
|
518
|
+
try { outputDir = failed(metaOut) ? null : JSON.parse(text(metaOut)).target_directory; } catch { outputDir = null; }
|
|
519
|
+
if (typeof outputDir !== "string" || !path.isAbsolute(outputDir)) { o.err(`${tag} BLOCKED: cargo metadata in the checkout reported no absolute target_directory for ${cargoDir}${failed(metaOut) ? ` (${why(metaOut)})` : ""}; nothing compiled`); return BLOCKED; }
|
|
520
|
+
outputDir = path.resolve(outputDir);
|
|
521
|
+
if (inside(outputDir, realSnapshot)) { o.err(`${tag} ${ROUTE_CODES.outputInSnapshot}: the resolved output directory ${outputDir} is inside the snapshot; nothing compiled`); return REFUSED_EXIT; }
|
|
522
|
+
o.out(`${tag} output directory for workspace ${cargoDir}: ${outputDir} (the checkout's)`);
|
|
523
|
+
|
|
524
|
+
// The item 7 cargo wrapper binds every cargo launch to that directory or refuses it.
|
|
525
|
+
const shimApi = deps.shim ?? await import("./cargo-target-shim.mjs");
|
|
526
|
+
|
|
527
|
+
try { shim = shimApi.installCargoShim({ base: os.tmpdir(), snapshotRoot: synced.path, targetDirs: { [cargoDir]: outputDir }, realCargo, platform: o.platform, onDir: (dir) => { shimDir = dir; } }); }
|
|
528
|
+
catch (e) { o.err(`${tag} BLOCKED: the runtime cargo wrapper cannot be installed (${e.message}); nothing compiled`); return BLOCKED; }
|
|
529
|
+
scanEnv = shimApi.shimScanEnv(o.env, shim);
|
|
530
|
+
o.out(`${tag} runtime cargo wrapper ${shim.shim} (identity ${shim.identity.slice(0, 16)}) -> ${realCargo}`);
|
|
531
|
+
}
|
|
508
532
|
|
|
509
533
|
// The toolchain identity this run compiled with (BROKER-CONTRACT B5: the same engine and toolchain for batch and per-crate runs).
|
|
510
|
-
const toolchain = toolchainIdentity({ spawn: o.spawn, env: o.env, cwd: snapCwd });
|
|
534
|
+
const toolchain = toolchainIdentity({ spawn: o.spawn, env: o.env, cwd: snapCwd, cargo: readCargo, rustc: readRustc });
|
|
511
535
|
if (!toolchain) { o.err(`${tag} BLOCKED: ${ROUTE_CODES.toolchainUnreadable}: \`cargo -vV\` or \`rustc -vV\` printed nothing the gate can read; nothing compiled`); return BLOCKED; }
|
|
512
536
|
|
|
513
537
|
// The requested package set (blocked-unit detection and the sidecar re-check), read from the snapshot's own metadata.
|
|
514
538
|
let scope = null;
|
|
515
|
-
const metaScope = o.spawn(shim.shim, ["metadata", "--no-deps", "--format-version", "1", "--locked", ...(parsed.manifestPath ? ["--manifest-path", parsed.manifestPath] : [])], { cwd: snapCwd, env: scanEnv });
|
|
539
|
+
const metaScope = o.spawn(brokerHost ? readCargo : shim.shim, ["metadata", "--no-deps", "--format-version", "1", "--locked", ...(parsed.manifestPath ? ["--manifest-path", parsed.manifestPath] : [])], { cwd: snapCwd, env: scanEnv });
|
|
516
540
|
try { if (!failed(metaScope)) scope = resolveScope({ before: parsed.before, metadata: JSON.parse(text(metaScope)), directory: parsed.manifestPath ? path.dirname(path.resolve(snapCwd, parsed.manifestPath)) : snapCwd }); } catch { scope = null; }
|
|
517
541
|
|
|
518
542
|
// Sidecar-bound scope (row 8.8): refused before the sync above; this re-check on the snapshot's own metadata is the backstop.
|
|
@@ -520,6 +544,32 @@ export async function clippyCommand(o, args, deps = {}) {
|
|
|
520
544
|
if (bound.length) { o.err(sidecarRefusal(tag, bound, "found in the snapshot, after the checkout's own metadata showed none")); resultLine(o, tag, { result: "BLOCKED", code: ROUTE_CODES.sidecarBound, blockedOn: ["item7:7.05"], bound, launched: false }); return BLOCKED; }
|
|
521
545
|
const invocations = [];
|
|
522
546
|
|
|
547
|
+
// Broker host: the seam. This run's class A wrote the full verdict for the synced commit; the request names it (gate-seam.mjs verdictForRun). The
|
|
548
|
+
// snapshot's state file binds the repository key; a state that names another commit or tree runs nothing.
|
|
549
|
+
let brokerSeam = null;
|
|
550
|
+
if (brokerHost) {
|
|
551
|
+
try {
|
|
552
|
+
const state = JSON.parse(fs.readFileSync(`${path.resolve(synced.path)}.state.json`, "utf8"));
|
|
553
|
+
if (state?.commit !== synced.commit || state?.tree !== synced.tree || typeof state?.repoKey !== "string") throw new Error(`${synced.path}.state.json does not describe commit ${synced.commit} tree ${synced.tree}`);
|
|
554
|
+
const verdictDir = path.join(path.dirname(path.resolve(snapshotsAt)), "class-a-verdicts");
|
|
555
|
+
// The workspace the broker admits the request under is the client's: the directory of --manifest-path when the request names one, else the working
|
|
556
|
+
// directory (rustright-cli shims.rs normalized_invocation). The verdict must name that same snapshot-relative directory, or the broker refuses it
|
|
557
|
+
// RK_CLASS_A_INVALID "workspace ... differs from admission" (Dell replay 27 Nov: a member crate of the root Cargo workspace named by its manifest path).
|
|
558
|
+
const admittedDir = parsed.manifestPath !== null ? path.dirname(path.resolve(snapCwd, parsed.manifestPath)) : snapCwd;
|
|
559
|
+
const admitted = posix(path.relative(realSnapshot, fs.realpathSync.native(admittedDir))) || ".";
|
|
560
|
+
const verdict = (deps.verdictForRun ?? verdictForRun)({ seam: { commit: synced.commit, tree: synced.tree, repoKey: state.repoKey, verdictDir, scope: null }, workspace: admitted });
|
|
561
|
+
brokerSeam = { verdict, env: seamEnv({ commit: synced.commit, classA: verdict }) };
|
|
562
|
+
} catch (e) { o.err(`${tag} BLOCKED: RK_SEAM: ${e.message}; nothing compiled`); resultLine(o, tag, { result: "BLOCKED", code: "RK_SEAM", launched: false }); return BLOCKED; }
|
|
563
|
+
o.out(`${tag} seam: class A verdict ${brokerSeam.verdict}`);
|
|
564
|
+
}
|
|
565
|
+
// The broker adds --keep-going itself (rustright-policy cargo_argv.rs BR29), so on a broker host the gate does not add it.
|
|
566
|
+
const finalArgv = brokerHost && !parsed.already.includes("--keep-going") ? parsed.final.filter((arg) => arg !== "--keep-going") : parsed.final;
|
|
567
|
+
const transformations = brokerHost ? parsed.transformations.filter((t) => t.arg !== "--keep-going") : parsed.transformations;
|
|
568
|
+
const launchCommand = brokerHost ? brokerClient : shim.shim;
|
|
569
|
+
const launchArgs = brokerHost ? ["cargo", "clippy", ...finalArgv] : ["clippy", ...finalArgv];
|
|
570
|
+
const launchEnv = brokerHost ? { ...o.env, ...brokerSeam.env } : scanEnv;
|
|
571
|
+
if (brokerHost) carriedSettled = false; // from here a broker job may exist until the client reports its exit
|
|
572
|
+
|
|
523
573
|
t = Date.now();
|
|
524
574
|
let run = { messages: [], stderr: "", exit: null, signal: null, startError: null };
|
|
525
575
|
const stateDir = path.join(gateStateDir(commonDirOf(o, root)), "clippy-route");
|
|
@@ -527,13 +577,17 @@ export async function clippyCommand(o, args, deps = {}) {
|
|
|
527
577
|
const requestId = crypto.randomUUID();
|
|
528
578
|
messagesFile = path.join(stateDir, `${requestId}.messages.jsonl`);
|
|
529
579
|
{
|
|
530
|
-
const r = await (deps.runCargo ?? defaultSpawnAsync)(
|
|
531
|
-
invocations.push({ role: "requested", argv: ["clippy", ...
|
|
580
|
+
const r = await (deps.runCargo ?? defaultSpawnAsync)(launchCommand, launchArgs, { cwd: snapCwd, env: launchEnv, signal: abort.signal, stdoutFile: messagesFile });
|
|
581
|
+
invocations.push({ role: "requested", argv: ["clippy", ...finalArgv], exit: r.status ?? null });
|
|
532
582
|
let body = "";
|
|
533
583
|
try { body = fs.readFileSync(messagesFile, "utf8"); } catch { body = String(r.stdout ?? ""); }
|
|
534
584
|
run = { messages: parseCargoMessages(body).messages, stderr: String(r.stderr ?? ""), exit: r.status ?? null, signal: stopped[0] ?? null, startError: r.error && !r.cancelled ? r.error.message : null };
|
|
535
585
|
}
|
|
536
586
|
lap("cargo", t);
|
|
587
|
+
// A broker refusal arrives on the client's stderr (`rustright-result {"code":...}`) with no cargo messages: show it, or the result reads as an empty build.
|
|
588
|
+
if (brokerHost && run.exit !== 0 && run.stderr) for (const l of run.stderr.trimEnd().split(/\r?\n/).slice(-6)) o.err(`${tag} broker: ${l}`);
|
|
589
|
+
// The carried request settled when the client returned an exit status of its own (not killed, not failed to start).
|
|
590
|
+
if (brokerHost) carriedSettled = run.exit !== null && !run.startError && !stopped.length;
|
|
537
591
|
if (stopped.length) { fs.rmSync(messagesFile, { force: true }); o.err(`${tag} stopped by ${stopped[0]}; no result`); return stopped[0] === "SIGINT" ? 130 : 143; }
|
|
538
592
|
|
|
539
593
|
// The result covers the commit only if the snapshot is still its tree after cargo exits (E6): otherwise the diagnostics are discarded.
|
|
@@ -551,14 +605,15 @@ export async function clippyCommand(o, args, deps = {}) {
|
|
|
551
605
|
fs.rmSync(messagesFile, { force: true });
|
|
552
606
|
lap("diagnostics", t);
|
|
553
607
|
const receipt = {
|
|
554
|
-
schema: ROUTE_RECEIPT_SCHEMA, requestId, executor: "direct", issuedAt: new Date().toISOString(),
|
|
608
|
+
schema: ROUTE_RECEIPT_SCHEMA, requestId, executor: brokerHost ? "broker" : "direct", issuedAt: new Date().toISOString(),
|
|
555
609
|
commit: { sha: synced.commit, tree: synced.tree },
|
|
556
610
|
snapshot: { path: synced.path, treeAtStart, treeAtExit },
|
|
557
611
|
snapshotLock: { token: lock.token },
|
|
558
|
-
outputDir, outputDirs: { [cargoDir]: outputDir },
|
|
559
|
-
cargoWrapper: { identity: shim.identity, workspaces: shim.workspaces },
|
|
612
|
+
outputDir, outputDirs: brokerHost ? null : { [cargoDir]: outputDir },
|
|
613
|
+
cargoWrapper: brokerHost ? null : { identity: shim.identity, workspaces: shim.workspaces },
|
|
614
|
+
broker: brokerHost ? { client: brokerClient, classAVerdict: brokerSeam.verdict, outputs: "pinned by the broker" } : null,
|
|
560
615
|
toolchain,
|
|
561
|
-
argv: { request: parsed.request, final:
|
|
616
|
+
argv: { request: parsed.request, final: finalArgv, transformations, already: parsed.already },
|
|
562
617
|
invocations,
|
|
563
618
|
exit: { status: run.exit, signal: run.signal }, diagnosticsPath, timingsMs: timings,
|
|
564
619
|
result: { aggregate: summary.aggregate, complete: summary.complete, completeness: summary.completeness, units: summary.units, blocked: summary.blocked, failedPackages: summary.failedPackages },
|
|
@@ -571,20 +626,31 @@ export async function clippyCommand(o, args, deps = {}) {
|
|
|
571
626
|
} finally {
|
|
572
627
|
for (const [sig, h] of handlers) process.off(sig, h);
|
|
573
628
|
if (shimDir) fs.rmSync(shimDir, { recursive: true, force: true });
|
|
574
|
-
//
|
|
575
|
-
|
|
629
|
+
// Released on positive evidence: always on a direct host; on a broker host only when the carried request settled or never started, else kept for the broker's
|
|
630
|
+
// stale-owner proof (as the door's releaseSeamLock does).
|
|
631
|
+
if (carriedSettled) lock();
|
|
632
|
+
else o.err(`${tag} note: the snapshot lock ${lock.token} is kept: the carried Clippy request did not settle, so a broker job may still be finishing; the lock is reclaimed on the broker's proof`);
|
|
576
633
|
}
|
|
577
634
|
}
|
|
578
635
|
|
|
636
|
+
/** The real toolchain cargo for a broker host's non-compiling reads (GC-A11): the broker's registered toolchain first, else PATH without the RustRight shims; null when none. */
|
|
637
|
+
function directToolchainCargo(o) {
|
|
638
|
+
const pk = o.platform === "win32" ? (Object.keys(o.env).find((k) => k.toUpperCase() === "PATH") ?? "Path") : "PATH";
|
|
639
|
+
const d = directCargoPath({ env: { ...o.env, PATH: o.env[pk] }, exists: o.exists ?? fs.existsSync, platform: o.platform, gateWrappers: true });
|
|
640
|
+
const name = o.platform === "win32" ? "cargo.exe" : "cargo";
|
|
641
|
+
for (const dir of String(d.path ?? "").split(o.platform === "win32" ? ";" : ":").filter(Boolean)) { const c = path.join(dir, name); if ((o.exists ?? fs.existsSync)(c)) return c; }
|
|
642
|
+
return null;
|
|
643
|
+
}
|
|
644
|
+
|
|
579
645
|
function commonDirOf(o, root) {
|
|
580
646
|
const r = o.spawn("git", ["rev-parse", "--path-format=absolute", "--git-common-dir"], { cwd: root });
|
|
581
647
|
return failed(r) ? path.join(root, ".git") : text(r).trim();
|
|
582
648
|
}
|
|
583
649
|
|
|
584
650
|
/** The toolchain identity in the broker's shape (`name|cargo:<sha256>|rustc:<sha256>`, over `-vV`), or null when unreadable. */
|
|
585
|
-
export function toolchainIdentity({ spawn, env, cwd }) {
|
|
586
|
-
const cargo = spawn(
|
|
587
|
-
const rustc = spawn(
|
|
651
|
+
export function toolchainIdentity({ spawn, env, cwd, cargo: cargoBin = "cargo", rustc: rustcBin = "rustc" }) {
|
|
652
|
+
const cargo = spawn(cargoBin, ["-vV"], { cwd, env });
|
|
653
|
+
const rustc = spawn(rustcBin, ["-vV"], { cwd, env });
|
|
588
654
|
if (failed(cargo) || failed(rustc) || !text(cargo).trim() || !text(rustc).trim()) return null;
|
|
589
655
|
return `${env?.RUSTUP_TOOLCHAIN ?? "direct"}|cargo:${sha256(text(cargo).trim())}|rustc:${sha256(text(rustc).trim())}`;
|
|
590
656
|
}
|
package/gate/compile.mjs
CHANGED
|
@@ -11,6 +11,7 @@ import { fileStore, resultsByCrate, runCalls } from "./run-calls.mjs";
|
|
|
11
11
|
import { runTests } from "./tests.mjs";
|
|
12
12
|
import { CROSS_TARGETS, hostTarget } from "../cross-targets.mjs";
|
|
13
13
|
import { resolveBrokerClient } from "../broker-client.mjs";
|
|
14
|
+
import { runtimeManifestPathOf } from "../seam-broker.mjs";
|
|
14
15
|
import { runSeamCargoCall } from "../seam-broker.mjs";
|
|
15
16
|
import { codeClosure } from "../code-closure.mjs";
|
|
16
17
|
|
|
@@ -42,11 +43,11 @@ export function gateCodeFiles(dir = HERE, { readFile = (f) => fs.readFileSync(f,
|
|
|
42
43
|
* The broker is named by its exact build (`brokerDigest` of the runtime manifest beside the client), never by a version label, which two builds
|
|
43
44
|
* can share. `brokerKnown` is false when that digest cannot be read; then nothing is remembered and nothing remembered is reused.
|
|
44
45
|
*/
|
|
45
|
-
export function gateIdentity({ commit, snapshot, platform, client, readFile = (f) => fs.readFileSync(f, "utf8") }) {
|
|
46
|
+
export function gateIdentity({ commit, snapshot, platform, client, readFile = (f) => fs.readFileSync(f, "utf8"), realpath = fs.realpathSync.native }) {
|
|
46
47
|
let toolchain = "unpinned";
|
|
47
48
|
for (const file of ["rust-toolchain.toml", "rust-toolchain"]) { try { toolchain = crypto.createHash("sha256").update(readFile(path.join(snapshot, file))).digest("hex").slice(0, 16); break; } catch { /* next */ } }
|
|
48
49
|
let broker = "none";
|
|
49
|
-
if (client) { try { const m = JSON.parse(readFile(
|
|
50
|
+
if (client) { try { const m = JSON.parse(readFile(runtimeManifestPathOf(client, { platform, read: readFile, realpath }))); broker = typeof m.brokerDigest === "string" && /^[0-9a-f]{64}$/.test(m.brokerDigest) ? m.brokerDigest : "unknown"; } catch { broker = "unknown"; } }
|
|
50
51
|
const code = crypto.createHash("sha256");
|
|
51
52
|
for (const f of gateCodeFiles(HERE)) code.update(f.name).update("\0").update(f.text).update("\0");
|
|
52
53
|
return { commit, toolchain, host: platform, broker, brokerKnown: /^[0-9a-f]{64}$/.test(broker), gate: code.digest("hex").slice(0, 16) };
|
package/lint-waivers.mjs
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
// Rust lint waivers (bogusyogi/rightkit#1830, first slice): a port of Legion's `legion-dev check-waivers` (engine/bins/legion-dev/src/checks/waivers.rs at
|
|
2
|
+
// db1f28bf) for every repository the gate checks. A waiver is any of:
|
|
3
|
+
// - a `#[allow(...)]`, `#![allow(...)]`, `#[expect(...)]` or `#![expect(...)]` attribute in Rust code, or one of them inside `cfg_attr(...)`;
|
|
4
|
+
// - a `[lints]` / `[workspace.lints]` level set to "allow" in a Cargo.toml;
|
|
5
|
+
// - a rustflags entry that disables lints (-A, --allow, --cap-lints) in a Cargo.toml or .cargo/config(.toml).
|
|
6
|
+
// Rust attributes are matched on code only: comments, string literals (raw and byte strings too) and char literals are blanked first, keeping every
|
|
7
|
+
// newline so line numbers stay exact. TOML comments are blanked; TOML strings are kept (a level or a flag is a string).
|
|
8
|
+
// Not waivers here: `#[warn(...)]` and a "warn" level. The gate's clippy rows run with `-D warnings` (deterministic-scans.mjs clippyArgs), which turns
|
|
9
|
+
// every warning into an error, so a lint lowered to warn still fails; only allow, expect and a lint cap silence it.
|
|
10
|
+
// Fixture trees (`/tests/fixtures/`) are skipped, as in Legion's check: they hold waivers on purpose, as test input.
|
|
11
|
+
|
|
12
|
+
const WAIVER = /#!?\[\s*(?:allow|expect)\s*\(/g;
|
|
13
|
+
const CFG_ATTR = /#!?\[\s*cfg_attr\s*\(/g;
|
|
14
|
+
const NESTED_WAIVER = /\b(?:allow|expect)\s*\(/;
|
|
15
|
+
const TABLE = /^\s*\[\[?\s*([^[\]]+?)\s*\]\]?\s*$/;
|
|
16
|
+
const KEY_VALUE = /^\s*([A-Za-z0-9_.-]+)\s*=\s*(.*?)\s*$/;
|
|
17
|
+
const INLINE_ALLOW = /=\s*["']allow["']/;
|
|
18
|
+
const RUSTFLAGS_KEY = /^\s*rustflags\s*=/;
|
|
19
|
+
const QUOTED = /"([^"\n]*)"|'([^'\n]*)'/g;
|
|
20
|
+
|
|
21
|
+
export const WAIVER_REASONS = Object.freeze({
|
|
22
|
+
attribute: "lint waiver attribute (allow/expect)",
|
|
23
|
+
cfgAttr: "cfg_attr applies a lint waiver (allow/expect)",
|
|
24
|
+
level: "lint level set to allow",
|
|
25
|
+
flag: "rustflags disable lints (-A, --allow or --cap-lints)",
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
/** The kind of file the scan reads, or null for any other file. */
|
|
29
|
+
export function waiverKindOf(file) {
|
|
30
|
+
if (/(^|\/)tests\/fixtures\//.test(file)) return null;
|
|
31
|
+
if (file.endsWith(".rs")) return "rust";
|
|
32
|
+
if (/(^|\/)Cargo\.toml$/.test(file)) return "manifest";
|
|
33
|
+
if (/(^|\/)\.cargo\/config(\.toml)?$/.test(file)) return "config";
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const isIdent = (c) => c !== undefined && /[\p{L}\p{N}_]/u.test(c);
|
|
38
|
+
const blank = (out, from, to) => { for (let k = from; k < to && k < out.length; k++) if (out[k] !== "\n") out[k] = " "; };
|
|
39
|
+
|
|
40
|
+
/** Blanks comments (nested block comments too), string contents and char literal contents in Rust source, keeping newlines. */
|
|
41
|
+
export function maskRust(text) {
|
|
42
|
+
const c = Array.from(text); const n = c.length; const out = c.slice();
|
|
43
|
+
let i = 0;
|
|
44
|
+
while (i < n) {
|
|
45
|
+
const ch = c[i];
|
|
46
|
+
if (ch === "/" && c[i + 1] === "/") { let e = i; while (e < n && c[e] !== "\n") e++; blank(out, i, e); i = e; continue; }
|
|
47
|
+
if (ch === "/" && c[i + 1] === "*") {
|
|
48
|
+
let depth = 0; let k = i;
|
|
49
|
+
while (k < n) {
|
|
50
|
+
if (c[k] === "/" && c[k + 1] === "*") { depth++; k += 2; }
|
|
51
|
+
else if (c[k] === "*" && c[k + 1] === "/") { depth--; k += 2; if (depth === 0) break; }
|
|
52
|
+
else k++;
|
|
53
|
+
}
|
|
54
|
+
blank(out, i, Math.min(k, n)); i = Math.min(k, n); continue;
|
|
55
|
+
}
|
|
56
|
+
// raw strings: r"..", r#".."#, br"..", cr".."
|
|
57
|
+
{
|
|
58
|
+
const r = (c[i] === "b" || c[i] === "c") ? i + 1 : i;
|
|
59
|
+
if (c[r] === "r" && !(i > 0 && isIdent(c[i - 1]))) {
|
|
60
|
+
let k = r + 1; while (c[k] === "#") k++;
|
|
61
|
+
if (c[k] === '"') {
|
|
62
|
+
const hashes = k - r - 1; let e = k + 1;
|
|
63
|
+
while (e < n && !(c[e] === '"' && Array.from({ length: hashes }, (_, h) => c[e + 1 + h] === "#").every(Boolean))) e++;
|
|
64
|
+
blank(out, k + 1, e); i = Math.min(e + 1 + hashes, n); continue;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (ch === '"') { let e = i + 1; while (e < n) { if (c[e] === "\\") e += 2; else if (c[e] === '"') break; else e++; } blank(out, i + 1, e); i = Math.min(e + 1, n); continue; }
|
|
69
|
+
if (ch === "'") {
|
|
70
|
+
let close = null;
|
|
71
|
+
if (c[i + 1] === "\\") { let k = i + 3; while (k < n && c[k] !== "'" && c[k] !== "\n") k++; if (k < n && c[k] === "'") close = k; }
|
|
72
|
+
else if (c[i + 1] !== undefined && c[i + 1] !== "\n" && c[i + 2] === "'") close = i + 2;
|
|
73
|
+
if (close !== null) { blank(out, i + 1, close); i = close + 1; continue; }
|
|
74
|
+
i++; continue; // a lifetime
|
|
75
|
+
}
|
|
76
|
+
i++;
|
|
77
|
+
}
|
|
78
|
+
return out.join("");
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Blanks TOML comments, keeping strings (basic, literal, multi-line) and newlines. */
|
|
82
|
+
export function maskTomlComments(text) {
|
|
83
|
+
const c = Array.from(text); const n = c.length; const out = c.slice();
|
|
84
|
+
let i = 0;
|
|
85
|
+
while (i < n) {
|
|
86
|
+
if (c[i] === "#") { let e = i; while (e < n && c[e] !== "\n") e++; blank(out, i, e); i = e; continue; }
|
|
87
|
+
if (c[i] === '"' || c[i] === "'") {
|
|
88
|
+
const q = c[i];
|
|
89
|
+
if (c[i + 1] === q && c[i + 2] === q) { let k = i + 3; while (k < n && !(c[k] === q && c[k + 1] === q && c[k + 2] === q)) k += (q === '"' && c[k] === "\\") ? 2 : 1; i = Math.min(k + 3, n); continue; }
|
|
90
|
+
let k = i + 1; while (k < n && c[k] !== "\n") { if (q === '"' && c[k] === "\\") k += 2; else if (c[k] === q) { k++; break; } else k++; }
|
|
91
|
+
i = Math.min(k, n); continue;
|
|
92
|
+
}
|
|
93
|
+
i++;
|
|
94
|
+
}
|
|
95
|
+
return out.join("");
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const lineOf = (text, offset) => text.slice(0, offset).split("\n").length;
|
|
99
|
+
const isAllowFlag = (t) => t.startsWith("-A") || t === "--allow" || t.startsWith("--allow=") || t === "--cap-lints" || t.startsWith("--cap-lints=");
|
|
100
|
+
const flagsOnLine = (line) => [...line.matchAll(QUOTED)].some((m) => String(m[1] ?? m[2] ?? "").split(/\s+/).filter(Boolean).some(isAllowFlag));
|
|
101
|
+
|
|
102
|
+
function rustWaivers(text) {
|
|
103
|
+
const masked = maskRust(text); const out = [];
|
|
104
|
+
for (const m of masked.matchAll(WAIVER)) out.push({ line: lineOf(masked, m.index), reason: WAIVER_REASONS.attribute });
|
|
105
|
+
for (const m of masked.matchAll(CFG_ATTR)) {
|
|
106
|
+
let depth = 1; let k = m.index + m[0].length;
|
|
107
|
+
while (k < masked.length && depth > 0) { if (masked[k] === "(") depth++; else if (masked[k] === ")") depth--; k++; }
|
|
108
|
+
if (NESTED_WAIVER.test(masked.slice(m.index + m[0].length, depth === 0 ? k - 1 : masked.length))) out.push({ line: lineOf(masked, m.index), reason: WAIVER_REASONS.cfgAttr });
|
|
109
|
+
}
|
|
110
|
+
return out;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function manifestWaivers(text, kind) {
|
|
114
|
+
const masked = maskTomlComments(text); const out = []; const lines = masked.split("\n");
|
|
115
|
+
if (kind === "manifest") {
|
|
116
|
+
let table = "";
|
|
117
|
+
lines.forEach((line, i) => {
|
|
118
|
+
const t = TABLE.exec(line); if (t) { table = t[1]; return; }
|
|
119
|
+
const kv = KEY_VALUE.exec(line); if (!kv) return;
|
|
120
|
+
const keyPath = table ? `${table}.${kv[1]}` : kv[1];
|
|
121
|
+
const lintsPath = keyPath === "lints" || keyPath.startsWith("lints.") || keyPath === "workspace.lints" || keyPath.startsWith("workspace.lints.");
|
|
122
|
+
const v = kv[2].trim();
|
|
123
|
+
const allows = v.startsWith("{") ? INLINE_ALLOW.test(v) : v.replace(/^["']|["']$/g, "") === "allow";
|
|
124
|
+
if (lintsPath && allows) out.push({ line: i + 1, reason: `${WAIVER_REASONS.level} at ${keyPath}` });
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
let inArray = false;
|
|
128
|
+
lines.forEach((line, i) => {
|
|
129
|
+
if (kind === "manifest" && !inArray) { const m = RUSTFLAGS_KEY.exec(line); if (!m) return; inArray = line.slice(m[0].length).trimStart().startsWith("["); }
|
|
130
|
+
if (flagsOnLine(line)) out.push({ line: i + 1, reason: WAIVER_REASONS.flag });
|
|
131
|
+
if (kind === "manifest" && inArray && line.replace(QUOTED, "").includes("]")) inArray = false;
|
|
132
|
+
});
|
|
133
|
+
return out;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** The waivers in one file's text: [{ line, reason }] in line order. `kind` from waiverKindOf. */
|
|
137
|
+
export function waiversIn(text, kind) {
|
|
138
|
+
const found = kind === "rust" ? rustWaivers(text) : kind ? manifestWaivers(text, kind) : [];
|
|
139
|
+
return found.sort((a, b) => a.line - b.line);
|
|
140
|
+
}
|
package/package.json
CHANGED
package/release.mjs
CHANGED
|
@@ -1309,7 +1309,13 @@ async function runCommand(command, root, { env = {}, captureStdout = false } = {
|
|
|
1309
1309
|
const nativeCommand = nativeToolOf(command.cmd) !== null;
|
|
1310
1310
|
const { [NATIVE_SIGNING_FILE_ENV]: signingFile, ...dynamicEnv } = env;
|
|
1311
1311
|
const commandEnvironment = { ...(await commandEnv(command, root)), ...(nativeCommand ? dynamicEnv : env) };
|
|
1312
|
-
|
|
1312
|
+
// GC-A28: an assemble-app step stamps CFBundleVersion from RIGHT_BUILD_NUMBER, which the gate counted in the checkout (the snapshot's `.git` stub
|
|
1313
|
+
// cannot). On a broker host the step is an adapter job whose environment carries only the names the step declares, so the number is declared here,
|
|
1314
|
+
// for that step only; the adapter's registry entry must list RIGHT_BUILD_NUMBER (RK_ADAPTER_ENV_DENIED otherwise).
|
|
1315
|
+
const assembles = (command.args ?? []).map(String).includes("assemble-app");
|
|
1316
|
+
const buildNumber = assembles && /^[1-9][0-9]*$/.test(process.env.RIGHT_BUILD_NUMBER ?? "") ? { RIGHT_BUILD_NUMBER: process.env.RIGHT_BUILD_NUMBER } : {};
|
|
1317
|
+
const stepEnv = Object.keys(buildNumber).length ? { ...(command.env ?? {}), ...buildNumber } : command.env;
|
|
1318
|
+
const target = buildLaunch(command.cmd, command.args ?? [], { env: { ...process.env, ...commandEnvironment }, stepEnv, cwd, exists: existsSync, ...(nativeCommand && signingFile ? { signingFile } : {}) });
|
|
1313
1319
|
// A direct (Linux) launch carries PATH without RustRight shim directories (build-launch `env`).
|
|
1314
1320
|
return run(target.command, target.args, cwd, { ...commandEnvironment, ...(target.env ?? {}) }, {
|
|
1315
1321
|
...command,
|
package/rightkit-versions.json
CHANGED
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"@rightkit/qa": "0.7.0",
|
|
50
50
|
"@rightkit/qa-chrome": "0.1.12",
|
|
51
51
|
"@rightkit/react-shell": "0.7.9",
|
|
52
|
-
"@rightkit/release": "0.6.
|
|
52
|
+
"@rightkit/release": "0.6.92",
|
|
53
53
|
"@rightkit/send-ui": "0.1.0",
|
|
54
54
|
"@rightkit/settings-ui": "0.7.7",
|
|
55
55
|
"@rightkit/social-ui": "0.2.1",
|
|
@@ -456,7 +456,9 @@
|
|
|
456
456
|
"0.6.86",
|
|
457
457
|
"0.6.87",
|
|
458
458
|
"0.6.88",
|
|
459
|
-
"0.6.89"
|
|
459
|
+
"0.6.89",
|
|
460
|
+
"0.6.90",
|
|
461
|
+
"0.6.91"
|
|
460
462
|
],
|
|
461
463
|
"@rightkit/settings-ui": [
|
|
462
464
|
"0.1.0",
|
|
@@ -548,8 +550,8 @@
|
|
|
548
550
|
"stagedCargo": {
|
|
549
551
|
"rightkit-adapt": "0.2.1",
|
|
550
552
|
"rightkit-adapt-taste": "0.1.3",
|
|
551
|
-
"rightkit-agent-coding-tools": "0.1
|
|
552
|
-
"rightkit-agent-config": "0.1.
|
|
553
|
+
"rightkit-agent-coding-tools": "0.2.1",
|
|
554
|
+
"rightkit-agent-config": "0.1.6",
|
|
553
555
|
"rightkit-agent-daemon": "0.2.0",
|
|
554
556
|
"rightkit-agent-demo": "0.2.1",
|
|
555
557
|
"rightkit-agent-engine": "0.2.0",
|
|
@@ -557,9 +559,9 @@
|
|
|
557
559
|
"rightkit-agent-engine-api-platform": "0.1.3",
|
|
558
560
|
"rightkit-agent-engine-api-sessions": "0.1.1",
|
|
559
561
|
"rightkit-agent-engine-api-workflows": "0.2.2",
|
|
560
|
-
"rightkit-agent-engine-attention": "0.2.
|
|
562
|
+
"rightkit-agent-engine-attention": "0.2.2",
|
|
561
563
|
"rightkit-agent-engine-cli": "0.1.1",
|
|
562
|
-
"rightkit-agent-engine-core": "0.
|
|
564
|
+
"rightkit-agent-engine-core": "0.2.0",
|
|
563
565
|
"rightkit-agent-engine-history": "0.1.6",
|
|
564
566
|
"rightkit-agent-engine-mobile-runtime": "0.1.1",
|
|
565
567
|
"rightkit-agent-engine-protocol": "0.4.1",
|
|
@@ -571,7 +573,7 @@
|
|
|
571
573
|
"rightkit-agent-host-traits": "0.1.3",
|
|
572
574
|
"rightkit-agent-learning": "0.1.2",
|
|
573
575
|
"rightkit-agent-local-models": "0.1.3",
|
|
574
|
-
"rightkit-agent-orchestration": "0.1.
|
|
576
|
+
"rightkit-agent-orchestration": "0.1.8",
|
|
575
577
|
"rightkit-agent-orchestration-handoff": "0.1.2",
|
|
576
578
|
"rightkit-agent-plugins": "0.1.4",
|
|
577
579
|
"rightkit-agent-policy": "0.2.4",
|
|
@@ -583,7 +585,7 @@
|
|
|
583
585
|
"rightkit-agent-telemetry": "0.1.1",
|
|
584
586
|
"rightkit-agent-tools": "0.4.4",
|
|
585
587
|
"rightkit-agent-transcript": "0.1.4",
|
|
586
|
-
"rightkit-agents": "0.
|
|
588
|
+
"rightkit-agents": "0.3.0",
|
|
587
589
|
"rightkit-ai-accounts": "0.1.4",
|
|
588
590
|
"rightkit-ai-keys": "0.1.1",
|
|
589
591
|
"rightkit-android": "0.3.3",
|
|
@@ -679,7 +681,7 @@
|
|
|
679
681
|
"rightkit-google-apis": "0.2.3",
|
|
680
682
|
"rightkit-google-identity": "0.3.0",
|
|
681
683
|
"rightkit-gpu": "0.1.1",
|
|
682
|
-
"rightkit-hooks": "0.3.
|
|
684
|
+
"rightkit-hooks": "0.3.1",
|
|
683
685
|
"rightkit-hotkeys": "0.1.8",
|
|
684
686
|
"rightkit-http": "0.4.1",
|
|
685
687
|
"rightkit-i18n": "0.1.0",
|
|
@@ -924,7 +926,7 @@
|
|
|
924
926
|
"@rightkit/qa": "0.7.0",
|
|
925
927
|
"@rightkit/qa-chrome": "0.1.12",
|
|
926
928
|
"@rightkit/react-shell": "0.7.7",
|
|
927
|
-
"@rightkit/release": "0.6.
|
|
929
|
+
"@rightkit/release": "0.6.91",
|
|
928
930
|
"@rightkit/settings-ui": "0.7.4",
|
|
929
931
|
"@rightkit/shell": "0.1.1",
|
|
930
932
|
"@rightkit/tauri": "0.4.3",
|
|
@@ -940,10 +942,12 @@
|
|
|
940
942
|
],
|
|
941
943
|
"rightkit-agent-engine-attention": [
|
|
942
944
|
"0.1.3",
|
|
943
|
-
"0.2.0"
|
|
945
|
+
"0.2.0",
|
|
946
|
+
"0.2.1"
|
|
944
947
|
],
|
|
945
948
|
"rightkit-agent-engine-core": [
|
|
946
|
-
"0.1.3"
|
|
949
|
+
"0.1.3",
|
|
950
|
+
"0.1.4"
|
|
947
951
|
],
|
|
948
952
|
"rightkit-agent-local-models": [
|
|
949
953
|
"0.1.1",
|
|
@@ -974,7 +978,8 @@
|
|
|
974
978
|
"rightkit-agents": [
|
|
975
979
|
"0.1.0",
|
|
976
980
|
"0.2.0",
|
|
977
|
-
"0.2.7"
|
|
981
|
+
"0.2.7",
|
|
982
|
+
"0.2.8"
|
|
978
983
|
],
|
|
979
984
|
"rightkit-ai-accounts": [
|
|
980
985
|
"0.1.1",
|
|
@@ -1291,7 +1296,8 @@
|
|
|
1291
1296
|
"rightkit-hooks": [
|
|
1292
1297
|
"0.1.0",
|
|
1293
1298
|
"0.2.0",
|
|
1294
|
-
"0.2.13"
|
|
1299
|
+
"0.2.13",
|
|
1300
|
+
"0.3.0"
|
|
1295
1301
|
],
|
|
1296
1302
|
"rightkit-hotkeys": [
|
|
1297
1303
|
"0.1.0",
|
|
@@ -1810,7 +1816,9 @@
|
|
|
1810
1816
|
"0.3.2"
|
|
1811
1817
|
],
|
|
1812
1818
|
"rightkit-agent-config": [
|
|
1813
|
-
"0.1.3"
|
|
1819
|
+
"0.1.3",
|
|
1820
|
+
"0.1.4",
|
|
1821
|
+
"0.1.5"
|
|
1814
1822
|
],
|
|
1815
1823
|
"rightkit-agent-demo": [
|
|
1816
1824
|
"0.2.0"
|
|
@@ -1829,7 +1837,8 @@
|
|
|
1829
1837
|
"0.3.0"
|
|
1830
1838
|
],
|
|
1831
1839
|
"rightkit-agent-orchestration": [
|
|
1832
|
-
"0.1.6"
|
|
1840
|
+
"0.1.6",
|
|
1841
|
+
"0.1.7"
|
|
1833
1842
|
],
|
|
1834
1843
|
"rightkit-agent-telemetry": [
|
|
1835
1844
|
"0.1.0"
|
package/seam-broker.mjs
CHANGED
|
@@ -152,26 +152,35 @@ export function posixAgentShimTarget(text) {
|
|
|
152
152
|
return exec ? exec[1] : null;
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
155
|
+
/**
|
|
156
|
+
* The runtime manifest that sits beside the RustRight client `exe` really starts (`exe` already resolved through resolveBrokerClient): on POSIX the real path,
|
|
157
|
+
* and through the installer's agent shim (a short sh script in the managed agent-bin that execs the runtime's client; not a symlink, so its real path is
|
|
158
|
+
* itself and agent-bin holds no manifest) to the client it starts. Used by every reader of the installed broker's identity: the seam's reclaim judge
|
|
159
|
+
* (2026-11-26), the unit compile's result store and the failure cache (2026-11-27: on the Mac both read agent-bin and found nothing, so every unit run
|
|
160
|
+
* reported "nothing is remembered or reused" and no compile failure was cached; CodeRight, rightkit-agent-engine-attention 71ea35fa).
|
|
161
|
+
*/
|
|
162
|
+
export function runtimeManifestPathOf(exe, { platform = process.platform, read = (file) => fs.readFileSync(file, "utf8"), realpath = fs.realpathSync.native } = {}) {
|
|
162
163
|
let real = exe;
|
|
163
|
-
if (platform !== "win32") { try { real = (o?.realpath ?? fs.realpathSync.native)(exe); } catch { real = exe; } }
|
|
164
|
-
// The installer's POSIX agent shim (a short sh script in the managed agent-bin that execs the runtime's client) is not a symlink, so
|
|
165
|
-
// its real path is itself and the manifest was looked for in agent-bin, where there is none: no dead holder's snapshot lock could be
|
|
166
|
-
// reclaimed on the Mac (2026-11-26). Follow the shim to the client it starts; the manifest sits beside that.
|
|
167
164
|
if (platform !== "win32") {
|
|
165
|
+
try { real = realpath(exe); } catch { real = exe; }
|
|
168
166
|
let shimText = null;
|
|
169
167
|
try { shimText = read(real); } catch { shimText = null; }
|
|
170
168
|
const target = posixAgentShimTarget(shimText);
|
|
171
169
|
if (target) real = target;
|
|
172
170
|
}
|
|
173
171
|
const paths = platform === "win32" ? path.win32 : path.posix;
|
|
174
|
-
|
|
172
|
+
return paths.join(paths.dirname(real), RUNTIME_MANIFEST_FILE);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export function brokerControlTarget(o, { client = o?.client } = {}) {
|
|
176
|
+
const platform = o?.platform ?? process.platform;
|
|
177
|
+
const env = o?.env ?? process.env;
|
|
178
|
+
const read = o?.readFile ?? ((file) => fs.readFileSync(file, "utf8"));
|
|
179
|
+
if (typeof client !== "string" || !client) return { ok: false, problem: "the RustRight client is not on PATH, so its runtime identity cannot be read" };
|
|
180
|
+
let exe;
|
|
181
|
+
try { exe = resolveBrokerClient(client, { platform, readFile: read }).file; } catch (error) { return { ok: false, problem: `the RustRight client cannot be resolved (${error.message})` }; }
|
|
182
|
+
// The POSIX agent shim is followed to the client it starts (runtimeManifestPathOf; no dead holder's lock could be reclaimed on the Mac before, 2026-11-26).
|
|
183
|
+
const manifest = runtimeManifestPathOf(exe, { platform, read, ...(o?.realpath ? { realpath: o.realpath } : {}) });
|
|
175
184
|
let text;
|
|
176
185
|
try { text = read(manifest); } catch (error) { return { ok: false, problem: `cannot read the runtime manifest ${manifest} beside the client (${error?.message ?? error})` }; }
|
|
177
186
|
const identity = parseRuntimeIdentity(text);
|