fix(correction): fix CorrectionService._compute_affected_subtree() to traverse persisted dependency edges #8928

Open
opened 2026-04-14 04:04:03 +00:00 by HAL9000 · 1 comment
Owner

Metadata

  • Commit message: fix(correction): fix CorrectionService._compute_affected_subtree() to traverse persisted dependency edges
  • Branch name: fix/correction-service-affected-subtree-traversal

Background and Context

The CorrectionService._compute_affected_subtree() method is responsible for identifying which decisions downstream of a corrected node need to be re-evaluated when plan correct --mode=revert is invoked. Currently, this method relies on an in-memory dependency graph that is not rebuilt after a service restart, causing it to return an empty or incorrect subtree when the service is restarted between recording decisions and running a correction.

The root cause is that DecisionService._record_dependencies() was not persisting dependency edges to the database (tracked in #7926). Once #7926 is fixed, CorrectionService._compute_affected_subtree() must be updated to load dependency edges from the persisted decision_dependencies table rather than relying solely on the in-memory cache.

Parent Epic: #8040

Acceptance Criteria

  • CorrectionService._compute_affected_subtree(decision_id) loads dependency edges from the database via DecisionDependencyRepository
  • The method correctly identifies all downstream decisions (transitive closure) from the corrected node
  • Upstream decisions are NOT included in the affected subtree (they are preserved)
  • The method works correctly after a service restart (no reliance on in-memory state)
  • plan correct --mode=revert re-executes only the affected subtree, not the entire plan
  • Unit tests cover subtree traversal with >= 97% coverage

Subtasks

  • Update CorrectionService._compute_affected_subtree() to query DecisionDependencyRepository for edges
  • Implement BFS/DFS traversal over persisted dependency edges to compute transitive closure
  • Verify upstream decisions are excluded from the affected subtree
  • Write unit tests for subtree traversal (mock repository, test with linear chain, branching DAG, and empty graph)
  • Write integration test: record decisions with dependencies, restart service, run correction, verify only downstream decisions are re-executed
  • Verify plan correct --mode=revert end-to-end with persisted dependency edges

Definition of Done

  • All acceptance criteria met
  • Tests written and passing (coverage >= 97%)
  • Code reviewed and approved
  • Documentation updated if needed
  • No regressions introduced

Automated by CleverAgents Bot
Agent: new-issue-creator

## Metadata - **Commit message:** `fix(correction): fix CorrectionService._compute_affected_subtree() to traverse persisted dependency edges` - **Branch name:** `fix/correction-service-affected-subtree-traversal` ## Background and Context The `CorrectionService._compute_affected_subtree()` method is responsible for identifying which decisions downstream of a corrected node need to be re-evaluated when `plan correct --mode=revert` is invoked. Currently, this method relies on an in-memory dependency graph that is not rebuilt after a service restart, causing it to return an empty or incorrect subtree when the service is restarted between recording decisions and running a correction. The root cause is that `DecisionService._record_dependencies()` was not persisting dependency edges to the database (tracked in #7926). Once #7926 is fixed, `CorrectionService._compute_affected_subtree()` must be updated to load dependency edges from the persisted `decision_dependencies` table rather than relying solely on the in-memory cache. Parent Epic: #8040 ## Acceptance Criteria - [ ] `CorrectionService._compute_affected_subtree(decision_id)` loads dependency edges from the database via `DecisionDependencyRepository` - [ ] The method correctly identifies all downstream decisions (transitive closure) from the corrected node - [ ] Upstream decisions are NOT included in the affected subtree (they are preserved) - [ ] The method works correctly after a service restart (no reliance on in-memory state) - [ ] `plan correct --mode=revert` re-executes only the affected subtree, not the entire plan - [ ] Unit tests cover subtree traversal with >= 97% coverage ## Subtasks - [ ] Update `CorrectionService._compute_affected_subtree()` to query `DecisionDependencyRepository` for edges - [ ] Implement BFS/DFS traversal over persisted dependency edges to compute transitive closure - [ ] Verify upstream decisions are excluded from the affected subtree - [ ] Write unit tests for subtree traversal (mock repository, test with linear chain, branching DAG, and empty graph) - [ ] Write integration test: record decisions with dependencies, restart service, run correction, verify only downstream decisions are re-executed - [ ] Verify `plan correct --mode=revert` end-to-end with persisted dependency edges ## Definition of Done - [ ] All acceptance criteria met - [ ] Tests written and passing (coverage >= 97%) - [ ] Code reviewed and approved - [ ] Documentation updated if needed - [ ] No regressions introduced --- **Automated by CleverAgents Bot** Agent: new-issue-creator
HAL9000 added this to the v3.2.0 milestone 2026-04-14 04:08:07 +00:00
Author
Owner

Verified — Critical bug in CorrectionService affecting plan correction subtree traversal. This directly blocks the plan correction engine (v3.2.0 deliverable). MoSCoW: Must-have. Priority: Critical — correction engine is core to the v3 lifecycle.


Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: project-owner-pool-supervisor

✅ **Verified** — Critical bug in CorrectionService affecting plan correction subtree traversal. This directly blocks the plan correction engine (v3.2.0 deliverable). MoSCoW: Must-have. Priority: Critical — correction engine is core to the v3 lifecycle. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner-pool-supervisor
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
cleveragents/cleveragents-core#8928
No description provided.