feat(di): wire decision services #173

Closed
opened 2026-02-22 23:39:50 +00:00 by freemo · 2 comments
Owner

Metadata

  • Commit Message: feat(di): wire decision services
  • Branch: feature/m4-decision-di

Background

Decision repositories and services are wired into the DI container and CLI. DecisionService is injected into PlanLifecycleService so that strategize and execute phases automatically record decisions.

Acceptance Criteria

  • Wire DecisionService and DecisionRepository into DI container with proper scoping.
  • Add integration test verifying DI resolution path for decision services.
  • Update docs/reference/di.md with decision service registration.

Definition of Done

This issue is complete when:

  • All subtasks below are completed and checked off.
  • A Git commit is created where the first line of the commit message matches
    the Commit Message in Metadata exactly, followed by a blank line, then
    additional lines providing relevant details about the implementation. The
    commit body should be appropriate in size for a commit message and relatively
    complete in describing what was done.
  • The commit is pushed to the remote on the branch matching the Branch in
    Metadata exactly.
  • The commit is submitted as a pull request to master, reviewed, and
    merged before this issue is marked done.

Subtasks

  • Wire DecisionService and DecisionRepository into DI container with proper scoping.
  • Add integration test verifying DI resolution path for decision services.
  • Update docs/reference/di.md with decision service registration.
  • Tests (Behave): Add DI resolution and scoping scenarios.
  • Tests (Robot): Add Robot integration test for decision DI wiring.
  • Tests (ASV): Add benchmarks/decision_di_bench.py for DI overhead.
  • Verify coverage >=97% via nox -s coverage_report. If coverage is <97% then review the current unit test coverage report at build/coverage.xml and use it to write new Behave based unit tests to improve code coverage. Specifically, write Behave style unit tests that are descriptively named and specifically improves coverage on whichever file has the most uncovered lines by writing tests that will target the uncovered lines in the report. Once that is done rerun nox -s coverage_report to verify all tests pass and coverage is above >=97%. Only mark this as complete once coverage is >=97%, if not repeat this task as many times as is needed until coverage reaches >=97%.
  • Run nox (all default sessions, including benchmark), fix any errors if needed ensuring nox passes across entire code base, do not ignore any failure even if it seems unrelated to this commit, fix it.

Section: #### M3: Decisions + Validations + Invariants (Day 18)
Status: Open

## Metadata - **Commit Message**: `feat(di): wire decision services` - **Branch**: `feature/m4-decision-di` ## Background Decision repositories and services are wired into the DI container and CLI. `DecisionService` is injected into `PlanLifecycleService` so that strategize and execute phases automatically record decisions. ## Acceptance Criteria - [ ] Wire `DecisionService` and `DecisionRepository` into DI container with proper scoping. - [ ] Add integration test verifying DI resolution path for decision services. - [ ] Update `docs/reference/di.md` with decision service registration. ## Definition of Done This issue is complete when: - All subtasks below are completed and checked off. - A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation. The commit body should be appropriate in size for a commit message and relatively complete in describing what was done. - The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly. - The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done. ## Subtasks - [ ] Wire `DecisionService` and `DecisionRepository` into DI container with proper scoping. - [ ] Add integration test verifying DI resolution path for decision services. - [ ] Update `docs/reference/di.md` with decision service registration. - [ ] Tests (Behave): Add DI resolution and scoping scenarios. - [ ] Tests (Robot): Add Robot integration test for decision DI wiring. - [ ] Tests (ASV): Add `benchmarks/decision_di_bench.py` for DI overhead. - [ ] Verify coverage >=97% via `nox -s coverage_report`. If coverage is <97% then review the current unit test coverage report at `build/coverage.xml` and use it to write new Behave based unit tests to improve code coverage. Specifically, write Behave style unit tests that are descriptively named and specifically improves coverage on whichever file has the most uncovered lines by writing tests that will target the uncovered lines in the report. Once that is done rerun `nox -s coverage_report` to verify all tests pass and coverage is above >=97%. Only mark this as complete once coverage is >=97%, if not repeat this task as many times as is needed until coverage reaches >=97%. - [ ] Run `nox` (all default sessions, including benchmark), fix any errors if needed ensuring nox passes across **entire** code base, do not ignore any failure even if it seems unrelated to this commit, fix it. **Section**: #### M3: Decisions + Validations + Invariants (Day 18) **Status**: Open
freemo added this to the v3.2.0 milestone 2026-02-22 23:39:50 +00:00
Author
Owner

