feat(FN-4042): add SQLite lock contention recovery in core database layer

Adds SQLite lock contention recovery for WAL-mode databases, covering both the core database layer (db.ts, central-db.ts, store.ts) and the run-audit subsystem, with comprehensive unit and integration test coverage and updated storage documentation.

Fusion-Task-Id: FN-4042
This commit is contained in:
Fusion
2026-05-12 00:40:40 -07:00
committed by gsxdsm
parent 8b0fc50a84
commit 43c8aa58f9
8 changed files with 540 additions and 36 deletions

View File

@@ -4137,21 +4137,23 @@ export class TaskStore extends EventEmitter<TaskStoreEvents> {
metadata: input.metadata,
};
this.db.prepare(`
INSERT INTO runAuditEvents (
id, timestamp, taskId, agentId, runId, domain, mutationType, target, metadata
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
`).run(
event.id,
event.timestamp,
event.taskId ?? null,
event.agentId,
event.runId,
event.domain,
event.mutationType,
event.target,
toJsonNullable(event.metadata),
);
this.db.transaction(() => {
this.db.prepare(`
INSERT INTO runAuditEvents (
id, timestamp, taskId, agentId, runId, domain, mutationType, target, metadata
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
`).run(
event.id,
event.timestamp,
event.taskId ?? null,
event.agentId,
event.runId,
event.domain,
event.mutationType,
event.target,
toJsonNullable(event.metadata),
);
});
return event;
}