Repository navigation
fix(daemon): Close eight live P1 findings in the daemon surface - #5414
Conversation
A resuming subscriber's completeness is inferred from MIN(id) alone, but two routes could break that inference and deliver a short OK page instead of the AGED_OUT refusal the gap is supposed to raise: - age retention deleted by ts_ms, which is not monotonic in id (observed_at_ms is caller-supplied and the wall clock can step back), so an interior row could be removed while an older id survived; - query_events_since read the retained range and the page in autocommit, so a writer pruning between the two statements was observed by the second read but not the first. Age retention now removes the id prefix below the first row the horizon retains, and the range check and page query share one read transaction. Verification: devtools test tests/unit/daemon/test_event_cursor.py tests/unit/daemon/test_daemon_events_endpoint.py tests/unit/daemon/test_events_sse_framing.py tests/unit/daemon/test_event_bus.py -> PASSED exit=0. Anti-vacuity executed: restoring the ts_ms predicate makes test_out_of_order_row_survives_age_prune and test_cursor_page_keeps_every_event red (assert 1 == 0; assert ['third'] == ['out-of-order', 'third']); dropping the BEGIN/rollback pair makes test_prune_between_range_and_page_unseen red (assert ['c'] == ['a','b','c']). Derived schema closure: polylogue/daemon/events.py is OUT; identity unmoved. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy
The guard that stopped persisting capped/sampled/estimated evaluations as a watch baseline only prevented new ones. A user.db written before it can still carry a baseline whose own exactness is not 'exact', and the first exact evaluation after upgrading compared its full merkle root against that partial root -- emitting a definitive query-delta for a membership change nobody ever observed, which is the same false claim the guard exists to prevent. A non-exact stored baseline is now unmeasured rather than a prior observation: the first exact evaluation replaces it silently and claims no delta against it, and a non-exact tick facing one records only its degraded receipt because there was never a measured membership to drift from. Verification: devtools test tests/unit/daemon/test_standing_queries.py tests/unit/daemon/test_standing_queries_default_evaluator.py tests/unit/daemon/test_maintenance_read_profiles.py -> PASSED exit=0. Anti-vacuity executed: restoring the unguarded `baseline` comparison makes all three new tests red, the first with `baseline_ref":"result-set:watch-legacy-capped"` inside an emitted query-delta finding. test_exact_delta_after_legacy_baseline_replaced pins the opposite direction, so silencing every delta cannot pass. Derived schema closure: polylogue/daemon/convergence_standing_queries.py is OUT; identity unmoved. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy
… once A class may consume its own reserve plus the shared remainder and never another class's -- but admission and dispatch checked only the submitting group's own ceiling. That is true of each group taken separately and false of any two together: on the default eight-worker pool control and incremental-background each have a four-slot ceiling, so four blocking tasks in each occupied the whole pool while both stayed inside their bound, and the three slots the snapshot advertised as reserved for interactive-read stopped existing. The queue behaved the same way: two saturated non-interactive groups left one unit of twenty-four for an interactive request whose declared reserve is nine. Both paths now check the complement: a unit starts only if what remains still covers every other group's unmet reserve. The reserve stays hard, so a saturated non-interactive mix now leaves the reserved capacity idle when the reserved class has nothing queued; that is the cost the per-group ceilings already paid for a single class, and a soft reserve would hand the slot away exactly at the moment an interactive request arrives. Verification: devtools test tests/unit/daemon/test_execution.py -> PASSED exit=0 (all pre-existing fairness laws included). Anti-vacuity executed: restoring the per-group-only dispatch check makes test_combined_classes_cannot_take_the_interactive_reserve red (`assert False where False = wait_started(1)`); restoring the raw capacity_units admission check makes test_combined_classes_cannot_take_the_interactive_queue red (`assert 1 >= 9`). Derived schema closure: polylogue/daemon/execution.py is OUT; identity unmoved. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy
…dget Ordinary raw admission budgets the whole expanded component: RawObservationDerivation.compute calls expand_raw_membership_selection and compares sum(sizes.values()) against its payload limit. Whale selection compared the seed row's own size, which discovery reports. A membership/revision component whose members are each inside the 64 MiB ordinary limit but whose total is not therefore failed every ordinary admission and was never offered to the whale owner, so it stayed unmaterialized indefinitely. The whale predicate now asks the same question the budget asks, skipping the extra bounded read when the seed alone already exceeds the limit. An unreadable component size is reported as unmeasured and the raw is left to ordinary admission rather than failing the periodic pass. The docstring also claimed the pass runs "only after the ordinary trickle conveyor has drained to quiescence". Nothing enforces that: the caller sets the intake wakeup event and immediately awaits this pass. The real check is the head of the discovery page, and the docstring now says so and names the dispatcher signal a true quiescence gate would need. Verification: devtools test tests/unit/daemon/test_whale_selection.py tests/unit/daemon/test_raw_materialization_parse_stage_equivalence.py -> PASSED exit=0. Anti-vacuity executed: restoring the per-raw predicate makes test_whale_selection_measures_component red (`assert False` on the pass's return) with no session published. Its fixture is two revisions of one source path, each under the limit and together over it; a seed that alone exceeds the limit is selected by both predicates and proves nothing. Derived schema closure: polylogue/daemon/cli.py is OUT; identity unmoved. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy
…e holds build_daemon_status treated `stale` as a sixth refusal state. It is not: it means "the last good value, plus a background refresh that has not landed". The persistent periodic registry is polled every _STATUS_SNAPSHOT_REFRESH_INTERVAL_SECONDS plus jitter while its components carry StatusComponentSpec's 10s ttl_s, so the TTL expires on essentially every tick. Measured over the production registry at a 10.5s cadence: fresh, stale, fresh, stale. On every stale tick the published snapshot threw away a ten-second-old reading and served the unknown-readiness defaults for raw-materialization, session-summary and live-ingest -- an unknown raw frontier with ok: false for half of the daemon's life. What decides whether that value is a current measurement is the fingerprint it was collected under. The registry keys its components on the index/ops tier mtimes, so an unchanged fingerprint means the value still describes the live frame, and a changed one means the collector in flight is answering a question the held value cannot -- which is precisely the "frame that is no longer authoritative" case the blanket rule stood in for. A snapshot with no fingerprint establishes no currency and stays unmeasured, so the ephemeral per-call registry is unaffected. Verification: devtools test tests/unit/daemon/test_status_stale.py tests/unit/daemon/test_daemon_status.py -> PASSED exit=0. Anti-vacuity executed both ways: putting "stale" back into the unmeasured set makes test_stale_with_current_fingerprint_is_measured and the production-route test_second_tick_keeps_the_raw_frontier_reading red; replacing the fingerprint arm with `return False` makes test_stale_with_changed_fingerprint_unmeasured and test_stale_without_fingerprint_is_unmeasured red. Derived schema closure: polylogue/daemon/status.py is OUT; identity unmoved. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy
…g it
GET /w/compare fell through to the generic typed-data page, whose scalar
branch projects any value with str(). The compare envelope's left, right,
pairs and metadata_diff are whole session payloads and a full pairing over
them, so that branch emitted an escaped Python repr of every message, once per
key that holds it. Measured on a twelve-message fixture: 20 205 bytes of HTML
carrying 480 copies of the message-text fragment, unbounded in the length of
the transcripts behind it. The page was also unreadable -- four `<dd>` blobs of
`{'session_id': ...}`.
Compare now has a structure-aware renderer: a metadata table, an aligned-pair
table with one bounded `_compact_preview` per message, and the window,
alignment and unresolved sides kept on the page because the pairing covers
exactly that window. The same fixture renders in 6 092 bytes with each message
appearing once and no repr. The generic page's scalar slot now reports a
bounded count for a nested structure rather than its repr, so no future typed
route can dump one either.
Verification: devtools test tests/unit/daemon/test_webui_compare.py
tests/unit/daemon/test_daemon_http_security.py
tests/visual/test_reader_dom_smoke.py -> PASSED exit=0.
Anti-vacuity executed: delegating render_compare_page back to
render_typed_data_page and restoring the str() scalar projection turns four
tests red, including `assert 135477 < (18837 * 1.5)` for a tenfold longer
message and the literal `{'session_id': ...` dump; removing the
route dispatch alone turns test_compare_route_uses_the_compare_renderer red
with the payload landing in the generic renderer. Two first-draft assertions
were refuted by that mutation (one was self-referential, one varied message
count, which both implementations grow with) and were rebuilt against the
preview bound and against message length instead.
Derived schema closure: polylogue/daemon/webui.py and polylogue/daemon/http.py
are both OUT; identity unmoved.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy
`operation.cancel` against a queued, pre-acceptance mutation was rejected with
`operation_reference_unknown` -- for the operation it had just cancelled. The
scheduler completes a queued task's future synchronously inside `cancel()`,
and the runtime's `settled` callback removes the exchange in the same call, so
the control loop's next look found neither a live exchange nor a durable
machine record and read that absence as "no such operation".
Reproduced at HEAD against the production runtime with a saturated kernel:
`mutation.session.delete.preview` reports `cancelled` to its own caller while
the cancel request returns
`{'code': 'operation_reference_unknown', 'retryable': False}`.
The control request now remembers that it released a live exchange which had
not started acceptance, and answers `cancelled` with `effect: no-effect`.
Nothing is committed before acceptance, so the cancellation is the whole
outcome. An absence this request did not cause is still
`operation_reference_unknown`.
Verification: devtools test tests/unit/daemon/test_queued_cancel.py
tests/unit/daemon/test_operation_recovery_identity.py -> PASSED exit=0.
Anti-vacuity executed: removing the pre-acceptance branch restores the
`operation_reference_unknown` rejection above.
test_cancel_of_an_unknown_reference_is_refused pins the opposite direction, so
answering `cancelled` unconditionally cannot pass.
Derived schema closure: polylogue/daemon/operation_runtime.py is OUT; identity
unmoved.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy
`gate mypy` refused three things the focused runs did not: `data.get("left")`
narrows to `object` across two separate calls, `RawMaterializationReadiness`
has no `broken_head_count` field, and the admission-class loop's cast was
redundant.
Verification: devtools verify --quick -> 21/22 gates green, `gate atlas` red
with the same docs/atlas/daemon.md hook-carrier anchor it reports at the base
SHA 17566b0 (PR #5408 owns it). devtools render all --check -> exit 0, zero
"out of sync" lines. devtools test over every changed file, in two batches ->
PASSED exit=0.
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 19 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 (15)
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: 5b7cc828bd
ℹ️ 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. |
|
Closing out open Codex review threads on this PR (evidence checked against master at 0914f89):
Resolving every thread listed; confirmed defects are fixed under the named bead. |
Summary
Eight live P1 review findings closed in
polylogue/daemon/, from a triage of all 38 anchored daemon findings.24 STALE (63%), 8 LIVE-and-fixed, 3 declined with measurements, 2 superseded, 6 exact duplicates.
What the stale rate says about the filter
63% is the highest of any lane — storage measured 34%, devtools 57%. The cause is specific and worth recording:
With six exact duplicates, a 38-row brief was really ~22 distinct questions, ten of which one refactor had already answered. The filter asks "did this line move?" when the real question is "does this code still exist?"
Fixed
The event ledger's cursor completeness proof was unsound. Age retention deleted
WHERE ts_ms < horizon, while_cursor_refusal_reasoninfers completeness fromMIN(id)alone. Timestamps are caller-supplied (observed_at_ms, wall-clock step), so a legitimately out-of-order interior row is removed and a subscriber below the hole gets anOKpage silently missing it. Retention now deletes the id prefix below the first row the horizon retains.Mutation:
assert ['third'] == ['out-of-order', 'third'], withtest_expired_prefix_is_removedstaying green to pin the opposite direction.The same file took two read snapshots per page.
open_readonly_connectionleaves the connection in autocommit andops.dbis WAL, so_retained_rangeand the page SELECT could straddle a prune — delivering a short page with statusOK. Now oneBEGIN/rollbackread transaction. Mutation:assert ['c'] == ['a', 'b', 'c'].Half of all published status snapshots served unknown-readiness defaults. Measured over the production
StatusComponentRegistryat the real 10.5 s cadence against the default 10 sttl_s: fresh, stale, fresh, stale — each stale snapshot carrying a perfectly good previous value, whilebuild_daemon_statuslistedstaleamong the unmeasured states. Replaced with_component_is_unmeasured, which keeps a stale value only while the fingerprint it was collected under still holds, so the original concern (a changed or absent fingerprint must stay unmeasured) is preserved exactly.Two non-interactive classes could jointly take the interactive reserve. With
max_workers=8, queue_units=16, control and incremental-background each haveceiling_slots=4; four blocking tasks in each filled all 8 workers while both stayed inside their own bound, and a subsequent interactive read never started. The queue half left 1 of 24 units against an interactive reserve of 9. Admission and dispatch now check the complement.A whale could never be selected.
RawObservationDerivation.computebudgetssum(sizes.values())over the expanded membership, butRawMaterializationDiscovery._with_costsreports each seed row's ownblob_size— and the whale predicate compared the latter. A component whose members are each inside the ordinary limit but whose total is not failed every ordinary admission and was never escalated. Selection now measures the expanded component.A cancel reported the operation it had just cancelled as unknown. Cancelling a queued
mutation.session.delete.previewreturned{'code': 'operation_reference_unknown', 'retryable': False}, because the scheduler settles the future synchronously andsettledremoves the exchange in the same call.control()now answerscancelledwitheffect: no-effect.A non-exact watch baseline produced a definitive false delta. A pre-guard
user.dbbaseline withexactness='capped'madesame_snapshotFalse, advanced the baseline, and compared an exact merkle root against a partial one — emitting a definitivequery-delta. A non-exact stored baseline is now unmeasured./w/comparestringified its envelope. Measured: 20,205 bytes of HTML and 480 copies of the message-text fragment for 12 short messages, as escaped Python reprs. Same fixture now 6,092 bytes, 0 reprs.Declined, with the measurement
future.cancel()returns True andfuture.done()is True immediately, while the coroutine'sfinallycleanup has not run — soshutdown()returns while a staged ingest is still unwinding. Declined: every correct remedy changes production shutdown sequencing, and no deterministic anti-vacuity test for "the compute owner was closed while cleanup was pending" was achievable without new harness machinery. Shipping an unproven change to shutdown is worse than the current bounded-but-real gap.FairIntakeDispatcher/DaemonIntakeServicesignal a true gate needs — the gate itself lives inoperations/intake_adapters.py, outside this scope.deterministic_raw_session_idhashessource_path, so the ingest operation (caller's path) and the watcher (staged path) mint two raw_ids for identical bytes. Both remedy sites are incli/andsources/live/watcher.py. This is an ownership decision — which route owns machine imports — not a daemon-local fix.storage_correctness_scenario.pystates in its own comment.Verification
Rebased onto master
1f996e133.devtools verify --quick→ exit 0, 25/25 gates green. (At the lane's base this was 21/22 with the then-inheritedgate atlasred, byte-identical at base and branch; fix(storage): Close seventeen live P1 review findings in the storage tier #5408 has since fixed it.)devtools render all --check→ exit 0,grep -c 'out of sync'= 0.Schema closure
All eight changed production files report
out— independently re-confirmed after rebase. The derived schema identity does not move and no reconvergence is implied by this PR.Anti-vacuity
Seven mutations executed, each restored, each with its opposite direction pinned. Notably, three first-draft tests were refuted by their own mutations and rebuilt: one self-referential, one that varied with message count (which both implementations grow with), and one where a probing collect consumed the stale tick, leaving the build finalising a settled attempt as fresh.
The whale test deserves note: the fixture is two revisions of one source path, each under the limit and together over it — because a seed that alone exceeds the limit is selected by both predicates and could not separate them.
Residuals
storage/raw_authority.py:606carries a docstring cross-reference toauto_resolve_stale_plan_blockers, a function that no longer exists anywhere. Cosmetic, outside this scope.RawObservationConvergenceOwner._converge_lockfor its duration.🤖 Generated with Claude Code
https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy