feat(resource): implement 6-level execution environment precedence chain #877

Closed
opened 2026-03-13 22:59:30 +00:00 by freemo · 0 comments
Owner

Metadata

  • Commit Message: feat(resource): implement 6-level execution environment precedence chain
  • Branch: feature/m5-exec-env-precedence

Background and Context

The specification defines a 6-level execution environment precedence chain: (1) plan override, (2) project override, (3) nearest-ancestor devcontainer, (4) plan fallback, (5) project fallback, (6) host default. The current ExecutionEnvironmentResolver implements only a 4-level chain: tool_env > plan_env > project_env > host, with no distinction between override and fallback priority, and no nearest-ancestor devcontainer auto-discovery integration.

The spec also defines priority attribute on plan/project environments (override vs fallback) that determines whether the configured environment takes precedence over auto-discovered devcontainers or defers to them.

Expected Behavior

The resolver must support the full 6-level chain with:

  • priority=override: environment takes absolute precedence (levels 1-2)
  • priority=fallback: environment is used only when no auto-discovered devcontainer is found (levels 4-5)
  • Nearest-ancestor devcontainer: walks the resource DAG to find the closest devcontainer-instance (level 3)
  • ExecutionEnvironment enum expanded beyond HOST/CONTAINER to support specific container references

Acceptance Criteria

  • Resolver supports override and fallback priority modes
  • Plan override (priority=override) takes precedence over everything except tool_env
  • Project override (priority=override) takes precedence over auto-discovered devcontainers
  • Nearest-ancestor devcontainer is discovered by walking resource DAG ancestors
  • Plan fallback (priority=fallback) is used only when no devcontainer is auto-discovered
  • Project fallback (priority=fallback) defers to auto-discovered devcontainers
  • Host is the final default when no environment is configured

Subtasks

  • Add priority field (override/fallback) to plan and project environment config
  • Implement nearest-ancestor devcontainer resolution in ExecutionEnvironmentResolver
  • Wire auto-discovery from resource/handlers/discovery.py into resolver
  • Expand ExecutionEnvironment to support specific container references
  • Implement full 6-level precedence chain
  • Tests (Behave): Add scenarios for each precedence level and priority mode
  • Verify coverage >= 97% via nox -s coverage_report
  • Run nox (all default sessions), fix any errors

Definition of Done

This issue is complete when:

  • All subtasks above are completed and checked off.
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation.
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly.
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done.
## Metadata - **Commit Message**: `feat(resource): implement 6-level execution environment precedence chain` - **Branch**: `feature/m5-exec-env-precedence` ## Background and Context The specification defines a 6-level execution environment precedence chain: (1) plan override, (2) project override, (3) nearest-ancestor devcontainer, (4) plan fallback, (5) project fallback, (6) host default. The current `ExecutionEnvironmentResolver` implements only a 4-level chain: tool_env > plan_env > project_env > host, with no distinction between override and fallback priority, and no nearest-ancestor devcontainer auto-discovery integration. The spec also defines `priority` attribute on plan/project environments (`override` vs `fallback`) that determines whether the configured environment takes precedence over auto-discovered devcontainers or defers to them. ## Expected Behavior The resolver must support the full 6-level chain with: - `priority=override`: environment takes absolute precedence (levels 1-2) - `priority=fallback`: environment is used only when no auto-discovered devcontainer is found (levels 4-5) - Nearest-ancestor devcontainer: walks the resource DAG to find the closest devcontainer-instance (level 3) - `ExecutionEnvironment` enum expanded beyond HOST/CONTAINER to support specific container references ## Acceptance Criteria - [ ] Resolver supports `override` and `fallback` priority modes - [ ] Plan override (priority=override) takes precedence over everything except tool_env - [ ] Project override (priority=override) takes precedence over auto-discovered devcontainers - [ ] Nearest-ancestor devcontainer is discovered by walking resource DAG ancestors - [ ] Plan fallback (priority=fallback) is used only when no devcontainer is auto-discovered - [ ] Project fallback (priority=fallback) defers to auto-discovered devcontainers - [ ] Host is the final default when no environment is configured ## Subtasks - [ ] Add `priority` field (override/fallback) to plan and project environment config - [ ] Implement nearest-ancestor devcontainer resolution in `ExecutionEnvironmentResolver` - [ ] Wire auto-discovery from `resource/handlers/discovery.py` into resolver - [ ] Expand `ExecutionEnvironment` to support specific container references - [ ] Implement full 6-level precedence chain - [ ] Tests (Behave): Add scenarios for each precedence level and priority mode - [ ] Verify coverage >= 97% via `nox -s coverage_report` - [ ] Run `nox` (all default sessions), fix any errors ## Definition of Done This issue is complete when: - All subtasks above are completed and checked off. - A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation. - The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly. - The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done.
freemo added this to the v3.5.0 milestone 2026-03-13 22:59:59 +00:00
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#877
No description provided.