test(e2e): workflow example 3 — multi-file refactoring with invariants (cautious profile) #800

Closed
freemo wants to merge 1 commits from test/e2e-wf03-refactoring into master
Owner

Summary

E2E test for Workflow Example 3 — multi-file refactoring with invariants using the cautious profile. Tests invariant management at three scopes (global, project, action), custom actor registration, plan tree inspection, plan explain, plan correct (revert mode), plan prompt, and the full lifecycle.

Consolidates Extract Plan Id keyword into common_e2e.resource as a shared keyword with safe Get Regexp Matches approach (Crockford Base32 charset, case-insensitive, positional group argument), eliminating duplication in m1_acceptance.robot.

Fixes pre-existing integration test failure in core_cli_commands.robot (Test Project Status Without Project) where CLI auto-init behavior changed.

Closes #749

ISSUES CLOSED: #749

Changes

robot/e2e/wf03_refactoring.robot (new)

  • Graceful skip via Skip If No LLM Keys when API keys absent
  • Dynamic provider selection — picks Anthropic or OpenAI based on available keys; uses modules=os for env access
  • Test timeout[Timeout] 30 minutes safety net on the test case
  • Timeout variables${LLM_TIMEOUT} (300s) and ${TREE_TIMEOUT} (120s) extracted from inline magic numbers
  • Custom actor registration (AC3) — creates and registers actor config via actor add using json.dumps for safe JSON construction; verifies actor name in output; confirms registration via actor list assertion
  • Multi-scope invariants (AC2) — global, project-level, and all three action-level invariants from spec WF03; invariant text aligned with spec examples
  • Invariant enforcement assertion (AC2) — best-effort check for invariant-related keywords in strategize output via Run Keyword And Warn On Failure
  • Estimation actor — included in action YAML per spec WF03
  • Cautious profile verification — verifies cautious appears in plan use output (AC4)
  • Spec WF03 Step 3 ordering — follows spec flow: tree → explain → prompt → status. Step 4: correct → tree --show-superseded → execute → diff → apply
  • Plan tree (spec WF03 Step 3) — inspects decision tree with explicit failure handling (rc != 0 → Fail)
  • Plan explain with plan_id (AC5, partial) — exercises plan-level explanation with explicit failure handling; includes TODO(#1057) for full decision-level coverage
  • Plan prompt (AC7) — exercises user guidance with --format plain; gracefully handles unimplemented command (rc != 0 → WARN); Traceback check only on success path; INTERNAL expected for unrecognized subcommands
  • Plan status (AC4) — placed after prompt per spec ordering; verifies plan_id in status output; known AC4 verification gap documented (LLM non-determinism prevents reliable pause assertion)
  • Plan correct --mode revert with plan_id (AC6, partial) — exercises correction flow with explicit failure handling; validates revert semantics in output via Run Keyword And Warn On Failure (soft-checked — CLI does not echo correction mode as fixed string); includes TODO(#1055) for full decision-level coverage
  • Plan tree --show-superseded — exercises post-correction tree view per spec WF03 Step 4
  • Post-correction execute — continues execution with explicit failure handling
  • Plan diff (AC8) — with content assertion checking for refactoring-related content via Run Keyword And Warn On Failure; explicit ELSE branch that fails on non-zero rc; includes TODO(#749) for plan diff --correction <CORRECTION_ID> variant
  • Plan lifecycle-apply — documented that lifecycle-apply does not support --yes; explicit rc check and non-empty output assertion; includes TODO(#749) for alignment with spec's plan apply --yes
  • Post-apply repository verification (AC8) — git log -1 --oneline check on target repo verifies actual file changes were committed
  • Invariant list — with --format plain; warning-level log on non-zero rc; explicit note documenting expected empty results due to in-memory persistence
  • Final status check — soft assertion for terminal state (applied/completed)
  • Return-code check for git rev-parse (was missing)
  • Consistent DEBUG-level logging — all command output logs use level=DEBUG; Plan ID announcement uses explicit level=INFO
  • Git operation safety — all Run Process git calls include timeout=60s on_timeout=kill
  • Explicit failure handling — plan tree, plan explain, plan correct, post-correction execute, plan diff, plan lifecycle-apply all fail the test on non-zero rc

robot/e2e/common_e2e.resource

  • Fixed Extract Plan Id Strategy 3 runtime crash: changed group=1 named argument to positional 1 — Robot Framework's Get Regexp Matches accepts groups only as positional *groups args
  • Fixed Strategy 3 regex: replaced (\S+) with ([0-9A-Za-z_-]+) to avoid capturing trailing punctuation (Crockford Base32 + UUID charset)
  • Fixed UUID regex: added \b word-boundary anchors for consistency with ULID regex strategy

robot/e2e/m1_acceptance.robot

  • Removed local Extract Plan Id — now uses shared keyword from common_e2e.resource
  • Updated Extract Plan Id call to pass both stdout and stderr for consistency with WF03

robot/core_cli_commands.robot

  • Fixed Test Project Status Without Project: updated to match current CLI auto-init behavior (rc=0, stdout contains "Project Status") — was failing on master

CHANGELOG.md

  • Updated WF03 entry to reflect all scopes (global, project, action), custom actor registration, plan tree, and graceful skip

Known Limitations / Deferred Items

  • strategy_actor cannot reference custom actor name: The spec WF03 Step 2 shows strategy_actor: local/refactoring-strategist but the runtime resolves strategy_actor as a provider/model pair — local/wf03-strategist yields "Unknown provider type: local". Uses provider/model directly; custom actor registration is still exercised and verified via actor list.
  • ActionConfigSchema does not support args: Spec shows args: section with target_module parameter but ActionConfigSchema rejects it (extra_forbidden). Args section omitted; --arg on CLI also not used since no declared args exist.
  • Partial AC5 coverage: plan explain uses plan_id (plan-level) instead of spec-required decision_id (decision-level). Tracked via TODO(#1057).
  • Partial AC6 coverage: plan correct uses plan_id instead of spec-required decision_id. Tracked via TODO(#1055).
  • Missing plan diff --correction: Spec WF03 Step 4 shows correction-specific diff; not exercised because correction_id extraction is not yet reliable. Tracked via TODO(#749).
  • plan prompt not implemented: Command returns "No such command 'prompt'" — handled gracefully with WARN log.
  • lifecycle-apply vs spec's plan apply --yes: v3 uses lifecycle-apply (no confirmation prompt) rather than plan apply --yes shown in spec. Tracked via TODO(#749).
  • LLM non-determinism: Several assertions use Run Keyword And Warn On Failure instead of hard assertions because LLM output is non-deterministic.
  • Known AC4 verification gap: Cautious profile pause verification is soft-checked only due to LLM non-determinism.
  • Invariant list expected empty: invariant list --effective returns empty results because InvariantService is in-memory only; previously-added invariants are not retained across CLI invocations.

Manual Verification

Prerequisites

  • OPENAI_API_KEY or ANTHROPIC_API_KEY environment variable set

Commands

nox -s e2e_tests

What to Look For

  • WF03 test passes with real LLM keys
  • WF03 test skips gracefully without keys
  • M1 test still passes (uses shared Extract Plan Id with both stdout and stderr)
  • No Traceback or INTERNAL in any command output
## Summary E2E test for Workflow Example 3 — multi-file refactoring with invariants using the cautious profile. Tests invariant management at three scopes (global, project, action), custom actor registration, plan tree inspection, plan explain, plan correct (revert mode), plan prompt, and the full lifecycle. Consolidates `Extract Plan Id` keyword into `common_e2e.resource` as a shared keyword with safe `Get Regexp Matches` approach (Crockford Base32 charset, case-insensitive, positional group argument), eliminating duplication in `m1_acceptance.robot`. Fixes pre-existing integration test failure in `core_cli_commands.robot` (`Test Project Status Without Project`) where CLI auto-init behavior changed. Closes #749 ISSUES CLOSED: #749 ## Changes ### `robot/e2e/wf03_refactoring.robot` (new) - **Graceful skip** via `Skip If No LLM Keys` when API keys absent - **Dynamic provider selection** — picks Anthropic or OpenAI based on available keys; uses `modules=os` for env access - **Test timeout** — `[Timeout] 30 minutes` safety net on the test case - **Timeout variables** — `${LLM_TIMEOUT}` (300s) and `${TREE_TIMEOUT}` (120s) extracted from inline magic numbers - **Custom actor registration** (AC3) — creates and registers actor config via `actor add` using `json.dumps` for safe JSON construction; verifies actor name in output; confirms registration via `actor list` assertion - **Multi-scope invariants** (AC2) — global, project-level, and all three action-level invariants from spec WF03; invariant text aligned with spec examples - **Invariant enforcement assertion** (AC2) — best-effort check for invariant-related keywords in strategize output via `Run Keyword And Warn On Failure` - **Estimation actor** — included in action YAML per spec WF03 - **Cautious profile verification** — verifies `cautious` appears in `plan use` output (AC4) - **Spec WF03 Step 3 ordering** — follows spec flow: tree → explain → prompt → status. Step 4: correct → tree --show-superseded → execute → diff → apply - **Plan tree** (spec WF03 Step 3) — inspects decision tree with explicit failure handling (rc != 0 → Fail) - **Plan explain** with plan_id (AC5, **partial**) — exercises plan-level explanation with explicit failure handling; includes `TODO(#1057)` for full decision-level coverage - **Plan prompt** (AC7) — exercises user guidance with `--format plain`; gracefully handles unimplemented command (rc != 0 → WARN); Traceback check only on success path; INTERNAL expected for unrecognized subcommands - **Plan status** (AC4) — placed after prompt per spec ordering; verifies plan_id in status output; known AC4 verification gap documented (LLM non-determinism prevents reliable pause assertion) - **Plan correct --mode revert** with plan_id (AC6, **partial**) — exercises correction flow with explicit failure handling; validates revert semantics in output via `Run Keyword And Warn On Failure` (soft-checked — CLI does not echo correction mode as fixed string); includes `TODO(#1055)` for full decision-level coverage - **Plan tree --show-superseded** — exercises post-correction tree view per spec WF03 Step 4 - **Post-correction execute** — continues execution with explicit failure handling - **Plan diff** (AC8) — with content assertion checking for refactoring-related content via `Run Keyword And Warn On Failure`; explicit `ELSE` branch that fails on non-zero rc; includes `TODO(#749)` for `plan diff --correction <CORRECTION_ID>` variant - **Plan lifecycle-apply** — documented that `lifecycle-apply` does not support `--yes`; explicit rc check and non-empty output assertion; includes `TODO(#749)` for alignment with spec's `plan apply --yes` - **Post-apply repository verification** (AC8) — `git log -1 --oneline` check on target repo verifies actual file changes were committed - **Invariant list** — with `--format plain`; warning-level log on non-zero rc; explicit note documenting expected empty results due to in-memory persistence - **Final status check** — soft assertion for terminal state (`applied`/`completed`) - **Return-code check** for `git rev-parse` (was missing) - **Consistent DEBUG-level logging** — all command output logs use `level=DEBUG`; Plan ID announcement uses explicit `level=INFO` - **Git operation safety** — all `Run Process` git calls include `timeout=60s on_timeout=kill` - **Explicit failure handling** — plan tree, plan explain, plan correct, post-correction execute, plan diff, plan lifecycle-apply all fail the test on non-zero rc ### `robot/e2e/common_e2e.resource` - **Fixed `Extract Plan Id` Strategy 3 runtime crash**: changed `group=1` named argument to positional `1` — Robot Framework's `Get Regexp Matches` accepts groups only as positional `*groups` args - **Fixed Strategy 3 regex**: replaced `(\S+)` with `([0-9A-Za-z_-]+)` to avoid capturing trailing punctuation (Crockford Base32 + UUID charset) - **Fixed UUID regex**: added `\b` word-boundary anchors for consistency with ULID regex strategy ### `robot/e2e/m1_acceptance.robot` - Removed local `Extract Plan Id` — now uses shared keyword from `common_e2e.resource` - Updated `Extract Plan Id` call to pass both stdout and stderr for consistency with WF03 ### `robot/core_cli_commands.robot` - **Fixed `Test Project Status Without Project`**: updated to match current CLI auto-init behavior (rc=0, stdout contains "Project Status") — was failing on master ### `CHANGELOG.md` - Updated WF03 entry to reflect all scopes (global, project, action), custom actor registration, plan tree, and graceful skip ## Known Limitations / Deferred Items - **strategy_actor cannot reference custom actor name**: The spec WF03 Step 2 shows `strategy_actor: local/refactoring-strategist` but the runtime resolves strategy_actor as a provider/model pair — `local/wf03-strategist` yields "Unknown provider type: local". Uses provider/model directly; custom actor registration is still exercised and verified via `actor list`. - **ActionConfigSchema does not support `args`**: Spec shows `args:` section with `target_module` parameter but ActionConfigSchema rejects it (`extra_forbidden`). Args section omitted; `--arg` on CLI also not used since no declared args exist. - **Partial AC5 coverage**: `plan explain` uses `plan_id` (plan-level) instead of spec-required `decision_id` (decision-level). Tracked via `TODO(#1057)`. - **Partial AC6 coverage**: `plan correct` uses `plan_id` instead of spec-required `decision_id`. Tracked via `TODO(#1055)`. - **Missing `plan diff --correction`**: Spec WF03 Step 4 shows correction-specific diff; not exercised because `correction_id` extraction is not yet reliable. Tracked via `TODO(#749)`. - **`plan prompt` not implemented**: Command returns "No such command 'prompt'" — handled gracefully with WARN log. - **`lifecycle-apply` vs spec's `plan apply --yes`**: v3 uses `lifecycle-apply` (no confirmation prompt) rather than `plan apply --yes` shown in spec. Tracked via `TODO(#749)`. - **LLM non-determinism**: Several assertions use `Run Keyword And Warn On Failure` instead of hard assertions because LLM output is non-deterministic. - **Known AC4 verification gap**: Cautious profile pause verification is soft-checked only due to LLM non-determinism. - **Invariant list expected empty**: `invariant list --effective` returns empty results because InvariantService is in-memory only; previously-added invariants are not retained across CLI invocations. ## Manual Verification ### Prerequisites - `OPENAI_API_KEY` or `ANTHROPIC_API_KEY` environment variable set ### Commands ```bash nox -s e2e_tests ``` ### What to Look For - WF03 test passes with real LLM keys - WF03 test skips gracefully without keys - M1 test still passes (uses shared Extract Plan Id with both stdout and stderr) - No `Traceback` or `INTERNAL` in any command output
freemo added the
Type
Testing
label 2026-03-13 01:16:23 +00:00
freemo added this to the v3.2.0 milestone 2026-03-13 01:16:23 +00:00
freemo force-pushed test/e2e-wf03-refactoring from 1d548345cf to 3351a3463e 2026-03-13 16:24:27 +00:00 Compare
freemo force-pushed test/e2e-wf03-refactoring from 3351a3463e to f6c0ce630f 2026-03-13 16:31:34 +00:00 Compare
freemo force-pushed test/e2e-wf03-refactoring from f6c0ce630f to a98dfd6fcb 2026-03-13 16:42:18 +00:00 Compare
freemo force-pushed test/e2e-wf03-refactoring from a98dfd6fcb to dda6a811f0 2026-03-13 16:59:14 +00:00 Compare
freemo force-pushed test/e2e-wf03-refactoring from dda6a811f0 to 49027f77e3 2026-03-13 17:28:35 +00:00 Compare
freemo force-pushed test/e2e-wf03-refactoring from 49027f77e3 to 180c435c57 2026-03-13 17:46:48 +00:00 Compare
freemo force-pushed test/e2e-wf03-refactoring from 180c435c57 to 1d548345cf 2026-03-13 18:12:59 +00:00 Compare
freemo force-pushed test/e2e-wf03-refactoring from 1d548345cf to d05e899c48 2026-03-13 18:14:19 +00:00 Compare
freemo force-pushed test/e2e-wf03-refactoring from d05e899c48 to d6a692ca00 2026-03-13 18:25:17 +00:00 Compare
freemo force-pushed test/e2e-wf03-refactoring from d6a692ca00 to 507c3f5268 2026-03-13 18:33:24 +00:00 Compare
freemo force-pushed test/e2e-wf03-refactoring from 507c3f5268 to 4f2b53c3a7 2026-03-13 20:20:56 +00:00 Compare
freemo added the
State
In Review
label 2026-03-13 21:16:34 +00:00
freemo force-pushed test/e2e-wf03-refactoring from 4f2b53c3a7 to 97ab3e6ad0 2026-03-13 23:19:33 +00:00 Compare
freemo added the
Priority
Medium
label 2026-03-14 04:10:12 +00:00
Author
Owner

PM Review — Day 34

Status: Mergeable, 0 reviews, M3 (v3.2.0)
Author: @freemo

E2E test for WF03 (cautious profile, multi-file refactoring with invariants). Follows identical structure to #799. Tests plan prompt (user guidance injection) — this is a critical acceptance criterion that the integration test counterpart PR #944 is missing.

See #799 for common review notes (Extract Plan Id duplication, merge order).

Action Items

Who Action Deadline
@hurui200320 Peer review Day 36
## PM Review — Day 34 **Status**: Mergeable, 0 reviews, M3 (v3.2.0) **Author**: @freemo E2E test for WF03 (cautious profile, multi-file refactoring with invariants). Follows identical structure to #799. Tests `plan prompt` (user guidance injection) — this is a critical acceptance criterion that the integration test counterpart PR #944 is missing. **See #799 for common review notes** (Extract Plan Id duplication, merge order). ### Action Items | Who | Action | Deadline | |-----|--------|----------| | @hurui200320 | **Peer review** | Day 36 |
freemo added the
MoSCoW
Must have
Points
3
labels 2026-03-14 22:11:26 +00:00
freemo added a new dependency 2026-03-16 02:42:16 +00:00
freemo added a new dependency 2026-03-16 02:42:16 +00:00
Author
Owner

PM Status — Day 36 (2026-03-16)

Day 34 review assignment deadline check. This PR has been in review for 2+ days with 0 reviewer activity.

Reminder: Assigned reviewer — please post your review by Day 37 EOD or flag any blockers. These E2E test PRs are foundational for milestone acceptance gates and cannot remain unreviewed indefinitely.

If you are unable to review by the deadline, please comment so the review can be reassigned.

## PM Status — Day 36 (2026-03-16) Day 34 review assignment deadline check. This PR has been in review for 2+ days with 0 reviewer activity. **Reminder**: Assigned reviewer — please post your review by **Day 37 EOD** or flag any blockers. These E2E test PRs are foundational for milestone acceptance gates and cannot remain unreviewed indefinitely. If you are unable to review by the deadline, please comment so the review can be reassigned.
freemo reviewed 2026-03-16 16:15:21 +00:00
freemo left a comment
Author
Owner

PM Day 36 Triage: M3 E2E test PR (v3.2.0). Lower priority than bug fixes and TDD infrastructure. Reviewer: @brent.edwards after critical path items clear.

PM Day 36 Triage: M3 E2E test PR (v3.2.0). Lower priority than bug fixes and TDD infrastructure. Reviewer: @brent.edwards after critical path items clear.
hurui200320 was assigned by freemo 2026-03-16 22:21:51 +00:00
Author
Owner

@hurui200320 I am going to have you take over this PR, it is mostly completed but is waiting on #628 and #966 One is yours and one is Brent's. Please be sure to get this PR and the two blocking PRs I listed in asap, thanks.

@hurui200320 I am going to have you take over this PR, it is mostly completed but is waiting on https://git.cleverthis.com/cleveragents/cleveragents-core/issues/628 and https://git.cleverthis.com/cleveragents/cleveragents-core/issues/966 One is yours and one is Brent's. Please be sure to get this PR and the two blocking PRs I listed in asap, thanks.
Author
Owner

PM Status — Day 37 — Rebase Required

This PR has merge conflicts and cannot be merged in its current state. 42% of all open PRs (21 of 50) have conflicts — this is a project-wide issue that must be resolved.

@freemo — Please rebase this PR onto master by Day 39 EOD (2026-03-19). If you cannot rebase by then, please post a comment explaining the blocker.


PM rebase request — Day 37

## PM Status — Day 37 — Rebase Required This PR has **merge conflicts** and cannot be merged in its current state. 42% of all open PRs (21 of 50) have conflicts — this is a project-wide issue that must be resolved. @freemo — Please rebase this PR onto `master` by **Day 39 EOD (2026-03-19)**. If you cannot rebase by then, please post a comment explaining the blocker. --- *PM rebase request — Day 37*
Author
Owner

PM Status — Day 37 (2026-03-17)

Status: Ownership transferred to @hurui200320. Blocked on #628 and #966. Now has merge conflicts. M3 (v3.2.0) E2E test for WF03 multi-file refactor invariants.

Blockers: Dependencies #628 (Rui) and #966 (Brent) must land first. Merge conflict with master.

Action required:

PM status — Day 37

## PM Status — Day 37 (2026-03-17) **Status**: Ownership transferred to @hurui200320. Blocked on #628 and #966. Now has merge conflicts. M3 (v3.2.0) E2E test for WF03 multi-file refactor invariants. **Blockers**: Dependencies #628 (Rui) and #966 (Brent) must land first. Merge conflict with master. **Action required**: - @hurui200320 — Rebase after #628 and #966 merge. Deadline: **Day 39 EOD**. - @brent.edwards — Land #966 to unblock. *PM status — Day 37*
hurui200320 force-pushed test/e2e-wf03-refactoring from 97ab3e6ad0 to 946580750b 2026-03-18 08:46:00 +00:00 Compare
freemo requested review from CoreRasurae 2026-03-22 16:40:06 +00:00
freemo requested review from brent.edwards 2026-03-22 16:40:06 +00:00
hurui200320 force-pushed test/e2e-wf03-refactoring from 946580750b to 37b12f8307 2026-03-24 07:48:52 +00:00 Compare
hurui200320 force-pushed test/e2e-wf03-refactoring from 37b12f8307 to 6fc3444b5f 2026-03-24 08:38:16 +00:00 Compare
hurui200320 force-pushed test/e2e-wf03-refactoring from 6fc3444b5f to ec059b925a 2026-03-24 10:01:52 +00:00 Compare
hurui200320 force-pushed test/e2e-wf03-refactoring from ec059b925a to 3789a804fb 2026-03-24 11:15:05 +00:00 Compare
hurui200320 force-pushed test/e2e-wf03-refactoring from 3789a804fb to 59899bd854 2026-03-24 11:56:17 +00:00 Compare
hurui200320 force-pushed test/e2e-wf03-refactoring from 59899bd854 to e4ca4d0e18 2026-03-27 09:59:22 +00:00 Compare
hurui200320 was unassigned by freemo 2026-04-02 06:15:23 +00:00
freemo self-assigned this 2026-04-02 06:15:23 +00:00
freemo force-pushed test/e2e-wf03-refactoring from e4ca4d0e18 to 87139bc987 2026-04-02 07:02:01 +00:00 Compare
Author
Owner

🤖 Backlog Groomer (groomer-1): Closing as duplicate of #749.

Issue #749 (test(e2e): workflow example 3 — multi-file refactoring with invariants) is the canonical version with full labels (MoSCoW/Must have, Priority/Critical, State/In Review, Type/Testing) and milestone v3.2.0. This issue is an exact title duplicate.

🤖 **Backlog Groomer (groomer-1):** Closing as duplicate of #749. Issue #749 (`test(e2e): workflow example 3 — multi-file refactoring with invariants`) is the canonical version with full labels (`MoSCoW/Must have`, `Priority/Critical`, `State/In Review`, `Type/Testing`) and milestone `v3.2.0`. This issue is an exact title duplicate.
freemo closed this pull request 2026-04-02 17:33:35 +00:00
Some required checks failed
CI / lint (pull_request) Failing after 5s
Required
Details
CI / typecheck (pull_request) Failing after 5s
Required
Details
CI / coverage (pull_request) Has been skipped
Required
Details
CI / security (pull_request) Failing after 5s
Required
Details
CI / quality (pull_request) Failing after 5s
Required
Details
CI / unit_tests (pull_request) Failing after 5s
Required
Details
CI / docker (pull_request) Has been skipped
Required
Details
CI / integration_tests (pull_request) Failing after 5s
Required
Details
CI / e2e_tests (pull_request) Failing after 5s
CI / build (pull_request) Failing after 4s
Required
Details
CI / helm (pull_request) Failing after 4s
CI / status-check (pull_request) Failing after 1s
CI / benchmark-publish (pull_request) Has been skipped
CI / benchmark-regression (pull_request) Has been skipped

Pull request closed

Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Reference: cleveragents/cleveragents-core#800