Files
cleveragents-core/robot/m3_e2e_verification.robot
brent.edwards 01b6eb1804 feat(autonomy): parallel execution scales to 10+ concurrent subplans (#1201)
## Summary

Add M6 parallel-scaling coverage for 10+ concurrent subplans:

- **15-subplan parallel scenario** with explicit peak-concurrency bound checks (`max_parallel=10`) and thread-safe concurrency tracking via `_build_executor()`.
- **Deep hierarchical decomposition** coverage (4+ levels) with adjusted leaf condition that only stops early when hitting `max_depth` or when the workset is trivially small (`min_files_per_subplan`).
- **Non-progress guard** in `_build_hierarchy` to prevent pathological recursion when clustering cannot meaningfully split the file set.
- **Small-project regression test** (< 50 files) verifying decomposition depth does not increase unexpectedly with the relaxed leaf condition.
- **ASV benchmark** for 15-subplan parallel execution with `max_parallel=10` to track scaling behavior.

### Removed from this PR

The `_build_hierarchy` child-linkage correctness fix (returning `node_id` from recursive calls instead of using `nodes[-1].node_id`) has been **removed** per review feedback — it is a separate bug fix and will be submitted as an independent issue/PR per CONTRIBUTING.md §Atomic Commits.

## Approach

- **Concurrency tracking:** The `_build_executor()` closure in step definitions detects `context.concurrency_counter` / `context.concurrency_lock` and performs thread-safe peak tracking in a try/finally block.
- **Leaf condition:** Replaced the `max_files_per_subplan` / `max_tokens_per_subplan` leaf check with a `min_files_per_subplan` check to allow deeper decomposition for large projects. Added a non-progress guard so clustering that cannot split the file set terminates immediately rather than recursing to `max_depth`.
- **Deterministic IDs:** `_ids_for_count()` preserves legacy fixed IDs for the first 5 subplans and generates additional deterministic IDs for scale scenarios.

## Validation

### Passing
- `nox -s lint` — all checks passed
- `nox -s typecheck` — 0 errors, 0 warnings
- `nox -s unit_tests` — 12,988 scenarios passed, 0 failed
- `nox -s coverage_report` — 97% (passes `--fail-under=97`)

Closes #855

Reviewed-on: cleveragents/cleveragents-core#1201
Co-authored-by: Brent E. Edwards <brent.edwards@cleverthis.com>
Co-committed-by: Brent E. Edwards <brent.edwards@cleverthis.com>
2026-03-31 23:57:39 +00:00

161 lines
8.4 KiB
Plaintext

*** Settings ***
Documentation End-to-end verification of M3 (v3.2.0) acceptance criteria:
... decision tree recording, context snapshots,
... decision tree persistence and rendering,
... invariant enforcement during strategize,
... dry-run correction via impact analysis,
... and live revert correction re-execution.
...
... This suite is the final gate before closing milestone v3.2.0.
... All acceptance criteria from the v3.2.0 milestone description
... must pass before the milestone can be closed.
Resource ${CURDIR}/common.resource
Suite Setup Setup Test Environment
Suite Teardown Cleanup Test Environment
Force Tags m3 acceptance_gate v3.2.0
*** Variables ***
${HELPER} ${CURDIR}/helper_m3_e2e_verification.py
*** Test Cases ***
Plan Execution Generates Decisions During Strategize
[Documentation] Execute ``agents plan use`` and ``agents plan execute``
... through the CLI command path, then verify decisions
... were recorded during Strategize before execution.
...
... Validates: plan use + plan execute generate decisions
... during Strategize phase.
[Tags] success_criteria decision_recording
${result}= Run Process ${PYTHON} ${HELPER} plan-generates-decisions cwd=${WORKSPACE} timeout=300s on_timeout=kill
Log ${result.stdout}
Log ${result.stderr}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} m3-plan-generates-decisions-ok
Decision Tree View Via Plan Tree
[Documentation] Invoke ``agents plan tree <plan_id>`` and validate
... nested JSON output for root/child/grandchild
... relationships from the rendered tree.
...
... Validates: plan tree displays the decision tree correctly.
[Tags] success_criteria decision_tree
${result}= Run Process ${PYTHON} ${HELPER} decision-tree-view cwd=${WORKSPACE} timeout=300s on_timeout=kill
Log ${result.stdout}
Log ${result.stderr}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} m3-decision-tree-view-ok
Decision Explain Shows Full Context
[Documentation] Invoke ``agents plan explain <decision_id>`` with
... ``--show-context`` and ``--show-reasoning`` and
... verify full decision context fields are present.
...
... Validates: plan explain shows full decision context.
[Tags] success_criteria decision_explain
${result}= Run Process ${PYTHON} ${HELPER} decision-explain cwd=${WORKSPACE} timeout=300s on_timeout=kill
Log ${result.stdout}
Log ${result.stderr}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} m3-decision-explain-ok
Invariant Add And List Via CLI And Service
[Documentation] Validate project-scoped invariant commands:
... ``agents invariant add --project local/large-project``
... and ``agents invariant list --project local/large-project``.
...
... Validates: invariant add and invariant list CLI commands.
[Tags] success_criteria invariant_management
${result}= Run Process ${PYTHON} ${HELPER} invariant-add-list cwd=${WORKSPACE} timeout=300s on_timeout=kill
Log ${result.stdout}
Log ${result.stderr}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} m3-invariant-add-list-ok
Correction Dry Run Via Plan Correct
[Documentation] Perform a dry-run correction and verify impact
... analysis output. Tests both the CorrectionService
... directly and the ``agents plan correct --dry-run``
... CLI command with mocked services.
...
... Validates: plan correct with --dry-run performs
... impact analysis without modifying state.
[Tags] success_criteria correction_dry_run
${result}= Run Process ${PYTHON} ${HELPER} correction-dry-run cwd=${WORKSPACE} timeout=300s on_timeout=kill
Log ${result.stdout}
Log ${result.stderr}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} m3-correction-dry-run-ok
Correction Live Revert Executes And Re-Creates Decisions
[Documentation] Execute ``agents plan correct --mode revert``
... through the CLI path (with ``--yes``) and verify
... reverted decisions and applied status in output.
...
... Validates: plan correct with --mode revert executes
... live correction.
[Tags] success_criteria correction_live_revert
${result}= Run Process ${PYTHON} ${HELPER} correction-live-revert cwd=${WORKSPACE} timeout=300s on_timeout=kill
Log ${result.stdout}
Log ${result.stderr}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} m3-correction-live-revert-ok
Decisions Recorded With Full Context Snapshot
[Documentation] Verify every decision in the tree has a complete
... context snapshot and that model_dump / model_validate
... round-trips preserve all snapshot fields.
...
... Technical criterion: decisions recorded during
... Strategize with full context snapshot.
[Tags] technical_criteria context_snapshot
${result}= Run Process ${PYTHON} ${HELPER} decisions-context-snapshot cwd=${WORKSPACE} timeout=300s on_timeout=kill
Log ${result.stdout}
Log ${result.stderr}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} m3-decisions-context-snapshot-ok
Decision Tree Persists To Database And Renders
[Documentation] Persist decisions through ``DecisionService`` with
... ``UnitOfWork`` backing, then verify round-trip
... retrieval and ``agents plan tree`` rendering.
...
... Technical criterion: decision tree persists to
... database and renders correctly.
[Tags] technical_criteria persistence
${result}= Run Process ${PYTHON} ${HELPER} decision-tree-persistence cwd=${WORKSPACE} timeout=300s on_timeout=kill
Log ${result.stdout}
Log ${result.stderr}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} m3-decision-tree-persistence-ok
Correction Revert Re-Executes From Decision Point
[Documentation] Verify that a revert correction invalidates the
... target subtree (child + grandchild) and allows
... new decisions to be spawned from the corrected
... point, forming a new valid subtree.
...
... Technical criterion: correction in revert mode
... re-executes from decision point.
[Tags] technical_criteria correction_reexecution
${result}= Run Process ${PYTHON} ${HELPER} correction-revert-reexecutes cwd=${WORKSPACE} timeout=300s on_timeout=kill
Log ${result.stdout}
Log ${result.stderr}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} m3-correction-revert-reexecutes-ok
Invariants Enforced During Strategize
[Documentation] Verify invariants at global, project, and plan
... scopes are merged with correct precedence,
... de-duplicated case-insensitively, and enforcement
... records are created with decision IDs. Also
... verifies InvariantSet.merge produces correct output.
...
... Technical criterion: invariants are enforced
... during strategize.
[Tags] technical_criteria invariant_enforcement
${result}= Run Process ${PYTHON} ${HELPER} invariants-enforced-strategize cwd=${WORKSPACE} timeout=300s on_timeout=kill
Log ${result.stdout}
Log ${result.stderr}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} m3-invariants-enforced-strategize-ok