Skip to content

Commit 4b404cc

Browse files
authored
Merge pull request #85 from dmoliveira/my_opencode-e15-enforcement-engine
Complete E15 todo enforcer and plan compliance
2 parents 34c0547 + 45ec7a8 commit 4b404cc

File tree

12 files changed

+722
-39
lines changed

12 files changed

+722
-39
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ All notable changes to this project are documented in this file.
4949
- Added `/start-work-bg` and `/start-work-doctor-json` aliases for background-safe queueing and execution health diagnostics.
5050
- Added `instructions/plan_execution_workflows.md` with sample plans and direct/background/recovery workflows for `/start-work`.
5151
- Added `instructions/todo_compliance_model.md` defining todo states, transition enforcement, bypass metadata, and compliance audit event format for Epic 15 Task 15.1.
52+
- Added `scripts/todo_enforcement.py` with deterministic todo transition/completion validation and remediation hint helpers for Epic 15 Task 15.2.
53+
- Added `scripts/todo_command.py` with `/todo status` and `/todo enforce` diagnostics for runtime compliance visibility.
54+
- Added `/todo`, `/todo-status`, and `/todo-enforce` aliases in `opencode.json`.
5255

5356
### Changes
5457
- Documented extension evaluation outcomes and when each tool is the better fit.
@@ -93,6 +96,9 @@ All notable changes to this project are documented in this file.
9396
- Expanded install/selftest coverage for `/start-work` plan validation, execution state persistence, and deviation diagnostics.
9497
- Expanded `/start-work` integrations with background queue handoff, digest recap payloads, and unified `/doctor` visibility.
9598
- Expanded `/start-work` validation coverage for missing frontmatter, out-of-order ordinals, and recovery from invalid runtime state.
99+
- Updated `/start-work` execution to enforce todo compliance transitions, emit audit events, and block completion when required items remain unchecked.
100+
- Integrated todo compliance checks into `/doctor` summary, installer self-checks, and install-test smoke coverage.
101+
- Expanded selftest coverage for todo transition gating, completion blocking, and bypass audit-event payload validation.
96102

97103
## v0.2.0 - 2026-02-12
98104

IMPLEMENTATION_ROADMAP.md

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Use this map to avoid overlapping implementations.
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 |
5353
| E14 | Plan-to-Execution Bridge Command | done | Medium | E2, E3 | bd-1z6, bd-2te, bd-3sg, bd-2bv | Execute validated plans with progress tracking |
54-
| E15 | Todo Enforcer and Plan Compliance | in_progress | High | E14 | bd-l9c | Keep execution aligned with approved checklists |
54+
| E15 | Todo Enforcer and Plan Compliance | done | High | E14 | bd-l9c | 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 |
5757
| E18 | LSP/AST-Assisted Safe Edit Mode | planned | High | E3 | TBD | Prefer semantic edits over plain text replacements |
@@ -595,7 +595,7 @@ Every command-oriented epic must ship all of the following:
595595

596596
## Epic 15 - Todo Enforcer and Plan Compliance
597597

