Skip to content

fix: pending_review store integrity (disk-backed queue + hygiene sweep) - #257

Merged
jkyberneees merged 1 commit into
mainfrom
fix/pending-review-store-integrity
Sep 19, 2026
Merged

jkyberneees merged 1 commit into
mainfrom
fix/pending-review-store-integrity

Conversation

@jkyberneees

Copy link
Copy Markdown
Contributor

Fixes the extended-memory pending-review store desync between odek serve and the CLI ("pending review X not found"), plus stale/duplicate entry hygiene.

  • Pending queue is disk-backed: confirm/reject/list re-read user_model.json under an advisory flock; applyDiff writes through under the lock
  • Load-time sweep drops entries whose referenced atoms are all gone (logged) and consolidates (field, value) duplicates to highest confidence
  • Adversarial-review hardening: no resurrection of confirmed entries via the inference path; transient atom-store errors never cause drops

RED-first tests: 13 new, -race green, lint clean. Docs: docs/EXTENDED_MEMORY.md.

…ygiene sweep

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.
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
odek 31b3594 Commit Preview URL

Branch Preview URL
Sep 19 2026, 03:22 PM

@jkyberneees
jkyberneees merged commit 7ec3cdc into main Sep 19, 2026
13 of 14 checks passed
@jkyberneees
jkyberneees deleted the fix/pending-review-store-integrity branch September 19, 2026 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant