Repository navigation
fix(daemon): Stop publishing cursor-lag health from a read that failed - #5398
Conversation
… no lag `cursor_lag_summary_info` swallowed every `sqlite3.Error` and returned a bare `CursorLagSummary()`. That projection is byte-identical to the one a quiet, fully caught-up archive produces, so a read that failed published "0 stuck, 0 degraded, 0 idle, worst lag 0s" to every consumer. The module's own comment admitted this and answered it with a log line -- but the log is for the operator and the *return value* is what the status and health surfaces consume. Three consumers turned that fabricated zero into a positive claim: - `evaluate_cursor_lag` derives its family set from the projection. With no families it reported no breach *and* fired an OK resolution alert for every family that was breaching at the last successful read -- "cursor lag cleared", asserted from a read that never happened. `_check_cursor_lag`'s `is_ok = not any(severity != OK)` then published cursor_lag healthy for a database it could not open. That is AC9 verbatim. - `evaluate_cursor_lag_anomaly` fabricated the same resolutions. - `format_daemon_status_lines` only prints when a count is positive, so an unreadable ledger rendered as no line at all -- identical to a quiet one. `CursorLagSummary` now carries `available` / `unavailable_reason`, the same pair `LiveCursorSummary` already had, and the marker is narrow: an absent database or absent relation is a *measured* empty ledger, only a read that raised is unavailable. `_UNMEASURED_CURSOR_LAG` carries it too, so `_v`'s stale substitute is no longer indistinguishable from a measured quiet archive -- the residual #5353 recorded and left open. Both readers now fail closed by raising `_CursorLedgerReadError` instead of returning a fabricated projection. That is also what retires their two `sqlite_degradation` anchors rather than re-anchoring them: the census exempts handlers that raise, and the baseline drops both in this change as its manifest instructs. `polylogue.storage.tier_access` was the other route and is not available -- daemon may not import it, and adding that edge would grow the layering ratchet. Anti-vacuity, all five mutations executed and restored: - index read error -> bare projection: `assert True is False` on `available` - ops read error -> "no evidence": same, with no index tier to fall back to - remove the `evaluate_cursor_lag` guard: `[OK] != [WARNING]`, the fabricated resolution reappears - `_UNMEASURED_CURSOR_LAG = CursorLagSummary()`: stale build's `available` is True with a measured quiet archive's zeros - delete the renderer branch: no cursor-lag line for an unreadable ledger Both directions pinned: a measured empty ledger stays `available`, and a genuine recovery still clears its alert. Verification (worktree /realm/worktrees/status-budgets, base bb65bc6): - devtools test (7 modules) -- 231 passed, 0 failed, exit 0 - devtools verify --quick -- exit 0, 25/25 gates, 0 FAILED - devtools render all --check -- exit 0, `grep -c "out of sync"` = 0 - devtools schema closure: all four changed production files `out` Advances polylogue-20d.17 AC3 and AC9. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy
|
Warning Review limit reachedNext included review available in 40 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (8)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4a0a7da157
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Closing out open Codex review threads on this PR (evidence checked against master at ef10e59):
Resolving the fixed, stale and refuted threads; tracked threads stay open. |
Summary
polylogue-20d.17AC3/AC9.cursor_lag_summary_infoswallowed everysqlite3.Errorand returned a bareCursorLagSummary()— byte-identical to a quiet, caught-up archive. Three consumers turned that fabricated zero into a positive health claim.All four children (
20d.17.1–.4) were already satisfied at base; the tracker was stale. Nothing was reimplemented.The defect — AC9 verbatim
The module comment admitted the swallow and answered it with a log line. But the log is for the operator; the return value is what the surfaces consume:
evaluate_cursor_lagderives its family set from the projection. With no families it reported no breach and fired an OK resolution alert — "cursor lag cleared" — for every family that was breaching at the last successful read. Asserted from a read that never happened._check_cursor_lag'sis_ok = not any(severity != OK)then published cursor_lag healthy for a database it could not open.format_daemon_status_linesonly prints on a positive count, so an unreadable ledger rendered as no line at all.CursorLagSummarynow carriesavailable/unavailable_reason, following the existingLiveCursorSummaryprecedent rather than inventing a shape. The marker is deliberately narrow: an absent database or relation is a measured empty ledger; only a read that raised is unavailable.Both readers now fail closed by raising
_CursorLedgerReadError, which also retires their twosqlite_degradationanchors rather than re-anchoring them — the census exempts handlers that raise. The manifest's other route,capture_sqlite_read, was tried and backed out:polylogue/daemonmay not importpolylogue/storage/tier_access, and adding that edge grew the layering ratchet.The two unlanded batch commits: superseded, nothing extracted
I asked this lane to salvage two commits from a 09-20 batch that never landed. It diffed both mechanically:
8590e3e91— 101/101 added lines already present at base, verbatim, including comment text.0f6603f78— 81/83 present.The two absent lines are
tier_count_unavailable = any(...)and"ok": _status_ok(...) and not tier_count_unavailable. They are absent because #5353 improved on them:tier_count_unavailablebecame a module-level function whose result is an operand of the singleoverall_status_okproducer. That inline composition was precisely the second verdict rule20d.17.1exists to eliminate — copying it back would have reintroduced the bug.They also did not fold unknowns into booleans (
planner_stats_present: None if rows is None else rows > 0is a correct tri-state). They were right-headed; #5353 built on them. Nothing cherry-picked.Anti-vacuity — five mutations
assert True is False … stuck_file_count=0evaluate_cursor_lagguardassert [OK] == [WARNING]— the fabricated resolution returns_UNMEASURED = CursorLagSummary()assert stale.cursor_lag.available is False→assert True is Falseassert any("Cursor lag: UNMEASURED")→assert FalseBoth directions pinned:
test_measured_empty_cursor_ledger_stays_availableandtest_a_readable_recovered_ledger_still_clears_its_alertstay green under every mutation.One test was refuted and rebuilt: it first failed at its fresh assertion because a
lambda **_:double rejected the production spec's positional call — fixed, then it separated red/green on the intended assertion.Verification
Derived identity identical at base and HEAD (
INDEX ce86c236…,OPS 86866235…) — the earlier INDEX movement was upstream's. Metadata-only; safe to land during a rebuild.Residuals
open_readonly_connectionraisesSchemaSkewError, notsqlite3.Error, so a schema-skewed ops tier propagates out to the registry collector. That is a typed refusal reaching the right place, but no test pins it.daemon/status.pydeletion + deletion ledger) stay open on an operator decision — the file has grown, and every landed slice has been additive hardening.devtools test(exit 137,pytest_no_report, pool ~20 deep) strands anindex.lockin the worktree gitdir, blockinggit addhours later.🤖 Generated with Claude Code
https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy