UAT: EstimationStubActor used in production instead of real actor registry dispatch #2816

Open
opened 2026-04-04 20:38:56 +00:00 by freemo · 2 comments
Owner

Metadata

  • Branch: fix/plan-lifecycle-estimation-actor-registry-dispatch
  • Commit Message: fix(plan-lifecycle): replace EstimationStubActor with real actor registry dispatch in _run_estimation
  • Milestone: v3.7.0
  • Parent Epic: #392

Background and Context

The _run_estimation method in src/cleveragents/application/services/plan_lifecycle_service.py (around line 230) contains an explicit TODO comment acknowledging that it uses a stub implementation instead of real actor dispatch:

# TODO: Replace EstimationStubActor with real actor dispatch
# via actor registry
stub = EstimationStubActor()
result = stub.estimate(plan.identity.plan_id)

Per docs/specification.md, the estimation actor is a real actor configured on the Action YAML template via the estimation_actor field (e.g., estimation_actor: local/estimator). When a plan has an estimation_actor configured, the Execute phase must dispatch to that actor via the actor registry — not use a hardcoded stub.

The EstimationStubActor class is imported from plan_executor.py and used directly. The actor registry resolution path (_resolve_actor_registry_entry) already exists in the service but is not used for estimation dispatch.

Current Behavior

When _run_estimation is called during the Execute phase:

  1. The method ignores the plan's configured estimation_actor field entirely.
  2. It instantiates EstimationStubActor() directly and calls stub.estimate(plan.identity.plan_id).
  3. The stub returns fake/placeholder estimation data (cost, risk, etc.).
  4. No actor registry lookup or dispatch occurs.

Any plan configured with an estimation_actor silently uses the stub instead of the configured actor. The failure is silent — no warning, no error, no log message indicating the stub is being used.

Affected codesrc/cleveragents/application/services/plan_lifecycle_service.py, method _run_estimation (~line 230):

# TODO: Replace EstimationStubActor with real actor dispatch
# via actor registry
stub = EstimationStubActor()
result = stub.estimate(plan.identity.plan_id)

Expected Behavior

Per docs/specification.md, when a plan has an estimation_actor configured:

  1. _run_estimation must resolve the actor via the actor registry using the existing _resolve_actor_registry_entry method.
  2. The resolved actor must be dispatched with the plan ID to perform real cost/risk estimation.
  3. If no estimation_actor is configured on the plan's Action YAML template, the method may skip estimation or use a documented default behaviour — but must not silently fall back to a stub.
  4. The EstimationStubActor import and usage must be removed from production code entirely. Any stub implementations must live exclusively in features/mocks/ per CONTRIBUTING.md.

Subtasks

  • Audit _run_estimation in plan_lifecycle_service.py to understand the full call chain and what data the stub currently returns
  • Audit _resolve_actor_registry_entry to confirm it can resolve an estimation_actor reference from the Action YAML template
  • Implement real actor registry dispatch in _run_estimation: resolve the configured estimation_actor via _resolve_actor_registry_entry and dispatch the estimation call
  • Handle the case where no estimation_actor is configured (skip estimation gracefully or raise a clear error — per spec)
  • Remove the EstimationStubActor import and all usages from plan_lifecycle_service.py (and plan_executor.py if it is only used there for this purpose)
  • Move any remaining stub/mock logic to features/mocks/ if needed for tests
  • Tests (Behave): Write a failing BDD scenario first demonstrating the bug (stub used instead of registry dispatch), then implement the fix
  • Tests (Behave): Add BDD scenarios covering: actor registry dispatch succeeds, actor not found in registry raises clear error, no estimation_actor configured is handled gracefully
  • Tests (Robot): Add/update integration test asserting that a plan with a configured estimation_actor dispatches to the registry (not a stub) during Execute phase
  • Run nox -e typecheck — ensure all type annotations are correct and no # type: ignore suppressions are added
  • Run nox -e lint — ensure code passes all linting checks
  • Run nox -e coverage_report — verify coverage ≥ 97%
  • Run full nox suite — all default sessions must pass

