fix(cli): add --execution-env-priority flag to plan use #972

Merged
hurui200320 merged 1 commits from feature/m3-plan-use-env-priority into master 2026-03-18 08:13:56 +00:00

1 Commits

Author SHA1 Message Date
hurui200320 a1e6c63f5d fix(cli): add --execution-env-priority flag to plan use
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 18s
CI / build (pull_request) Successful in 28s
CI / quality (pull_request) Successful in 29s
CI / security (pull_request) Successful in 41s
CI / typecheck (pull_request) Successful in 44s
CI / unit_tests (pull_request) Successful in 2m54s
CI / integration_tests (pull_request) Successful in 3m39s
CI / e2e_tests (pull_request) Successful in 3m47s
CI / docker (pull_request) Successful in 55s
CI / coverage (pull_request) Successful in 7m36s
CI / benchmark-regression (pull_request) Successful in 38m37s
Adds the missing --execution-env-priority flag to the agents plan use
command, aligning the CLI with the specification (spec line 12501).
The flag accepts fallback (default) or override and controls execution
environment routing precedence per ADR-043.

Domain model changes:
- Added ExecutionEnvPriority StrEnum with FALLBACK/OVERRIDE values.
- Changed execution_env_priority field type from str | None to
  ExecutionEnvPriority | None for Pydantic-level enum validation.
- Added model_validator enforcing that execution_env_priority requires
  execution_environment to be set (fail-fast domain invariant).
- Added execution_environment and execution_env_priority to
  Plan.as_cli_dict() for programmatic output paths.

CLI changes:
- Added --execution-env-priority Typer option to use_action command.
- Validation: priority requires --execution-environment, enum value
  check, case-insensitive input via .lower().
- Defaults to fallback when --execution-environment is set without
  explicit priority.
- Updated _print_lifecycle_plan and _plan_spec_dict to display priority
  using .value for consistent string output.

Persistence changes:
- Added execution_environment and execution_env_priority columns to
  LifecyclePlanModel (String(20), nullable).
- Updated from_domain()/to_domain() for round-trip serialization
  including ExecutionEnvPriority enum reconstruction.
- Updated LifecyclePlanRepository.update() to persist both fields.
- Added PlanLifecycleService.save_plan() public convenience method for
  callers that need to re-persist after post-creation mutations.
- CLI use_action calls service.save_plan(plan) after applying overrides
  so execution_env_priority survives across sessions.
- Added Alembic migration m4_003_plan_env_columns adding both columns
  to the v3_plans table.

Tests:
- 8 Behave scenarios covering valid values, defaults, validation errors,
  output display, JSON output, case-insensitive input, service
  invocation verification (use_action.assert_called_once), and
  persistence verification (save_plan.assert_called_once).
- 5 Robot Framework integration tests.
- Simplified Robot helper sys.path pattern to standard approach.

Changelog updated per CONTRIBUTING.md requirements.

ISSUES CLOSED: #886
2026-03-18 16:03:21 +08:00