feat(acms): implement context policy configuration loader and plan execution ACMS integration #9671

Merged
HAL9000 merged 17 commits from feat/v3.4.0/acms-context-policy into master 2026-06-18 03:33:25 +00:00

17 Commits

Author SHA1 Message Date
CleverAgents Bot 77146b147b test(e2e): fix llm key skip guard
CI / load-versions (pull_request) Successful in 18s
CI / push-validation (pull_request) Successful in 28s
CI / lint (pull_request) Successful in 43s
CI / build (pull_request) Successful in 43s
CI / helm (pull_request) Successful in 46s
CI / typecheck (pull_request) Successful in 1m15s
CI / quality (pull_request) Successful in 1m14s
CI / security (pull_request) Successful in 1m30s
CI / unit_tests (pull_request) Successful in 6m11s
CI / docker (pull_request) Successful in 1m56s
CI / integration_tests (pull_request) Successful in 11m29s
CI / coverage (pull_request) Successful in 9m51s
CI / status-check (pull_request) Successful in 3s
2026-06-17 23:15:50 -04:00
controller-ci-rerun 5605fb22da chore: re-trigger CI [controller] 2026-06-17 23:15:50 -04:00
controller-ci-rerun 4a9f63a3a3 chore: re-trigger CI [controller] 2026-06-17 23:15:50 -04:00
controller-ci-rerun 7d8a923938 chore: re-trigger CI [controller] 2026-06-17 23:15:50 -04:00
HAL9000 ebaff67eaf fix(acms): convert ContextPolicyConfig and ViewPolicyConfiguration to Pydantic BaseModel
The two dataclasses used @dataclass decorator without importing it from
dataclasses, causing a NameError on import. This also violated the
architecture invariant that requires all dataclasses to use Pydantic
BaseModel instead of @dataclass.

Replace @dataclass with BaseModel inheritance and field(default_factory=...)
with Field(default_factory=...) which was already imported from pydantic.
2026-06-17 23:15:50 -04:00
CleverAgents Bot 641a8ed67d test(acms): cover context policy edge cases 2026-06-17 23:15:50 -04:00
controller-ci-rerun 597b69c3c7 chore: re-trigger CI [controller] 2026-06-17 23:15:50 -04:00
controller-ci-rerun 5ad194424b chore: re-trigger CI [controller] 2026-06-17 23:15:50 -04:00
HAL9000 8280bd5ee2 fix(acms): resolve remaining AmbiguousStep conflicts, NameError bugs, and function name duplicates
Fix two critical issues identified by HAL9001 review #8271:

1. Rename literal step 'policy{1,2} has priority_weight' in loader
   steps to 'loader policy{1,2} has priority_weight' to disambiguate
   from parameterised 'policy(\d+) has priority_weight' in integration
   steps (fixes AmbiguousStep Conflicts 1 & 2 - root cause of CI failures).

2. Fix NameError: change undefined variable 'weight' to float(weight_str)
   in step_policy1_priority and step_policy2_priority functions.

3. Rename duplicate Python function names across step files to prevent
   namespace shadowing: step_check_view_name, step_have_multiple_policies,
   step_have_policy_config, step_policy_not_applied → suffixed with _loader
   or _integration.

ISSUES CLOSED: #9584
2026-06-17 23:15:50 -04:00
HAL9000 a8cfee5b37 fix(acms): resolve AmbiguousStep conflicts, format specifier errors, and duplicate step definitions
Convert all Behave {param:d/f/int} cucumber-expression format specifiers
to raw regex patterns (\d+, [\d.]+) compatible with behave 1.3.x parse
library. Remove duplicate @given/@then step definitions across both ACMS
step files that caused AmbiguousStep errors: budget_override and assembled
context budget assertions. Remove overlapping 'I prepare LLM context'
handlers that matched the same plain text feature steps. Restore missing
ContextPolicyConfig/ConfigurationLoader/PolicyScope/ViewPolicyConfiguration
imports in acms/__init__.py.

ISSUES CLOSED: #9584
2026-06-17 23:15:50 -04:00
HAL9000 9a9214dcf1 fix(acms): resolve AmbiguousStep regression, lint violations, and type safety issues
Resolve blocking issues identified in final review (ID 7998) for PR #9671:

1. AmbiguousStep fix: Renamed duplicate step '@then("the policy should not be applied")'
   to '@then("the policy should not be applied to the LLM context")' in
   acms_plan_execution_integration_steps.py and updated corresponding scenario in
   features/acms_plan_execution_integration.feature

2. lint fix (SIM102): Combined nested if statements into single compound condition in
   step_set_policy_priority() to remove ruff SIM102 violation