598-
**Status:** `in_progress`
598+
**Status:** `done`
599599
**Priority:** High
600600
**Goal:** Enforce explicit checklist progress during execution so outcomes stay aligned with approved plans.
601601
**Depends on:** Epic 14
@@ -605,20 +605,23 @@ Every command-oriented epic must ship all of the following:
605605
- [x] Subtask 15.1.2: Define rules for one-active-item-at-a-time enforcement
606606
- [x] Subtask 15.1.3: Define acceptable bypass annotations and audit format
607607
- [x] Notes: Added `instructions/todo_compliance_model.md` with state model, transition constraints, bypass metadata requirements, and audit event contract.
608-
- [ ] Task 15.2: Implement enforcement engine
609-
- [ ] Subtask 15.2.1: Validate state transitions before major actions
610-
- [ ] Subtask 15.2.2: Block completion when required tasks remain unchecked
611-
- [ ] Subtask 15.2.3: Emit actionable remediation prompts on violations
612-
- [ ] Task 15.3: Integrate command workflows
613-
- [ ] Subtask 15.3.1: Integrate with plan execution command and background runs
614-
- [ ] Subtask 15.3.2: Add `/todo status` and `/todo enforce` diagnostics
615-
- [ ] Subtask 15.3.3: Add docs for compliant workflow patterns
616-
- [ ] Task 15.4: Verification
617-
- [ ] Subtask 15.4.1: Add tests for transition validity and blocking behavior
618-
- [ ] Subtask 15.4.2: Add tests for bypass annotations and logs
619-
- [ ] Subtask 15.4.3: Add install-test smoke scenarios
620-
- [ ] Exit criteria: plan completion cannot be marked done with unchecked required items
621-
- [ ] Exit criteria: bypass behavior is explicit, logged, and reviewable
608+
- [x] Task 15.2: Implement enforcement engine
609+
- [x] Subtask 15.2.1: Validate state transitions before major actions
610+
- [x] Subtask 15.2.2: Block completion when required tasks remain unchecked
611+
- [x] Subtask 15.2.3: Emit actionable remediation prompts on violations
612+
- [x] Notes: Added `scripts/todo_enforcement.py` and wired `/start-work` to enforce deterministic todo transitions, completion gating, and remediation/audit outputs in runtime state.
613+
- [x] Task 15.3: Integrate command workflows
614+
- [x] Subtask 15.3.1: Integrate with plan execution command and background runs
615+
- [x] Subtask 15.3.2: Add `/todo status` and `/todo enforce` diagnostics
616+
- [x] Subtask 15.3.3: Add docs for compliant workflow patterns
617+
- [x] Notes: Added `scripts/todo_command.py`, command aliases, doctor integration, and README/install workflow guidance for explicit todo compliance checks.
618+
- [x] Task 15.4: Verification
619+
- [x] Subtask 15.4.1: Add tests for transition validity and blocking behavior
620+
- [x] Subtask 15.4.2: Add tests for bypass annotations and logs
621+
- [x] Subtask 15.4.3: Add install-test smoke scenarios
622+
- [x] Notes: Expanded `scripts/selftest.py` and install smoke checks for transition gating, completion blocking, bypass metadata validation, and deterministic bypass audit payloads.
623+
- [x] Exit criteria: plan completion cannot be marked done with unchecked required items
624+
- [x] Exit criteria: bypass behavior is explicit, logged, and reviewable
622625

