5 Commits

Author SHA1 Message Date
brent.edwards 29639558a3 fix(tests): resolve all failing CI checks on PR #3774
Fix 8 distinct integration test and E2E failures:

1. JSON envelope unwrapping in test helpers
   Helpers were asserting keys at the top-level of the JSON envelope
   ({command, status, exit_code, data, timing, messages}) rather than
   inside the nested 'data' field.  Updated helpers to access
   parsed['data'] for assertions on the actual response payload:
   - helper_cli_formats.py: action_list_json, action_show_yaml,
     plan_list_json, global_format_json_version, global_format_yaml_version,
     global_format_shorthand
   - helper_automation_profile_cli.py: test_show_json, test_list_json
   - helper_cli_extensions.py: action_show_json
   - helper_config_cli.py: config_set_get_roundtrip
   - helper_config_project_scope.py: cli_roundtrip

2. Plan list --namespace / -n option (issue #4301)
   Add 'namespace' parameter to lifecycle_list_plans() in plan.py,
   passing it through to service.list_plans(namespace=...) and
   displaying it in the Filters panel.

3. Config registry key count (issue #4304)
   Update expected count from 105 to 106 to match current registry
   (additional server key was added via the server stubs feature).

4. Container tool exec mock fix (issue #4243)
   The test mocked ev.resolve_and_validate (no longer called) instead
   of ev.resolve_with_precedence.  Fix the mock target so ToolRunner
   correctly routes to the container path and returns the expected
   error when no ContainerToolExecutor is configured.

5. E2E config CLI CLEVERAGENTS_HOME support
   config.py used a hardcoded Path.home() / '.cleveragents' for the
   config directory, ignoring CLEVERAGENTS_HOME.  E2E tests run in
   isolated temporary homes set via CLEVERAGENTS_HOME; this caused the
   WF07 CI Profile Configuration test to read from the global config
   (returning 'review') instead of the test-scoped config.  Make
   _get_config_dir() and _get_service() respect CLEVERAGENTS_HOME.

ISSUES CLOSED: #4204 #4205 #4206 #4243 #4301 #4302 #4303 #4304
2026-06-16 23:08:30 -04:00
freemo 7fb3fc76c8 fix(plan-lifecycle): add rollback_plan method to PlanLifecycleService
- What was implemented
  - Added PLAN_ROLLED_BACK event type to the EventType enum at src/cleveragents/infrastructure/events/types.py to properly represent successful rollbacks in the domain model.
  - Implemented rollback_plan(plan_id: str, checkpoint_id: str) -> RollbackResult in PlanLifecycleService (src/cleveragents/application/services/plan_lifecycle_service.py) with:
    - Plan state validation: rejects rollback when the plan is in terminal APPLIED or CANCELLED states.
    - Delegation to CheckpointService.selective_rollback() to perform the actual rollback logic and obtain a RollbackResult.
    - Emission of PLAN_ROLLED_BACK as a domain event to reflect the completed rollback.
    - checkpoint_service is accepted as an optional constructor parameter; if not provided, a PlanError is raised to preserve backward compatibility.
  - Updated CLI behavior in src/cleveragents/cli/commands/plan.py so agents plan rollback routes through PlanLifecycleService.rollback_plan() rather than calling CheckpointService.selective_rollback() directly.
  - Updated PlanLifecycleService module docstring to include rollback_plan in the documented API.
  - Added Behave feature file features/plan_lifecycle_rollback.feature with 11 scenarios covering state validation, domain events, and delegation.
  - Added step implementations in features/steps/plan_lifecycle_rollback_steps.py to support the new scenarios.

- Key design decisions
  - rollback_plan returns RollbackResult (the same result type produced by CheckpointService.selective_rollback) so the CLI can display rollback details consistently.
  - Terminal states APPLIED and CANCELLED are disallowed for rollback to prevent inconsistent or invalid state transitions.
  - checkpoint_service is optional in the PlanLifecycleService constructor; when omitted (None), a PlanError is raised to retain backward compatibility while signaling explicit dependency requirements.
  - CLI UI remains powered by CheckpointService for metadata enrichment (e.g., confirmation prompts), but the actual rollback action is performed via PlanLifecycleService to ensure proper domain workflow and event emission.

- Technical implications
  - All rollback logic now flows through the domain service layer (PlanLifecycleService) to preserve invariants and emit domain events, rather than allowing ad-hoc UI routes to bypass service validation.
  - The UI can still retrieve checkpoint metadata for user confirmation, but the operation that modifies state uses the new rollback_plan pathway.
  - Tests and behavior coverage were expanded via the new Behave feature and step implementations to validate state handling, events, and delegation.

- Affected modules/components
  - src/cleveragents/infrastructure/events/types.py
  - src/cleveragents/application/services/plan_lifecycle_service.py
  - src/cleveragents/cli/commands/plan.py
  - PlanLifecycleService module docstring
  - features/plan_lifecycle_rollback.feature
  - features/steps/plan_lifecycle_rollback_steps.py

ISSUES CLOSED: #3677
2026-06-03 03:22:59 -04:00
freemo eaf15dd17c fix(ci): restore all CI quality gates to passing on master
Apply remaining fixes not covered by the 4278ba91 commit:

1. src/cleveragents/cli/main.py:
   info and diagnostics commands now call configure_structlog(WARNING)
   before build_info_data()/build_diagnostics_data() when non-rich format
   is requested. This prevents debug-level structlog messages from
   corrupting --format json/yaml output in integration tests.

2. robot/helper_config_cli.py:
   Call configure_structlog(WARNING) before importing cleveragents CLI
   commands so plugin_manager debug messages don't pollute CliRunner
   captured output (fixes Config List JSON Format test).

3. features/steps/aimodelscredentials_steps.py:
   ModelProviderOption config checks now use getattr fallback so they
   work both when context.model_config is set (via explicit 'I examine
   the ModelProviderOption model_config' step) and when context.model_instance
   is set (via 'I create a ModelProviderOption with only priority set to N').

4. features/steps/plan_namespaced_name_tdd_steps.py:
   @when steps now set context.error and context.lsp_error in addition to
   context.exception so the existing @then steps from service_steps.py
   and lsp_registry_steps.py match and validate correctly.

No quality gates suppressed. All changes are to test and source files.

ISSUES CLOSED: #2597
2026-04-04 20:38:16 +00:00
freemo 7c4663b8ee feat(config): add config service with multi-level resolution
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 15s
CI / quality (pull_request) Successful in 18s
CI / build (pull_request) Successful in 19s
CI / typecheck (pull_request) Successful in 38s
CI / security (pull_request) Successful in 46s
CI / integration_tests (pull_request) Successful in 2m52s
CI / unit_tests (pull_request) Successful in 12m35s
CI / docker (pull_request) Successful in 38s
CI / benchmark-regression (pull_request) Successful in 20m57s
CI / coverage (pull_request) Successful in 47m23s
CI / lint (push) Successful in 12s
CI / build (push) Successful in 14s
CI / quality (push) Successful in 17s
CI / typecheck (push) Successful in 32s
CI / benchmark-regression (push) Has been skipped
CI / security (push) Successful in 40s
CI / integration_tests (push) Successful in 2m52s
CI / benchmark-publish (push) Successful in 12m29s
CI / unit_tests (push) Successful in 12m31s
CI / docker (push) Successful in 38s
CI / coverage (push) Successful in 47m17s
Implement the complete configuration system with multi-level resolution
chain, typed key registry, and CLI integration per specification.

ConfigService changes:
- Expand _build_catalog() to register all 102 spec-aligned config keys
  across 8 groups: core (14), server (4), actor (5), plan (8),
  sandbox (5), index (12), context (43), provider (11)
- Each key carries exact dotted-dash name, Python type, default value,
  explicit env var name per spec, project-scopability flag, and
  description
- Fix _env_name() to convert dots and dashes to underscores
- Provider keys use standard env var names (e.g., OPENAI_API_KEY)

CLI commands rewiring:
- Rewrite config set/get/list to use ConfigService instead of Settings
- Add --verbose flag to config get showing full 5-level resolution chain
- Add --project flag to config set/get/list for project-scoped overrides
- Support both glob and regex patterns in config list
- Validate keys against ConfigService registry with actionable errors
- Retain backward-compatible helper functions delegating to ConfigService

Documentation:
- Add docs/reference/config_resolution.md covering resolution chain,
  all 102 config keys, CLI commands, TOML format, and provider credentials

Testing:
- Update all 4 Behave feature files and step definitions to use new
  spec-aligned key names, env vars, and defaults (119 scenarios passing)
- Add robot/config_resolution.robot with 10 integration test cases
- Add benchmarks/config_resolution_bench.py with 8 time + 2 memory suites

ISSUES CLOSED: #258
2026-03-01 04:38:30 +00:00
brent.edwards 69a86858a7 feat(cli): add config get/set/list commands 2026-02-19 23:48:40 +00:00