Skip to content

feat(operations): blocker-resolution operator surface + annotation family through MutationTransaction (polylogue-t46.9 phase 3) - #3258

Merged
Sinity merged 6 commits into
masterfrom
feature/refactor/t46-9-phase3-blockers-annotations
Jul 22, 2026
Merged

Sinity merged 6 commits into
masterfrom
feature/refactor/t46-9-phase3-blockers-annotations

Conversation

@Sinity

@Sinity Sinity commented Jul 21, 2026

Copy link
Copy Markdown
Owner

Summary

Phase 3 of polylogue-t46.9/polylogue-kwsb.2 (make OperationSpec the executable mutation authority): migrates the annotation family onto OperationExecutor, and closes a concrete operator gap found live 2026-07-21/22 -- raw-authority blocker resolution had no discovery surface and no census/authorization entry at all.

Problem

Two independent, evidence-backed gaps:

  1. Undiscoverable blockers. resolve_raw_authority_blocker requires an exact --blocker-id, but the only way to find an unresolved one was page-walking raw-authority-census/raw-authority-detail or writing an ad hoc script against the live archive -- which the operator had to do tonight to unblock a stale-plan blocker.
  2. Unclassified mutation. raw-authority-blocker-resolve (CLI) already existed with its own --yes gate, but had no OperationSpec/docs/plans/mutation-census.yaml entry at all -- not merely un-migrated debt, but an unclassified destructive route the census was silently missing. save_annotation/delete_annotation were declared-not-routed debt from phase 2's mark-family migration.

