Files
cleveragents-core/features/plan_executor_coverage_boost.feature
T
hamza.khyari 29b62587f9
CI / helm (pull_request) Successful in 23s
CI / build (pull_request) Successful in 25s
CI / lint (pull_request) Successful in 3m18s
CI / quality (pull_request) Successful in 3m40s
CI / typecheck (pull_request) Successful in 3m57s
CI / security (pull_request) Successful in 4m5s
CI / unit_tests (pull_request) Successful in 9m37s
CI / docker (pull_request) Successful in 1m32s
CI / coverage (pull_request) Successful in 12m36s
CI / integration_tests (pull_request) Successful in 24m32s
CI / e2e_tests (pull_request) Failing after 10m11s
CI / status-check (pull_request) Failing after 1s
CI / benchmark-publish (pull_request) Has been skipped
CI / benchmark-regression (pull_request) Successful in 55m58s
feat(resource): add virtual resource equivalence tracking
Virtual-to-physical resource equivalence linking system for tracking
which physical resources are manifestations of the same virtual identity.

Database:
- VirtualResourceLinkModel ORM with ULID PK, FK cascades, unique
  constraint on (virtual_resource_id, physical_resource_id), CHECK
  constraints on link_type and confidence, 4 indexes
- Alembic migration: m7_001_virtual_resource_links.py (depends on
  m8_002_merge_profile_rename_and_corrections)

Domain model:
- LinkType enum (content_hash, name, identity)
- VirtualResourceLink frozen Pydantic model with confidence [0.0-1.0]

Service (ResourceEquivalenceService — 498 lines):
- create_link() with type-mismatch guard via ALLOWED_PAIRINGS
- remove_link() by virtual+physical ID pair
- list_links() with pagination (limit/offset)
- merge_virtual_resources() — batch N+1-free with IntegrityError guard
- check_divergence() — removes stale content_hash links
- reconcile() — delegated to _resource_equivalence_reconciler.py

Helpers (_resource_equivalence_helpers.py — 228 lines):
- compute_equivalence_key() for string content (SHA-256/name/identity)
- compute_equivalence_key_from_path() streaming file hash (64 KiB chunks)
- ALLOWED_PAIRINGS type compatibility map (unprefixed virtual type names)
- validate_link_inputs() shared validation

CLI (resource_equivalence.py):
- agents resource equivalence list (--virtual, --physical, --format)
- agents resource equivalence add (--key, --type, --confidence, --format)
- agents resource equivalence remove (--yes, --format)

Tests:
- 50 Behave scenarios (CRUD, merge, divergence, reconciliation, boundaries)
- 9 Robot integration tests
- 5 ASV benchmark suites

ISSUES CLOSED: #334
2026-04-02 13:08:54 +00:00

64 lines
2.9 KiB
Gherkin

Feature: PlanExecutor Coverage Boost
Additional scenarios that exercise previously uncovered code paths
in plan_executor.py, targeting lines 328-335, 384, 422, 458,
598-599, 612, and 619.
Background:
Given the plan executor module is imported
# --- _try_emit_metric success path (lines 328-330) ---
Scenario: _try_emit_metric emits a metric when emitter is configured
Given a PlanExecutor with a mock metrics emitter
When I trigger metric emission with a valid key and value
Then the metrics emitter should have received exactly one entry
# --- _try_emit_metric exception path (lines 331-335) ---
Scenario: _try_emit_metric silently handles emission failure
Given a PlanExecutor with a failing metrics emitter
When I trigger metric emission that causes an exception
Then no exception should propagate from metric emission
# --- _try_create_checkpoint returns None when sandbox is None (line 384) ---
Scenario: _try_create_checkpoint returns None when no sandbox is resolvable
Given a PlanExecutor with a checkpoint manager but no sandbox source
When I attempt to create a plan executor checkpoint
Then the checkpoint result should be None
# --- _try_rollback_to_last_checkpoint returns False when sandbox is None (line 422) ---
Scenario: _try_rollback_to_last_checkpoint returns False when no sandbox is resolvable
Given a PlanExecutor with a checkpoint manager but no sandbox source
When I attempt to rollback to the last checkpoint
Then the rollback result should be False for executor
# --- _resolve_sandbox_for_checkpoint via execution_context (line 458) ---
Scenario: _resolve_sandbox_for_checkpoint returns sandbox from execution context
Given a PlanExecutor with an execution context that has a sandbox manager
When I resolve a sandbox for checkpointing
Then the resolved sandbox should come from the execution context
# --- _enforce_guardrails raises PlanError on step limit (lines 598-599) ---
Scenario: _enforce_guardrails raises PlanError when step limit is already reached
Given a PlanExecutor with a guardrail service that blocks step limit
When I enforce guardrails for a plan
Then a PlanError about step limit should be raised
# --- _enforce_guardrails_per_step returns when guardrails is None (line 612) ---
Scenario: _enforce_guardrails_per_step returns early when guardrails is None
Given a PlanExecutor with a guardrail service that returns no guardrails
When I enforce per-step guardrails
Then no exception should be raised from per-step enforcement
# --- _enforce_guardrails_per_step raises PlanError on wall-clock (line 619) ---
Scenario: _enforce_guardrails_per_step raises PlanError when wall-clock exceeded
Given a PlanExecutor with a guardrail service that blocks wall-clock per step
When I enforce per-step guardrails expecting wall-clock error
Then a PlanError about wall-clock limit should be raised from per-step