Definition of Done

  • _run_estimation dispatches to the actor registry using the plan's configured estimation_actor — no stub is used in production code
  • EstimationStubActor is removed from all production source files; any test doubles live exclusively in features/mocks/
  • A failing Behave scenario demonstrating the bug exists before the fix is implemented (TDD)
  • All new and updated Behave scenarios pass
  • Robot Framework integration test confirms real actor registry dispatch during Execute phase
  • All nox stages pass (nox -e lint, nox -e typecheck, nox -e unit_tests, nox -e integration_tests, nox -e coverage_report)
  • Coverage ≥ 97%
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly (fix(plan-lifecycle): replace EstimationStubActor with real actor registry dispatch in _run_estimation), followed by a blank line, then additional implementation details, and ending with ISSUES CLOSED: #<this issue number>
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly (fix/plan-lifecycle-estimation-actor-registry-dispatch)
  • The commit is submitted as a pull request to master, reviewed by at least two non-authors, all CI checks pass, and the PR is merged before this issue is marked done

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

## Metadata - **Branch**: `fix/plan-lifecycle-estimation-actor-registry-dispatch` - **Commit Message**: `fix(plan-lifecycle): replace EstimationStubActor with real actor registry dispatch in _run_estimation` - **Milestone**: v3.7.0 - **Parent Epic**: #392 ## Background and Context The `_run_estimation` method in `src/cleveragents/application/services/plan_lifecycle_service.py` (around line 230) contains an explicit TODO comment acknowledging that it uses a stub implementation instead of real actor dispatch: ```python # TODO: Replace EstimationStubActor with real actor dispatch # via actor registry stub = EstimationStubActor() result = stub.estimate(plan.identity.plan_id) ``` Per `docs/specification.md`, the estimation actor is a real actor configured on the Action YAML template via the `estimation_actor` field (e.g., `estimation_actor: local/estimator`). When a plan has an `estimation_actor` configured, the Execute phase must dispatch to that actor via the actor registry — not use a hardcoded stub. The `EstimationStubActor` class is imported from `plan_executor.py` and used directly. The actor registry resolution path (`_resolve_actor_registry_entry`) already exists in the service but is **not** used for estimation dispatch. ## Current Behavior When `_run_estimation` is called during the Execute phase: 1. The method ignores the plan's configured `estimation_actor` field entirely. 2. It instantiates `EstimationStubActor()` directly and calls `stub.estimate(plan.identity.plan_id)`. 3. The stub returns fake/placeholder estimation data (cost, risk, etc.). 4. No actor registry lookup or dispatch occurs. Any plan configured with an `estimation_actor` silently uses the stub instead of the configured actor. The failure is silent — no warning, no error, no log message indicating the stub is being used. **Affected code** — `src/cleveragents/application/services/plan_lifecycle_service.py`, method `_run_estimation` (~line 230): ```python # TODO: Replace EstimationStubActor with real actor dispatch # via actor registry stub = EstimationStubActor() result = stub.estimate(plan.identity.plan_id) ``` ## Expected Behavior Per `docs/specification.md`, when a plan has an `estimation_actor` configured: 1. `_run_estimation` must resolve the actor via the actor registry using the existing `_resolve_actor_registry_entry` method. 2. The resolved actor must be dispatched with the plan ID to perform real cost/risk estimation. 3. If no `estimation_actor` is configured on the plan's Action YAML template, the method may skip estimation or use a documented default behaviour — but must **not** silently fall back to a stub. 4. The `EstimationStubActor` import and usage must be removed from production code entirely. Any stub implementations must live exclusively in `features/mocks/` per CONTRIBUTING.md. ## Subtasks - [ ] Audit `_run_estimation` in `plan_lifecycle_service.py` to understand the full call chain and what data the stub currently returns - [ ] Audit `_resolve_actor_registry_entry` to confirm it can resolve an `estimation_actor` reference from the Action YAML template - [ ] Implement real actor registry dispatch in `_run_estimation`: resolve the configured `estimation_actor` via `_resolve_actor_registry_entry` and dispatch the estimation call - [ ] Handle the case where no `estimation_actor` is configured (skip estimation gracefully or raise a clear error — per spec) - [ ] Remove the `EstimationStubActor` import and all usages from `plan_lifecycle_service.py` (and `plan_executor.py` if it is only used there for this purpose) - [ ] Move any remaining stub/mock logic to `features/mocks/` if needed for tests - [ ] Tests (Behave): Write a failing BDD scenario first demonstrating the bug (stub used instead of registry dispatch), then implement the fix - [ ] Tests (Behave): Add BDD scenarios covering: actor registry dispatch succeeds, actor not found in registry raises clear error, no `estimation_actor` configured is handled gracefully - [ ] Tests (Robot): Add/update integration test asserting that a plan with a configured `estimation_actor` dispatches to the registry (not a stub) during Execute phase - [ ] Run `nox -e typecheck` — ensure all type annotations are correct and no `# type: ignore` suppressions are added - [ ] Run `nox -e lint` — ensure code passes all linting checks - [ ] Run `nox -e coverage_report` — verify coverage ≥ 97% - [ ] Run full `nox` suite — all default sessions must pass ## Definition of Done - [ ] `_run_estimation` dispatches to the actor registry using the plan's configured `estimation_actor` — no stub is used in production code - [ ] `EstimationStubActor` is removed from all production source files; any test doubles live exclusively in `features/mocks/` - [ ] A failing Behave scenario demonstrating the bug exists before the fix is implemented (TDD) - [ ] All new and updated Behave scenarios pass - [ ] Robot Framework integration test confirms real actor registry dispatch during Execute phase - [ ] All nox stages pass (`nox -e lint`, `nox -e typecheck`, `nox -e unit_tests`, `nox -e integration_tests`, `nox -e coverage_report`) - [ ] Coverage ≥ 97% - [ ] A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly (`fix(plan-lifecycle): replace EstimationStubActor with real actor registry dispatch in _run_estimation`), followed by a blank line, then additional implementation details, and ending with `ISSUES CLOSED: #<this issue number>` - [ ] The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly (`fix/plan-lifecycle-estimation-actor-registry-dispatch`) - [ ] The commit is submitted as a **pull request** to `master`, reviewed by at least two non-authors, all CI checks pass, and the PR is merged before this issue is marked done --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-uat-tester
freemo added this to the v3.7.0 milestone 2026-04-04 20:39:06 +00:00
Author
Owner