623626
---
624627

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ install-test: ## Run installer smoke test in temp HOME
4949
HOME="$$TMP_HOME" python3 "$$TMP_HOME/.config/opencode/my_opencode/scripts/stack_profile_command.py" status; \
5050
if [ -f "$$TMP_HOME/.config/opencode/my_opencode/scripts/browser_command.py" ]; then HOME="$$TMP_HOME" python3 "$$TMP_HOME/.config/opencode/my_opencode/scripts/browser_command.py" status --json; HOME="$$TMP_HOME" python3 "$$TMP_HOME/.config/opencode/my_opencode/scripts/browser_command.py" profile agent-browser; HOME="$$TMP_HOME" python3 "$$TMP_HOME/.config/opencode/my_opencode/scripts/browser_command.py" doctor --json; HOME="$$TMP_HOME" python3 "$$TMP_HOME/.config/opencode/my_opencode/scripts/browser_command.py" profile playwright; HOME="$$TMP_HOME" python3 "$$TMP_HOME/.config/opencode/my_opencode/scripts/browser_command.py" status --json; HOME="$$TMP_HOME" python3 "$$TMP_HOME/.config/opencode/my_opencode/scripts/browser_command.py" doctor --json; fi; \
5151
if [ -f "$$TMP_HOME/.config/opencode/my_opencode/scripts/start_work_command.py" ]; then PLAN_FILE="$$TMP_HOME/.config/opencode/my_opencode/.install-test-plan.md"; python3 -c "from pathlib import Path; Path('$$PLAN_FILE').write_text('---\nid: install-test-plan\ntitle: Install Test Plan\nowner: install-test\ncreated_at: 2026-02-13T00:00:00Z\nversion: 1\n---\n\n# Plan\n\n- [ ] 1. Validate command availability\n- [ ] 2. Validate status persistence\n', encoding='utf-8')"; HOME="$$TMP_HOME" python3 "$$TMP_HOME/.config/opencode/my_opencode/scripts/start_work_command.py" "$$PLAN_FILE" --deviation "install smoke" --json; HOME="$$TMP_HOME" python3 "$$TMP_HOME/.config/opencode/my_opencode/scripts/start_work_command.py" "$$PLAN_FILE" --background --json; HOME="$$TMP_HOME" python3 "$$TMP_HOME/.config/opencode/my_opencode/scripts/background_task_manager.py" run --max-jobs 1; HOME="$$TMP_HOME" python3 "$$TMP_HOME/.config/opencode/my_opencode/scripts/start_work_command.py" status --json; HOME="$$TMP_HOME" python3 "$$TMP_HOME/.config/opencode/my_opencode/scripts/start_work_command.py" deviations --json; HOME="$$TMP_HOME" python3 "$$TMP_HOME/.config/opencode/my_opencode/scripts/start_work_command.py" doctor --json; fi; \
52+
if [ -f "$$TMP_HOME/.config/opencode/my_opencode/scripts/todo_command.py" ]; then HOME="$$TMP_HOME" python3 "$$TMP_HOME/.config/opencode/my_opencode/scripts/todo_command.py" status --json; HOME="$$TMP_HOME" python3 "$$TMP_HOME/.config/opencode/my_opencode/scripts/todo_command.py" enforce --json; fi; \
5253
HOME="$$TMP_HOME" python3 "$$TMP_HOME/.config/opencode/my_opencode/scripts/nvim_integration_command.py" install minimal --link-init; \
5354
HOME="$$TMP_HOME" python3 "$$TMP_HOME/.config/opencode/my_opencode/scripts/nvim_integration_command.py" status; \
5455
HOME="$$TMP_HOME" python3 "$$TMP_HOME/.config/opencode/my_opencode/scripts/devtools_command.py" status; \

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ Epic 14 Task 14.1 defines the baseline plan format and execution-state rules for
588588
- backend command: `scripts/start_work_command.py`
589589
- format scope: markdown checklist + YAML metadata frontmatter
590590
- validation scope: deterministic preflight failures with line-level remediation hints
591-
- state model scope: `pending/in_progress/completed/failed/skipped` with strict transition semantics
591+
- state model scope: `pending/in_progress/done/skipped` with strict transition semantics
592592

593593
Use:
594594
```text
@@ -614,6 +614,23 @@ Epic 15 Task 15.1 defines the baseline compliance contract for enforced todo exe
614614
- enforcement: one active item at a time with deterministic transition validation
615615
- bypass path: explicit metadata + audit event requirements for controlled exceptions
616616

617+
Epic 15 Task 15.2 implements the enforcement backend:
618+
619+
- engine module: `scripts/todo_enforcement.py`
620+
- `/start-work` now validates todo transitions before state mutation and blocks completion when required items remain unchecked
621+
- compliance violations now emit deterministic remediation prompts and persisted audit events
622+
623+
Use:
624+
```text
625+
/todo status --json
626+
/todo enforce --json
627+
```
628+
629+
Compliant workflow pattern:
630+
- run `/start-work path/to/plan.md --json`
631+
- inspect `/todo status --json` for current state counts
632+
- gate handoff/closure with `/todo enforce --json`
633+
617634
## Context resilience policy
618635

619636
Epic 11 Task 11.1 defines the baseline policy schema for context-window resilience:
@@ -961,6 +978,8 @@ For your LangGraph setup, default endpoint target is `http://localhost:3000/open
961978
- `scripts/stack_profile_command.py` - backend script for `/stack`
962979
- `scripts/browser_command.py` - backend script for `/browser`
963980
- `scripts/start_work_command.py` - backend script for `/start-work`
981+
- `scripts/todo_command.py` - backend script for `/todo`
982+
- `scripts/todo_enforcement.py` - shared todo compliance enforcement helpers
964983
- `scripts/install_wizard.py` - interactive install/reconfigure wizard
965984
- `scripts/nvim_integration_command.py` - backend script for `/nvim`
966985
- `scripts/devtools_command.py` - backend script for `/devtools`

