patchwork-os 1.2.0-beta.2.canary.608 → 1.2.0-beta.2.canary.610
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/dist/index.js +56 -0
- package/dist/index.js.map +1 -1
- package/dist/runLog.d.ts +15 -0
- package/dist/runLog.js +12 -6
- package/dist/runLog.js.map +1 -1
- package/dist/runStore/backfillMirror.d.ts +90 -0
- package/dist/runStore/backfillMirror.js +168 -0
- package/dist/runStore/backfillMirror.js.map +1 -0
- package/dist/runStore/sqliteRunRepository.js +8 -1
- package/dist/runStore/sqliteRunRepository.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -196,6 +196,7 @@ const KNOWN_SUBCOMMANDS = [
|
|
|
196
196
|
"panic",
|
|
197
197
|
"halts",
|
|
198
198
|
"judgments",
|
|
199
|
+
"runstore",
|
|
199
200
|
"analytics",
|
|
200
201
|
"doctor",
|
|
201
202
|
"codex",
|
|
@@ -1951,6 +1952,61 @@ if (process.argv[2] === "panic") {
|
|
|
1951
1952
|
// per-category breakdown plus the 5 most-recent halt reasons. Default
|
|
1952
1953
|
// window is "overnight" (since 6pm yesterday local) so it lines up with
|
|
1953
1954
|
// "what halted while I was asleep?".
|
|
1955
|
+
if (process.argv[2] === "runstore") {
|
|
1956
|
+
const sub = process.argv[3];
|
|
1957
|
+
const args = process.argv.slice(4);
|
|
1958
|
+
const json = args.includes("--json");
|
|
1959
|
+
if (!sub || sub === "--help" || sub === "-h") {
|
|
1960
|
+
process.stdout.write("Usage: patchwork runstore <backfill|compare> [--json]\n" +
|
|
1961
|
+
"\n" +
|
|
1962
|
+
" backfill seed the ADR-0022 shadow mirror from runs.jsonl (idempotent)\n" +
|
|
1963
|
+
" compare report where the authoritative store and the mirror disagree\n" +
|
|
1964
|
+
"\n" +
|
|
1965
|
+
"Both are READ-ONLY with respect to runs.jsonl. The mirror is never\n" +
|
|
1966
|
+
"consulted for answers; it exists to be compared until it has earned a\n" +
|
|
1967
|
+
"flip. Backfill first — an unseeded mirror reports every pre-existing\n" +
|
|
1968
|
+
"run as a difference, and a signal that always fires means nothing.\n");
|
|
1969
|
+
process.exit(0);
|
|
1970
|
+
}
|
|
1971
|
+
if (sub !== "backfill" && sub !== "compare") {
|
|
1972
|
+
process.stderr.write(`Unknown runstore subcommand: "${sub}"\n`);
|
|
1973
|
+
process.exit(1);
|
|
1974
|
+
}
|
|
1975
|
+
void (async () => {
|
|
1976
|
+
const os = await import("node:os");
|
|
1977
|
+
const pathMod = await import("node:path");
|
|
1978
|
+
const { SqliteRunRepository } = await import("./runStore/sqliteRunRepository.js");
|
|
1979
|
+
const { backfillMirror, compareStores, formatCompare } = await import("./runStore/backfillMirror.js");
|
|
1980
|
+
const dir = process.env.PATCHWORK_HOME
|
|
1981
|
+
? process.env.PATCHWORK_HOME
|
|
1982
|
+
: pathMod.join(os.homedir(), ".patchwork");
|
|
1983
|
+
const mirror = new SqliteRunRepository({
|
|
1984
|
+
dir: pathMod.join(dir, "runstore-mirror"),
|
|
1985
|
+
});
|
|
1986
|
+
try {
|
|
1987
|
+
if (sub === "backfill") {
|
|
1988
|
+
const r = backfillMirror(dir, mirror);
|
|
1989
|
+
if (json) {
|
|
1990
|
+
process.stdout.write(`${JSON.stringify(r, null, 2)}\n`);
|
|
1991
|
+
}
|
|
1992
|
+
else {
|
|
1993
|
+
process.stdout.write(`Seeded the mirror from ${r.rawSourceLines} raw line(s) → ` +
|
|
1994
|
+
`${r.sourceRows} distinct run(s); mirror now holds ${r.mirrorRows}.\n` +
|
|
1995
|
+
'Raw lines exceed runs because a run appends a "running" row and ' +
|
|
1996
|
+
"later a terminal one; readers take the last. Not loss.\n");
|
|
1997
|
+
}
|
|
1998
|
+
process.exit(0);
|
|
1999
|
+
}
|
|
2000
|
+
const r = compareStores(dir, mirror);
|
|
2001
|
+
process.stdout.write(json ? `${JSON.stringify(r, null, 2)}\n` : formatCompare(r));
|
|
2002
|
+
// Non-zero on disagreement so this is usable as a gate before the flip.
|
|
2003
|
+
process.exit(r.agree ? 0 : 1);
|
|
2004
|
+
}
|
|
2005
|
+
finally {
|
|
2006
|
+
mirror.close();
|
|
2007
|
+
}
|
|
2008
|
+
})();
|
|
2009
|
+
}
|
|
1954
2010
|
if (process.argv[2] === "halts") {
|
|
1955
2011
|
const args = process.argv.slice(3);
|
|
1956
2012
|
const wantHelp = args.includes("--help") || args.includes("-h");
|