Skip to content

refactor(operations): route remaining mutation families through MutationTransaction (polylogue-t46.9 phase 2) - #3253

Merged
Sinity merged 1 commit into
masterfrom
feature/refactor/t46-9-phase2-mutation-routes
Jul 21, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/refactor/t46-9-phase2-mutation-routes

Conversation

@Sinity

@Sinity Sinity commented Jul 21, 2026

Copy link
Copy Markdown
Owner

Summary

Phase 2 of the t46.9/kwsb.2 mutation-executor migration: routes the
reversible-class tag, metadata, and mark mutation families through
OperationExecutor/MutationActuator (the PREPARE → AUTHORIZE → EXECUTE
lifecycle shipped in phase 1, PR #3249), replacing per-surface direct calls
to the underlying ArchiveStore primitives.

Problem

docs/plans/mutation-census.yaml (phase 1) inventoried mutate-add-tag,
mutate-remove-tag, mutate-bulk-tag-sessions, mutate-set-metadata, and
mutate-delete-metadata as declared-not-routed: CLI (query-mutation path),
MCP (write(operation=...)), and the Python API facade each reached
ArchiveStore.add_user_tags/remove_user_tags/set_user_metadata/
delete_user_metadata independently, with no shared preview/authorize/
receipt contract and no OperationSpec-level executor status beyond
"declared". Separately, add_mark/remove_mark was a genuine MCP-only
mutation family with no OperationSpec at all — invisible to the t46.9
AC1 inventory.

Solution

New actuators (polylogue/operations/mutation_actuators.py):
TagAddActuator, TagRemoveActuator, BulkTagActuator,
MetadataSetActuator, MetadataDeleteActuator, MarkAddActuator,
MarkRemoveActuator. Each wraps exactly one existing ArchiveStore
primitive unchanged (add_user_tags/remove_user_tags/set_user_metadata/
delete_user_metadata/add_mark/remove_mark) and declares
destructive_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_mark now construct the actuator + OperationExecutor
and 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 and
query_verbs.py, MCP's write(operation=...) dispatch, and direct API
callers), 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 existing
tag/metadata specs' executor_status to executor-routed, and added two
new specs, mutate-add-mark/mutate-remove-mark (previously absent from
the catalog entirely) — the first MCP no-spec mutation family to gain both
an OperationSpec and an executor route.

Census (docs/plans/mutation-census.yaml): moved the seven rows above
from declared-not-routed to executor-routed with actuator/adapter
citations, and removed a stale duplicate delete_metadata (MCP admin alias)
row that named the exact same code path as mutate-delete-metadata (there
is only one delete_metadata code path in mcp/server_cutover.py).

Race-window fix (polylogue/api/archive.py): widened the
KeyError → SessionNotFoundError conversion in add_tag/remove_tag/
set_metadata/delete_metadata to wrap AUTHORIZE+EXECUTE as well as
PREPARE. OperationExecutor.execute re-resolves the plan via a fresh
actuator.prepare() call before mutating; if a session is deleted by a
concurrent actor between AUTHORIZE and EXECUTE, that fresh PREPARE now
raises KeyError inside the same try block instead of leaking an
untyped exception past the facade boundary.

Routing matrix

Family Spec Actuator Surfaces Census state
add tag mutate-add-tag TagAddActuator facade, mcp, api executor-routed
remove tag mutate-remove-tag TagRemoveActuator facade, mcp, api executor-routed
bulk tag mutate-bulk-tag-sessions BulkTagActuator mcp, api executor-routed
set metadata mutate-set-metadata MetadataSetActuator facade, mcp, api executor-routed
delete metadata mutate-delete-metadata MetadataDeleteActuator mcp, api executor-routed
add mark mutate-add-mark (new) MarkAddActuator mcp, api executor-routed
remove mark mutate-remove-mark (new) MarkRemoveActuator mcp, api executor-routed

AC coverage (t46.9)

  • AC1 (one inventory covers every mutation): extended — add_mark/
    remove_mark now have OperationSpec entries where previously they had
    none; the census/spec cross-check test (test_mutation_census.py) stays
    green and honest.
  • AC5 (internal actors use declared capabilities through the executor):
    not touched this phase — no daemon/maintenance internal actor was in
    scope here.
  • AC8 (jn40 confirm booleans retained only as interim compat): not
    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_execute family are), so there was no confirm boolean to
    remove or reduce here.

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
# 307 passed

devtools test 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
# 60 passed

devtools verify --quick
# exit_code: 0 (ruff format/check, mypy --strict, render all --check all clean)

Anti-vacuity (tests/unit/operations/test_mutation_actuators.py): each new
actuator is driven against a real seeded index.db/user.db pair (real
schema, real SQL) and asserts on the actual assertions table rows —
e.g. TestTagAddActuator::test_full_lifecycle_writes_the_tag_assertion
fails if TagAddActuator.apply stops calling ArchiveStore.add_user_tags.
TestReversibleActuatorsAcceptTheWeakestConfirmation directly contrasts a
role_only AUTHORIZE succeeding for the new reversible actuators against
SessionDeleteActuator (phase 1) refusing the identical role_only
strength 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_unlimited fails
identically on unmodified master (git stash before/after) — pre-existing
"no running event loop" / RuntimeServices ConfigError, unrelated to this
change; not touched here.

Not run: full devtools verify --all (reserved for a final pre-merge pass
per repo convention; the touched surface's affected-area tests above plus
--quick gate 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 jn40
    confirm-gated at the MCP layer; not yet executor-routed.
  • record_correction/clear_corrections, capture_assertion_candidate,
    blackboard_post, import_annotation_batch — additive/low-blast-radius
    writes, still declared-not-routed.
  • rebuild_index/update_index/rebuild_insights (maintenance_execute
    family) — internal idempotent-rebuild maintenance, jn40 confirm-gated.
  • ops reset --database/--index/--blob/--assets/--cache/--auth (file-tier
    deletion) — census still asks whether to extend MutationPlan's
    target-ref vocabulary to file-tier targets or keep this a typed exemption
    permanently; no decision made in this PR.
  • bound_token confirmation-strength adoption and durable audit-row
    persistence — untouched, as scoped by the task brief.

Ref polylogue-t46.9
Ref polylogue-kwsb.2

…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]>
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Sinity, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 45 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 037d9785-e922-4776-a544-a083120b9808

📥 Commits

Reviewing files that changed from the base of the PR and between 7978859 and 58e49ee.

📒 Files selected for processing (6)
  • docs/plans/mutation-census.yaml
  • docs/test-quality-workflows.md
  • polylogue/api/archive.py
  • polylogue/operations/mutation_actuators.py
  • polylogue/operations/specs.py
  • tests/unit/operations/test_mutation_actuators.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/refactor/t46-9-phase2-mutation-routes

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread docs/plans/mutation-census.yaml Resolved
@Sinity

Sinity commented Jul 21, 2026

Copy link
Copy Markdown
Owner Author

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.

@Sinity
Sinity merged commit e0d6e5b into master Jul 21, 2026
3 checks passed
@Sinity
Sinity deleted the feature/refactor/t46-9-phase2-mutation-routes branch July 21, 2026 19:15
Sinity added a commit that referenced this pull request Jul 21, 2026
Sinity added a commit that referenced this pull request Jul 22, 2026
…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]>
Sinity added a commit that referenced this pull request Jul 26, 2026
…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]>
Sinity added a commit that referenced this pull request Jul 26, 2026
…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]>
Sinity added a commit that referenced this pull request Jul 27, 2026
#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]>
@Sinity

Sinity commented Oct 1, 2026

Copy link
Copy Markdown
Owner Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant