@rightkit/release 0.6.52 → 0.6.55

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.
Files changed (90) hide show
  1. package/README.md +6 -1
  2. package/adapter-env.mjs +16 -105
  3. package/admission-host.mjs +14 -1
  4. package/bin/darwin/rightkit-swap +0 -0
  5. package/bin/rightkit-gate.mjs +585 -404
  6. package/broker-admission.mjs +122 -2
  7. package/build-launch.mjs +52 -58
  8. package/build-release.mjs +2 -2
  9. package/cargo-ledger.mjs +24 -5
  10. package/cargo-target-shim.mjs +54 -23
  11. package/cargo-target.mjs +2 -2
  12. package/carried-adapter-run.mjs +7 -8
  13. package/carried-cargo-run.mjs +1 -1
  14. package/ci-compile-admission.mjs +1 -1
  15. package/clippy-route.mjs +65 -18
  16. package/compile-inputs.mjs +91 -15
  17. package/cross-targets.mjs +5 -3
  18. package/deps-cargo-lock.mjs +1 -1
  19. package/deterministic-scans.mjs +789 -259
  20. package/development.mjs +33 -7
  21. package/direct-receipt.mjs +3 -5
  22. package/feature-coverage.mjs +45 -9
  23. package/feature-partition.mjs +204 -0
  24. package/feature-sets.mjs +113 -0
  25. package/gate-acceptance.mjs +187 -115
  26. package/gate-seam.mjs +352 -0
  27. package/gate-serve.mjs +34 -2
  28. package/gate-stages.mjs +6 -2
  29. package/ghsa-audit.mjs +19 -4
  30. package/heavy-command.mjs +5 -4
  31. package/install-tauri-authenticode.mjs +73 -4
  32. package/ios-dev.mjs +3 -3
  33. package/ios-package-recipe.mjs +6 -6
  34. package/linux-setup.mjs +3 -2
  35. package/local-publish.mjs +113 -17
  36. package/lock-identity.mjs +24 -100
  37. package/managed-cargo.mjs +3 -3
  38. package/managed-root-guard.mjs +2 -2
  39. package/managed-roots.mjs +3 -3
  40. package/native-adapters.mjs +41 -244
  41. package/native-helpers.mjs +1 -1
  42. package/ownership-mandatory-set.json +16 -0
  43. package/pack-digest.mjs +1 -1
  44. package/package-recipe-targets.mjs +19 -11
  45. package/package.json +2 -2
  46. package/publication-gate.mjs +29 -6
  47. package/publish-cargo.mjs +4 -5
  48. package/publish-local-cargo.mjs +77 -1
  49. package/qualification-verify.mjs +76 -49
  50. package/receipt-signature.mjs +104 -0
  51. package/recipe-build.mjs +15 -2
  52. package/release-switch-registry.json +4 -0
  53. package/release-switch-scan.mjs +13 -10
  54. package/rightkit-versions.json +184 -170
  55. package/scan-digest.mjs +43 -14
  56. package/seam-broker.mjs +168 -0
  57. package/snapshot-check.mjs +4 -1
  58. package/snapshot-dependency-reuse.mjs +1 -1
  59. package/snapshot-metadata.mjs +24 -35
  60. package/snapshot.mjs +328 -49
  61. package/stage-commands.mjs +59 -5
  62. package/stage-ledger.mjs +2 -2
  63. package/{carried-cargo.mjs → stage-seam.mjs} +118 -70
  64. package/stage-sidecar.mjs +9 -7
  65. package/tauri-bundle-marker.mjs +5 -2
  66. package/tauri-locked.mjs +1 -1
  67. package/tool-build.mjs +8 -6
  68. package/unit-gate.mjs +40 -10
  69. package/broker-handshake.mjs +0 -160
  70. package/broker-wire.mjs +0 -278
  71. package/build-ownership.mjs +0 -1578
  72. package/cargo-shapes.mjs +0 -332
  73. package/cargo-width.mjs +0 -49
  74. package/carrier-census.mjs +0 -124
  75. package/clippy-equivalence.mjs +0 -202
  76. package/freshness-census.mjs +0 -405
  77. package/handle-revocation.mjs +0 -100
  78. package/handle-revocation.rust-vector.json +0 -1
  79. package/handle-revocation.vectors.json +0 -53
  80. package/legion-freeze-consumer.mjs +0 -241
  81. package/linux-qualifier.mjs +0 -83
  82. package/native-tool-planning.mjs +0 -94
  83. package/owner-process-proof.mjs +0 -14
  84. package/ownership-mark.mjs +0 -191
  85. package/ownership-recover.mjs +0 -78
  86. package/pnpm-adapter-grammar.mjs +0 -226
  87. package/provenance-verify.mjs +0 -413
  88. package/snapshot-broker.mjs +0 -808
  89. package/snapshot-request.mjs +0 -722
  90. package/unit-list-compile.mjs +0 -356
@@ -1,34 +1,51 @@
1
- // The carried seam of right-release's own broker calls on a broker host (rightkit#1301; GATE-CONTRACT "Commit-only build", item 7 rows
2
- // 7.20 and 7.24-R). ONE model: every compile of a snapshot stage is either a carried request of its own or nested under one.
1
+ // A snapshot door stage's children and the broker (reset plan section 3; kept by the plan): the stage map and ledger the gate hands its children, each child Cargo
2
+ // call and pnpm, node or QA step sent through the seam (`rustright cargo|run` with RUSTRIGHT_GATE_COMMIT and RUSTRIGHT_CLASS_A, seam-broker.mjs), the GC-A11 direct reads,
3
+ // and the readers the gate and later steps use (outputs by workspace, the Tauri bundle's target, the seam calls still unsettled for the door's lock).
3
4
  //
