Repository navigation
refactor(operations): route remaining mutation families through MutationTransaction (polylogue-t46.9 phase 2) - #3253
Conversation
…rough MutationTransaction Problem: docs/plans/mutation-census.yaml (t46.9/kwsb.2 phase 1, PR #3249) inventoried mutate-add-tag/remove-tag/bulk-tag-sessions/set-metadata/ delete-metadata as declared-not-routed, and add_mark/remove_mark as an MCP mutation family with no OperationSpec at all -- every surface still called ArchiveStore.add_user_tags/remove_user_tags/set_user_metadata/ delete_user_metadata/add_mark/remove_mark directly instead of sharing one preview/authorize/receipt contract. Solution: add TagAddActuator/TagRemoveActuator/BulkTagActuator/ MetadataSetActuator/MetadataDeleteActuator/MarkAddActuator/ MarkRemoveActuator (polylogue/operations/mutation_actuators.py), all declaring destructive_class="reversible" and required_confirmation= "role_only" per t46.9 AC4 (reversible writes must not require interactive confirmation, unlike phase 1's confirm_flag-gated delete/ excise/reset). Each actuator wraps the existing ArchiveStore primitive unchanged; PolylogueArchiveMixin.add_tag/remove_tag/bulk_tag_sessions/ set_metadata/delete_metadata/add_mark/remove_mark (polylogue/api/ archive.py) now drive them through OperationExecutor, so CLI (query- mutation path), MCP (write(operation=...)), and the Python API facade all share the route. Added OperationSpec entries mutate-add-mark/ mutate-remove-mark (previously no spec existed) and flipped the five existing tag/metadata specs' executor_status to executor-routed; updated docs/plans/mutation-census.yaml accordingly and removed a stale duplicate "delete_metadata (MCP admin alias)" row that named the same code path as mutate-delete-metadata. Also widened the KeyError->SessionNotFoundError conversion in add_tag/ remove_tag/set_metadata/delete_metadata to cover EXECUTE's revalidation (not just the initial PREPARE), since a session deleted by a concurrent actor between AUTHORIZE and EXECUTE now surfaces the same typed error instead of a raw KeyError. Remaining polylogue-t46.9 / polylogue-kwsb.2 scope (named in the census as Phase 3 debt, not attempted here): save_annotation/delete_annotation, save_saved_view/delete_saved_view, save_recall_pack/delete_recall_pack, save_workspace/delete_workspace, record_correction/clear_corrections, capture_assertion_candidate, blackboard_post, import_annotation_batch, the rebuild_index/update_index/rebuild_insights maintenance_execute family, and the ops reset --database/--index/--blob/--assets/--cache/ --auth file-tier deletion family (still declared-not-routed, per its census row, pending a decision on whether to extend MutationPlan's target-ref vocabulary to file-tier targets or keep it a typed exemption). bound_token strength adoption and durable audit-row persistence are untouched, as scoped. Verification: devtools test tests/unit/operations/test_mutation_actuators.py tests/unit/operations/test_mutation_census.py tests/unit/operations/test_mutations.py tests/unit/api/test_facade_contracts.py tests/unit/mcp/test_mcp_edge_cases.py tests/unit/mcp/test_contract_evidence.py tests/unit/mcp/test_privileged_tools.py tests/unit/mcp/test_tool_discovery.py -> 402 passed (36+279+60+20+ overlap dedup across runs; see PR body matrix) devtools verify --quick -> exit_code 0 (ruff format/check, mypy --strict, render all --check all clean) devtools test tests/unit/cli/test_verb_cardinality.py -k test_guard_dry_run_and_deleted_sets_are_identical_and_unlimited fails identically on unmodified master (pre-existing "no running event loop" RuntimeServices ConfigError, unrelated to this change) -- confirmed via git stash before/after. Ref polylogue-t46.9 Ref polylogue-kwsb.2 Co-Authored-By: Claude <[email protected]>
|
Warning Review limit reached
Next review available in: 45 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (6)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 58e49ee9bd
ℹ️ 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".
|
Coordinator review (CodeRabbit rate-limited): read the full 1509-line diff. Consistent phase-2 shape — 7 reversible-class actuators each wrapping the exact existing ArchiveStore primitive (add_user_tags/remove_user_tags/set_user_metadata/delete_user_metadata/mark writers), role_only confirmation per AC4, api/archive.py as the single choke point for facade/CLI/MCP, KeyError widened to cover the AUTHORIZE→EXECUTE race window. Census delta honest (7 rows to executor-routed, one stale duplicate row removed). 20 anti-vacuity tests against a real seeded user.db. Pre-existing test_verb_cardinality failure verified on unmodified master by the lane — unrelated. Phase-3 residuals named in body. Merging on green quick-gate. |
…pts (#3253); file meoz delete-detonation bug; yqeo incident note Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QUsH3Rhq6oAZpYPWcsZqnZ
…gh MutationTransaction (phase 4) Problem: docs/plans/mutation-census.yaml carried save_saved_view/ delete_saved_view, save_recall_pack/delete_recall_pack, and save_workspace/delete_workspace as declared-not-routed debt since phase 2 (t46.9/kwsb.2) -- each pair still enforced authorization independently of every other destructive route, with jn40's confirm boolean the only interim mitigation for the destructive members. What changed: six new actuators (SavedViewSaveActuator/ SavedViewDeleteActuator, RecallPackSaveActuator/RecallPackDeleteActuator, WorkspaceSaveActuator/WorkspaceDeleteActuator) wrap the existing ArchiveStore.save_view/delete_view, save_recall_pack/delete_recall_pack, save_workspace/delete_workspace primitives -- all reversible class, role_only confirmation (AC4), matching the phase-2/phase-3 pattern exactly: each pair's primitive is a create-or-update upsert paired with a soft-delete (mark_assertion_status ... "deleted"), so undo is always the paired actuator through the same primitive. Six new OperationSpec entries (mutate-save-saved-view, mutate-delete-saved-view, mutate-save-recall-pack, mutate-delete-recall-pack, mutate-save-workspace, mutate-delete-workspace), all executor-routed. api/archive.py's save_view/delete_view, create_recall_pack/ delete_recall_pack, save_workspace/delete_workspace now drive their actuators through OperationExecutor instead of calling ArchiveStore directly -- async validation/item-resolution (which may consult insight-derived indexes for recall-pack/workspace targets) stays in the facade and runs once before the actuator sees already-normalized JSON payloads, mirroring AnnotationSaveActuator's pattern. MCP's write(operation='save_saved_view'/'delete_saved_view'/ 'save_recall_pack'/'delete_recall_pack'/'save_workspace'/ 'delete_workspace') already calls these facade methods, so no MCP tool signature change is needed. Also fixed a pre-existing test_specs.py gap on this branch (mirrors the one fixed on the phase-3 branch, #3258): mutate-add-mark/ mutate-remove-mark, added in the phase-2 PR (#3253, already on master), were never added to test_runtime_operation_catalog_covers_the_current_runtime_paths' expected set -- fixed while touching this file for the six new specs. Anti-vacuity: TestSavedViewActuators/TestRecallPackActuators/ TestWorkspaceActuators in tests/unit/operations/test_mutation_actuators.py drive each actuator against a real seeded user.db (real schema, real SQL) -- they fail if e.g. SavedViewSaveActuator.apply stops calling ArchiveStore.save_view, or if the delete actuators stop marking their assertion rows deleted. Existing facade-contract tests for save_view/ create_recall_pack/save_workspace (tests/unit/api/test_facade_contracts.py) pass unchanged, confirming the executor routing preserves the existing public behavior. Note: this branch is cut from master before phase 3's own PR (#3258, annotation family + raw-authority blocker resolution) merges, so that PR's census rows are not present here; docs/plans/mutation-census.yaml's header explains the ordering. Ref polylogue-t46.9 Ref polylogue-kwsb.2 Co-Authored-By: Claude <[email protected]>
…gh MutationTransaction (phase 4) Problem: docs/plans/mutation-census.yaml carried save_saved_view/ delete_saved_view, save_recall_pack/delete_recall_pack, and save_workspace/delete_workspace as declared-not-routed debt since phase 2 (t46.9/kwsb.2) -- each pair still enforced authorization independently of every other destructive route, with jn40's confirm boolean the only interim mitigation for the destructive members. What changed: six new actuators (SavedViewSaveActuator/ SavedViewDeleteActuator, RecallPackSaveActuator/RecallPackDeleteActuator, WorkspaceSaveActuator/WorkspaceDeleteActuator) wrap the existing ArchiveStore.save_view/delete_view, save_recall_pack/delete_recall_pack, save_workspace/delete_workspace primitives -- all reversible class, role_only confirmation (AC4), matching the phase-2/phase-3 pattern exactly: each pair's primitive is a create-or-update upsert paired with a soft-delete (mark_assertion_status ... "deleted"), so undo is always the paired actuator through the same primitive. Six new OperationSpec entries (mutate-save-saved-view, mutate-delete-saved-view, mutate-save-recall-pack, mutate-delete-recall-pack, mutate-save-workspace, mutate-delete-workspace), all executor-routed. api/archive.py's save_view/delete_view, create_recall_pack/ delete_recall_pack, save_workspace/delete_workspace now drive their actuators through OperationExecutor instead of calling ArchiveStore directly -- async validation/item-resolution (which may consult insight-derived indexes for recall-pack/workspace targets) stays in the facade and runs once before the actuator sees already-normalized JSON payloads, mirroring AnnotationSaveActuator's pattern. MCP's write(operation='save_saved_view'/'delete_saved_view'/ 'save_recall_pack'/'delete_recall_pack'/'save_workspace'/ 'delete_workspace') already calls these facade methods, so no MCP tool signature change is needed. Also fixed a pre-existing test_specs.py gap on this branch (mirrors the one fixed on the phase-3 branch, #3258): mutate-add-mark/ mutate-remove-mark, added in the phase-2 PR (#3253, already on master), were never added to test_runtime_operation_catalog_covers_the_current_runtime_paths' expected set -- fixed while touching this file for the six new specs. Anti-vacuity: TestSavedViewActuators/TestRecallPackActuators/ TestWorkspaceActuators in tests/unit/operations/test_mutation_actuators.py drive each actuator against a real seeded user.db (real schema, real SQL) -- they fail if e.g. SavedViewSaveActuator.apply stops calling ArchiveStore.save_view, or if the delete actuators stop marking their assertion rows deleted. Existing facade-contract tests for save_view/ create_recall_pack/save_workspace (tests/unit/api/test_facade_contracts.py) pass unchanged, confirming the executor routing preserves the existing public behavior. Note: this branch is cut from master before phase 3's own PR (#3258, annotation family + raw-authority blocker resolution) merges, so that PR's census rows are not present here; docs/plans/mutation-census.yaml's header explains the ordering. Ref polylogue-t46.9 Ref polylogue-kwsb.2 Co-Authored-By: Claude <[email protected]>
…ationTransaction (#3262) ## Summary Phase 4 of polylogue-t46.9/polylogue-kwsb.2 (make `OperationSpec` the executable mutation authority): migrates the saved-view/recall-pack/workspace family onto `OperationExecutor`, the next coherent slice of `declared-not-routed` debt named in the phase-2 receipt. ## Problem `docs/plans/mutation-census.yaml` carried three MCP write-operation pairs as `declared-not-routed` since phase 2: - `save_saved_view` / `delete_saved_view` - `save_recall_pack` / `delete_recall_pack` - `save_workspace` / `delete_workspace` Each pair still enforced authorization independently of every other destructive route, with jn40's interim confirm-boolean sweep the only mitigation for the destructive members (`delete_saved_view`, `delete_recall_pack`, `delete_workspace`). All six operations share the exact same shape already proven safe for the tag/metadata/mark/annotation families: an `ArchiveStore` primitive that is a create-or-update upsert (`save_view`/`save_recall_pack`/`save_workspace`) paired with a soft-delete (`delete_view`/`delete_recall_pack`/`delete_workspace`, each calling `mark_assertion_status(..., "deleted")`). ## Solution - **`polylogue/operations/mutation_actuators.py`**: six new actuators (`SavedViewSaveActuator`/`SavedViewDeleteActuator`, `RecallPackSaveActuator`/`RecallPackDeleteActuator`, `WorkspaceSaveActuator`/`WorkspaceDeleteActuator`), all **reversible** class, `role_only` confirmation (AC4) -- undo is always the paired actuator through the same primitive. - **`polylogue/operations/specs.py`**: six new executor-routed `OperationSpec` entries. - **`polylogue/api/archive.py`**: `save_view`/`delete_view`, `create_recall_pack`/`delete_recall_pack`, `save_workspace`/`delete_workspace` now drive their actuators through `OperationExecutor` instead of calling `ArchiveStore` directly. Async validation and item resolution (recall-pack/workspace targets may consult insight-derived indexes) stays in the facade and runs once before the actuator sees already-normalized JSON payloads -- mirroring `AnnotationSaveActuator`'s pattern from phase 3. MCP's `write(operation='save_saved_view'/.../'delete_workspace')` already calls these facade methods, so **no MCP tool signature change is needed**. - **Drive-by fix**: `tests/unit/operations/test_specs.py`'s `test_runtime_operation_catalog_covers_the_current_runtime_paths` was missing `mutate-add-mark`/`mutate-remove-mark` (added in the already-merged phase-2 PR #3253) from its expected set -- fixed while touching this file for the six new specs. (The same pre-existing gap was independently found and fixed on the phase-3 branch for PR #3258.) ### Routing matrix | Operation | Class | Confirmation | Surfaces | Status | | --- | --- | --- | --- | --- | | `mutate-save-saved-view` | reversible | role_only | mcp, api | executor-routed (new) | | `mutate-delete-saved-view` | reversible | role_only | mcp, api | executor-routed (new) | | `mutate-save-recall-pack` | reversible | role_only | mcp, api | executor-routed (new) | | `mutate-delete-recall-pack` | reversible | role_only | mcp, api | executor-routed (new) | | `mutate-save-workspace` | reversible | role_only | mcp, api | executor-routed (new) | | `mutate-delete-workspace` | reversible | role_only | mcp, api | executor-routed (new) | ### Census delta (`docs/plans/mutation-census.yaml`) - `save_saved_view / delete_saved_view` (combined `declared-not-routed` row) -> split into `mutate-save-saved-view` + `mutate-delete-saved-view`, both `executor-routed`. - `save_recall_pack / delete_recall_pack` (combined `declared-not-routed` row) -> split into `mutate-save-recall-pack` + `mutate-delete-recall-pack`, both `executor-routed`. - `save_workspace / delete_workspace` (combined `declared-not-routed` row) -> split into `mutate-save-workspace` + `mutate-delete-workspace`, both `executor-routed`. **Branch-cut note:** this branch is cut from `origin/master` before phase 3's own PR (#3258 -- annotation family + raw-authority blocker resolution) merges, so phase 3's census rows are not present in this diff; the census file's header comment explains the ordering. No conflict is expected on merge since the two PRs touch disjoint rows/regions of the file, but whichever merges second will need a routine rebase. ## Verification ``` devtools test tests/unit/operations/test_mutation_actuators.py tests/unit/operations/test_specs.py \ tests/unit/operations/test_mutation_census.py tests/unit/api/test_facade_contracts.py # 316 passed in 8.56s devtools verify --quick # exit_code: 0 (ruff format/check, mypy --strict, render all --check, topology, layering, # closure-matrix, schema roundtrip, manifests, ci-workflows, doc-commands, docs-coverage, # test-infra-currency, test-clock-hygiene, pytest-timeout-overrides, degrade-loudly) ``` Anti-vacuity: `TestSavedViewActuators`/`TestRecallPackActuators`/`TestWorkspaceActuators` in `tests/unit/operations/test_mutation_actuators.py` drive each actuator against a real seeded `user.db` (real schema, real SQL) -- they fail if e.g. `SavedViewSaveActuator.apply` stops calling `ArchiveStore.save_view`, or if a delete actuator stops marking its assertion row deleted. Existing facade-contract tests for `save_view`/`create_recall_pack`/`save_workspace` (`tests/unit/api/test_facade_contracts.py`) pass unchanged, confirming the executor routing preserves existing public behavior (creation/update/deletion semantics, return values). Not run: full `devtools verify --all` (reserved for harness/dependency changes or a final pre-merge diagnostic; the touched surface is fully covered by the focused runs above). ## Remaining polylogue-t46.9 / polylogue-kwsb.2 scope Explicitly deferred, not silently dropped (see updated `docs/plans/mutation-census.yaml`): - `record_correction / clear_corrections` -- still `declared-not-routed` (low blast radius / single-target overwrite, per existing census reason). - `capture_assertion_candidate`, `blackboard_post`, `import_annotation_batch` -- still `declared-not-routed` (additive, not destructive). - `rebuild_index / update_index / rebuild_insights` (maintenance_execute family) -- still `declared-not-routed`. - `ops reset --database/--index/--blob/--assets/--cache/--auth` (file-tier deletions) -- still `declared-not-routed`; whether to extend `MutationPlan`'s target-ref vocabulary to file-tier targets or keep this a permanent typed exemption is an open decision. - `bound_token` confirmation strength adoption (currently no actuator requires it; all destructive-class actuators use `confirm_flag`). - Durable audit-row persistence for `MutationReceipt`s. - Crash/partial-failure resume semantics for multi-target operations. Ref polylogue-t46.9 Ref polylogue-kwsb.2 Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
#3294) ## Summary Migrates the `record_correction` / `delete_correction` / `clear_corrections` learning-corrections family from `declared-not-routed` to `executor-routed` in the t46.9/kwsb.2 mutation-authority migration — phase 5 in the sequence started by #3249/#3253/#3258/#3262. ## Problem `docs/plans/mutation-census.yaml`'s `record_correction / clear_corrections` row was the next `declared-not-routed` family after phase 4 (#3262, saved-view/recall-pack/workspace) landed. These three operations independently mutated `user.db` without going through `OperationExecutor`'s PREPARE -> AUTHORIZE -> EXECUTE protocol, so they had no shared plan-hash staleness check or confirmation-strength floor — the same class of gap kwsb.2's design doc calls a security boundary (one adapter bypassing the proof required by another). ## Solution - `polylogue/operations/mutation_actuators.py`: new `CorrectionRecordActuator`, `CorrectionDeleteActuator`, `CorrectionsClearActuator` — all `reversible` class / `role_only` confirmation (AC4: reversible writes don't need interactive confirmation), following the exact same actuator shape as the annotation and workspace families. `CorrectionsClearActuator.prepare` resolves the *exact live set* of correction kinds for the session at plan time (mirroring `SessionDeleteActuator`'s re-resolve-against-live-state pattern), so a concurrent `record_correction` between AUTHORIZE and EXECUTE changes the plan hash and forces `PlanStaleError` instead of silently clearing a kind the caller never previewed. - `polylogue/operations/specs.py`: `mutate-record-correction`, `mutate-delete-correction`, `mutate-clear-corrections` `OperationSpec` entries, `executor_status="executor-routed"`. - `polylogue/api/archive.py`: `record_correction`/`delete_correction`/`clear_corrections` now build actuator args and drive `OperationExecutor.prepare/authorize/execute` instead of calling `ArchiveStore` directly. Behavior/return types are unchanged (same `LearningCorrection`/`bool`/`int` signatures). - `docs/plans/mutation-census.yaml`: replaced the single `declared-not-routed` row with three `executor-routed` rows citing their specs/actuators/adapters. - `docs/test-quality-workflows.md`: regenerated (the uncovered-runtime-operations list picked up the three new spec names, matching the existing pattern for e.g. `mutate-save-annotation`). Only this one family was migrated — per repo convention, the remaining `declared-not-routed` rows (`capture_assertion_candidate`, `blackboard_post`, `import_annotation_batch`, the `maintenance_execute` family, and the file-tier `ops reset` family) are untouched debt for later phases. ## Verification - `python -m pytest tests/unit/operations/{test_mutation_actuators,test_mutation_census,test_specs}.py -q` -> 56 passed - `devtools test tests/unit/operations/` -> 146 passed - `devtools test tests/unit/mcp/test_query_gap_projections.py tests/unit/api/test_facade_contracts.py` -> 295 passed (these two files exercise `record_correction`/`clear_corrections` through the MCP/API layers) - `python -m mypy polylogue/operations/mutation_actuators.py polylogue/operations/specs.py polylogue/api/archive.py tests/unit/operations/test_mutation_actuators.py` -> `Success: no issues found in 4 source files` - `ruff check` / `ruff format --check` on all changed `.py` files -> clean - `devtools render all --check` -> no `out of sync` surfaces (after regenerating `docs/test-quality-workflows.md`) - `devtools verify --quick` -> exit 0 (ran automatically on push via the pre-push hook too) New test: `tests/unit/operations/test_mutation_actuators.py::TestCorrectionActuators` — 5 cases including the anti-vacuity case `test_concurrent_record_between_authorize_and_execute_makes_clear_plan_stale`, which authorizes a clear-plan, records a new correction kind through a second actuator in between AUTHORIZE and EXECUTE, and asserts the held authorization is refused with `PlanStaleError` before any row is deleted — proving authorization is actually enforced, not just "it still works." Ref polylogue-kwsb.2 Ref polylogue-t46.9 Co-Authored-By: Claude <[email protected]>
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
Summary
Phase 2 of the t46.9/kwsb.2 mutation-executor migration: routes the
reversible-class tag, metadata, and mark mutation families throughOperationExecutor/MutationActuator(the PREPARE → AUTHORIZE → EXECUTElifecycle shipped in phase 1, PR #3249), replacing per-surface direct calls
to the underlying
ArchiveStoreprimitives.Problem
docs/plans/mutation-census.yaml(phase 1) inventoriedmutate-add-tag,mutate-remove-tag,mutate-bulk-tag-sessions,mutate-set-metadata, andmutate-delete-metadataasdeclared-not-routed: CLI (query-mutation path),MCP (
write(operation=...)), and the Python API facade each reachedArchiveStore.add_user_tags/remove_user_tags/set_user_metadata/delete_user_metadataindependently, with no shared preview/authorize/receipt contract and no
OperationSpec-level executor status beyond"declared". Separately,
add_mark/remove_markwas a genuine MCP-onlymutation family with no
OperationSpecat all — invisible to the t46.9AC1 inventory.
Solution
New actuators (
polylogue/operations/mutation_actuators.py):TagAddActuator,TagRemoveActuator,BulkTagActuator,MetadataSetActuator,MetadataDeleteActuator,MarkAddActuator,MarkRemoveActuator. Each wraps exactly one existingArchiveStoreprimitive unchanged (
add_user_tags/remove_user_tags/set_user_metadata/delete_user_metadata/add_mark/remove_mark) and declaresdestructive_class="reversible"+required_confirmation="role_only"—the AC4 floor: reversible writes (undo = another write through the same
actuator) must not force an interactive confirm ceremony, unlike phase 1's
confirm_flag-gated delete/excise/reset actuators.Routing (
polylogue/api/archive.py):PolylogueArchiveMixin.add_tag,remove_tag,bulk_tag_sessions,set_metadata,delete_metadata,add_mark,remove_marknow construct the actuator +OperationExecutorand drive PREPARE → AUTHORIZE → EXECUTE instead of calling the archive
primitive directly. This is the single choke point every surface already
funneled through (CLI's
apply_modifiers/query-mutation path andquery_verbs.py, MCP'swrite(operation=...)dispatch, and direct APIcallers), so routing it there covers all three surfaces in one place —
mirroring how phase 1 routed
delete_session_safe.Specs (
polylogue/operations/specs.py): flipped the five existingtag/metadata specs'
executor_statustoexecutor-routed, and added twonew specs,
mutate-add-mark/mutate-remove-mark(previously absent fromthe catalog entirely) — the first MCP no-spec mutation family to gain both
an
OperationSpecand an executor route.Census (
docs/plans/mutation-census.yaml): moved the seven rows abovefrom
declared-not-routedtoexecutor-routedwith actuator/adaptercitations, and removed a stale duplicate
delete_metadata (MCP admin alias)row that named the exact same code path as
mutate-delete-metadata(thereis only one
delete_metadatacode path inmcp/server_cutover.py).Race-window fix (
polylogue/api/archive.py): widened theKeyError → SessionNotFoundErrorconversion inadd_tag/remove_tag/set_metadata/delete_metadatato wrap AUTHORIZE+EXECUTE as well asPREPARE.
OperationExecutor.executere-resolves the plan via a freshactuator.prepare()call before mutating; if a session is deleted by aconcurrent actor between AUTHORIZE and EXECUTE, that fresh PREPARE now
raises
KeyErrorinside the sametryblock instead of leaking anuntyped exception past the facade boundary.
Routing matrix
mutate-add-tagTagAddActuatormutate-remove-tagTagRemoveActuatormutate-bulk-tag-sessionsBulkTagActuatormutate-set-metadataMetadataSetActuatormutate-delete-metadataMetadataDeleteActuatormutate-add-mark(new)MarkAddActuatormutate-remove-mark(new)MarkRemoveActuatorAC coverage (t46.9)
add_mark/remove_marknow haveOperationSpecentries where previously they hadnone; the census/spec cross-check test (
test_mutation_census.py) staysgreen and honest.
not touched this phase — no daemon/maintenance internal actor was in
scope here.
affected — none of the seven migrated operations were in jn40's
confirm-gated list (only
delete_session/delete_annotation/delete_saved_view/delete_recall_pack/delete_workspace/maintenance_executefamily are), so there was no confirm boolean toremove or reduce here.
Verification
Anti-vacuity (
tests/unit/operations/test_mutation_actuators.py): each newactuator is driven against a real seeded
index.db/user.dbpair (realschema, real SQL) and asserts on the actual
assertionstable rows —e.g.
TestTagAddActuator::test_full_lifecycle_writes_the_tag_assertionfails if
TagAddActuator.applystops callingArchiveStore.add_user_tags.TestReversibleActuatorsAcceptTheWeakestConfirmationdirectly contrasts arole_onlyAUTHORIZE succeeding for the new reversible actuators againstSessionDeleteActuator(phase 1) refusing the identicalrole_onlystrength with
ConfirmationRequiredError— the AC4 evidence.devtools test tests/unit/cli/test_verb_cardinality.py -k test_guard_dry_run_and_deleted_sets_are_identical_and_unlimitedfailsidentically on unmodified
master(git stashbefore/after) — pre-existing"no running event loop" /
RuntimeServicesConfigError, unrelated to thischange; not touched here.
Not run: full
devtools verify --all(reserved for a final pre-merge passper repo convention; the touched surface's affected-area tests above plus
--quickgate cover this change).Remaining polylogue-t46.9 / polylogue-kwsb.2 scope
Named as Phase 3 debt in the census, not attempted in this PR:
save_annotation/delete_annotation,save_saved_view/delete_saved_view,save_recall_pack/delete_recall_pack,save_workspace/delete_workspace—delete_*members are jn40confirm-gated at the MCP layer; not yet executor-routed.
record_correction/clear_corrections,capture_assertion_candidate,blackboard_post,import_annotation_batch— additive/low-blast-radiuswrites, still
declared-not-routed.rebuild_index/update_index/rebuild_insights(maintenance_executefamily) — internal idempotent-rebuild maintenance, jn40 confirm-gated.
ops reset --database/--index/--blob/--assets/--cache/--auth(file-tierdeletion) — census still asks whether to extend
MutationPlan'starget-ref vocabulary to file-tier targets or keep this a typed exemption
permanently; no decision made in this PR.
bound_tokenconfirmation-strength adoption and durable audit-rowpersistence — untouched, as scoped by the task brief.
Ref polylogue-t46.9
Ref polylogue-kwsb.2