@rightkit/release 0.6.72 → 0.6.74

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.
@@ -115,6 +115,9 @@ async function main() {
115
115
  if (git(fixture, ["status", "--porcelain", "--untracked-files=no"])) throw new Error("the fixture's working checkout has changes to tracked files; the cases need it clean to start");
116
116
  const storeDir = cacheStoreDir(fixture); const args = ["--to", cases.fixture.stage];
117
117
  const wanted = (opt("--cases") ?? cases.order.join(",")).split(",").map(Number);
118
+ // The advisory rows key on the UTC day by design: a run that crosses UTC midnight sees them run again in case 2 and reads it as NN06 (0.6.73, 2026-11-25).
119
+ const late = minutesToUtcMidnight(new Date());
120
+ if (wanted.includes(2) && late < MIDNIGHT_MARGIN_MIN) throw new Error(`UTC midnight is ${late} min away; the advisory rows change key at midnight, so start the cases after 00:00 UTC (or with more than ${MIDNIGHT_MARGIN_MIN} min to go)`);
118
121
  try {
119
122
  for (const id of cases.order.filter((n) => wanted.includes(n))) {
120
123
  const def = cases.cases.find((c) => c.id === id); console.log(`case ${id}: ${def.name}`);
@@ -159,4 +162,6 @@ async function main() {
159
162
  for (const l of all.realBuild) console.log(`real build ${l.id} ${l.verdict}${l.verdict === "pass" ? "" : `: ${l.why}`}`.slice(0, 600));
160
163
  process.exit(all.pass ? 0 : 1);
161
164
  }
165
+ export const MIDNIGHT_MARGIN_MIN = 45;
166
+ export function minutesToUtcMidnight(now) { const next = Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate() + 1); return Math.floor((next - now.getTime()) / 60000); }
162
167
  if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) main().catch((e) => { console.error(`acceptance-run: ${e.stack ?? e.message}`); process.exit(2); });
package/advisory-db.mjs CHANGED
@@ -55,7 +55,8 @@ export function ensureAdvisoryDb({ cacheRoot, pin, git = defaultGit, fsImpl = fs
55
55
  const { url, commit } = checkPin(pin);
56
56
  const base = path.join(cacheRoot, "advisory-db");
57
57
  const dest = path.join(base, commit);
58
- const head = (dir) => { const r = git(["rev-parse", "HEAD"], { cwd: dir }); return !r.error && r.status === 0 ? String(r.stdout).trim() : null; };
58
+ // -C names the checkout on the command line, so the process log tells this question from the fixture's own HEAD (NN08, 0.6.72).
59
+ const head = (dir) => { const r = git(["-C", dir, "rev-parse", "HEAD"], { cwd: dir }); return !r.error && r.status === 0 ? String(r.stdout).trim() : null; };
59
60
  if (fsImpl.existsSync(dest)) {
60
61
  if (head(dest) === commit) return dest;
61
62
  // A stale or damaged directory under the pinned name is never trusted; replace it.
@@ -41,7 +41,7 @@ import { OutdatedUnavailableError, resolveOutdatedBin } from "./outdated-command
41
41
  import { SCAN_TOKEN_ENV, readLedger, scanTokenOf, unclaimedLedgers } from "./cargo-ledger.mjs";
42
42
  import { ADMISSION_POLL_MS, CARRIED_CANCEL_GRACE_MS, QUEUED_CEILING_FACTOR, createRunClock, createStatusPoller, watchBrokerAdmission } from "./broker-admission.mjs";
43
43
  import { CANCEL_WAIT_ENV, operationDeadlineEnv } from "./broker-admission.mjs";
44
- import { windowsPnpmIdentity } from "./snapshot-dependency-reuse.mjs";
44
+ import { pnpmVersionAnswerAsync, windowsPnpmIdentity } from "./snapshot-dependency-reuse.mjs";
45
45
  import { compatibleTargetClasses, groupTargetDifference, meetPartitions, parseTreeFeatures, partitionByFeatures, partitionCacheKey, splitNote, stripSelectors, targetSplitNote, treeArgs, treeArgsForTargets, workspaceManifestDigest } from "./feature-partition.mjs";
46
46
  import { CLASS_A_ENV, NOT_EXECUTED_EXIT, RECEIPT_NONCE_ENV, contractJobTag, judgeSeamOutcome, normalizeWorkspace, recordContractJob, seamEnv, seamSettled, verdictForRun } from "./gate-seam.mjs";
47
47
 
@@ -2327,6 +2327,7 @@ export function isRememberedRead(command, args) {
2327
2327
  if (sub[0] === "ls-tree" && sub.length >= 2 && /^[0-9a-f]{40}$/.test(sub[sub.length - 1]) && sub.slice(1, -1).every((a) => /^-[a-z]$|^--name-only$|^--full-tree$/.test(a))) return true;
2328
2328
  return sub.length === 2 && sub[0] === "rev-parse" && sub[1] === "--show-toplevel";
2329
2329
  }
2330
+ export const PNPM_VERSION_ENV = /^(path|pnpm_home|corepack_.*|npm_config_.*|appdata|localappdata|userprofile|home|xdg_.*)$/i;
2330
2331
  const readMemoKey = (command, args, options = {}) => {
2331
2332
  const a = (args ?? []).map(String); let i = 0; while (i < a.length && (a[i] === "-c" || a[i] === "-C")) i += 2;
2332
2333
  const sub = a.slice(i);
@@ -2339,7 +2340,11 @@ const readMemoKey = (command, args, options = {}) => {
2339
2340
  let file = String(command); try { file = resolveInvocation(command, args, { env: options.env ?? process.env }).file ?? file; } catch { /* as given */ }
2340
2341
  return sha256(JSON.stringify(["version", String(file).toLowerCase(), a]));
2341
2342
  }
2342
- const env = options.env ? Object.keys(options.env).sort().map((k) => `${k}=${options.env[k]}`).join("\0") : "";
2343
+ // pnpm --version: what decides the answer is the program, the folder and pnpm's own variables, never a per-run value such as a lease id (NN08: the
2344
+ // lookup pass and the real pass handed different environments, so pnpm --version was asked again from the same folder, 0.6.73 case 1).
2345
+ const versionOnly = tool === "pnpm" && a.length === 1 && a[0] === "--version";
2346
+ const keep = versionOnly ? (k) => PNPM_VERSION_ENV.test(k) : () => true;
2347
+ const env = options.env ? Object.keys(options.env).filter(keep).sort().map((k) => `${k}=${options.env[k]}`).join("\0") : "";
2343
2348
  return sha256(JSON.stringify([String(command), a, path.resolve(options.cwd ?? process.cwd()), env]));
2344
2349
  };
2345
2350
  export function rememberReads(spawn, { store = READ_MEMO } = {}) {
@@ -2409,10 +2414,12 @@ export function killProcessTree(child, { platform = process.platform, run = spaw
2409
2414
  */
2410
2415
  export function defaultSpawnAsync(command, args, options = {}) {
2411
2416
  // GC-A27 NN08: the reads rememberReads keeps are answered from the same memory here, and an answer this path gets is kept for both.
2412
- if (isRememberedRead(command, args) && options.input === undefined && options.stdio === undefined && !options.stdoutFile && !options.onSpawn && !options.signal) {
2417
+ // A cancel signal does not change the answer: a remembered one starts nothing to cancel (Class A's version probe always passes one).
2418
+ if (isRememberedRead(command, args) && options.input === undefined && options.stdio === undefined && !options.stdoutFile && !options.onSpawn && !options.signal?.aborted) {
2413
2419
  const key = readMemoKey(command, args, options);
2414
2420
  if (READ_MEMO.has(key)) return Promise.resolve({ ...READ_MEMO.get(key) });
2415
- return rawSpawnAsync(command, args, options).then((r) => { if (r && r.status === 0 && !r.error) READ_MEMO.set(key, { status: 0, signal: null, stdout: r.stdout, stderr: r.stderr }); return r; });
2421
+ // A path missing from a commit named by its full id (status 128) is kept too, as the process-wide memory keeps it (NN08, 0.6.73 case 1).
2422
+ return rawSpawnAsync(command, args, options).then((r) => { if (r && !r.error && (r.status === 0 || (r.status === 128 && absentAtCommit(command, args ?? []) && /does not exist in|exists on disk, but not in/.test(String(r.stderr ?? ""))))) READ_MEMO.set(key, { status: r.status, signal: null, stdout: r.stdout, stderr: r.stderr }); return r; });
2416
2423
  }
2417
2424
  return rawSpawnAsync(command, args, options);
2418
2425
  }
@@ -3431,7 +3438,16 @@ export async function runScans(plan, options = {}) {
3431
3438
  // gate claims and checks like a scan's.
3432
3439
  const probeLedgerEnv = cargoLedger ? { [SCAN_TOKEN_ENV]: PROBE_LEDGER_TOKEN } : {};
3433
3440
  if (cargoLedger) claimedTokens.add(PROBE_LEDGER_TOKEN);
3434
- const probeOnce = (ms) => deps.spawn(command, PROBES[tool] ?? ["--version"], { cwd, env: { ...deps.env, ...PNPM_NO_HOOKS_ENV, COREPACK_ENABLE_AUTO_PIN: "0", ...probeLedgerEnv }, signal: signalFor(ms) });
3441
+ const probeEnv = { ...deps.env, ...PNPM_NO_HOOKS_ENV, COREPACK_ENABLE_AUTO_PIN: "0", ...probeLedgerEnv };
3442
+ const rawProbe = (ms) => deps.spawn(command, PROBES[tool] ?? ["--version"], { cwd, env: probeEnv, signal: signalFor(ms) });
3443
+ // pnpm's version is the one answer the Class A digest asks too (bin/rightkit-gate.mjs, pnpmVersionAnswer): with no pin to switch to, both
3444
+ // share it, so one gate process starts `pnpm --version` once for both (NN08, 0.6.73 case 1).
3445
+ const probeOnce = tool !== "pnpm" ? rawProbe : async (ms) => {
3446
+ let started = null;
3447
+ const { version, kept } = await pnpmVersionAnswerAsync({ cwd, env: probeEnv, remember: deps.spawn === defaultSpawnAsync, run: async () => { started = await rawProbe(ms); return started && !started.error && started.status === 0 ? String(started.stdout ?? "").trim() : null; } });
3448
+ return kept ? { status: 0, signal: null, stdout: `${version}
3449
+ `, stderr: "" } : started;
3450
+ };
3435
3451
  // One retry, with three times the bound, when only the bound stopped it (the run itself was not aborted).
3436
3452
  let r = await probeOnce(probeMs);
3437
3453
  if (r?.cancelled && !signal?.aborted) r = await probeOnce(probeMs * 3);
@@ -5073,3 +5089,8 @@ export function scanFailures(result) {
5073
5089
  export function scanDeferrals(result) {
5074
5090
  return result.scans.filter((r) => r.status === "deferred").map((r) => `${r.id}: deferred, not passed (${r.detail})`);
5075
5091
  }
5092
+
5093
+ /** `git show <full commit id>:<path>`: a missing path there is missing for ever (NN08). Same rule as probe-memo.mjs absentAtCommit. */
5094
+ function absentAtCommit(cmd, argv) {
5095
+ return /(^|[\/])git(\.exe)?$/i.test(String(cmd)) && argv.length === 2 && argv[0] === "show" && /^[0-9a-f]{40}:[^:]+$/.test(String(argv[1]));
5096
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rightkit/release",
3
- "version": "0.6.72",
3
+ "version": "0.6.74",
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",
package/probe-memo.mjs CHANGED
@@ -227,6 +227,13 @@ export function installProbeMemo({ storeDir = null } = {}) {
227
227
  if (answered && !missing && (r.stdout?.length ?? 0) <= KEEP_MAX_BYTES) seenSpawn.set(key, { ...r, stdout: copy(r.stdout), stderr: copy(r.stderr) });
228
228
  return r;
229
229
  }
230
+ // A path missing from a commit named by its full id is missing for ever (NN08: `git show <sha>:package.json` asked twice, status 128, 0.6.72).
231
+ if (absentAtCommit(cmd, argv)) {
232
+ const r = spawnSync.apply(this, arguments);
233
+ if (r && !r.error && r.signal === null && r.status === 128 && /does not exist in|exists on disk, but not in/.test(String(r.stderr ?? ""))) seenSpawn.set(key, { ...r, stdout: copy(r.stdout), stderr: copy(r.stderr) });
234
+ else if (r && !r.error && r.status === 0 && (r.stdout?.length ?? 0) <= KEEP_MAX_BYTES) seenSpawn.set(key, { ...r, stdout: copy(r.stdout), stderr: copy(r.stderr) });
235
+ return r;
236
+ }
230
237
  const question = piped(opts) ? questionKeyOf(cmd, argv, opts) : null;
231
238
  const shared = question ? answers.get(question) : undefined;
232
239
  if (shared) {
@@ -273,3 +280,7 @@ export function installProbeMemo({ storeDir = null } = {}) {
273
280
  module.syncBuiltinESMExports();
274
281
  return stats;
275
282
  }
283
+
284
+ export function absentAtCommit(cmd, argv) {
285
+ return /(^|[\/])git(.exe)?$/i.test(String(cmd)) && argv.length === 2 && argv[0] === "show" && /^[0-9a-f]{40}:[^:]+$/.test(String(argv[1]));
286
+ }
@@ -274,10 +274,20 @@ export function pnpmVersionSwitchInputs({ dir }) {
274
274
  return { pin, manageVersions };
275
275
  }
276
276
 
277
- export function pnpmVersionAnswer({ cwd, env, remember = false, run, ask }) {
277
+ // Variables only the scan's version probe adds (no pnpmfile, no lifecycle scripts, no corepack auto-pin). With no pin to switch to they cannot
278
+ // change the version pnpm reports, so there they are left out of the key and the probe shares the Class A digest's answer (NN08, 0.6.73 case 1:
279
+ // `pnpm --version` from the repository root and again from the probe folder, neither with a pin).
280
+ const PROBE_ONLY_PNPM_ENV = /^(?:npm_config_ignore_pnpmfile|npm_config_ignore_scripts|pnpm_config_ignore_pnpmfile|pnpm_config_ignore_scripts|COREPACK_ENABLE_AUTO_PIN|RIGHTKIT_CARGO_SCAN)$/i;
281
+ function pnpmVersionKeyOf({ cwd, env, remember }) {
278
282
  const dependencies = remember ? pnpmConfigDependencies({ dir: cwd, env }) : null;
279
- const lastingEnv = dependencies?.program ? Object.entries(env ?? {}).filter(([name]) => !PER_RUN_BOOKKEEPING.test(String(name).toUpperCase())).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)) : null;
280
- const key = dependencies?.program ? answerKey(['rightkit.pnpm-version-answer/3', dependencies.program, lastingEnv, pnpmVersionSwitchInputs({ dir: cwd })]) : null;
283
+ if (!dependencies?.program) return { key: null, dependencies };
284
+ const switches = pnpmVersionSwitchInputs({ dir: cwd });
285
+ const noPin = !switches.pin && !switches.manageVersions;
286
+ const lastingEnv = Object.entries(env ?? {}).filter(([name]) => !PER_RUN_BOOKKEEPING.test(String(name).toUpperCase()) && !(noPin && PROBE_ONLY_PNPM_ENV.test(String(name)))).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));
287
+ return { key: answerKey(['rightkit.pnpm-version-answer/4', dependencies.program, lastingEnv, switches]), dependencies };
288
+ }
289
+ export function pnpmVersionAnswer({ cwd, env, remember = false, run, ask }) {
290
+ const { key, dependencies } = pnpmVersionKeyOf({ cwd, env, remember });
281
291
  const kept = key ? recallAnswer(key, { env, ...(ask ? { ask } : {}) }) : null;
282
292
  if (kept) return kept;
283
293
  const marks = key ? fileMarks(dependencies.files) : null;
@@ -285,6 +295,16 @@ export function pnpmVersionAnswer({ cwd, env, remember = false, run, ask }) {
285
295
  if (key && typeof version === 'string' && /^\d+\.\d+\.\d+/.test(version)) rememberAnswer(key, version, marks, { env, ...(ask ? { ask } : {}) });
286
296
  return version;
287
297
  }
298
+ /** pnpmVersionAnswer for an asynchronous run (the scan's version probe): run() resolves to the version text, or null when it failed. */
299
+ export async function pnpmVersionAnswerAsync({ cwd, env, remember = false, run, ask }) {
300
+ const { key, dependencies } = pnpmVersionKeyOf({ cwd, env, remember });
301
+ const kept = key ? recallAnswer(key, { env, ...(ask ? { ask } : {}) }) : null;
302
+ if (kept) return { version: kept, kept: true };
303
+ const marks = key ? fileMarks(dependencies.files) : null;
304
+ const version = await run();
305
+ if (key && typeof version === 'string' && /^\d+\.\d+\.\d+/.test(version)) rememberAnswer(key, version, marks, { env, ...(ask ? { ask } : {}) });
306
+ return { version, kept: false };
307
+ }
288
308
 
289
309
  export function pnpmConfigIdentity({ dir, env, spawn, remember = false }) {
290
310
  const fail = (code) => { const e = new Error(code); e.reuseCode = code; throw e; };