4
- // A right-release child of a snapshot door stage (dev, test, stage-sidecar, build, qa) reaches the broker in two carried ways:
5
- // - its Cargo calls (`runCargoSync`, which stage-sidecar, cargo-target and development use; a `cargo` step through build-launch.mjs):
6
- // this module's `runCarriedCargo`, one carried request per call through `carryBrokerCargo` (snapshot-broker.mjs): fresh nonce,
7
- // `primaryCwd` from the gate's snapshot-to-checkout map, the signed receipt verified, a ledger record either way. The call runs from the
8
- // manifest's directory and passes no `--manifest-path` and no output directory (the RustRight client refuses to rewrite an attested
9
- // call, and the broker pins the output), so `--manifest-path <p>` is turned into a working directory here, and the output directory the
10
- // caller needs is the receipt's `outputDir`, never a carrier-less `cargo metadata`;
11
- // - its pnpm, node and QA steps (build-launch.mjs routes them to carried-adapter-run.mjs): `runCarriedAdapter`, one carried ADAPTER
12
- // request per step through `carryBrokerAdapter` (rustright#190, snapshot-adapter-v1). The Tauri CLI, and any other child that compiles,
13
- // runs NESTED under that job (the broker attributes each compile by the parent's capability token); the broker signs the list of those
14
- // children (request id, argv, cwd, exit, outputDir) in the job's receipt, and the gate verifies it. A Tauri bundle's root is under the
15
- // `outputDir` of the signed child that built it (`carriedOutputDir`), never a directory the child reported.
16
- // There is no PATH wrapper and no stage grant: the carrier is the map and the ledger only, on every platform. The gate hands the child the
17
- // map file through `RIGHTKIT_CARRIED_CARGO_MAP` and reads the ledger after the child ends: a refused, unverified or unfinished call fails
18
- // the stage, and every verified call, nested children included, is verified again from the broker's receipt.
5
+ // A call without the seam variables is refused (RK_STAGE_NO_SEAM), never run some other way: the legacy carrier route is deleted (reset plan step 5).
19
6
  import fs from "node:fs";
20
7
  import os from "node:os";
21
8
  import path from "node:path";
22
9
  import { spawnSync } from "./background-process.mjs";
23
- import { appendLedger, readLedger, SCAN_TOKEN_ENV, UNSCOPED } from "./cargo-ledger.mjs";
10
+ import { CARGO_REFUSAL_STATUS, appendLedger, readLedger, readLedgerDir, SCAN_TOKEN_ENV } from "./cargo-ledger.mjs";
24
11
  import { SHIM_MAP_SCHEMA, directCargoShape, locateWorkspaceByWalk } from "./cargo-target-shim.mjs";
25
12
  import { directCargoPath } from "./managed-cargo.mjs";
26
- import { BROKER_REFUSAL_STATUS, carryBrokerAdapter, carryBrokerCargo, verifyBrokerLedger } from "./snapshot-broker.mjs";
27
- import { splitCarriedArgs } from "./snapshot-request.mjs";
13
+ import { runSeamAdapterCall, runSeamCargoCall, seamEnvPresent } from "./seam-broker.mjs";
28
14
 
29
15
  /** The environment variable that names the gate-written map of a snapshot stage's carried Cargo calls. */
30
16
  export const CARRIED_CARGO_MAP_ENV = "RIGHTKIT_CARRIED_CARGO_MAP";
31
17
  export const CARRIER_MISSING_CODE = "RK_CARGO_CARRIER_MISSING";
18
+ /** Exit status of a refusal: cargo's own error status, so every caller reads it as a failed cargo (cargo-ledger.mjs CARGO_REFUSAL_STATUS, shared with the wrapper and the carrier). */
19
+ export const STAGE_REFUSAL_STATUS = CARGO_REFUSAL_STATUS;
20
+
21
+ // Options that move a call's working directory, configuration or output (cargo's own `--config`, `-Z`, `-C`): never sent.
22
+ const STAGE_REDIRECT = /^(--config|-Z|-C)(=|$)|^-[A-Za-z]*[CZ]/;
23
+ /**
24
+ * A stage child's cargo arguments as sent: `--manifest-path <p>` taken out (the call runs from that manifest's directory instead) and any output, configuration or
25
+ * directory redirect refused. `{ words, manifestPath }` or `{ refusal: { code, message } }`. stage-commands.mjs says what a stage's signed requests show with it.
26
+ */
27
+ export function splitStageArgs(args) {
28
+ const original = [...args];
29
+ const words = [];
30
+ let manifestPath = null;
31
+ let atSeparator = false;
32
+ for (let i = 0; i < original.length; i += 1) {
33
+ const w = original[i];
34
+ if (atSeparator) { words.push(w); continue; }
35
+ if (w === "--") { atSeparator = true; words.push(w); continue; }
36
+ if (w === "--manifest-path" || w.startsWith("--manifest-path=")) {
37
+ const value = w === "--manifest-path" ? original[i + 1] : w.slice("--manifest-path=".length);
38
+ if (w === "--manifest-path") i += 1;
39
+ if (typeof value !== "string" || !value) return { refusal: { code: "RK_CARGO_BROKER_MANIFEST_PATH", message: "--manifest-path names no manifest" } };
40
+ manifestPath = value;
41
+ continue;
42
+ }
43
+ if (w === "--target-dir" || w.startsWith("--target-dir=")) return { refusal: { code: "RK_CARGO_REDIRECT", message: `\`cargo ${original.join(" ")}\` passes --target-dir; the broker pins a carried call's output directory` } };
44
+ if (STAGE_REDIRECT.test(w)) return { refusal: { code: "RK_CARGO_REDIRECT", message: `\`cargo ${original.join(" ")}\` passes ${w}, which moves its working directory, configuration or output` } };
45
+ words.push(w);
46
+ }
47
+ return { words, manifestPath };
48
+ }
32
49
 
33
50
  /** `null` (no carrier in this environment), `{ map }` or `{ error }` (a map that cannot be read: the call is refused, never run direct). */
