Repository navigation
fix(cli): Lower annotations import onto a declared daemon operation - #5400
Conversation
`polylogue annotations import` was the last CLI-invisible durable writer: it drove `OperationExecutor` against `user.db` from the CLI process via `polylogue.annotations.importer.import_annotation_batch`, a module the mutation-authority layering rule did not name until the rule was extended to match by drive rather than by spelling (polylogue-gjwto). That extension turned the hole into a reviewed baseline entry (`docs/plans/layering-cli-mutation-authority-baseline.json`); this closes it by declaring `mutation.annotation.import_batch`, giving it a daemon handler that reuses the existing actuator plus the shared `resolve_ref_against_archive` implementation (PR #5370) instead of a second ref-resolution path, and rewiring the CLI command onto `submit_cli_mutation` (polylogue-r29bv AC3). The handler drives the actuator's `async def import_annotation_batch` from a synchronous daemon handler. A bare `asyncio.run(...)` would mint a new task and lose the write lease bound to the calling thread/task, so the handler mints a `delegate_write_lease()` on the calling thread and adopts it inside the new task -- the declared mechanism for exactly this handoff (`polylogue/daemon/write_coordinator.py` uses the same pattern). The CLI-side `polylogue.annotations.importer` import is gone, so the baseline shrinks from three entries to two (the two `polylogue/api` entries stay, blocked on decision D2 per the existing baseline reason). Verification: - devtools test tests/unit/cli/test_annotation_import_command.py -- 3 passed - devtools test tests/unit/api/test_operation_executor_routes.py tests/unit/operations/test_cli_operation_binding_registry.py tests/unit/operations/test_operation_bindings.py tests/unit/cli/test_cli_storage_boundary.py tests/unit/devtools/test_layering_gates.py tests/unit/api/test_facade_contracts.py::test_facade_import_annotation_batch_persists_candidate_provenance tests/unit/api/test_facade_contracts.py::test_facade_import_annotation_batch_uses_default_registry tests/unit/cli/test_setting_command.py tests/unit/annotations/test_importer.py -- 87 passed, 9 failed, all 9 in test_layering_gates.py over an unrelated durable-write-census fixture gap (devtools/, zero diff here, reproduces identically against origin/master 6fa8440; not fixed by this lane) - devtools gate layering, gate api-parity, gate declaration-bindings -- ok - devtools verify --quick -- 25/25 gates ok - devtools render all --check -- no "out of sync" - devtools schema closure -- every changed file OUT of the derived schema identity closure - Anti-vacuity (executed): reverted annotations.py to the pre-fix in-process writer, ran test_annotations_import_refuses_without_a_daemon -- failed with the row importing successfully with no daemon running (assert 0 != 0 / exit_code 0), then restored the fix and reran the full file -- 3 passed. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy
polylogue-re6s3 AC4's coverage test fails closed when a new mutating operation gains a CLI binding without a matrix row (test_the_matrix_covers_every_cli_bound_mutating_operation); the previous commit's mutation.annotation.import_batch tripped exactly that. Add its row, which surfaced a real, independent gap: `annotations import` had no `--format` option at all, so appending `--format json` (every machine-format invocation does this) failed with Click's own "No such option" before the daemon probe ever ran. Give it the same `-f/--format text|json` shape as `note`/`setting set`, defaulting to `json` to preserve its existing unconditional-JSON behavior for every caller that omits the flag. Verification: - devtools test tests/unit/cli/test_cli_operation_authority.py tests/unit/cli/test_annotation_import_command.py -- 33 passed - devtools verify --quick -- 25/25 gates ok - devtools render all --check -- no "out of sync" (annotations import is not part of the generated CLI-reference surface) - devtools schema closure -- both changed files OUT of the derived schema identity closure 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 38 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 (7)
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: a94178b8d5
ℹ️ 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-r29bvAC3, asserted bygjwto/re6s3.polylogue annotations importwas the last CLI-invisible durable writer — it droveOperationExecutoragainstuser.dbin-process. It now goes through a declared daemon operation, and the CLI-mutation-authority baseline shrinks 3 → 2.A real bug the work surfaced
Driving the actuator's
async def import_annotation_batchfrom a synchronous handler with a bareasyncio.run(...)mints a new asyncio task and loses the write lease, which is bound to the calling thread/task —UnleasedWriteError, confirmed by direct reproduction.That is the same property #5382 recorded from the other side:
write_leasebindsowner_task_id/owner_thread_idat mint time. Fixed with the declareddelegate_write_lease()/adopt_write_lease()handoff — the existingwrite_coordinator.pypattern, not a new one — and verified end to end against a real daemon stack (session written, audit row present).A gap it exposed by keeping a test honest
Adding a 12th CLI-bound mutating operation tripped
re6s3AC4's coverage test. Fixing that surfaced an independent defect:annotations importhad no--formatoption at all, so the machine-format daemon-down check failed on Click's own--format jsonbefore ever reaching the daemon probe. Added-f/--format text|json, defaulting tojsonso every existing caller is unaffected.The lane could have exempted the new operation from the matrix. It extended the matrix instead, which is why the missing flag was found.
Verification
All 9 failures are in
test_layering_gates.py(KeyError: 'file', thedurable_write_censusrenderer gap). Confirmed inherited:git diff --stat HEAD --over the three implicated files is empty — none was touched. That ispolylogue-1or21, fixed in #5393.Anti-vacuity executed: reverted
annotations.pyto the in-process writer, rantest_annotations_import_refuses_without_a_daemon→ real failure (assert 0 != 0; the row imported with no daemon running), restored, re-ran → 3 passed.d02y8deliberately not implemented — and its bead contradicts itselfThe bead carries a 2026-09-20 note recording "DECISION RESOLVED (coordinator): the daemon DOES hold the provider credential" with reasoning, and a later 2026-09-22 scoping note saying "NOT DISPATCHABLE: an operator policy decision a worker must not answer" — apparently written against the stale DESIGN section rather than the resolution above it.
The lane treated neither as authorization and made no credential choice. The three options and the implementation path under (a) are recorded on the PR for whoever rules.
Residuals
gjwtoAC6 asks to reopen/supersedepolylogue-5vps8.2, which is closed on a reason resting on a baseline the extended rule now proves could not see facade-routed writes. A Beads action for the coordinator.gjwtoAC1/AC2 stay blocked on decision D2:_execute_facade_mutationstill has 20 call sites, and the 2 surviving baseline entries are bothpolylogue/api.re6s3AC3'spipeline/services/archive_ingest.pyand the direct-tier-writer list (embed backfill, scan-secrets, backup, demo, archive-init, blob-*) were out of the collision boundary and untouched.🤖 Generated with Claude Code
https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy