@rightkit/release 0.6.43 → 0.6.45

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.
@@ -392,6 +392,16 @@ export function checkCrateAdvisoryExceptions({ root = process.cwd(), now = new D
392
392
  }
393
393
  for (const p of checkAdvisoryExceptions({ root: here, now, allowPending, exceptionsFile: CRATE_EXCEPTIONS_FILE, readFile: f => readFile(path.join(here, f)) })) problems.push(`${dir}: ${p}`);
394
394
  }
395
+ // RightKit is one Cargo workspace with one Cargo.lock (GATE-CONTRACT GC-T24): the repository root holds the ledger, deny.toml and
396
+ // .cargo/audit.toml for every crate that is a member of it.
397
+ if (exists(path.join(root, 'Cargo.toml')) && exists(path.join(root, LOCK_FILE))) {
398
+ const ignores = [DENY_FILE, AUDIT_FILE].some(f => { try { return IGNORE_LIST_RE.test(readFile(path.join(root, f))); } catch { return false; } });
399
+ if (!exists(path.join(root, CRATE_EXCEPTIONS_FILE))) {
400
+ if (ignores) problems.push(`.: ${DENY_FILE} or ${AUDIT_FILE} ignores an advisory but ${CRATE_EXCEPTIONS_FILE} does not exist`);
401
+ } else {
402
+ for (const p of checkAdvisoryExceptions({ root, now, allowPending, exceptionsFile: CRATE_EXCEPTIONS_FILE, readFile: f => readFile(path.join(root, f)) })) problems.push(`.: ${p}`);
403
+ }
404
+ }
395
405
  return problems;
396
406
  }
397
407
 
