@rightkit/release 0.6.70 → 0.6.72

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.
@@ -322,6 +322,14 @@
322
322
  ],
323
323
  "count": 2,
324
324
  "why": "one per npm package"
325
+ },
326
+ {
327
+ "program": "pnpm",
328
+ "args": [
329
+ "--version"
330
+ ],
331
+ "count": 2,
332
+ "why": "two different questions: Class A probes pnpm in a neutral folder (its answer is in the pnpm rows' cache keys), compile planning asks in the project folder; pnpm 9+ switches to a project's packageManager version, so the answers can differ. Settled with Gemini, 2026-11-25 (Adrian delegated decisions to Gemini overnight)."
325
333
  }
326
334
  ],
327
335
  "cases": [
@@ -224,7 +224,7 @@ export async function launch({ out, commit, kind = null, receiptsDir, limits = n
224
224
  const changed = storeBefore && storeAfter ? Object.keys(storeAfter).filter((k) => !storeBefore[k] || storeBefore[k][0] !== storeAfter[k][0] || storeBefore[k][1] !== storeAfter[k][1]).sort() : null;
225
225
  const rowOfFile = (name) => { try { const d = JSON.parse(fs.readFileSync(path.join(storeDir, name), "utf8")); return typeof d?.row?.id === "string" ? d.row.id : typeof d?.id === "string" ? d.id : null; } catch { return null; } };
226
226
  // A combined result names its crates in its own record, or in the command it stores (`-p <crate>`).
227
- const cratesOfFile = (name) => { try { const d = JSON.parse(fs.readFileSync(path.join(storeDir, name), "utf8")); if (Array.isArray(d?.row?.crates)) return d.row.crates.map(String); const words = String(d?.row?.command ?? "").split(/\s+/); const out = []; words.forEach((w, i) => { if ((w === "-p" || w === "--package") && words[i + 1]) out.push(words[i + 1]); }); return out.length ? [...new Set(out)] : null; } catch { return null; } };
227
+ const cratesOfFile = (name) => { try { const d = JSON.parse(fs.readFileSync(path.join(storeDir, name), "utf8")); if (Array.isArray(d?.row?.crates)) return d.row.crates.map(String); let units = null; try { const text = String(d?.row?.raw?.inputs ?? "null"); units = JSON.parse(text.slice(0, text.lastIndexOf("}") + 1) || "null")?.units; /* the key text is the JSON, then :<key schema> */ } catch { units = null; } if (Array.isArray(units) && units.length) return [...new Set(units.map((u) => String(Array.isArray(u) ? u[0] : u).split(":").pop()))]; /* a combined result's row-index entry lists its units, <workspace>:<crate> */ const words = String(d?.row?.command ?? "").split(/\s+/); const out = []; words.forEach((w, i) => { if ((w === "-p" || w === "--package") && words[i + 1]) out.push(words[i + 1]); }); return out.length ? [...new Set(out)] : null; } catch { return null; } };
228
228
  fs.writeFileSync(path.join(out, "cache-written.json"), `${JSON.stringify(changed === null ? null : changed.map((name) => ({ name, row: rowOfFile(name), crates: cratesOfFile(name) })))}\n`);
229
229
  const snaps = rootEntries === null ? { root: snapRoot, dirs: {}, known: false } : statSnapshots(snapRoot, Date.parse(record.startedAt), { entries: rootEntries });
230
230
  fs.writeFileSync(path.join(out, "snapshot-stat.json"), `${JSON.stringify(snaps)}\n`);
@@ -124,6 +124,9 @@ async function main() {
124
124
  if (id === 1) {
125
125
  const aside = path.join(out, "set-aside", new Date().toISOString().replace(/[:.]/g, "-"));
126
126
  moveAside(storeDir, path.join(aside, "rightkit-gate-cache")); moveAside(historyFileOf(managed, storeDir), path.join(aside, "history.json"));
127
+ // From nothing includes the sidecar's kept staging (0.6.71): the gate keeps it per snapshot folder, so it outlives the scan store.
128
+ // Only the fixture's own folder: other repositories' kept stagings are theirs.
129
+ { const snap = (await import("./snapshot.mjs")).repositoryOf(fixture).key; moveAside(path.join(managed, "sidecar-state", snap), path.join(aside, "sidecar-state", snap)); }
127
130
  const dirty = path.join(fixture, "rk", "crates", "rk-leaf", "src", "lib.rs");
128
131
  fs.writeFileSync(dirty, "pub fn leaf() -> u32 { this does not compile\n");
129
132
  try { runs.push(await one(fixture, commit, "case1", { args })); } finally { git(fixture, ["checkout", "--", "rk/crates/rk-leaf/src/lib.rs"]); }
@@ -2905,10 +2905,17 @@ export async function stageSidecarsOnce({ o, ds, root, git = null, configs, appD
2905
2905
  const keyOf = (parts) => (parts ? createHash("sha256").update(JSON.stringify(parts)).digest("hex") : null);
2906
2906
  const keyNow = (dirs) => keyOf(partsNow(dirs));
2907
2907
  const nowParts = prior?.schema === 2 ? partsNow(prior.dirs) : null;
2908
+ // The snapshot sync removes ignored outputs (app/src-tauri/binaries/) when the commit changes (acceptance case 3 on 0.6.70). When the sources are those of
2909
+ // the last staging, its kept copy is put back, as the web build's dist cache is; stage-sidecar --if-stale then checks the files and builds nothing.
2910
+ const keptDir = stateFile.replace(/\.json$/, ".files");
2911
+ if (prior?.schema === 2 && nowParts && keyOf(nowParts) === prior.key && Array.isArray(prior.kept) && typeof prior.receipt === "string" && !fs.existsSync(path.join(ds.path, prior.receipt))) {
2912
+ try { for (const rel of prior.kept) { const from = path.join(keptDir, ...rel.split("/")); const to = path.join(ds.path, ...rel.split("/")); fs.mkdirSync(path.dirname(to), { recursive: true }); fs.copyFileSync(from, to); const st = fs.statSync(from); fs.utimesSync(to, st.atime, st.mtime); } }
2913
+ catch (e) { o.out(tag + " [" + stage + "] stage-sidecar " + config + ": the kept staging could not be put back (" + e.message + ")"); }
2914
+ }
2908
2915
  const receiptNow = prior?.schema === 2 && typeof prior.receipt === "string" ? stagedFilesDigest(path.join(ds.path, prior.receipt)) : null;
2909
2916
  const unchanged = Boolean(prior?.schema === 2 && nowParts && keyOf(nowParts) === prior.key && receiptNow === prior.receiptSha256);
2910
2917
  // Why it stages again, in one line, so a missed reuse can be traced from the run's own output.
2911
- if (!unchanged) o.out(tag + " [" + stage + "] stage-sidecar " + config + " builds: " + (prior?.schema !== 2 ? "no earlier staging is recorded" : !nowParts ? "its sources cannot be read from the commit" : keyOf(nowParts) !== prior.key ? "changed since the last staging: " + (Object.keys(nowParts).filter((k) => nowParts[k] !== prior.parts?.[k]).join(", ") || "unknown part") : "the staged receipt is not the one recorded"));
2918
+ if (!unchanged) o.out(tag + " [" + stage + "] stage-sidecar " + config + " builds: " + (prior?.schema !== 2 ? "no earlier staging is recorded" : !nowParts ? "its sources cannot be read from the commit" : keyOf(nowParts) !== prior.key ? "changed since the last staging: " + (Object.keys(nowParts).filter((k) => nowParts[k] !== prior.parts?.[k]).join(", ") || "unknown part") : "the staged receipt is not the one recorded (recorded " + String(prior.receiptSha256).slice(0, 12) + ", now " + (receiptNow === null ? (fs.existsSync(path.join(ds.path, prior.receipt)) ? "unreadable" : "absent") + " at " + path.join(ds.path, prior.receipt) : String(receiptNow).slice(0, 12)) + ")"));
2912
2919
  let r;
2913
2920
  try {
2914
2921
  o.out(`${tag} [${stage}] right-release stage-sidecar --config ${path.join(ds.path, config)}${target ? ` --target ${target}` : ""}${unchanged ? " --if-stale (its sources are those of the last staging: the staged files are checked, nothing is built)" : ""} (from the snapshot ${ds.path})`);
@@ -2938,7 +2945,9 @@ export async function stageSidecarsOnce({ o, ds, root, git = null, configs, appD
2938
2945
  // The sources this staging was built from, for the next run (NN07). Not recordable (a sidecar not built by Cargo, a package not found): the state is removed.
2939
2946
  try {
2940
2947
  const dirs = git ? sidecarSourceDirs({ git, commit, result }) : null; const k = dirs ? keyNow(dirs) : null; const sha = receiptAbs ? stagedFilesDigest(path.join(ds.path, receiptAbs)) : null;
2941
- if (k && sha) { fs.mkdirSync(path.dirname(stateFile), { recursive: true }); const tmp = `${stateFile}.${process.pid}.tmp`; fs.writeFileSync(tmp, `${JSON.stringify({ schema: 2, key: k, parts: partsNow(dirs), dirs, receipt: receiptAbs, receiptSha256: sha })}\n`); fs.renameSync(tmp, stateFile); }
2948
+ let kept = null;
2949
+ if (k && sha) { try { const files = [receiptAbs, ...(Array.isArray(result?.files) ? result.files.map((x) => (typeof x?.path === "string" ? underApp(x.path) : null)).filter(Boolean) : [])]; fs.rmSync(keptDir, { recursive: true, force: true }); for (const rel of files) { const from = path.join(ds.path, ...rel.split("/")); const to = path.join(keptDir, ...rel.split("/")); fs.mkdirSync(path.dirname(to), { recursive: true }); fs.copyFileSync(from, to); const st = fs.statSync(from); fs.utimesSync(to, st.atime, st.mtime); } kept = files; } catch (e) { kept = null; o.out(tag + " [" + stage + "] stage-sidecar " + config + ": the staging was not kept (" + e.message + "); the next run builds again"); } }
2950
+ if (k && sha) { fs.mkdirSync(path.dirname(stateFile), { recursive: true }); const tmp = `${stateFile}.${process.pid}.tmp`; fs.writeFileSync(tmp, `${JSON.stringify({ schema: 2, key: k, parts: partsNow(dirs), dirs, receipt: receiptAbs, receiptSha256: sha, ...(kept ? { kept } : {}) })}\n`); fs.renameSync(tmp, stateFile); }
2942
2951
  else fs.rmSync(stateFile, { force: true });
2943
2952
  } catch (e) { o.out(`${tag} [${stage}] stage-sidecar ${config}: the staging state was not recorded (${e.message}); the next run stages again`); }
2944
2953
  }
@@ -5555,7 +5564,8 @@ export async function main(argv, io = {}) {
5555
5564
  if (!classAOnly) {
5556
5565
  const needsForecast = !o.runScans;
5557
5566
  try {
5558
- const headSha = snapshotBCommit?.commit ?? text(git("rev-parse", "HEAD")).trim();
5567
+ // The selected commit, never asked again: a self-call names it by its full id (NN08: `git rev-parse HEAD` asked twice in one run on 0.6.71).
5568
+ const named = option("--commit"); const headSha = snapshotBCommit?.commit ?? (/^[0-9a-f]{40}$/.test(named ?? "") ? named : text(git("rev-parse", "HEAD")).trim());
5559
5569
  const treeId = text(git("rev-parse", `${headSha}^{tree}`)).trim();
5560
5570
  const common = git("rev-parse", "--git-common-dir");
5561
5571
  if (headSha && treeId && !failed(common) && text(common).trim()) {
@@ -2333,7 +2333,9 @@ const readMemoKey = (command, args, options = {}) => {
2333
2333
  // git show <sha>:<path>, ls-tree <sha>, cat-file -p <sha>: content-addressed, the same answer wherever it is asked (a repository without the object fails, and a failure is not kept).
2334
2334
  if (/(^|[\\/])git(\.exe)?$/i.test(String(command)) && sub[0] !== "rev-parse") return sha256(JSON.stringify(["object", sub]));
2335
2335
  // A tool's own version is the version of the binary that runs: the program as the environment resolves it.
2336
- if (a.length === 1 || (a.length === 2 && a[1] === "--version")) {
2336
+ // Only tools with one binary on PATH: rustup's proxies (cargo, rustc, rustfmt) and pnpm resolve a version per folder, so their key keeps the folder.
2337
+ const tool = String(command).replaceAll("\\", "/").split("/").pop().replace(/.(exe|cmd|bat)$/i, "").toLowerCase();
2338
+ if (["actionlint", "shellcheck", "oxlint", "cargo-deny", "cargo-audit"].includes(tool) && (a.length === 1 || (a.length === 2 && a[1] === "--version"))) {
2337
2339
  let file = String(command); try { file = resolveInvocation(command, args, { env: options.env ?? process.env }).file ?? file; } catch { /* as given */ }
2338
2340
  return sha256(JSON.stringify(["version", String(file).toLowerCase(), a]));
2339
2341
  }
@@ -2961,7 +2963,9 @@ async function defaultScanSecrets() {
2961
2963
  */
2962
2964
  export async function ignoredPathSkip(ctx) {
2963
2965
  const git = async (args) => { try { return await ctx.deps.spawn("git", args, { cwd: ctx.contentRoot, encoding: "utf8", env: ctx.deps.env }); } catch { return null; } };
2964
- const top = await git(["rev-parse", "--show-toplevel"]);
2966
+ // The gate hands the tracked-file list only for a snapshot run: then the content root is a snapshot, which is what this question found out, so it is
2967
+ // not asked (GC-A27 NN08: the snapshot's top level was asked again after the checkout's, acceptance case 3 on 0.6.71).
2968
+ const top = Array.isArray(ctx.trackedFiles) ? null : await git(["rev-parse", "--show-toplevel"]);
2965
2969
  const same = (a, b) => { try { return fs.realpathSync(a) === fs.realpathSync(b); } catch { return path.resolve(a) === path.resolve(b); } };
2966
2970
  if (!top || top.status !== 0 || !same(String(top.stdout ?? "").trim(), ctx.contentRoot)) {
2967
2971
  // Not a git toplevel: a snapshot, which holds the commit's files and also whatever a stage wrote into it (dist/stage, build output), and
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rightkit/release",
3
- "version": "0.6.70",
3
+ "version": "0.6.72",
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
@@ -26,6 +26,10 @@ export function pureQuestion(cmd, args) {
26
26
  if (name === "where" || name === "which") return args.length === 1 && /^[A-Za-z0-9._-]+$/.test(args[0]);
27
27
  // A broker job's status, by its id: remembered only once the answer is final (see FINAL_ONLY), never while the job may still change.
28
28
  if (name === "rustright") return args.length === 2 && args[0] === "status" && /^[0-9a-f-]{36}$/.test(args[1]);
29
+ // A tool's own version, asked with nothing else: the version of the binary PATH resolves (GC-A27 NN08: actionlint -version and shellcheck --version
30
+ // asked once by the lookup pass and again by the real pass, from two probe folders, on 0.6.70). Only tools with one binary on PATH: rustup's proxies
31
+ // (cargo, rustc, rustfmt) and pnpm resolve a version per folder, so they are not listed.
32
+ if (FIXED_VERSION_TOOLS.has(name) && args.length === 1 && TOOL_VERSION_FLAGS.has(args[0])) return true;
29
33
  if (name !== "git") return false;
30
34
  // Leading `-c key=value` pairs configure the call, they are part of the question (and of the key), not a different question.
31
35
  let rest = args; while (rest[0] === "-c" && typeof rest[1] === "string" && rest[1].includes("=")) rest = rest.slice(2);
@@ -53,6 +57,23 @@ export function pureQuestion(cmd, args) {
53
57
  if (rest[0] === "ls-tree") return treeListOf(args) !== null || (rest.length >= 2 && SHA.test(rest[rest.length - 1]) && rest.slice(1, -1).every((f) => LS_TREE_FLAGS.has(f)));
54
58
  return false;
55
59
  }
60
+ const TOOL_VERSION_FLAGS = new Set(["--version", "-version", "-V"]);
61
+ const FIXED_VERSION_TOOLS = new Set(["actionlint", "shellcheck", "oxlint", "cargo-deny", "cargo-audit"]);
62
+ /**
63
+ * A question whose answer is fixed by its arguments alone, whatever folder asks it: a git object named by its full id (the same bytes in any
64
+ * repository that has it; one that does not fails, and a failure is never kept), or a tool's own version (keyed by PATH instead). The checkout and
65
+ * the snapshot asked these separately, so each was asked twice (NN08, acceptance cases on 0.6.70). Exported for its test.
66
+ */
67
+ export function folderFree(cmd, args) {
68
+ const name = path.basename(String(cmd).replaceAll("\\", "/")).toLowerCase().replace(/\.(exe|cmd|bat)$/, "");
69
+ if (name !== "git") return FIXED_VERSION_TOOLS.has(name) && args.length === 1 && TOOL_VERSION_FLAGS.has(args[0]);
70
+ let rest = args; while (rest[0] === "-c" && typeof rest[1] === "string" && rest[1].includes("=")) rest = rest.slice(2);
71
+ if (rest[0] === "show") return rest.length === 2 && /^[0-9a-f]{40}([0-9a-f]{24})?:/.test(rest[1]);
72
+ if (rest[0] === "cat-file") return rest.length === 3 && SHA.test(rest[2]);
73
+ if (rest[0] === "ls-tree") return rest.length >= 2 && SHA.test(rest[rest.length - 1]);
74
+ if (rest[0] === "rev-parse") { const tail = rest.slice(1); return tail.length >= 1 && /^[0-9a-f]{40}/.test(tail[tail.length - 1]) && !tail.some((a) => a === "--show-toplevel" || a === "HEAD"); }
75
+ return false;
76
+ }
56
77
  const LS_TREE_FLAGS = new Set(["-r", "-z", "-l", "-t", "--name-only", "--full-tree", "--long"]);
57
78
 
58
79
  /**
@@ -166,7 +187,9 @@ const copy = (v) => (Buffer.isBuffer(v) ? Buffer.from(v) : v);
166
187
  const programNameOf = (cmd) => path.basename(String(cmd).replaceAll("\\", "/")).toLowerCase().replace(/\.(exe|cmd|bat)$/, "");
167
188
  const questionKeyOf = (cmd, args, options) => {
168
189
  const env = Object.entries(options?.env && typeof options.env === "object" ? options.env : process.env).filter(([k]) => /^GIT_/i.test(k)).sort();
169
- return JSON.stringify([programNameOf(cmd), args, path.resolve(typeof options?.cwd === "string" ? options.cwd : process.cwd()), env]);
190
+ const free = folderFree(cmd, Array.isArray(args) ? args : []);
191
+ const pathVar = free && programNameOf(cmd) !== "git" ? Object.entries(options?.env && typeof options.env === "object" ? options.env : process.env).filter(([k]) => /^path$/i.test(k)).map(([, v]) => v) : [];
192
+ return JSON.stringify([programNameOf(cmd), args, free ? pathVar : path.resolve(typeof options?.cwd === "string" ? options.cwd : process.cwd()), env]);
170
193
  };
171
194
  const piped = (options) => options?.stdio === undefined || options.stdio === "pipe";
172
195
  /** A batch read or a grep answer larger than this is not kept in memory: it is asked again. */
@@ -49,7 +49,7 @@
49
49
  "@rightkit/qa": "0.7.0",
50
50
  "@rightkit/qa-chrome": "0.1.12",
51
51
  "@rightkit/react-shell": "0.7.7",
52
- "@rightkit/release": "0.6.70",
52
+ "@rightkit/release": "0.6.72",
53
53
  "@rightkit/send-ui": "0.1.0",
54
54
  "@rightkit/settings-ui": "0.7.5",
55
55
  "@rightkit/social-ui": "0.2.1",