mirror of
https://github.com/block/buzz.git
synced 2026-11-06 09:21:45 +00:00
Four correctness fixes on top of the am/peon feedback round: 1. publish_prepared_persona_via_flush now checks the readiness latch (ReadinessState::Ready for exactly the prepared scope's db_path) before calling flush_pending_events_at. Unready or InProgress → row stays pending, returns Queued. Avoids publishing during boot/workspace reconcile window before scope-wide arbitration completes. New test: test_publish_via_flush_blocked_when_latch_not_ready uses an accepting relay so a bypass would flip the assertion. 2. retain_agent_record gains a user_intent: bool parameter. Interactive saves pass true (clears publish_blocked even on unchanged-content early-return); boot reconcile passes false. tombstone_managed_agent_pending and tombstone_team_pending route through retain_user_intent_event. snapshot import callers (team_snapshot, personas/snapshot/import) use retain_user_intent_event. All three config kinds now reopen gated rows on explicit user action. New tests: test_retain_agent_record_user_intent_clears_gate_but_reconcile_does_not (via retain_agent_record production seam) and test_non_persona_tombstone_user_intent_clears_gate (kind-5 tombstone path). 3. mark_synced_and_stamp_baseline wraps both SQL statements in a single SQLite transaction (unchecked_transaction). The baseline is only stamped when the compare-and-clear affected the intended row (rows_changed == 1). A crash or error between the two statements can no longer produce pending_sync=0 without a baseline stamp. New test: test_mark_synced_and_stamp_baseline_atomic_both_written_on_success verifies both pending_sync cleared AND baseline stamped in one call. 4. quarantine_unprovable_pending replaces the stale baseline_event_id IS NULL column check with a NOT EXISTS subquery against persona_baselines (the table baselines now live in). publish_prepared_persona_via_flush replaces the aggregate-flushed-count + row-absence published heuristic with a per-coordinate check: baseline stamped with the expected event_id (primary) OR row pending_sync cleared with matching content (fallback). Co-authored-by: Will Pfleger <pfleger.will@gmail.com> Signed-off-by: Will Pfleger <pfleger.will@gmail.com>