BUG-HUNT: [business-rules] AutomationProfileService precedence hierarchy broken in get_effective_profile #7066

Open
opened 2026-04-10 07:28:20 +00:00 by HAL9000 · 1 comment
Owner

Bug Report: [Business Rules] — Broken automation profile precedence hierarchy

Severity Assessment

  • Impact: Automation profile resolution skips project level, breaking documented plan > action > project > global precedence
  • Likelihood: Medium - affects callers using get_effective_profile() instead of resolve_profile()
  • Priority: High

Location

  • File: src/cleveragents/application/services/automation_profile_service.py
  • Function/Class: AutomationProfileService.get_effective_profile()
  • Lines: ~180-200

Description

The get_effective_profile() method has misleading parameter names and incorrect precedence mapping. The parameter default_profile is mapped to project_profile internally, which breaks the documented four-level precedence hierarchy.

Evidence

def get_effective_profile(
    self,
    plan_profile: str | None = None,
    action_profile: str | None = None,
    default_profile: str | None = None,  # MISLEADING NAME
) -> AutomationProfile:
    return self.resolve_profile(
        plan_profile=plan_profile,
        action_profile=action_profile,
        project_profile=default_profile,  # MAPPED TO WRONG LEVEL
    )

Expected Behavior

The method should either:

  1. Correctly implement 3-level precedence as the name suggests (plan > action > default)
  2. Or implement full 4-level precedence with proper parameter names

The specification clearly states the precedence is: plan > action > project > global

Actual Behavior

The method maps "default_profile" parameter to the project level in the precedence chain, skipping the actual project level entirely. This causes incorrect profile resolution for callers expecting three-level precedence.

Suggested Fix

Either rename the parameter to project_profile or add a separate project_profile parameter and map default_profile to the global level fallback.

Category

business-rules

TDD Note

After this bug issue is verified, a corresponding Type/Testing issue will be created for TDD. The test will use tags: @tdd_issue, @tdd_issue_<this-issue-number>, and @tdd_expected_fail to prove the bug exists before fixing it.

  • See also: #3130 — earlier UAT report of the same underlying parameter mis-mapping (different framing; this issue adds the BUG-HUNT categorisation and TDD workflow note)

Backlog note: This issue was discovered during autonomous operation
on milestone v3.5.0. It does not block milestone completion and has been
placed in the backlog for human review and future milestone assignment.


Metadata

  • Branch: fix/business-rules-automation-profile-get-effective-profile-precedence
  • Commit Message: fix(business-rules): correct default_profile parameter mapping in AutomationProfileService.get_effective_profile()
  • Milestone: (none — backlog)
  • Parent Epic: #4951

Subtasks

  • Audit AutomationProfileService.get_effective_profile() (~lines 180-200) and confirm the default_profileproject_profile mis-mapping
  • Determine correct fix: rename parameter to project_profile OR remap default_profile to global_profile in the resolve_profile() call
  • Apply the fix in src/cleveragents/application/services/automation_profile_service.py
  • Add/update BDD scenario in the relevant .feature file covering the corrected 4-level precedence (plan > action > project > global)
  • Implement corresponding step definitions
  • Run nox -e unit_tests — confirm all Behave scenarios pass
  • Run nox -e typecheck — confirm Pyright reports no errors
  • Run nox -e coverage_report — confirm coverage ≥ 97%
  • Run nox (all default sessions) — confirm all quality gates pass

Definition of Done

  • get_effective_profile() correctly maps its parameters to the right precedence tiers in resolve_profile()
  • BDD scenario added proving plan > action > project > global precedence via get_effective_profile()
  • All nox stages pass
  • Coverage >= 97%

Automated by CleverAgents Bot
Supervisor: Bug Hunting | Agent: new-issue-creator

