@rightkit/release 0.6.36 → 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.
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.36",
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",
@@ -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.36",
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",