UAT: require_approval_for_apply guard never triggered by PlanApplyService — apply phase bypasses automation guard #5624

Open
opened 2026-04-09 07:57:12 +00:00 by HAL9000 · 0 comments
Owner

Summary

The AutomationGuard.require_approval_for_apply flag is designed to require human approval before the apply phase. However, PlanApplyService.apply_with_validation_gate() never calls AutomationProfile.check_guard("__apply__", ...) before proceeding with apply. The guard is completely bypassed.

What Was Tested

Code-level analysis of:

  • src/cleveragents/application/services/plan_apply_service.pyapply_with_validation_gate() method
  • src/cleveragents/domain/models/core/automation_profile.pycheck_guard() method (line 347)

Expected Behavior (from spec §"Automation Guard Sub-Model")

require_approval_for_apply | boolean | false | Require human approval before the apply phase.

When require_approval_for_apply: true is set in an automation profile's guards, the apply phase must pause and request human approval before committing changes to real resources.

Actual Behavior

PlanApplyService.apply_with_validation_gate() proceeds directly to apply without consulting the automation profile's guard:

# src/cleveragents/application/services/plan_apply_service.py
def apply_with_validation_gate(self, plan_id, ...):
    # Checks: terminal state, empty changeset, validation gate
    # MISSING: check_guard("__apply__", ...) call
    # Proceeds directly to apply without checking require_approval_for_apply
    self._lifecycle.complete_apply(plan_id, ...)

The check_guard() implementation correctly handles the "__apply__" sentinel:

# automation_profile.py line 347
if guards.require_approval_for_apply and tool_name == "__apply__":
    return GuardResult(allowed=False, requires_approval=True, ...)

But PlanApplyService never calls check_guard("__apply__", ...).

Impact

  • Plans configured with require_approval_for_apply: true will apply automatically without pausing for human approval
  • This is a security bypass: users who configure their automation profile to require apply approval get no such protection
  • The full-auto profile's safety model is undermined — even profiles that should require apply approval don't

Code Location

  • Guard definition: src/cleveragents/domain/models/core/automation_guard.py:145
  • Guard check: src/cleveragents/domain/models/core/automation_profile.py:347
  • Missing integration: src/cleveragents/application/services/plan_apply_service.py:apply_with_validation_gate()

Fix Required

PlanApplyService.apply_with_validation_gate() must:

  1. Accept the resolved AutomationProfile as a parameter
  2. Call profile.check_guard("__apply__", is_write=False, ...) before proceeding
  3. If GuardResult.allowed == False and requires_approval == True, pause and request human approval instead of applying

Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: uat-tester

## Summary The `AutomationGuard.require_approval_for_apply` flag is designed to require human approval before the apply phase. However, `PlanApplyService.apply_with_validation_gate()` never calls `AutomationProfile.check_guard("__apply__", ...)` before proceeding with apply. The guard is completely bypassed. ## What Was Tested Code-level analysis of: - `src/cleveragents/application/services/plan_apply_service.py` — `apply_with_validation_gate()` method - `src/cleveragents/domain/models/core/automation_profile.py` — `check_guard()` method (line 347) ## Expected Behavior (from spec §"Automation Guard Sub-Model") > `require_approval_for_apply` | boolean | `false` | Require human approval before the apply phase. When `require_approval_for_apply: true` is set in an automation profile's guards, the apply phase must pause and request human approval before committing changes to real resources. ## Actual Behavior `PlanApplyService.apply_with_validation_gate()` proceeds directly to apply without consulting the automation profile's guard: ```python # src/cleveragents/application/services/plan_apply_service.py def apply_with_validation_gate(self, plan_id, ...): # Checks: terminal state, empty changeset, validation gate # MISSING: check_guard("__apply__", ...) call # Proceeds directly to apply without checking require_approval_for_apply self._lifecycle.complete_apply(plan_id, ...) ``` The `check_guard()` implementation correctly handles the `"__apply__"` sentinel: ```python # automation_profile.py line 347 if guards.require_approval_for_apply and tool_name == "__apply__": return GuardResult(allowed=False, requires_approval=True, ...) ``` But `PlanApplyService` never calls `check_guard("__apply__", ...)`. ## Impact - Plans configured with `require_approval_for_apply: true` will apply automatically without pausing for human approval - This is a security bypass: users who configure their automation profile to require apply approval get no such protection - The `full-auto` profile's safety model is undermined — even profiles that should require apply approval don't ## Code Location - Guard definition: `src/cleveragents/domain/models/core/automation_guard.py:145` - Guard check: `src/cleveragents/domain/models/core/automation_profile.py:347` - Missing integration: `src/cleveragents/application/services/plan_apply_service.py:apply_with_validation_gate()` ## Fix Required `PlanApplyService.apply_with_validation_gate()` must: 1. Accept the resolved `AutomationProfile` as a parameter 2. Call `profile.check_guard("__apply__", is_write=False, ...)` before proceeding 3. If `GuardResult.allowed == False` and `requires_approval == True`, pause and request human approval instead of applying --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: uat-tester
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#5624
No description provided.