Starting implementation on branch fix/plan-lifecycle-estimation-actor-registry-dispatch.

Analysis complete:

  • _run_estimation in plan_lifecycle_service.py uses EstimationStubActor directly instead of the actor registry
  • _resolve_actor_registry_entry already exists and can resolve actors by name
  • The fix requires: (1) resolve actor via registry, (2) dispatch estimation call, (3) remove stub import from production code
  • TDD approach: write failing BDD scenario first, then implement fix

Wave plan:

  • Wave 1 (parallel): Write failing BDD scenario + audit code
  • Wave 2: Implement real actor registry dispatch in _run_estimation
  • Wave 3: Remove EstimationStubActor from production, move to features/mocks/
  • Wave 4: Quality gates (lint, typecheck, coverage)

Automated by CleverAgents Bot
Supervisor: Implementation | Agent: ca-issue-worker

Starting implementation on branch `fix/plan-lifecycle-estimation-actor-registry-dispatch`. **Analysis complete:** - `_run_estimation` in `plan_lifecycle_service.py` uses `EstimationStubActor` directly instead of the actor registry - `_resolve_actor_registry_entry` already exists and can resolve actors by name - The fix requires: (1) resolve actor via registry, (2) dispatch estimation call, (3) remove stub import from production code - TDD approach: write failing BDD scenario first, then implement fix **Wave plan:** - Wave 1 (parallel): Write failing BDD scenario + audit code - Wave 2: Implement real actor registry dispatch in `_run_estimation` - Wave 3: Remove `EstimationStubActor` from production, move to `features/mocks/` - Wave 4: Quality gates (lint, typecheck, coverage) --- **Automated by CleverAgents Bot** Supervisor: Implementation | Agent: ca-issue-worker
Author
Owner

Label compliance fix applied:

  • Added missing label: State/Verified
  • Reason: Issue had Priority/High and Type/Bug but was missing a State/* label. Per CONTRIBUTING.md, a State/* label is required. Added State/Verified since the issue has a milestone and is ready for work.

Automated by CleverAgents Bot
Supervisor: Backlog Grooming | Agent: ca-backlog-groomer

Label compliance fix applied: - Added missing label: `State/Verified` - Reason: Issue had `Priority/High` and `Type/Bug` but was missing a `State/*` label. Per CONTRIBUTING.md, a `State/*` label is required. Added `State/Verified` since the issue has a milestone and is ready for work. --- **Automated by CleverAgents Bot** Supervisor: Backlog Grooming | Agent: ca-backlog-groomer
freemo removed this from the v3.7.0 milestone 2026-04-07 00:42:17 +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
#392 Epic: Actor YAML & Compiler
cleveragents/cleveragents-core
Reference
cleveragents/cleveragents-core#2816
No description provided.