Repository navigation
Commit 7ec3cdc
authored
fix: pending_review store integrity — disk-backed queue + load-time hygiene sweep (#257)
Bug 1: Confirm/Reject/List operated purely on in-memory state, so a running
serve process and a CLI process each served stale pending ids ("pending
review X not found"). The pending array is now disk-backed:
- List/Confirm/Reject re-read user_model.json under an advisory flock
(user_model.json.lock) before lookup/mutation
- applyDiff writes through immediately, keeping the on-disk array
authoritative; non-pending state (style/focus) is preserved per process
- read errors on List fail open to the last known snapshot
Bug 2: pending entries referencing consumed atom ids accumulated forever.
Load now runs a hygiene sweep: entries whose value text references atom ids
that are ALL missing from the atom store are dropped (only when an atom
checker is installed; transient read errors count as present — fail-open),
drops are logged with ids, and identical (field, value) duplicates
consolidate to the highest-confidence entry. ExtendedMemory.New wires the
checker to the live atom store.
Adversarial-review hardening: applyDiff write-through also runs under the
flock and syncs the queue from disk first (a serve inference cycle can no
longer resurrect a CLI-confirmed entry); mutate treats the full disk state
as authoritative (no stale style/focus clobber); the sweep probes only the
entry value and requires every referenced atom to be gone before dropping.
RED-first tests in pending_store_integrity_test.go cover cross-process
write-through, concurrent no-loss mutations, self-referential defect
entries, sweep drop/keep/dedup, and the list-vs-disk invariant.1 parent 86caa44 commit 7ec3cdc
6 files changed
Lines changed: 711 additions & 19 deletions
File tree
- docs
- internal/memory/extended
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
280 | 280 | | |
281 | 281 | | |
282 | 282 | | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
283 | 287 | | |
284 | 288 | | |
285 | 289 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
128 | 138 | | |
129 | 139 | | |
130 | 140 | | |
| |||
0 commit comments