Repository navigation
fix: Name hook-carrier watch sources apart from their session source - #5229
Conversation
… source PR #5225 gave each carrier source the bare harness name, so it collided with the provider's own session source: any by-name lookup (default_sources mapped by name, the run-catchup name set) silently saw only the last one, and two daemon CLI tests went red on master. Carrier sources are now <provider>-hooks; the test fixture builder uses the same name. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01Sx3uCnEiY7MXtLt4FDEYfw
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Warning Review limit reachedNext included review available in 17 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 (5)
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. |
The watch source name is the provider hint at acquisition, so the distinct carrier names need runtime aliases back to their harness; a test pins both the name uniqueness and the provider resolution. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01Sx3uCnEiY7MXtLt4FDEYfw
…#5228) ## Summary The convergence stage engine runs off the daemon writer lease (polylogue-ssplv), the daemon's seventeen hand-rolled periodic loops are one observable runner (polylogue-74wvj), and the event bus has its first real producer/consumer pair (polylogue-14t7). ## Problem `converge_batch` ran entirely inside `DaemonWriteCoordinator.run_sync`, so Drive downloads, archive-wide materializers and the debt-drain's stage construction all held the sole writer; in a synthetic five-stage pass the writer was held 99.6% of the time. Seventeen loops each carried their own sleep/jitter/error handling, eight of them with cadences that had drifted from the registry. Nothing consumed the event bus. ## Solution - `ConvergenceStage.writer_admission` is a typed field: `bridged` stages compute outside admission and bracket only their publication with `admit_stage_write` (`polylogue/core/stage_admission.py`); `whole_execute` names the residual. Converted: attachment_bytes, claude_workflow, delegation_work_evidence, sinex_publication. Residual: raw_authority_verdict_cache, standing_queries. Callers defer the pass through `defer_convergence` and run it after their coordinated region releases the writer. - `polylogue/daemon/periodic.py`: one runner with declared intervals, jitter, run-first vs sleep-first, recorded skips and failures, per-loop last-run/next-run/last-error surfaced through the status payload. Deleted loops: cli.py ×11 (schema_preflight_recheck, fts_merge, wal_checkpoint, status_snapshot_refresh, drive_source_catchup, heartbeat, lifecycle_heartbeat, db_optimize, convergence_check, raw_observation_convergence, health_check), blob_gc_periodic ×2, embedding_backlog ×2, secret_scan_sweep ×1. `judgment_automation` stays hand-rolled (async failure receipt on config reload) with a test asserting the exemption. A test holds registry cadences and loop bodies together. - `announce_ingest_committed` publishes `IngestCommitted` post-commit; the embedding backlog loop waits on the event or its interval, whichever first. Measured (synthetic, 200 ms compute + 10 ms publish × 5 stages): writer held 1.050 s of 1.054 s before, 0.050 s of 1.050 s after. ## Closure `write_effects.py` and `core/stage_admission.py` are IN the derived-schema closure; the identity moves. Lands before the rebuild, never during one. ## Verification - `agentctl ... verify_quick` → job 2550 **succeeded** (after the closure-baseline declaration 5b57142) - `agentctl ... pytest_focused -- <touched test files + daemon cli, live watcher, live batch>` → job 2545: 487 passed, 2 failed (both the master-red test_daemon_cli tests fixed forward in #5229) - Worker: daemon selection 484 passed / 1 inherited failure; revision_backfill 105 passed; new test modules green; `gate layering` 0 violations; `gate atlas` green; ruff/mypy clean. ## Residuals - Inherited at base, not touched: `test_embedding_readiness.py::test_readiness_failure_branch_counts_error_message_rows`, `test_codex_state_live_ingest.py::test_codex_goal_materials_do_not_cross_supersede_source_roots`. - `daemon/status.py`: one added key and one import (PR #5220 overlap kept minimal); `daemon/http.py` untouched. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01Sx3uCnEiY7MXtLt4FDEYfw --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Same defect class as the carrier sources: two default watch sources shared the name inbox. The legacy root is inbox-legacy and maps to the inbox debt family; the uniqueness test now holds for every default source. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01Sx3uCnEiY7MXtLt4FDEYfw
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01Sx3uCnEiY7MXtLt4FDEYfw
## Summary
Archive-bound writer ownership becomes total (polylogue-8qm4k): a
writable open of any archive tier without the in-process write lease is
refused at `sqlite3.connect` itself, and one write coordinator exists
per event loop.
## Problem
Lease enforcement was per connection factory. Every declared factory
asserted the lease, but ~70 direct `sqlite3.connect` sites could
reintroduce an unserialized writer invisibly (the 2026-09-05 rehearsal
death: a concurrent writer held source.db past DB_TIMEOUT during the
Drive catch-up). The standalone HTTP write runtime also built a
`DaemonWriteCoordinator` outside the per-loop registry, so a second
serialization queue could be minted on the same loop.
## Solution
- `polylogue/storage/sqlite/write_guard.py`:
`install_archive_write_guard` wraps `sqlite3.connect`; a writable open
of one of the six tier files asserts `require_write_lease`, with
`declared_unguarded_write(reason)` as the single thread-local seam for
bootstrap/test authorities. Armed inside `run_daemon_services`'
writer-boundary block.
- `register_write_coordinator`: one coordinator per loop; the standalone
runtime registers the one it builds.
- The guard's first integration run caught a real census miss: startup
durable-change-train reconciliation opened every durable tier read-write
inside `run_daemon_services` outside the lease (`daemon/cli.py` →
`durable_change_train._open_existing_tier`, 14 call sites); it now runs
under `write_lease("daemon.durable_change_train.startup")`. Three
test-side writable opens became read-only and one genuine test authority
declares itself.
- Census of every writable tier open at 89618f9 (table in the worker
report, condensed in the commit): every production daemon route already
reached the lease (via `require_write_lease`, `admit_stage_write`,
bridged stages or the HTTP write gate); CLI maintenance, MCP telemetry
and the offline generation builder are cross-process authorities outside
any in-process lease by construction.
- The #4683 locked-chunk guard still holds after #5228; a new test
reproduces the lock race with two synthetic writers on a scratch
archive.
- `docs/sqlite-connection-policy.md` gains the writable-open boundary
section.
## Closure
`daemon/write_coordinator.py` is IN the derived-schema closure; the
identity moves. Lands before the rebuild.
## Verification
- `agentctl ... verify_quick` → job 2605 **succeeded** (2591 failed on
layering/consumer-reachability/closure for the new module; fixed in
afbd03f)
- `agentctl ... pytest_focused -- <write lease/guard, convergence,
coordinator, watcher, http, daemon cli, ingest batch>` → job 2606: 511
passed, 2 failed (both the master-red test_daemon_cli tests fixed
forward in #5229)
- Worker: 240 + 137 passed over the affected files; ruff/mypy clean.
## Residuals
- The guard is armed only in the daemon writer boundary; the standalone
HTTP write runtime and MCP server do not arm it.
- `storage/index_generation.py`'s three writable generation opens are
not explicitly leased; if a daemon-side generation build reaches them
they will now be refused. Smoke this at the start of the fresh build
(polylogue-i3i5k owns the full-scale proof; 8qm4k stays open as that
gate).
- `daemon/http.py`: two lines (PR #5220 overlap).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01Sx3uCnEiY7MXtLt4FDEYfw
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
- **New Features**
- Added connection-level protection for archive SQLite databases,
requiring an active write lease before writable connections are opened.
- Added safe handling for declared administrative or maintenance writes.
- Extended daemon startup recovery so durable changes occur within the
single-writer boundary.
- Registered standalone HTTP writers with their write coordinator to
improve coordination.
- **Bug Fixes**
- Prevented uncoordinated archive writes while leaving read-only,
in-memory, and non-archive connections unaffected.
- **Documentation**
- Documented writable SQLite connection boundaries, lease requirements,
and approved bypass behavior.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Claude Fable 5.1 <[email protected]>
…ute (#5233) ## Summary One intake route (polylogue-v4dcc, operator ruling 2026-09-16): the fair-intake dispatcher admits whole pages as one live ingest batch, and the watcher's chunk/catch-up/debounce/failed-retry route is deleted. Measured 3.0x end-to-end on a synthetic 500-file corpus through the production dispatcher. ## Problem `polylogued run` has intaked through `FairIntakeDispatcher` one file per `ingest_files` call since #4913, so every per-batch fixed cost (retention scan, six-tier bootstrap, convergence pass, cursor initialise, one writer hold) was paid per file, and the parse-stage prefetch received one path at a time. The watcher's own 4-file chunk route was still in the tree, exercised only by tests and the perf harness, and every campaign number measured that dead route. ## Solution - `FairIntakeDispatcher._service_class` plans a page against the class deficit (bytes-aware, stops at the class share, never splits below one file) and calls one `admit_page`; adapters without it still get per-item `admit`. - `FileIntakeAdapter.admit_page`: authority gate → `cursor.initialize` → `select_ingest_candidates` → one `ingest_files` batch → one embedding and one session-profile convergence for the page → one outcome per path from `LiveBatchMetrics` (`succeeded_paths`, new `excluded_paths`/`deferred_paths`, `failed_paths`), so deficit, retry_after and isolation stay per item; `AdmissionOutcome.DEFERRED` is new; `MultiplexIntakeAdapter` splits a page along source ownership; `LiveParseStage` is warmed with the page. - Deleted (ledger in the commit, pinned by `tests/unit/architecture/test_one_intake_route.py`): `_catch_up` and its planner/candidate/chunk/pledge helpers, `_periodic_catch_up`, the debounce queue, the failed-retry scan, `_flush_convergence_off_writer`, `_stage_write_admission`, `intake_hints_only`, `catch_up_active`, `debounce_s`, the `_CATCH_UP_*` constants, and `run_live_watcher` (no production caller). The unclaimed-file sweep moved into the dispatcher's discovery walk; cursor comparison and reconciliation scope became `LiveWatcher.select_ingest_candidates`. - Kept deliberately: the writer hold around `_ingest_files`, now per page rather than per file. Removing it refuses the daemon's own ingest because `ingest_files`' ops-tier writes are not self-admitting (follow-up bead filed). - Discovery follows directory symlinks with cycle detection over resolved real paths (polylogue-lu1dk, a regression since #4913 the deleted scan had masked): a cycle or dangling link is a typed `daemon.intake.discovery_failed` per path, a link into the archive root is never followed, and source ownership matches the lexical path as well as the resolved one (a second bug: linked files were discovered, then disowned). - New events: `daemon.intake.page_refused`, `daemon.intake.item_retryable`. - Harness: `/realm/tmp/work/perf-2026-09-15/real_ingest_driver.py` gained `--dispatcher`, `--admit-per-item`, `--synthetic N`, `--budget/--page-size`. ## Measured (500 synthetic claude-code files, 8.44 MB, same host, 17 dispatcher passes) | shape | wall | end-to-end MB/s | files/s | peak RSS | |---|---|---|---|---| | per-item admission (base) | 155.28 s | 0.054 | 3.22 | 180 MB | | page admission (after) | 51.66 s | 0.163 | 9.68 | 237 MB | Receipts under `/realm/tmp/work/intake-route-perf/`. Run in the foreground because host backpressure had frozen the bulk pool for ~50 min; rerunnable through the `scratch` operation. ## Closure `sources/live/{watcher,batch,metrics,parse_prefetch}.py` are IN the derived-schema closure; the identity moves. Lands before the rebuild, never during one. ## Verification - `agentctl ... verify_quick` → job 2637 **succeeded** (2634 failed on two stale test typings, fixed in bd15f51) - `agentctl ... pytest_focused -- <13 touched test files + fair intake + daemon cli>` → job 2635: 518 passed, 3 failed (the two master-red test_daemon_cli tests fixed in #5229 and the inherited codex goal-materials test); the two fixed test files re-ran 92/92 green - Worker: 518 passed / 3 inherited failures over the 13 touched files; `gate atlas`, `gate layering`, `gate patterns` green; ruff/mypy clean. ## Residuals (filed as beads) - Ops-tier writes inside `ingest_files` are not self-admitting (hold stays per page). - Dead `catch_up_cycle` readers, inert `--debounce-s`, `catch_up_complete` now meaning "watcher ready", coarser unreadable-subtree accounting, Claude sidecar forced reparse gone. Sequenced after PR #5220 (daemon/status.py). 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01Sx3uCnEiY7MXtLt4FDEYfw --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Summary
Carrier watch sources introduced by #5225 are named
<provider>-hooksinstead of the bare harness name.Problem
hook_carrier_watch_sourcesnamed each carrier source after its harness (claude-code,codex,hermes), colliding with the provider's own session source. Any by-name lookup saw only the last one:default_sources()mapped by name reported the Claude Code root as<archive>/hooks/carriers/claude-code, and two tests intests/unit/daemon/test_daemon_cli.pywent red on master (test_workspace_env_isolates_typed_default_source_roots,test_polylogued_run_can_skip_configured_source_catchup; the latter also still expected the deletedhookssource).Solution
Carrier sources are
<provider>-hookswith runtime provider aliases back to their harness (the watch source name is the acquisition provider hint); the pre-existing duplicateinboxname on the legacy data-home inbox source becomesinbox-legacy(mapped to the same debt family); a test pins that every default source name is unique and every carrier name resolves to its provider.Verification
agentctl ... pytest_focused -- test_daemon_cli.py test_hook_carriers.py test_hook_events.py test_live_watcher.py test_fair_resumable_intake.py→ job 2570: 400 passed (carrier, hook-event, watcher, intake); job 2573: 272 passed (daemon CLI, debt alert, watcher) with one test-side resolver slip; job 2576 succeeded (107 passed, daemon CLI after the fix)agentctl ... verify_quick→ job 2574 succeeded (all gates ok)Residuals
The integration selection for #5225 did not include
test_daemon_cli.py; that is the gap this fixes forward.🤖 Generated with Claude Code
https://claude.ai/code/session_01Sx3uCnEiY7MXtLt4FDEYfw