34
51
  export function carriedCargoMapOf(env = process.env) {
@@ -52,14 +69,14 @@ function directCargoBin(env, platform = process.platform) {
52
69
 
53
70
  const refused = (code, message) => {
54
71
  const text = `rightkit-gate: ${code}: ${message}`;
55
- return { status: BROKER_REFUSAL_STATUS, signal: null, stdout: "", stderr: `${text}\n`, error: null, refusal: { code, message } };
72
+ return { status: STAGE_REFUSAL_STATUS, signal: null, stdout: "", stderr: `${text}\n`, error: null, refusal: { code, message } };
56
73
  };
57
74
 
58
75
  /**
59
- * One right-release Cargo call, carried. `args` are the cargo arguments (without `cargo`); `options` is the spawn options of the call
76
+ * One right-release Cargo call of a stage child: through the seam when its environment carries the two seam variables, else refused (RK_STAGE_NO_SEAM). `args` are the cargo arguments (without `cargo`); `options` is the spawn options of the call
60
77
  * (`cwd`, `env`, `stdio`). Returns a `spawnSync`-shaped result with `outputDir` (the receipt's) when the call verified.
61
78
  */
62
- export function runCarriedCargo(args, options = {}, { map, spawn = spawnSync, err = (m) => process.stderr.write(`${m}\n`) } = {}) {
79
+ export function runStageCargo(args, options = {}, { map, spawn = spawnSync, err = (m) => process.stderr.write(`${m}\n`) } = {}) {
63
80
  const env = options.env ?? process.env;
64
81
  const cwd = path.resolve(options.cwd ?? process.cwd());
65
82
  const token = env[SCAN_TOKEN_ENV];
@@ -72,8 +89,8 @@ export function runCarriedCargo(args, options = {}, { map, spawn = spawnSync, er
72
89
  err(`rightkit-gate: ${code}: ${message}`);
73
90
  return refused(code, message);
74
91
  };
75
- // The same function stage-commands.mjs uses to say what a stage's signed receipts must show (splitCarriedArgs, snapshot-request.mjs).
76
- const split = splitCarriedArgs(original);
92
+ // The same function stage-commands.mjs uses to say what a stage's signed receipts must show.
93
+ const split = splitStageArgs(original);
77
94
  if (split.refusal) return refuse(split.refusal.code, split.refusal.message);
78
95
  const { words } = split;
79
96
  if (split.manifestPath !== null) from = path.dirname(path.resolve(cwd, split.manifestPath));
@@ -107,36 +124,59 @@ export function runCarriedCargo(args, options = {}, { map, spawn = spawnSync, er
107
124
  try { record({ ...base, status: "ran", direct: true, exit: r.status ?? null }); } catch { /* the result is returned either way */ }
108
125
  return { status: r.status ?? 1, signal: r.signal ?? null, stdout: r.stdout ?? "", stderr: r.stderr ?? "", error: null };
109
126
  }
110
- const result = carryBrokerCargo({ words, cwd: from, env, section: map.broker, workspace, checkoutWorkspace: map.workspaces[workspace], record: (entry) => record({ ...entry, id: base.id }), spawn, err, stdio: capture });
111
- return { status: result.status, signal: null, stdout: result.stdout, stderr: result.stderr, error: null, ...(result.outcome?.status === "verified" ? { outputDir: result.outcome.outputDir, requestId: result.outcome.requestId, requestDigest: result.outcome.requestDigest } : {}), ...(result.outcome?.status === "refused" ? { refusal: { code: result.outcome.code, message: result.outcome.message } } : {}) };
127
+ // The seam (reset plan section 3): a compile from a stage child whose environment carries the two seam variables is `rustright cargo <words>` in its snapshot workspace,
128
+ // judged by its result line and receipt and filed for the parent; it never goes through the carrier, which the broker refuses under a held seam lock.
129
+ if (seamEnvPresent(env)) {
130
+ // The pending row goes in BEFORE the broker sees the call: a stage child killed or cancelled during the call leaves this row unsettled, so the door keeps its lock.
131
+ // A pending row that cannot be written stops the call before submission (nothing is admitted that the parent cannot see).
132
+ try { record({ ...base, mode: "seam", workspace: map.workspaces[workspace], status: "pending", settled: false }); }
133
+ catch (error) { return refuse("RK_CARGO_LEDGER", `the seam call cannot be filed for the parent before it is sent (${error.message}); nothing was submitted`); }
134
+ const { result, ledger } = runSeamCargoCall(words, { cwd: from, env, stdio: capture === "inherit" ? "inherit" : "pipe", client: map?.broker?.client ?? "rustright", spawnSync: spawn });
135
+ try { record({ ...base, mode: "seam", workspace: map.workspaces[workspace], ...ledger }); }
136
+ catch (error) { return { ...result, status: result.status === 0 ? 1 : result.status, error: null, refusal: { code: "RK_CARGO_LEDGER", message: `the seam call's outcome could not be filed for the parent (${error.message})` } }; }
137
+ if (result.refusal) err(`rightkit-gate: ${result.refusal.code}: ${result.refusal.message}`);
138
+ return result;
139
+ }
140
+ return refuse("RK_STAGE_NO_SEAM", `\`cargo ${words.join(" ")}\` compiles, and this stage child does not carry the seam variables; nothing was sent`);
112
141
  }
113
142
 
114
143
  /**
115
- * One right-release pnpm, node or QA step, carried as a broker adapter job. `adapter` is the registered adapter (`rightkit-pnpm`,
144
+ * One right-release pnpm, node or QA step of a stage child: through the seam (`rustright run <adapter> -- <args>`), else refused (RK_STAGE_NO_SEAM). `adapter` is the registered adapter (`rightkit-pnpm`,
116
145
  * `rightkit-node`, `rightkit-qa`), `args` the adapter's arguments (what follows `--` in `rustright run <adapter> -- <args>`); `options` is
117
- * the spawn options of the step (`cwd`, `env`, `stdio`). Returns a `spawnSync`-shaped result with `outputDir` (the job's) and
118
- * `nestedChildren` (the verified signed list), `requestId` and, for a native build tool, `executable.managedOutputs` (the output mapping the broker signed) when the call verified.
146
+ * the spawn options of the step (`cwd`, `env`, `stdio`). Returns a `spawnSync`-shaped result with `outputDir` (the job's) and `requestId` when the call verified.
119
147
  */
120
- export function runCarriedAdapter(adapter, args, options = {}, { map, spawn = spawnSync, err = (m) => process.stderr.write(`${m}\n`) } = {}) {
148
+ export function runStageAdapter(adapter, args, options = {}, { map, spawn = spawnSync, err = (m) => process.stderr.write(`${m}\n`) } = {}) {
121
149
  const env = options.env ?? process.env;
122
150
  const cwd = path.resolve(options.cwd ?? process.cwd());
123
151
  const token = env[SCAN_TOKEN_ENV];
124
- const result = carryBrokerAdapter({ adapter, words: args, cwd, env, section: map.broker, record: (entry) => appendLedger(map.ledgerDir, token, entry), spawn, err, stdio: options.stdio === "inherit" ? "inherit" : "capture" });
125
- const verified = result.outcome?.status === "verified";
126
- return {
127
- status: result.status, signal: null, stdout: result.stdout, stderr: result.stderr, error: null,
128
- ...(verified ? { outputDir: result.outcome.outputDir, requestId: result.outcome.requestId, nestedChildren: result.outcome.nestedChildren, ...(result.executable ? { executable: result.executable } : {}) } : {}),
129
- ...(result.outcome?.status === "refused" ? { refusal: { code: result.outcome.code, message: result.outcome.message } } : {}),
130
- };
152
+ // The seam (reset plan section 3): a stage child whose environment carries RUSTRIGHT_GATE_COMMIT and RUSTRIGHT_CLASS_A runs its adapter as `rustright run <adapter> -- <args>`
153
+ // (seam-broker.mjs), never as a carried request; the outcome is filed in the stage's ledger so the parent judges it (carrier.finish) and the door's lock release
154
+ // sees an unsettled call (seamUnsettled).
155
+ if (seamEnvPresent(env)) {
156
+ // The adapter's checkout workspace (the snapshot workspace its cwd is in), so the stage's output readers map its receipt's outputDir: the broker signs the adapter
157
+ // job's pinned target there, and a compile the adapter starts (`tauri build`) uses that same target (rustright normalize_impl.rs, adapter parent).
158
+ const snaps = adapterSnapshotWorkspaces(map.workspaces ?? {}, cwd);
159
+ const row = { id: `${process.pid}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`, mode: "seam", shim: "adapter", cwd, argv: args, adapter, workspaces: snaps.map((w) => map.workspaces[w]) };
160
+ // Pending before submission, as for a seam cargo call: a child killed during the call leaves it unsettled; a pending row that cannot be written submits nothing.
161
+ try { appendLedger(map.ledgerDir, token, { ...row, status: "pending", settled: false }); }
162
+ catch (error) { const message = `the seam call cannot be filed for the parent before it is sent (${error.message}); nothing was submitted`; err(`rightkit-gate: RK_CARGO_LEDGER: ${message}`); return refused("RK_CARGO_LEDGER", message); }
163
+ const { result, ledger } = runSeamAdapterCall(adapter, args, { cwd, env, stdio: options.stdio === "inherit" ? "inherit" : "pipe", client: map?.broker?.client ?? "rustright", spawnSync: spawn });
164
+ try { appendLedger(map.ledgerDir, token, { ...row, ...ledger }); }
165
+ catch (error) { return { ...result, status: result.status === 0 ? 1 : result.status, refusal: { code: "RK_CARGO_LEDGER", message: `the seam call's outcome could not be filed for the parent (${error.message})` } }; }
166
+ return result;
167
+ }
168
+ const message = `the ${adapter} step does not carry the seam variables; nothing was sent`;
169
+ err(`rightkit-gate: RK_STAGE_NO_SEAM: ${message}`);
170
+ return refused("RK_STAGE_NO_SEAM", message);
131
171
  }
132
172
 
133
173
  /**
134
174
  * Writes the carrier of one snapshot stage's children under `base` and returns what to hand them: the map and the ledger only, on every
135
175
  * platform (no PATH wrapper, no stage grant: a compile a child makes is nested under a carried adapter job, rustright#190). `checkoutDirs`
136
176
  * is the gate's { [cargoDir]: absolute path of that workspace in the primary checkout }; `section` the public part of the gate's
137
- * snapshot broker (brokerSection). Returns `{ env, ledgerDir, dir, mode, problems(sb), cleanup() }`; `env` is the delta to add.
177
+ * snapshot broker (the `broker` section the map files for the client). Returns `{ env, ledgerDir, dir, mode, problems(), cleanup() }`; `env` is the delta to add.
138
178
  */
139
- export function installCarrier({ base, snapshotRoot, checkoutDirs, section, known = {}, realpath = (p) => fs.realpathSync.native(p), onDir = () => {} }) {
179
+ export function installStageCarrier({ base, snapshotRoot, checkoutDirs, section, known = {}, realpath = (p) => fs.realpathSync.native(p), onDir = () => {} }) {
140
180
  const dir = fs.mkdtempSync(path.join(base, "rk-carrier-"));
141
181
  onDir(dir);
142
182
  try {
@@ -160,34 +200,44 @@ const deepestSnapshotRoot = (workspaces, file) => {
160
200
  return Object.keys(workspaces).filter((r) => real === r || real.startsWith(`${r}${path.sep}`)).sort((a, b) => b.length - a.length)[0] ?? null;
161
201
  };
162
202
 
163
- /** The verified calls' signed output directories: a cargo call's, an adapter job's own and each of its nested children's. */
164
- const outputsOf = (entry) => [
165
- ...(typeof entry.outputDir === "string" ? [entry.outputDir] : []),
166
- ...(entry.shim === "adapter" && Array.isArray(entry.nestedChildren) ? entry.nestedChildren.map((c) => c.outputDir).filter((d) => typeof d === "string") : []), // a child that compiles nothing has outputDir null
167
- ];
203
+ /**
204
+ * The snapshot Cargo workspaces an adapter job's compiles may build, as keys of `workspaces`: every one at or under its cwd (a Tauri app's `tauri build` runs from the app
205
+ * root and compiles its `src-tauri`, even when the app itself sits inside an outer workspace), else the deepest one its cwd is in. The broker pins every compile an adapter
206
+ * job starts to that job's own target (rustright normalize_impl.rs: an adapter parent's target), so the receipt's outputDir is each of these workspaces' output.
207
+ */
208
+ function adapterSnapshotWorkspaces(workspaces, cwd) {
209
+ let real = cwd;
210
+ try { real = fs.realpathSync.native(cwd); } catch { /* as given */ }
211
+ const under = Object.keys(workspaces).filter((r) => r === real || r.startsWith(`${real}${path.sep}`)).sort();
212
+ if (under.length) return under;
213
+ const inside = deepestSnapshotRoot(workspaces, cwd);
214
+ return inside ? [inside] : [];
215
+ }
216
+
217
+ /** The verified calls' receipt output directories: a cargo call's and an adapter job's own. */
218
+ const outputsOf = (entry) => (typeof entry.outputDir === "string" ? [entry.outputDir] : []);
168
219
 
169
220
  function finish(ledgerDir, dir, workspaces = {}) {
170
221
  const checkoutRoots = Object.values(workspaces);
171
222
  return {
172
- /** Every call of the stage that is not a completed, verified success, and every verified call the gate cannot verify again itself. */
173
- async problems(sb, opts = {}) {
174
- const { entries, problems } = readLedger(ledgerDir, UNSCOPED);
175
- const out = [...problems];
176
- if (sb) out.push(...await verifyBrokerLedger(entries, sb, opts));
177
- return out;
223
+ /** Every call of the stage that is not a completed, verified success (every ledger file of the stage; an unreadable record is a problem). */
224
+ async problems() {
225
+ const { problems } = readLedgerDir(ledgerDir);
226
+ return [...problems];
178
227
  },
179
- /** The verified calls' output directories, in call order (the receipts'; an adapter job's nested children's included). */
180
- outputDirs() { return readLedger(ledgerDir, UNSCOPED).entries.filter((e) => e.status === "verified").flatMap(outputsOf); },
181
- /** The verified compiles' output directories by checkout workspace root: `[[root, outputDir]]`, the last call of a workspace winning. A nested child counts for the workspace its cwd is in. */
228
+ /** The seam calls of the stage's children that have no settled outcome (the door keeps its snapshot lock when any exist; reset plan section 3). */
229
+ // Every file of the stage's ledger (a child that carried a scan token files under it), and every record that cannot be read as a call: its owner is unknown.
230
+ seamUnsettled() { const { entries, malformed } = readLedgerDir(ledgerDir); return entries.filter((e) => e.mode === "seam" && e.settled !== true).length + malformed; },
231
+ /** The verified calls' output directories, in call order (the receipts'). */
232
+ outputDirs() { return readLedgerDir(ledgerDir).entries.filter((e) => e.status === "verified").flatMap(outputsOf); },
233
+ /** The verified compiles' output directories by checkout workspace root: `[[root, outputDir]]`, the last call of a workspace winning. */
182
234
  outputsByWorkspace() {
183
235
  const out = new Map();
184
- for (const e of readLedger(ledgerDir, UNSCOPED).entries) {
236
+ for (const e of readLedgerDir(ledgerDir).entries) {
185
237
  if (e.status !== "verified") continue;
186
- if (e.shim === "adapter") {
187
- for (const child of Array.isArray(e.nestedChildren) ? e.nestedChildren : []) {
188
- const snap = typeof child.cwd === "string" ? deepestSnapshotRoot(workspaces, child.cwd) : null;
189
- if (snap && typeof child.outputDir === "string") out.set(workspaces[snap], child.outputDir);
190
- }
238
+ // A seam adapter job (reset plan section 3) has no signed child list: its receipt's outputDir is the target its own compiles used, filed with its workspace.
239
+ if (e.shim === "adapter" && e.mode === "seam") {
240
+ for (const ws of Array.isArray(e.workspaces) ? e.workspaces : []) if (typeof e.outputDir === "string" && typeof ws === "string") out.set(ws, e.outputDir);
191
241
  continue;
192
242
  }
193
243
  if (typeof e.outputDir !== "string" || typeof e.workspace !== "string") continue;
@@ -234,8 +284,8 @@ export function carriedAdapterOutputDir(env, adapter, before = new Set()) {
234
284
 
235
285
  /**
236
286
  * The output directory of the workspace a manifest belongs to, from a signed receipt, or null: a verified call this child already made
237
- * in that workspace (a build, whose receipt names the broker's pinned `outputDir`, or a nested child of a carried adapter job, whose entry in
238
- * the job's signed list names the compile's own `outputDir`), else one an earlier stage of the door run
287
+ * in that workspace (a build, whose receipt names the broker's pinned `outputDir`, or a seam adapter job, whose receipt names the one target its own compiles
288
+ * used), else one an earlier stage of the door run
239
289
  * verified (the map's `knownOutputDirs`, seeded by the gate). Asking Cargo for it (a read-only `metadata` call) is a snapshot request
240
290
  * the broker does not accept today (rightkit#1301 F1), so a caller asks here first and only then falls back to a carried call.
241
291
  */
@@ -251,19 +301,17 @@ export function carriedOutputDir(env, manifestPath, { preferNested = false } = {
251
301
  if (!root) return null;
252
302
  let entries = [];
253
303
  try { entries = readLedger(map.ledgerDir, env[SCAN_TOKEN_ENV]).entries; } catch { entries = []; }
254
- // The signed output directories of this workspace's compiles, in call order: a carried cargo call's receipt, or a nested child of a
255
- // carried adapter job (the Tauri CLI's own compile), by the directory the child ran in.
304
+ // The receipts' output directories of this workspace's compiles, in call order: a seam cargo call's, or a seam adapter job's (the Tauri CLI's own compile).
256
305
  const mine = []; const nested = [];
257
306
  for (const e of entries) {
258
307
  if (e.status !== "verified") continue;
259
- if (e.shim === "adapter") {
260
- for (const child of Array.isArray(e.nestedChildren) ? e.nestedChildren : []) {
261
- const snap = typeof child.cwd === "string" ? deepestSnapshotRoot(map.workspaces, child.cwd) : null;
262
- if (snap && map.workspaces[snap] === root && typeof child.outputDir === "string") { mine.push(child.outputDir); nested.push(child.outputDir); }
263
- }
308
+ // A seam adapter job's receipt names the one target the adapter and every compile it starts used (rustright normalize_impl.rs: an adapter parent's own target),
309
+ // so for a Tauri bundle it is the bundle root's target.
310
+ if (e.shim === "adapter" && e.mode === "seam") {
311
+ if (typeof e.outputDir === "string" && Array.isArray(e.workspaces) && e.workspaces.includes(root)) { mine.push(e.outputDir); nested.push(e.outputDir); }
264
312
  } else if (typeof e.outputDir === "string" && typeof e.workspace === "string" && deepestRoot(Object.values(map.workspaces), e.workspace) === root) mine.push(e.outputDir);
265
313
  }
266
- // A Tauri bundle's root is under the compile the Tauri CLI itself made: the nested child's, when one is signed, whatever carried Cargo call came after it.
314
+ // A Tauri bundle's root is under the compile the Tauri CLI itself made: the adapter job's, when one is filed, whatever Cargo call came after it.
267
315
  if (preferNested && nested.length) return nested.at(-1);
268
316
  if (mine.length) return mine.at(-1);
269
317
  const known = map.knownOutputDirs?.[root];
package/stage-sidecar.mjs CHANGED
@@ -38,7 +38,7 @@ import os from "node:os";
38
38
  import path from "node:path";
39
39
  import { spawnSync as nodeSpawnSync } from "./background-process.mjs";
40
40
  import { resolveCommand } from "./development.mjs";
41
- import { carriedCargoMapOf } from "./carried-cargo.mjs";
41
+ import { carriedCargoMapOf } from "./stage-seam.mjs";
42
42
  import { BUILD_LAUNCH_REFUSED, buildLaunch } from "./build-launch.mjs";
43
43
  import { directCargoPath, directHost, managedHost, nonCompilingCargoEnv, runCargoSync } from "./managed-cargo.mjs";
44
44
  import { snapshotCargoMetadata } from "./gate-serve.mjs";
@@ -972,7 +972,7 @@ function splitRoots(ctx) {
972
972
  */
973
973
  function splitCommandEnv(ctx) {
974
974
  if (!ctx.split) return ctx.env;
975
- // A carried stage (carried-cargo.mjs): the broker pins every Cargo output, so nothing is pinned here and the commands inherit the carrier.
975
+ // A carried stage (stage-seam.mjs): the broker pins every Cargo output, so nothing is pinned here and the commands inherit the carrier.
976
976
  if (carriedCargoMapOf(ctx.env)?.map) return ctx.env;
977
977
  if (ctx.splitEnv === undefined) {
978
978
  const pinned = snapshotTargetDirectory(ctx, ctx.env, null); // no Cargo workspace in the snapshot: nothing to pin
@@ -1107,7 +1107,7 @@ function stageCargoBuild(entry, ctx, triple) {
1107
1107
  // resolved in the checkout instead and passed as an absolute CARGO_TARGET_DIR, so the warm outputs stay the checkout's and the
1108
1108
  // snapshot holds no target/ (docs/GATE-CONTRACT.md "Output directory & cache").
1109
1109
  let buildEnv = env;
1110
- // A carried stage (carried-cargo.mjs, a broker host): the broker pins the output directory and the call passes no CARGO_TARGET_DIR;
1110
+ // A carried stage (stage-seam.mjs, a broker host): the broker pins the output directory and the call passes no CARGO_TARGET_DIR;
1111
1111
  // the directory the binary is read from is the signed receipt's `outputDir`, never a carrier-less `cargo metadata`.
1112
1112
  const carried = Boolean(carriedCargoMapOf(env)?.map);
1113
1113
  if (ctx.split && !carried) {
@@ -1157,15 +1157,17 @@ function resolveLocalFfmpegSource(ctx, spec, tool) {
1157
1157
  }
1158
1158
 
1159
1159
  /**
1160
- * Fetch the bytes of the catalog rows that `ffmpeg.sources` names (a local `path` is copied, never downloaded): an archive pinned by digest, one member unpacked, the
1160
+ * Fetch the bytes of the catalog rows that `ffmpeg.sources` names, or the rows' own pinned archives when it names none (a local `path` is copied, never downloaded): an archive pinned by digest, one member unpacked, the
1161
1161
  * member's digest checked against the APPROVED catalog row (so a swapped archive can never stage). A staged file that already
1162
1162
  * matches its row is left alone.
1163
1163
  */
1164
1164
  async function fetchFfmpegSources(entry, ctx, plan, arch) {
1165
- if (!entry.sources) return;
1165
+ // No `sources` and no `stage` command: the catalog row's own pinned archive is the source (as the native-library kind does).
1166
+ if (!entry.sources && entry.stage) return;
1166
1167
  const { fs } = ctx;
1167
- for (const file of plan.files) {
1168
- const spec = ffmpegSourceFor(entry.sources, file.tool, arch);
1168
+ for (const [index, file] of plan.files.entries()) {
1169
+ const archive = plan.rows?.[index]?.archive;
1170
+ const spec = entry.sources ? ffmpegSourceFor(entry.sources, file.tool, arch) : archive && { url: archive.url, sha256: archive.sha256, member: archive.member ?? file.tool };
1169
1171
  if (!spec) continue;
1170
1172
  if (fs.existsSync(file.stagedPath) && catalogContentDigest(fs.readFileSync(file.stagedPath), arch) === file.contentSha256) {
1171
1173
  ctx.log(`stage-sidecar: ${rel(ctx, file.stagedPath)} already staged`);
@@ -56,11 +56,14 @@ export function patchTauriBundleType(file, { bundle = "nsis", read = readFileSyn
56
56
  const targetOffsets = findAll(before, targetMarker);
57
57
 
58
58
  if (unknownOffsets.length === 0) {
59
- if (targetOffsets.length === 1) {
59
+ // Already patched. tauri-utils 2.10 also compiles the match literal of the target marker into the binary (platform.rs bundle_type), so a
60
+ // patched binary of that line carries two target markers, the patched static next to the literal (rightkit#1556); an older Tauri, one.
61
+ // A warm rebuild that reuses the already patched (and signed) output therefore finds 0 unknown and 1 or 2 target markers.
62
+ if (targetOffsets.length === 1 || targetOffsets.length === 2) {
60
63
  return {
61
64
  file: resolved,
62
65
  bundle,
63
- offset: targetOffsets[0],
66
+ offset: targetOffsets[targetOffsets.length - 1],
64
67
  changedBytes: 0,
65
68
  alreadyPatched: true,
66
69
  size: before.length,
package/tauri-locked.mjs CHANGED
@@ -8,7 +8,7 @@
8
8
  // tauri dev -- --locked -- <appArgs> when app arguments are passed, --locked stays before the second `--`.
9
9
  // So `--locked` goes right after the first `--` (added with its own `--` when the step has none). A step that already names `--locked`
10
10
  // or `--frozen` among the Cargo arguments is left as it is.
11
- import { carriedCargoMapOf } from "./carried-cargo.mjs";
11
+ import { carriedCargoMapOf } from "./stage-seam.mjs";
12
12
 
13
13
  /** `args` of a step that may run the Tauri CLI, with `--locked` forwarded to Cargo in a carried stage; unchanged otherwise. */
14
14
  export function lockedTauriArgs(args, env = process.env) {
package/tool-build.mjs CHANGED
@@ -2,7 +2,7 @@
2
2
  //
3
3
  // Release QA runs only an ENROLLED rightkit-qa runner of the exact version an app's `qa.version` names (qa-runner.mjs). The unit stages cannot
4
4
  // make that binary: `--to compile|package --unit cargo:rightkit-qa` runs the unit's test plan and packs a .crate, and refuses a version that is
5
- // already on crates.io (local-publish.mjs); `cargo install` is denied (cargo-shapes.mjs). This route is the one sanctioned way to produce it:
5
+ // already on crates.io (local-publish.mjs); `cargo install` is denied (RK_COMMAND_DENIED at the broker, command_policy.rs). This route is the one sanctioned way to produce it:
6
6
  //
7
7
  // 1. the unit's class A check (the compile tier), exactly as a unit stage runs it;
8
8
  // 2. `cargo build --release --locked --bin <bin>` in the unit's own Cargo workspace of the selected commit's snapshot, through the same executor,
@@ -40,7 +40,7 @@ export class ToolBuildError extends Error {
40
40
  }
41
41
  const refuse = (code, message) => { throw new ToolBuildError(code, message); };
42
42
 
43
- /** The cargo arguments of the build (no `cargo`): the one shape the broker admits as a compile and a stage grant carries (cargo-shapes.mjs). */
43
+ /** The cargo arguments of the build (no `cargo`): the one shape the broker admits as a compile and a stage grant carries. */
44
44
  export const toolBuildArgs = (bin) => ["build", "--release", "--locked", "--bin", bin];
45
45
 
46
46
  /**
@@ -67,11 +67,13 @@ const sha256OfFile = (file) => crypto.createHash("sha256").update(fs.readFileSyn
67
67
 
68
68
  /**
69
69
  * The built binary under `outputDir` (the target directory: the carried receipt's `outputDir` on a broker host, the checkout's pinned target on a direct
70
- * one): `<outputDir>/release/<executable>`, a regular file the build just wrote, never a link. Returns its path or throws.
70
+ * one): `<outputDir>/<targetTriple>/release/<executable>` when the receipt names its target, else the direct layout
71
+ * `<outputDir>/release/<executable>`. Never falls back from a missing target-qualified output to stale direct bytes.
71
72
  */
72
- export function builtToolBinary({ outputDir, executable }) {
73
+ export function builtToolBinary({ outputDir, executable, targetTriple = null }) {
73
74
  if (typeof outputDir !== "string" || !path.isAbsolute(outputDir)) refuse("RK_TOOL_NO_OUTPUT_DIR", `the build reported no absolute output directory (${JSON.stringify(outputDir ?? null)}); the produced binary cannot be located, so nothing was enrolled`);
74
- const file = path.join(outputDir, "release", executable);
75
+ if (targetTriple !== null && (typeof targetTriple !== "string" || !/^[A-Za-z0-9_]+(?:-[A-Za-z0-9_]+)+$/.test(targetTriple))) refuse("RK_TOOL_NO_BINARY", "invalid receipt target triple; nothing was enrolled");
76
+ const file = path.join(outputDir, ...(targetTriple ? [targetTriple] : []), "release", executable);
75
77
  let meta;
76
78
  try { meta = fs.lstatSync(file); } catch (error) { refuse("RK_TOOL_NO_BINARY", `the build succeeded but ${file} does not exist (${error.code ?? error.message}); nothing was enrolled`); }
77
79
  if (meta.isSymbolicLink() || !meta.isFile()) refuse("RK_TOOL_NO_BINARY", `${file} is not a regular file; nothing was enrolled`);
@@ -120,7 +122,7 @@ export async function runUnitTool({
120
122
  throw new Error(`${selector}: cargo ${plan.argv.join(" ")} failed (${result?.error?.message ?? `exit ${result?.status}`})\nstdout:\n${String(result?.stdout ?? "").slice(-4000)}\nstderr:\n${String(result?.stderr ?? "").slice(-4000)}`);
121
123
  }
122
124
  // A carried (broker) call names the receipt's output directory; a direct call wrote the checkout target the gate pinned for this workspace.
123
- built = builtToolBinary({ outputDir: result.outputDir ?? pinnedTargetDir(targetDirs, plan.cargoDir), executable: plan.executable });
125
+ built = builtToolBinary({ outputDir: result.outputDir ?? pinnedTargetDir(targetDirs, plan.cargoDir), executable: plan.executable, targetTriple: result.targetTriple ?? null });
124
126
  } finally { endRun(doorRun); }
125
127
  if (stageGuard && !(await stageGuard.end(TOOL_STAGE))) throw new Error(`RK_CHECK_ERROR: the ${TOOL_STAGE} stage's result covers no known bytes (a snapshot byte changed, a write is outside the ledger, or a cargo call did not complete)`);
126
128
  const builtSha256 = sha256OfFile(built);
package/unit-gate.mjs CHANGED
@@ -11,12 +11,11 @@ import { spawnSync as nodeSpawnSync } from "./background-process.mjs";
11
11
  import { endRun, startRun, stagesTo } from "./gate-stages.mjs";
12
12
  import { RIGHTKIT_REPOSITORY, buildDirectOrigin, directStageEvidence, verifyDirectOrigin } from "./direct-origin.mjs";
13
13
  import { exclusionsFor } from "./pack-digest.mjs";
14
- import { ATTEST_STAGE_NONCE_ENV, qualificationNonce } from "./provenance-verify.mjs";
15
14
  import { verifyQualificationReceipts } from "./qualification-verify.mjs";
16
- import { ciCompileIdentity, ciCompileStageNonce, makeCiCompileProof, verifyCiCompileProof } from "./ci-compile-admission.mjs";
15
+ import { makeCiCompileProof, verifyCiCompileProof } from "./ci-compile-admission.mjs";
17
16
  import { assignJobs, describeCommand, directRowsNotRun, expectedStageCommands } from "./stage-commands.mjs";
18
- import { carriedCargoMapOf } from "./carried-cargo.mjs";
19
- import { UNSCOPED, readLedger } from "./cargo-ledger.mjs";
17
+ import { carriedCargoMapOf } from "./stage-seam.mjs";
18
+ import { UNSCOPED, readLedger, readLedgerDir } from "./cargo-ledger.mjs";
20
19
  import { resolveManagedRoots } from "./managed-roots.mjs";
21
20
  import { controlPlaneProblem } from "./control-plane.mjs";
22
21
 
@@ -61,6 +60,29 @@ export function readBrokerReceipt(id, { run = defaultRun, platform = process.pla
61
60
  if (receipt?.id !== id || !receipt.provenance?.payload || !receipt.provenance.signature) throw new Error(`job ${id} has no signed provenance receipt`);
62
61
  return { id, provenance: receipt.provenance };
63
62
  }
63
+ /**
64
+ * The signed broker receipts of the seam calls a stage's children filed in the stage ledger (reset plan section 3; stage-seam.mjs and cargo-target-shim.mjs file
65
+ * `mode: "seam"` rows with `status`, `requestId`, `receipt` (the durable receipt's absolute path) and `receiptSha256`). Only a `verified` row that is not in `before` (the
66
+ * ledger's ids before the stage ran) counts; its receipt file is read, its sha256 must equal the ledger's, its own id must be the row's request id, and it must carry a signed
67
+ * provenance envelope. Returns `{ id, provenance }` per distinct job, in ledger order: the shape the qualification carries and CI's publication admission verifies. A row whose
68
+ * receipt cannot be read or does not match its digest is an error: an unauthenticated qualification is worth nothing, and a silently skipped row would hide the failure.
69
+ */
70
+ export function readSeamStageReceipts(ledgerDir, before = new Set(), { readFile = (file) => fs.readFileSync(file) } = {}) {
71
+ const rows = readLedgerDir(ledgerDir).entries.filter((e) => e.mode === "seam" && e.status === "verified" && !before.has(e.id));
72
+ const out = new Map();
73
+ for (const row of rows) {
74
+ const call = `${row.adapter ?? "cargo"} ${(row.argv ?? []).join(" ")}`.trim();
75
+ if (typeof row.receipt !== "string" || !path.isAbsolute(row.receipt) || !/^[0-9a-f]{64}$/.test(row.receiptSha256 ?? "")) throw new Error(`the seam call ${call} is filed verified without its receipt path and sha256`);
76
+ let bytes;
77
+ try { bytes = readFile(row.receipt); } catch (error) { throw new Error(`the receipt ${row.receipt} of the seam call ${call} cannot be read (${error.code ?? error.message})`); }
78
+ if (hash(bytes) !== row.receiptSha256) throw new Error(`the receipt ${row.receipt} of the seam call ${call} is not the file its ledger row recorded (sha256 differs)`);
79
+ let receipt;
80
+ try { receipt = JSON.parse(Buffer.from(bytes).toString("utf8")); } catch { throw new Error(`the receipt ${row.receipt} of the seam call ${call} is not JSON`); }
81
+ if (typeof receipt?.id !== "string" || !receipt.id || (typeof row.requestId === "string" && receipt.id !== row.requestId) || !receipt.provenance?.payload || !receipt.provenance.signature) throw new Error(`the receipt ${row.receipt} of the seam call ${call} is not the signed receipt of request ${row.requestId}`);
82
+ if (!out.has(receipt.id)) out.set(receipt.id, { id: receipt.id, provenance: receipt.provenance });
83
+ }
84
+ return [...out.values()];
85
+ }
64
86
  /** `<bundle>/qualification.json`: the local stages that passed and the one artifact sha256 they bound, for the dispatcher. */
65
87
  export function writeQualification({ report, artifact, unit, commit, tree, runtime, executor, directOrigin = null, write = fs.writeFileSync }) {
66
88
  for (const stage of ["check", "compile", "package", "qualify"]) if (report.stages?.[stage]?.ok !== true) throw new Error(`release needs stage ${stage} ok before it runs`);
@@ -387,8 +409,7 @@ export async function runUnitGate({ selector, to, root, commonDir, commit, tree,
387
409
  };
388
410
  const stageEnv = async (stage, action) => {
389
411
  const run = startRun({ commonDir, commit, tree, stage });
390
- const nonce = attested && ATTESTED_STAGES.includes(stage) ? { [ATTEST_STAGE_NONCE_ENV]: (ciProof ? ciCompileStageNonce(ciCompileIdentity({ commit, tree })) : qualificationNonce({ commit, tree, unit: `${unit.kind}:${unit.name}`, stage })) } : {};
391
- try { return await action({ ...env, ...envExtra, ...nonce, ...run.env }); } finally { endRun(run); }
412
+ try { return await action({ ...env, ...envExtra, ...run.env }); } finally { endRun(run); }
392
413
  };
393
414
  // The hosted admission's own verification of the qualification's receipts, run here against the commit before anything is dispatched
394
415
  // (or, for --to qualify, before the run reports success): what it would refuse, this refuses first, naming why.
@@ -402,11 +423,18 @@ export async function runUnitGate({ selector, to, root, commonDir, commit, tree,
402
423
  catch (error) { throw new Error(`the local check of the qualification's signed broker receipts failed; the hosted admission would refuse it, so nothing is dispatched: ${String(error.message).replace(/^publication admission refused: /, "")}`); }
403
424
  };
404
425
  const receipts = {};
405
- const collectReceipts = (stage, ids) => {
426
+ // The stage ledger's ids before a stage runs, so the seam calls the stage filed are told from an earlier stage's (the one door ledger holds every stage's).
427
+ const stageLedgerDir = () => { const carried = carriedCargoMapOf(envExtra); return carried?.map?.ledgerDir ?? null; };
428
+ const ledgerIds = () => { const dir = stageLedgerDir(); if (!dir) return new Set(); try { return new Set(readLedgerDir(dir).entries.map((e) => e.id)); } catch { return new Set(); } };
429
+ const collectReceipts = (stage, ids, before = new Set()) => {
406
430
  if (!attested || !ATTESTED_STAGES.includes(stage)) return;
407
431
  // Every job of the stage is fetched; the stage owes a signed receipt for EVERY command it runs (hosted admission requires the same),
408
432
  // so a missing one fails here, before any dispatch, naming it. Jobs that are none of the stage's commands are not carried.
409
- const fetched = [...new Set(ids ?? [])].map((id) => fetchReceipt(id));
433
+ // A carrier-era job is fetched by id from the broker (`rustright status`); a seam call's receipt is the durable file its ledger row names (readSeamStageReceipts).
434
+ // A stage's children are one or the other; a stage with both carries both and the hosted admission refuses the mix.
435
+ const dir = stageLedgerDir();
436
+ const seamReceipts = dir ? readSeamStageReceipts(dir, before) : [];
437
+ const fetched = [...[...new Set(ids ?? [])].filter((id) => !seamReceipts.some((r) => r.id === id)).map((id) => fetchReceipt(id)), ...seamReceipts];
410
438
  // A carried cargo command is bound to the directory of the primary checkout it ran in (source.checkout; stage-commands.mjs requestIs).
411
439
  const rows = stageCommands({ unit, root, platform })[stage];
412
440
  const { assigned, missing } = assignJobs(rows, fetched.map((r) => ({ id: r.id, payload: r.provenance.payload })), { checkout: source?.checkout ?? null });
@@ -433,12 +461,14 @@ export async function runUnitGate({ selector, to, root, commonDir, commit, tree,
433
461
  if (stage === "check") { checkTier = stages.includes("qualify") ? "release" : "compile"; if (await check(checkTier) !== 0) throw new Error(`class A check (${checkTier} tier) failed`); }
434
462
  else if (stage === "compile") {
435
463
  owner = await loadOwner();
464
+ const before = ledgerIds();
436
465
  state = await stageEnv(stage, (runEnv) => owner.compileLocalUnit(unit.kind, argv, { env: runEnv, ...(source ? { source } : {}) }));
437
- collectReceipts(stage, owner.localUnitCompileRequests?.(state));
466
+ collectReceipts(stage, owner.localUnitCompileRequests?.(state), before);
438
467
  } else if (stage === "package") {
468
+ const before = ledgerIds();
439
469
  artifact = await stageEnv(stage, (runEnv) => owner.packageLocalUnit(state, { env: runEnv }));
440
470
  verifyArtifact(artifact);
441
- collectReceipts(stage, artifact.brokerRequests);
471
+ collectReceipts(stage, artifact.brokerRequests, before);
442
472
  } else if (stage === "qualify") {
443
473
  if (checkTier !== "release" && await check("release") !== 0) throw new Error("release-tier check failed");
444
474
  const qualified = await stageEnv(stage, (runEnv) => owner.qualifyLocalUnit(state, { env: runEnv }));