Repository navigation
fix(daemon): repair backup scope, restart resume and derivation barrier - #5664
Conversation
Backup copied source.db whole but scoped the blob set, and the debt report computed from it, to the newest sealed generation. A restore carried earlier generations' rows without their blobs and nothing counted the gap. Project liveness over every generation, so the backup, its debt report and verification see the same reference set. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4
…first part The runtime returned any durable non-terminal record instead of dispatching, so a request accepted just before a restart stayed at accepted forever although its handler resumes unstarted parts safely. Only a started attempt (running or indeterminate) is the recovery authority now; accepted falls through to the live exchange or the handler. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4
…barrier Staged routes honored the Sinex primary barrier, but derivation owners run their own convergers without that stage, so FTS, session profiles, summaries, usage rollups and embeddings could derive a session whose newest revision was still unpublished. The kernel takes the barrier, holds a session-derived key as pending/blocked, and holds everything when the barrier cannot be read. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4
|
You have reached your Codex usage limits for security reviews. Please try again later. |
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: 474e07de3c
ℹ️ 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".
…d sessions Review follow-up. Marker lowering maps each carrier to every session it names, so the barrier holds the batch when any waits. The barrier applies only to required keys, since retiring excess output derives nothing new, and a session no longer in the archive is never held, so its leftover demand or bindings can retire. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8142758266
ℹ️ 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".
…intenance Review follow-up. The absent-session exemption moves from the global barrier into the index-backed session domains, so marker carriers for a deleted session still wait. Exact-target maintenance consults the same barrier for required targets. summary() classifies failed from current stage state only. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dd2482bed6
ℹ️ 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".
…ssion Review follow-up. Compute runs outside the writer, so a newer unpublished revision can be staged between the pre-compute barrier check and publication. Both the kernel and the selected maintenance route now re-check inside the admitted publish and refuse it as pending/blocked. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2f49d09d38
ℹ️ 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 `polylogued run` now applies pending declared durable migrations when it opens the archive, before it serves anything. A step that changes existing data runs only behind a backup the daemon takes itself and scratch-verifies. ## Problem - Durable tiers (`source`, `user`, `audit`) evolve by numbered migrations with change-train sidecars. #5646 deleted `ops maintenance migrate-tier`, their only application route, so `execute_durable_change_train` had no production caller. - No durable migration is declared today. The first one would therefore have shipped with no way to apply it except a maintenance command, which the operator has ruled out. ## Solution - `operations/durable_change_train.py` gains `pending_durable_migrations`. It lists each durable tier standing below the runtime's declared version that has a complete declared route (every step from the current version to the target) and says whether any step requires a backup. A tier with no declared route is left alone, and schema preflight still reports its skew. - `daemon/durable_migrations.py` adds `apply_declared_durable_migrations`. For each pending tier it runs `execute_durable_change_train` under the daemon's write lease, with the daemon's exclusive archive ownership. The daemon keeps that ownership afterwards, so the train's release is a no-op. - For a step that requires a backup, `pre_migration_backup` first runs `backup_archive(verify=True)` into `.maintenance-state/pre-migration-backups/`: - It uses the `user_overlays` profile for user and audit, and `rebuildable_cache_exclude` for source, which carries its blobs. - The train binds the backup's authenticated receipt to the exact pre-apply bytes. - A failed backup refuses startup. - `backup_archive` accepts `archive_owner`: the caller's existing exclusive ownership. The backup copies under that ownership instead of acquiring its own, which the daemon's own lock would refuse at open. - `daemon/cli.py` calls the route right after durable-change-train reconciliation, inside the same ownership scope, and emits `daemon.durable_migration.applied` for each applied tier. - The durable-schema section of `docs/maintenance.md` describes the route. ## Verification - `tests/unit/daemon/test_durable_migrations.py` ships synthetic numbered migration packages: - An archive already at the runtime version is left alone and gets no backup directory. - An additive `source` step applies without a backup, and a second open is a no-op. - A data-changing `user` step applies only after a verified backup; the manifest and verification receipt are present. - `devtools test` over `test_durable_migrations.py`, `test_daemon_cli.py` and `test_backup.py`: `185 passed, 3 failed`. - `test_run_daemon_services_parks_operation_recovery_on_audit_schema_mismatch` failed because the first version tried to migrate a tier with no declared route. That is fixed, and it passes on rerun with the migration tests. - `test_run_daemon_services_waits_for_fts_startup_before_watcher` (2 parametrizations) fails the same way on current master: its fake converger lacks the `derivation_barrier` argument #5664 added. - `devtools gate mypy`: `Success`. - `devtools gate schema-closure`: `ok`, no change (567). ## Residuals - The source-tier backup copies referenced blobs, so a data-changing source migration pays that copy at open. 🤖 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]>
- expect an unavailable snapshot when no rich observation exists (#5621); - let the converger test double accept derivation_barrier (#5664); - expect the request model's normalized mark payload; - measure a steady-state chunk: the first chunk after seeding also prunes the seeding's raw-existence journal, one trigger per row (#5657); - inject the thread-insight failure at the ArchiveStore the route reads. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4
## 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]>
Summary
Four daemon and backup defects from the bug sweep:
acceptedforever.DaemonConverger.summary()counts a file that failed and later converged once.Problem
backup.pycopiedsource.dbwhole but scoped the copied blob set, and the debt report computed from it, to the newest sealed generation. Earlier generations'raw_sessionsandblob_refsrows came back without their blobs, and nothing counted the gap.operation_runtime.pyreturned any durable non-terminal record without dispatching. An execution batch durably accepted just before its daemon died, with every part unattempted, stayed atacceptedon every retry. Its handler already resumes unstarted parts and never replays a consumed one.DaemonConvergerwith no stages. The Sinex stage'sblocks_following_stagesnever reached them, so in primary mode they could derive a session whose newest revision was unpublished.summary()countederror_count > 0as failed even for a converged file, so the buckets overlapped andin_progresswent negative.Solution
running/indeterminate) is the recovery authority.acceptedfalls through to the live exchange if one exists, and otherwise to the handler.PublicationBarrier. A session-derived domain implementsbarrier_sessions(frame, keys). A held key is pending/blocked, and an unreadable barrier holds everything.configured_derivation_barrier()returns the barrier only in primary mode, and composition passes it to all three owners. The blocking query moves to a module-level read,primary_blocking_object_ids, paged under SQLite's parameter ceiling.summary()makes the buckets mutually exclusive.Verification
devtools test tests/unit/daemon/test_backup.py tests/unit/storage/test_blob_liveness.py tests/unit/daemon/test_converger_summary.py tests/unit/daemon/test_daemon_operation_route.py tests/unit/daemon/test_derivation_kernel_laws.py tests/unit/daemon/test_convergence_stages.py tests/unit/sinex tests/unit/storage/test_blob_conservation.py→233 passed.test_cancelled_long_delete_retains_writer_until_blocked_apply_releasesfailed once under a saturated pool and passed alone on the automatic rerun.devtools gate mypy→ exit 0;devtools verify --quick→ PASSED.Residuals
devtools schema closure:blob_liveness.py,fts/derivation.pyand three session derivation modules are IN, so this must land before a rebuild.polylogue/daemon/convergence_stages.pyalso carries the lineage recompose stage another change is removing; the edits here don't touch it.🤖 Generated with Claude Code
https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4