Implemented optional estimation_actor role for cost, risk, and duration
estimation during plan lifecycle. Estimates are persisted to plan metadata
and surfaced in CLI output. Key implementation details:
- EstimationOutput (Pydantic models): CostEstimate with currency, token
estimates, and confidence ranges; RiskScore with 0-100 scale and factors;
DurationEstimate with min/expected/max seconds. All include confidence
levels and validation. EstimationSkipped records when estimation is opted out.
- EstimationService: stateless async service that invokes estimation actor
(stub implementation for M6). Handles actor output parsing, error recovery,
and fallback to EstimationSkipped on failure.
- Integration: Plan model gains estimation_output and estimation_skipped fields.
LifecyclePlanModel adds JSON columns for persistence. PlanLifecycleService
invokes estimation during use_action unless skip_estimation is true.
- CLI: --no-estimate flag added to 'agents plan use'. plan status displays
cost (USD with token estimates), risk (score/100 with confidence), and
duration (seconds with ranges) in rich format.
- Database: Alembic migration m6_003_estimation_metadata adds
estimation_output_json and estimation_skipped_json columns to v3_plans.
- Tests: 44 BDD scenarios (features/estimation.feature) covering validation,
lifecycle integration, persistence, CLI display, and edge cases. 18 Robot
Framework smoke tests. 19 ASV benchmark suites for schema, serialization,
validation, and plan integration performance.
- Documentation: docs/reference/estimation.md with schema, configuration,
and examples. plan_cli.md updated with --no-estimate flag usage.
ISSUES CLOSED: #209
Add Alembic migration m4_002_skill_flattened_tools to extend the skills
table with five new columns: flattened_tools_json, includes_json,
capability_summary_json, yaml_text, and flattening_hash (SHA-256). A
defence-in-depth uniqueness constraint (uq_skills_name) is also added.
Update SkillModel with the new column definitions and extend
SkillRepository with update_flattened_tools(), get_flattened_tools(),
needs_refresh(), recompute_flattening_hash(), and
invalidate_cached_summaries() methods. The existing update() method
now nulls all cached fields on mutation (hash-based invalidation).
All new repository methods follow the session-factory pattern with
@database_retry and flush-but-don-t-commit semantics. Structured
logging via structlog records cache updates and invalidations.
Database schema docs updated with the new skills table columns and a
persistence-field-to-domain-model mapping table.
Tests:
- 6 Behave scenarios covering create, invalidation, hash staleness,
refresh recomputation, uniqueness constraint, and namespace filtering
- 2 Robot Framework smoke tests (round-trip and invalidation)
- 3 ASV benchmarks (persist, refresh check, namespace list)
ISSUES CLOSED: #166
Add decision persistence layer with DecisionRepository, DecisionModel,
and Alembic migration. Includes tree queries (BFS traversal via deque,
path-to-root), superseded lookup, ordered decision path retrieval,
concrete Decision type annotations (via TYPE_CHECKING), and comprehensive
test coverage (Behave BDD, Robot Framework, ASV benchmarks). Updated
database_schema.md, CHANGELOG.md, and CONTRIBUTORS.md.
ISSUES CLOSED: #171