bug(cli): automation_profile._get_service() bypasses DI container #1181
No reviewers
Labels
No labels
auto/needs-reevaluation
controller-managed
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
Bounty
$100
Bounty
$1000
Bounty
$10000
Bounty
$20
Bounty
$2000
Bounty
$250
Bounty
$50
Bounty
$500
Bounty
$5000
Bounty
$750
MoSCoW
Could have
MoSCoW
Must have
MoSCoW
Should have
Needs Feedback
Points
1
Points
13
Points
2
Points
21
Points
3
Points
34
Points
5
Points
55
Points
8
Points
88
Priority
Backlog
Priority
CI Blocker
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Signed-off: Owner
Signed-off: Scrum Master
Signed-off: Tech Lead
Spike
State
Completed
State
Duplicate
State
In Progress
State
In Review
State
Paused
State
Unverified
State
Verified
State
Wont Do
Type
Automation
Type
Bug
Type
Discussion
Type
Documentation
Type
Epic
Type
Feature
Type
Legendary
Type
Refactor
Type
Support
Type
Task
Type
Testing
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Depends on
#990 bug(cli): automation_profile._get_service() bypasses DI container
cleveragents/cleveragents-core
Reference
cleveragents/cleveragents-core!1181
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "bugfix/m4-automation-profile-di-bypass"
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
automation_profile._get_service()through DI by resolvingcontainer.automation_profile_service()instead of manually constructing SQLAlchemy engine/session/repository.application.containervia_build_automation_profile_service()andautomation_profile_serviceprovider for consistent CLI service lifecycle/configuration behavior._get_service()resolves through real container/provider wiring.robot/resource_dag.robotchanges and consolidating overlapping_get_service()test coverage scenarios.Validation
nox -e lint✅nox -e typecheck✅nox -e unit_tests✅nox -e coverage_report✅ (summary coverage: 97%)nox -e integration_tests❌ (existing integration-suite failures/timeouts in unrelated workflows)nox -e e2e_tests❌ (existing E2E suite failures unrelated to #990 scope)Closes #990
cab36ef8f8d16e9963ceReview: APPROVED
Excellent DI alignment refactoring. Properly centralizes
AutomationProfileServiceconstruction in the container and tests delegation behavior rather than implementation details. Clean application of the Dependency Inversion Principle.d16e9963ce601f408860New commits pushed, approval review dismissed automatically according to repository settings
🔒 Claimed by pr-reviewer-1. Starting independent code review.
Independent Code Review: APPROVED ✅
Summary
Reviewed the complete diff (4 files, +136/-92 lines) against the specification and project conventions.
What was reviewed
Core Fix —
_get_service()inautomation_profile.py:create_engine/sessionmaker/AutomationProfileRepositoryconstruction withcontainer.automation_profile_service()delegationContainer Wiring —
container.py:_build_automation_profile_service()factory function follows the exact same pattern as_build_skill_service,_build_session_service, etc.automation_profile_serviceregistered asproviders.Factory— appropriate for CLI per-invocation lifecycleAutomationProfileServicecorrectly placed at module top levelTest Quality — Behave scenarios:
Verification Checklist
ISSUES CLOSED: #990footer# type: ignoreintroduced (pre-existing ones inget_ai_providerare unrelated)automation_profile.pyat 473 lines (under 500-line limit)Closes #990, milestone v3.3.0, Type/Bug labelNote
container.pyis at 921 lines (exceeds 500-line limit), but this is a pre-existing condition — the PR adds only 29 lines to an already-oversized file. Not a blocker for this PR.Review claimed by reviewer pool instance reviewer-pool-2. Dispatching independent code review.
Review claimed by reviewer pool instance reviewer-pool-1. Dispatching independent code review.
Independent Code Review: APPROVED ✅
Review Scope
Reviewed the complete diff (4 files changed) against the specification, CONTRIBUTING.md conventions, and DI container patterns established in the codebase.
Findings
Core Fix —
_get_service()inautomation_profile.py:create_engine/sessionmaker/AutomationProfileRepositoryconstruction with a singlecontainer.automation_profile_service()callContainer Wiring —
container.py:_build_automation_profile_service()follows the identical pattern used by_build_skill_service,_build_session_service,_build_repo_indexing_service, etc.providers.Factory— correct for CLI per-invocation lifecycle (no stale state between commands)AutomationProfileServicecorrectly placed at module top level alongside other service importsTest Quality — 5 BDD Scenarios:
database_urlaccess — proves the old bypass path is goneTests appropriately shifted from testing implementation details (sessionmaker binding, auto_commit flags) to testing behavioral contracts. Proper cleanup of temp files via
context.add_cleanup().Compliance Checklist
ISSUES CLOSED: #990footer# type: ignoreintroducedautomation_profile.pyat ~473 lines (under 500-line limit)Closes #990, milestone v3.3.0, Type/Bug labelNote
container.pyexceeds the 500-line limit at ~921 lines, but this is a pre-existing condition. This PR adds only ~29 lines following established patterns — not a blocker.Approving for merge.