Repository navigation
fix(operations): route learning corrections through MutationTransaction - #3294
Conversation
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]>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Warning Review limit reached
Next review available in: 33 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 Plus Run ID: 📒 Files selected for processing (7)
✨ 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 |
Summary
Migrates the
record_correction/delete_correction/clear_correctionslearning-corrections family fromdeclared-not-routedtoexecutor-routedin 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'srecord_correction / clear_correctionsrow was the nextdeclared-not-routedfamily after phase 4 (#3262, saved-view/recall-pack/workspace) landed. These three operations independently mutateduser.dbwithout going throughOperationExecutor'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: newCorrectionRecordActuator,CorrectionDeleteActuator,CorrectionsClearActuator— allreversibleclass /role_onlyconfirmation (AC4: reversible writes don't need interactive confirmation), following the exact same actuator shape as the annotation and workspace families.CorrectionsClearActuator.prepareresolves the exact live set of correction kinds for the session at plan time (mirroringSessionDeleteActuator's re-resolve-against-live-state pattern), so a concurrentrecord_correctionbetween AUTHORIZE and EXECUTE changes the plan hash and forcesPlanStaleErrorinstead of silently clearing a kind the caller never previewed.polylogue/operations/specs.py:mutate-record-correction,mutate-delete-correction,mutate-clear-correctionsOperationSpecentries,executor_status="executor-routed".polylogue/api/archive.py:record_correction/delete_correction/clear_correctionsnow build actuator args and driveOperationExecutor.prepare/authorize/executeinstead of callingArchiveStoredirectly. Behavior/return types are unchanged (sameLearningCorrection/bool/intsignatures).docs/plans/mutation-census.yaml: replaced the singledeclared-not-routedrow with threeexecutor-routedrows 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-routedrows (capture_assertion_candidate,blackboard_post,import_annotation_batch, themaintenance_executefamily, and the file-tierops resetfamily) are untouched debt for later phases.Verification
python -m pytest tests/unit/operations/{test_mutation_actuators,test_mutation_census,test_specs}.py -q-> 56 passeddevtools test tests/unit/operations/-> 146 passeddevtools test tests/unit/mcp/test_query_gap_projections.py tests/unit/api/test_facade_contracts.py-> 295 passed (these two files exerciserecord_correction/clear_correctionsthrough 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 filesruff check/ruff format --checkon all changed.pyfiles -> cleandevtools render all --check-> noout of syncsurfaces (after regeneratingdocs/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 casetest_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 withPlanStaleErrorbefore 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]