UAT: ErrorPatternService (Layer 4 Predictive Error Prevention) is not wired into the DI container — predictive guidance is never injected before plan execution #4032

Open
opened 2026-04-06 08:52:52 +00:00 by freemo · 0 comments
Owner

Metadata

  • Branch: fix/wire-error-pattern-service-into-di-container
  • Commit Message: fix(container): wire ErrorPatternService into DI container and inject into PlanLifecycleService
  • Milestone: None (backlog)
  • Parent Epic: #368

What Was Tested

  • src/cleveragents/application/container.py — Searched entire file (968 lines) for ErrorPatternService, error_pattern_service, error_patternzero matches found
  • src/cleveragents/application/services/plan_lifecycle_service.py:190PlanLifecycleService.__init__ accepts error_pattern_service: ErrorPatternService | None = None as an optional parameter
  • src/cleveragents/application/container.py:629-636PlanLifecycleService is instantiated in the DI container WITHOUT the error_pattern_service parameter, so it always defaults to None
  • When error_pattern_service is None, the predictive guidance injection in PlanLifecycleService (lines 294-299) is silently skipped

Bug Description

ErrorPatternService (in src/cleveragents/application/services/error_pattern_service.py) implements "Layer 4: Predictive Error Prevention" — it matches historical error patterns against the current plan context and injects preventive guidance before execution. However, it is not wired into the DI container (src/cleveragents/application/container.py).

Expected Behavior

Per the implementation's own docstring:

When provided, the service is consulted before the Execute phase to inject preventive guidance. When None, predictive prevention is silently skipped.

ErrorPatternService should be instantiated in the DI container and injected into PlanLifecycleService so that:

  1. Historical error patterns are matched against the current plan context before execution
  2. Preventive guidance is injected into the actor context to avoid known failure modes
  3. New failures are recorded to the error pattern database for future prevention

Actual Behavior

ErrorPatternService is never instantiated in production. The DI container creates PlanLifecycleService without it, so:

  • Layer 4 Predictive Error Prevention is completely disabled at runtime
  • No preventive guidance is ever injected before plan execution
  • New failures are never recorded to the error pattern database (except via the agents system error-patterns CLI command which creates its own instance directly)

Code Locations

  • src/cleveragents/application/container.py:629-636PlanLifecycleService created without error_pattern_service
  • src/cleveragents/application/services/plan_lifecycle_service.py:190,234error_pattern_service parameter defaults to None
  • src/cleveragents/application/services/plan_lifecycle_service.py:294-299 — predictive guidance injection silently skipped when None
  • src/cleveragents/application/services/error_pattern_service.py — fully implemented but never used in production

Steps to Reproduce

  1. Create a plan that has previously failed with a known error pattern
  2. Observe that no preventive guidance is injected into the actor context before execution
  3. Observe that the error pattern database is never consulted before plan execution

Subtasks

  • Add a TDD issue-capture Behave scenario proving ErrorPatternService is None in PlanLifecycleService at runtime
  • Add a TDD issue-capture Behave scenario proving predictive guidance injection is silently skipped (lines 294-299) when error_pattern_service is None
  • Instantiate ErrorPatternService in container.py and register it as a singleton provider
  • Inject ErrorPatternService into PlanLifecycleService via the DI container (remove None default for production wiring)
  • Verify that historical error patterns are consulted before the Execute phase when error_pattern_service is present
  • Verify that new failures are recorded to the error pattern database during plan execution
  • Update integration tests to assert preventive guidance appears in actor context before execution when matching patterns exist
  • Ensure all nox stages pass with coverage >= 97%

Definition of Done

  • ErrorPatternService is instantiated and registered as a singleton in container.py
  • PlanLifecycleService receives a non-None ErrorPatternService from the DI container at runtime
  • Predictive guidance is injected into actor context before Execute phase when matching error patterns exist
  • New plan execution failures are recorded to the error pattern database
  • TDD issue-capture tests are green (bug proven before fix, passing after fix)
  • All nox stages pass
  • Coverage >= 97%

Backlog note: This issue was discovered during autonomous operation
on milestone v3.5.0. It does not block milestone completion and has been
placed in the backlog for human review and future milestone assignment.


Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: ca-uat-tester

