pi-mega-compact 0.20.78 → 0.20.79

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.
@@ -157,6 +157,7 @@ function loadDb(stateDir) {
157
157
  const { DatabaseSync } = require("node:sqlite");
158
158
  const { join } = require("node:path");
159
159
  const db = new DatabaseSync(join(stateDir, "mega-compact.db"));
160
+ db.exec("PRAGMA busy_timeout = 5000"); // tolerate concurrent-opener WAL contention (see store/sqlite/utils.ts)
160
161
  db.exec("PRAGMA journal_mode=WAL");
161
162
  _dbCache.set(stateDir, { db });
162
163
  return { db };
@@ -71,6 +71,13 @@ export function openStore(stateDir = getStateDir()) {
71
71
  if (!existsSync(stateDir))
72
72
  mkdirSync(stateDir, { recursive: true });
73
73
  const db = new DatabaseSync(join(stateDir, "sqlite.db"));
74
+ // busy_timeout BEFORE journal_mode/schema writes: with the default 0ms a
75
+ // second process opening this global DB while a live session holds a WAL
76
+ // write/recovery lock fails instantly with SQLITE_BUSY — the "Failed to load
77
+ // extension: database is locked" abort that kills child pi runs (e.g. agent
78
+ // dispatches). 5s grace waits out transient contention; connections.ts and
79
+ // global-index.ts already follow this.
80
+ db.exec("PRAGMA busy_timeout = 5000");
74
81
  db.exec("PRAGMA journal_mode = WAL");
75
82
  db.exec("PRAGMA foreign_keys = ON");
76
83
  initSchema(db);
@@ -56,9 +56,9 @@ export function openTurnDb(stateDir, options) {
56
56
  mkdirSync(stateDir, { recursive: true });
57
57
  }
58
58
  const db = new DatabaseSync(resolvedPath);
59
+ db.exec("PRAGMA busy_timeout = 5000");
59
60
  db.exec("PRAGMA journal_mode = WAL");
60
61
  db.exec("PRAGMA foreign_keys = ON");
61
- db.exec("PRAGMA busy_timeout = 5000");
62
62
  initTurnSchema(db);
63
63
  // S49B: one-time move of legacy main-db turn tables into turns.db (idempotent,
64
64
  // non-fatal). File-backed only; never runs for the in-memory test backend.
@@ -56,6 +56,7 @@ export function openOccurrenceStore(dbPath) {
56
56
  if (!existsSync(dir))
57
57
  mkdirSync(dir, { recursive: true });
58
58
  const db = new DatabaseSync(dbPath);
59
+ db.exec("PRAGMA busy_timeout = 5000"); // tolerate concurrent-opener WAL contention (see store/sqlite/utils.ts)
59
60
  db.exec("PRAGMA journal_mode = WAL");
60
61
  db.exec("PRAGMA foreign_keys = ON");
61
62
  db.exec(SCHEMA);
@@ -56,6 +56,7 @@ export function openOccurrenceStore(dbPath) {
56
56
  if (!existsSync(dir))
57
57
  mkdirSync(dir, { recursive: true });
58
58
  const db = new DatabaseSync(dbPath);
59
+ db.exec("PRAGMA busy_timeout = 5000"); // tolerate concurrent-opener WAL contention (see store/sqlite/utils.ts)
59
60
  db.exec("PRAGMA journal_mode = WAL");
60
61
  db.exec("PRAGMA foreign_keys = ON");
61
62
  db.exec(SCHEMA);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-mega-compact",
3
- "version": "0.20.78",
3
+ "version": "0.20.79",
4
4
  "description": "Layered, local, vector-backed context compressor for pi — supersede/collapse/cluster compaction with deduped inline recall.",
5
5
  "type": "module",
6
6
  "license": "BSD-3-Clause",
@@ -200,6 +200,7 @@ function loadDb(stateDir: string): { db: import("node:sqlite").DatabaseSync } {
200
200
  const { DatabaseSync } = require("node:sqlite") as typeof import("node:sqlite");
201
201
  const { join } = require("node:path") as typeof import("node:path");
202
202
  const db = new DatabaseSync(join(stateDir, "mega-compact.db"));
203
+ db.exec("PRAGMA busy_timeout = 5000"); // tolerate concurrent-opener WAL contention (see store/sqlite/utils.ts)
203
204
  db.exec("PRAGMA journal_mode=WAL");
204
205
  _dbCache.set(stateDir, { db });
205
206
  return { db };
@@ -73,6 +73,13 @@ export function openStore(stateDir: string = getStateDir()): DatabaseSync {
73
73
 
74
74
  if (!existsSync(stateDir)) mkdirSync(stateDir, { recursive: true });
75
75
  const db = new DatabaseSync(join(stateDir, "sqlite.db"));
76
+ // busy_timeout BEFORE journal_mode/schema writes: with the default 0ms a
77
+ // second process opening this global DB while a live session holds a WAL
78
+ // write/recovery lock fails instantly with SQLITE_BUSY — the "Failed to load
79
+ // extension: database is locked" abort that kills child pi runs (e.g. agent
80
+ // dispatches). 5s grace waits out transient contention; connections.ts and
81
+ // global-index.ts already follow this.
82
+ db.exec("PRAGMA busy_timeout = 5000");
76
83
  db.exec("PRAGMA journal_mode = WAL");
77
84
  db.exec("PRAGMA foreign_keys = ON");
78
85
  initSchema(db);
@@ -64,9 +64,9 @@ export function openTurnDb(
64
64
  mkdirSync(stateDir, { recursive: true });
65
65
  }
66
66
  const db = new DatabaseSync(resolvedPath);
67
+ db.exec("PRAGMA busy_timeout = 5000");
67
68
  db.exec("PRAGMA journal_mode = WAL");
68
69
  db.exec("PRAGMA foreign_keys = ON");
69
- db.exec("PRAGMA busy_timeout = 5000");
70
70
  initTurnSchema(db);
71
71
  // S49B: one-time move of legacy main-db turn tables into turns.db (idempotent,
72
72
  // non-fatal). File-backed only; never runs for the in-memory test backend.
@@ -74,6 +74,7 @@ export function openOccurrenceStore(dbPath: string): DatabaseSync {
74
74
  const dir = dirname(dbPath);
75
75
  if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
76
76
  const db = new DatabaseSync(dbPath);
77
+ db.exec("PRAGMA busy_timeout = 5000"); // tolerate concurrent-opener WAL contention (see store/sqlite/utils.ts)
77
78
  db.exec("PRAGMA journal_mode = WAL");
78
79
  db.exec("PRAGMA foreign_keys = ON");
79
80
  db.exec(SCHEMA);