fix: align WAL multi-surface DB safety

- align app and standalone MCP busy-timeout and retry behavior
- guard live DB dev and restore flows
- document WAL maintenance boundaries
This commit is contained in:
“BeeRad”
2026-04-25 16:09:14 +10:00
parent b5ef0191d7
commit c9fb623e02
10 changed files with 226 additions and 48 deletions
@@ -1,6 +1,6 @@
'use strict';
const { query, getDb } = require('./sqlite-client');
const { query, getDb, runWithBusyRetry } = require('./sqlite-client');
/**
* Get all edges.
@@ -74,12 +74,14 @@ function createEdge(edgeData) {
VALUES (?, ?, ?, ?, ?)
`);
const result = stmt.run(
from_node_id,
to_node_id,
JSON.stringify(context),
source,
now
const result = runWithBusyRetry(() => stmt.run(
from_node_id,
to_node_id,
JSON.stringify(context),
source,
now
),
'createEdge'
);
const edgeId = Number(result.lastInsertRowid);
@@ -109,14 +111,14 @@ function updateEdge(id, updates) {
};
const stmt = db.prepare('UPDATE edges SET context = ? WHERE id = ?');
stmt.run(JSON.stringify(newContext), id);
runWithBusyRetry(() => stmt.run(JSON.stringify(newContext), id), 'updateEdge');
} else if (contextUpdates) {
const newContext = {
...existing.context,
...contextUpdates
};
const stmt = db.prepare('UPDATE edges SET context = ? WHERE id = ?');
stmt.run(JSON.stringify(newContext), id);
runWithBusyRetry(() => stmt.run(JSON.stringify(newContext), id), 'updateEdge');
}
return getEdgeById(id);