Expected completion updated (Day 15 rebaseline): Day 30 / 2026-03-10 (previously Day 26 / 2026-03-06)

**Expected completion updated (Day 15 rebaseline):** Day 30 / 2026-03-10 (previously Day 26 / 2026-03-06)
freemo added the due date 2026-03-06 2026-02-23 18:41:26 +00:00
freemo self-assigned this 2026-02-24 21:53:07 +00:00
Author
Owner

Implementation Notes (Day 19 — 2026-02-27)

PR #461: feat(di): wire decision services

Branch: feature/m4-decision-di
Commit: d551132da4c1286786b540e47bd1514d9202494d

Changes (11 files, +998 lines)

  1. DecisionService (application/services/decision_service.py, 210 lines):

    • Application-layer service wrapping DecisionRepository with UnitOfWork transaction management
    • Methods: record_decision, get_decision, get_decisions_for_plan, get_decision_tree, get_path_to_root, mark_superseded, list_by_type
    • Full structlog logging for all operations
  2. DI Container Wiring (application/container.py):

    • DecisionService registered as Factory provider
    • PlanLifecycleService registered as Factory with DecisionService injected
  3. PlanLifecycleService Integration:

    • Optional decision_service parameter in constructor
    • start_strategize auto-records strategy_choice decision
    • start_execute auto-records implementation_choice decision
    • Failures caught + logged — never block phase transitions
  4. Documentation: New docs/reference/di.md with provider table and usage examples

Tests

  • Behave: 5 scenarios — DI resolution, strategize recording, execute recording, repository access, scoping
  • Robot: 2 smoke tests — DI resolution, recording integration
  • ASV: 3 benchmarks — resolution, recording, tree retrieval

Quality Gates: All PASS (lint, typecheck, unit_tests, integration_tests)

## Implementation Notes (Day 19 — 2026-02-27) ### PR #461: `feat(di): wire decision services` **Branch:** `feature/m4-decision-di` **Commit:** `d551132da4c1286786b540e47bd1514d9202494d` ### Changes (11 files, +998 lines) 1. **DecisionService** (`application/services/decision_service.py`, 210 lines): - Application-layer service wrapping `DecisionRepository` with UnitOfWork transaction management - Methods: `record_decision`, `get_decision`, `get_decisions_for_plan`, `get_decision_tree`, `get_path_to_root`, `mark_superseded`, `list_by_type` - Full structlog logging for all operations 2. **DI Container Wiring** (`application/container.py`): - `DecisionService` registered as `Factory` provider - `PlanLifecycleService` registered as `Factory` with `DecisionService` injected 3. **PlanLifecycleService Integration**: - Optional `decision_service` parameter in constructor - `start_strategize` auto-records `strategy_choice` decision - `start_execute` auto-records `implementation_choice` decision - Failures caught + logged — never block phase transitions 4. **Documentation**: New `docs/reference/di.md` with provider table and usage examples ### Tests - **Behave**: 5 scenarios — DI resolution, strategize recording, execute recording, repository access, scoping - **Robot**: 2 smoke tests — DI resolution, recording integration - **ASV**: 3 benchmarks — resolution, recording, tree retrieval ### Quality Gates: All PASS (lint, typecheck, unit_tests, integration_tests)
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".

2026-03-06

Blocks
#394 Epic: Decision Framework
cleveragents/cleveragents-core
Reference
cleveragents/cleveragents-core#173
No description provided.