3. Type safety fix: Changed 'policy: Any' to 'policy: ContextPolicyConfig' in
   ACMSContextAssembler._apply_policy() for proper Pyright type safety, added
   ContextPolicyConfig to module imports

This resolves the unit_tests CI failure caused by AmbiguousStep and fixes
the lint CI failure introduced by commit 3457fc61.

ISSUES CLOSED: #9584
2026-06-17 23:15:50 -04:00
HAL9000 24a3f6ff45 fix(acms): add missing BDD step definitions for priority, budget, and scope scenarios
The Plan Execution ACMS Integration feature file was missing step
definitions for three key test scenarios: priority weight configuration,
budget override enforcement, and negative-scope policy rejection. Added:
- 'policy{count} has priority_weight {weight}' step
- 'the policy has budget_override {amount}' step
- generic 'I prepare LLM context' catch-all step

Also added explicit Then assertions for budget verification, scope
mismatch rejection, and negative context checks.

ISSUES CLOSED: #9584
2026-06-17 23:15:50 -04:00
HAL9000 18280df28c fix(acms): move StrategyDecision import to module level in integration steps
Remove import inside function body in acms_plan_execution_integration_steps.py
which violated the project rule against imports inside functions. Move
StrategyDecision import to the top-level import block.

ISSUES CLOSED: #9584
2026-06-17 23:15:50 -04:00
HAL9000 7ab95a8641 fix(acms): wire PlanExecutionACMSIntegration into plan execution engine
Wire PlanExecutionACMSIntegration into PlanExecutor and RuntimeExecuteActor
via dependency injection. PlanExecutor now accepts an optional acms_integration
parameter and passes it to RuntimeExecuteActor, which uses it to assemble
context via ACMS policies before LLM calls instead of passing raw file dumps.

Added BDD tests verifying the DI wiring and context assembly integration.
Updated CHANGELOG to document the plan execution engine integration.

ISSUES CLOSED: #9584
2026-06-17 23:15:50 -04:00
HAL9000 e023366858 style(acms): apply ruff format to fix CI lint format check failure
The CI lint job runs both ruff check and ruff format --check. The format
check was failing because 5 files had formatting inconsistencies. Applied
ruff format to fix the CI lint failure.

ISSUES CLOSED: #9584
2026-06-17 23:15:50 -04:00
HAL9000 7faab96582 fix(acms): resolve all reviewer feedback for context policy loader and plan execution integration
Fixed all blocking issues identified in 4 REQUEST_CHANGES reviews:

- Removed broken ContextPolicy import (root cause of all CI failures)
- Fixed all ruff lint violations: deprecated typing aliases, format parameter shadowing built-in, unused imports, imports inside functions, SIM115/SIM102
- Fixed Behave step ambiguity and duplicate step definitions across files
- Fixed context.config collision with Behave's internal config attribute
- Added CHANGELOG entry for the new ACMS context policy feature
- Added CONTRIBUTORS.md entry for HAL9000
- Added performance benchmark file: benchmarks/acms_context_policy_bench.py
- Fixed pre-existing lint errors in scripts/validate_automation_tracking.py
- Wired PlanExecutionACMSIntegration documentation to explain integration point

ISSUES CLOSED: #9584
2026-06-17 23:15:50 -04:00
HAL9000 8a5567f5d8 feat(acms): implement context policy configuration loader and plan execution ACMS integration
Implemented a new context policy configuration loader and integrated plan execution context assembly for ACMS. Key additions include:

- New module: src/cleveragents/acms/context_policy_loader.py
  - ContextPolicyConfigurationLoader class for loading YAML/TOML configurations
  - Data models: PolicyScope and ContextPolicyConfig dataclasses
  - ViewPolicyConfiguration for per-view policy management
  - Schema validation to ensure policy configurations adhere to expected structure and constraints
  - Supports loading configurations from both files and strings, with robust error reporting

- New module: src/cleveragents/acms/plan_execution_integration.py
  - ACMSContextAssembler for assembling runtime context based on policy-driven decisions
  - PlanExecutionACMSIntegration to connect with the plan execution engine
  - Flexible policy loading from files or strings, allowing runtime configurability

- BDD tests
  - features/acms_context_policy_loader.feature (20 scenarios) validating loader behavior and policy scoping
  - features/acms_plan_execution_integration.feature (8 scenarios) validating end-to-end plan-context integration
  - features/steps/acms_context_policy_loader_steps.py (step definitions)
  - features/steps/acms_plan_execution_integration_steps.py (step definitions)
  - Tests cover YAML/TOML parsing, validation errors, per-view policy application, and plan integration flows

- Updated exports
  - Updated src/cleveragents/acms/__init__.py to export the two new modules, enabling easier imports and usage

ISSUES CLOSED: #9584
2026-06-17 23:15:50 -04:00