Solution

  • polylogue/storage/raw_authority.py: describe_raw_authority_blocker (zero-mutation single lookup) and list_unresolved_raw_authority_blockers (bounded inventory), both classifying kind as stale_plan vs frontier_judgment from the plan's authority_witness_json schema -- same classification resolve_raw_authority_blocker already used internally. product/raw_authority.list_blockers is the CLI-facing wrapper.
  • polylogue/operations/mutation_actuators.py: three new actuators.
    • AnnotationSaveActuator/AnnotationDeleteActuator wrap ArchiveStore.save_annotation/delete_annotation -- reversible class, role_only confirmation (undo is the paired actuator through the same primitive, matching the phase-2 mark family).
    • BlockerResolveActuator wraps resolve_raw_authority_blocker -- reset class, confirm_flag confirmation (not reversible: a blocker cannot be un-resolved; not delete/excise: no archive content is removed, only the blocked state is tombstoned). Frontier-judgment assertion-id/disposition enforcement stays inside the primitive (domain-owned); the executor's job is confirmation strength plus TOCTOU staleness detection via the standard fresh-PREPARE-before-EXECUTE revalidation.
  • polylogue/operations/specs.py: three new executor-routed OperationSpec entries (mutate-save-annotation, mutate-delete-annotation, mutate-resolve-raw-authority-blocker).
  • polylogue/api/archive.py: save_annotation/delete_annotation now drive their actuators through OperationExecutor instead of calling ArchiveStore directly (mirrors add_mark/remove_mark's phase-2 pattern). MCP's write(operation='save_annotation'/'delete_annotation') already calls these facade methods -- no MCP tool signature change needed.
  • CLI: new read-only polylogue ops maintenance raw-authority-blockers [--limit] [--output-format] lists unresolved blockers with kind. raw-authority-blocker-resolve now drives BlockerResolveActuator through OperationExecutor instead of calling raw_authority.resolve_blocker directly -- operator-visible behavior (the --yes gate, error text) is unchanged, but resolution now shares the same PREPARE/AUTHORIZE/EXECUTE proof every other destructive route uses, and refuses with PlanStaleError if the blocker is concurrently resolved between preview and confirm.
  • Docs: docs/maintenance.md documents the new list command and resolve's executor routing; docs/plans/docs-coverage-baseline.yaml drops a stale ops maintenance rebuild-index entry the docs-coverage lint flagged as removable while checking this PR's new surface; docs/test-quality-workflows.md regenerated.
  • 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 in its expected set (a pre-existing gap from the phase-2 PR, confirmed failing on master before this change) -- fixed while touching this file for the three new specs.

Routing matrix

Operation Class Confirmation Surfaces Status
mutate-save-annotation reversible role_only mcp, api executor-routed (new)
mutate-delete-annotation reversible role_only mcp, api executor-routed (new)
mutate-resolve-raw-authority-blocker reset confirm_flag cli executor-routed (new)

Census delta (docs/plans/mutation-census.yaml)

  • save_annotation / delete_annotation (one combined declared-not-routed row) -> split into mutate-save-annotation + mutate-delete-annotation, both executor-routed.
  • New mutate-resolve-raw-authority-blocker row, executor-routed (previously absent from the census entirely).
  • raw-authority-blockers (the new list command) is read-only and intentionally has no census row (the census classifies mutating operations).

Verification

devtools test polylogue/storage/raw_authority.py polylogue/product/raw_authority.py \
  polylogue/operations/mutation_actuators.py polylogue/operations/specs.py polylogue/api/archive.py \
  polylogue/cli/commands/maintenance/_raw_identity.py tests/unit/operations/test_mutation_actuators.py \
  tests/unit/operations/test_specs.py tests/unit/operations/test_mutation_census.py \
  tests/unit/cli/test_archive_maintenance_cli.py tests/unit/storage/test_raw_authority_ledger.py
# 120 passed in 11.05s

devtools test tests/unit/api/test_facade_contracts.py tests/unit/mcp/test_query_gap_projections.py
# 295 passed in 9.24s

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: TestAnnotationActuators/TestBlockerResolveActuator in tests/unit/operations/test_mutation_actuators.py drive the actuators against real seeded source.db/user.db (real schema, real SQL) -- they fail if AnnotationSaveActuator.apply stops calling ArchiveStore.save_annotation, if AnnotationDeleteActuator.apply stops marking the assertion deleted, or if BlockerResolveActuator.apply stops calling resolve_raw_authority_blocker. A dedicated test proves TOCTOU: a blocker resolved out-of-band between PREPARE and EXECUTE raises PlanStaleError rather than double-applying. The CLI blocker-resolve test was rewritten from a mock of the underlying storage function (which the new real PREPARE existence-check would have made vacuous) to a real seeded blocker row, plus a new unknown-blocker-id test proving the resolve command fails rather than silently succeeding.

Not run: full devtools verify --all (reserved for harness/dependency changes or final pre-merge diagnostic per repo convention; 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):

  • save_saved_view / delete_saved_view, save_recall_pack / delete_recall_pack, save_workspace / delete_workspace -- still declared-not-routed, jn40 confirm-gated interim mitigation only.
  • record_correction / clear_corrections, capture_assertion_candidate, blackboard_post, import_annotation_batch -- still declared-not-routed (low blast radius / additive, per existing census reasons).
  • 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 Phase-4 decision.
  • bound_token confirmation strength adoption (currently no actuator requires it; all destructive-class actuators use confirm_flag).
  • Durable audit-row persistence for MutationReceipts (currently receipts are returned, not persisted to a dedicated audit table).
  • Crash/partial-failure resume semantics for multi-target operations.

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

Co-Authored-By: Claude [email protected]

Sinity and others added 5 commits July 22, 2026 01:15
Problem: resolve_raw_authority_blocker requires an exact blocker_id, but
there was no way to discover an unresolved blocker_id short of
page-walking raw-authority-census/-detail or writing an ad hoc script
against the live archive (found live 2026-07-21/22).

What changed: add describe_raw_authority_blocker (zero-mutation single
lookup, used by the phase-3 BlockerResolveActuator's PREPARE) and
list_unresolved_raw_authority_blockers (bounded inventory) to
storage/raw_authority.py, plus product/raw_authority.list_blockers as
the CLI-facing wrapper. Both classify each blocker's `kind` as
stale_plan or frontier_judgment by reading the plan's
authority_witness_json schema, matching resolve_raw_authority_blocker's
own classification logic.

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

Co-Authored-By: Claude <[email protected]>
…hrough the executor

Problem: polylogue-t46.9 phase 3 continues migrating declared-not-routed
mutation families onto MutationTransaction/OperationExecutor. The
annotation family (save_annotation/delete_annotation) was still a bare
ArchiveStore call with no shared authorization path, and
resolve_raw_authority_blocker -- a durable, replanning-reopening
mutation -- had no OperationSpec/census entry at all (an unclassified
operation, not merely an un-migrated one).

What changed:
- AnnotationSaveActuator/AnnotationDeleteActuator wrap
  ArchiveStore.save_annotation/delete_annotation (reversible class,
  role_only confirmation, matching the mark family's phase-2 pattern:
  undo is the paired actuator through the same primitive).
- BlockerResolveActuator wraps
  raw_authority.resolve_raw_authority_blocker (reset class,
  confirm_flag confirmation -- not reversible since a blocker cannot be
  un-resolved, not delete/excise since no archive content is removed).
  Frontier-judgment assertion-id/disposition enforcement stays inside
  the primitive; the executor's job is confirmation strength and TOCTOU
  staleness detection via the standard fresh-PREPARE-before-EXECUTE
  revalidation.
- Three new OperationSpec entries (mutate-save-annotation,
  mutate-delete-annotation, mutate-resolve-raw-authority-blocker), all
  executor-routed, plus matching mutation-census.yaml rows.
- Fixed a pre-existing test_specs.py gap (mutate-add-mark/
  mutate-remove-mark, added in the phase-2 PR, were never added to
  test_runtime_operation_catalog_covers_the_current_runtime_paths'
  expected set) while touching this file for the three new specs.

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

Co-Authored-By: Claude <[email protected]>
…xecutor

Wires PolylogueArchiveMixin.save_annotation/delete_annotation to the
new AnnotationSaveActuator/AnnotationDeleteActuator instead of calling
ArchiveStore.save_annotation/delete_annotation directly, mirroring
add_mark/remove_mark's phase-2 pattern: async target resolution stays
in the facade (may consult insight-derived indexes), then the actuator
sees an already-resolved target_type/target_id through
PREPARE->AUTHORIZE->EXECUTE. MCP's write(operation='save_annotation'/
'delete_annotation') already calls these facade methods, so no MCP
surface change is needed.

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

Co-Authored-By: Claude <[email protected]>
…ough executor

Problem (found live 2026-07-21/22): raw-authority blocker resolution had
a working CLI command (raw-authority-blocker-resolve, with its own --yes
gate) but no way to discover an unresolved blocker_id short of
page-walking raw-authority-census/-detail or writing an ad hoc script
against the live archive, and its authorization was independent of
every other destructive route.

What changed:
- New `polylogue ops maintenance raw-authority-blockers` (read-only):
  lists unresolved blockers via product.raw_authority.list_blockers,
  classifying each as stale_plan or frontier_judgment.
- `raw-authority-blocker-resolve` now drives BlockerResolveActuator
  through OperationExecutor (PREPARE previews the exact blocker target,
  EXECUTE requires confirm_flag-strength authorization bound to that
  plan's hash, and refuses PlanStaleError if the blocker was resolved
  concurrently between preview and confirm) instead of calling
  raw_authority.resolve_blocker directly. The --yes gate and error
  handling are unchanged from the operator's perspective.
- docs/maintenance.md: document the new list command and the
  executor-routing behavior of resolve.
- docs/plans/docs-coverage-baseline.yaml: drop the stale
  'ops maintenance rebuild-index' entry (now documented; the
  docs-coverage lint reported it as removable while checking this PR's
  new surface).

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

Co-Authored-By: Claude <[email protected]>
…tuators

Real-dependency tests (real seeded source.db/user.db, real SQL, no
mocks of the primitives under test):

- TestAnnotationActuators: save-then-update-then-delete round-trip
  through user.db assertions (kind='annotation'), proving created-vs-
  updated receipt honesty and AC4 role_only confirmation.
- TestBlockerResolveActuator: PREPARE finds/doesn't-find a real
  unresolved blocker row, EXECUTE genuinely resolves it and reopens
  replanning, a concurrent out-of-band resolve between PREPARE and
  EXECUTE raises PlanStaleError (TOCTOU), role_only is refused
  (contrast with the reversible-class actuators), and frontier_judgment
  vs stale_plan classification is proven from a real
  authority_witness_json schema.
- CLI: rewrote the blocker-resolve confirmation test against a real
  seeded blocker (the previous version mocked
  raw_authority.resolve_raw_authority_blocker directly, which the new
  PREPARE step's real existence check would have made vacuous -- the
  mock would never be reached without a real row). Added an
  unknown-blocker-id anti-vacuity test and CLI-level coverage for the
  new raw-authority-blockers list command (kind classification, and
  that resolving one blocker removes it from the unresolved listing).

Also regenerates docs/test-quality-workflows.md (devtools render
quality-reference) to reflect the three new OperationSpec entries in
its uncovered-runtime-operations snapshot.

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: 3 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: 453b9f8c-9c12-47dd-b78a-05f8d30e270d

📥 Commits

Reviewing files that changed from the base of the PR and between 26f02d0 and ce3fd94.

📒 Files selected for processing (14)
  • docs/maintenance.md
  • docs/plans/docs-coverage-baseline.yaml
  • docs/plans/mutation-census.yaml
  • docs/test-quality-workflows.md
  • polylogue/api/archive.py
  • polylogue/cli/commands/maintenance/__init__.py
  • polylogue/cli/commands/maintenance/_raw_identity.py
  • polylogue/operations/mutation_actuators.py
  • polylogue/operations/specs.py
  • polylogue/product/raw_authority.py
  • polylogue/storage/raw_authority.py
  • tests/unit/cli/test_archive_maintenance_cli.py
  • tests/unit/operations/test_mutation_actuators.py
  • tests/unit/operations/test_specs.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/refactor/t46-9-phase3-blockers-annotations

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: 8ca8a55d03

ℹ️ 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 polylogue/storage/raw_authority.py Resolved
Comment thread polylogue/storage/raw_authority.py Resolved
…sting

Two Codex-bot P2 review comments on PR #3258 (both against
polylogue/storage/raw_authority.py), triaged and fixed:

