feat(events): enrich PLAN_CANCELLED event with progress and resource cleanup context #1301
No reviewers
Labels
No labels
auto/needs-reevaluation
controller-managed
auto/blocked-by-deps
auto/ci-timeout
auto/claimed-implementer
auto/claimed-merge
auto/claimed-reviewer
auto/driver-down
auto/invariant-violation
auto/last-attempt-tier-0
auto/last-attempt-tier-1
auto/last-attempt-tier-2
auto/last-attempt-tier-min
Automation Tracking
auto/needs-conflict-resolution
auto/needs-implementer
auto/postmortem
auto/ready-to-merge
auto/restart-throttled
auto/revert
auto/sentinel
auto/stale-inactivity
auto/unstable
Blocked
Bounty
$100
Bounty
$1000
Bounty
$10000
Bounty
$20
Bounty
$2000
Bounty
$250
Bounty
$50
Bounty
$500
Bounty
$5000
Bounty
$750
MoSCoW
Could have
MoSCoW
Must have
MoSCoW
Should have
Needs Feedback
Points
1
Points
13
Points
2
Points
21
Points
3
Points
34
Points
5
Points
55
Points
8
Points
88
Priority
Backlog
Priority
CI Blocker
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Signed-off: Owner
Signed-off: Scrum Master
Signed-off: Tech Lead
Spike
State
Completed
State
Duplicate
State
In Progress
State
In Review
State
Paused
State
Unverified
State
Verified
State
Wont Do
Type
Automation
Type
Bug
Type
Discussion
Type
Documentation
Type
Epic
Type
Feature
Type
Legendary
Type
Refactor
Type
Support
Type
Task
Type
Testing
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
cleveragents/cleveragents-core!1301
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feature/m6-plan-cancelled-enrichment"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Enriches the
PLAN_CANCELLEDdomain event emitted byPlanLifecycleService.cancel_plan()with additional context fields to improve the audit trail quality (SEC7 Audit Logging spec).Changes
src/cleveragents/application/services/plan_lifecycle_service.pyThe
cancel_plan()method now captures plan state before mutating it toCANCELLED, and includes the following additional fields in thePLAN_CANCELLEDeventdetailsdict:Progress context (where the plan was when cancelled):
cancelled_phase— the plan phase at cancellation (e.g."strategize")cancelled_processing_state— the processing state at cancellation (e.g."queued")last_completed_step— index of the last successfully completed step (-1if none)subplan_count— number of spawned subplans at cancellation timeResource cleanup context (what needs cleanup):
sandbox_refs— list of active sandbox reference IDs requiring cleanupchangeset_id— ID of any in-progress changeset that needs cleanupresources_pending_cleanup— count of sandbox refs pending cleanupExisting fields (
reason,project_names) are preserved for backward compatibility.features/plan_cancelled_enrichment.feature+features/steps/plan_cancelled_enrichment_steps.py15 BDD scenarios covering:
Quality Gates
nox -e lint— all checks passednox -e typecheck— 0 errors, 0 warningsnox -e unit_tests -- features/plan_cancelled_enrichment.feature— 15/15 scenarios passnox -e unit_tests -- features/plan_lifecycle_service_coverage_boost_r2.feature— 14/14 scenarios pass (no regressions)Closes #717
Review claimed by reviewer pool instance reviewer-pool-1. Dispatching independent code review.
Independent Code Review — APPROVED ✅
Summary
This PR enriches the
PLAN_CANCELLEDdomain event with progress and resource cleanup context, improving the audit trail per SEC7 Audit Logging spec requirements. The implementation is clean, well-typed, and well-tested.What Was Reviewed
plan_lifecycle_service.py): ~30 lines of net change tocancel_plan()methodplan_cancelled_enrichment.feature): 15 BDD scenariosplan_cancelled_enrichment_steps.py): 252 lines of test infrastructureCloses #717Findings
✅ Specification Alignment
reasonandproject_namesfields retained)✅ Correctness
cancelled_phase,cancelled_processing_state,last_completed_step,sandbox_refs,changeset_id,subplan_countare all captured beforeplan.processing_state = ProcessingState.CANCELLEDlist(plan.sandbox_refs)creates a defensive copy — good practiceresources_pending_cleanupderived fromlen(sandbox_refs)provides convenient count for consumersCOV-3comment is appropriate since the data is now available✅ Type Safety
str,int,list[str],str | None)event_details: dict[str, object]is correctly typed for mixed-value dict# type: ignoresuppressions✅ Test Quality
_RecordingBushelper is minimal and focusedmodel_copyis a clean approach for testing resource contextstop_all_active_containersproperly mocked to avoid side effects⚠️ Minor Process Notes (non-blocking)
Type/label and milestone assignment (issue #717 hasType/Documentationand milestone v3.5.0)_RecordingBus.eventsuses barelisttype hint — could belist[object]for stricter typing, but this is test-only codeVerdict
The code changes are solid, well-tested, and aligned with the specification. Proceeding with merge.