install.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ fi
7575
if [ -f "$INSTALL_DIR/scripts/start_work_command.py" ]; then
7676
chmod +x "$INSTALL_DIR/scripts/start_work_command.py"
7777
fi
78+
if [ -f "$INSTALL_DIR/scripts/todo_command.py" ]; then
79+
chmod +x "$INSTALL_DIR/scripts/todo_command.py"
80+
fi
7881
ln -sfn "$INSTALL_DIR/opencode.json" "$CONFIG_PATH"
7982

8083
if [ "$RUN_WIZARD" = true ]; then
@@ -120,6 +123,10 @@ if [ "$SKIP_SELF_CHECK" = false ]; then
120123
python3 "$INSTALL_DIR/scripts/start_work_command.py" deviations --json
121124
python3 "$INSTALL_DIR/scripts/start_work_command.py" doctor --json
122125
fi
126+
if [ -f "$INSTALL_DIR/scripts/todo_command.py" ]; then
127+
python3 "$INSTALL_DIR/scripts/todo_command.py" status --json
128+
python3 "$INSTALL_DIR/scripts/todo_command.py" enforce --json
129+
fi
123130
python3 "$INSTALL_DIR/scripts/nvim_integration_command.py" status
124131
python3 "$INSTALL_DIR/scripts/devtools_command.py" status
125132
python3 "$INSTALL_DIR/scripts/doctor_command.py" run || true
@@ -183,6 +190,8 @@ printf " /start-work-bg ~/.config/opencode/my_opencode/plan.md\n"
183190
printf " /start-work status --json\n"
184191
printf " /start-work deviations --json\n"
185192
printf " /start-work-doctor-json\n"
193+
printf " /todo status --json\n"
194+
printf " /todo enforce --json\n"
186195
printf " /nvim status\n"
187196
printf " /devtools status\n"
188197
printf " /devtools install all\n"

opencode.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,18 @@
290290
"description": "Run plan execution health diagnostics in JSON",
291291
"template": "!`python3 \"$HOME/.config/opencode/my_opencode/scripts/start_work_command.py\" doctor --json`\nShow only the command output."
292292
},
293+
"todo": {
294+
"description": "Inspect todo compliance state (status|enforce)",
295+
"template": "!`python3 \"$HOME/.config/opencode/my_opencode/scripts/todo_command.py\" $ARGUMENTS`\nShow only the command output."
296+
},
297+
"todo-status": {
298+
"description": "Show latest todo compliance status",
299+
"template": "!`python3 \"$HOME/.config/opencode/my_opencode/scripts/todo_command.py\" status --json`\nShow only the command output."
300+
},
301+
"todo-enforce": {
302+
"description": "Run todo compliance enforcement checks in JSON",
303+
"template": "!`python3 \"$HOME/.config/opencode/my_opencode/scripts/todo_command.py\" enforce --json`\nShow only the command output."
304+
},
293305
"nvim": {
294306
"description": "Manage Neovim OpenCode integration (status|doctor|snippet|install|uninstall)",
295307
"template": "!`python3 \"$HOME/.config/opencode/my_opencode/scripts/nvim_integration_command.py\" $ARGUMENTS`\nShow only the command output."

scripts/doctor_command.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,18 @@ def script_path(name: str) -> Path:
192192
"--json",
193193
],
194194
},
195+
{
196+
"name": "todo",
197+
"kind": "doctor-json",
198+
"optional": True,
199+
"required_path": str(script_path("todo_command.py")),
200+
"command": [
201+
sys.executable,
202+
str(script_path("todo_command.py")),
203+
"enforce",
204+
"--json",
205+
],
206+
},
195207
]
196208

197209

0 commit comments

Comments
 (0)