feat(actor): implement estimation actor type #962
Merged
brent.edwards
merged 3 commits from 2026-03-21 01:40:58 +00:00
feature/m5-estimation-actor into master
Dismiss Review
Are you sure you want to dismiss this review?
Labels
Clear labels
auto/needs-reevaluation
controller-managed
overdue
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
Needs Feedback
Signed-off: Owner
Signed-off: Scrum Master
Signed-off: Tech Lead
Spike
Controller deferred this PR; awaiting Phase 6+ scope-evaluator or operator re-enablement.
Auto-agents controller manages this PR/issue (see tools/controller/deploy/RUNBOOK.md). Remove this label to abandon controller management.
PR blocked by an open issue dependency. Operator must close the dep (or remove the dependency link) before the merge driver can act. Auto-cleared by merge_drive when no open deps remain.
Most recent merge cycle hit CI timeout. Driver excludes this PR while last merge_cycle row is < 30 min old; label persists thereafter as visible history.
Currently being processed by an implementer worker.
Currently being processed by the merge driver.
Currently being processed by a reviewer worker.
Merge driver heartbeat stale; pipeline halted. Closed automatically on next clean tick.
Detected master commit violating the strict merge invariant. Tracked as an issue (not a PR label); kept here for label completeness.
In-cycle escalation: most recent attempt ran at the Tier 0 slot (`tier-0`). Slot's model defined in .opencode/models/tiers.yaml.
In-cycle escalation: most recent attempt ran at the Tier 1 slot (`tier-1`). Slot's model defined in .opencode/models/tiers.yaml.
In-cycle escalation: most recent attempt ran at the Tier 2 slot (`tier-2`). Slot's model defined in .opencode/models/tiers.yaml. Gated behind IMPLEMENTER_ESCALATION_TIER2_ENABLED.
In-cycle escalation: most recent attempt ran at the Tier -1 slot (`tier-min`). Slot's model defined in .opencode/models/tiers.yaml. Suffix is ``-min`` (not ``--1``) so the Forgejo UI reads naturally.
Tracking issues used by the AI Automation system for agents to communicate and report.
Rebase conflict needs LLM conflict-resolver.
Failing CI needs implementer attention.
Documenting a driver incident or rollback.
Reviewer has APPROVED this PR and no later REQUEST_CHANGES is outstanding. The merge driver requires this label to even consider a PR for merging. Set by the reviewer worker on APPROVE; cleared on REQUEST_CHANGES.
Train repeatedly lost master-tempo races. Driver excludes via merge_cycle until cooldown elapses; label persists as visible history.
Revert PR backing out an invariant violation. Fast-tracked through the merge driver.
Sentinel PR duplicated from upstream into a personal fork by tools/duplicate_prs_to_fork.py for pipeline testing. Lives only in the fork; the canonical pipeline never sees it.
No implementer activity for N days. Flagged for human review. Auto-cleared on next push to head branch.
Repeatedly fails on current master (>= 3 ci-fail-on-rebased-sha releases in 12 h). Excluded from driver until human triage.
A ticket in a blocked state and unable to complete until some other task is completed first.
Bounty
$100
A bounty of $100 for any open-source contributor who provides a MR that solves this issue
Bounty
$1000
A bounty of $1000 for any open-source contributor who provides a MR that solves this issue
Bounty
$10000
A bounty of $10000 for any open-source contributor who provides a MR that solves this issue
Bounty
$20
A bounty of $20 for any open-source contributor who provides a MR that solves this issue
Bounty
$2000
A bounty of $2000 for any open-source contributor who provides a MR that solves this issue
Bounty
$250
A bounty of $250 for any open-source contributor who provides a MR that solves this issue
Bounty
$50
A bounty of $50 for any open-source contributor who provides a MR that solves this issue
Bounty
$500
A bounty of $500 for any open-source contributor who provides a MR that solves this issue
Bounty
$5000
A bounty of $5000 for any open-source contributor who provides a MR that solves this issue
Bounty
$750
A bounty of $750 for any open-source contributor who provides a MR that solves this issue
MoSCoW
Could have
Could have feature in order to satisfy the epic/legendary.
MoSCoW
Must have
Must have feature in order to satisfy the epic/legendary.
MoSCoW
Should have
Should have feature in order to satisfy the epic/legendary.
There are questions in the ticket that can not be completed until the project owner provides clarity.
Points
1
1 man-hours worth of work for an expert with no learning curve.
Points
13
13 man-hours worth of work for an expert with no learning curve.
Points
2
2 man-hours worth of work for an expert with no learning curve.
Points
21
21 man-hours worth of work for an expert with no learning curve.
Points
3
3 man-hours worth of work for an expert with no learning curve.
Points
34
34 man-hours worth of work for an expert with no learning curve.
Points
5
5 man-hours worth of work for an expert with no learning curve.
Points
55
55 man-hours worth of work for an expert with no learning curve.
Points
8
8 man-hours worth of work for an expert with no learning curve.
Points
88
88 man-hours worth of work for an expert with no learning curve.
Priority
Backlog
This ticket has backlogged priority and is not to be worked on yet
Priority
CI Blocker
Critical priority issue that blocks CI/CD pipeline and prevents PR merges
Priority
Critical
The priority is critical
Priority
High
The priority is high
Priority
Low
The priority is low
Priority
Medium
The priority is medium
When an epic or legendary is in review it must be signed off by owner, tech lead, and scrum master before being marked as completed.
When an epic or legendary is in review it must be signed off by owner, tech lead, and scrum master before being marked as completed.
When an epic or legendary is in review it must be signed off by owner, tech lead, and scrum master before being marked as completed.
A ticket for learning a tool or technology that is needed to be able to do future planning and design.
State
Completed
The ticket has been fully implemented, completed, and merged with the source code. This label should only be applied once a ticket is closed.
State
Duplicate
A ticket that represents the same content as an existing ticket.
State
In Progress
A ticket that is actively being developed.
State
In Review
A ticket that has had some code completed to implement but is waiting to pass peer review and is not yet merged in.
State
Paused
This ticket's work started but wasn't finished. It's on hold (likely in a feature branch) and will be resumed later, either due to a blocker or a delay.
State
Unverified
All new tickets start in this state. A developer may set it to show the ticket is unverified. This means we haven't agreed to work on it. It will either move to a verified state or be closed as wontdo.
State
Verified
The issue has been verified by a developer as legitimate. It will be worked on and verified tickets are now considered part of the backlog.
State
Wont Do
This ticket has been decided it wont be done. This may mean the bug has been determined to not be real (cant verify) or the feature is one we have decided we dont want to adopt.
Type
Automation
Any edits or discussion about the AI automated coding system.
Type
Bug
Something that doesnt work as intended.
Type
Discussion
Anytime a ticket represents a discussion about a subject and doesnt fall into one of the other categories.
Type
Documentation
An error or improvement needed in the documentation.
Type
Epic
Any first tier epic. That is, an epic which contains only issues as children and will not have sub-epics.
Type
Feature
Some new functionality not present.
Type
Legendary
A type of Epic which will contain other Epics.
Type
Refactor
A code change that restructures existing code without changing its external behavior.
Type
Support
Someone needs help using the project.
Type
Task
A generic task that doesnt fit into the other type categories.
Type
Testing
Work exclusively focusing on fixing or expanding testing.
Projects
Clear projects
No project
Assignees
aditya (Aditya Chhabra)
aleenaumair (Aleena Umair)
brent.edwards (Brent Edwards)
CoreRasurae (Luis Mendes)
drew (Drew Morris)
eugen.thaci (Eugen Thaci)
freemo (Jeffrey Phillips Freeman)
HAL9000 (HAL 9000)
HAL9001 (HAL9001)
hamza.khyari (Hamza Khyari)
hurui200320 (Rui Hu)
justin.morris
khird (Kyle Hird)
org.cleveragents
Clear assignees
No Assignees
brent.edwards
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cleveragents/cleveragents-core#962
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "feature/m5-estimation-actor"
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
Implement the estimation actor as a functional actor type. The estimation actor provides cost, time, and resource estimates for plan operations, running after Strategize completes (before Execute). Estimation is informational only and optional — plans work without an estimation actor configured.
Changes
New files:
src/cleveragents/domain/models/core/estimation.py—EstimationResultfrozen Pydantic model with fields for cost (USD), tokens, steps, child plans, time, risk level/factors, summaryfeatures/estimation_actor.feature— 12 Behave test scenarios (model validation, serialization, stub actor, plan integration, optional behavior)features/steps/estimation_actor_steps.py— Step definitionsrobot/estimation_actor.robot— 6 Robot integration testsrobot/helper_estimation_actor.py— Robot test helperModified files:
domain/models/acms/tiers.py— AddedESTIMATORtoActorRoleenumdomain/models/core/plan.py— Addedestimation_result: EstimationResult | Nonefield, estimation data inas_cli_dict()application/services/plan_executor.py— AddedEstimationStubActorclassapplication/services/plan_lifecycle_service.py— Added_run_estimation()method, invoked inexecute_plan()cli/commands/plan.py— Display estimation results in plan statusvulture_whitelist.py— Added 12 new public symbolsQuality Gates
nox -s lintnox -s typechecknox -s unit_testsnox -s integration_testsnox -s coverage_reportCloses #890
81a811265eto72b31b005fPM Triage — Day 36 (2026-03-16)
feat(actor): implement estimation actor type — M6 (v3.5.0), Points/8, Should have.
Status: New PR submitted Day 35, 0 reviews. This implements #890 (estimation actor).
Reviewer assignment: @CoreRasurae — you reviewed the estimation domain model. Please review this implementation for spec compliance.
Note: This PR depends on the estimation domain model (#649) being in a stable state. @brent.edwards — please confirm whether this is ready for independent review or if there are upstream dependencies that need to merge first.
PM Day 36 Triage: Estimation actor feature PR. Closes #890. Assignee: @hurui200320. Reviewer needed: @CoreRasurae (Python architecture expertise). This is M6 scope — not on critical path but contributes to autonomy hardening. Please ensure the actor YAML aligns with ADR-010 and ADR-031 actor abstraction requirements.
Status Update — Day 37
@freemo — Confirmed: PR #962 is ready for independent review. Master has been merged in today (conflicts in robot timeout files resolved).
Upstream dependencies: None blocking. The
EstimationResultdomain model is defined in this PR's ownestimation.pyfile — it doesn't depend on a separate domain model PR. The only dependency is on the existingPlanLifecycleServiceandActorRoleenum, both of which are stable on master.Ready for @CoreRasurae's review.
PM Status — Day 37
Reviewers assigned. This PR needs at least 2 approving reviews per
CONTRIBUTING.mdbefore merge.Author: Please ensure this PR is rebased on latest
masterand all quality gates pass before requesting merge.PM status — Day 37
Code Review — PR #962
Reviewed against the full review protocol (Phases 0-9) plus adversarial boundary testing. Typecheck (0 errors), lint, and all 12 Behave scenarios pass. The
EstimationResultdomain model is clean and well-structured.mergeable: true.Critical (must fix)
F1: PR labels — Remove
MoSCoW/Should haveandPoints/8from the PR. These belong on the issue only.F2: Issue #890 subtasks — All 9 subtasks and 7 acceptance criteria are still unchecked.
Major (must fix)
F3:
_run_estimation()always uses stub, ignores actual actor name (plan_lifecycle_service.py:293-305)The method checks if
estimation_actoris set, but then unconditionally createsEstimationStubActor()regardless of the actor name. If the user setsestimation_actor="openai/gpt-4-estimator", the real actor is never resolved — only the stub runs. The actor name is logged but never used for dispatch.This is acceptable if the stub is intentional for this milestone (with real actor dispatch deferred), but the docstring says "invokes the estimation stub actor" without clarifying this is a temporary limitation. Either add a TODO comment or implement actual actor resolution.
F4: No input validation on
EstimationResultnumeric fields (estimation.py)Empirically confirmed — all of these are silently accepted:
estimated_cost_usd,estimated_tokens,estimated_steps,estimated_time_secondsneedge=0constraints.risk_levelshould useLiteral["low", "medium", "high", "critical"]or a StrEnum.F5: Duplicated estimation serialization in 3 places
The identical
est_dictconstruction (8 conditional field assignments) appears in:Plan.as_cli_dict()(plan.py:953-978)_plan_spec_dict()(cli/commands/plan.py:142-167)_print_lifecycle_plan()(cli/commands/plan.py:1200-1228) uses the same logic in a different formatExtract a shared helper — e.g.,
EstimationResult.as_display_dict()— and have all three call it.F6: Missing
__all__(estimation.py)Module needs:
Minor (non-blocking)
F7: Test step accesses private method
_commit_plan(estimation_actor_steps.py:319)context.est_lifecycle._commit_plan(plan)directly calls a private API. Use a public method or add a test-specific helper.F8: No boundary tests for negative/invalid estimation values
No scenario tests negative
estimated_cost_usd, negativeestimated_tokens, or invalidrisk_level. Once F4 is fixed, add rejection scenarios.F9:
context_tiers.featureassertion is count-basedThe test checks for exactly 4 roles (after adding ESTIMATOR). If another role is added, this test breaks. Consider asserting
ESTIMATOR in rolesinstead of checking total count.Summary
The domain model and lifecycle integration are well-designed. F3 (stub always used) should either be documented as intentional or resolved. F4 (missing validation constraints) is the most important model-level issue.
Code Review — PR #962 (Round 2)
Deeper analysis: frozen-model container mutation, NaN/Inf floats, unbounded fields, and lifecycle state tracing. All findings empirically confirmed.
Major
F10:
risk_factorslist is mutable despite frozen model (estimation.py:53)Classic Phase 3.4 bug. Confirmed:
Pydantic
frozen=Trueprevents field reassignment but not mutation of mutable containers. Therisk_factorslist can be modified in-place after construction, violating the frozen invariant.Fix: use
tuple[str, ...]instead oflist[str]:F11: NaN and Inf accepted for float fields (
estimation.py:29,45)Confirmed:
NaN serializes as
nullin JSON (model_dump_json), silently losing data. Inf would fail JSON serialization in strict mode. Addallow_inf_nan=Falseto the model config or useField(allow_inf_nan=False)on each float field.F12: No bounds on
summary,raw_output, andrisk_factorssize (estimation.py:53-64)Confirmed:
An adversarial or buggy estimation actor could produce unbounded output. Add
max_lengthon string fields and amax_lengthor validator onrisk_factors.Minor
F13:
_run_estimationdouble-commits the plan_run_estimation()callsself._commit_plan(plan)at line 305. Then the calling methodexecute_plan()modifiesplan.phase/plan.processing_stateand callsself._commit_plan(plan)again at line 1028. The first commit persists the plan in Strategize/complete with estimation_result, then the second commit transitions to Execute/queued. If the second commit fails, the plan is left with estimation data but never transitions. Not a data-corruption bug (estimation is informational), but an unnecessary intermediate persist.F14: Frozen model test gives false confidence (
estimation_actor.feature:18-21)The "EstimationResult is frozen" scenario only tests field reassignment (which frozen blocks). It does not test container mutation (which frozen does NOT block). Given F10, this test passes while the model is demonstrably mutable.
F15: No test for estimation failure being non-blocking
The issue and docstring say "Estimation is informational only -- failures are logged but never block the Execute transition." There is no scenario that verifies a failing estimation actor still allows Execute to proceed.
Round 2 Summary
The most important finding is F10 (frozen container mutation). Combined with Round 1, the total is 2 Critical, 7 Major, 6 Minor.
check comments
Response to @hamza.khyari's Review (Rounds 1+2) — PR #962
Thank you for the extremely thorough review, Hamza. The empirical confirmations on the boundary cases are particularly valuable. Addressing all 15 findings:
Critical
F1 (PR labels): Will remove
MoSCoW/Should haveandPoints/8from the PR.F2 (Issue subtasks): Will check off all completed subtasks and ACs on issue #890.
Major (Round 1)
F3 (Stub always used): Good catch. The stub is intentional for this milestone — real actor dispatch is deferred to the estimation actor integration PR. I'll add a clear
# TODO(#XXX): Replace stub with real actor dispatchcomment and update the docstring to say "currently uses a stub implementation."F4 (No input validation): Confirmed all 5 examples. Will add
ge=0toestimated_cost_usd,estimated_tokens,estimated_steps,estimated_time_seconds. Will changerisk_leveltoLiteral["low", "medium", "high", "critical"] | None.F5 (Duplicated serialization): Agreed — will extract
EstimationResult.as_display_dict()and have all 3 sites call it.F6 (Missing
__all__): Will add.Major (Round 2)
F10 (Mutable
risk_factors): Excellent catch — the classic frozen-model gotcha. Will change totuple[str, ...].F11 (NaN/Inf accepted): Will add
model_config = ConfigDict(frozen=True, allow_inf_nan=False).F12 (No bounds): Will add
max_length=10_000onsummary,max_length=100_000onraw_output, and a@field_validatoronrisk_factorscapping at 100 items.Minor
F7 (Private
_commit_planaccess): Will add a publicpersist_plan()method and use that from tests.F8 (No negative boundary tests): Will add scenarios for negative values and invalid
risk_levelonce F4 is fixed.F9 (Count-based assertion): Will change to
assert "ESTIMATOR" in roles.F13 (Double-commit): Acknowledged — the intermediate persist is harmless but wasteful. Will remove the first
_commit_planand let the caller handle persistence.F14 (Frozen test false confidence): Will add a scenario testing container mutation rejection (after F10).
F15 (No failure-is-non-blocking test): Will add a scenario with a failing estimation that verifies Execute still proceeds.
Working on all fixes now.
186e9de15btobf98803460beacd0373fto7e5695002b7e5695002bto2977c678cfReview Fixes Applied
Pushed
2977c678with the following fixes from @hamza.khyari's review:Major Fixes
EstimationResultnumeric fieldsge=0/ge=0.0toestimated_cost_usd,estimated_tokens,estimated_steps,estimated_time_seconds. Changedrisk_leveltoLiteral["low", "medium", "high", "critical"] | None.risk_factorslist on frozen modellist[str]→tuple[str, ...]withdefault_factory=tuple. Updated all call-sites.allow_inf_nan=FalsetoConfigDict.__all____all__ = ["EstimationResult"].as_display_dict()method onEstimationResult. Wired it intoPlan.as_cli_dict()and_build_plan_summary(). Added TODO on the Rich display site (_show_plan_detail)._run_estimation()always uses stub# TODO: Replace EstimationStubActor with real actor dispatch via actor registry.Minor Fixes
summary,raw_output,risk_factorssizemax_length=10_000onsummary,max_length=100_000onraw_output,@field_validatorcappingrisk_factorsat 100 items.context_tiersassert len(ActorRole) == 4→assert "estimator" in [r.value for r in ActorRole]._commit_plan# TODO: Use public save_plan() once test helpers are refactored.Skipped (handled separately)
Verification
nox -s lint— passed (0 errors)nox -s typecheck— passed (0 errors, 1 pre-existing warning)Review Fixes Applied — Commit
2977c678Addressed all actionable findings from @hamza.khyari's 2-round review.
Model fixes (
estimation.py)ge=0on all numeric fields;risk_levelnowLiteral["low", "medium", "high", "critical"] | None__all__)__all__ = ["EstimationResult"]risk_factors)list[str]→tuple[str, ...]withField(default_factory=tuple)allow_inf_nan=FalsetoConfigDictmax_length=10_000onsummary,max_length=100_000onraw_output;@field_validatorcapsrisk_factorsat 100 itemsas_display_dict()method;plan.pyandplan.pyCLI callers now use it; TODO on Rich display siteService/test fixes
_run_estimation()docstring + added TODO comment"estimator" in [r.value for r in ActorRole]_commit_planaccess)Process items (handled separately)
MoSCoW/Should haveandPoints/8from PRQuality Gates
nox -s lint— PASSnox -s typecheck— PASS (0 errors)Code Review — PR #962
Estimation actor implementation. Proper labels, milestone, and issue linkage (#890). Approved.
2977c678cfto02c09bebd7New commits pushed, approval review dismissed automatically according to repository settings
Rebased onto
origin/master(79b0a2c5). Clean rebase (no conflicts).nox -s lintPASS,nox -s typecheckPASS (0 errors). Commit02c09beb.02c09bebd7tof325f7a036Coverage was 96.9%, just under the 97% threshold. Added 2 new Behave scenarios to
estimation_actor.featurecovering previously-unexercised paths inEstimationResult:as_display_dictincludes all populated fields — exercises theestimated_child_plans,estimated_time_seconds, andrisk_factorsbranches inas_display_dict()(lines 108, 110, 114)._cap_risk_factorsvalidator error path (line 82).All 14 estimation scenarios pass. Lint and typecheck clean.