Skip to content

Commit 0b99496

Browse files
authored
Merge pull request #83 from dmoliveira/my_opencode-e14-validation-docs
Complete E14-T4 validation coverage and docs
2 parents ae31851 + f896b45 commit 0b99496

File tree

5 files changed

+183
-8
lines changed

5 files changed

+183
-8
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ All notable changes to this project are documented in this file.
4747
- Added `scripts/start_work_command.py` with `/start-work <plan>` execution, persisted checkpoint status, and deviation reporting (`status`, `deviations`).
4848
- Added `/start-work`, `/start-work-status`, and `/start-work-deviations` aliases in `opencode.json`.
4949
- Added `/start-work-bg` and `/start-work-doctor-json` aliases for background-safe queueing and execution health diagnostics.
50+
- Added `instructions/plan_execution_workflows.md` with sample plans and direct/background/recovery workflows for `/start-work`.
5051

5152
### Changes
5253
- Documented extension evaluation outcomes and when each tool is the better fit.
@@ -90,6 +91,7 @@ All notable changes to this project are documented in this file.
9091
- Expanded browser verification coverage to assert provider reset readiness and added install smoke checks that run browser status/doctor after switching across providers.
9192
- Expanded install/selftest coverage for `/start-work` plan validation, execution state persistence, and deviation diagnostics.
9293
- Expanded `/start-work` integrations with background queue handoff, digest recap payloads, and unified `/doctor` visibility.
94+
- Expanded `/start-work` validation coverage for missing frontmatter, out-of-order ordinals, and recovery from invalid runtime state.
9395

9496
## v0.2.0 - 2026-02-12
9597

IMPLEMENTATION_ROADMAP.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Use this map to avoid overlapping implementations.
5050
| E11 | Context-Window Resilience Toolkit | done | High | E4 | bd-2tj, bd-n9y, bd-2t0, bd-18e | Improve long-session stability and recovery |
5151
| E12 | Provider/Model Fallback Visibility | done | Medium | E5 | bd-1jq, bd-298, bd-194, bd-2gq | Explain why model routing decisions happen |
5252
| E13 | Browser Automation Profile Switching | done | Medium | E1 | bd-3rs, bd-2qy, bd-f6g, bd-393 | Toggle Playwright/agent-browser with checks |
53-
| E14 | Plan-to-Execution Bridge Command | in_progress | Medium | E2, E3 | bd-1z6, bd-2te, bd-3sg | Execute validated plans with progress tracking |
53+
| E14 | Plan-to-Execution Bridge Command | done | Medium | E2, E3 | bd-1z6, bd-2te, bd-3sg, bd-2bv | Execute validated plans with progress tracking |
5454
| E15 | Todo Enforcer and Plan Compliance | planned | High | E14 | TBD | Keep execution aligned with approved checklists |
5555
| E16 | Comment and Output Quality Checker Loop | merged | Medium | E23 | TBD | Merged into E23 (PR Review Copilot) |
5656
| E17 | Auto-Resume and Recovery Loop | planned | High | E11, E14 | TBD | Resume interrupted work from checkpoints safely |
@@ -563,7 +563,7 @@ Every command-oriented epic must ship all of the following:
563563

564564
## Epic 14 - Plan-to-Execution Bridge Command
565565

566-
**Status:** `in_progress`
566+
**Status:** `done`
567567
**Priority:** Medium
568568
**Goal:** Add a command to execute from an approved plan artifact with progress tracking and deviation reporting.
569569
**Depends on:** Epic 2, Epic 3
@@ -583,12 +583,13 @@ Every command-oriented epic must ship all of the following:
583583
- [x] Subtask 14.3.2: Integrate with digest summaries for end-of-run recap
584584
- [x] Subtask 14.3.3: Expose execution status in doctor/debug outputs
585585
- [x] Notes: Added background-safe `/start-work` queueing (`--background` + `/start-work-bg`), digest `plan_execution` recap output, and `/doctor` integration via `/start-work doctor --json`.
586-
- [ ] Task 14.4: Validation and docs
587-
- [ ] Subtask 14.4.1: Add tests for plan parsing and execution flow
588-
- [ ] Subtask 14.4.2: Add recovery tests for interrupted plan runs
589-
- [ ] Subtask 14.4.3: Add docs with sample plans and workflows
590-
- [ ] Exit criteria: approved plans can be executed and resumed with clear state
591-
- [ ] Exit criteria: deviations are explicitly surfaced and reviewable
586+
- [x] Task 14.4: Validation and docs
587+
- [x] Subtask 14.4.1: Add tests for plan parsing and execution flow
588+
- [x] Subtask 14.4.2: Add recovery tests for interrupted plan runs
589+
- [x] Subtask 14.4.3: Add docs with sample plans and workflows
590+
- [x] Notes: Expanded `scripts/selftest.py` with additional plan validation/recovery checks and added `instructions/plan_execution_workflows.md` with sample plans plus direct/background/recovery workflows.
591+
- [x] Exit criteria: approved plans can be executed and resumed with clear state
592+
- [x] Exit criteria: deviations are explicitly surfaced and reviewable
592593

593594
---
594595

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,7 @@ Recommended workflow:
584584
Epic 14 Task 14.1 defines the baseline plan format and execution-state rules for the upcoming `/start-work <plan>` command:
585585

586586
- contract spec: `instructions/plan_artifact_contract.md`
587+
- validation/workflow guide: `instructions/plan_execution_workflows.md`
587588
- backend command: `scripts/start_work_command.py`
588589
- format scope: markdown checklist + YAML metadata frontmatter
589590
- validation scope: deterministic preflight failures with line-level remediation hints
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Plan Execution Validation and Workflow Guide
2+
3+
This guide accompanies Epic 14 Task 14.4 and documents validated workflows for `/start-work`.
4+
5+
## Sample plan artifact
6+
7+
Use this baseline plan format:
8+
9+
```markdown
10+
---
11+
id: sample-plan-001
12+
title: Sample implementation plan
13+
owner: diego
14+
created_at: 2026-02-13T00:00:00Z
15+
version: 1
16+
---
17+
18+
# Plan
19+
20+
- [ ] 1. Prepare implementation environment
21+
- [ ] 2. Apply code changes
22+
- [ ] 3. Run verification and summarize results
23+
```
24+
25+
## Primary execution workflow
26+
27+
1. Run `/start-work path/to/plan.md --json`.
28+
2. Verify state with `/start-work status --json`.
29+
3. Review deviations with `/start-work deviations --json`.
30+
4. Run `/start-work doctor --json` before handoff.
31+
32+
## Background-safe workflow
33+
34+
Use queued execution when you want reviewable handoff through the background subsystem:
35+
36+
1. Run `/start-work-bg path/to/plan.md`.
37+
2. Capture returned `job_id`.
38+
3. Execute queued work with `/bg run --id <job-id>`.
39+
4. Inspect logs via `/bg read <job-id> --json`.
40+
5. Confirm final state using `/start-work status --json`.
41+
42+
## Validation failure examples
43+
44+
- Missing frontmatter should fail with `validation_failed` and `missing_frontmatter` violation.
45+
- Out-of-order checklist ordinals should fail with `validation_failed` and `out_of_order_ordinals` violation.
46+
- Non-numbered checklist items should fail with `validation_failed` and `missing_step_ordinal` violation.
47+
48+
## Recovery workflow
49+
50+
When runtime state is inconsistent (for example, multiple steps marked `in_progress`):
51+
52+
1. Run `/start-work doctor --json` to confirm failure diagnostics.
53+
2. Re-run a valid plan with `/start-work path/to/plan.md --json` to restore deterministic state.
54+
3. Re-check with `/start-work doctor --json` and `/doctor run --json`.
55+
4. Run `/digest run --reason manual` to capture end-of-run recap including `plan_execution` summary.

scripts/selftest.py

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1840,6 +1840,122 @@ def run_bg(*args: str) -> subprocess.CompletedProcess[str]:
18401840
"start-work should report validation_failed for invalid plan format",
18411841
)
18421842

