@rightkit/release 0.6.57 → 0.6.61
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/README.md +4 -0
- package/acceptance-admission.mjs +104 -0
- package/acceptance-launch.mjs +234 -0
- package/acceptance-lines.mjs +1254 -0
- package/acceptance-result.mjs +77 -0
- package/acceptance-rows.mjs +47 -0
- package/admission-files.mjs +2 -0
- package/affected-units.mjs +17 -0
- package/app-check.mjs +6 -2
- package/app-closure.mjs +3 -1
- package/bin/rightkit-gate.mjs +546 -121
- package/broker-admission.mjs +45 -2
- package/broker-pins.mjs +11 -1
- package/broker-toolchain.mjs +113 -0
- package/cargo-profile-contract.mjs +7 -2
- package/class-a-cache-history.mjs +135 -0
- package/cli/right-release.mjs +0 -0
- package/code-closure.mjs +24 -0
- package/config-inspect.mjs +6 -0
- package/consumer-contracts.mjs +3 -1
- package/contract-nn.json +166 -0
- package/deterministic-scans.mjs +835 -112
- package/feature-coverage.mjs +109 -82
- package/feature-partition.mjs +76 -0
- package/forbidden-literals.mjs +78 -0
- package/gate/calls.mjs +121 -0
- package/gate/compile.mjs +190 -0
- package/gate/crate-results.mjs +127 -0
- package/gate/run-calls.mjs +241 -0
- package/gate/tests.mjs +234 -0
- package/gate-coverage.mjs +12 -3
- package/gate-release-admission.mjs +200 -0
- package/gate-seam.mjs +100 -4
- package/gate-serve.mjs +178 -32
- package/gate-stages.mjs +59 -0
- package/legacy-contract-receipt.mjs +809 -0
- package/local-publish.mjs +2 -4
- package/local-runtime.mjs +2 -2
- package/nsis-payload.mjs +4 -3
- package/ownership-applicability.mjs +5 -0
- package/ownership-class-rules.mjs +19 -8
- package/ownership-mandatory-set.json +15 -21
- package/ownership-mandatory-set.mjs +19 -4
- package/package.json +14 -8
- package/probe-memo.mjs +252 -0
- package/publication-artifacts.mjs +56 -2
- package/publish-local-npm.mjs +3 -0
- package/publish-update.mjs +2 -2
- package/receipt-signature.mjs +40 -0
- package/release.mjs +47 -29
- package/resident-answers.mjs +66 -0
- package/rightkit-ownership.json +20 -11
- package/rightkit-versions.json +349 -183
- package/runtime-bundle-stage.mjs +146 -0
- package/scan-digest.mjs +28 -4
- package/seam-broker.mjs +8 -1
- package/shell-contract.mjs +23 -2
- package/snapshot-changes.mjs +106 -0
- package/snapshot-check.mjs +17 -13
- package/snapshot-dependency-reuse.mjs +186 -14
- package/snapshot-git.mjs +17 -1
- package/snapshot-metadata.mjs +155 -3
- package/snapshot.mjs +90 -12
- package/spawn-ledger.mjs +21 -2
- package/stage-sidecar.mjs +231 -19
- package/suite-trust-roots.mjs +2 -2
- package/test-env.mjs +26 -0
- package/tool-version-memo.mjs +46 -0
- package/win-package-recipe.mjs +11 -0
- package/bin/darwin/rightkit-swap +0 -0
- package/gate-acceptance.mjs +0 -3362
package/snapshot.mjs
CHANGED
|
@@ -42,6 +42,8 @@ import { HostConfigError, hostConfigFile, readSnapshotRootConfig } from "./snaps
|
|
|
42
42
|
import { discoveryGit, discoveryRun, sealedRepoInfo, sealedRun, withSealedGit } from "./snapshot-git.mjs";
|
|
43
43
|
import { SOURCE_IDENTITY_FILE, sourceIdentityBytes } from "./snapshot-identity.mjs";
|
|
44
44
|
import { parseIdentity, processIdentity } from "./gate-seam.mjs";
|
|
45
|
+
import { serveRequest } from "./gate-serve.mjs";
|
|
46
|
+
import { treeStandsAfterChanges } from "./snapshot-changes.mjs";
|
|
45
47
|
// The error class and the managed-root guard live in managed-root-guard.mjs (decision D4 rule 1).
|
|
46
48
|
import { SnapshotError, requireManagedRoot } from "./managed-root-guard.mjs";
|
|
47
49
|
|
|
@@ -237,7 +239,51 @@ export function resolveCommit(checkout, rev = "HEAD") {
|
|
|
237
239
|
* object database and ignore rules; writes only objects (into the checkout's object database) and a temporary index kept outside the
|
|
238
240
|
* checkout's `.git`, always removed.
|
|
239
241
|
*/
|
|
242
|
+
/** How often this process hashed a snapshot's tree, walked it to verify it, and took the resident gate's proof instead (NN11): one line per run. */
|
|
243
|
+
export const SNAPSHOT_PROOF_COUNTS = { treeHashes: 0, verifyWalks: 0, residentProofs: 0, changedFileProofs: 0, changeSource: null };
|
|
244
|
+
/** NN28: remembers how the open gate process said it learns of changes (`source` of its answers), for the run's `snapshot proof:` line. */
|
|
245
|
+
export function noteChangeSource(reply) { if (typeof reply?.source === "string" && reply.source) SNAPSHOT_PROOF_COUNTS.changeSource = reply.source; return reply; }
|
|
246
|
+
/** The `snapshot proof:` line the contract test reads (NN11, NN28). `changeSource`: how the resident gate learns of changes. */
|
|
247
|
+
export const snapshotProofLine = (changeSource) => `snapshot proof: tree-hashes=${SNAPSHOT_PROOF_COUNTS.treeHashes} verify-walks=${SNAPSHOT_PROOF_COUNTS.verifyWalks} resident-proofs=${SNAPSHOT_PROOF_COUNTS.residentProofs} changed-file-proofs=${SNAPSHOT_PROOF_COUNTS.changedFileProofs} change-source=${changeSource}`;
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* NN11: whether the tree the open gate process last saw proven in `dir` still stands, judged from its record of what changed since
|
|
251
|
+
* (`reply`: its answer to "check"; snapshot-changes.mjs). True only after the caller's own walk of the snapshot has passed: then the tree id
|
|
252
|
+
* depends on the commit's files alone, and each one the changes could have touched is compared with the commit's blob here. False on any
|
|
253
|
+
* doubt, and the caller hashes the tree.
|
|
254
|
+
*/
|
|
255
|
+
export function treeProvenByChanges({ reply, dir, tree, entries, objectFormat }) {
|
|
256
|
+
const base = reply?.base;
|
|
257
|
+
if (!base || base.tree !== tree) return false;
|
|
258
|
+
if (!treeStandsAfterChanges({ dir, entries, changes: { changed: base.changed, renamed: base.renamed }, objectFormat }).ok) return false;
|
|
259
|
+
SNAPSHOT_PROOF_COUNTS.changedFileProofs += 1;
|
|
260
|
+
return true;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* The open gate process's change generation for `dir`, taken before a proof begins (gate-serve.mjs "begin"), or null. When the process was
|
|
264
|
+
* not running it is started (for the host's own snapshot root only) and asked again for a short while: a proof recorded now saves every later
|
|
265
|
+
* hash of this run.
|
|
266
|
+
*/
|
|
267
|
+
export function beginResidentProof(dir, { env = process.env, ask = serveRequest, waitMs = 8000 } = {}) {
|
|
268
|
+
if (env.RK_GATE_SERVE === "0") return null;
|
|
269
|
+
const root = path.dirname(path.resolve(dir));
|
|
270
|
+
// Only the first question may start the process (each start is a launcher of its own on Windows); the ones after it only ask.
|
|
271
|
+
let r = noteChangeSource(ask({ op: "begin", dir }, { env, root }));
|
|
272
|
+
if (Number.isInteger(r?.generation)) return r.generation;
|
|
273
|
+
if (residentWaitFailed) return null; // it did not come up within the wait once already in this process: not waited for again
|
|
274
|
+
const until = Date.now() + waitMs;
|
|
275
|
+
while (Date.now() < until) {
|
|
276
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 200);
|
|
277
|
+
r = noteChangeSource(ask({ op: "begin", dir }, { env }));
|
|
278
|
+
if (Number.isInteger(r?.generation)) return r.generation;
|
|
279
|
+
}
|
|
280
|
+
residentWaitFailed = true;
|
|
281
|
+
return null;
|
|
282
|
+
}
|
|
283
|
+
let residentWaitFailed = false;
|
|
284
|
+
|
|
240
285
|
export function snapshotTree({ checkout, dir, baseTree, repo = repositoryOf(checkout), indexStore = treeIndexStoreOf(dir) }) {
|
|
286
|
+
SNAPSHOT_PROOF_COUNTS.treeHashes += 1;
|
|
241
287
|
// The sealed runner (snapshot-git.mjs): a private git directory T holds the index and receives every object written; the
|
|
242
288
|
// checkout's git directory is not written at all (row 5.13), and its configuration, attributes, hooks and filters cannot reach the id.
|
|
243
289
|
const once = (stored) => withSealedGit({ commonDir: repo.commonDir, objectFormat: repo.objectFormat, snapshot: dir }, (git) => {
|
|
@@ -255,8 +301,14 @@ export function snapshotTree({ checkout, dir, baseTree, repo = repositoryOf(chec
|
|
|
255
301
|
throw e instanceof SnapshotError ? e : new SnapshotError("error", e.message);
|
|
256
302
|
}
|
|
257
303
|
});
|
|
304
|
+
// The stored index is a cache of the last run's stat data. Its answer is taken only when it is the tree the caller expects (`baseTree`):
|
|
305
|
+
// on Windows a file's executable bit lives in the index alone (core.fileMode=false), so a path that became 100755 since the stored index
|
|
306
|
+
// was written is hashed as 100644 and the id is wrong though every byte is right (Dell, 2026-11-17: rightkit 09aaf01e1 -> 4b23c9870, two
|
|
307
|
+
// files renamed and made executable; the run stopped with "is tree 26f549d1 after sync, not tree 2df67580"). Any other id is recomputed
|
|
308
|
+
// from the commit's own tree, which is the contract's method, and that result is the one returned.
|
|
258
309
|
if (indexStore && fs.existsSync(indexStore)) {
|
|
259
|
-
try {
|
|
310
|
+
try { const id = once(indexStore); if (id === baseTree) return id; } catch { /* recomputed below */ }
|
|
311
|
+
try { fs.rmSync(indexStore, { force: true }); } catch { /* best effort */ }
|
|
260
312
|
}
|
|
261
313
|
return once(null);
|
|
262
314
|
}
|
|
@@ -277,7 +329,7 @@ export function treeIndexStoreOf(dir) {
|
|
|
277
329
|
* input even though the seeded tree id cannot see it. Never follows a link (only real directories are entered); names compare
|
|
278
330
|
* case-insensitively where the host filesystem does (Mac, Windows; colliding names were refused before this runs).
|
|
279
331
|
*/
|
|
280
|
-
function pruneToTree(dir, entries, platform = process.platform, keepRoot = new Set(), keepDirs = new Set()) {
|
|
332
|
+
function pruneToTree(dir, entries, platform = process.platform, keepRoot = new Set(), keepDirs = new Set(), removedPaths = null) {
|
|
281
333
|
const fold = platform === "darwin" || platform === "win32" ? (n) => n.toLowerCase() : (n) => n;
|
|
282
334
|
const files = new Set(entries.map((e) => fold(e.path)));
|
|
283
335
|
const dirs = new Set();
|
|
@@ -289,8 +341,8 @@ function pruneToTree(dir, entries, platform = process.platform, keepRoot = new S
|
|
|
289
341
|
const p = path.join(d, e.name);
|
|
290
342
|
// keepDirs: the commit's own generated pnpm dependency directories (dependencyDirs), real directories only, kept whole for the
|
|
291
343
|
// dependency step, which reuses them only when every installed byte matches its last completed install and otherwise removes them.
|
|
292
|
-
if (e.isDirectory()) { if (keepDirs.has(fold(r))) continue; if (dirs.has(fold(r))) walk(p, r); else { fs.rmSync(p, { recursive: true, force: true }); removed++; } }
|
|
293
|
-
else if (!files.has(fold(r)) && !(rel === "" && keepRoot.has(fold(r)))) { fs.unlinkSync(p); removed++; }
|
|
344
|
+
if (e.isDirectory()) { if (keepDirs.has(fold(r))) continue; if (dirs.has(fold(r))) walk(p, r); else { fs.rmSync(p, { recursive: true, force: true }); removed++; removedPaths?.push(`${r}/`); } }
|
|
345
|
+
else if (!files.has(fold(r)) && !(rel === "" && keepRoot.has(fold(r)))) { fs.unlinkSync(p); removed++; removedPaths?.push(r); }
|
|
294
346
|
}
|
|
295
347
|
};
|
|
296
348
|
walk(dir, "");
|
|
@@ -677,7 +729,8 @@ const statKey = (s) => `${s.size}:${s.mtimeNs}:${s.ctimeNs}:${s.ino}`;
|
|
|
677
729
|
// and the broker's SNAPSHOT_STATUS proof covers only broker jobs. So while this process holds a snapshot lock, every detached child it starts is recorded beside
|
|
678
730
|
// the lock (`<lock>.children/group-<pid>.json`, removed only once the whole group is gone), and a dead holder's lock is never reclaimed while a recorded group still answers.
|
|
679
731
|
// Windows children are contained by the lock holder's named job instead (below). Residual, named: a crash between the spawn returning and the record being written
|
|
680
|
-
// leaves that one group unrecorded.
|
|
732
|
+
// leaves that one group unrecorded. Second residual, named: the record follows the group, not the tree. A process that leaves the group (setsid, setpgid)
|
|
733
|
+
// is not seen by it, so "the group is gone" is never proof that everything the child started is gone (gate/tests.mjs treats a timed-out program as unreaped for this reason).
|
|
681
734
|
let heldLockFile = null;
|
|
682
735
|
const childrenDirOf = (lockFile) => `${lockFile}.children`;
|
|
683
736
|
/** The variable that hands the held lock's record directory to this process's own children (right-release, heavy-command), which record their detached children there. */
|
|
@@ -688,7 +741,7 @@ export function recordLockChild(child, { platform = process.platform, env = proc
|
|
|
688
741
|
if (!dir || platform === "win32" || !child || !Number.isInteger(child.pid) || child.pid <= 0) return child;
|
|
689
742
|
const file = path.join(dir, `group-${child.pid}.json`);
|
|
690
743
|
try { fs.mkdirSync(dir, { recursive: true, mode: 0o700 }); fs.writeFileSync(file, JSON.stringify({ group: child.pid, by: process.pid, at: new Date().toISOString() }), { mode: 0o600 }); }
|
|
691
|
-
catch (error) { try { process.kill(-child.pid, "SIGKILL"); } catch { /* already gone */ } throw new SnapshotError("error", `the snapshot lock's child record ${file} cannot be written (${error.message});
|
|
744
|
+
catch (error) { try { process.kill(-child.pid, "SIGKILL"); } catch { /* already gone */ } throw new SnapshotError("error", `the snapshot lock's child record ${file} cannot be written (${error.message}); a stop was sent to its group and is not confirmed`); }
|
|
692
745
|
// The root's exit does not end the group: a descendant it started (a backgrounded process with its own stdio) can outlive it in the same group.
|
|
693
746
|
// The record goes only on proof the whole group is gone (kill(-group, 0) is ESRCH); otherwise it stays and liveLockChildren keeps seeing the group.
|
|
694
747
|
const forget = () => {
|
|
@@ -1090,7 +1143,7 @@ export const lockView = (release) => ({ token: release.token, lockFile: release.
|
|
|
1090
1143
|
// `lock`: the snapshot lock of this sync (reset plan section 3). `held` is a lock the caller already took with `takeSnapshotLock` for this same snapshot: the sync
|
|
1091
1144
|
// uses it, re-checks it before every write and never releases it (the caller holds it through the batch). Without `held` the sync takes the lock itself, for the sync
|
|
1092
1145
|
// alone: `body` is the seam's lock body the broker reads (gate-seam.mjs snapshotLockBody) and `judge` decides a dead holder's reclaim on the broker's proof.
|
|
1093
|
-
export function syncSnapshot({ checkout, rev = "HEAD", root = snapshotRoot(), managedRoot = hostManagedRootFor(root), device, now = () => Date.now(), lock = {} } = {}) {
|
|
1146
|
+
export function syncSnapshot({ checkout, rev = "HEAD", root = snapshotRoot(), managedRoot = hostManagedRootFor(root), device, now = () => Date.now(), lock = {}, resident = managedRoot ? serveRequest : null } = {}) {
|
|
1094
1147
|
const started = now();
|
|
1095
1148
|
const repo = repositoryOf(checkout);
|
|
1096
1149
|
const { commit, tree } = resolveCommit(repo.checkout, rev);
|
|
@@ -1251,7 +1304,9 @@ export function syncSnapshot({ checkout, rev = "HEAD", root = snapshotRoot(), ma
|
|
|
1251
1304
|
})();
|
|
1252
1305
|
const keepDeps = dependencyDirs(entries, process.platform);
|
|
1253
1306
|
if (keepGit) keepDeps.add(foldFor(process.platform)(".git"));
|
|
1254
|
-
removed
|
|
1307
|
+
// NN22: what was removed is named (the first 8), so a warm sync that removes anything says what (the sync line in rightkit-gate).
|
|
1308
|
+
const removedPaths = [];
|
|
1309
|
+
removed += pruneToTree(dir, entries, process.platform, keepIdentity ? new Set([foldFor(process.platform)(SOURCE_IDENTITY_FILE)]) : new Set(), keepDeps, removedPaths);
|
|
1255
1310
|
if (identityBytes) {
|
|
1256
1311
|
// Written only when the commit's own ignore rules ignore the name (they are in the snapshot now): an unignored file would change the
|
|
1257
1312
|
// tree id the broker computes too, so the gate would break every build of that repository. Then nothing is written and the reason is reported.
|
|
@@ -1277,12 +1332,17 @@ export function syncSnapshot({ checkout, rev = "HEAD", root = snapshotRoot(), ma
|
|
|
1277
1332
|
}
|
|
1278
1333
|
|
|
1279
1334
|
assertLockHeld();
|
|
1335
|
+
// NN11: this walk and hash are a proof like any other, and the first of the run. The open gate process is told (its change generation is
|
|
1336
|
+
// taken before the walk, so a change during the proof refuses the record), and every later proof of this run starts from it instead of
|
|
1337
|
+
// hashing the tree again. On a host's managed root only: a test's temporary root has no such process (`resident` is the transport, for tests).
|
|
1338
|
+
const residentGeneration = resident ? beginResidentProof(dir, { ask: resident }) : null;
|
|
1280
1339
|
const extra = snapshotProblem({ dir, entries, checkout: repo.checkout, commit });
|
|
1281
1340
|
if (extra) throw new SnapshotError("mismatch", `snapshot ${dir} is not exactly commit ${commit} after sync: ${extra}`);
|
|
1282
1341
|
const actual = snapshotTree({ checkout: repo.checkout, dir, baseTree: tree, repo });
|
|
1283
1342
|
if (actual !== tree) throw new SnapshotError("mismatch", `snapshot ${dir} is tree ${actual} after sync, not tree ${tree} of commit ${commit}`);
|
|
1343
|
+
if (residentGeneration !== null) resident({ op: "record", dir, tree, generation: residentGeneration });
|
|
1284
1344
|
writeState(stateFile, { schema: STATE_SCHEMA, repo: repo.checkout, repoKey: repo.key, commit, tree, paths: [...wanted.keys()], stat: nextStat, syncedAt: new Date(now()).toISOString() });
|
|
1285
|
-
return { schema: SNAPSHOT_SCHEMA, path: dir, repoKey: repo.key, commit, tree, written, removed, modesFixed, unchanged, linksRemoved, hardLinksReplaced, casesFixed, identity, ms: now() - started };
|
|
1345
|
+
return { schema: SNAPSHOT_SCHEMA, path: dir, repoKey: repo.key, commit, tree, written, removed, removedPaths: removedPaths.slice(0, 8), modesFixed, unchanged, linksRemoved, hardLinksReplaced, casesFixed, identity, ms: now() - started };
|
|
1286
1346
|
} finally {
|
|
1287
1347
|
// A lock the caller took is the caller's to release; a lock this sync took ends with it.
|
|
1288
1348
|
if (!joined) release();
|
|
@@ -1305,7 +1365,7 @@ export function syncSnapshot({ checkout, rev = "HEAD", root = snapshotRoot(), ma
|
|
|
1305
1365
|
* result carry `ledger: [{ path, type, size, sha256, execBit }]`, every admitted entry. The tree id is still the commit's tree:
|
|
1306
1366
|
* an ignored output does not change it. With neither option nothing beyond the commit (and 5.09's allowances) is accepted.
|
|
1307
1367
|
*/
|
|
1308
|
-
export function verifySnapshot({ checkout, rev = "HEAD", root = snapshotRoot(), dir, managedRoot = hostManagedRootFor(root), device, environment, ledger, admitNew } = {}) {
|
|
1368
|
+
export function verifySnapshot({ checkout, rev = "HEAD", root = snapshotRoot(), dir, managedRoot = hostManagedRootFor(root), device, environment, ledger, admitNew, resident = serveRequest } = {}) {
|
|
1309
1369
|
const repo = repositoryOf(checkout);
|
|
1310
1370
|
const { commit, tree } = resolveCommit(repo.checkout, rev);
|
|
1311
1371
|
if (managedRoot) requireManagedRoot(managedRoot, { device });
|
|
@@ -1313,12 +1373,30 @@ export function verifySnapshot({ checkout, rev = "HEAD", root = snapshotRoot(),
|
|
|
1313
1373
|
// The root the snapshot sits directly in is private to this user, as at sync (a root another principal can use proves nothing).
|
|
1314
1374
|
if (path.resolve(path.dirname(at)) === path.resolve(root)) requirePrivateRoot(root, lstat(root));
|
|
1315
1375
|
if (!lstat(at)?.isDirectory()) throw new SnapshotError("mismatch", `no snapshot directory at ${at}`);
|
|
1376
|
+
// NN11 (Dell 2026-11-19, every warm run of the witness fixture: tree-hashes=3): the door verifies at each stage's start and end, and each
|
|
1377
|
+
// verify walked and hashed the snapshot again although the check's own verify of the same directory took the resident gate's proof. When
|
|
1378
|
+
// nothing beyond the commit is admitted (no ledger entry to match) and no environment is asked for, the resident gate's answer is the same
|
|
1379
|
+
// proof as in snapshot-check.mjs verifySnapshotDir: this directory was proven to be exactly this tree and nothing under it changed since.
|
|
1380
|
+
// Clean means no stage output exists, so the admitted ledger is empty. Any doubt (no resident gate, another tree, a change) is the full verify.
|
|
1381
|
+
const nothingAdmitted = (ledger === undefined || (Array.isArray(ledger) && ledger.length === 0)) && environment === undefined;
|
|
1382
|
+
let residentGeneration = null;
|
|
1383
|
+
// Asked in every case: with outputs admitted the answer is never "nothing changed", but it still says what changed since the tree was proven.
|
|
1384
|
+
const c = noteChangeSource(resident({ op: "check", dir: at, tree }, { root: path.dirname(path.resolve(at)) }));
|
|
1385
|
+
if (nothingAdmitted && c?.clean === true) { SNAPSHOT_PROOF_COUNTS.residentProofs += 1; return { schema: SNAPSHOT_SCHEMA, path: at, repoKey: repo.key, commit, tree, ...(ledger !== undefined || admitNew ? { ledger: [] } : {}) }; }
|
|
1386
|
+
if (Number.isInteger(c?.generation)) residentGeneration = c.generation;
|
|
1316
1387
|
// The seeded tree id cannot see an ignored file or follow a link, so the directory itself is walked first (E6, §1 exact snapshot).
|
|
1317
|
-
const
|
|
1388
|
+
const entries = treeEntries(repo.checkout, commit);
|
|
1389
|
+
const inspected = snapshotProblem({ dir: at, entries, checkout: repo.checkout, commit, ledger, admitNew });
|
|
1318
1390
|
const extra = ledger !== undefined || admitNew ? inspected.problem : inspected;
|
|
1319
1391
|
if (extra) throw new SnapshotError("mismatch", `the snapshot at ${at} is not exactly commit ${commit}${ledger !== undefined || admitNew ? " plus its stage-output ledger" : ""}: ${extra}`);
|
|
1320
|
-
|
|
1392
|
+
// NN11: the walk passed. When the open gate process knows what changed since this tree was proven, only the commit's files those changes
|
|
1393
|
+
// could have touched are compared (treeProvenByChanges); otherwise the tree is hashed.
|
|
1394
|
+
const actual = treeProvenByChanges({ reply: c, dir: at, tree, entries }) ? tree : snapshotTree({ checkout: repo.checkout, dir: at, baseTree: tree, repo });
|
|
1321
1395
|
if (actual !== tree) throw new SnapshotError("mismatch", `the snapshot at ${at} is tree ${actual}, not tree ${tree} of commit ${commit}`);
|
|
1396
|
+
// "record" (exactly this tree, nothing else) only after a verify that could admit nothing: no ledger, no admitNew, no environment. A walk
|
|
1397
|
+
// with a ledger, even an empty one, passes over an ignored empty directory without listing it (inspectSnapshot), which a plain walk
|
|
1398
|
+
// refuses; so its proof is "tree-record": the commit's files are this tree, which is what a later proof starts from (review 2026-11-19).
|
|
1399
|
+
if (residentGeneration !== null) resident({ op: ledger === undefined && admitNew !== true && environment === undefined ? "record" : "tree-record", dir: at, tree, generation: residentGeneration });
|
|
1322
1400
|
if (environment !== undefined) {
|
|
1323
1401
|
if (!environment || !/^[0-9a-f]{64}$/.test(String(environment.expected ?? "")) || typeof environment.compute !== "function") throw new SnapshotError("error", "verify with an environment needs { expected: <64 hex env digest>, compute: <function> }");
|
|
1324
1402
|
let now;
|
package/spawn-ledger.mjs
CHANGED
|
@@ -7,6 +7,24 @@ import childProcess from "node:child_process";
|
|
|
7
7
|
import fs from "node:fs";
|
|
8
8
|
import module from "node:module";
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* A Windows shell-shim start as the process it really starts: `cmd.exe /d /s /c ""<shim>" <args>"` (the only form the gate
|
|
12
|
+
* builds, deterministic-scans.mjs resolveInvocation: every argument matched SAFE_SHIM_ARG, so none holds a space and the
|
|
13
|
+
* split is exact) records as `<shim>` with its arguments, so the acceptance judges see the rustright/cargo/pnpm start the
|
|
14
|
+
* shim carried instead of an opaque cmd.exe string (NN40 saw no `cargo doc` start on Dell although six ran, run
|
|
15
|
+
* muse-fulldev-4). Anything else is returned unchanged. Exported for its test.
|
|
16
|
+
*/
|
|
17
|
+
export function unwrapCmdShim(cmd, args) {
|
|
18
|
+
if (!/(^|[\\/])cmd\.exe$/i.test(String(cmd)) || !Array.isArray(args)) return { cmd: String(cmd), args };
|
|
19
|
+
const at = args.findIndex((a) => /^\/c$/i.test(String(a)));
|
|
20
|
+
if (at < 0 || at + 1 >= args.length) return { cmd: String(cmd), args };
|
|
21
|
+
let line = String(args[at + 1]);
|
|
22
|
+
if (line.startsWith('""') && line.endsWith('"') && line.length >= 3) line = line.slice(1, -1);
|
|
23
|
+
const m = /^"([^"]+)"(?:\s+(.*))?$/.exec(line) ?? /^(\S+)(?:\s+(.*))?$/.exec(line);
|
|
24
|
+
if (!m) return { cmd: String(cmd), args };
|
|
25
|
+
return { cmd: m[1], args: m[2] ? m[2].split(/\s+/).filter(Boolean) : [] };
|
|
26
|
+
}
|
|
27
|
+
|
|
10
28
|
let installed = false;
|
|
11
29
|
|
|
12
30
|
/** Patch node:child_process once so every caller (default or named import) is recorded. No-op without RK_GATE_SPAWN_LEDGER. */
|
|
@@ -16,9 +34,10 @@ export function installSpawnLedger(env = process.env) {
|
|
|
16
34
|
installed = true;
|
|
17
35
|
const write = (entry) => { try { fs.appendFileSync(file, `${JSON.stringify(entry)}\n`); } catch { /* the ledger never fails a run */ } };
|
|
18
36
|
const describe = (cmd, args, options) => {
|
|
19
|
-
const
|
|
37
|
+
const raw = Array.isArray(args) ? args.map(String) : [];
|
|
38
|
+
const { cmd: logical, args: argv } = unwrapCmdShim(cmd, raw);
|
|
20
39
|
const opts = Array.isArray(args) ? options : args;
|
|
21
|
-
return { cmd:
|
|
40
|
+
return { cmd: logical, args: argv.join("\u0000").length > 4000 ? [...argv.slice(0, 40), `... ${argv.length} args`] : argv, cwd: typeof opts?.cwd === "string" ? opts.cwd : process.cwd() };
|
|
22
41
|
};
|
|
23
42
|
for (const name of ["spawnSync", "execFileSync", "execSync"]) {
|
|
24
43
|
const orig = childProcess[name];
|