You are already running inside the megaplan harness for this step. Do the requested planning/review/execution work directly. Do NOT invoke the megaplan CLI, do NOT read or activate the megaplan skill, do NOT start nested megaplan plans, and do NOT recurse into another planning harness. Treat mentions of megaplan in the repository or environment as implementation context only.
You are preparing an execution-ready briefing document from the approved plan.
Megaplan currently only produces code artifacts. This feature adds --mode doc so the same harness can produce structured documents (plans, RFCs, design docs). The core state machine, flag taxonomy, critique/gate/revise loop, and robustness levels are unchanged. What changes: (1) plan.json gains mode and output_path fields, (2) new doc-mode prompt variants for prep, execute, and review, (3) a new execution schema with sections_written instead of files_changed, (4) a new doc_assembly.py module to assemble sections into the output file, (5) validate_execution_evidence branches on mode, (6) a doc-quality critique category, (7) finalize handler skips test baseline capture and verification-task injection for doc mode, (8) timeout recovery branches on mode for checkpoint merge and task validation, and (9) Hermes worker's execute fallback reconstructs doc-shaped payloads when mode is doc.
The spec is well-scoped: single output file, no mixed-mode, no loop-mode doc support. Existing code-mode tests remain untouched.
Assistant
Reading the idea doc and key source files to build the execution briefing.
Assistant
Now let me read the remaining key files needed for the briefing.
Assistant
Let me check a few more files for the workers and hermes paths.
Assistant
Now let me check the remaining pieces needed — the execution flow, review handler, and the status builder.
Assistant
Now let me check the remaining execution code for _run_and_merge_batch and _check_done_task_evidence, and the pyproject.toml / CHANGELOG.
Assistant
I have enough context. Producing the finalize briefing now.
Assistant
Finalize briefing produced with 14 tasks covering all 21 plan steps. Key structure: T1-T3 are independent foundation work (types/CLI, schemas, version bump), T4-T5 are prompts, T6-T10 are core logic, T11-T13 wire everything together, and T14 is the final test barrier. All four addressed critique flags (finalize handler, timeout recovery, Hermes worker, path containment) are covered in their respective tasks.
Phase 1: Foundation — Types, Config, CLI, Schema
Step 1: Add mode/output_path to plan config and types (megaplan/types.py)
Scope: Small
Addmode and output_path as optional fields to PlanConfig TypedDict (megaplan/types.py:28). mode is str (values: "code", "doc"), output_path is str.
Verify that PlanState inherits config: PlanConfig at types.py:115, so the new fields propagate automatically.
Step 2: Wire --mode and --output CLI flags (megaplan/cli.py:811, megaplan/handlers.py:717)
Scope: Small
Add--mode argument to init_parser with choices=["code", "doc"], default="code" (cli.py:811, after line 820).
Add--output argument to init_parser (cli.py:811). Required only when mode=doc.
Updatehandle_init (handlers.py:717):
Validate that --output is provided when --mode doc and raise CliError otherwise.
Validate that output_path is relative (no leading /) and does not escape project_dir (reject ../ traversal). Resolve and normalize against project_dir.
Persist mode and output_path in state["config"]. Default mode to "code" for backward compatibility.
Createmegaplan/prompts/prep_doc.py with a _prep_doc_prompt(state, plan_dir, root=None) function. Repoint the prompt from "search the codebase for relevant files" to "what sources, prior art, related docs should inform this document?" Sense-check items become "did you read X?" rather than "did you find the relevant module?"
Keep the output schema identical to prep.json — the fields (key_evidence, relevant_code, constraints, suggested_approach) still apply, just the content and prompt framing change. relevant_code becomes references to existing docs/prior art.
Createmegaplan/prompts/execute_doc.py with _execute_doc_prompt and _execute_doc_batch_prompt.
Frame the executor as an author writing a document. Its only filesystem operation is writing to the configured output_path. Replace files_changed references with sections_written. Remove commands_run from per-task guidance.
Include the doc-mode output shape example (JSON with sections_written instead of files_changed, no commands_run in task_updates).
Reuse shared helpers: _execute_nudges, _execute_approval_note, _execute_rerun_guidance, _render_prep_block from existing code.
Createmegaplan/prompts/review_doc.py with _review_doc_prompt(state, plan_dir, *, review_intro, criteria_guidance, ...).
Reword to treat the deliverable as text: instead of "cross-reference files_changed against git diff", say "read the output file and judge it against success criteria." Remove git-diff and execution_audit.json references — the audit for doc mode is section-based, not git-based.
Keep the same review.json output schema — must/should/info criteria, task_verdicts, sense_check_verdicts all apply.
Step 9: Wire doc-mode prompts into dispatch (megaplan/prompts/__init__.py, megaplan/prompts/finalize.py)
Scope: Small
Import the new prompt builders from prep_doc.py, execute_doc.py, review_doc.py.
Updatecreate_claude_prompt / create_codex_prompt / create_hermes_prompt to check state["config"].get("mode", "code") and select the appropriate builder for prep, execute, and review steps. Other steps (plan, critique, gate, finalize, revise) use the same builders regardless of mode.
Update_finalize_prompt (finalize.py:22): add a conditional block for doc mode that replaces task field guidance — use sections_written instead of files_changed/commands_run, remove the test-verification requirement from the prompt text, and instruct the finalizer to omit baseline_test_failures/baseline_test_command.
assemble_doc(plan_dir: Path, output_path: Path, finalize_data: dict) -> Path: reads per-batch executor outputs, orders sections by plan position, writes the assembled file atomically (temp file + rename).
extract_sections(batch_payloads: list[dict]) -> dict[str, str]: maps section_id → rendered text from executor output.
Idempotent: running twice on the same plan replaces the file completely.
Call site: invoked at the end of execute (after all batches complete) in execution.py.
Step 11: Update merge validation for doc mode (megaplan/execution.py:256)
Scope: Medium
Update_merge_batch_results in execution.py:256 to read mode from state config. When mode is "doc":
Required fields for task_updates become ("task_id", "status", "executor_notes", "sections_written") instead of ("task_id", "status", "executor_notes", "files_changed", "commands_run").
Merge fields become ("status", "executor_notes", "sections_written").
array_fields becomes ("sections_written",).
No changes to merge.py itself — it's generic; the branching happens at the call site.
Step 12: Branch validate_execution_evidence for doc mode (megaplan/evaluation.py:123)
Scope: Medium
Add a mode parameter to validate_execution_evidence (default "code").
When mode is "doc", replace the git-status comparison with:
Extract planned sections from finalize_data tasks (all sections_written across done tasks).
Resolve output_path from finalize_data or accept it as a parameter.
Verify: output file exists and is non-empty, all planned sections claimed by done tasks, no unclaimed sections.
Return findings in the same {"findings": [...], "files_in_diff": [], "files_claimed": [], "skipped": False} shape for compatibility.
When mode is "code", behavior is unchanged (existing git-status logic).
Update all callers to pass mode: execution.py:423 and execution_timeout.py:203,216.
Step 13: Branch finalize handler for doc mode (megaplan/handlers.py:376)
Scope: Medium
Update_write_finalize_artifacts (handlers.py:376): when state["config"].get("mode") == "doc":
Skip_capture_test_baseline() — doc plans don't run tests. Set baseline_test_failures to None and baseline_test_command to None.
Skip_ensure_verification_task() — doc plans don't have a final test-running task.
Still call _reconcile_validation_after_mutation() (it's harmless and keeps validation consistent).
Update_validate_finalize_payload (handlers.py:409): no changes needed — it validates tasks, sense_checks, watch_items generically. Doc-mode tasks still have id, description, status: pending.
Step 14: Branch timeout recovery for doc mode (megaplan/execution_timeout.py)
Scope: Medium
Update_merge_timeout_checkpoint (execution_timeout.py:110): read mode from state config (passed as parameter or read from finalize_data). When mode is "doc":
Required fields become ("task_id", "status", "executor_notes", "sections_written").
Merge fields become ("status", "executor_notes", "sections_written").
array_fields becomes ("sections_written",).
Update_reset_timeout_invalid_tasks (execution_timeout.py:41): when mode is "doc":
Evidence check uses sections_written instead of files_changed.
Skip the files_in_diff cross-check (no git diff in doc mode).
Update_recover_execute_timeout (execution_timeout.py:163): pass mode to validate_execution_evidence calls at lines 203 and 216. When mode is "doc", aggregate sections_written instead of files_changed for the response at line 275–281.
Step 15: Update status display for doc mode (megaplan/cli.py:341)
Scope: Small
Update_build_status_payload (in cli.py) to include mode and output_path in the status output when present in state config.
Phase 4: Wiring — Handlers, Workers, Hermes
Step 16: Update execute handler for doc mode (megaplan/handlers.py:1337, megaplan/execution.py)
Scope: Medium
Inhandle_execute (handlers.py:1337): detect mode from state["config"].get("mode", "code"). When "doc":
Skip --confirm-destructive requirement (doc mode writes a single output file, not repo code).
After all batches complete, call assemble_doc() to produce the output file.
In_run_and_merge_batch (execution.py:349): accept mode parameter. When mode is "doc":
Skip _observe_git_changes, _collect_quality_deviations, and capture_before_line_counts (no git changes expected).
Adapt _check_done_task_evidence: has_evidence checks sections_written instead of files_changed, has_advisory_evidence always returns True (no commands_run analog).
Pass mode to validate_execution_evidence.
In_build_aggregate_execution_payload (execution.py:136): when mode is "doc", aggregate sections_written instead of files_changed.
Step 17: Update review handler for doc mode (megaplan/handlers.py:1576, megaplan/prompts/review.py)
Scope: Small
Inhandle_review: when mode is "doc", skip mechanical pre-checks that depend on code (test pass/fail, type checking).
In_parallel_review_context (prompts/review.py:78): when mode is "doc", replace git_diff with the output file content read from state["config"]["output_path"] resolved against project_dir.
Update schema lookup: when step is "execute" and mode is "doc" (read from state["config"]), use "execution_doc.json" instead of "execution.json". The mode is available from state["config"] which is already passed to run_claude_step, run_codex_step, etc.
Touch points: workers.py:58 (STEP_SCHEMA_FILENAMES lookup in run_claude_step), workers.py codex schema path, and hermes_worker.py:294 (schema_name = STEP_SCHEMA_FILENAMES[step]).
Step 19: Update Hermes worker for doc mode (megaplan/hermes_worker.py)
Scope: Medium
Update_reconstruct_execute_payload (hermes_worker.py:635): when mode is "doc":
Skip git-diff and git-status based files_changed reconstruction (lines 670–697).
Return sections_written instead of files_changed in the reconstructed payload.
Remove commands_run from the reconstructed payload (or leave as empty list for schema compat).
Update schema lookup at hermes_worker.py:294: use get_execution_schema_key(mode) to select the correct schema filename. Mode comes from state["config"] which is passed through to run_hermes_step.
Update the execute fallback path at hermes_worker.py:192–196: when mode is "doc", the fallback should attempt doc-shaped reconstruction rather than code-shaped.
Phase 5: Tests
Step 20: Add doc-mode unit tests (tests/test_doc_mode.py)
Scope: Medium
Testhandle_init with --mode doc --output docs/plan.md produces state with mode: "doc" and output_path.
Testhandle_init with --mode doc but no --output raises CliError.
Testhandle_init with --mode doc --output /absolute/path raises CliError (path containment).
Testhandle_init with --mode doc --output ../escape/path raises CliError (traversal).
Testvalidate_execution_evidence in doc mode: catches missing sections, catches unclaimed sections, passes when all sections present.
Testassemble_doc: sections assembled in plan order, output file is non-empty, idempotent re-run replaces file.
Test doc-mode execution schema validates correctly via strict_schema.
Test_write_finalize_artifacts in doc mode: skips test baseline capture, skips verification task injection.
Test_merge_timeout_checkpoint in doc mode: uses sections_written fields.
Test_reset_timeout_invalid_tasks in doc mode: checks sections_written evidence, skips git-diff cross-check.
Step 21: Verify existing tests pass (tests/)
Scope: Small
Runpytest tests/ — all existing tests must pass unchanged. The mode field defaults to "code" everywhere, so no existing behavior changes.
Execution Order
Steps 1–5 (types, CLI, schema, version) — foundation with no behavioral changes.
Steps 6–9 (prompts) — can be done in parallel since they're independent files. Wire dispatch last.
Steps 20–21 (tests) — prove the change works and nothing regressed.
Validation Order
Run pytest tests/test_schemas.py after Step 4 to verify new schema is valid.
Run pytest tests/ after Step 5 to verify no regressions from version bump.
Run pytest tests/test_doc_mode.py after Step 20 for focused doc-mode coverage.
Run full pytest tests/ after Step 21 for final regression check.
code
Plan metadata:
{
"version": 2,
"timestamp": "2026-04-15T07:55:59Z",
"hash": "sha256:0f9e654ea81728c6a99fa5a73ef26a1e87a0dcf6effa4576f87ed66926d7f463",
"changes_summary": "Addressed four significant critique flags: (1) FLAG-001 \u2014 added Step 13 to branch _write_finalize_artifacts for doc mode, skipping _capture_test_baseline() and _ensure_verification_task(), and updated Step 9 to add doc-mode guidance in the finalize prompt. (2) FLAG-002 \u2014 added Step 14 to branch all three timeout recovery functions (_merge_timeout_checkpoint, _reset_timeout_invalid_tasks, _recover_execute_timeout) for doc mode, using sections_written instead of files_changed/commands_run and skipping git-diff cross-checks. (3) FLAG-003 \u2014 added Step 19 to update Hermes worker's _reconstruct_execute_payload and schema lookup for doc mode, preventing code-shaped fallback reconstruction. (4) FLAG-004 \u2014 expanded Step 2 to add concrete output_path validation in handle_init: reject absolute paths, reject ../ traversal, normalize against project_dir. Added path-containment tests to Step 20. Also added new success criteria for timeout recovery and path containment.",
"flags_addressed": [
"FLAG-001",
"FLAG-002",
"FLAG-003",
"FLAG-004"
],
"questions": [
"The spec says 'output file exists and is non-empty' in the doc-mode audit. Should the audit also verify that the output file is valid markdown (or whatever format), or just check existence + non-empty?",
"For doc-mode execute, should the executor agent have full filesystem read access (to reference existing docs/code) but only write access to the output path? Or should read access also be restricted? (Assumption: read access unrestricted, write containment via init-time validation only for v0.15.)"
],
"success_criteria": [
{
"criterion": "megaplan init --mode doc --output X '...' produces a plan with mode: doc and output_path in state.json",
"priority": "must"
},
{
"criterion": "megaplan init --mode doc without --output raises a clear error",
"priority": "must"
},
{
"criterion": "megaplan init --mode doc --output /absolute/path raises a clear error",
"priority": "must"
},
{
"criterion": "megaplan init --mode doc --output ../traversal raises a clear error",
"priority": "must"
},
{
"criterion": "All existing code-mode tests pass unchanged (pytest tests/ green)",
"priority": "must"
},
{
"criterion": "Doc-mode audit rejects an executor that claims a section not in the plan",
"priority": "must"
},
{
"criterion": "Doc-mode audit rejects an executor that skips a section without marking the task blocked/skipped",
"priority": "must"
},
{
"criterion": "Doc-mode execute produces a non-empty file at the configured output_path",
"priority": "must"
},
{
"criterion": "pyproject.toml version is 0.15.0",
"priority": "must"
},
{
"criterion": "CHANGELOG has a v0.15.0 entry describing doc-mode",
"priority": "must"
},
{
"criterion": "Doc-mode execution schema (execution_doc.json) validates correctly via strict_schema",
"priority": "must"
},
{
"criterion": "Doc-mode review with a must criterion about doc content can fail and trigger needs_rework",
"priority": "must"
},
{
"criterion": "Doc-mode finalize skips test baseline capture and verification task injection",
"priority": "must"
},
{
"criterion": "Doc-mode timeout recovery uses sections_written fields and skips git-diff cross-check",
"priority": "must"
},
{
"criterion": "Hermes worker doc-mode execute uses execution_doc.json schema and reconstructs sections_written fallback",
"priority": "must"
},
{
"criterion": "New prompt files (prep_doc.py, execute_doc.py, review_doc.py) each under ~300 lines",
"priority": "should"
},
{
"criterion": "doc_assembly.py under ~150 lines \u2014 simple section concatenation, not a complex engine",
"priority": "should"
},
{
"criterion": "No changes to existing code-mode prompt files beyond adding mode-dispatch branches",
"priority": "should"
},
{
"criterion": "megaplan status shows mode: doc and output_path when in doc mode",
"priority": "should"
},
{
"criterion": "Full end-to-end doc-mode plan lifecycle tested manually (init through review)",
"priority": "info"
}
],
"assumptions": [
"Assembly happens once after all batches complete (not incrementally per-batch). The spec says 'assembles sections in plan-order' which implies a final assembly step, and incremental assembly would require conflict resolution between partial writes.",
"The output_path is relative to project_dir as stated in the spec. Validation in handle_init rejects absolute paths and '../' traversal. The resolved path is stored normalized in state.json.",
"Doc-mode tasks in finalize.json use the same task schema but with sections_written: [] instead of files_changed: []. The finalize schema gains an optional sections_written field on tasks, populated only in doc mode.",
"Existing plans with no mode field default to 'code' \u2014 this is a backward-compatible addition, not a migration.",
"The doc-mode review uses the same review.json output schema. The only difference is prompt framing \u2014 criteria like 'the doc names every blocking risk' replace 'tsc clean'.",
"The --confirm-destructive flag is not required for doc-mode execute since it only writes a single output file, not repo code.",
"Doc-mode finalize skips _capture_test_baseline and _ensure_verification_task entirely. The finalizer prompt for doc mode instructs the model not to produce test-related fields.",
"Hermes execute fallback for doc mode returns sections_written instead of files_changed and skips git-diff reconstruction. If no tool calls or sections are found, the fallback returns None as it does today for code mode.",
"Output-path containment is enforced at init time only (reject bad paths). Runtime enforcement of write-only-to-output-path is not added in v0.15 because agent sandboxing is already handled by the worker layer (Codex writable_roots, trusted-container mode). The init-time guard prevents accidental misconfiguration, not adversarial agents."
],
"delta_from_previous_percent": 73.49,
"structure_warnings": []
}
code
Gate summary:
{
"recommendation": "ITERATE",
"rationale": "Light robustness: single revision pass to incorporate critique feedback.",
"signals_assessment": "",
"warnings": [],
"settled_decisions": []
}
code
Flag registry:
[
{
"id": "FLAG-001",
"concern": "Finalize contract: the plan treats finalize as mostly shared, but the current finalize prompt and handler are hard-wired for code execution. _finalize_prompt() still requires the final task to run tests and even create a throwaway repro script, while _write_finalize_artifacts() always captures a pytest baseline and _ensure_verification_task() appends a test task with files_changed/commands_run. Without an explicit doc-mode branch for finalize, doc plans will be mutated back into code-style execution checklists before execute starts.",
"evidence": "Addressed four significant critique flags: (1) FLAG-001 \u2014 added Step 13 to branch _write_finalize_artifacts for doc mode, skipping _capture_test_baseline() and _ensure_verification_task(), and updated Step 9 to add doc-mode guidance in the finalize prompt. (2) FLAG-002 \u2014 added Step 14 to branch all three timeout recovery functions (_merge_timeout_checkpoint, _reset_timeout_invalid_tasks, _recover_execute_timeout) for doc mode, using sections_written instead of files_changed/commands_run and skipping git-diff cross-checks. (3) FLAG-003 \u2014 added Step 19 to update Hermes worker's _reconstruct_execute_payload and schema lookup for doc mode, preventing code-shaped fallback reconstruction. (4) FLAG-004 \u2014 expanded Step 2 to add concrete output_path validation in handle_init: reject absolute paths, reject ../ traversal, normalize against project_dir. Added path-containment tests to Step 20. Also added new success criteria for timeout recovery and path containment.",
"status": "addressed",
"severity": "significant"
},
{
"id": "FLAG-002",
"concern": "Timeout recovery: the execute timeout/checkpoint path is still code-only, and the plan does not include it. If a doc-mode execute times out, _merge_timeout_checkpoint() requires files_changed and commands_run, and _reset_timeout_invalid_tasks() revalidates tasks against git-diff-style evidence. That will drop or reset legitimate doc-mode progress instead of recovering it.",
"evidence": "Addressed four significant critique flags: (1) FLAG-001 \u2014 added Step 13 to branch _write_finalize_artifacts for doc mode, skipping _capture_test_baseline() and _ensure_verification_task(), and updated Step 9 to add doc-mode guidance in the finalize prompt. (2) FLAG-002 \u2014 added Step 14 to branch all three timeout recovery functions (_merge_timeout_checkpoint, _reset_timeout_invalid_tasks, _recover_execute_timeout) for doc mode, using sections_written instead of files_changed/commands_run and skipping git-diff cross-checks. (3) FLAG-003 \u2014 added Step 19 to update Hermes worker's _reconstruct_execute_payload and schema lookup for doc mode, preventing code-shaped fallback reconstruction. (4) FLAG-004 \u2014 expanded Step 2 to add concrete output_path validation in handle_init: reject absolute paths, reject ../ traversal, normalize against project_dir. Added path-containment tests to Step 20. Also added new success criteria for timeout recovery and path containment.",
"status": "addressed",
"severity": "significant"
},
{
"id": "FLAG-003",
"concern": "Agent coverage: the worker changes are incomplete for Hermes. The plan mentions workers.py schema selection, but hermes_worker.py independently loads the execute schema from STEP_SCHEMA_FILENAMES and reconstructs failed execute payloads with files_changed/commands_run. Doc mode would therefore remain code-shaped or fail under --hermes and any Hermes fallback path.",
"evidence": "Addressed four significant critique flags: (1) FLAG-001 \u2014 added Step 13 to branch _write_finalize_artifacts for doc mode, skipping _capture_test_baseline() and _ensure_verification_task(), and updated Step 9 to add doc-mode guidance in the finalize prompt. (2) FLAG-002 \u2014 added Step 14 to branch all three timeout recovery functions (_merge_timeout_checkpoint, _reset_timeout_invalid_tasks, _recover_execute_timeout) for doc mode, using sections_written instead of files_changed/commands_run and skipping git-diff cross-checks. (3) FLAG-003 \u2014 added Step 19 to update Hermes worker's _reconstruct_execute_payload and schema lookup for doc mode, preventing code-shaped fallback reconstruction. (4) FLAG-004 \u2014 expanded Step 2 to add concrete output_path validation in handle_init: reject absolute paths, reject ../ traversal, normalize against project_dir. Added path-containment tests to Step 20. Also added new success criteria for timeout recovery and path containment.",
"status": "addressed",
"severity": "significant"
},
{
"id": "FLAG-004",
"concern": "Output-path containment: the plan assumes output_path will be validated and doc execute will only write that file, but no implementation step actually adds that enforcement. In the current runner, Codex execute is given the whole project as a writable root, and trusted-container mode bypasses Codex sandboxing entirely. Skipping --confirm-destructive for doc mode is unsafe unless the plan also adds concrete path normalization and worker-level write restriction.",
"evidence": "Addressed four significant critique flags: (1) FLAG-001 \u2014 added Step 13 to branch _write_finalize_artifacts for doc mode, skipping _capture_test_baseline() and _ensure_verification_task(), and updated Step 9 to add doc-mode guidance in the finalize prompt. (2) FLAG-002 \u2014 added Step 14 to branch all three timeout recovery functions (_merge_timeout_checkpoint, _reset_timeout_invalid_tasks, _recover_execute_timeout) for doc mode, using sections_written instead of files_changed/commands_run and skipping git-diff cross-checks. (3) FLAG-003 \u2014 added Step 19 to update Hermes worker's _reconstruct_execute_payload and schema lookup for doc mode, preventing code-shaped fallback reconstruction. (4) FLAG-004 \u2014 expanded Step 2 to add concrete output_path validation in handle_init: reject absolute paths, reject ../ traversal, normalize against project_dir. Added path-containment tests to Step 20. Also added new success criteria for timeout recovery and path containment.",
"status": "addressed",
"severity": "significant"
}
]
"[DEBT] are-the-proposed-changes-technically-correct: are the proposed changes technically correct?: the mobile action-surface plan is technically incorrect for the current component structure. submissioncarouselcard hides footercontent below the md breakpoint (src/components/submissioncarouselcard.tsx:219), while submissionscarouselpage also hides the score panel on mobile via asidecontent={<div classname=\"hidden md:block\">... and passes hideactions to scorepanel at src/pages/submissionscarouselpage.tsx:250-263,347. reusing that pattern for entrypage would leave mobile users with no navigation controls and no scoring controls. (flagged 1 times across 1 plans)",
"[DEBT] are-the-proposed-changes-technically-correct: are the proposed changes technically correct?: i checked the sign-in callback path again. submissionslayout already wires usescoring(..., { onrequiresignin: () => pagemachine.dispatch({ type: 'open_sign_in_modal' }) }) at src/pages/submissionslayout.tsx:38-40, and scorepanel still has its own onrequiresignin prop. the revised step 4.2 is acceptable only if it explicitly rewires that prop to pagemachine.dispatch; otherwise removing local modal state would orphan the direct ui callback. the plan hints at this, but it remains easy to misread because the scoring-context callback and the scorepanel prop are separate mechanisms. (flagged 1 times across 1 plans)",
"[DEBT] are-the-proposed-changes-technically-correct: are the proposed changes technically correct?: checked the new diff-helper proposal against the repo's existing execution-evidence semantics. validate_execution_evidence() in megaplan/evaluation.py:109-175 uses git status --short, so untracked files count as real changed files today, but step 3 proposes collect_git_diff_patch(project_dir) via git diff head; by git behavior that will not include untracked files, so heavy review could miss exactly the newly created files that execute and review already treat as part of the patch. (flagged 1 times across 1 plans)",
"[DEBT] are-the-proposed-changes-technically-correct: are the proposed changes technically correct?: a generated-schema gap remains. tests/test_schemas.py reads the repo-root .megaplan/schemas/review.json directly via _review_disk_schema(), the checked-in local file is currently stale relative to schemas, and ensure_runtime_layout() in megaplan/_core/io.py is the production writer for that file class. the plan says generated schemas must stay aligned, but it never names a regeneration step or a test adjustment for that disk-schema path, so the validation story is still incomplete. (flagged 1 times across 1 plans)",
"[DEBT] are-the-success-criteria-well-prioritized-and-verifiable: are the success criteria well-prioritized and verifiable?: mobile behavior is still under-prioritized relative to the actual risk in this repo. the user constraint specifically mentions the mobile bottom nav, but the only mobile-specific success criterion left is 'mobile scoring ux is coherent' at info level. given that the plan currently removes the working mobile nav, there should be at least a should or must criterion stating that mobile users retain navigation and scoring controls. (flagged 1 times across 1 plans)",
"[DEBT] completeness: handle_init() and override flows also emit next_step but aren't listed for next_step_runtime enrichment. (flagged 1 times across 1 plans)",
"[DEBT] completeness: handle_execute() at handlers.py:1152-1175 can clear next_step to none but leave stale next_step_runtime. (flagged 1 times across 1 plans)",
"[DEBT] completeness: next_step_runtime fires on previous step completion, not literally when the next phase starts. (flagged 1 times across 1 plans)",
"[DEBT] completeness: test_command config override unreachable via normal init/cli flow (flagged 1 times across 1 plans)",
"[DEBT] correctness: status-progress gating excludes finalized plans with finalize.json in between-batch and blocked states. (flagged 1 times across 1 plans)",
"[DEBT] correctness: resolve_phase_runtime called on non-phase next_step values would fail. (flagged 1 times across 1 plans)",
"[DEBT] correctness: non-phase next_step values from workflow_next() not filtered. (flagged 1 times across 1 plans)",
"[DEBT] correctness: baseline_test_command schema says string-only but fallback returns none (flagged 1 times across 1 plans)",
"[DEBT] correctness: fallback uses null+baseline_test_note instead of brief's empty-array+meta_commentary (flagged 1 times across 1 plans)",
"[DEBT] criteria-prompt: criteria prompt: v3 replaces _review_prompt() in heavy mode with a new heavy_criteria_review_prompt, so the plan no longer follows the brief's explicit requirement that _review_prompt() remain the heavy-mode criteria_verdict check. (flagged 1 times across 1 plans)",
"[DEBT] did-the-work-fully-address-the-issue-hints-user-notes-and-approved-plan-requirements: did the work fully address the issue hints, user notes, and approved plan requirements?: a new critical issue is introduced on mobile. step 4.9 says to remove entrypage's mobile sticky bottom nav and 'use the same footercontent slot in submissioncarouselcard', but src/components/submissioncarouselcard.tsx:217-221 renders footercontent inside classname=\"hidden md:block\". in the current repo, the mobile sticky nav at src/pages/entrypage.tsx:283-340 is the only mobile surface for back/next and the score toggle, so the revised plan would remove working mobile controls and replace them with a slot that is explicitly hidden on phones. (flagged 1 times across 1 plans)",
"[DEBT] did-the-work-fully-address-the-issue-hints-user-notes-and-approved-plan-requirements: did the work fully address the issue hints, user notes, and approved plan requirements?: the plan still contradicts itself on mobile behavior. assumption #3 says the browse-mode mobile score toggle will be preserved, but step 4.9 removes the entire mobile sticky nav that contains that toggle in src/pages/entrypage.tsx:314-330. the implementer cannot satisfy both instructions as written. (flagged 1 times across 1 plans)",
"[DEBT] did-the-work-fully-address-the-issue-hints-user-notes-and-approved-plan-requirements: did the work fully address the issue hints, user notes, and approved plan requirements?: checked step 7 against the brief's explicit prompt-builder requirement. the revision fixes the old context leak by introducing a brand-new heavy_criteria_review_prompt, but the brief said _review_prompt() should stay as-is and still run as the criteria_verdict check in heavy mode; v3 solves the problem by replacing that heavy-mode criteria path instead of reusing the baseline review prompt, which is still a material divergence from the requested design. (flagged 1 times across 1 plans)",
"[DEBT] diff-capture: diff capture: the proposed collect_git_diff_patch(project_dir) helper uses git diff head, which will miss untracked files even though the existing execution-evidence path already treats untracked files as real changed work. (flagged 1 times across 1 plans)",
"[DEBT] does-the-change-touch-all-locations-and-supporting-infrastructure: does the change touch all locations and supporting infrastructure?: if the implementation really wants footercontent to carry mobile actions, the plan must also include a supporting change in src/components/submissioncarouselcard.tsx or render a separate mobile control surface outside the card. right now step 4.9 removes the mobile nav but does not list submissioncarouselcard.tsx:217-221 as a place that must change, so the required glue for mobile controls is missing. (flagged 1 times across 1 plans)",
"[DEBT] does-the-change-touch-all-locations-and-supporting-infrastructure: does the change touch all locations and supporting infrastructure?: the prior missing locations in megaplan/workers.py and tests/test_workers.py are now covered, but one supporting-infrastructure path is still absent from the steps: the repo-root generated schema copy under .megaplan/schemas/review.json and the tests that read it directly. without either explicitly regenerating that file or changing those tests to materialize schemas in a temp root, the plan can still leave the runtime-schema copy out of sync with the raw registry. (flagged 1 times across 1 plans)",
"[DEBT] does-the-change-touch-all-locations-and-supporting-infrastructure: does the change touch all locations and supporting infrastructure?: the plan adds _set_active_step and _clear_active_step helpers to handlers.py. _run_worker (handlers.py:135) is modified to accept a resolved parameter. but _run_worker is also called directly by handle_critique's sequential fallback at line 801 and 803. these calls currently don't pass resolved. the plan's step 2.6 for handle_critique says to set active_step after resolution at line 794 \u2014 but the _run_worker calls at 801/803 would re-resolve the agent internally (since resolved isn't passed). this means the agent is resolved twice on the critique sequential path. the double-resolution is wasteful but correct (same result). however, to match the plan's goal of 'resolve_agent_mode() is called once per handler invocation', the resolved tuple should be passed to these _run_worker calls too. (flagged 1 times across 1 plans)",
"[DEBT] execute-phase-contract: early-killed baselines pass truncated output to the execute worker, which may produce lower-quality diagnosis than full output. (flagged 1 times across 1 plans)",
"[DEBT] find-the-callers-of-the-changed-function-what-arguments-do-they-actually-pass-does-the-fix-handle-all-of-them: find the callers of the changed function. what arguments do they actually pass? does the fix handle all of them?: i checked the skip caller path against the real hook behavior and removefromqueue(entryid) looks redundant. scoring.skipentry(entryid) optimistically adds the id to skippedentryids in src/hooks/usescoring.ts:245-249, and usecarouselqueue already reactively filters skipped entries from submissions[] in src/hooks/usecarouselqueue.ts:154-165. calling removefromqueue() immediately afterward is safe, but it duplicates an existing state transition and should be justified as an explicit ux optimization rather than required logic. (flagged 1 times across 1 plans)",
"[DEBT] find-the-callers-of-the-changed-function-what-arguments-do-they-actually-pass-does-the-fix-handle-all-of-them: find the callers of the changed function. what arguments do they actually pass? does the fix handle all of them?: the direct ui sign-in caller is still important here. scorepanel invokes its own onrequiresignin prop when an unauthenticated user interacts with the score ui (src/components/scorepanel.tsx:499-515), which is independent of the scoring hook's internal requireauth() path. the plan should be read as requiring that caller to dispatch open_sign_in_modal; otherwise one caller remains broken even if submitscore() is correctly wired. (flagged 1 times across 1 plans)",
"[DEBT] find-the-callers-of-the-changed-function-what-arguments-do-they-actually-pass-does-the-fix-handle-all-of-them: find the callers of the changed function. what arguments do they actually pass? does the fix handle all of them?: i rechecked the caller paths after the revision. the raw-schema caller path through validate_payload() is now accounted for, but the runtime-schema caller path still is not: strict_schema() only reaches the on-disk runtime schemas through ensure_runtime_layout(), while current tests like tests/test_schemas.py and tests/test_parallel_review.py consume the already-written repo copy directly. the plan does not yet say how that caller path gets refreshed or asserted after the code change. (flagged 1 times across 1 plans)",
"[DEBT] handler-boilerplate: _run_worker() pseudocode hardcodes iteration=state['iteration'] but handle_plan and handle_revise use different failure iteration values. (flagged 1 times across 1 plans)",
"[DEBT] handler-boilerplate: same issue as correctness-1: failure iteration would be wrong for plan/revise handlers. (flagged 1 times across 1 plans)",
"[DEBT] install-paths: local setup path doesn't expose subagent mode (flagged 1 times across 1 plans)",
"[DEBT] install-paths: no automated guard to keep the mirror file synchronized with source files (flagged 1 times across 1 plans)",
"[DEBT] install-paths: local setup test only checks agents.md existence, not content (flagged 1 times across 1 plans)",
"[DEBT] is-there-convincing-verification-for-the-change: is there convincing verification for the change?: the test-plan details still miss a small but real infrastructure update: the current locationdisplay helper in src/pages/submissionscarouselpage.test.tsx:289-291 only renders location.pathname, so the step 7 requirement to assert { state: { carousel: true, navdirection: 'forward' } } cannot be implemented unless that helper is extended to expose location.state. the same pattern exists in the related page tests. (flagged 1 times across 1 plans)",
"[DEBT] is-there-convincing-verification-for-the-change: is there convincing verification for the change?: there is still no explicit mobile regression test in the plan, even though the revised implementation proposal removes the only current mobile nav/score surface. given the repository's actual component structure, a mobile-focused test or visual verification step is needed to prove controls remain accessible below md. (flagged 1 times across 1 plans)",
"[DEBT] mobile-ui: mobile ui: removing entrypage's mobile sticky nav and relying on submissioncarouselcard.footercontent would break mobile navigation and scoring because that footer slot is hidden below the md breakpoint. (flagged 1 times across 1 plans)",
"[DEBT] runtime-schema-sync: runtime schema sync: the plan still does not include an explicit refresh or validation step for the generated .megaplan/schemas/review.json copy that repository tests read directly. (flagged 1 times across 1 plans)",
"[DEBT] search-for-related-code-that-handles-the-same-concept-is-the-reported-issue-a-symptom-of-something-broader: search for related code that handles the same concept. is the reported issue a symptom of something broader?: the mobile problem is broader than entrypage. submissionscarouselpage already has a pre-existing mobile gap because its score panel is desktop-only and its footer actions are also hidden on mobile (src/pages/submissionscarouselpage.tsx:250-263,347-354 plus src/components/submissioncarouselcard.tsx:219). the revised plan says entrypage should 'match the carouselpage pattern', which would spread that existing gap into the one page that currently has working mobile controls. (flagged 1 times across 1 plans)",
"[DEBT] search-for-related-code-that-handles-the-same-concept-is-the-reported-issue-a-symptom-of-something-broader: search for related code that handles the same concept. is the reported issue a symptom of something broader?: the revised plan correctly narrows the schema-shape problem itself back to the six audited mismatches, but the generated runtime-schema consumer path is broader than the plan acknowledges: tests/test_parallel_review.py also reads the runtime review.json schema from schemas_root(repo_root), so stale generated schema copies can affect more than the direct schema tests. (flagged 1 times across 1 plans)",
"[DEBT] subagent-safeguards: hermes reference safeguard numbers not validated against actual implementation (flagged 1 times across 1 plans)",
"[DEBT] subagent-safeguards: plan's retry caps (1 phase, 3 execute) may differ from hermes-agent's actual policy (flagged 1 times across 1 plans)",
"[DEBT] worker-permissions: codex --full-auto flag only triggers for step == 'execute', not 'loop_execute' (flagged 1 times across 1 plans)",
"[DEBT] worker-permissions: claude --permission-mode bypasspermissions only triggers for step == 'execute', not 'loop_execute' (flagged 1 times across 1 plans)",
"[DEBT] workflow-state-machine: _plan_prompt() does not read research.json, so replanning from state_researched would ignore research results. (flagged 1 times across 1 plans)",
"[DEBT] workflow-state-machine: same issue as correctness-2: state_researched \u2192 plan path is only partially wired. (flagged 1 times across 1 plans)",
"[DEBT] workflow-state-machine: _plan_prompt() is a missed location for the state_researched \u2192 plan change. (flagged 1 times across 1 plans)"
]
code
Requirements:
- Produce structured JSON only.
- `tasks` must be an ordered array of task objects. Every task object must include:
- `id`: short stable task ID like `T1`
- `description`: concrete work item
- `depends_on`: array of earlier task IDs or `[]`
- `status`: always `"pending"` at finalize time
- `executor_notes`: always `""` at finalize time
- `reviewer_verdict`: always `""` at finalize time
- `watch_items` must be an array of strings covering runtime risks, critique concerns, and assumptions to keep visible during execution.
- `sense_checks` must be an array with one verification question per task. Every sense-check object must include:
- `id`: short stable ID like `SC1`
- `task_id`: the related task ID
- `question`: reviewer verification question
- `verdict`: always `""` at finalize time
- `meta_commentary` must be a single string with execution guidance, gotchas, or judgment calls that help the executor succeed.
- `validation` must be an object that self-checks plan coverage:
- `plan_steps_covered`: enumerate EVERY step from the approved plan. For each step, provide a short `plan_step_summary` (the step's intent in one phrase) and `finalize_task_ids` (array of task IDs that implement it — a single plan step may map to multiple tasks).
- `orphan_tasks`: task IDs that do not correspond to any plan step. Normally empty. If non-empty, explain in `completeness_notes`.
- `completeness_notes`: free-text explanation of any gaps, deviations, or deliberate omissions.
- `coverage_complete`: set to `true` only if every plan step has at least one finalize task AND you have verified the mapping by reviewing each entry. Set to `false` if any plan step is missing coverage.
- Example:
```json
"validation": {
"plan_steps_covered": [
{"plan_step_summary": "Add retry logic to API client", "finalize_task_ids": ["T1", "T2"]},
{"plan_step_summary": "Update configuration schema", "finalize_task_ids": ["T3"]}
],
"orphan_tasks": [],
"completeness_notes": "All plan steps mapped to tasks.",
"coverage_complete": true
}
```
- Preserve information that strong existing artifacts already capture well: execution ordering, watch-outs, reviewer checkpoints, and practical context.
- The structured output should be self-contained: an executor reading only `finalize.json` should have everything needed to work.
- Keep the task count proportional to the work. A simple 1-2 file fix should be 2 tasks: (1) apply the fix, (2) run tests. Do NOT create separate "inspect" or "read" tasks for simple changes — the executor can read and fix in one step. Only create more tasks when the work has genuinely independent stages.
- The FINAL task MUST always be to run tests and verify the changes work. If specific test IDs or commands are mentioned in the original task, include them. Otherwise, the executor should find and run the tests most relevant to the files changed. If any test fails, read the error, fix the code, and re-run until they pass. Do NOT create new test files — run the project's existing test suite. Additionally, the executor should write a short throwaway script that reproduces the specific bug described in the task, run it to confirm the fix works, then delete the script.