1843+
malformed_frontmatter_plan = tmp / "invalid_frontmatter_plan.md"
1844+
malformed_frontmatter_plan.write_text(
1845+
"""# Plan
1846+
1847+
- [ ] 1. Missing metadata should fail
1848+
""",
1849+
encoding="utf-8",
1850+
)
1851+
malformed_start_work = subprocess.run(
1852+
[
1853+
sys.executable,
1854+
str(START_WORK_SCRIPT),
1855+
str(malformed_frontmatter_plan),
1856+
"--json",
1857+
],
1858+
capture_output=True,
1859+
text=True,
1860+
env=refactor_env,
1861+
check=False,
1862+
cwd=REPO_ROOT,
1863+
)
1864+
expect(
1865+
malformed_start_work.returncode == 1,
1866+
"start-work should fail when frontmatter is missing",
1867+
)
1868+
malformed_start_work_report = parse_json_output(malformed_start_work.stdout)
1869+
expect(
1870+
malformed_start_work_report.get("code") == "validation_failed",
1871+
"start-work should return validation_failed for missing frontmatter",
1872+
)
1873+
1874+
out_of_order_plan = tmp / "invalid_out_of_order_plan.md"
1875+
out_of_order_plan.write_text(
1876+
"""---
1877+
id: out-of-order-plan
1878+
title: Out Of Order Plan
1879+
owner: selftest
1880+
created_at: 2026-02-13T00:00:00Z
1881+
version: 1
1882+
---
1883+
1884+
# Plan
1885+
1886+
- [ ] 2. Second task appears first
1887+
- [ ] 1. First task appears second
1888+
""",
1889+
encoding="utf-8",
1890+
)
1891+
out_of_order_start_work = subprocess.run(
1892+
[sys.executable, str(START_WORK_SCRIPT), str(out_of_order_plan), "--json"],
1893+
capture_output=True,
1894+
text=True,
1895+
env=refactor_env,
1896+
check=False,
1897+
cwd=REPO_ROOT,
1898+
)
1899+
expect(
1900+
out_of_order_start_work.returncode == 1,
1901+
"start-work should fail out-of-order step ordinals",
1902+
)
1903+
out_of_order_report = parse_json_output(out_of_order_start_work.stdout)
1904+
expect(
1905+
any(
1906+
violation.get("code") == "out_of_order_ordinals"
1907+
for violation in out_of_order_report.get("violations", [])
1908+
if isinstance(violation, dict)
1909+
),
1910+
"start-work should surface out_of_order_ordinals violation",
1911+
)
1912+
1913+
runtime_config_path = Path(str(start_work_report.get("config") or ""))
1914+
expect(
1915+
runtime_config_path.exists(),
1916+
"start-work should report writable config path",
1917+
)
1918+
runtime_cfg = load_json_file(runtime_config_path)
1919+
runtime_cfg.setdefault("plan_execution", {})["status"] = "in_progress"
1920+
runtime_cfg["plan_execution"]["steps"] = [
1921+
{"ordinal": 1, "state": "in_progress"},
1922+
{"ordinal": 2, "state": "in_progress"},
1923+
]
1924+
runtime_config_path.write_text(
1925+
json.dumps(runtime_cfg, indent=2) + "\n", encoding="utf-8"
1926+
)
1927+
1928+
start_work_doctor_fail = subprocess.run(
1929+
[sys.executable, str(START_WORK_SCRIPT), "doctor", "--json"],
1930+
capture_output=True,
1931+
text=True,
1932+
env=refactor_env,
1933+
check=False,
1934+
cwd=REPO_ROOT,
1935+
)
1936+
expect(
1937+
start_work_doctor_fail.returncode == 1,
1938+
"start-work doctor should fail invalid in-progress step recovery state",
1939+
)
1940+
start_work_doctor_fail_report = parse_json_output(start_work_doctor_fail.stdout)
1941+
expect(
1942+
start_work_doctor_fail_report.get("result") == "FAIL",
1943+
"start-work doctor should report FAIL for invalid recovery state",
1944+
)
1945+
1946+
start_work_recover = subprocess.run(
1947+
[sys.executable, str(START_WORK_SCRIPT), str(plan_path), "--json"],
1948+
capture_output=True,
1949+
text=True,
1950+
env=refactor_env,
1951+
check=False,
1952+
cwd=REPO_ROOT,
1953+
)
1954+
expect(
1955+
start_work_recover.returncode == 0,
1956+
"start-work should recover by re-running valid plan after invalid runtime state",
1957+
)
1958+
18431959
keyword_report = resolve_prompt_modes(
18441960
"Please safe-apply and deep-analyze this migration; ulw can wait.",
18451961
enabled=True,

0 commit comments

Comments
 (0)