Repository navigation
fix(daemon): recover session profiles after promotion and restart - #5570
Conversation
|
You have reached your Codex usage limits for security reviews. Please try again later. |
|
Warning Review limit reachedNext included review available in 47 seconds. 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: 17c9f54ea5
ℹ️ 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".
17c9f54 to
604d3e9
Compare
604d3e9 to
b480d0f
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b480d0f62d
ℹ️ 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".
## Summary Fixes one product defect and realigns daemon and MCP tests that fail on master because they encode superseded contracts. ## Problem A per-directory run of `tests/unit/daemon` and `tests/unit/mcp` on clean master (`03c543dfe`) failed 28 and 11 tests. This PR covers the clusters below. Other failures belong to named owners or need a decision; see Residuals. - **Product defect: MCP hides daemon rejections.** When the resident daemon refused a write before durable acceptance, MCP callers saw `write: internal error (DaemonOperationRejectedError)`. The daemon's typed code and detail were lost, for example why a saved view cannot be watched. - **MCP tests that write with no daemon.** Public archive writes are daemon-owned since #5550. Nine MCP tests plus three standing-query tests still wrote with no daemon and got `FacadeDaemonRequiredError`. - **Stale daemon expectations:** - Since #5621 a snapshot with no rich observation is `unavailable`, not `stale`. - #5664 passes `derivation_barrier` to the converger, which the test double did not accept. - The mark-delete route test compared against the raw payload rather than the request model's normalized one. - The chunk-cost test measured the first chunk after seeding. Since #5657, that chunk also prunes the seeding's raw-existence journal, one trigger firing per row, so its cost grew with archive size once. - The insights failure injection patched the facade the route no longer reads. ## Solution - `_exception_to_error_json` relays `DaemonOperationRejectedError` with the daemon's code and detail, as the CLI does. - New `tests/infra/mcp.py::daemon_served_runtime_services` runs the real operation stack on the archive's socket for MCP write tests. The load-evidence test seeds its deliveries under the daemon and measures reads without it. - Each stale expectation is realigned; the chunk-cost test converges one warm-up chunk and measures a steady-state chunk. ## Verification `devtools test` over the affected daemon and MCP tests plus the MCP error-translation tests: `165 passed, 1 failed` (receipt `20260928T000820Z-focused-test-736375-35660df1`, pre-rebase). The one failure is `test_working_dir_demand_withholds_profile_readiness`, tracked in polylogue-6remh. The rebase kept master's own fix to `test_convergence_debt_alert.py` and dropped this branch's change to that file. No other conflicts. Review follow-up (`f189af7`): `WatchDefinitionError` declares `invalid_watch_definition`. MCP reports an undeclared (prose) rejection code as `rejected`. `DaemonClient` keeps a pre-dispatch refusal's public detail. `devtools test tests/unit/mcp/test_tool_error_isolation.py …::test_skewed_write_refusal_is_pre_dispatch_not_an_indeterminate_mutation tests/unit/daemon/test_standing_queries_default_evaluator.py` passed (receipt `20260928T003051Z-focused-test-966381-9c978486`). `devtools schema closure`: `archive/query/watch_definition.py` is IN, so this lands before a rebuild. ## Residuals - polylogue-6remh (filed): since #5570, periodic profile ticks run the startup audit before demanded work. This starves demand and contradicts #5540's idle-tick contract. It leaves `test_two_accepted_revisions_survive_one_periodic_profile_pass`, `test_working_dir_demand_withholds_profile_readiness` and likely `test_real_factory_defers_hot_target_without_losing_the_no_hint_cursor` red. - Not covered here: - master-fix-owned clusters: the read-authorizer `not authorized` regression, `selected_session_parts` and `raw_observation_derivation`; - daemon failures still to diagnose: schema preflight behind the #5657 frontier gate, status baseline `ok`, evidence-summary lineage authority, stale archive storage, Drive asserted-authority growth, the watcher-hint timeout, and status component metadata. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4 --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
… per tick A periodic profile tick ran the archive-wide startup audit, one domain slice at a time, before any demanded session work (#5570). Demanded profiles therefore waited for the whole sweep after every start, and an idle tick kept inspecting. Decision (polylogue-6remh): #5540's contract wins. Every tick runs the demand pass first. The startup/promotion audit advances only in bounded slices through converge_backlog after demand, and does not repeat once swept. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4
## Summary Periodic profile ticks now serve demanded session work before the archive-wide audit, and never re-run the audit once it has swept (polylogue-6remh). Phased Drive catch-up binds a grown document as an asserted revision again instead of quarantining it. The halted-units status test gets a genuinely green baseline. ## Problem - **Demand starved behind the audit (6remh).** Two landed contracts conflicted. #5540 says a periodic tick publishes demanded work and an idle tick inspects nothing. #5570 made every unscoped tick run the startup audit one domain slice at a time (summary, usage rollup, profile; 128 keys each) before any demand pass. Take a one-session archive with pending `session_profile_demand`: the first `callback(None)` returned `outcomes=()`, and no profile was published. On a large archive, demanded profiles waited for all three domains to sweep after every daemon start. `test_two_accepted_revisions_survive_one_periodic_profile_pass` and `test_working_dir_demand_withholds_profile_readiness` were red on master. - **Drive scratch missed a relation.** Phased Drive preparation classifies revision lineage against an in-memory snapshot of the cohort. Since #5630, membership classification also reads `source_item_raw_members`, and the scratch did not carry that table. Every grown Drive document was therefore quarantined instead of being bound to its predecessor (`test_drive_phased_matches_ordinary_document_growth`). - **Halted-units test baseline.** The healthy frontier fixture set only `overall_status` over unknown sub-checks. That is not a proof, and it refutes `ok`, so the test's "green before the halt" baseline was not green. ## Solution - Decision recorded on 6remh: #5540's contract wins. `callback(None)` runs only the demand pass. The startup/promotion audit advances in bounded slices through `ComposedSessionProfiles.converge_backlog` after that demand pass, and it does not repeat once swept (only promotion resets it). Tests that encoded the per-tick audit now drive `audit_pass` / `converge_backlog`. The insights race test now models the replacement at the record the route actually compares. - `_prepare_ingest_unit_sync` snapshots the cohort's `source_item_raw_members` into the scratch alongside the other relations, and revalidates it at publish in the same way. - The halted-units test pins every collector to a measured healthy value, keeping the archive's real raw-failure lifecycle, and the shared frontier fixture proves each sub-check. `devtools schema closure`: both source files are `out`, so the derived identity does not move. ## Verification - `devtools gate mypy`: `Success: no issues found in 3095 source files` - `devtools test` on session profile composition, the periodic-pass test, insights browser endpoint, convergence restart law, raw-materialization fair intake, Drive catch-up execution, status observations and status unmeasured: pending; this body is updated with the receipt when it reports ## Residuals - None known for these three changes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01P8nGdByCWAzpk78ko2xza6 --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
|
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
Problem
A watcher can finish intake while a cold build is writing an inactive index. Its profile callback then inspects the old active index; promotion makes the new sessions visible without a corresponding profile pass. A restarted owner can also find a missing profile with no demand hint. A single shared-budget pass can spend its budget on summary and usage prerequisites before reaching profiles, and a completed domain restarts on the next pass.
Solution
The composed owner advances a bounded summary, usage, then profile sweep, retaining each domain's cursor across periodic ticks. Promotion starts up to three bounded ticks immediately, so a small new generation converges promptly; larger generations continue from their saved position. The profile sweep keyset-pages all sessions, including missing profiles with no demand hint. Targeted callbacks keep their demand-only route and cannot replace the archive cursor. Once the sweep finishes, ordinary periodic callbacks return to demand-only work. A fresh owner begins a new sweep after restart.
The resilience fixtures retain nonzero-ingestion, partial-progress, cancellation, and teardown checks while separating startup/admission waits and preserving failure diagnostics. The pager edit is in the derived schema closure, so it moves the derived identity; land it before starting a fresh rebuild.
Verification
devtools test tests/unit/daemon/test_session_profile_composition.py— 6 passed, including a 131-session budget regression and a fresh-owner restart. Receipt:20260927T002217Z-focused-test-187156-14cd1195. The strengthened 131-session case clears demand after prerequisites and passed separately:20260927T002538Z-focused-test-191011-fb7d892f.devtools test tests/unit/storage/test_session_profile_derivation.py::test_profile_input_demand_is_transactional_and_late_worker_cannot_ack_it tests/property/test_inferred_corpus_loop.py::test_inferred_selection_profiles_recover_in_a_fresh_process— 2 passed.devtools test tests/unit/daemon/test_daemon_cli.py::test_daemon_watcher_hints_wake_fair_intake_and_canonical_derivation— passed all 4 parameters; one case exceeded the unchanged cancellation deadline on the first pass and passed the harness's isolated rerun.git diff --check, Ruff lint, and the commit's format/lint hook passed.The final local quick gate was interrupted when shared host I/O backpressure reached about 80%; the hosted
ci/circleci: quick-gateis the final-head candidate gate. The full five-file OL2FC selector has not passed on an integrated candidate. The SIGKILL case was held during backpressure, and the separate inferred-corpus relative-path fix is owned by another lane. Keeppolylogue-ol2fcopen until the integrated five-file run satisfies its acceptance criterion.