@rightkit/release 0.6.35 → 0.6.37

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.
@@ -64,7 +64,6 @@ export const SCAN_CLASS = Object.freeze({ A: "A", B: "B" });
64
64
  export const UNOBSERVED_NESTED_CARGO_NOTE = "cargo calls that a build script makes through $CARGO are unobserved: cargo hands build scripts its own path, not the gate's wrapper, so they are not in the cargo ledger; they inherit the parent's bound CARGO_TARGET_DIR, and the per-scan sentinel and the after-compile snapshot verify are the backstops";
65
65
 
66
66
  /** The ledger token of the gate's own tool version probes (they reach the cargo wrapper like any scan does). */
67
- const BUILD_HELPERS_COMMAND = fileURLToPath(new URL("./build-helpers-command.mjs", import.meta.url));
68
67
  const PROBE_LEDGER_TOKEN = scanTokenOf("tool-probe");
69
68
 
70
69
  /** Scan id prefixes (the text before the first ":") that belong to each class. */
@@ -1251,12 +1250,8 @@ export function planScans({
1251
1250
  }
1252
1251
  if (rustTouched) {
1253
1252
  for (const ws of touchedWs) add({ id: `cargo-metadata${wsIdSuffix(ws)}`, class: A, ...cargoReadIn(ws, ...metadataArgs()) });
1254
- // rightkit#1450 (Adrian, 2026-11-02): every build script and proc macro of the workspace must have been traced once on this host, writing only
1255
- // inside its build directories; an untraced or out-of-bounds unit refuses Class A, naming it. Runs the gate's own command, directly (GC-A11).
1256
- // It runs in its workspace (cwd), so a unit's scope keeps it only for the Cargo workspaces of its own closure (app-closure CARGO_WORKSPACE_SCAN),
1257
- // like metadata, deny and audit: an npm-only unit traces nothing.
1258
- // Build helpers are vetted only on broker hosts (Mac, Dell); a Linux host or CI runner is a throwaway container (Adrian, 2026-11-03).
1259
- if (platform === "darwin" || platform === "win32") for (const ws of touchedWs) add({ id: `build-helpers${wsIdSuffix(ws)}`, class: A, tool: "node", args: [BUILD_HELPERS_COMMAND, "check", "--manifest-path", "Cargo.toml"], ...(ws !== "." ? { cwd: ws } : {}), root: "content" });
1253
+ // The build-helper trace check (rightkit#1450) is removed from Class A (Adrian, 2026-11-03): the Mac tracer misattributed writes and
1254
+ // its sessions filled the disk (rightkit#1494), and apps waited on traces for hours. No host blocks on build-helper traces.
1260
1255
  // Locked package listings are observations in RustRight (#1216). They run through the selected executor
1261
1256
  // from the checked Cargo inputs, just like metadata; an executor refusal remains a failed scan.
1262
1257
  for (const name of crateNames.filter((n) => rustMap?.get(n).publish !== false)) add({ id: rustScanId.packageList(name), class: A, ...cargoReadIn(wsOf(name), "package", "-p", crateOf(name), "--list", "--allow-dirty", "--locked") });
package/local-publish.mjs CHANGED
@@ -43,6 +43,35 @@ export const LOCAL_HOST_POLICIES = Object.freeze({ darwin: "darwin-only", win32:
43
43
  const localHostPolicyReason = (platform) => (platform === "win32" ? LOCAL_WIN32_HOST_POLICY_REASON : platform === "linux" ? LOCAL_LINUX_HOST_POLICY_REASON : LOCAL_HOST_POLICY_REASON);
44
44
  const STEP_TIMEOUT_MS = 30 * 60 * 1000;
45
45
 
46
+ /** The broker's reply to a `cargo test` it compiled and did not run (GATE-CONTRACT GC-A08). */
47
+ export const BROKER_COMPILED_ONLY = /^rustright: compiled, ready for testing\b/m;
48
+
49
+ /**
50
+ * Run the test executables a broker-compiled `cargo test` step listed, outside the broker (GC-A08), with the run arguments after its `--`.
51
+ * The listing must have finished and name at least one test executable; every executable must sit inside the compile's output directory
52
+ * (the carried receipt's, else cargo metadata's target directory). Returns runTestBinaries' { status, code?, detail?, results }.
53
+ */
54
+ export async function runCompiledTests({ unit, step, result, cwd, env, scans }) {
55
+ const ds = scans ?? await import("./deterministic-scans.mjs");
56
+ const { resolveTargetRoot } = await import("./cargo-target.mjs");
57
+ const listing = ds.parseTestListing(`${result.stdout ?? ""}`);
58
+ if (listing.buildFinished !== true) return { status: "fail", code: "TEST_LISTING", detail: `${unit}: the compile has no successful build-finished record`, results: null };
59
+ if (listing.binaries.length === 0) return { status: "fail", code: "NO_TEST_EXECUTABLES", detail: `${unit}: the compile listed no test executable (${listing.artifacts} artifact record(s))`, results: null };
60
+ const outputDir = typeof result.outputDir === "string" ? result.outputDir : resolveTargetRoot(path.join(cwd, "Cargo.toml"), { env });
61
+ const contained = ds.containTestExecutables(listing.binaries, { boundDirs: [outputDir] });
62
+ if (contained.problems.length) return { status: "fail", code: "TEST_EXECUTABLE_OUTSIDE_OUTPUT", detail: `${unit}: ${contained.problems.slice(0, 5).join("; ")}; nothing was run`, results: null };
63
+ const sep = step.args.indexOf("--");
64
+ const runArgs = sep >= 0 ? step.args.slice(sep + 1) : [];
65
+ const scan = { id: `test:${unit}`, runOutside: { args: runArgs } };
66
+ // Each executable's output is kept so the caller's ResultScanner still counts SKIP markers (an asset-gated proof that returned early).
67
+ const outputs = [];
68
+ const spawn = async (...a) => { const r = await ds.defaultSpawnAsync(...a); outputs.push(r); return r; };
69
+ // A serial step stays serial across executables, as `cargo test -- --test-threads=1` runs them one after another.
70
+ const concurrency = runArgs.includes("--test-threads=1") ? 1 : undefined;
71
+ const ran = await ds.runTestBinaries({ scan, binaries: contained.accepted, spawn, env, limitMs: STEP_TIMEOUT_MS, ...(concurrency ? { concurrency } : {}) });
72
+ return { ...ran, outputs };
73
+ }
74
+
46
75
  export class LocalPublishError extends Error {
47
76
  constructor(message) { super(message); this.name = "LocalPublishError"; }
48
77
  }
@@ -698,6 +727,20 @@ async function* publishUnitStages(parsed, deps, batch) {
698
727
  refuse(`${plan.id} step failed (${result.error?.message ?? `exit ${result.status}`}): ${commandText}\nstdout:\n${result.stdout ?? ""}\nstderr:\n${result.stderr ?? ""}`);
699
728
  }
700
729
  row.ok = true;
730
+ // GATE-CONTRACT GC-A08: a broker compiles a `cargo test` and never runs it. Its reply names that; the executables its JSON listing
731
+ // names are then run here, outside the broker, exactly as the gate's class B test rows run them (runCompiledTests).
732
+ if (row.isTest && step.command === "cargo" && BROKER_COMPILED_ONLY.test(`${result.stderr ?? ""}\n${result.stdout ?? ""}`)) {
733
+ const ran = await (deps.runCompiledTests ?? runCompiledTests)({ unit, step, result, cwd: stepCwd, env: step.env ? { ...env, ...step.env } : env });
734
+ if (ran.status !== "pass") { steps.push(row); refuse(`${plan.id} tests not run or failed (${ran.code}): ${ran.detail}`); }
735
+ // SKIP markers come from the executables' own output, read the way the old in-cargo run was read.
736
+ // An output cut at the kept tail could hide an early SKIP line; such a run proves nothing.
737
+ if ((ran.outputs ?? []).some((o) => o?.truncated === true)) { steps.push(row); refuse(`${plan.id}: a test executable's output exceeded the kept tail, so its SKIP markers cannot be counted`); }
738
+ const marks = new ResultScanner(); for (const o of ran.outputs ?? []) { marks.push(`${o?.stdout ?? ""}\n`); marks.push(`${o?.stderr ?? ""}\n`); }
739
+ const scanned = marks.finish();
740
+ Object.assign(row, { executed: ran.results.pass, failed: ran.results.fail, ignored: ran.results.skipped, skipped: scanned.skipped, binaries: ran.results.binaries });
741
+ steps.push(row);
742
+ continue;
743
+ }
701
744
  if (row.isTest) {
702
745
  const out = new ResultScanner(); const err = new ResultScanner();
703
746
  out.push(result.stdout ?? ""); err.push(result.stderr ?? "");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rightkit/release",
3
- "version": "0.6.35",
3
+ "version": "0.6.37",
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",
@@ -9,8 +9,10 @@
9
9
  // 2. the gate's Class A for the package passes on that commit (`rightkit-gate --to check --unit npm:<name> --commit <sha>`, this
10
10
  // package's own gate, so a release publishes through the gate it ships);
11
11
  // 3. the version is not on npm yet.
12
- // The package folder is exported from the commit (git archive) and packed there; npm provenance is off (rightkit#1472). After publishing,
13
- // the registry's shasum must equal the packed tarball's, or the command fails.
12
+ // The commit's whole tree is exported (git archive), its dependencies are installed there offline from the commit's own lockfile and the
13
+ // checkout's pnpm store (a package whose prepack builds needs its devDependencies, rightkit#1493), and the package is packed there; the
14
+ // checkout and the gate's snapshot are never written. npm provenance is off (rightkit#1472). After publishing, the registry's shasum must
15
+ // equal the packed tarball's, or the command fails.
14
16
  import crypto from "node:crypto";
15
17
  import { spawnSync } from "node:child_process";
16
18
  import fs from "node:fs";
@@ -24,6 +26,16 @@ const GATE = fileURLToPath(new URL("./bin/rightkit-gate.mjs", import.meta.url));
24
26
 
25
27
  function fail(message) { throw new Error(message); }
26
28
 
29
+ /** The pnpm store the checkout installed from (`storeDir` in its node_modules/.modules.yaml, e.g. /Volumes/D/.pnpm-store/v11), as a `--store-dir` value (its parent). */
30
+ export function checkoutStoreDir(repo, readFile = (f) => fs.readFileSync(f, "utf8")) {
31
+ let text;
32
+ try { text = readFile(path.join(repo, "node_modules", ".modules.yaml")); } catch { fail(`${repo}/node_modules/.modules.yaml is missing: install the checkout once so its pnpm store is known`); }
33
+ const m = /"?storeDir"?\s*:\s*"?([^"\r\n]+)"?/.exec(text);
34
+ if (!m) fail(`${repo}/node_modules/.modules.yaml names no storeDir`);
35
+ const storeDir = m[1].trim();
36
+ return /^v\d+$/.test(path.basename(storeDir)) ? path.dirname(storeDir) : storeDir;
37
+ }
38
+
27
39
  export function parseArgs(argv) {
28
40
  const out = { kind: argv[0], pkg: null, commit: null, repo: process.cwd() };
29
41
  for (let i = 1; i < argv.length; i += 1) {
@@ -61,13 +73,23 @@ export function publishLocalNpm(argv, { run = spawnSync, log = console.log, plat
61
73
  const classA = run(process.execPath, [GATE, "--to", "check", "--unit", `npm:${o.pkg}`, "--commit", commit], { cwd: o.repo, stdio: ["ignore", "inherit", "inherit"] });
62
74
  if (classA.status !== 0) fail(`Class A failed for npm:${o.pkg} on ${commit} (exit ${classA.status}); nothing published`);
63
75
 
64
- const work = fs.mkdtempSync(path.join(os.tmpdir(), "rk-publish-local-"));
76
+ // The agent volume, not the internal drive: the export holds a full install (workspace rule: run output under /Volumes/D/scratch).
77
+ const scratchRoot = fs.existsSync("/Volumes/D/scratch") ? "/Volumes/D/scratch" : os.tmpdir();
78
+ const work = fs.mkdtempSync(path.join(scratchRoot, "rk-publish-local-"));
65
79
  try {
66
- const archive = run("git", ["archive", "--format=tar", commit, dir], { cwd: o.repo, maxBuffer: 1 << 30 });
67
- if (archive.status !== 0) fail(`git archive ${commit} ${dir} failed`);
68
- const tarIn = run("tar", ["-x", "-C", work], { input: archive.stdout });
69
- if (tarIn.status !== 0) fail("unpacking the commit's package folder failed");
70
- const pkgDir = path.join(work, dir);
80
+ const tree = path.join(work, "tree");
81
+ fs.mkdirSync(tree);
82
+ const archive = run("git", ["archive", "--format=tar", commit], { cwd: o.repo, maxBuffer: 1 << 30 });
83
+ if (archive.status !== 0) fail(`git archive ${commit} failed`);
84
+ const tarIn = run("tar", ["-x", "-C", tree], { input: archive.stdout });
85
+ if (tarIn.status !== 0) fail("unpacking the commit's tree failed");
86
+ // The package and its workspace dependencies, from the commit's lockfile only, offline from the store; no dependency's install scripts run.
87
+ const install = run("pnpm", ["install", "--frozen-lockfile", "--offline", "--ignore-scripts", "--ignore-pnpmfile", "--store-dir", checkoutStoreDir(o.repo), "--filter", `${o.pkg}...`], { cwd: tree, encoding: "utf8", maxBuffer: 1 << 28 });
88
+ if (install.status !== 0) fail(`pnpm install (offline, frozen lockfile) for ${o.pkg} failed: ${String(install.stderr || install.stdout || "").trim().split(/\r?\n/).slice(-3).join(" | ")}`);
89
+ // Workspace dependencies resolve through their dist/ (gitignored, so not in the export): build them first, in dependency order.
90
+ const deps = run("pnpm", ["-r", "--filter", `${o.pkg}^...`, "run", "--if-present", "build"], { cwd: tree, encoding: "utf8", maxBuffer: 1 << 28 });
91
+ if (deps.status !== 0) fail(`building ${o.pkg}'s workspace dependencies failed: ${String(deps.stderr || deps.stdout || "").trim().split(/\r?\n/).slice(-3).join(" | ")}`);
92
+ const pkgDir = path.join(tree, dir);
71
93
  const packed = run("pnpm", ["pack", "--pack-destination", work], { cwd: pkgDir, encoding: "utf8" });
72
94
  if (packed.status !== 0) fail(`pnpm pack failed: ${String(packed.stderr ?? packed.stdout ?? "").trim().split(/\r?\n/).slice(-3).join(" | ")}`);
73
95
  const tgz = fs.readdirSync(work).find((f) => f.endsWith(".tgz"));
@@ -49,7 +49,7 @@
49
49
  "@rightkit/qa": "0.6.2",
50
50
  "@rightkit/qa-chrome": "0.1.12",
51
51
  "@rightkit/react-shell": "0.7.2",
52
- "@rightkit/release": "0.6.35",
52
+ "@rightkit/release": "0.6.37",
53
53
  "@rightkit/settings-ui": "0.7.0",
54
54
  "@rightkit/social-ui": "0.1.0",
55
55
  "@rightkit/system-ui": "0.1.0",
@@ -502,7 +502,7 @@
502
502
  "rightkit-agent-plugins": "0.1.0",
503
503
  "rightkit-agent-policy": "0.1.0",
504
504
  "rightkit-agent-recipes": "0.1.0",
505
- "rightkit-agent-tools": "0.3.1",
505
+ "rightkit-agent-tools": "0.3.2",
506
506
  "rightkit-agent-transcript": "0.1.0",
507
507
  "rightkit-agents": "0.2.1",
508
508
  "rightkit-ai-accounts": "0.1.0",