Harden the execute→review pipeline so that by the time a plan reaches DONE, every task has verifiable evidence of completion. During execution: require the executor to return structured per-task evidence (files_changed, commands_run) that can be cross-checked against the actual git diff; require preliminary sense-check acknowledgments from the executor (not just reviewer). Between execute and review: add a programmatic validation pass that audits executor claims against repo state — did the claimed files actually change? do executor_notes reference real artifacts? are sense checks acknowledged? During review: reviewer cross-references executor evidence with git diff and fills verdicts. The whole loop should be thorough but not cumbersome — no new CLI flags, no interactive prompts, enforcement is automatic and invisible on the happy path. The goal: when a plan hits DONE, you can read finalize.json and have complete auditable evidence of what was done, why, and whether it checks out.
User notes and answers:
Ease of agentic use is extremely important. The executor agent needs to understand what's expected without confusion. Enforcement should be robust but the interface (schema, prompts, error messages) must be simple and clear. Don't make the executor jump through hoops — make the right thing easy and the wrong thing impossible.
Two additional requirements before execution:
PROMPT QUALITY FOR AGENTS: The execute and review prompts must be example-driven, not prose-driven. Show the executor a concrete JSON example of the expected output shape (task_updates with files_changed, commands_run; sense_check_acknowledgments with notes). Show the reviewer how to work: trust executor evidence by default, add your own detail where things seem ambiguous or audit flags something, don't re-verify everything from scratch. The sense check experience should be: executor acknowledges each check with a brief note during execution, reviewer confirms or digs deeper only where needed.
REVIEW-TO-EXECUTE KICKBACK LOOP: If the reviewer finds that work itself is incomplete (not just paperwork — actual tasks that weren't done properly), they should be able to kick the plan back to execute. Add a review verdict that triggers STATE_EXECUTED -> STATE_FINALIZED transition with next_step='execute', preserving review findings as context for the re-execution. The executor on re-run sees what the reviewer flagged and addresses it. This creates a mini execute<->review loop that can run multiple times until the reviewer is satisfied. The review.json should carry forward so the executor knows what was flagged.
code
Assistant
User
Assistant
The remaining work is the reviewer-requested rework in handle_execute, handle_review, and their tests. I’m checking the current tree to confirm whether those softening paths are still present, but this session is read-only, so if code changes are still needed I’ll have to stop at a concrete blocker report.
Assistant
I could not execute the rework because this session is read-only. The remaining reviewer-blocked gaps are still present in handlers.py and handlers.py: execute still treats plus non-empty as advisory, and review still treats empty plus substantive reviewer text as advisory. The tests still encode that softened behavior in and .
Execution tracking source of truth (`finalize.json`):
{
"tasks": [
{
"id": "T1",
"description": "Add per-task evidence fields (files_changed, commands_run) to execution.json task_updates schema, add sense_check_acknowledgments top-level array to execution.json schema, and add evidence fields (files_changed, commands_run, evidence_files, executor_note) with empty defaults to finalize.json and review.json schemas in megaplan/schemas.py",
"depends_on": [],
"status": "pending",
"executor_notes": "",
"reviewer_verdict": ""
},
{
"id": "T2",
"description": "Update execute prompt (megaplan/prompts.py:398-430) to instruct the executor to return per-task files_changed and commands_run in task_updates, and to return sense_check_acknowledgments with sense_check_id and executor_note for each sense check. Use example-driven format showing exact expected output shape.",
"depends_on": [
"T1"
],
"status": "pending",
"executor_notes": "",
"reviewer_verdict": ""
},
{
"id": "T3",
"description": "Update review prompts (_review_claude_prompt and _review_codex_prompt in megaplan/prompts.py:433-520) to require evidence_files in each task verdict, instruct cross-referencing executor per-task files_changed against git diff, verify sense-check acknowledgment quality, and include execution_audit.json findings if the file exists (graceful skip if absent).",
"depends_on": [
"T1"
],
"status": "pending",
"executor_notes": "",
"reviewer_verdict": ""
},
{
"id": "T4",
"description": "Extend _validate_merge_inputs (megaplan/handlers.py:183-228) with array_fields: tuple[str, ...] = () parameter. Array fields validated with isinstance(value, list) instead of isinstance(value, str), copied to normalized dict. Update return type to list[dict[str, Any]]. Update _merge_validated_entries type annotation to list[dict[str, Any]] (logic unchanged \u2014 target[field] = entry[field] already works for any type).",
"depends_on": [],
"status": "pending",
"executor_notes": "",
"reviewer_verdict": ""
},
{
"id": "T5",
"description": "Update mock workers (megaplan/workers.py:340-411): mock finalize adds files_changed: [], commands_run: [], evidence_files: [] on tasks and executor_note: '' on sense_checks. Mock execute adds per-task files_changed and commands_run in task_updates and adds sense_check_acknowledgments. Mock review adds evidence_files in each task_verdict.",
"depends_on": [
"T1"
],
"status": "pending",
"executor_notes": "",
"reviewer_verdict": ""
},
{
"id": "T6",
"description": "Update handle_execute (megaplan/handlers.py:1110-1139): pass array_fields=('files_changed', 'commands_run') to _validate_merge_inputs for task_updates; extend merge_fields to include files_changed and commands_run; add sense_check_acknowledgments merge block (validate, merge executor_note into sense_checks, block if unacked_checks > 0); add per-task evidence enforcement \u2014 block if done task has empty files_changed AND empty commands_run (FLAG-006 softening: if commands_run is non-empty, downgrade to advisory deviation instead of blocking).",
"depends_on": [
"T4"
],
"status": "pending",
"executor_notes": "",
"reviewer_verdict": ""
},
{
"id": "T7",
"description": "Implement validate_execution_evidence(finalize_data, project_dir) in megaplan/evaluation.py. Returns dict with findings, files_in_diff, files_claimed, skipped, reason. Uses git status --short (matching collect_git_diff_summary pattern). Four non-fatal fallback paths: no .git, FileNotFoundError, TimeoutExpired, non-zero returncode. Check 1: phantom claims vs unclaimed changes. Check 2: path-like tokens in executor_notes checked for existence. Check 3: perfunctory sense-check acknowledgments (<10 chars or generic patterns).",
"depends_on": [
"T6"
],
"status": "pending",
"executor_notes": "",
"reviewer_verdict": ""
},
{
"id": "T8",
"description": "Wire validate_execution_evidence into handle_execute (after task merge, before writing finalize.json). Write result to execution_audit.json in plan_dir. Append findings to deviations as advisory (non-blocking). Add execution_audit.json to artifacts list.",
"depends_on": [
"T7"
],
"status": "pending",
"executor_notes": "",
"reviewer_verdict": ""
},
{
"id": "T9",
"description": "Update handle_review (megaplan/handlers.py:1191-1280): pass array_fields=('evidence_files',) to _validate_merge_inputs for task_verdicts; extend merge_fields to include evidence_files; add per-task evidence enforcement \u2014 block if done task has empty evidence_files AND reviewer_verdict doesn't substantively reference command output (FLAG-006 softening: if reviewer_verdict is substantive, downgrade to advisory deviation).",
"depends_on": [
"T4"
],
"status": "pending",
"executor_notes": "",
"reviewer_verdict": ""
},
{
"id": "T10",
"description": "Update render_final_md (megaplan/_core.py:92-142) to render per-task files_changed (indented list under each task when non-empty), executor_note on sense checks, and evidence_files under reviewer verdict (when non-empty). Keep existing gap-detection logic intact.",
"depends_on": [
"T1"
],
"status": "pending",
"executor_notes": "",
"reviewer_verdict": ""
},
{
"id": "T11",
"description": "Write tests: unit test validate_execution_evidence with mocked git status (modified, untracked, renamed, deleted; graceful skip for all four fallback paths including non-zero returncode); unit test _validate_merge_inputs with array_fields; update existing schema/handler/render test fixtures to include new required fields; test blocking behavior for empty evidence on done tasks; test FLAG-006 softening (done task with empty files_changed but non-empty commands_run is not blocked). Run full test suite.",
"depends_on": [
"T7",
"T8",
"T6",
"T9",
"T10",
"T5"
],
"status": "pending",
"executor_notes": "",
"reviewer_verdict": ""
}
],
"watch_items": [
"FLAG-006: Do NOT block execute when a done task has empty files_changed but non-empty commands_run \u2014 treat as advisory deviation. Same principle for review: empty evidence_files with substantive reviewer_verdict is a deviation, not a blocker. This handles verification-only tasks.",
"strict_schema() (schemas.py:189-196) forces ALL declared properties to be required and sets additionalProperties: false. Every new field added to schemas will be required in agent-facing output. Empty arrays [] are the valid value for skipped tasks \u2014 not missing fields.",
"_validate_merge_inputs currently only handles string fields (isinstance check at line 210). T4 MUST land before T6/T9 or array evidence fields will be silently stripped during merge, causing data loss.",
"The sense_check_acknowledgments merge needs a targets_by_id built from finalize_data sense_checks (keyed by 'id'), not from tasks. Don't confuse the two ID spaces.",
"validate_execution_evidence must handle four failure modes from git status: (1) no .git directory, (2) git not on PATH (FileNotFoundError), (3) timeout, (4) non-zero returncode (empty .git dirs in test scaffolds at tests/test_prompts.py:54 and tests/test_megaplan.py:67). All return skipped=True, never raise.",
"Existing top-level files_changed and commands_run in execution.json are summary fields and must be preserved alongside the new per-task fields \u2014 they serve different purposes (summary vs attribution).",
"The review prompt must gracefully handle missing execution_audit.json (first-time runs, non-git environments). Use conditional read, not hard dependency.",
"Keep executor-facing schema and prompt changes minimal and example-driven. The executor should see exactly what shape to return, no ambiguity. This is the user's top priority.",
"commands_run is intentionally NOT enforced non-empty for done tasks \u2014 some tasks are pure file edits. Only files_changed non-emptiness is enforced (softened by FLAG-006 for verification-only tasks).",
"Return type annotations on _validate_merge_inputs and _merge_validated_entries must change from list[dict[str, str]] to list[dict[str, Any]] to accommodate array fields."
],
"sense_checks": [
{
"id": "SC1",
"task_id": "T1",
"question": "Do the new schema fields in execution.json, finalize.json, and review.json all survive strict_schema() \u2014 i.e., are they declared as properties (not just defaults) so they become required?",
"verdict": ""
},
{
"id": "SC2",
"task_id": "T2",
"question": "Does the execute prompt show the executor the exact expected JSON shape for task_updates (with files_changed, commands_run) and sense_check_acknowledgments, with a concrete example?",
"verdict": ""
},
{
"id": "SC3",
"task_id": "T3",
"question": "Do both review prompts (Claude and Codex) include the execution_audit.json read with a graceful fallback if the file doesn't exist?",
"verdict": ""
},
{
"id": "SC4",
"task_id": "T4",
"question": "Does _validate_merge_inputs correctly validate array fields with isinstance(value, list) and skip entries where an array field is not a list, without breaking existing string-field validation?",
"verdict": ""
},
{
"id": "SC5",
"task_id": "T5",
"question": "Do mock workers produce payloads that pass schema validation with all new required fields populated (including empty arrays for skipped tasks)?",
"verdict": ""
},
{
"id": "SC6",
"task_id": "T6",
"question": "Does handle_execute correctly implement FLAG-006 softening \u2014 blocking only when a done task has BOTH empty files_changed AND empty commands_run, treating empty files_changed with non-empty commands_run as advisory deviation?",
"verdict": ""
},
{
"id": "SC7",
"task_id": "T7",
"question": "Does validate_execution_evidence handle all four git failure modes (no .git, FileNotFoundError, TimeoutExpired, non-zero returncode) by returning skipped=True without raising?",
"verdict": ""
},
{
"id": "SC8",
"task_id": "T8",
"question": "Are audit findings appended to deviations as advisory (non-blocking) and is execution_audit.json written before finalize.json so the reviewer can reference it?",
"verdict": ""
},
{
"id": "SC9",
"task_id": "T9",
"question": "Does handle_review implement FLAG-006 softening for evidence_files \u2014 not blocking when a done task has empty evidence_files but a substantive reviewer_verdict?",
"verdict": ""
},
{
"id": "SC10",
"task_id": "T10",
"question": "Does render_final_md correctly render the new fields (files_changed list, executor_note, evidence_files) without breaking existing gap-detection logic?",
"verdict": ""
},
{
"id": "SC11",
"task_id": "T11",
"question": "Does the full test suite pass, including tests for FLAG-006 softening (done task with commands_run but no files_changed is not blocked)?",
"verdict": ""
}
],
"meta_commentary": "Execution order: T1 and T4 are independent and can run in parallel (schemas and helper extension). T2, T3, T5, T10 depend only on T1. T6 and T9 depend on T4. T7 depends on T6. T8 depends on T7. T11 depends on everything else.\n\nCritical judgment call \u2014 FLAG-006 softening: The plan's Step 7 says 'block if done task has empty files_changed.' The gate warning says to NOT block when commands_run is non-empty. Implement the softened version: block only when BOTH files_changed AND commands_run are empty for a done task. Same principle for Step 10 / evidence_files \u2014 if reviewer_verdict is substantive (>20 chars), treat empty evidence_files as advisory. This avoids forcing agents to invent file attribution for verification-only tasks.\n\nThe _validate_merge_inputs extension (T4) is the keystone \u2014 without it, array fields silently vanish during merge. Prioritize getting this right. The fix is surgical: add an array_fields parameter, validate with isinstance(value, list), copy to normalized dict. The existing _merge_validated_entries logic (target[field] = entry[field]) already works for any type \u2014 only the type annotation needs updating.\n\nFor the sense_check_acknowledgments merge in T6: build targets_by_id from finalize_data['sense_checks'] keyed by 'id' field (not 'sense_check_id'). The executor returns sense_check_id in its acknowledgments, but the finalize.json sense_checks use 'id'. The _merge_validated_entries id_field should be 'sense_check_id' and targets_by_id should be keyed by the sense_check 'id' values.\n\nThe execution_audit.json is advisory-only \u2014 findings go into deviations for visibility but never set blocked=True. The blocking guarantees come from the handler-level checks (empty evidence arrays) and schema-level enforcement (required fields). This separation keeps the audit from creating false-positive blocks while still surfacing useful cross-check information for the reviewer.\n\nRun existing tests after T1+T4+T5 to catch any fixture breakage early. The test fixtures in tests/ construct execution.json and review.json payloads that will need the new required fields added."
}
code
Plan metadata:
{
"version": 3,
"timestamp": "2026-03-25T02:35:04Z",
"hash": "sha256:af55ff5e059d3c0e617f36461a3abeede5f73aee14030fa79896597286d98282",
"changes_summary": "Surgical fixes for the three remaining flags \u2014 no structural changes to the plan, just closing the specific gaps:\n\nFLAG-003 (DONE enforcement): Added explicit blocking checks for empty evidence arrays. In Step 7: after merging task_updates, iterate done tasks \u2014 if any has empty files_changed, block execute. In Step 10: after merging task_verdicts, iterate done tasks \u2014 if any has empty evidence_files, block review. commands_run is intentionally not enforced (some tasks are pure file edits). This closes the gap between "required in schema" (agent must return the field) and "non-empty at DONE" (the field must have content for done tasks).\n\nFLAG-004 (non-zero returncode): Added the fourth fallback path explicitly in Step 8: if process.returncode != 0: return {\"findings\": [], \"skipped\": True, \"reason\": f\"git status failed: {stderr}\"}. This matches collect_git_diff_summary's handling at _core.py:417-418 and covers the empty .git directory case used in test scaffolds.\n\nFLAG-005 (merge helpers strip array fields): Added Step 6 as a dedicated step to extend _validate_merge_inputs. The fix adds an array_fields: tuple[str, ...] = () parameter. Array fields get validated with isinstance(value, list) instead of isinstance(value, str), and copied to the normalized dict alongside string fields. Return type annotation updated to dict[str, Any]. _merge_validated_entries already handles any type via target[field] = entry[field], so it only needs a type annotation update. Steps 7 and 10 now show the exact call signatures with array_fields= parameter.",
"flags_addressed": [
"FLAG-003",
"FLAG-004",
"FLAG-005"
],
"questions": [],
"success_criteria": [
"Every task in finalize.json at STATE_DONE has non-empty files_changed, executor_notes, and reviewer_verdict fields (enforced by handler blocking on empty arrays + required schema fields)",
"Every task in finalize.json at STATE_DONE has non-empty evidence_files from the reviewer (enforced by handle_review blocking)",
"Every sense_check in finalize.json at STATE_DONE has a non-empty executor_note and reviewer verdict (enforced by blocking on incomplete acknowledgment coverage)",
"execution_audit.json exists after every execute step and contains programmatic cross-check of claimed vs actual file changes",
"Phantom file claims (executor says file changed but git status disagrees) are detected and surfaced in audit findings",
"Unclaimed changes (file in git status but not claimed by any task) are detected and surfaced in audit findings",
"Review prompts include audit findings so the reviewer can act on discrepancies",
"New fields are required in agent-facing schemas \u2014 agents always return them, no ambiguity",
"No new CLI flags or interactive prompts are introduced",
"Audit validation degrades gracefully in all non-git scenarios: missing .git, missing git binary, timeout, AND non-zero returncode from empty .git directories",
"Existing test suite passes after updating test fixtures to include new required fields",
"render_final_md shows the enriched evidence when present",
"Mock workers produce valid payloads with all new fields",
"_validate_merge_inputs correctly carries array fields (files_changed, commands_run, evidence_files) through validation without stripping them"
],
"assumptions": [
"Per-task files_changed and commands_run are executor-reported claims, not system-captured. The audit validates claims against git state but doesn't independently log commands. Acceptable since the executor is an LLM agent that can only self-report.",
"The git status check uses git status --short (matching existing collect_git_diff_summary). This captures modified, added, deleted, renamed, and untracked files. Committed-then-amended changes that are no longer dirty won't appear \u2014 assumed acceptable.",
"Making all new fields required in the schema means plans created before this version will need megaplan init re-run to regenerate schema files. This is standard for schema-breaking changes and acceptable.",
"The execution_audit.json artifact is written alongside execution.json and finalize.json \u2014 no separate CLI step or state transition needed.",
"Sense-check acknowledgment coverage blocking uses the same pattern as task coverage: if executor doesn't acknowledge all sense checks, execute is blocked and must re-run.",
"The path-extraction regex for executor_notes validation is simple (tokens with / and file extensions). False positives are acceptable since findings are advisory for the reviewer.",
"commands_run is not enforced non-empty for done tasks \u2014 some tasks are pure file edits with no shell commands. Only files_changed is enforced non-empty since every done task must touch at least one file.",
"Reviewer evidence_files is enforced non-empty for done tasks \u2014 the reviewer must cite at least one file they verified. For skipped tasks, empty is valid."
],
"structure_warnings": [],
"delta_from_previous_percent": 30.3
}
code
Gate summary:
{
"passed": true,
"criteria_check": {
"count": 14,
"items": [
"Every task in finalize.json at STATE_DONE has non-empty files_changed, executor_notes, and reviewer_verdict fields (enforced by handler blocking on empty arrays + required schema fields)",
"Every task in finalize.json at STATE_DONE has non-empty evidence_files from the reviewer (enforced by handle_review blocking)",
"Every sense_check in finalize.json at STATE_DONE has a non-empty executor_note and reviewer verdict (enforced by blocking on incomplete acknowledgment coverage)",
"execution_audit.json exists after every execute step and contains programmatic cross-check of claimed vs actual file changes",
"Phantom file claims (executor says file changed but git status disagrees) are detected and surfaced in audit findings",
"Unclaimed changes (file in git status but not claimed by any task) are detected and surfaced in audit findings",
"Review prompts include audit findings so the reviewer can act on discrepancies",
"New fields are required in agent-facing schemas \u2014 agents always return them, no ambiguity",
"No new CLI flags or interactive prompts are introduced",
"Audit validation degrades gracefully in all non-git scenarios: missing .git, missing git binary, timeout, AND non-zero returncode from empty .git directories",
"Existing test suite passes after updating test fixtures to include new required fields",
"render_final_md shows the enriched evidence when present",
"Mock workers produce valid payloads with all new fields",
"_validate_merge_inputs correctly carries array fields (files_changed, commands_run, evidence_files) through validation without stripping them"
]
},
"preflight_results": {
"project_dir_exists": true,
"project_dir_writable": true,
"success_criteria_present": true,
"claude_available": true,
"codex_available": true
},
"unresolved_flags": [
{
"id": "FLAG-006",
"concern": "The plan now over-corrects by assuming every done task must map to at least one changed file. In this repository's task model, some legitimate tasks are verification-only, so blocking execute/review on non-empty files_changed / evidence_files for every done task will force agents to invent file attribution.",
"category": "correctness",
"severity_hint": "likely-significant",
"evidence": "The repo already models non-edit tasks: the mock finalize output creates T2 as \"Verify success criteria\" in megaplan/workers.py:348-354. Your Step 7 would block execute whenever a done task has empty files_changed, and Step 10 would block review whenever a done task has empty evidence_files. For verification-only tasks, the real evidence may be commands/results rather than a touched file, so this enforcement conflicts with the existing workflow shape and the user goal of keeping the agent interface simple and non-confusing.",
"raised_in": "critique_v3.json",
"status": "open",
"severity": "significant",
"verified": false
}
],
"recommendation": "PROCEED",
"rationale": "Score trajectory is steadily improving (4.5\u21923.0\u21922.0), 5 flags resolved across 3 iterations, plan delta narrowing (71%\u219230%), zero recurring critiques. The single remaining flag (FLAG-006) is valid but minor in practice \u2014 the fix is a one-line adjustment during execution: change the blocking check from "all done tasks must have non-empty files_changed" to "done tasks with status 'done' (not 'skipped') that aren't verification-only must have non-empty files_changed", or more simply, downgrade the empty-files_changed check from blocking to deviation for tasks where commands_run is non-empty (evidence exists, just not file-based). This is a small implementation-time judgment call, not a plan-level design flaw. Further iteration risks diminishing returns and churn on an increasingly mature plan.",
"signals_assessment": "Iteration 3, weighted score 2.0 on steady downward trajectory (4.5\u21923.0\u21922.0). Plan delta narrowing appropriately (71%\u219230%). Five flags resolved, zero recurring critiques, zero scope creep. Single remaining FLAG-006 is a real but bounded concern about over-enforcement on verification-only tasks \u2014 it doesn't threaten the architectural design, just needs the executor to soften one blocking condition to a deviation when files_changed is empty but commands_run is non-empty. Preflight all green.",
"warnings": [
"FLAG-006: During implementation of Step 7, do NOT block execute when a done task has empty files_changed but non-empty commands_run. Treat that case as a deviation (advisory), not a blocker. This handles verification-only tasks that run commands but don't edit files. Same principle applies to Step 10 for evidence_files \u2014 if the reviewer's verdict references command output rather than files, empty evidence_files with a substantive reviewer_verdict should be a deviation, not a blocker."
],
"override_forced": false,
"orchestrator_guidance": "Plan passed gate and preflight. Proceed to finalize. Verify unresolved flags against the plan and project code before accepting.",
"robustness": "standard",
"signals": {
"iteration": 3,
"idea": "Harden the execute\u2192review pipeline so that by the time a plan reaches DONE, every task has verifiable evidence of completion. During execution: require the executor to return structured per-task evidence (files_changed, commands_run) that can be cross-checked against the actual git diff; require preliminary sense-check acknowledgments from the executor (not just reviewer). Between execute and review: add a programmatic validation pass that audits executor claims against repo state \u2014 did the claimed files actually change? do executor_notes reference real artifacts? are sense checks acknowledged? During review: reviewer cross-references executor evidence with git diff and fills verdicts. The whole loop should be thorough but not cumbersome \u2014 no new CLI flags, no interactive prompts, enforcement is automatic and invisible on the happy path. The goal: when a plan hits DONE, you can read finalize.json and have complete auditable evidence of what was done, why, and whether it checks out.",
"significant_flags": 1,
"unresolved_flags": [
{
"id": "FLAG-006",
"concern": "The plan now over-corrects by assuming every done task must map to at least one changed file. In this repository's task model, some legitimate tasks are verification-only, so blocking execute/review on non-empty files_changed / evidence_files for every done task will force agents to invent file attribution.",
"category": "correctness",
"severity": "significant",
"status": "open"
}
],
"resolved_flags": [
{
"id": "FLAG-001",
"concern": "The backward-compatibility claim is not achievable as written: adding new "optional" evidence fields to execution.json, finalize.json, or review.json will make them required in the agent-facing schemas unless strict_schema() changes too.",
"resolution": "Revised plan to address all four significant critique flags:\n\n1. FLAG-001 (strict_schema makes all fields required): Flipped the design from "optional fields" to "required fields with empty defaults." Since strict_schema() forces all properties to be required and additionalProperties: false prevents extra fields, we embrace this \u2014 all new evidence fields are required in the schema. Empty arrays [] are valid for skipped tasks. No changes to strict_schema() needed. This is actually clearer for agents.\n\n2. FLAG-002 (wrong git command): Replaced git diff --name-only with git status --short throughout the audit logic, matching the existing collect_git_diff_summary() pattern at _core.py:402-419. This catches untracked files, staged changes, and deletions \u2014 all the states the pipeline already surfaces.\n\n3. FLAG-003 (no DONE enforcement): Now that fields are required in the schema, the agent literally cannot return a valid payload without them. Additionally: sense-check acknowledgment coverage now blocks (same pattern as task coverage blocking). Per-task evidence completeness is checked (done tasks must have non-empty files_changed). The DONE guarantee is enforced structurally.\n\n4. FLAG-004 (non-git test environments):validate_execution_evidence() follows collect_git_diff_summary()'s exact non-fatal pattern: check .git exists, catch FileNotFoundError, catch TimeoutExpired, return {\"skipped\": true, \"reason\": \"...\"} on any failure. Test environments with empty .git dirs degrade gracefully.\n\nAlso simplified the sense-check acknowledgment schema from three fields (sense_check_id, acknowledged, executor_note) to two (sense_check_id, executor_note) \u2014 the boolean was redundant since presence of a note implies acknowledgment. Fewer fields = easier for the agent."
},
{
"id": "FLAG-002",
"concern": "The proposed file-audit basis is wrong for this repository: git diff --name-only will miss normal changes that the current pipeline surfaces, especially new untracked files, so the audit will report false phantom/unclaimed discrepancies.",
"resolution": "Revised plan to address all four significant critique flags:\n\n1. FLAG-001 (strict_schema makes all fields required): Flipped the design from "optional fields" to "required fields with empty defaults." Since strict_schema() forces all properties to be required and additionalProperties: false prevents extra fields, we embrace this \u2014 all new evidence fields are required in the schema. Empty arrays [] are valid for skipped tasks. No changes to strict_schema() needed. This is actually clearer for agents.\n\n2. FLAG-002 (wrong git command): Replaced git diff --name-only with git status --short throughout the audit logic, matching the existing collect_git_diff_summary() pattern at _core.py:402-419. This catches untracked files, staged changes, and deletions \u2014 all the states the pipeline already surfaces.\n\n3. FLAG-003 (no DONE enforcement): Now that fields are required in the schema, the agent literally cannot return a valid payload without them. Additionally: sense-check acknowledgment coverage now blocks (same pattern as task coverage blocking). Per-task evidence completeness is checked (done tasks must have non-empty files_changed). The DONE guarantee is enforced structurally.\n\n4. FLAG-004 (non-git test environments):validate_execution_evidence() follows collect_git_diff_summary()'s exact non-fatal pattern: check .git exists, catch FileNotFoundError, catch TimeoutExpired, return {\"skipped\": true, \"reason\": \"...\"} on any failure. Test environments with empty .git dirs degrade gracefully.\n\nAlso simplified the sense-check acknowledgment schema from three fields (sense_check_id, acknowledged, executor_note) to two (sense_check_id, executor_note) \u2014 the boolean was redundant since presence of a note implies acknowledgment. Fewer fields = easier for the agent."
},
{
"id": "FLAG-003",
"concern": "The DONE guarantee is still not fully enforced. The revised plan makes the new fields required in the payload shape, but it still allows key evidence fields to stay empty and remain non-blocking, so a plan can reach DONE without the non-empty per-task evidence promised in the success criteria.",
"resolution": "Surgical fixes for the three remaining flags \u2014 no structural changes to the plan, just closing the specific gaps:\n\nFLAG-003 (DONE enforcement): Added explicit blocking checks for empty evidence arrays. In Step 7: after merging task_updates, iterate done tasks \u2014 if any has empty files_changed, block execute. In Step 10: after merging task_verdicts, iterate done tasks \u2014 if any has empty evidence_files, block review. commands_run is intentionally not enforced (some tasks are pure file edits). This closes the gap between "required in schema" (agent must return the field) and "non-empty at DONE" (the field must have content for done tasks).\n\nFLAG-004 (non-zero returncode): Added the fourth fallback path explicitly in Step 8: if process.returncode != 0: return {\"findings\": [], \"skipped\": True, \"reason\": f\"git status failed: {stderr}\"}. This matches collect_git_diff_summary's handling at _core.py:417-418 and covers the empty .git directory case used in test scaffolds.\n\nFLAG-005 (merge helpers strip array fields): Added Step 6 as a dedicated step to extend _validate_merge_inputs. The fix adds an array_fields: tuple[str, ...] = () parameter. Array fields get validated with isinstance(value, list) instead of isinstance(value, str), and copied to the normalized dict alongside string fields. Return type annotation updated to dict[str, Any]. _merge_validated_entries already handles any type via target[field] = entry[field], so it only needs a type annotation update. Steps 7 and 10 now show the exact call signatures with array_fields= parameter."
},
{
"id": "FLAG-004",
"concern": "The non-git fallback is still incomplete for this repository's actual test scaffolds. The revised plan handles missing .git, missing git, and timeouts, but it still does not cover the non-zero git status case caused by the empty .git directories used in tests.",
"resolution": "Surgical fixes for the three remaining flags \u2014 no structural changes to the plan, just closing the specific gaps:\n\nFLAG-003 (DONE enforcement): Added explicit blocking checks for empty evidence arrays. In Step 7: after merging task_updates, iterate done tasks \u2014 if any has empty files_changed, block execute. In Step 10: after merging task_verdicts, iterate done tasks \u2014 if any has empty evidence_files, block review. commands_run is intentionally not enforced (some tasks are pure file edits). This closes the gap between "required in schema" (agent must return the field) and "non-empty at DONE" (the field must have content for done tasks).\n\nFLAG-004 (non-zero returncode): Added the fourth fallback path explicitly in Step 8: if process.returncode != 0: return {\"findings\": [], \"skipped\": True, \"reason\": f\"git status failed: {stderr}\"}. This matches collect_git_diff_summary's handling at _core.py:417-418 and covers the empty .git directory case used in test scaffolds.\n\nFLAG-005 (merge helpers strip array fields): Added Step 6 as a dedicated step to extend _validate_merge_inputs. The fix adds an array_fields: tuple[str, ...] = () parameter. Array fields get validated with isinstance(value, list) instead of isinstance(value, str), and copied to the normalized dict alongside string fields. Return type annotation updated to dict[str, Any]. _merge_validated_entries already handles any type via target[field] = entry[field], so it only needs a type annotation update. Steps 7 and 10 now show the exact call signatures with array_fields= parameter."
},
{
"id": "FLAG-005",
"concern": "The merge steps still do not fit the repository's current helper behavior. As written, Phase 2 assumes the existing merge helpers can carry array fields through execute/review, but _validate_merge_inputs() currently strips them, so files_changed, commands_run, and evidence_files will not merge without an explicit helper redesign.",
"resolution": "Surgical fixes for the three remaining flags \u2014 no structural changes to the plan, just closing the specific gaps:\n\nFLAG-003 (DONE enforcement): Added explicit blocking checks for empty evidence arrays. In Step 7: after merging task_updates, iterate done tasks \u2014 if any has empty files_changed, block execute. In Step 10: after merging task_verdicts, iterate done tasks \u2014 if any has empty evidence_files, block review. commands_run is intentionally not enforced (some tasks are pure file edits). This closes the gap between "required in schema" (agent must return the field) and "non-empty at DONE" (the field must have content for done tasks).\n\nFLAG-004 (non-zero returncode): Added the fourth fallback path explicitly in Step 8: if process.returncode != 0: return {\"findings\": [], \"skipped\": True, \"reason\": f\"git status failed: {stderr}\"}. This matches collect_git_diff_summary's handling at _core.py:417-418 and covers the empty .git directory case used in test scaffolds.\n\nFLAG-005 (merge helpers strip array fields): Added Step 6 as a dedicated step to extend _validate_merge_inputs. The fix adds an array_fields: tuple[str, ...] = () parameter. Array fields get validated with isinstance(value, list) instead of isinstance(value, str), and copied to the normalized dict alongside string fields. Return type annotation updated to dict[str, Any]. _merge_validated_entries already handles any type via target[field] = entry[field], so it only needs a type annotation update. Steps 7 and 10 now show the exact call signatures with array_fields= parameter."
}
],
"weighted_score": 2.0,
"weighted_history": [
4.5,
3.0
],
"plan_delta_from_previous": 30.3,
"recurring_critiques": [],
"scope_creep_flags": [],
"loop_summary": "Iteration 3. Weighted score trajectory: 4.5 -> 3.0 -> 2.0. Plan deltas: 71.3%, 30.3%. Recurring critiques: 0. Resolved flags: 5. Open significant flags: 1."
}
}
code
Note: User explicitly approved this plan at the gate checkpoint.
Robustness level: standard.
Requirements:
- Implement the intent, not just the text.
- Adapt if repository reality contradicts the plan.
- Report deviations explicitly.
- Output concrete files changed and commands run.
- Use the tasks in `finalize.json` as the execution boundary. Do not create or rewrite tracking artifacts directly.
- Return `task_updates` with one object per completed or skipped task: `{"task_id": "...", "status": "done|skipped", "executor_notes": "..."}`.
- Keep `executor_notes` specific enough that a reviewer can map each update to the actual code and commands you ran.
Sense checks to keep in mind during execution (reviewer will verify these):
SC1 (T1): Do the new schema fields in execution.json, finalize.json, and review.json all survive strict_schema() — i.e., are they declared as properties (not just defaults) so they become required?
SC2 (T2): Does the execute prompt show the executor the exact expected JSON shape for task_updates (with files_changed, commands_run) and sense_check_acknowledgments, with a concrete example?
SC3 (T3): Do both review prompts (Claude and Codex) include the execution_audit.json read with a graceful fallback if the file doesn't exist?
SC4 (T4): Does _validate_merge_inputs correctly validate array fields with isinstance(value, list) and skip entries where an array field is not a list, without breaking existing string-field validation?
SC5 (T5): Do mock workers produce payloads that pass schema validation with all new required fields populated (including empty arrays for skipped tasks)?
SC6 (T6): Does handle_execute correctly implement FLAG-006 softening — blocking only when a done task has BOTH empty files_changed AND empty commands_run, treating empty files_changed with non-empty commands_run as advisory deviation?
SC7 (T7): Does validate_execution_evidence handle all four git failure modes (no .git, FileNotFoundError, TimeoutExpired, non-zero returncode) by returning skipped=True without raising?
SC8 (T8): Are audit findings appended to deviations as advisory (non-blocking) and is execution_audit.json written before finalize.json so the reviewer can reference it?
SC9 (T9): Does handle_review implement FLAG-006 softening for evidence_files — not blocking when a done task has empty evidence_files but a substantive reviewer_verdict?
SC10 (T10): Does render_final_md correctly render the new fields (files_changed list, executor_note, evidence_files) without breaking existing gap-detection logic?
SC11 (T11): Does the full test suite pass, including tests for FLAG-006 softening (done task with commands_run but no files_changed is not blocked)?
Watch items to keep visible during execution:
FLAG-006: Do NOT block execute when a done task has empty files_changed but non-empty commands_run — treat as advisory deviation. Same principle for review: empty evidence_files with substantive reviewer_verdict is a deviation, not a blocker. This handles verification-only tasks.
strict_schema() (schemas.py:189-196) forces ALL declared properties to be required and sets additionalProperties: false. Every new field added to schemas will be required in agent-facing output. Empty arrays [] are the valid value for skipped tasks — not missing fields.
_validate_merge_inputs currently only handles string fields (isinstance check at line 210). T4 MUST land before T6/T9 or array evidence fields will be silently stripped during merge, causing data loss.
The sense_check_acknowledgments merge needs a targets_by_id built from finalize_data sense_checks (keyed by 'id'), not from tasks. Don't confuse the two ID spaces.
validate_execution_evidence must handle four failure modes from git status: (1) no .git directory, (2) git not on PATH (FileNotFoundError), (3) timeout, (4) non-zero returncode (empty .git dirs in test scaffolds at tests/test_prompts.py:54 and tests/test_megaplan.py:67). All return skipped=True, never raise.
Existing top-level files_changed and commands_run in execution.json are summary fields and must be preserved alongside the new per-task fields — they serve different purposes (summary vs attribution).
The review prompt must gracefully handle missing execution_audit.json (first-time runs, non-git environments). Use conditional read, not hard dependency.
Keep executor-facing schema and prompt changes minimal and example-driven. The executor should see exactly what shape to return, no ambiguity. This is the user's top priority.
commands_run is intentionally NOT enforced non-empty for done tasks — some tasks are pure file edits. Only files_changed non-emptiness is enforced (softened by FLAG-006 for verification-only tasks).
Return type annotations on _validate_merge_inputs and _merge_validated_entries must change from list[dict[str, str]] to list[dict[str, Any]] to accommodate array fields.
{"output":"Implemented the execute→review hardening end to end. Schemas now require per-task evidence and sense-check acknowledgments in schemas.py, execute/review prompts are example-driven and review-aware in prompts.py, execute now merges evidence, writes execution_audit.json, and enforces the FLAG-006 softening path while review can either approve, block on missing evidence, or route back to execute via review_verdict in handlers.py and handlers.py. The audit pass lives in evaluation.py, and final.md now renders files_changed, sense-check executor notes, and reviewer evidence_files in \u000core.py. Mock workers and tests were updated across workers.py, test_megaplan.py, test_evaluation.py, test_prompts.py, test_schemas.py, and test_workers.py.\n\nCommands run: pytest tests/test_schemas.py tests/test_prompts.py tests/test_workers.py tests/test_evaluation.py tests/test_megaplan.py -q, pytest -q, git status --short, git diff --stat -- megaplan tests. Full test suite passed: 254 passed.\n\nFiles changed: megaplan/_core.py, megaplan/evaluation.py, megaplan/handlers.py, megaplan/prompts.py, megaplan/schemas.py, megaplan/workers.py, tests/test_evaluation.py, tests/test_megaplan.py, tests/test_prompts.py, tests/test_schemas.py, tests/test_workers.py. Deviation from the written task list: I added a required top-level review_verdict field and execute-side reuse of prior review.json so the approved review→execute kickback loop is explicit and machine-enforceable. Existing unrelated worktree change left untouched: scorecard.png.","files_changed":[[REDACTED],[REDACTED],[REDACTED],[REDACTED],[REDACTED],[REDACTED],[REDACTED],[REDACTED],[REDACTED],[REDACTED],[REDACTED]],"commands_run":["pytest tests/test_schemas.py tests/test_prompts.py tests/test_workers.py tests/test_evaluation.py tests/test_megaplan.py -q","pytest -q","git status --short","git diff --stat -- megaplan tests"],"deviations":["Added a required top-level review_verdict field to review.json and corresponding prompt/handler wiring so review can explicitly kick work back to execute, because the approved plan required that behavior but did not define a concrete schema field for it.","Included prior review.json in the execute prompt when present so re-execution sees preserved review findings directly.","Left the pre-existing unrelated scorecard.png modification untouched."],"task_updates":[{"task_id":"T1","status":"done","executor_notes":"Extended strict schemas so finalize tasks now carry files_changed, commands_run, and evidence_files; finalize sense checks now carry executor_note; execution task_updates now require per-task files_changed and commands_run plus top-level sense_check_acknowledgments; review outputs now require evidence_files and a top-level review_verdict for the kickback loop."},{"task_id":"T2","status":"done","executor_notes":"Rewrote the execute prompt to be example-driven with exact JSON output shape for task_updates and sense_check_acknowledgments, and to surface prior review.json findings on re-execution so the executor sees what must be fixed."},{"task_id":"T3","status":"done","executor_notes":"Reworked both review prompts to be example-driven, to trust executor evidence by default, to cross-check per-task files_changed and commands_run against git diff, and to include execution_audit.json with a graceful missing-file fallback."},{"task_id":"T4","status":"done","executor_notes":"Extended _validate_merge_inputs with array_fields support and widened merge helper typing to carry list-valued evidence fields through execute/review merges without stripping them."},{"task_id":"T5","status":"done","executor_notes":"Updated mock finalize/execute/review workers so every new required field is populated, including empty arrays for pending/skipped fields, per-task evidence arrays, sense_check_acknowledgments, and review verdict evidence_files."},{"task_id":"T6","status":"done","executor_notes":"Updated handle_execute to merge per-task files_changed and commands_run, merge sense_check_acknowledgments onto finalize sense_checks by id, block incomplete task/sense-check coverage, and enforce FLAG-006 by blocking only when a done task has both files_changed and commands_run empty while treating command-only tasks as advisory."},{"task_id":"T7","status":"done","executor_notes":"Implemented validate_execution_evidence using git status --short with non-fatal fallback handling for missing .git, missing git binary, timeouts, and non-zero returncode; it audits phantom claims, unclaimed changes, missing note artifacts, and perfunctory sense-check acknowledgments."},{"task_id":"T8","status":"done","executor_notes":"Wired execution auditing into handle_execute so execution_audit.json is written before finalize.json and all audit findings or skips are appended to deviations as advisory, non-blocking signals."},{"task_id":"T9","status":"done","executor_notes":"Updated handle_review to merge evidence_files, enforce reviewer evidence for done tasks, soften FLAG-006 when reviewer_verdict is substantive, and route review_verdict=needs_rework back to STATE_FINALIZED with next_step=execute so review findings carry into the next execution pass."},{"task_id":"T10","status":"done","executor_notes":"Extended render_final_md to show per-task files_changed, per-sense-check executor_note, and reviewer evidence_files while preserving the existing coverage-gap reporting behavior."},{"task_id":"T11","status":"done","executor_notes":"Added unit and flow tests for array-field validation, execution auditing across all git fallback modes, execute/review evidence enforcement, FLAG-006 softening, prompt/schema updates, and the new review-to-execute kickback loop; full pytest suite passes."}]}
Harden the execute→review pipeline so that by the time a plan reaches DONE, every task has verifiable evidence of completion. During execution: require the executor to return structured per-task evidence (files_changed, commands_run) that can be cross-checked against the actual git diff; require preliminary sense-check acknowledgments from the executor (not just reviewer). Between execute and review: add a programmatic validation pass that audits executor claims against repo state — did the claimed files actually change? do executor_notes reference real artifacts? are sense checks acknowledged? During review: reviewer cross-references executor evidence with git diff and fills verdicts. The whole loop should be thorough but not cumbersome — no new CLI flags, no interactive prompts, enforcement is automatic and invisible on the happy path. The goal: when a plan hits DONE, you can read finalize.json and have complete auditable evidence of what was done, why, and whether it checks out.
User notes and answers:
Ease of agentic use is extremely important. The executor agent needs to understand what's expected without confusion. Enforcement should be robust but the interface (schema, prompts, error messages) must be simple and clear. Don't make the executor jump through hoops — make the right thing easy and the wrong thing impossible.
Two additional requirements before execution:
PROMPT QUALITY FOR AGENTS: The execute and review prompts must be example-driven, not prose-driven. Show the executor a concrete JSON example of the expected output shape (task_updates with files_changed, commands_run; sense_check_acknowledgments with notes). Show the reviewer how to work: trust executor evidence by default, add your own detail where things seem ambiguous or audit flags something, don't re-verify everything from scratch. The sense check experience should be: executor acknowledges each check with a brief note during execution, reviewer confirms or digs deeper only where needed.
REVIEW-TO-EXECUTE KICKBACK LOOP: If the reviewer finds that work itself is incomplete (not just paperwork — actual tasks that weren't done properly), they should be able to kick the plan back to execute. Add a review verdict that triggers STATE_EXECUTED -> STATE_FINALIZED transition with next_step='execute', preserving review findings as context for the re-execution. The executor on re-run sees what the reviewer flagged and addresses it. This creates a mini execute<->review loop that can run multiple times until the reviewer is satisfied. The review.json should carry forward so the executor knows what was flagged.
code
Execution tracking source of truth (`finalize.json`):
{
"tasks": [
{
"id": "T1",
"description": "Add per-task evidence fields (files_changed, commands_run) to execution.json task_updates schema, add sense_check_acknowledgments top-level array to execution.json schema, and add evidence fields (files_changed, commands_run, evidence_files, executor_note) with empty defaults to finalize.json and review.json schemas in megaplan/schemas.py",
"depends_on": [],
"status": "done",
"executor_notes": "Extended strict schemas so finalize tasks now carry files_changed, commands_run, and evidence_files; finalize sense checks now carry executor_note; execution task_updates now require per-task files_changed and commands_run plus top-level sense_check_acknowledgments; review outputs now require evidence_files and a top-level review_verdict for the kickback loop.",
"reviewer_verdict": "Pass. The schema changes landed: finalize.json, execution.json, and review.json now declare the new evidence fields and survive strict_schema().",
"evidence_files": [
"megaplan/schemas.py"
]
},
{
"id": "T2",
"description": "Update execute prompt (megaplan/prompts.py:398-430) to instruct the executor to return per-task files_changed and commands_run in task_updates, and to return sense_check_acknowledgments with sense_check_id and executor_note for each sense check. Use example-driven format showing exact expected output shape.",
"depends_on": [
"T1"
],
"status": "done",
"executor_notes": "Rewrote the execute prompt to be example-driven with exact JSON output shape for task_updates and sense_check_acknowledgments, and to surface prior review.json findings on re-execution so the executor sees what must be fixed.",
"reviewer_verdict": "Pass. The execute prompt is example-driven, shows the exact JSON shape for task_updates and sense_check_acknowledgments, and includes prior review.json context for re-execution.",
"evidence_files": [
"megaplan/prompts.py"
]
},
{
"id": "T3",
"description": "Update review prompts (_review_claude_prompt and _review_codex_prompt in megaplan/prompts.py:433-520) to require evidence_files in each task verdict, instruct cross-referencing executor per-task files_changed against git diff, verify sense-check acknowledgment quality, and include execution_audit.json findings if the file exists (graceful skip if absent).",
"depends_on": [
"T1"
],
"status": "done",
"executor_notes": "Reworked both review prompts to be example-driven, to trust executor evidence by default, to cross-check per-task files_changed and commands_run against git diff, and to include execution_audit.json with a graceful missing-file fallback.",
"reviewer_verdict": "Pass. Both review prompts are example-driven, instruct trust-by-default cross-checking, and include the execution_audit.json fallback path.",
"evidence_files": [
"megaplan/prompts.py"
]
},
{
"id": "T4",
"description": "Extend _validate_merge_inputs (megaplan/handlers.py:183-228) with array_fields: tuple[str, ...] = () parameter. Array fields validated with isinstance(value, list) instead of isinstance(value, str), copied to normalized dict. Update return type to list[dict[str, Any]]. Update _merge_validated_entries type annotation to list[dict[str, Any]] (logic unchanged \u2014 target[field] = entry[field] already works for any type).",
"depends_on": [],
"status": "done",
"executor_notes": "Extended _validate_merge_inputs with array_fields support and widened merge helper typing to carry list-valued evidence fields through execute/review merges without stripping them.",
"reviewer_verdict": "Pass. now carries list-valued evidence fields through validation and merge without stripping them.",
"evidence_files": [
"megaplan/handlers.py"
]
},
{
"id": "T5",
"description": "Update mock workers (megaplan/workers.py:340-411): mock finalize adds files_changed: [], commands_run: [], evidence_files: [] on tasks and executor_note: '' on sense_checks. Mock execute adds per-task files_changed and commands_run in task_updates and adds sense_check_acknowledgments. Mock review adds evidence_files in each task_verdict.",
"depends_on": [
"T1"
],
"status": "done",
"executor_notes": "Updated mock finalize/execute/review workers so every new required field is populated, including empty arrays for pending/skipped fields, per-task evidence arrays, sense_check_acknowledgments, and review verdict evidence_files.",
"reviewer_verdict": "Pass. Mock finalize/execute/review payloads include the new required fields and sense-check acknowledgment structures.",
"evidence_files": [
"megaplan/workers.py",
"tests/test_workers.py"
]
},
{
"id": "T6",
"description": "Update handle_execute (megaplan/handlers.py:1110-1139): pass array_fields=('files_changed', 'commands_run') to _validate_merge_inputs for task_updates; extend merge_fields to include files_changed and commands_run; add sense_check_acknowledgments merge block (validate, merge executor_note into sense_checks, block if unacked_checks > 0); add per-task evidence enforcement \u2014 block if done task has empty files_changed AND empty commands_run (FLAG-006 softening: if commands_run is non-empty, downgrade to advisory deviation instead of blocking).",
"depends_on": [
"T4"
],
"status": "done",
"executor_notes": "Updated handle_execute to merge per-task files_changed and commands_run, merge sense_check_acknowledgments onto finalize sense_checks by id, block incomplete task/sense-check coverage, and enforce FLAG-006 by blocking only when a done task has both files_changed and commands_run empty while treating command-only tasks as advisory.",
"reviewer_verdict": "Needs rework. The merge and sense-check acknowledgment logic is correct, but the blocker is softer than the approved success criteria: done tasks may still proceed with when is non-empty.",
"evidence_files": [
"megaplan/handlers.py",
"tests/test_megaplan.py"
]
},
{
"id": "T7",
"description": "Implement validate_execution_evidence(finalize_data, project_dir) in megaplan/evaluation.py. Returns dict with findings, files_in_diff, files_claimed, skipped, reason. Uses git status --short (matching collect_git_diff_summary pattern). Four non-fatal fallback paths: no .git, FileNotFoundError, TimeoutExpired, non-zero returncode. Check 1: phantom claims vs unclaimed changes. Check 2: path-like tokens in executor_notes checked for existence. Check 3: perfunctory sense-check acknowledgments (<10 chars or generic patterns).",
"depends_on": [
"T6"
],
"status": "done",
"executor_notes": "Implemented validate_execution_evidence using git status --short with non-fatal fallback handling for missing .git, missing git binary, timeouts, and non-zero returncode; it audits phantom claims, unclaimed changes, missing note artifacts, and perfunctory sense-check acknowledgments.",
"reviewer_verdict": "Pass. handles the four non-git fallback modes and audits phantom claims, unclaimed changes, missing note artifacts, and perfunctory acknowledgments.",
"evidence_files": [
"megaplan/evaluation.py",
"tests/test_evaluation.py"
]
},
{
"id": "T8",
"description": "Wire validate_execution_evidence into handle_execute (after task merge, before writing finalize.json). Write result to execution_audit.json in plan_dir. Append findings to deviations as advisory (non-blocking). Add execution_audit.json to artifacts list.",
"depends_on": [
"T7"
],
"status": "done",
"executor_notes": "Wired execution auditing into handle_execute so execution_audit.json is written before finalize.json and all audit findings or skips are appended to deviations as advisory, non-blocking signals.",
"reviewer_verdict": "Pass. Execute writes , appends advisory audit findings to deviations, and keeps those findings non-blocking.",
"evidence_files": [
"megaplan/handlers.py",
"tests/test_megaplan.py"
]
},
{
"id": "T9",
"description": "Update handle_review (megaplan/handlers.py:1191-1280): pass array_fields=('evidence_files',) to _validate_merge_inputs for task_verdicts; extend merge_fields to include evidence_files; add per-task evidence enforcement \u2014 block if done task has empty evidence_files AND reviewer_verdict doesn't substantively reference command output (FLAG-006 softening: if reviewer_verdict is substantive, downgrade to advisory deviation).",
"depends_on": [
"T4"
],
"status": "done",
"executor_notes": "Updated handle_review to merge evidence_files, enforce reviewer evidence for done tasks, soften FLAG-006 when reviewer_verdict is substantive, and route review_verdict=needs_rework back to STATE_FINALIZED with next_step=execute so review findings carry into the next execution pass.",
"reviewer_verdict": "Needs rework. The review-to-execute kickback loop is implemented, but review still allows for done tasks when the reviewer text is substantive, which misses the approved DONE evidence requirement.",
"evidence_files": [
"megaplan/handlers.py",
"tests/test_megaplan.py"
]
},
{
"id": "T10",
"description": "Update render_final_md (megaplan/_core.py:92-142) to render per-task files_changed (indented list under each task when non-empty), executor_note on sense checks, and evidence_files under reviewer verdict (when non-empty). Keep existing gap-detection logic intact.",
"depends_on": [
"T1"
],
"status": "done",
"executor_notes": "Extended render_final_md to show per-task files_changed, per-sense-check executor_note, and reviewer evidence_files while preserving the existing coverage-gap reporting behavior.",
"reviewer_verdict": "Pass. now shows per-task files, sense-check executor notes, and reviewer evidence files without breaking the existing coverage-gap output.",
"evidence_files": [
"megaplan/_core.py"
]
},
{
"id": "T11",
"description": "Write tests: unit test validate_execution_evidence with mocked git status (modified, untracked, renamed, deleted; graceful skip for all four fallback paths including non-zero returncode); unit test _validate_merge_inputs with array_fields; update existing schema/handler/render test fixtures to include new required fields; test blocking behavior for empty evidence on done tasks; test FLAG-006 softening (done task with empty files_changed but non-empty commands_run is not blocked). Run full test suite.",
"depends_on": [
"T7",
"T8",
"T6",
"T9",
"T10",
"T5"
],
"status": "done",
"executor_notes": "Added unit and flow tests for array-field validation, execution auditing across all git fallback modes, execute/review evidence enforcement, FLAG-006 softening, prompt/schema updates, and the new review-to-execute kickback loop; full pytest suite passes.",
"reviewer_verdict": "Needs rework. Coverage is broad, but the tests currently encode the T6/T9 softening instead of enforcing the approved non-empty evidence guarantees, so they will need to move with the handler fixes.",
"evidence_files": [
"tests/test_megaplan.py",
"tests/test_evaluation.py",
"tests/test_prompts.py",
"tests/test_schemas.py",
"tests/test_workers.py"
]
}
],
"watch_items": [
"FLAG-006: Do NOT block execute when a done task has empty files_changed but non-empty commands_run \u2014 treat as advisory deviation. Same principle for review: empty evidence_files with substantive reviewer_verdict is a deviation, not a blocker. This handles verification-only tasks.",
"strict_schema() (schemas.py:189-196) forces ALL declared properties to be required and sets additionalProperties: false. Every new field added to schemas will be required in agent-facing output. Empty arrays [] are the valid value for skipped tasks \u2014 not missing fields.",
"_validate_merge_inputs currently only handles string fields (isinstance check at line 210). T4 MUST land before T6/T9 or array evidence fields will be silently stripped during merge, causing data loss.",
"The sense_check_acknowledgments merge needs a targets_by_id built from finalize_data sense_checks (keyed by 'id'), not from tasks. Don't confuse the two ID spaces.",
"validate_execution_evidence must handle four failure modes from git status: (1) no .git directory, (2) git not on PATH (FileNotFoundError), (3) timeout, (4) non-zero returncode (empty .git dirs in test scaffolds at tests/test_prompts.py:54 and tests/test_megaplan.py:67). All return skipped=True, never raise.",
"Existing top-level files_changed and commands_run in execution.json are summary fields and must be preserved alongside the new per-task fields \u2014 they serve different purposes (summary vs attribution).",
"The review prompt must gracefully handle missing execution_audit.json (first-time runs, non-git environments). Use conditional read, not hard dependency.",
"Keep executor-facing schema and prompt changes minimal and example-driven. The executor should see exactly what shape to return, no ambiguity. This is the user's top priority.",
"commands_run is intentionally NOT enforced non-empty for done tasks \u2014 some tasks are pure file edits. Only files_changed non-emptiness is enforced (softened by FLAG-006 for verification-only tasks).",
"Return type annotations on _validate_merge_inputs and _merge_validated_entries must change from list[dict[str, str]] to list[dict[str, Any]] to accommodate array fields."
],
"sense_checks": [
{
"id": "SC1",
"task_id": "T1",
"question": "Do the new schema fields in execution.json, finalize.json, and review.json all survive strict_schema() \u2014 i.e., are they declared as properties (not just defaults) so they become required?",
"verdict": "Confirmed. The new schema fields are declared as properties in [megaplan/schemas.py], so makes them required."
},
{
"id": "SC2",
"task_id": "T2",
"question": "Does the execute prompt show the executor the exact expected JSON shape for task_updates (with files_changed, commands_run) and sense_check_acknowledgments, with a concrete example?",
"verdict": "Confirmed. The execute prompt includes a concrete JSON example with , , and ."
},
{
"id": "SC3",
"task_id": "T3",
"question": "Do both review prompts (Claude and Codex) include the execution_audit.json read with a graceful fallback if the file doesn't exist?",
"verdict": "Confirmed. Both review prompts load when present and fall back cleanly when it is absent."
},
{
"id": "SC4",
"task_id": "T4",
"question": "Does _validate_merge_inputs correctly validate array fields with isinstance(value, list) and skip entries where an array field is not a list, without breaking existing string-field validation?",
"verdict": "Confirmed. Array fields are validated with and preserved through merge validation."
},
{
"id": "SC5",
"task_id": "T5",
"question": "Do mock workers produce payloads that pass schema validation with all new required fields populated (including empty arrays for skipped tasks)?",
"verdict": "Confirmed. The mock workers populate the new required fields, including empty arrays and default values."
},
{
"id": "SC6",
"task_id": "T6",
"question": "Does handle_execute correctly implement FLAG-006 softening \u2014 blocking only when a done task has BOTH empty files_changed AND empty commands_run, treating empty files_changed with non-empty commands_run as advisory deviation?",
"verdict": "Confirmed, and this is one of the two substantive gaps: execute intentionally softens the blocker and allows command-only done tasks."
},
{
"id": "SC7",
"task_id": "T7",
"question": "Does validate_execution_evidence handle all four git failure modes (no .git, FileNotFoundError, TimeoutExpired, non-zero returncode) by returning skipped=True without raising?",
"verdict": "Confirmed. returns without raising for all four non-git failure modes."
},
{
"id": "SC8",
"task_id": "T8",
"question": "Are audit findings appended to deviations as advisory (non-blocking) and is execution_audit.json written before finalize.json so the reviewer can reference it?",
"verdict": "Confirmed. Audit findings are appended as advisory deviations and is written before ."
},
{
"id": "SC9",
"task_id": "T9",
"question": "Does handle_review implement FLAG-006 softening for evidence_files \u2014 not blocking when a done task has empty evidence_files but a substantive reviewer_verdict?",
"verdict": "Confirmed, and this is the second substantive gap: review intentionally softens the blocker and allows substantive-verdict-only done tasks."
},
{
"id": "SC10",
"task_id": "T10",
"question": "Does render_final_md correctly render the new fields (files_changed list, executor_note, evidence_files) without breaking existing gap-detection logic?",
"verdict": "Confirmed. renders the new evidence fields and still reports missing coverage where appropriate."
},
{
"id": "SC11",
"task_id": "T11",
"question": "Does the full test suite pass, including tests for FLAG-006 softening (done task with commands_run but no files_changed is not blocked)?",
"verdict": "Provisionally confirmed from the diff: the new tests exist and target the right areas, and the executor reported full pytest success. I could not rerun pytest here because the sandbox has no usable temporary directory."
}
],
"meta_commentary": "Execution order: T1 and T4 are independent and can run in parallel (schemas and helper extension). T2, T3, T5, T10 depend only on T1. T6 and T9 depend on T4. T7 depends on T6. T8 depends on T7. T11 depends on everything else.\n\nCritical judgment call \u2014 FLAG-006 softening: The plan's Step 7 says 'block if done task has empty files_changed.' The gate warning says to NOT block when commands_run is non-empty. Implement the softened version: block only when BOTH files_changed AND commands_run are empty for a done task. Same principle for Step 10 / evidence_files \u2014 if reviewer_verdict is substantive (>20 chars), treat empty evidence_files as advisory. This avoids forcing agents to invent file attribution for verification-only tasks.\n\nThe _validate_merge_inputs extension (T4) is the keystone \u2014 without it, array fields silently vanish during merge. Prioritize getting this right. The fix is surgical: add an array_fields parameter, validate with isinstance(value, list), copy to normalized dict. The existing _merge_validated_entries logic (target[field] = entry[field]) already works for any type \u2014 only the type annotation needs updating.\n\nFor the sense_check_acknowledgments merge in T6: build targets_by_id from finalize_data['sense_checks'] keyed by 'id' field (not 'sense_check_id'). The executor returns sense_check_id in its acknowledgments, but the finalize.json sense_checks use 'id'. The _merge_validated_entries id_field should be 'sense_check_id' and targets_by_id should be keyed by the sense_check 'id' values.\n\nThe execution_audit.json is advisory-only \u2014 findings go into deviations for visibility but never set blocked=True. The blocking guarantees come from the handler-level checks (empty evidence arrays) and schema-level enforcement (required fields). This separation keeps the audit from creating false-positive blocks while still surfacing useful cross-check information for the reviewer.\n\nRun existing tests after T1+T4+T5 to catch any fixture breakage early. The test fixtures in tests/ construct execution.json and review.json payloads that will need the new required fields added."
}
code
Plan metadata:
{
"version": 3,
"timestamp": "2026-03-25T02:35:04Z",
"hash": "sha256:af55ff5e059d3c0e617f36461a3abeede5f73aee14030fa79896597286d98282",
"changes_summary": "Surgical fixes for the three remaining flags \u2014 no structural changes to the plan, just closing the specific gaps:\n\nFLAG-003 (DONE enforcement): Added explicit blocking checks for empty evidence arrays. In Step 7: after merging task_updates, iterate done tasks \u2014 if any has empty files_changed, block execute. In Step 10: after merging task_verdicts, iterate done tasks \u2014 if any has empty evidence_files, block review. commands_run is intentionally not enforced (some tasks are pure file edits). This closes the gap between "required in schema" (agent must return the field) and "non-empty at DONE" (the field must have content for done tasks).\n\nFLAG-004 (non-zero returncode): Added the fourth fallback path explicitly in Step 8: if process.returncode != 0: return {\"findings\": [], \"skipped\": True, \"reason\": f\"git status failed: {stderr}\"}. This matches collect_git_diff_summary's handling at _core.py:417-418 and covers the empty .git directory case used in test scaffolds.\n\nFLAG-005 (merge helpers strip array fields): Added Step 6 as a dedicated step to extend _validate_merge_inputs. The fix adds an array_fields: tuple[str, ...] = () parameter. Array fields get validated with isinstance(value, list) instead of isinstance(value, str), and copied to the normalized dict alongside string fields. Return type annotation updated to dict[str, Any]. _merge_validated_entries already handles any type via target[field] = entry[field], so it only needs a type annotation update. Steps 7 and 10 now show the exact call signatures with array_fields= parameter.",
"flags_addressed": [
"FLAG-003",
"FLAG-004",
"FLAG-005"
],
"questions": [],
"success_criteria": [
"Every task in finalize.json at STATE_DONE has non-empty files_changed, executor_notes, and reviewer_verdict fields (enforced by handler blocking on empty arrays + required schema fields)",
"Every task in finalize.json at STATE_DONE has non-empty evidence_files from the reviewer (enforced by handle_review blocking)",
"Every sense_check in finalize.json at STATE_DONE has a non-empty executor_note and reviewer verdict (enforced by blocking on incomplete acknowledgment coverage)",
"execution_audit.json exists after every execute step and contains programmatic cross-check of claimed vs actual file changes",
"Phantom file claims (executor says file changed but git status disagrees) are detected and surfaced in audit findings",
"Unclaimed changes (file in git status but not claimed by any task) are detected and surfaced in audit findings",
"Review prompts include audit findings so the reviewer can act on discrepancies",
"New fields are required in agent-facing schemas \u2014 agents always return them, no ambiguity",
"No new CLI flags or interactive prompts are introduced",
"Audit validation degrades gracefully in all non-git scenarios: missing .git, missing git binary, timeout, AND non-zero returncode from empty .git directories",
"Existing test suite passes after updating test fixtures to include new required fields",
"render_final_md shows the enriched evidence when present",
"Mock workers produce valid payloads with all new fields",
"_validate_merge_inputs correctly carries array fields (files_changed, commands_run, evidence_files) through validation without stripping them"
],
"assumptions": [
"Per-task and are executor-reported claims, not system-captured. The audit validates claims against git state but doesn't independently log commands. Acceptable since the executor is an LLM agent that can only self-report.",
"The git status check uses (matching existing ). This captures modified, added, deleted, renamed, and untracked files. Committed-then-amended changes that are no longer dirty won't appear \u2014 assumed acceptable.",
"Making all new fields required in the schema means plans created before this version will need re-run to regenerate schema files. This is standard for schema-breaking changes and acceptable.",
"The artifact is written alongside and \u2014 no separate CLI step or state transition needed.",
"Sense-check acknowledgment coverage blocking uses the same pattern as task coverage: if executor doesn't acknowledge all sense checks, execute is blocked and must re-run.",
"The path-extraction regex for executor_notes validation is simple (tokens with and file extensions). False positives are acceptable since findings are advisory for the reviewer.",
" is not enforced non-empty for done tasks \u2014 some tasks are pure file edits with no shell commands. Only is enforced non-empty since every done task must touch at least one file.",
"Reviewer is enforced non-empty for done tasks \u2014 the reviewer must cite at least one file they verified. For skipped tasks, empty is valid."
],
"structure_warnings": [],
"delta_from_previous_percent": 30.3
}
code
Gate summary:
{
"passed": true,
"criteria_check": {
"count": 14,
"items": [
"Every task in finalize.json at STATE_DONE has non-empty files_changed, executor_notes, and reviewer_verdict fields (enforced by handler blocking on empty arrays + required schema fields)",
"Every task in finalize.json at STATE_DONE has non-empty evidence_files from the reviewer (enforced by handle_review blocking)",
"Every sense_check in finalize.json at STATE_DONE has a non-empty executor_note and reviewer verdict (enforced by blocking on incomplete acknowledgment coverage)",
"execution_audit.json exists after every execute step and contains programmatic cross-check of claimed vs actual file changes",
"Phantom file claims (executor says file changed but git status disagrees) are detected and surfaced in audit findings",
"Unclaimed changes (file in git status but not claimed by any task) are detected and surfaced in audit findings",
"Review prompts include audit findings so the reviewer can act on discrepancies",
"New fields are required in agent-facing schemas \u2014 agents always return them, no ambiguity",
"No new CLI flags or interactive prompts are introduced",
"Audit validation degrades gracefully in all non-git scenarios: missing .git, missing git binary, timeout, AND non-zero returncode from empty .git directories",
"Existing test suite passes after updating test fixtures to include new required fields",
"render_final_md shows the enriched evidence when present",
"Mock workers produce valid payloads with all new fields",
"_validate_merge_inputs correctly carries array fields (files_changed, commands_run, evidence_files) through validation without stripping them"
]
},
"preflight_results": {
"project_dir_exists": true,
"project_dir_writable": true,
"success_criteria_present": true,
"claude_available": true,
"codex_available": true
},
"unresolved_flags": [
{
"id": "FLAG-006",
"concern": "The plan now over-corrects by assuming every done task must map to at least one changed file. In this repository's task model, some legitimate tasks are verification-only, so blocking execute/review on non-empty files_changed / evidence_files for every done task will force agents to invent file attribution.",
"category": "correctness",
"severity_hint": "likely-significant",
"evidence": "The repo already models non-edit tasks: the mock finalize output creates T2 as \"Verify success criteria\" in megaplan/workers.py:348-354. Your Step 7 would block execute whenever a done task has empty files_changed, and Step 10 would block review whenever a done task has empty evidence_files. For verification-only tasks, the real evidence may be commands/results rather than a touched file, so this enforcement conflicts with the existing workflow shape and the user goal of keeping the agent interface simple and non-confusing.",
"raised_in": "critique_v3.json",
"status": "open",
"severity": "significant",
"verified": false
}
],
"recommendation": "PROCEED",
"rationale": "Score trajectory is steadily improving (4.5\u21923.0\u21922.0), 5 flags resolved across 3 iterations, plan delta narrowing (71%\u219230%), zero recurring critiques. The single remaining flag (FLAG-006) is valid but minor in practice \u2014 the fix is a one-line adjustment during execution: change the blocking check from "all done tasks must have non-empty files_changed" to "done tasks with status 'done' (not 'skipped') that aren't verification-only must have non-empty files_changed", or more simply, downgrade the empty-files_changed check from blocking to deviation for tasks where commands_run is non-empty (evidence exists, just not file-based). This is a small implementation-time judgment call, not a plan-level design flaw. Further iteration risks diminishing returns and churn on an increasingly mature plan.",
"signals_assessment": "Iteration 3, weighted score 2.0 on steady downward trajectory (4.5\u21923.0\u21922.0). Plan delta narrowing appropriately (71%\u219230%). Five flags resolved, zero recurring critiques, zero scope creep. Single remaining FLAG-006 is a real but bounded concern about over-enforcement on verification-only tasks \u2014 it doesn't threaten the architectural design, just needs the executor to soften one blocking condition to a deviation when files_changed is empty but commands_run is non-empty. Preflight all green.",
"warnings": [
"FLAG-006: During implementation of Step 7, do NOT block execute when a done task has empty files_changed but non-empty commands_run. Treat that case as a deviation (advisory), not a blocker. This handles verification-only tasks that run commands but don't edit files. Same principle applies to Step 10 for evidence_files \u2014 if the reviewer's verdict references command output rather than files, empty evidence_files with a substantive reviewer_verdict should be a deviation, not a blocker."
],
"override_forced": false,
"orchestrator_guidance": "Plan passed gate and preflight. Proceed to finalize. Verify unresolved flags against the plan and project code before accepting.",
"robustness": "standard",
"signals": {
"iteration": 3,
"idea": "Harden the execute\u2192review pipeline so that by the time a plan reaches DONE, every task has verifiable evidence of completion. During execution: require the executor to return structured per-task evidence (files_changed, commands_run) that can be cross-checked against the actual git diff; require preliminary sense-check acknowledgments from the executor (not just reviewer). Between execute and review: add a programmatic validation pass that audits executor claims against repo state \u2014 did the claimed files actually change? do executor_notes reference real artifacts? are sense checks acknowledged? During review: reviewer cross-references executor evidence with git diff and fills verdicts. The whole loop should be thorough but not cumbersome \u2014 no new CLI flags, no interactive prompts, enforcement is automatic and invisible on the happy path. The goal: when a plan hits DONE, you can read finalize.json and have complete auditable evidence of what was done, why, and whether it checks out.",
"significant_flags": 1,
"unresolved_flags": [
{
"id": "FLAG-006",
"concern": "The plan now over-corrects by assuming every task must map to at least one changed file. In this repository's task model, some legitimate tasks are verification-only, so blocking execute/review on non-empty / for every done task will force agents to invent file attribution.",
"category": "correctness",
"severity": "significant",
"status": "open"
}
],
"resolved_flags": [
{
"id": "FLAG-001",
"concern": "The backward-compatibility claim is not achievable as written: adding new "optional" evidence fields to , , or will make them required in the agent-facing schemas unless changes too.",
"resolution": "Revised plan to address all four significant critique flags:\n\n1. Flipped the design from "optional fields" to "required fields with empty defaults." Since forces all properties to be required and prevents extra fields, we embrace this \u2014 all new evidence fields are required in the schema. Empty arrays are valid for skipped tasks. No changes to needed. This is actually clearer for agents.\n\n2. Replaced with throughout the audit logic, matching the existing pattern at . This catches untracked files, staged changes, and deletions \u2014 all the states the pipeline already surfaces.\n\n3. Now that fields are required in the schema, the agent literally cannot return a valid payload without them. Additionally: sense-check acknowledgment coverage now blocks (same pattern as task coverage blocking). Per-task evidence completeness is checked (done tasks must have non-empty files_changed). The DONE guarantee is enforced structurally.\n\n4. follows 's exact non-fatal pattern: check exists, catch , catch , return on any failure. Test environments with empty dirs degrade gracefully.\n\nAlso simplified the sense-check acknowledgment schema from three fields (, , ) to two (, ) \u2014 the boolean was redundant since presence of a note implies acknowledgment. Fewer fields = easier for the agent."
},
{
"id": "FLAG-002",
"concern": "The proposed file-audit basis is wrong for this repository: will miss normal changes that the current pipeline surfaces, especially new untracked files, so the audit will report false phantom/unclaimed discrepancies.",
"resolution": "Revised plan to address all four significant critique flags:\n\n1. Flipped the design from "optional fields" to "required fields with empty defaults." Since forces all properties to be required and prevents extra fields, we embrace this \u2014 all new evidence fields are required in the schema. Empty arrays are valid for skipped tasks. No changes to needed. This is actually clearer for agents.\n\n2. Replaced with throughout the audit logic, matching the existing pattern at . This catches untracked files, staged changes, and deletions \u2014 all the states the pipeline already surfaces.\n\n3. Now that fields are required in the schema, the agent literally cannot return a valid payload without them. Additionally: sense-check acknowledgment coverage now blocks (same pattern as task coverage blocking). Per-task evidence completeness is checked (done tasks must have non-empty files_changed). The DONE guarantee is enforced structurally.\n\n4. follows 's exact non-fatal pattern: check exists, catch , catch , return on any failure. Test environments with empty dirs degrade gracefully.\n\nAlso simplified the sense-check acknowledgment schema from three fields (, , ) to two (, ) \u2014 the boolean was redundant since presence of a note implies acknowledgment. Fewer fields = easier for the agent."
},
{
"id": "FLAG-003",
"concern": "The DONE guarantee is still not fully enforced. The revised plan makes the new fields required in the payload shape, but it still allows key evidence fields to stay empty and remain non-blocking, so a plan can reach DONE without the non-empty per-task evidence promised in the success criteria.",
"resolution": "Surgical fixes for the three remaining flags \u2014 no structural changes to the plan, just closing the specific gaps:\n\n Added explicit blocking checks for empty evidence arrays. In Step 7: after merging task_updates, iterate done tasks \u2014 if any has empty , block execute. In Step 10: after merging task_verdicts, iterate done tasks \u2014 if any has empty , block review. is intentionally not enforced (some tasks are pure file edits). This closes the gap between "required in schema" (agent must return the field) and "non-empty at DONE" (the field must have content for done tasks).\n\n Added the fourth fallback path explicitly in Step 8: . This matches 's handling at and covers the empty directory case used in test scaffolds.\n\n Added Step 6 as a dedicated step to extend . The fix adds an parameter. Array fields get validated with instead of , and copied to the normalized dict alongside string fields. Return type annotation updated to . already handles any type via , so it only needs a type annotation update. Steps 7 and 10 now show the exact call signatures with parameter."
},
{
"id": "FLAG-004",
"concern": "The non-git fallback is still incomplete for this repository's actual test scaffolds. The revised plan handles missing , missing , and timeouts, but it still does not cover the non-zero case caused by the empty directories used in tests.",
"resolution": "Surgical fixes for the three remaining flags \u2014 no structural changes to the plan, just closing the specific gaps:\n\n Added explicit blocking checks for empty evidence arrays. In Step 7: after merging task_updates, iterate done tasks \u2014 if any has empty , block execute. In Step 10: after merging task_verdicts, iterate done tasks \u2014 if any has empty , block review. is intentionally not enforced (some tasks are pure file edits). This closes the gap between "required in schema" (agent must return the field) and "non-empty at DONE" (the field must have content for done tasks).\n\n Added the fourth fallback path explicitly in Step 8: . This matches 's handling at and covers the empty directory case used in test scaffolds.\n\n Added Step 6 as a dedicated step to extend . The fix adds an parameter. Array fields get validated with instead of , and copied to the normalized dict alongside string fields. Return type annotation updated to . already handles any type via , so it only needs a type annotation update. Steps 7 and 10 now show the exact call signatures with parameter."
},
{
"id": "FLAG-005",
"concern": "The merge steps still do not fit the repository's current helper behavior. As written, Phase 2 assumes the existing merge helpers can carry array fields through execute/review, but currently strips them, so , , and will not merge without an explicit helper redesign.",
"resolution": "Surgical fixes for the three remaining flags \u2014 no structural changes to the plan, just closing the specific gaps:\n\n Added explicit blocking checks for empty evidence arrays. In Step 7: after merging task_updates, iterate done tasks \u2014 if any has empty , block execute. In Step 10: after merging task_verdicts, iterate done tasks \u2014 if any has empty , block review. is intentionally not enforced (some tasks are pure file edits). This closes the gap between "required in schema" (agent must return the field) and "non-empty at DONE" (the field must have content for done tasks).\n\n Added the fourth fallback path explicitly in Step 8: . This matches 's handling at and covers the empty directory case used in test scaffolds.\n\n Added Step 6 as a dedicated step to extend . The fix adds an parameter. Array fields get validated with instead of , and copied to the normalized dict alongside string fields. Return type annotation updated to . already handles any type via , so it only needs a type annotation update. Steps 7 and 10 now show the exact call signatures with parameter."
}
],
"weighted_score": 2.0,
"weighted_history": [
4.5,
3.0
],
"plan_delta_from_previous": 30.3,
"recurring_critiques": [],
"scope_creep_flags": [],
"loop_summary": "Iteration 3. Weighted score trajectory: 4.5 -> 3.0 -> 2.0. Plan deltas: 71.3%, 30.3%. Recurring critiques: 0. Resolved flags: 5. Open significant flags: 1."
}
}
code
Previous review findings to address on this execution pass (`review.json`):
{
"review_verdict": "needs_rework",
"criteria": [
{
"name": "Every done task has non-empty files_changed, executor_notes, and reviewer_verdict",
"pass": false,
"evidence": "Failed on the files_changed part: [megaplan/handlers.py] only blocks execute when both files_changed and commands_run are empty, and [tests/test_megaplan.py] explicitly preserves that softened path in test_execute_softens_done_task_with_commands_only."
},
{
"name": "Every done task has non-empty evidence_files from the reviewer",
"pass": false,
"evidence": "Failed: [megaplan/handlers.py] allows review to finish with empty evidence_files when reviewer_verdict is deemed substantive, and [tests/test_megaplan.py] locks that in via test_review_softens_substantive_verdict_without_evidence_files_and_can_kick_back."
},
{
"name": "Every sense check at DONE has non-empty executor_note and reviewer verdict",
"pass": true,
"evidence": "[megaplan/handlers.py] blocks missing executor acknowledgments during execute and incomplete sense-check verdict coverage during review."
},
{
"name": "execution_audit.json exists after every execute step",
"pass": true,
"evidence": "[megaplan/handlers.py] writes execution_audit.json unconditionally before finalize.json, and [tests/test_megaplan.py] asserts the artifact exists after execute. The current review bundle omitted the artifact, but the implementation path is present."
},
{
"name": "Phantom file claims are detected and surfaced",
"pass": true,
"evidence": "[megaplan/evaluation.py] compares claimed files against git status --short and emits phantom-claim findings; [tests/test_evaluation.py] covers the ghost.py case."
},
{
"name": "Unclaimed changes are detected and surfaced",
"pass": true,
"evidence": "[megaplan/evaluation.py] reports changed files in git status that no task claimed; [tests/test_evaluation.py] covers deleted and untracked files."
},
{
"name": "Review prompts include audit findings",
"pass": true,
"evidence": "[megaplan/prompts.py] includes execution_audit.json in both review prompts and falls back cleanly when it is absent."
},
{
"name": "New fields are required in agent-facing schemas",
"pass": true,
"evidence": "[megaplan/schemas.py] adds the new evidence fields as declared properties, and strict_schema() makes them required."
},
{
"name": "No new CLI flags or interactive prompts were introduced",
"pass": true,
"evidence": "The diff is confined to schemas, prompts, handlers, evaluation, rendering, workers, and tests; no CLI surface change was introduced."
},
{
"name": "Audit validation degrades gracefully in all non-git scenarios",
"pass": true,
"evidence": "[megaplan/evaluation.py] returns skipped=true for missing , missing git binary, timeouts, and non-zero ; [tests/test_evaluation.py] covers all four paths."
},
{
"name": "Existing test suite passes after fixture updates",
"pass": true,
"evidence": "The diff updates the affected schema/prompt/worker/handler tests, and the executor reported passing. I could not rerun pytest here because the sandbox has no usable temporary directory."
},
{
"name": " shows the enriched evidence",
"pass": true,
"evidence": "[megaplan/_core.py] renders per-task , sense-check , and reviewer while keeping gap reporting intact."
},
{
"name": "Mock workers produce valid payloads with all new fields",
"pass": true,
"evidence": "[megaplan/workers.py] populates the new task arrays, sense-check acknowledgments, , and reviewer ; [tests/test_workers.py] checks those fields."
},
{
"name": " carries array fields without stripping them",
"pass": true,
"evidence": "[megaplan/handlers.py] now accepts , validates lists, and returns ; [tests/test_megaplan.py] covers valid and malformed array-field inputs."
}
],
"issues": [
"T6 needs rework: tighten so every done task must carry non-empty , then update the execute-side tests and mocks to match. The current FLAG-006 softening leaves a DONE path without file-backed task evidence.",
"T9 needs rework: tighten so every done task must carry non-empty , then update the review-side tests and mocks to match. The current substantive-verdict softening leaves a DONE path without reviewer-cited file evidence."
],
"summary": "Needs rework. The schema, prompt, audit, rendering, and review-kickback pieces are largely in place, but the core DONE guarantee is still softened in execute and review: a plan can finish with empty task or empty reviewer . I also could not rerun pytest in this sandbox because no usable temp directory is available, so test-pass confirmation relies on the executor report and the updated test files.",
"task_verdicts": [
{
"task_id": "T1",
"reviewer_verdict": "Pass. The schema changes landed: , , and now declare the new evidence fields and survive .",
"evidence_files": [
"megaplan/schemas.py"
]
},
{
"task_id": "T2",
"reviewer_verdict": "Pass. The execute prompt is example-driven, shows the exact JSON shape for and , and includes prior context for re-execution.",
"evidence_files": [
"megaplan/prompts.py"
]
},
{
"task_id": "T3",
"reviewer_verdict": "Pass. Both review prompts are example-driven, instruct trust-by-default cross-checking, and include the fallback path.",
"evidence_files": [
"megaplan/prompts.py"
]
},
{
"task_id": "T4",
"reviewer_verdict": "Pass. now carries list-valued evidence fields through validation and merge without stripping them.",
"evidence_files": [
"megaplan/handlers.py"
]
},
{
"task_id": "T5",
"reviewer_verdict": "Pass. Mock finalize/execute/review payloads include the new required fields and sense-check acknowledgment structures.",
"evidence_files": [
"megaplan/workers.py",
"tests/test_workers.py"
]
},
{
"task_id": "T6",
"reviewer_verdict": "Needs rework. The merge and sense-check acknowledgment logic is correct, but the blocker is softer than the approved success criteria: done tasks may still proceed with when is non-empty.",
"evidence_files": [
"megaplan/handlers.py",
"tests/test_megaplan.py"
]
},
{
"task_id": "T7",
"reviewer_verdict": "Pass. handles the four non-git fallback modes and audits phantom claims, unclaimed changes, missing note artifacts, and perfunctory acknowledgments.",
"evidence_files": [
"megaplan/evaluation.py",
"tests/test_evaluation.py"
]
},
{
"task_id": "T8",
"reviewer_verdict": "Pass. Execute writes , appends advisory audit findings to deviations, and keeps those findings non-blocking.",
"evidence_files": [
"megaplan/handlers.py",
"tests/test_megaplan.py"
]
},
{
"task_id": "T9",
"reviewer_verdict": "Needs rework. The review-to-execute kickback loop is implemented, but review still allows for done tasks when the reviewer text is substantive, which misses the approved DONE evidence requirement.",
"evidence_files": [
"megaplan/handlers.py",
"tests/test_megaplan.py"
]
},
{
"task_id": "T10",
"reviewer_verdict": "Pass. now shows per-task files, sense-check executor notes, and reviewer evidence files without breaking the existing coverage-gap output.",
"evidence_files": [
"megaplan/_core.py"
]
},
{
"task_id": "T11",
"reviewer_verdict": "Needs rework. Coverage is broad, but the tests currently encode the T6/T9 softening instead of enforcing the approved non-empty evidence guarantees, so they will need to move with the handler fixes.",
"evidence_files": [
"tests/test_megaplan.py",
"tests/test_evaluation.py",
"tests/test_prompts.py",
"tests/test_schemas.py",
"tests/test_workers.py"
]
}
],
"sense_check_verdicts": [
{
"sense_check_id": "SC1",
"verdict": "Confirmed. The new schema fields are declared as properties in [megaplan/schemas.py], so makes them required."
},
{
"sense_check_id": "SC2",
"verdict": "Confirmed. The execute prompt includes a concrete JSON example with , , and ."
},
{
"sense_check_id": "SC3",
"verdict": "Confirmed. Both review prompts load when present and fall back cleanly when it is absent."
},
{
"sense_check_id": "SC4",
"verdict": "Confirmed. Array fields are validated with and preserved through merge validation."
},
{
"sense_check_id": "SC5",
"verdict": "Confirmed. The mock workers populate the new required fields, including empty arrays and default values."
},
{
"sense_check_id": "SC6",
"verdict": "Confirmed, and this is one of the two substantive gaps: execute intentionally softens the blocker and allows command-only done tasks."
},
{
"sense_check_id": "SC7",
"verdict": "Confirmed. returns without raising for all four non-git failure modes."
},
{
"sense_check_id": "SC8",
"verdict": "Confirmed. Audit findings are appended as advisory deviations and is written before ."
},
{
"sense_check_id": "SC9",
"verdict": "Confirmed, and this is the second substantive gap: review intentionally softens the blocker and allows substantive-verdict-only done tasks."
},
{
"sense_check_id": "SC10",
"verdict": "Confirmed. renders the new evidence fields and still reports missing coverage where appropriate."
},
{
"sense_check_id": "SC11",
"verdict": "Provisionally confirmed from the diff: the new tests exist and target the right areas, and the executor reported full pytest success. I could not rerun pytest here because the sandbox has no usable temporary directory."
}
]
}
code
Note: User explicitly approved this plan at the gate checkpoint.
Robustness level: standard.
Requirements:
- Implement the intent, not just the text.
- Adapt if repository reality contradicts the plan.
- Report deviations explicitly.
- Output concrete files changed and commands run.
- Use the tasks in `finalize.json` as the execution boundary. Do not create or rewrite tracking artifacts directly.
- Return `task_updates` with one object per completed or skipped task.
- Return `sense_check_acknowledgments` with one object per sense check.
- Keep `executor_notes` specific enough that a reviewer can map each update to the actual code and commands you ran.
- Follow this JSON shape exactly:
```json
{
"output": "Implemented the approved plan and captured execution evidence.",
"files_changed": ["megaplan/handlers.py", "megaplan/evaluation.py"],
"commands_run": ["pytest tests/test_megaplan.py -k evidence"],
"deviations": [],
"task_updates": [
{
"task_id": "T6",
"status": "done",
"executor_notes": "Updated handle_execute to merge per-task evidence, merge sense-check acknowledgments, and enforce the FLAG-006 softening path.",
"files_changed": ["megaplan/handlers.py"],
"commands_run": ["pytest tests/test_megaplan.py -k execute"]
},
{
"task_id": "T11",
"status": "skipped",
"executor_notes": "Skipped because upstream work is not ready yet; no repo changes were made for this task.",
"files_changed": [],
"commands_run": []
}
],
"sense_check_acknowledgments": [
{
"sense_check_id": "SC6",
"executor_note": "Confirmed execute only blocks when both files_changed and commands_run are empty for a done task."
}
]
}
```
Sense checks to keep in mind during execution (reviewer will verify these):
SC1 (T1): Do the new schema fields in execution.json, finalize.json, and review.json all survive strict_schema() — i.e., are they declared as properties (not just defaults) so they become required?
SC2 (T2): Does the execute prompt show the executor the exact expected JSON shape for task_updates (with files_changed, commands_run) and sense_check_acknowledgments, with a concrete example?
SC3 (T3): Do both review prompts (Claude and Codex) include the execution_audit.json read with a graceful fallback if the file doesn't exist?
SC4 (T4): Does _validate_merge_inputs correctly validate array fields with isinstance(value, list) and skip entries where an array field is not a list, without breaking existing string-field validation?
SC5 (T5): Do mock workers produce payloads that pass schema validation with all new required fields populated (including empty arrays for skipped tasks)?
SC6 (T6): Does handle_execute correctly implement FLAG-006 softening — blocking only when a done task has BOTH empty files_changed AND empty commands_run, treating empty files_changed with non-empty commands_run as advisory deviation?
SC7 (T7): Does validate_execution_evidence handle all four git failure modes (no .git, FileNotFoundError, TimeoutExpired, non-zero returncode) by returning skipped=True without raising?
SC8 (T8): Are audit findings appended to deviations as advisory (non-blocking) and is execution_audit.json written before finalize.json so the reviewer can reference it?
SC9 (T9): Does handle_review implement FLAG-006 softening for evidence_files — not blocking when a done task has empty evidence_files but a substantive reviewer_verdict?
SC10 (T10): Does render_final_md correctly render the new fields (files_changed list, executor_note, evidence_files) without breaking existing gap-detection logic?
SC11 (T11): Does the full test suite pass, including tests for FLAG-006 softening (done task with commands_run but no files_changed is not blocked)?
Watch items to keep visible during execution:
FLAG-006: Do NOT block execute when a done task has empty files_changed but non-empty commands_run — treat as advisory deviation. Same principle for review: empty evidence_files with substantive reviewer_verdict is a deviation, not a blocker. This handles verification-only tasks.
strict_schema() (schemas.py:189-196) forces ALL declared properties to be required and sets additionalProperties: false. Every new field added to schemas will be required in agent-facing output. Empty arrays [] are the valid value for skipped tasks — not missing fields.
_validate_merge_inputs currently only handles string fields (isinstance check at line 210). T4 MUST land before T6/T9 or array evidence fields will be silently stripped during merge, causing data loss.
The sense_check_acknowledgments merge needs a targets_by_id built from finalize_data sense_checks (keyed by 'id'), not from tasks. Don't confuse the two ID spaces.
files_changed=[]
commands_run
evidence_files
test_megaplan.py
test_megaplan.py
Files changed in this session: none. Commands run: git status --short, nl -ba megaplan/handlers.py | sed -n '1176,1365p', nl -ba tests/test_megaplan.py | sed -n '1945,2125p'. Existing modified files already in the worktree: megaplan/_core.py, megaplan/evaluation.py, megaplan/handlers.py, megaplan/prompts.py, megaplan/schemas.py, megaplan/workers.py, tests/test_evaluation.py, tests/test_megaplan.py, tests/test_prompts.py, tests/test_schemas.py, tests/test_workers.py, plus unrelated scorecard.png. With write access restored, the next step is to tighten T6/T9 to require non-empty files_changed and evidence_files for every done task, then update T11’s tests and mocks to match.
Not yet included in a published release.
_validate_merge_inputs
files_changed=[]
commands_run
validate_execution_evidence()
execution_audit.json
evidence_files=[]
render_final_md()
strict_schema()
files_changed
commands_run
sense_check_acknowledgments
execution_audit.json
isinstance(value, list)
executor_note
validate_execution_evidence()
skipped=true
execution_audit.json
finalize.json
final.md
files_changed
commands_run
git status --short
collect_git_diff_summary
megaplan init
execution_audit.json
execution.json
finalize.json
/
commands_run
files_changed
evidence_files
done
files_changed
evidence_files
execution.json
finalize.json
review.json
strict_schema()
FLAG-001 (strict_schema makes all fields required):
strict_schema()
additionalProperties: false
[]
strict_schema()
FLAG-002 (wrong git command):
git diff --name-only
git status --short
collect_git_diff_summary()
_core.py:402-419
FLAG-003 (no DONE enforcement):
FLAG-004 (non-git test environments):
validate_execution_evidence()
collect_git_diff_summary()
.git
FileNotFoundError
TimeoutExpired
{\"skipped\": true, \"reason\": \"...\"}
.git
sense_check_id
acknowledged
executor_note
sense_check_id
executor_note
git diff --name-only
FLAG-001 (strict_schema makes all fields required):
strict_schema()
additionalProperties: false
[]
strict_schema()
FLAG-002 (wrong git command):
git diff --name-only
git status --short
collect_git_diff_summary()
_core.py:402-419
FLAG-003 (no DONE enforcement):
FLAG-004 (non-git test environments):
validate_execution_evidence()
collect_git_diff_summary()
.git
FileNotFoundError
TimeoutExpired
{\"skipped\": true, \"reason\": \"...\"}
.git
sense_check_id
acknowledged
executor_note
sense_check_id
executor_note
FLAG-003 (DONE enforcement):
files_changed
evidence_files
commands_run
FLAG-004 (non-zero returncode):
if process.returncode != 0: return {\"findings\": [], \"skipped\": True, \"reason\": f\"git status failed: {stderr}\"}
collect_git_diff_summary
_core.py:417-418
.git
FLAG-005 (merge helpers strip array fields):
_validate_merge_inputs
array_fields: tuple[str, ...] = ()
isinstance(value, list)
isinstance(value, str)
dict[str, Any]
_merge_validated_entries
target[field] = entry[field]
array_fields=
.git
git
git status
.git
FLAG-003 (DONE enforcement):
files_changed
evidence_files
commands_run
FLAG-004 (non-zero returncode):
if process.returncode != 0: return {\"findings\": [], \"skipped\": True, \"reason\": f\"git status failed: {stderr}\"}
collect_git_diff_summary
_core.py:417-418
.git
FLAG-005 (merge helpers strip array fields):
_validate_merge_inputs
array_fields: tuple[str, ...] = ()
isinstance(value, list)
isinstance(value, str)
dict[str, Any]
_merge_validated_entries
target[field] = entry[field]
array_fields=
_validate_merge_inputs()
files_changed
commands_run
evidence_files
FLAG-003 (DONE enforcement):
files_changed
evidence_files
commands_run
FLAG-004 (non-zero returncode):
if process.returncode != 0: return {\"findings\": [], \"skipped\": True, \"reason\": f\"git status failed: {stderr}\"}
collect_git_diff_summary
_core.py:417-418
.git
FLAG-005 (merge helpers strip array fields):
_validate_merge_inputs
array_fields: tuple[str, ...] = ()
isinstance(value, list)
isinstance(value, str)
dict[str, Any]
_merge_validated_entries
target[field] = entry[field]
array_fields=
.git
git status
pytest -q
render_final_md
files_changed
executor_note
evidence_files
review_verdict
evidence_files
_validate_merge_inputs
array_fields
dict[str, Any]
handle_execute
files_changed
handle_review
evidence_files
files_changed
evidence_files
finalize.json
execution.json
review.json
strict_schema()
task_updates
sense_check_acknowledgments
review.json
execution_audit.json
_validate_merge_inputs
files_changed=[]
commands_run
validate_execution_evidence()
execution_audit.json
evidence_files=[]
render_final_md()
strict_schema()
files_changed
commands_run
sense_check_acknowledgments
execution_audit.json
isinstance(value, list)
executor_note
validate_execution_evidence()
skipped=true
execution_audit.json
finalize.json
final.md
validate_execution_evidence must handle four failure modes from git status: (1) no .git directory, (2) git not on PATH (FileNotFoundError), (3) timeout, (4) non-zero returncode (empty .git dirs in test scaffolds at tests/test_prompts.py:54 and tests/test_megaplan.py:67). All return skipped=True, never raise.
Existing top-level files_changed and commands_run in execution.json are summary fields and must be preserved alongside the new per-task fields — they serve different purposes (summary vs attribution).
The review prompt must gracefully handle missing execution_audit.json (first-time runs, non-git environments). Use conditional read, not hard dependency.
Keep executor-facing schema and prompt changes minimal and example-driven. The executor should see exactly what shape to return, no ambiguity. This is the user's top priority.
commands_run is intentionally NOT enforced non-empty for done tasks — some tasks are pure file edits. Only files_changed non-emptiness is enforced (softened by FLAG-006 for verification-only tasks).
Return type annotations on _validate_merge_inputs and _merge_validated_entries must change from list[dict[str, str]] to list[dict[str, Any]] to accommodate array fields.