Skip to content

fix(operations): route learning corrections through MutationTransaction - #3294

Merged
Sinity merged 1 commit into
masterfrom
feature/fix/mutation-transaction-corrections-family
Jul 27, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/fix/mutation-transaction-corrections-family

Conversation

@Sinity

@Sinity Sinity commented Jul 27, 2026

Copy link
Copy Markdown
Owner

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]

Problem: docs/plans/mutation-census.yaml's `record_correction /
clear_corrections` row was the next declared-not-routed family in the
t46.9/kwsb.2 migration sequence after phase 4 (#3262, saved-view/
recall-pack/workspace) landed. record_correction, delete_correction, and
clear_corrections 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.

What changed:
- polylogue/operations/mutation_actuators.py: new CorrectionRecordActuator,
  CorrectionDeleteActuator, and CorrectionsClearActuator, all reversible
  class / role_only confirmation (AC4: reversible writes don't need
  interactive confirmation). CorrectionsClearActuator.prepare resolves the
  *exact live set* of correction kinds for the session (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-routed.
- polylogue/api/archive.py: record_correction/delete_correction/
  clear_corrections now build args, prepare/authorize/execute through
  OperationExecutor instead of calling ArchiveStore directly.
- 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 (uncovered-operations list
  picked up the three new spec names).

Tests: tests/unit/operations/test_mutation_actuators.py gains
TestCorrectionActuators (5 cases) proving save/delete round-trip through
user.db, idempotent already-satisfied delete, AC4 role-only acceptance,
session-scoped clear, and — the key 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, and asserts the held authorization is refused
with PlanStaleError before any row is deleted.

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
- python -m mypy polylogue/operations/mutation_actuators.py polylogue/operations/specs.py polylogue/api/archive.py tests/unit/operations/test_mutation_actuators.py -> Success
- ruff check / ruff format --check on all changed .py files -> clean
- devtools render all --check -> no "out of sync" surfaces
- devtools verify --quick -> exit 0

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

Co-Authored-By: Claude <[email protected]>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Jul 27, 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: 33 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 Plus

Run ID: 5307e450-dc91-4694-83bd-c51331bf3b56

📥 Commits

Reviewing files that changed from the base of the PR and between 9a04c56 and fb4f8d3.

📒 Files selected for processing (7)
  • 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
  • tests/unit/operations/test_specs.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/fix/mutation-transaction-corrections-family

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.

@Sinity
Sinity merged commit 07b74da into master Jul 27, 2026
3 checks passed
@Sinity
Sinity deleted the feature/fix/mutation-transaction-corrections-family branch July 27, 2026 02:33
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