## Metadata - **Branch**: `fix/wire-error-pattern-service-into-di-container` - **Commit Message**: `fix(container): wire ErrorPatternService into DI container and inject into PlanLifecycleService` - **Milestone**: None (backlog) - **Parent Epic**: #368 ## What Was Tested - `src/cleveragents/application/container.py` — Searched entire file (968 lines) for `ErrorPatternService`, `error_pattern_service`, `error_pattern` — **zero matches found** - `src/cleveragents/application/services/plan_lifecycle_service.py:190` — `PlanLifecycleService.__init__` accepts `error_pattern_service: ErrorPatternService | None = None` as an optional parameter - `src/cleveragents/application/container.py:629-636` — `PlanLifecycleService` is instantiated in the DI container WITHOUT the `error_pattern_service` parameter, so it always defaults to `None` - When `error_pattern_service` is `None`, the predictive guidance injection in `PlanLifecycleService` (lines 294-299) is silently skipped ## Bug Description `ErrorPatternService` (in `src/cleveragents/application/services/error_pattern_service.py`) implements "Layer 4: Predictive Error Prevention" — it matches historical error patterns against the current plan context and injects preventive guidance before execution. However, it is **not wired into the DI container** (`src/cleveragents/application/container.py`). ## Expected Behavior Per the implementation's own docstring: > When provided, the service is consulted before the Execute phase to inject preventive guidance. When None, predictive prevention is silently skipped. `ErrorPatternService` should be instantiated in the DI container and injected into `PlanLifecycleService` so that: 1. Historical error patterns are matched against the current plan context before execution 2. Preventive guidance is injected into the actor context to avoid known failure modes 3. New failures are recorded to the error pattern database for future prevention ## Actual Behavior `ErrorPatternService` is never instantiated in production. The DI container creates `PlanLifecycleService` without it, so: - Layer 4 Predictive Error Prevention is completely disabled at runtime - No preventive guidance is ever injected before plan execution - New failures are never recorded to the error pattern database (except via the `agents system error-patterns` CLI command which creates its own instance directly) ## Code Locations - `src/cleveragents/application/container.py:629-636` — `PlanLifecycleService` created without `error_pattern_service` - `src/cleveragents/application/services/plan_lifecycle_service.py:190,234` — `error_pattern_service` parameter defaults to `None` - `src/cleveragents/application/services/plan_lifecycle_service.py:294-299` — predictive guidance injection silently skipped when `None` - `src/cleveragents/application/services/error_pattern_service.py` — fully implemented but never used in production ## Steps to Reproduce 1. Create a plan that has previously failed with a known error pattern 2. Observe that no preventive guidance is injected into the actor context before execution 3. Observe that the error pattern database is never consulted before plan execution ## Subtasks - [ ] Add a TDD issue-capture Behave scenario proving `ErrorPatternService` is `None` in `PlanLifecycleService` at runtime - [ ] Add a TDD issue-capture Behave scenario proving predictive guidance injection is silently skipped (lines 294-299) when `error_pattern_service` is `None` - [ ] Instantiate `ErrorPatternService` in `container.py` and register it as a singleton provider - [ ] Inject `ErrorPatternService` into `PlanLifecycleService` via the DI container (remove `None` default for production wiring) - [ ] Verify that historical error patterns are consulted before the Execute phase when `error_pattern_service` is present - [ ] Verify that new failures are recorded to the error pattern database during plan execution - [ ] Update integration tests to assert preventive guidance appears in actor context before execution when matching patterns exist - [ ] Ensure all nox stages pass with coverage >= 97% ## Definition of Done - [ ] `ErrorPatternService` is instantiated and registered as a singleton in `container.py` - [ ] `PlanLifecycleService` receives a non-`None` `ErrorPatternService` from the DI container at runtime - [ ] Predictive guidance is injected into actor context before Execute phase when matching error patterns exist - [ ] New plan execution failures are recorded to the error pattern database - [ ] TDD issue-capture tests are green (bug proven before fix, passing after fix) - [ ] All nox stages pass - [ ] Coverage >= 97% > **Backlog note:** This issue was discovered during autonomous operation > on milestone v3.5.0. It does not block milestone completion and has been > placed in the backlog for human review and future milestone assignment. --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-uat-tester
HAL9000 added this to the v3.5.0 milestone 2026-04-09 03:11:46 +00:00
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.

Blocks
#368 Epic: Subplans & Parallelism
cleveragents/cleveragents-core
Reference
cleveragents/cleveragents-core#4032
No description provided.