fix(gate3): configure WAL once at initialization
Davood Mehraban committed
Nov 1, 2026 at 21:28 UTC
d75cbbbc16068acc3735e8d1e8204ee57d266318
1 file changed
+6
-1
backend/src/aram_backend/mapping_store.py
+6
-1
@@ -17,6 +17,7 @@ class MappingStore:
17
if self.path == ":memory:":
18
raise MappingWorkflowError("durable store requires a filesystem path")
19
with self._connect() as db:
20
+ db.execute("PRAGMA journal_mode=WAL")
21
db.executescript("""
22
CREATE TABLE IF NOT EXISTS mapping_state (
23
company TEXT NOT NULL, year INTEGER NOT NULL,
@@ -34,7 +35,6 @@ class MappingStore:
35
def _connect(self):
36
db = sqlite3.connect(self.path, timeout=15, isolation_level=None)
37
db.execute("PRAGMA busy_timeout=15000")
37
- db.execute("PRAGMA journal_mode=WAL")
38
db.execute("PRAGMA synchronous=FULL")
39
return db
40
@@ -93,6 +93,11 @@ class MappingStore:
93
if len(new_events) == len(old_events) and payload != row[1]:
94
raise MappingWorkflowError("state changed without audit event")
95
appended = new_events[len(old_events):]
96
+ if appended and not all(
97
+ event["mapping_id"] in {d.mapping_id for d in workspace.decisions}
98
+ for event in appended
99
+ ):
100
+ raise MappingWorkflowError("audit event references unknown mapping")
101
else:
102
appended = [asdict(e) for e in workspace.audit]
103
if workspace.decisions and not appended: