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.
Add a megaplan tiebreaker command that takes an architectural/design decision question and produces structured context for a human final call, by running two subagents in sequence (researcher → challenger) and presenting their output in a decision-ready format.
Motivation. When megaplan's gate returns ESCALATE because the plan's constraints are inconsistent (needs a human architectural decision), the human is left with just the gate rationale. No structured research, no stress-test. A megaplan tiebreaker subcommand can call two 125-IQ-engineer-style subagents with different mandates, then output their findings in a shape that makes the final call fast and well-informed.
Reuse, don't reinvent. The researcher is a stripped-down plan-phase worker with a research-focused prompt. The challenger is a stripped-down critique-phase worker that reads the researcher's output. Both write to artifact files next to the plan's other artifacts. Reuse the worker dispatch machinery (run_codex_step / run_claude_step / SessionDB) — do NOT reinvent.
The question file or inline question states the decision, the constraints that can't all hold, and any pinned context (relevant files, patterns to consider).
Phase flow inside the subcommand (not new top-level phases):
Researcher pass — worker reads the question, the repo, the plan's current state (if any), and the critique history. Produces tiebreaker_researcher.json with fields: question, evidence (array of {claim, evidence_type: "code|measurement|pattern|doc", file_paths, quote}), options (array of {name, description, assumptions, costs}), preliminary_pick ({option_name, rationale, what_I'm_least_sure_about}).
Assistant
Let me read the key files to understand the current codebase structure before producing the briefing.
Assistant
Now I have the full picture. Producing the execution briefing.
Assistant
Execution briefing produced with 6 tasks mapping 1:1 to the plan's 6 steps. The three open critique flags (args.agent bare access, session persistence, state mutation) are resolved in the watch items and T3 guidance: use ephemeral mode and pass a state copy.
Challenger pass — second worker, fresh session, reads the researcher's JSON plus the question and repo. Produces tiebreaker_challenger.json with: measurements_vs_assumptions, missing_options, hard_cases, reframings, aging_analysis, counter_recommendation.
Synthesis output — final tiebreaker.md structured for the human: Decision, Options considered (table), Evidence summary, Researcher pick vs challenger call, Where they agree, Where they disagree, Recommended framing, Fallback plan.
Important design rules:
Two separate persistent sessions for researcher and challenger; challenger must NOT see researcher's session, only the JSON output. Independence is the point.
Both workers use codex by default (config agents.tiebreaker_researcher and agents.tiebreaker_challenger, defaulting to codex). Claude is a valid alternative and should be configurable.
Researcher's prompt explicitly asks for evidence-over-opinion; challenger's prompt explicitly asks for stress-test-not-restate.
Tiebreaker does NOT auto-resolve the original plan's state. Advisory only.
megaplan tiebreaker status shows whether researcher, challenger, and synthesis have each completed.
Idempotent: re-running writes new artifacts with v2/v3 suffixes.
Testable: unit tests for prompt rendering, JSON schema validation, synthesis markdown rendering.
Add a megaplan tiebreaker command that orchestrates two independent subagent passes (researcher → challenger) to produce structured decision context for human architectural calls. The command operates on an existing plan and writes advisory artifacts alongside existing plan artifacts.
Current repo shape: v0.16.0. CLI commands register via build_parser() in cli.py:802–952, with complex commands (auto, chain) using the build_*_parser() + deferred-import pattern dispatched directly in main() at lines 1037–1049. Workers are dispatched through run_step_with_worker() (workers.py:1477) which resolves agent → run_codex_step() / run_claude_step(). Schemas live in megaplan/schemas.py:SCHEMAS dict and are written to .megaplan/schemas/ at setup time.
Key design decisions (resolving open questions from v1):
Agent config: Both CLI --agent flag AND per-plan config via agents.tiebreaker_researcher / agents.tiebreaker_challenger are supported. This is free — resolve_agent_mode() at workers.py:1424 already falls back through --agent → config.agents.<step> → DEFAULT_AGENT_ROUTING[step]. We just register the two step names in DEFAULT_AGENT_ROUTING.
Artifact location: Artifacts go directly in the plan directory (e.g., .megaplan/plans/<name>/tiebreaker_researcher.json), matching the existing pattern where all phase artifacts live flat in the plan dir.
Status sub-subcommand: Use argparse sub-subparsers under tiebreaker, matching the config/debt/step pattern (cli.py:856–902). megaplan tiebreaker status --plan <name>.
Worker reuse strategy: We call run_step_with_worker() directly (not _run_worker() from handlers.py which assumes plan-phase semantics like set_active_step). We pass resolved=(agent, mode, True, model) to pre-resolve the agent and prompt_override for custom prompts. Schemas are registered in STEP_SCHEMA_FILENAMES + SCHEMAS so the existing schema-loading in run_codex_step/run_claude_step works unchanged.
Phase 1: Foundation — Schemas, Types, Prompts
Step 1: Add tiebreaker schemas and routing (megaplan/schemas.py, megaplan/workers.py, megaplan/types.py)
Scope: Small
Add two schemas to SCHEMAS dict (megaplan/schemas.py:8):
Builds prompt including: the decision question, current plan text (if available from plan_dir/plan.md), critique history summary (if available), and repo root for exploration.
Core directives: "Evidence over opinion. Every claim must cite a file path and optionally a quote. Enumerate ALL viable options — do not pre-filter. For each option list assumptions that must hold and concrete costs. Give a preliminary pick but explicitly state what you're least sure about."
Includes: the decision question, the researcher's full JSON output (serialized), repo root.
Core directives: "Stress-test, don't restate. For each evidence item, check if it's a measurement or an assumption. Identify options the researcher missed. Find hard cases that break the recommended option. Reframe the decision if the researcher's framing hides a better decomposition. Aging analysis: how does each option look in 6 months and 2 years? Give a counter-recommendation only if you genuinely disagree."
Explicitly does NOT include researcher session ID or any session context.
Pure function (no I/O) that produces markdown with sections: # Tiebreaker: {question}, ## Options Considered (table: Name | Description | Assumptions | Costs), ## Evidence Summary, ## Researcher Pick (option + rationale), ## Challenger Assessment (agree/disagree + rationale), ## Where They Agree, ## Where They Disagree, ## Recommended Framing, ## Fallback Plan.
Agreement/disagreement derived by comparing researcher.preliminary_pick.option_name with challenger.counter_recommendation.option_name and agrees_with_researcher.
Do NOT register these in megaplan/prompts/__init__.py dispatch tables — they are used exclusively via prompt_override.
run_tiebreaker_cli(root: Path, args: Namespace) -> int — top-level dispatch that routes to _run_tiebreaker() or _run_tiebreaker_status() based on args.tiebreaker_action.
_run_tiebreaker(root, args) -> int:
Resolve plan: plan_dir = plans_dir(root) / args.plan. Validate it exists.
Validate and write tiebreaker_challenger{suffix}.json.
Render synthesis via render_synthesis(question, researcher_payload, challenger_payload).
Write tiebreaker{suffix}.md to plan_dir.
Print path to synthesis file, return 0.
_run_tiebreaker_status(root, args) -> int: Check existence of tiebreaker_researcher*.json, tiebreaker_challenger*.json, tiebreaker*.md in plan_dir. Print status table (phase | status | file). Return 0.
_next_version_suffix(plan_dir: Path) -> str: Scan for existing tiebreaker_researcher*.json files, return "" for first run, "_v2" for second, etc.
Key detail on session independence: The researcher step name "tiebreaker_researcher" and challenger step name "tiebreaker_challenger" produce different session keys via session_key_for(step, agent) in workers.py. This ensures they get separate persistent sessions automatically. The challenger's prompt includes the researcher's JSON output but has no access to the researcher's conversation history.
Key detail on args namespace: The tiebreaker parser adds --agent, --fresh (default True for both passes), and --persist (default True). These are read by resolve_agent_mode() when resolved= is not passed. We call resolve_agent_mode() ourselves for each step (researcher/challenger separately, since they could have different config routing) and pass the result as resolved= to run_step_with_worker().
Error handling: If the researcher pass fails, bail immediately (don't attempt challenger). If the challenger fails, the researcher artifact is already written — status will show partial completion. Re-running produces a new version.
Step 4: Wire CLI dispatch (megaplan/cli.py)
Scope: Small
Add parser registration after chain parser (cli.py:950):
python
from megaplan.tiebreaker import build_tiebreaker_parser
build_tiebreaker_parser(subparsers)
Add dispatch block in main() after the chain block (after cli.py:1049):
python
if args.command == "tiebreaker":
from megaplan.tiebreaker import run_tiebreaker_cli
try:
return run_tiebreaker_cli(root, args)
except CliError as error:
return error_response(error, root=root)
Phase 3: Tests and Polish
Step 5: Unit tests (tests/test_tiebreaker.py)
Scope: Medium
Test researcher prompt rendering: Call researcher_prompt() with a sample question and minimal state dict. Verify output contains: the question text, "evidence over opinion" directive, plan text (when available), and instructions to cite file paths.
Test challenger prompt rendering: Call challenger_prompt() with a sample question, sample researcher JSON, and minimal state. Verify: researcher JSON appears in prompt, "stress-test" directive present, no session ID or session context leakage.
Test synthesis rendering: Call render_synthesis() with sample researcher + challenger dicts. Verify output contains all 8 required sections (## Options Considered, ## Evidence Summary, ## Researcher Pick, ## Challenger Assessment, ## Where They Agree, ## Where They Disagree, ## Recommended Framing, ## Fallback Plan). Verify the options table has correct columns.
Test schema validation: Create minimal valid payloads for both tiebreaker_researcher.json and tiebreaker_challenger.json schemas. Validate with jsonschema.validate(). Also test that missing required fields produce validation errors.
Test version suffix logic: Create a tmpdir, touch tiebreaker_researcher.json and tiebreaker_researcher_v2.json, verify _next_version_suffix() returns "_v3". Verify empty dir returns "".
Test status output: Create a tmpdir with various artifact combinations (none, researcher only, all three), verify _run_tiebreaker_status() prints correct status for each phase.
UseMEGAPLAN_MOCK_WORKERS=1 env var for any test that would invoke actual workers.
Step 6: Schema registry test + version bump (tests/test_schemas.py, pyproject.toml, CHANGELOG.md)
Scope: Small
Updatetest_schema_registry_matches_5_step_workflow at tests/test_schemas.py:33 — the existing required set asserts core workflow schemas; add a separate test test_tiebreaker_schemas_registered that verifies tiebreaker_researcher.json and tiebreaker_challenger.json are in SCHEMAS.
Bump version in pyproject.toml from 0.16.0 to 0.17.0.
Add CHANGELOG entry describing the new tiebreaker subcommand.
Orchestrator (Step 3) — main implementation, depends on schemas and prompts.
CLI wiring (Step 4) — simple integration after orchestrator exists.
Tests (Step 5) — validate everything works together.
Schema test + version/changelog (Step 6) — last.
Validation Order
Run pytest tests/test_schemas.py after Step 1 to verify schemas are well-formed.
Run pytest tests/test_tiebreaker.py after Step 5 for unit-level validation.
Run full pytest after Step 6 to catch regressions in existing tests.
code
Plan metadata:
{
"version": 2,
"timestamp": "2026-04-15T10:54:01Z",
"hash": "sha256:efa02e513460c482b77ee58e5426c99fd2f7ed2c993a31f952f6c18063756830",
"changes_summary": "No critique flags were raised. Resolved all three open questions from v1 (agent config routing, artifact location, status subcommand syntax) with concrete decisions in the Overview. Added full JSON schema definitions inline in Step 1. Clarified that we call resolve_agent_mode() ourselves per-step and pass resolved= to run_step_with_worker() rather than building synthetic args. Added requires fields to all success criteria. Tightened Step 3 with explicit error handling strategy (bail on researcher failure, partial artifact on challenger failure). Collapsed Steps 7+8 into Step 6 to reduce step count from 8 to 6.",
"flags_addressed": [],
"questions": [],
"success_criteria": [
{
"criterion": "megaplan tiebreaker --plan --question '...' runs researcher then challenger and produces tiebreaker.md in plan_dir",
"priority": "must",
"requires": [
"run_shell",
"read_files"
]
},
{
"criterion": "megaplan tiebreaker --plan --question-file path works as alternative to inline question",
"priority": "must",
"requires": [
"run_shell",
"read_files"
]
},
{
"criterion": "megaplan tiebreaker status --plan reports completion status of researcher, challenger, and synthesis phases",
"priority": "must",
"requires": [
"run_shell"
]
},
{
"criterion": "Researcher and challenger use separate persistent sessions \u2014 challenger prompt contains researcher JSON output but has no access to researcher session context",
"priority": "must",
"requires": [
"read_files"
]
},
{
"criterion": "Both workers default to codex via DEFAULT_AGENT_ROUTING but are configurable via config agents.tiebreaker_researcher / agents.tiebreaker_challenger and CLI --agent",
"priority": "must",
"requires": [
"read_files"
]
},
{
"criterion": "Researcher output validates against tiebreaker_researcher.json schema",
"priority": "must",
"requires": [
"run_tests"
]
},
{
"criterion": "Challenger output validates against tiebreaker_challenger.json schema",
"priority": "must",
"requires": [
"run_tests"
]
},
{
"criterion": "Tiebreaker does NOT call set_active_step, save_state, or otherwise modify plan state \u2014 advisory only",
"priority": "must",
"requires": [
"read_files",
"parse_diff"
]
},
{
"criterion": "Re-running tiebreaker writes new artifacts with _v2/_v3 suffixes rather than overwriting",
"priority": "must",
"requires": [
"run_tests"
]
},
{
"criterion": "All existing tests pass (pytest exits 0)",
"priority": "must",
"requires": [
"run_tests"
]
},
{
"criterion": "Unit tests exist for: prompt rendering (researcher + challenger), schema validation (both schemas), synthesis markdown rendering, version suffix logic, and status output",
"priority": "must",
"requires": [
"run_tests"
]
},
{
"criterion": "tiebreaker.py reuses run_step_with_worker from workers.py rather than reimplementing worker dispatch",
"priority": "must",
"requires": [
"read_files"
]
},
{
"criterion": "Researcher prompt emphasizes evidence-over-opinion; challenger prompt emphasizes stress-test-not-restate",
"priority": "should",
"requires": [
"read_files"
]
},
{
"criterion": "Synthesis markdown includes all 8 specified sections: Options table, Evidence summary, Researcher Pick, Challenger Assessment, Where They Agree, Where They Disagree, Recommended Framing, Fallback Plan",
"priority": "should",
"requires": [
"read_files"
]
},
{
"criterion": "tiebreaker.py under ~400 lines; each prompt file under ~150 lines",
"priority": "should",
"requires": [
"read_files"
]
}
],
"assumptions": [
"Tiebreaker follows the auto/chain pattern: own module with build_tiebreaker_parser(), dispatched directly in main() rather than through COMMAND_HANDLERS",
"Tiebreaker reads plan state via load_plan_locked() but releases the lock immediately before running workers \u2014 advisory only, no state mutations",
"Artifacts go directly in the plan directory alongside existing phase artifacts (not a subdirectory), matching the flat layout of plan.md, critique.json, etc.",
"Prompt dispatch tables in prompts/init.py are NOT modified \u2014 tiebreaker uses prompt_override exclusively",
"Version bump to 0.17.0 as indicated in the idea",
"Status uses argparse sub-subparsers under tiebreaker, matching the config/debt/step pattern in cli.py:856-902",
"Both tiebreaker steps are registered in STEP_SCHEMA_FILENAMES and DEFAULT_AGENT_ROUTING so resolve_agent_mode() and schema loading work without special-casing",
"resolve_agent_mode() is called once per step (researcher, challenger) so they can have different agent config if desired"
],
"delta_from_previous_percent": 81.48,
"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": "Worker dispatch: resolve_agent_mode() accesses args.agent directly (workers.py:1418,1428) without getattr, so the synthetic args namespace must include .agent or it will AttributeError. The plan mentions constructing a synthetic args namespace but does not enumerate the required attributes: agent, phase_model (used via getattr), hermes (used via getattr), ephemeral/fresh/persist (used via getattr). Missing .agent specifically would be a runtime crash.",
"evidence": "workers.py:1418 explicit = args.agent and workers.py:1428 explicit_agent = args.agent are bare attribute access, not getattr.",
"status": "open",
"severity": "minor"
},
{
"id": "FLAG-002",
"concern": "Worker dispatch: apply_session_update() is NOT called by run_step_with_worker itself. Callers (handlers.py:281) are responsible for persisting session IDs. The tiebreaker orchestrator does not mention calling apply_session_update after each worker completes. Without it, codex persistent sessions cannot resume on retry or re-run. For advisory one-shot use this is acceptable, but the plan claims idempotent re-run (v2/v3 suffixes) which implies sessions should persist. The orchestrator should either call apply_session_update or explicitly use fresh/ephemeral mode to make the one-shot intent clear.",
"evidence": "handlers.py:281 shows apply_session_update is called by the handler, not by run_step_with_worker. Plan Step 4 does not mention it.",
"status": "open",
"severity": "minor"
},
{
"id": "FLAG-003",
"concern": "State pollution: run_step_with_worker internal retry path (workers.py:1537) calls apply_session_update which writes session data into the plan state dict. Since tiebreaker is advisory and should not modify plan state, the retry path would silently add tiebreaker session keys to state sessions. Minor state pollution, not a correctness failure, but the orchestrator should either pass a copy of state or avoid persisting state after tiebreaker runs.",
"evidence": "workers.py:1537-1552 retry path calls apply_session_update(state, step, agent, session_id, ...) which mutates the state dict.",
"status": "open",
"severity": "minor"
}
]
"[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.