1. "Reserve frontier_judgment for actual judgment blockers": frontier
   plans cover four obligation states (missing bytes, conflicting
   authority needing judgment, unresolved provenance, corrupt --
   raw_reconciler._OBLIGATION_STATES), but
   _reconcile_frontier_obligations only writes a judgment_assertion_id
   into observed_json for CONFLICTING_AUTHORITY_NEEDS_JUDGMENT.
   resolve_raw_authority_blocker itself only demands an accepted
   assertion + disposition when that key is present. Classifying every
   frontier-schema blocker as frontier_judgment therefore told operators
   an accepted assertion was required even when the resolver enforces
   none. Fixed: kind is now derived from the presence of
   judgment_assertion_id in observed_json (the same signal the resolver
   itself checks), not merely "is this a frontier-schema plan". Other
   frontier obligation states now classify as the new frontier_obligation
   kind. Verified against raw_reconciler.py's _reconcile_frontier_
   obligations and _OBLIGATION_STATES.

2. "Paginate the blocker inventory past the hard limit": --limit capped
   at 500 with no offset/continuation, so an archive with >500 unresolved
   blockers could never expose rows past the first page. Fixed:
   list_unresolved_raw_authority_blockers now takes an `offset` and
   returns a paginated envelope (blockers, offset, limit, returned_count,
   total_count, truncated, next_offset) instead of a bare list; the CLI
   gained a matching --offset flag and prints a "Truncated: pass --offset
   N" notice in plain-mode output when more rows remain.

Both fixes are covered by new real-dependency tests (real seeded
source.db, no mocks): TestListUnresolvedRawAuthorityBlockersPagination
and test_raw_authority_blockers_cli_paginates_past_the_limit prove a
3-row inventory queried with --limit 2 exposes all 3 rows across two
pages; test_frontier_obligation_without_judgment_assertion_is_not_
misclassified proves a frontier blocker without a judgment assertion
classifies frontier_obligation (not frontier_judgment) and resolves
without one, exactly as resolve_raw_authority_blocker allows.

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

Co-Authored-By: Claude <[email protected]>
@Sinity
Sinity merged commit 7591d33 into master Jul 22, 2026
3 checks passed
@Sinity
Sinity deleted the feature/refactor/t46-9-phase3-blockers-annotations branch July 22, 2026 00:17
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.

  • 73.F094 / P2: fixed-already at the checked revision: polylogue/storage/raw_authority.py:812 accepts LIMIT/OFFSET and :840 returns the next offset when more blockers remain. The CLI now exposes --offset at polylogue/cli/commands/maintenance/_raw_identity.py:58, so unresolved blockers beyond the first 500 are accessible without resolving the first page.
  • 73.F095 / P2: fixed-already at the checked revision: polylogue/storage/raw_authority.py:709 now labels current-schema frontier records frontier_obligation rather than frontier_judgment. Missing bytes and corrupt/provenance obligations are no longer presented as requiring a judgment assertion that does not exist.

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