Implement spec-compliant correction diff output for `agents plan diff
--correction <CORRECTION_ATTEMPT_ID>`. Fixes the following issues from
the cycle-1 PR review:
- C1/M1: Replace direct `unit_of_work.correction_attempts` access with
the proper `unit_of_work.transaction()` context manager, eliminating
the AttributeError crash and the resource (session) leak.
- C2: Add `unit_of_work: UnitOfWork | None = None` constructor parameter
to `PlanApplyService` and wire it in `_get_apply_service()` via
`container.unit_of_work()`, removing the illegal `get_container()`
call inside the method body (ADR-003 DI violation).
- C3: Replace metadata serialization stub with a three-section structured
diff (Correction Diff summary, Comparison table, Patch Preview) as
specified in §agents plan diff of the specification.
- C4/M2: Add `features/plan_correction_diff.feature` with 6 BDD
scenarios covering all 4 output formats plus plan-not-found and
correction-not-found error paths.
- C5: Update the three existing BDD scenarios that tested old stub
behavior to mock `_get_apply_service()` and assert the new output.
- C6: Rename branch to `bugfix/m4-plan-diff-correction-stub` per
CONTRIBUTING.md convention.
- C7: Amend commit message with body and ISSUES CLOSED footer.
- C8: Narrow `except Exception` to `except CorrectionAttemptNotFoundError`
to avoid masking programming errors.
- M3: Add `robot/plan_correction_diff.robot` and
`robot/helper_plan_correction_diff.py` integration test covering rich,
plain, and JSON formats and the not-found error path.
- M4: Type `_build_correction_diff_dict` parameter as
`CorrectionAttemptRecord` instead of `Any`.
- M5: Change `fmt: str` to `fmt: Literal["rich", "plain", "json", "yaml"]`
on both `diff()` and `correction_diff()`, with a `cast()` call in the
CLI layer where Typer supplies a plain `str`.
- M6: Add `ValueError` guards for empty `plan_id` and
`correction_attempt_id` at the top of `correction_diff()`.
- M7: Add blank line between `diff()` and `correction_diff()` method
definitions.
- M8: Update PR description to reflect actual implementation.
- m1: Remove unused `plan` variable in `correction_diff()`.
- m2: Reduce three blank lines to two between top-level definitions in
`plan_apply_service.py`.
- n1: Remove trailing whitespace from blank line in `plan.py`.
Quality gates: lint (ruff), typecheck (pyright strict), unit_tests
(Behave 632 features / 0 failures) all pass.
ISSUES CLOSED: #9085