## Bug Report: [Business Rules] — Broken automation profile precedence hierarchy ### Severity Assessment - **Impact**: Automation profile resolution skips project level, breaking documented plan > action > project > global precedence - **Likelihood**: Medium - affects callers using get_effective_profile() instead of resolve_profile() - **Priority**: High ### Location - **File**: `src/cleveragents/application/services/automation_profile_service.py` - **Function/Class**: `AutomationProfileService.get_effective_profile()` - **Lines**: ~180-200 ### Description The `get_effective_profile()` method has misleading parameter names and incorrect precedence mapping. The parameter `default_profile` is mapped to `project_profile` internally, which breaks the documented four-level precedence hierarchy. ### Evidence ```python def get_effective_profile( self, plan_profile: str | None = None, action_profile: str | None = None, default_profile: str | None = None, # MISLEADING NAME ) -> AutomationProfile: return self.resolve_profile( plan_profile=plan_profile, action_profile=action_profile, project_profile=default_profile, # MAPPED TO WRONG LEVEL ) ``` ### Expected Behavior The method should either: 1. Correctly implement 3-level precedence as the name suggests (plan > action > default) 2. Or implement full 4-level precedence with proper parameter names The specification clearly states the precedence is: plan > action > project > global ### Actual Behavior The method maps "default_profile" parameter to the project level in the precedence chain, skipping the actual project level entirely. This causes incorrect profile resolution for callers expecting three-level precedence. ### Suggested Fix Either rename the parameter to `project_profile` or add a separate `project_profile` parameter and map `default_profile` to the global level fallback. ### Category business-rules ### TDD Note After this bug issue is verified, a corresponding Type/Testing issue will be created for TDD. The test will use tags: `@tdd_issue`, `@tdd_issue_<this-issue-number>`, and `@tdd_expected_fail` to prove the bug exists before fixing it. ### Related Issues - **See also**: #3130 — earlier UAT report of the same underlying parameter mis-mapping (different framing; this issue adds the BUG-HUNT categorisation and TDD workflow note) > **Backlog note:** This issue was discovered during autonomous operation > on milestone v3.5.0. It does not block milestone completion and has been > placed in the backlog for human review and future milestone assignment. --- ## Metadata - **Branch**: `fix/business-rules-automation-profile-get-effective-profile-precedence` - **Commit Message**: `fix(business-rules): correct default_profile parameter mapping in AutomationProfileService.get_effective_profile()` - **Milestone**: *(none — backlog)* - **Parent Epic**: #4951 --- ## Subtasks - [ ] Audit `AutomationProfileService.get_effective_profile()` (~lines 180-200) and confirm the `default_profile` → `project_profile` mis-mapping - [ ] Determine correct fix: rename parameter to `project_profile` OR remap `default_profile` to `global_profile` in the `resolve_profile()` call - [ ] Apply the fix in `src/cleveragents/application/services/automation_profile_service.py` - [ ] Add/update BDD scenario in the relevant `.feature` file covering the corrected 4-level precedence (plan > action > project > global) - [ ] Implement corresponding step definitions - [ ] Run `nox -e unit_tests` — confirm all Behave scenarios pass - [ ] Run `nox -e typecheck` — confirm Pyright reports no errors - [ ] Run `nox -e coverage_report` — confirm coverage ≥ 97% - [ ] Run `nox` (all default sessions) — confirm all quality gates pass --- ## Definition of Done - [ ] `get_effective_profile()` correctly maps its parameters to the right precedence tiers in `resolve_profile()` - [ ] BDD scenario added proving plan > action > project > global precedence via `get_effective_profile()` - [ ] All nox stages pass - [ ] Coverage >= 97% --- **Automated by CleverAgents Bot** Supervisor: Bug Hunting | Agent: new-issue-creator
Author
Owner

Verified — Critical business rule bug: AutomationProfileService precedence hierarchy broken. MoSCoW: Must-have. Priority: High — automation profile resolution is a core v3.5.0 deliverable.


Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: project-owner-pool-supervisor

✅ **Verified** — Critical business rule bug: AutomationProfileService precedence hierarchy broken. MoSCoW: Must-have. Priority: High — automation profile resolution is a core v3.5.0 deliverable. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner-pool-supervisor
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.

Reference
cleveragents/cleveragents-core#7066
No description provided.