Skip to content

fix(observer): seed SSE revision persistently and fence closed-server loops - #111

Merged
DTALEX66 merged 3 commits into
mainfrom
fix/observer-runtime-truth-round2
Aug 15, 2026
Merged

fix(observer): seed SSE revision persistently and fence closed-server loops#111
DTALEX66 merged 3 commits into
mainfrom
fix/observer-runtime-truth-round2

Conversation

@DTALEX66

Copy link
Copy Markdown
Owner

Summary

WL3-600 persistent-SSE hardening — three real P0 gaps on current main
(9090da6), each with a failing-test-then-fix (RED→GREEN):

P0-1 — canonical readback failure no longer keeps LIVE

_last_canonical_ok_at is now invalidated (None) when the canonical
fingerprint readback raises, so cursor_valid cannot stay LIVE on thread
liveness alone. Test: test_failing_canonical_readback_removes_live.

P0-2 — SSE revision is persistent across restarts

New sse_state table (schema migration v3) + CanonicalStore.record_revision();
seed_revision() prefers sse_state.last_revision. A restarted sidecar now
seeds SseRevisionHub from the stored revision, keeping Last-Event-ID
cursors monotonic instead of resetting the sequence to 1.

P0-3 — SSE serve loop fenced by server closure

/api/v1/events returns 503 once the server is closed, and the serve loop
breaks out of its heartbeat cycle on server._closed — an old handler can no
longer refresh _last_heartbeat_at (or touch a closed store) after shutdown.
Test: test_sse_handler_loop_stops_after_server_close (also cleans up the
Windows serve_forever select noise with an explicit shutdown()).

Verification

  • test_sidecar_v3_snapshot.py + test_snapshot_sse_live.py: 50 passed, 7 subtests passed, 0 warnings
  • tests/ci/test_aggregate_gate.py + test_governance_gate.py: 17 passed
  • py_compile clean on all three modified scripts

… loops

- persist the SSE revision in a new sse_state table so a restarted sidecar
  seeds its revision hub from the stored value (Last-Event-ID cursors stay
  monotonic across restarts)
- fail closed when canonical readback fails: _last_canonical_ok_at is
  invalidated so cursor_valid cannot keep LIVE on thread liveness alone
- stop the SSE serve loop once the server is closed (no more heartbeats
  after store shutdown) and reject new /api/v1/events connections with 503
@DTALEX66
DTALEX66 merged commit 1c0e25f into main Aug 15, 2026
14 checks passed
@DTALEX66
DTALEX66 deleted the fix/observer-runtime-truth-round2 branch August 15, 2026 12:14
DTALEX66 added a commit that referenced this pull request Aug 15, 2026
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