@@ -1438,10 +1438,18 @@ export async function rightkitDoorRule(o, args, root, git, io, { unitsFileFlag,
1438
1438
  if (unitsFileFlag) {
1439
1439
  const stage = option("--to");
1440
1440
  const given = args.filter((a, i) => a.startsWith("--") && args[i - 1] !== "--units-file" && a !== "--units-file");
1441
- if (given.some((a) => a !== "--to" && a !== "--commit")) { o.err(`${tag} a unit list run takes only --to, --units-file and optional --commit (a receipt is written per unit run: run the unit alone with --receipt-out)`); return { exit: 2 }; }
1441
+ if (given.some((a) => a !== "--to" && a !== "--commit" && a !== "--receipt-dir")) { o.err(`${tag} a unit list run takes only --to, --units-file and optional --commit and --receipt-dir (one receipt file per unit is written into the directory)`); return { exit: 2 }; }
1442
+ const receiptDir = option("--receipt-dir");
1443
+ if (receiptDir !== undefined && (receiptDir.startsWith("--") || !path.isAbsolute(receiptDir))) { o.err(`${tag} --receipt-dir needs an absolute directory`); return { exit: 2 }; }
1444
+ // One Class A for the whole list (rightkit#1505; Adrian, 2026-10-31: "a JSON file that is created at that time"): the first unit's Class A is scoped to
1445
+ // every listed unit's directory (the repeatable --scope), and a pass is remembered for the commit and rule tier, so the other units do not run it again.
1446
+ // Before this, each unit ran its own Class A: 145 s median of a 206 s unit run on 2026-11-04, the same scans on the same commit 168 times.
1447
+ const dirOf = (sel) => { const m = /^(?:npm:@rightkit\/([a-z0-9-]+)|cargo:(rightkit-[a-z0-9-]+))$/.exec(sel); return m ? (m[1] ? `packages/${m[1]}` : `crates/${m[2]}`) : null; };
1448
+ const unitListClassA = { dirs: [...new Set(unitList.map(dirOf).filter(Boolean))], memo: new Map() };
1442
1449
  for (const [i, selector] of unitList.entries()) {
1443
1450
  o.out(`${tag} unit list ${i + 1}/${unitList.length}: ${selector} on commit ${pinned.commit.slice(0, 12)}`);
1444
- const code = await main(["--to", stage, "--unit", selector, "--commit", pinned.commit], io);
1451
+ const receipt = receiptDir === undefined ? [] : ["--receipt-out", path.join(receiptDir, `gate-${selector.replace(/^npm:@rightkit\//, "npm-").replace(/^cargo:/, "")}.json`)];
1452
+ const code = await main(["--to", stage, "--unit", selector, "--commit", pinned.commit, ...receipt], { ...io, unitListClassA });
1445
1453
  if (code !== 0) { o.err(`${tag} BLOCKED: unit ${selector} ended with exit ${code}; ${unitList.length - i - 1} unit(s) of the list did not run`); return { exit: code }; }
1446
1454
  }
1447
1455
  return { exit: 0 };
@@ -2551,7 +2559,17 @@ async function runUnitSnapshot(o, args, root, git, io, option) {
2551
2559
  for (const p of calls.slice(0, 10)) o.err(`${tag} RK_CHECK_ERROR: [unit:${stage}] a cargo call the unit stage made did not complete: ${typeof p === "string" ? p : JSON.stringify(p)}`);
2552
2560
  return calls.length === 0;
2553
2561
  } };
2554
- const runCheck = (tier) => (o.runCheck ?? (() => main(["check", "--commit", ds.commit, "--full-a", "--snapshot", ds.path, "--rule-tier", tier, "--scope", path.posix.dirname(manifest)], { ...io, cwd: root, buildOwnership: own })))(tier);
2562
+ // A unit-list run (--units-file) shares one Class A: scoped to every listed unit's directory, run by the first unit, remembered for the rest.
2563
+ const unitDir = path.posix.dirname(manifest);
2564
+ const shared = io.unitListClassA?.dirs?.includes(unitDir) ? io.unitListClassA : null;
2565
+ const runCheck = async (tier) => {
2566
+ const memoKey = `${ds.commit}:${tier}`;
2567
+ if (shared && shared.memo.get(memoKey) === 0) { o.out(`${tag} class A (${tier} tier) of this unit list already passed on ${ds.commit.slice(0, 12)}: not run again`); return 0; }
2568
+ const scopes = shared ? shared.dirs : [unitDir];
2569
+ const code = await (o.runCheck ?? (() => main(["check", "--commit", ds.commit, "--full-a", "--snapshot", ds.path, "--rule-tier", tier, ...scopes.flatMap((d) => ["--scope", d])], { ...io, cwd: root, buildOwnership: own })))(tier);
2570
+ if (shared && code === 0) shared.memo.set(memoKey, 0);
2571
+ return code;
2572
+ };
2555
2573
  if (toolRun) {
2556
2574
  const { runUnitTool } = await import("../tool-build.mjs");
2557
2575
  return await runUnitTool({ selector, root: ds.path, commonDir: path.resolve(root, text(common).trim()), commit: ds.commit, tree: ds.tree, executor, env: o.env, platform: o.platform, source, envExtra, targetDirs: bound.targetDirs ?? {},
@@ -3201,7 +3219,7 @@ export function doorPath(o, gateFile = o.gateFile ?? fileURLToPath(import.meta.u
3201
3219
  * lookup of a usable rustfmt, which the deferred Rust gate needs).
3202
3220
  */
3203
3221
  /** The gate flags a `--to <stage>` invocation takes (before a `--` separator, after which the arguments belong to right-release), and whether each takes a value. */
3204
- const STAGE_VALUE_FLAGS = Object.freeze(["--to", "--platform", "--tier", "--commit", "--receipt-in", "--receipt-out", "--unit", "--units-file", "--all-units-exception"]);
3222
+ const STAGE_VALUE_FLAGS = Object.freeze(["--to", "--platform", "--tier", "--commit", "--receipt-in", "--receipt-out", "--unit", "--units-file", "--all-units-exception", "--receipt-dir"]);
3205
3223
  const STAGE_BOOLEAN_FLAGS = Object.freeze(["--route"]);
3206
3224
 
3207
3225
  /**
@@ -2416,16 +2416,36 @@ const INTERNAL = {
2416
2416
  "dependency-freshness": async (s, ctx) => {
2417
2417
  let bin;
2418
2418
  try { bin = resolveOutdatedBin(); } catch (e) { return { advice: `dependency freshness not measured: ${e instanceof OutdatedUnavailableError ? e.message : `right-update could not be located (${e.message})`}` }; }
2419
+ // The answer is a property of the repository's lock files and of the registry at this hour, not of the unit being gated: a run per unit of one
2420
+ // commit asks the registry again for the same locks (88 s per crate on 2026-11-04, 6795 s over 77 crate runs). One answer per lock set and UTC hour.
2421
+ let cachePath = null;
2422
+ try {
2423
+ const names = [".rightkit/update.json", "Cargo.lock", "pnpm-lock.yaml", "package.json"];
2424
+ const h = crypto.createHash("sha256");
2425
+ for (const n of names) { h.update(`${n}\0`); try { h.update(fs.readFileSync(path.join(ctx.contentRoot, n))); } catch { h.update("absent"); } }
2426
+ const dir = path.join(ctx.tmpRoot ?? os.tmpdir(), "rightkit-freshness-cache");
2427
+ cachePath = path.join(dir, `${h.digest("hex").slice(0, 32)}-${new Date().toISOString().slice(0, 13)}.json`);
2428
+ const hit = JSON.parse(fs.readFileSync(cachePath, "utf8"));
2429
+ if (typeof hit?.advice === "string") return { advice: hit.advice };
2430
+ } catch { /* no cached answer: measure */ }
2431
+ const remember = (result) => {
2432
+ // A measurement that timed out is cached too: it is the 120 s case (41 of 81 crate runs on 2026-11-04), and asking again for every unit of the same
2433
+ // lock set within the hour is the cost this cache removes. The advice text says "not measured", so nobody reads it as a pass.
2434
+ if (cachePath && typeof result?.advice === "string") {
2435
+ try { fs.mkdirSync(path.dirname(cachePath), { recursive: true }); fs.writeFileSync(cachePath, JSON.stringify({ advice: result.advice })); } catch { /* the cache is an optimisation only */ }
2436
+ }
2437
+ return result;
2438
+ };
2419
2439
  let r;
2420
2440
  try { r = await ctx.deps.spawn(process.execPath, [bin, "check", "--json", "--repo", ctx.contentRoot], { cwd: ctx.contentRoot, encoding: "utf8", env: { ...ctx.deps.env, ...PNPM_NO_HOOKS_ENV }, timeout: 120_000, maxBuffer: 1 << 26 }); }
2421
- catch (e) { return { advice: `dependency freshness not measured: right-update check did not run (${e.message})` }; }
2441
+ catch (e) { return remember({ advice: `dependency freshness not measured: right-update check did not run (${e.message})` }); }
2422
2442
  let report = null;
2423
2443
  try { report = JSON.parse(String(r?.stdout ?? "")); } catch { report = null; }
2424
- if (!report || !Array.isArray(report.entries)) return { advice: `dependency freshness not measured: right-update check printed no report${r?.status ? ` (exit ${r.status})` : ""}` };
2444
+ if (!report || !Array.isArray(report.entries)) return remember({ advice: `dependency freshness not measured: right-update check printed no report${r?.status ? ` (exit ${r.status})` : ""}` });
2425
2445
  const behind = report.entries.filter((e) => e.status === "outdated");
2426
2446
  const unjudged = report.entries.filter((e) => e.status === "unknown" || e.error).length;
2427
2447
  const named = behind.slice(0, 5).map((e) => `${e.name} ${e.pinned ?? "?"} -> ${e.latest ?? "?"}`).join(", ");
2428
- return { advice: `${behind.length} behind latest${named ? ` (${named}${behind.length > 5 ? ", ..." : ""})` : ""}${unjudged ? `; ${unjudged} not judged` : ""}` };
2448
+ return remember({ advice: `${behind.length} behind latest${named ? ` (${named}${behind.length > 5 ? ", ..." : ""})` : ""}${unjudged ? `; ${unjudged} not judged` : ""}` });
2429
2449
  },
2430
2450
  // The Swift type-check (rightkit#1289): Mac host only, Class A, before any compile stage. SwiftPM compiles each target with `-Xswiftc -typecheck`: swiftc type-checks every
2431
2451
  // source against the real SDK and the target's dependencies and writes no object file, so a labelled-argument order error fails here in seconds instead of at the
package/managed-cargo.mjs CHANGED
@@ -272,8 +272,14 @@ export function brokerClientRoute({ env = process.env, platform = process.platfo
272
272
  return { client, env: socket ? { ...env, RUSTRIGHT_BUILD_BROKER_SOCKET: socket } : env, mapUnavailable: platform === 'darwin' };
273
273
  }
274
274
 
275
+ /** Cargo commands that compile nothing: Class A, run direct with the pinned toolchain and never carried by the broker (GC-A11, BROKER-CONTRACT interface item 14). */
276
+ const NON_COMPILING_CARGO = new Set(['metadata', 'fetch', 'tree', 'locate-project', 'pkgid', 'verify-project', 'read-manifest']);
277
+
275
278
  export function runCargoSync(args, options = {}, { platform = process.platform, exists = existsSync, spawn = spawnSync, fsOps } = {}) {
276
279
  const env = options.env ?? process.env;
280
+ // The broker refuses every carried request that compiles nothing (RK_CHECK_ERROR), so right-release's `cargo metadata` of the compile and
281
+ // package stages runs here, directly, exactly as the gate runs its Class A cargo calls.
282
+ if (NON_COMPILING_CARGO.has(args[0])) return spawn("cargo", args, { ...options, env: directCargoEnv(env, platform, exists) });
277
283
  const seam = carriedSeam(args, options, { platform, spawn });
278
284
  if (seam) return seam;
279
285
  // A gate run outside the broker by Adrian's recorded exception: the real toolchain, shims off PATH, on every platform (NO_BROKER_ENV).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rightkit/release",
3
- "version": "0.6.43",
3
+ "version": "0.6.45",
4
4
  "description": "Portable release CLI/SDK with fail-closed public GitHub Releases and private R2 + RightApps distribution.",
5
5
  "license": "MIT OR Apache-2.0",
6
6
  "type": "module",
@@ -50,7 +50,7 @@
50
50
  "@rightkit/qa": "0.7.0",
51
51
  "@rightkit/qa-chrome": "0.1.12",
52
52
  "@rightkit/react-shell": "0.7.3",
53
- "@rightkit/release": "0.6.43",
53
+ "@rightkit/release": "0.6.45",
54
54
  "@rightkit/settings-ui": "0.7.1",
55
55
  "@rightkit/social-ui": "0.1.0",
56
56
  "@rightkit/system-ui": "0.1.0",
@@ -529,7 +529,7 @@
529
529
  "rightkit-app-host": "0.1.0",
530
530
  "rightkit-app-lock": "0.1.0",
531
531
  "rightkit-app-manager": "0.1.2",
532
- "rightkit-app-settings": "0.3.3",
532
+ "rightkit-app-settings": "0.3.4",
533
533
  "rightkit-app-update": "0.1.0",
534
534
  "rightkit-apple-ops": "0.1.2",
535
535
  "rightkit-approvals": "0.1.0",
@@ -569,7 +569,7 @@
569
569
  "rightkit-contracts": "0.1.10",
570
570
  "rightkit-contrast": "0.1.0",
571
571
  "rightkit-crash": "0.3.8",
572
- "rightkit-credentials": "0.4.6",
572
+ "rightkit-credentials": "0.5.0",
573
573
  "rightkit-crypto": "0.1.2",
574
574
  "rightkit-daemon": "0.5.3",
575
575
  "rightkit-db": "0.5.5",
@@ -605,7 +605,7 @@
605
605
  "rightkit-evidence-governance": "0.1.1",
606
606
  "rightkit-evidence-report": "0.1.1",
607
607
  "rightkit-feed": "0.1.0",
608
- "rightkit-ffmpeg": "0.2.16",
608
+ "rightkit-ffmpeg": "0.3.0",
609
609
  "rightkit-file-watch": "0.4.4",
610
610
  "rightkit-fs": "0.4.12",
611
611
  "rightkit-fsindex": "0.6.2",
@@ -659,7 +659,7 @@
659
659
  "rightkit-privileged-helper": "0.1.1",
660
660
  "rightkit-prompt-recipes": "0.1.0",
661
661
  "rightkit-pty": "0.1.0",
662
- "rightkit-qa": "0.10.3",
662
+ "rightkit-qa": "0.10.4",
663
663
  "rightkit-qa-driver": "0.7.1",
664
664
  "rightkit-record": "0.4.0",
665
665
  "rightkit-reframe": "0.1.1",