Commit ec155dc
committed
feat(server): Phase 0 plumbing for state.db durable-write split
Adds default_state_db_path (.calm/state.db, mirrors default_db_path),
a state_db_path field on CalmServer (propagates to every for_connection
clone via ..self.clone()), and two new connection helpers:
make_state_read_conn (query_only read) and state_write_conn
(open_state_writer, synchronous=FULL) — the state.db counterparts of
make_read_conn/memory_write_conn.
new_with_preset now also initializes state.db (init_state_db) and runs
migrate_legacy_durable_tables to pull any durable rows a pre-split
index.db still has, before recover_incomplete/reconcile_stale_at_startup
-- both of which now scan the state connection instead of the index one.
Nothing yet calls the new read/write helpers from a tool handler (Phase
2-4 of docs/plans/2026-08-05-state-db-rewiring-execution-plan.md) --
this commit only stands the plumbing up. Empirically confirmed while
testing this phase: 80 calm-server tests already fail on unmodified
HEAD with "no such table: edit_transactions" et al -- independent proof
of the plan doc's §0 finding that PR #58 split the durable schema out
of index.db without wiring any real call site to state.db, so every
durable-table operation on a freshly created index.db currently targets
a table that doesn't exist there.
Also found while wiring: memory_write_conn is shared by remember AND
pattern_debt_register/pattern_debt_status, but pattern_debt lives in
the rebuildable index.db, not state.db -- so unlike the plan doc's
§2.1 table (which said to redirect memory_write_conn itself), this adds
a separate state_write_conn instead and leaves memory_write_conn
pointed at index.db for pattern_debt's sake. remember's own call site
moves to state_write_conn in the next phase.1 parent c095a8d commit ec155dc
3 files changed
Lines changed: 75 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
723 | 723 | | |
724 | 724 | | |
725 | 725 | | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
726 | 737 | | |
727 | 738 | | |
728 | 739 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
239 | 239 | | |
240 | 240 | | |
241 | 241 | | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
242 | 249 | | |
243 | 250 | | |
244 | 251 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
48 | 78 | | |
49 | 79 | | |
50 | 80 | | |
| |||
60 | 90 | | |
61 | 91 | | |
62 | 92 | | |
63 | | - | |
| 93 | + | |
64 | 94 | | |
65 | 95 | | |
66 | 96 | | |
| |||
71 | 101 | | |
72 | 102 | | |
73 | 103 | | |
74 | | - | |
| 104 | + | |
75 | 105 | | |
76 | 106 | | |
77 | 107 | | |
| |||
82 | 112 | | |
83 | 113 | | |
84 | 114 | | |
85 | | - | |
| 115 | + | |
86 | 116 | | |
87 | 117 | | |
88 | 118 | | |
89 | 119 | | |
90 | 120 | | |
| 121 | + | |
91 | 122 | | |
92 | 123 | | |
93 | 124 | | |
| |||
192 | 223 | | |
193 | 224 | | |
194 | 225 | | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
195 | 249 | | |
196 | 250 | | |
197 | 251 | | |
| |||
0 commit comments