Robust Review Phase for Megaplan (Heavy Mode Only)
Context
Megaplan is a planning/execution harness with phases: prep → plan → critique → gate → (revise → critique → gate)* → finalize → execute → review. Critique already has a "robust" mode where it runs multiple focused checks in parallel (megaplan/parallel_critique.py + megaplan/checks.py), each as an independent sub-agent with its own session. We validated on ~15 random SWE-bench failures that the current single-call review phase misses ~65% of salvageable failures because it anchors to the plan's success criteria instead of the original issue text, and because it evaluates everything in one call without forced enumeration.
Goal
Add a robust review mode that mirrors the robust critique architecture: multiple focused, parallel, issue-anchored checks that produce structured flags with rework directives, which feed back through the existing gate → revise/re-execute loop.
Standard robustness mode must remain exactly as today. This design is heavy-mode only.
What exists today (don't break)
megaplan/prompts/review.py — single-call review prompt; validates execution against finalize.json criteria/task_verdicts/sense_check_verdicts. Works well as the baseline. Keep it.
megaplan/prompts/critique.py + megaplan/parallel_critique.py + megaplan/checks.py — the pattern we're mirroring. Read these to understand the architecture.
megaplan/handlers.pyhandle_review() — entry point. Currently calls a single worker.
The gate → revise/re-execute loop already exists with max iteration cap and ESCALATE semantics.
intent_and_notes_block(state) contains the original issue text — crucial input for issue-anchored checks.
What needs to exist
1. New check table for review
New file megaplan/review_checks.py mirroring megaplan/checks.py. Define REVIEW_CHECKS with these entries (core + extended tiers). Each check has id, question, guidance, category, default_severity, tier:
Core tier (always run in heavy mode):
Assistant
User
Assistant
I’m reviewing the revised plan against the repo and the prior flags. First I’ll read the iteration-2 template, then re-check the concrete repo seams the plan claims to have fixed before I update the findings and verified flags.
Assistant
I’ve rechecked the revised seams and one new tension is already clear: the plan fixes the old 3-cycle default by lowering the global review cap, but _resolve_review_outcome() applies that cap to every review path, so this is no longer heavy-mode-only. I’m now checking whether the new criteria_verdict check and diff/plumbing choices still line up with the repo’s actual review architecture or introduce fresh drift.
Assistant
I’ve finished the repo-side recheck of the revised fixes. Two of the old problems are genuinely fixed, but two new tensions remain: the plan now changes the global review loop for standard mode, and its new criteria_verdict check still inherits _review_prompt’s broad context and git status-style diff summary, which conflicts with the heavy-review check isolation the brief calls for.
Assistant
I’ve got enough context to write the second-pass critique. I’m updating the template now with verified prior fixes, two remaining significant issues, and one smaller API-drift finding about how the new review check registry no longer actually mirrors megaplan/checks.py.
Assistant
User
Assistant
I’m reviewing the v3 revision against the repo and the prior iteration’s flags. First I’ll read the iteration-3 template, then re-check the exact code paths this revision claims to fix before I write the new findings and verified flags.
Assistant
I’m rechecking the remaining sharp edges in v3: the new heavy-only cap key, the full-diff helper, and whether the revised validation claims still line up with the repo’s actual config/schema/test plumbing. After that I’ll update the template with whichever prior flags are genuinely closed and any new drift introduced by v3.
Assistant
One possible new risk in v3 is emerging from the new diff helper choice: git diff HEAD will miss untracked files, while this repo’s existing execution/review plumbing treats untracked files as real execution evidence via git status --short. I’m checking that path now because it directly affects whether the heavy review would actually see the whole patch.
Assistant
I’ve isolated the remaining v3 gaps. The previous standard-cap and context-leak flags are mostly fixed, but v3 introduces a new design divergence by replacing _review_prompt() instead of reusing it in heavy mode, and its proposed git diff HEAD helper would miss untracked files that this repo already treats as real execution evidence.
Assistant
coverage — Enumerate every concrete failing example, symptom, or "X should Y" statement in the issue. For each, point to the specific line in the diff that addresses it. Flag any not covered. Subsumes intent/opt-in/default and accepted-changes concerns.
placement — Trace the call path from the failing input to where we made the change. Is the fix at the source of the bug or a downstream consumer? Would a maintainer put it here or elsewhere?
parity — Find 2–3 structurally similar classes/functions in the same module. Enumerate the methods/overrides/conventions they share. Does our new code follow the same patterns? If not, why not? (Highest new-leverage check.)
simplicity — What's the smallest possible change that would make the reported issue's example work? Compare against our diff. Every extra line must justify its existence against a specific requirement in the issue.
Extended tier (heavy mode with extended robustness):
dead_guard — For every new if x: / try: block added by the patch, trace whether the guarded branch is actually reachable given how callers invoke this function. Flag guards that never fire.
adjacent_calls — What other code calls the changed function or uses the same pattern? Would the same bug affect them?
parser_source — If the bug is in parsing/transformation, is the fix at the source of the bug or at a downstream consumer?
return_value_downstream — For any value the patch returns or constructs in an error path, trace where it flows next. Will the downstream consumer handle it correctly?
Also include a checks_for_robustness() function mirroring megaplan/checks.py.
2. Mechanical pre-checks (no LLM, run before parallel review)
Add a new module megaplan/review_mechanical.py or inline in handlers:
source_touch — Does the diff touch at least one non-test file in the package? Reject test-only diffs.
diff_size_sanity — Compare diff size (lines/hunks/files) to a rough expectation from the issue (number of code snippets × ~10 lines). Flag >3x or <0.3x.
dead_guard_static — For new if x: blocks, AST-parse the changed file, find the enclosing function, check whether x has a callable signature at the call site where it could be None/False. This is a heuristic; don't overreach.
These are advisory flags, not blocks. They populate a pre_check_flags array that the LLM review checks see as input.
3. Parallel review runner
New file megaplan/parallel_review.py, mirroring megaplan/parallel_critique.py. Same architecture: ThreadPoolExecutor, one agent per check, each with its own session via SessionDB, writes findings to a pre-populated template slot. Concurrency of 2 (same as critique). Include the MiniMax→OpenRouter fallback pattern.
Important: each check agent gets the original issue text + the full git diff + the finalize.json artifacts, nothing else. No plan, no critique history, no gate summary. The whole point is that these checks are anchored to the issue, not the plan.
4. Prompt builders for single-check review
In megaplan/prompts/review.py, add:
single_check_review_prompt(state, plan_dir, root, check, output_path) — mirrors single_check_critique_prompt — single focused prompt for one check.
_write_single_check_review_template(plan_dir, state, check, filename) — pre-populates the output file with the check's ID.
_build_review_checks_template(plan_dir, state, checks) — builds the per-check template list.
Keep _review_prompt() as-is. It still runs as the "criteria_verdict" check in heavy mode.
5. Handler integration
In megaplan/handlers.pyhandle_review():
Read configured_robustness(state)
If standard or light → run the existing single-call review unchanged
If heavy → run the mechanical pre-checks, then run parallel_review() across REVIEW_CHECKS + the existing criteria-based review-as-check. Merge all flags into one review.json
The output shape adds a checks array alongside the existing review_verdict, criteria, issues, rework_items, task_verdicts, sense_check_verdicts, summary. Back-compat: existing consumers that only look at review_verdict / rework_items keep working.
6. Feedback loop — how flags flow back
This is the tricky part. The review runs after execute. If it raises blocking flags, where does control go?
Decision: reuse the existing gate → revise/re-execute loop, not a new review-specific loop.
Concretely:
If review_verdict == "needs_rework" with blocking flags, the handler writes them to rework_items as today.
The execute loop in evals/run_evals.py already handles needs_rework by going back to revise or re-execute based on the rework type. No new routing logic.
Add a new field rework_directive.source = "review_{check_id}" so the executor knows the provenance and can prioritize.
Max review iterations cap at 2 (configurable). After 2 rounds of needs_rework from the review, escalate. Otherwise the same check can fire forever on tasks the model can't solve.
Review flags cannot re-raise concerns the gate already settled. Before raising a coverage/placement/parity flag, the review check must check gate.settled_decisions — if the concern matches a settled decision, downgrade to "significant" (info) rather than "blocking". This prevents the gate-override deadlock we hit before.
7. Severity ladder (mirrors critique)
Each review flag has:
blocking — triggers needs_rework, forces another revise/execute pass
significant — logged, shown to gate for future iterations, doesn't auto-block
minor — info only, aggregated into summary
8. Flag tracking across review iterations
Mirror critique's flag registry. Each review check's findings get IDs like REVIEW-COV-001. Status transitions open → verified → resolved across iterations, just like critique flags. Read megaplan/_core flag registry helpers — reuse them, don't duplicate.
9. Schema updates
Add a review checks schema fragment alongside the existing review schema in schemas/ (wherever step schemas live — look at STEP_SCHEMA_FILENAMES in megaplan/workers.py). The schema should allow the existing top-level fields PLUS a new checks array with per-check findings.
10. Tests
Unit tests for REVIEW_CHECKS structure and checks_for_robustness() behavior
Unit test that standard robustness still calls the single-call review (regression guard)
Unit test for mechanical pre-checks (source_touch, diff_size_sanity)
Integration test: feed a known-bad patch through heavy review, assert it raises the expected flag
Integration test: feed a known-good patch through heavy review, assert no blocking flags
Use the existing test infrastructure patterns.
Generalization beyond review
While implementing, keep these generalizations in mind (don't implement them now, but design so they're easy later):
checks_for_robustness() pattern should be extractable to a shared utility — same function body in checks.py and review_checks.py should be one function.
Parallel focused-agent runner (parallel_critique.py + parallel_review.py) should be refactorable to a single parallel_phase_runner.py that both delegate to. Not in this PR, but leave clean seams.
Template-file-with-preloaded-IDs pattern should be documented as "the preferred way to get structured output" in a short comment at the top of parallel_review.py.
Mechanical pre-checks should be runnable standalone so they can be reused by critique, finalize, or any other phase that wants cheap advisory checks.
Out of scope for this plan
Automatic golden-patch comparison for false-negative detection (we already have auto_improve/check_false_negatives.py)
Running these checks on tasks that already passed
A/B evaluation of which checks actually earn their spot (that's a separate measurement exercise)
Any changes to critique, plan, execute, prep, or finalize phases
Any changes to standard or light robustness mode
New top-level phases between review and execute
Success criteria
Heavy mode review produces a checks array with one entry per REVIEW_CHECK
Standard mode review produces byte-identical output to today for the same input
Blocking flags flow through the existing rework loop without new routing logic
Flag iteration cap prevents infinite review→re-execute loops
Unit + integration tests pass
Code follows the same patterns as parallel_critique.py and checks.py — a reader familiar with critique should find nothing surprising in the review code
Files likely to change
NEW: megaplan/review_checks.py
NEW: megaplan/parallel_review.py
NEW: megaplan/review_mechanical.py (or inline in handlers)
Add a heavy-mode review path that mirrors the existing robust-critique architecture: a registry of focused checks (REVIEW_CHECKS), a parallel runner (parallel_review.py), single-check prompt builders, mechanical pre-checks, and a handler branch on configured_robustness(state). Standard/light review must remain byte-identical. Existing patterns to mirror live in megaplan/checks.py, megaplan/parallel_critique.py, megaplan/prompts/critique.py (single_check_critique_prompt, write_single_check_template), and megaplan/flags.py:53 (synthetic-flag-from-check pattern). The current handler entrypoint is megaplan/handlers.py:1105 (handle_review); the schema lives at .megaplan/schemas/review.json.
Key constraints from inspection:
STEP_SCHEMA_FILENAMES (megaplan/workers.py:49) maps "review" → "review.json". We'll extend this same schema with an optional checks array — no new step.
Flag synthesis from checks already exists for critique (megaplan/flags.py:69-87); we'll reuse it via a small refactor to avoid duplication when converting review check findings into rework.
Rework loop already enforces max_review_rework_cycles (megaplan/handlers.py:1089). The brief's "max 2" cap is already configurable via get_effective("execution", "max_review_rework_cycles") — we will document this and not add a new knob.
_critique_context injects plan/critique history; the brief explicitly requires review checks to only see issue text + diff + finalize.json. We'll build a separate _review_check_context rather than reusing _critique_context.
Verifyintent_and_notes_block is exported from megaplan/_core and works without plan/critique context.
Step 2: Add the review check registry (megaplan/review_checks.py)
Scope: Medium
Createmegaplan/review_checks.py mirroring megaplan/checks.py:1-236 exactly. Define ReviewCheckSpec (TypedDict, same shape as CritiqueCheckSpec) and REVIEW_CHECKS containing the four core checks (coverage, placement, parity, simplicity) and four extended checks (dead_guard, adjacent_calls, parser_source, return_value_downstream) with the id/question/guidance/category/default_severity/tier fields specified in the brief.
Provideget_check_ids, get_check_by_id, build_check_category_map, build_empty_template, validate_review_checks, and checks_for_robustness (heavy → all, standard → core, light → ()).
Note in a top-of-file comment that checks_for_robustness here has the same body as megaplan/checks.py:139 and is a candidate for extraction into a shared helper later (per generalization #1 in the brief).
Createmegaplan/review_mechanical.py exposing run_pre_checks(plan_dir, state, project_dir) -> list[dict]. Each entry has id, severity (always advisory), detail, evidence.
Implement three checks:
source_touch: parse git diff --stat (or reuse collect_git_diff_summary); flag if no non-test file in the project package was modified. Test files identified via tests/ path or filename test_*.py.
diff_size_sanity: count lines of diff and code-snippet-shaped blocks in intent_and_notes_block(state) (regex for fenced blocks). Flag if diff_lines > 3 * expected or < 0.3 * expected.
dead_guard_static: walk diff hunks for new if /try: lines, AST-parse the post-image of the file via ast.parse(Path(file).read_text()), locate the enclosing function, and (best-effort) flag guards whose tested name is statically a callable from a default arg. Keep heuristic; on any AST failure, return no findings for that hunk.
Return a flat list. These are advisory only — never blocking.
Add_review_check_context(state, plan_dir) returning only: project_dir, intent_block, git_diff, finalize_data (read from plan_dir / "finalize.json"), gate_settled_decisions (read from gate.json, only the settled_decisions list — nothing else from the gate). No plan, no critique, no execution_audit beyond what's in finalize.
Add_write_single_check_review_template(plan_dir, state, check, filename) that pre-populates {checks: [{id, question, guidance, findings: []}], flags: [], pre_check_flags: []} and returns the path. This intentionally omits task_verdicts/sense_check_verdicts — those still come exclusively from the existing _review_prompt worker (the "criteria_verdict" check).
Add_build_review_checks_template(plan_dir, state, checks) returning the per-check template list (used if we ever run them in one shot; the parallel runner uses the single-check helper).
Inputs: only the issue text (intent_and_notes_block), git diff (collect_git_diff_summary), finalize.json contents, settled-decisions block, and pre_check_flags.
Includes a "Settled gate decisions" block listing each settled decision; the prompt instructs the agent: "If your finding for this check restates a settled decision listed below, downgrade flagged to false and instead record it as a significant note."
Reuses the same finding schema (detail ≥ 40 chars, flagged bool) as critique.
Leave_review_prompt and _write_review_template untouched.
Createmegaplan/parallel_review.py by copying megaplan/parallel_critique.py:1-260 and adapting:
Import single_check_review_prompt, _write_single_check_review_template from megaplan.prompts.review.
Toolset stays _toolsets_for_phase("critique") (read-only investigation toolset is appropriate; verify by reading _toolsets_for_phase — if there is a "review" toolset use it instead).
Schema source: STEP_SCHEMA_FILENAMES["review"]. After Step 7 the review schema will accept the single-check shape.
Concurrency: min(max_concurrent or get_effective("orchestration", "max_critique_concurrency"), len(checks)) — same key as critique per the brief ("Concurrency of 2 (same as critique)"). Document the choice; do not introduce a new config key.
Keep the MiniMax → OpenRouter fallback verbatim.
Output payload: {"checks": [...], "flags": [], "pre_check_flags": [...]} (verified/disputed flag id arrays empty for review v1; flag-registry transitions reuse critique's machinery in Step 6).
Add a top-of-file docstring describing the "template-file-with-preloaded-IDs" output convention (per generalization #3).
Refactormegaplan/flags.py:69-87 (the synthetic-flag-from-check loop inside update_flags_after_critique) into a small helper _synthesize_flags_from_checks(checks, *, category_map, get_check_def, prefix) that returns a list of raw flag dicts.
Addupdate_flags_after_review(plan_dir, review, *, iteration) that uses the same helper with prefix="REVIEW" and writes flags with id REVIEW-{CHECK_ID} (e.g., REVIEW-COVERAGE-001). Flags inherit default_severity from review_checks.get_check_by_id. Reuse load_flag_registry / save_flag_registry.
Status tracking (open → verified → resolved) is handled by the same registry; iteration transitions follow the existing critique pattern.
Extend.megaplan/schemas/review.json to add an optional top-level checks array (per-check {id, question, findings: [{detail, flagged}]}) and an optional pre_check_flags array. Keep checks and pre_check_flags out of required so existing single-call review payloads continue to validate. Existing fields untouched.
VerifyadditionalProperties: false is removed at the top level, or that checks/pre_check_flags are added explicitly to the property list. (Currently additionalProperties: false, so they MUST be added as named properties.)
Step 8: Handler branch (megaplan/handlers.py)
Scope: Medium
Modifyhandle_review (megaplan/handlers.py:1105):
Read robustness = configured_robustness(state) at the top.
If robustness in {"standard", "light"} → existing path unchanged.
If robustness == "heavy":
Run the existing worker_module.run_step_with_worker("review", ...) first — this still produces the criteria/task_verdicts/sense_check_verdicts payload via _review_prompt. This is the brief's "existing criteria-based review-as-check".
Run mechanical pre-checks: pre_check_flags = run_pre_checks(plan_dir, state, project_dir).
Run parallel_review(...) over review_checks.checks_for_robustness("heavy") passing pre_check_flags.
Merge the parallel checks array and pre_check_flags into worker.payload before atomic_write_json(plan_dir / "review.json", ...). Sum cost_usd/duration_ms into the recorded history entry.
Call update_flags_after_review(plan_dir, worker.payload, iteration=state["iteration"]) to register flags.
If any blocking finding (flagged finding whose check default_severity == "likely-significant" AND not downgraded by settled-decision rule), append a corresponding entry to worker.payload["rework_items"] with {task_id: "REVIEW", issue, expected, actual, evidence_file, source: "review_<check_id>"} and force review_verdict = "needs_rework". Pre-existing rework_items from the criteria worker stay.
Confirm_resolve_review_outcome already handles the iteration cap via max_review_rework_cycles (megaplan/handlers.py:1089). No change required there. Surface this in the comment block at the top of the new heavy branch.
No changes to the execute loop in evals/run_evals.py — needs_rework already routes through it.
Step 9: Tests (tests/)
Scope: Medium
Addtests/test_review_checks.py:
Asserts REVIEW_CHECKS contains the eight expected ids with the right tiers.
source_touch returns a flag when a fixture diff touches only tests/foo.py.
diff_size_sanity flags a 2000-line diff against an issue with one ~10-line snippet.
dead_guard_static returns no findings on AST parse failure (graceful).
Addtests/test_handle_review_robustness.py:
Regression: with robustness="standard", handle_review writes a review.json whose top-level keys equal exactly today's set (no checks, no pre_check_flags). Mock the worker to return a fixed payload and assert read_json(plan_dir / "review.json").keys() is unchanged.
Heavy: with robustness="heavy", mock run_parallel_review to return one flagged coverage finding; assert review.json contains a checks array, update_flags_after_review registered a REVIEW-COVERAGE-001 flag, and review_verdict is needs_rework.
pytest tests/ — full suite, especially tests/test_parallel_critique.py, tests/test_checks.py, tests/test_megaplan.py to confirm no regression in critique/standard-review paths.
Manual: run a heavy-mode plan end-to-end against a known-failing SWE-bench case from the validation set; assert at least one of coverage/placement/parity/simplicity flags fires and routes through rework.
code
Plan metadata:
{
"version": 1,
"timestamp": "2026-04-07T20:33:24Z",
"hash": "sha256:c07a743a3d3e70d1943cce1768e3ccfbc3e08845fd9b44c8ac13515767687163",
"questions": [
"The brief says 'Max review iterations cap at 2 (configurable)'. The repo already has max_review_rework_cycles via get_effective('execution', 'max_review_rework_cycles'). Do you want a separate cap for heavy-mode review specifically, or is reusing the existing single cap acceptable?",
"For pre-check dead_guard_static, how aggressive should the AST heuristic be? The brief says 'don't overreach' \u2014 is it acceptable to ship a v1 that only flags the trivial case of if x: where x is a parameter with default None and never reassigned, and skip all other shapes?",
"Should heavy-mode review still consume tokens/budget under the same max_critique_concurrency knob, or do you want a separate max_review_concurrency introduced now (the brief says 'same as critique' so I'm assuming reuse)?",
"When a parallel-review check raises a blocking finding, should the synthesized rework_item be assigned task_id='REVIEW' (a sentinel) or should the review check be required to map its finding to one of finalize.json's task IDs? The latter is more useful to the executor but harder to enforce in the prompt."
],
"success_criteria": [
{
"criterion": "megaplan/review_checks.py exists and exports REVIEW_CHECKS containing exactly the 8 ids: coverage, placement, parity, simplicity, dead_guard, adjacent_calls, parser_source, return_value_downstream",
"priority": "must"
},
{
"criterion": "checks_for_robustness('heavy') returns all 8; checks_for_robustness('standard') returns only the 4 core checks; checks_for_robustness('light') returns ()",
"priority": "must"
},
{
"criterion": "With robustness='standard', handle_review produces a review.json whose top-level key set is identical to today's (no new checks/pre_check_flags keys)",
"priority": "must"
},
{
"criterion": "With robustness='heavy', handle_review writes a review.json containing a checks array with one entry per active REVIEW_CHECK and a pre_check_flags array",
"priority": "must"
},
{
"criterion": "Heavy-mode blocking review findings populate rework_items and set review_verdict='needs_rework', routing through the existing _resolve_review_outcome rework loop with no new routing logic in evals/run_evals.py",
"priority": "must"
},
{
"criterion": ".megaplan/schemas/review.json validates both legacy payloads (no checks field) and new heavy-mode payloads (with checks and pre_check_flags)",
"priority": "must"
},
{
"criterion": "All existing tests in tests/ pass after the change (pytest tests/)",
"priority": "must"
},
{
"criterion": "New unit tests cover REVIEW_CHECKS structure, mechanical pre-checks, the standard-mode regression guard, and the heavy-mode handler branch",
"priority": "must"
},
{
"criterion": "Parallel review check agents receive only issue text + git diff + finalize.json + settled gate decisions \u2014 no plan, no critique history, no full gate summary",
"priority": "must"
},
{
"criterion": "Review-synthesized flags use REVIEW-<CHECK_ID> ids and are registered via the existing flag registry helpers (no parallel registry)",
"priority": "must"
},
{
"criterion": "Existing max_review_rework_cycles setting bounds heavy-mode review iterations (no infinite re-review loop)",
"priority": "must"
},
{
"criterion": "Synthetic-flag-from-check logic is shared between critique and review (one helper, not two copies)",
"priority": "should"
},
{
"criterion": "parallel_review.py is structurally close enough to parallel_critique.py that a future refactor to a shared parallel_phase_runner.py is mechanical",
"priority": "should"
},
{
"criterion": "megaplan/review_mechanical.py is callable as a standalone module so other phases could reuse it later",
"priority": "should"
},
{
"criterion": "End-to-end heavy-mode review on a known-bad SWE-bench patch raises at least one blocking flag from coverage/placement/parity/simplicity",
"priority": "info"
},
{
"criterion": "Heavy review meaningfully reduces the ~65% missed-salvageable-failures rate observed on the 15-task validation set",
"priority": "info"
}
],
"assumptions": [
"Reusing max_review_rework_cycles from get_effective('execution', ...) satisfies the brief's '2-iteration cap (configurable)' requirement \u2014 no new config key.",
"Reusing max_critique_concurrency for parallel review concurrency is acceptable (brief explicitly says 'same as critique').",
"The existing single-call review (_review_prompt) continues to run in heavy mode as the criteria-verdict producer alongside the parallel checks. The parallel checks add to it; they do not replace it.",
"Synthetic review flags are written to the existing flag registry at plan_dir/flags.json with id prefix REVIEW- to avoid colliding with critique's FLAG-NNN numbering.",
"Heavy-mode review's blocking rework items use a sentinel task_id='REVIEW' because finding-to-task mapping cannot be reliably inferred from issue-anchored prompts; the executor reads the source: 'review_<check_id>' field for prioritization.",
"The checks and pre_check_flags fields will be added as explicit named properties in review.json since the schema currently has additionalProperties: false.",
"The settled-decisions downgrade rule is enforced in the prompt (the LLM is told to downgrade) rather than in post-processing \u2014 keeping the rule simple for v1.",
"The existing _toolsets_for_phase('critique') toolset is appropriate for review check agents (read-only repo investigation); if a 'review' toolset exists it will be preferred."
],
"structure_warnings": []
}
code
Plan structure warnings from validator:
[]
Existing flags:
[]
Known accepted debt grouped by subsystem:
{
"are-the-proposed-changes-technically-correct": [
{
"id": "DEBT-009",
"concern": "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.",
"occurrence_count": 1,
"plan_ids": [
"move-the-entry-page-into-20260401-0450"
]
},
{
"id": "DEBT-010",
"concern": "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.",
"occurrence_count": 1,
"plan_ids": [
"move-the-entry-page-into-20260401-0450"
]
}
],
"are-the-success-criteria-well-prioritized-and-verifiable": [
{
"id": "DEBT-019",
"concern": "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.",
"occurrence_count": 1,
"plan_ids": [
"move-the-entry-page-into-20260401-0450"
]
}
],
"did-the-work-fully-address-the-issue-hints-user-notes-and-approved-plan-requirements": [
{
"id": "DEBT-011",
"concern": "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.",
"occurrence_count": 1,
"plan_ids": [
"move-the-entry-page-into-20260401-0450"
]
},
{
"id": "DEBT-012",
"concern": "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.",
"occurrence_count": 1,
"plan_ids": [
"move-the-entry-page-into-20260401-0450"
]
}
],
"does-the-change-touch-all-locations-and-supporting-infrastructure": [
{
"id": "DEBT-018",
"concern": "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.",
"occurrence_count": 1,
"plan_ids": [
"move-the-entry-page-into-20260401-0450"
]
}
],
"execute-phase-contract": [
{
"id": "DEBT-003",
"concern": "early-killed baselines pass truncated output to the execute worker, which may produce lower-quality diagnosis than full output.",
"occurrence_count": 1,
"plan_ids": [
"design-and-implement-a-20260327-0512"
]
}
],
"find-the-callers-of-the-changed-function-what-arguments-do-they-actually-pass-does-the-fix-handle-all-of-them": [
{
"id": "DEBT-014",
"concern": "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.",
"occurrence_count": 1,
"plan_ids": [
"move-the-entry-page-into-20260401-0450"
]
},
{
"id": "DEBT-015",
"concern": "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.",
"occurrence_count": 1,
"plan_ids": [
"move-the-entry-page-into-20260401-0450"
]
}
],
"handler-boilerplate": [
{
"id": "DEBT-004",
"concern": "_run_worker() pseudocode hardcodes iteration=state['iteration'] but handle_plan and handle_revise use different failure iteration values.",
"occurrence_count": 1,
"plan_ids": [
"clean-up-and-properly-20260331-0149"
]
},
{
"id": "DEBT-005",
"concern": "same issue as correctness-1: failure iteration would be wrong for plan/revise handlers.",
"occurrence_count": 1,
"plan_ids": [
"clean-up-and-properly-20260331-0149"
]
}
],
"install-paths": [
{
"id": "DEBT-023",
"concern": "local setup path doesn't expose subagent mode",
"occurrence_count": 1,
"plan_ids": [
"refactor-megaplan-skill-so-20260406-1818"
]
},
{
"id": "DEBT-024",
"concern": "no automated guard to keep the mirror file synchronized with source files",
"occurrence_count": 1,
"plan_ids": [
"update-all-documentation-20260406-1902"
]
},
{
"id": "DEBT-025",
"concern": "local setup test only checks agents.md existence, not content",
"occurrence_count": 1,
"plan_ids": [
"update-all-documentation-20260406-1902"
]
}
],
"is-there-convincing-verification-for-the-change": [
{
"id": "DEBT-016",
"concern": "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.",
"occurrence_count": 1,
"plan_ids": [
"move-the-entry-page-into-20260401-0450"
]
},
{
"id": "DEBT-017",
"concern": "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.",
"occurrence_count": 1,
"plan_ids": [
"move-the-entry-page-into-20260401-0450"
]
}
],
"mobile-ui": [
{
"id": "DEBT-020",
"concern": "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.",
"occurrence_count": 1,
"plan_ids": [
"move-the-entry-page-into-20260401-0450"
]
}
],
"search-for-related-code-that-handles-the-same-concept-is-the-reported-issue-a-symptom-of-something-broader": [
{
"id": "DEBT-013",
"concern": "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.",
"occurrence_count": 1,
"plan_ids": [
"move-the-entry-page-into-20260401-0450"
]
}
],
"subagent-safeguards": [
{
"id": "DEBT-021",
"concern": "hermes reference safeguard numbers not validated against actual implementation",
"occurrence_count": 1,
"plan_ids": [
"refactor-megaplan-skill-so-20260406-1818"
]
},
{
"id": "DEBT-022",
"concern": "plan's retry caps (1 phase, 3 execute) may differ from hermes-agent's actual policy",
"occurrence_count": 1,
"plan_ids": [
"refactor-megaplan-skill-so-20260406-1818"
]
}
],
"worker-permissions": [
{
"id": "DEBT-001",
"concern": "codex --full-auto flag only triggers for step == 'execute', not 'loop_execute'",
"occurrence_count": 1,
"plan_ids": [
"build-megaloop-a-minimal-20260327-0250"
]
},
{
"id": "DEBT-002",
"concern": "claude --permission-mode bypasspermissions only triggers for step == 'execute', not 'loop_execute'",
"occurrence_count": 1,
"plan_ids": [
"build-megaloop-a-minimal-20260327-0250"
]
}
],
"workflow-state-machine": [
{
"id": "DEBT-006",
"concern": "_plan_prompt() does not read research.json, so replanning from state_researched would ignore research results.",
"occurrence_count": 1,
"plan_ids": [
"clean-up-and-properly-20260331-0149"
]
},
{
"id": "DEBT-007",
"concern": "same issue as correctness-2: state_researched \u2192 plan path is only partially wired.",
"occurrence_count": 1,
"plan_ids": [
"clean-up-and-properly-20260331-0149"
]
},
{
"id": "DEBT-008",
"concern": "_plan_prompt() is a missed location for the state_researched \u2192 plan change.",
"occurrence_count": 1,
"plan_ids": [
"clean-up-and-properly-20260331-0149"
]
}
]
}
code
Escalated debt subsystems:
[
{
"subsystem": "install-paths",
"total_occurrences": 3,
"plan_count": 2,
"entries": [
{
"id": "DEBT-023",
"concern": "local setup path doesn't expose subagent mode",
"occurrence_count": 1,
"plan_ids": [
"refactor-megaplan-skill-so-20260406-1818"
]
},
{
"id": "DEBT-024",
"concern": "no automated guard to keep the mirror file synchronized with source files",
"occurrence_count": 1,
"plan_ids": [
"update-all-documentation-20260406-1902"
]
},
{
"id": "DEBT-025",
"concern": "local setup test only checks agents.md existence, not content",
"occurrence_count": 1,
"plan_ids": [
"update-all-documentation-20260406-1902"
]
}
]
},
{
"subsystem": "workflow-state-machine",
"total_occurrences": 3,
"plan_count": 1,
"entries": [
{
"id": "DEBT-006",
"concern": "_plan_prompt() does not read research.json, so replanning from state_researched would ignore research results.",
"occurrence_count": 1,
"plan_ids": [
"clean-up-and-properly-20260331-0149"
]
},
{
"id": "DEBT-007",
"concern": "same issue as correctness-2: state_researched \u2192 plan path is only partially wired.",
"occurrence_count": 1,
"plan_ids": [
"clean-up-and-properly-20260331-0149"
]
},
{
"id": "DEBT-008",
"concern": "_plan_prompt() is a missed location for the state_researched \u2192 plan change.",
"occurrence_count": 1,
"plan_ids": [
"clean-up-and-properly-20260331-0149"
]
}
]
}
]
code
Debt guidance:
- These are known accepted limitations. Do not re-flag them unless the current plan makes them worse, broadens them, or fails to contain them.
- Prefix every new concern with a subsystem tag followed by a colon, for example `Timeout recovery: retry backoff remains brittle`.
- When a concern is recurring debt that still needs to be flagged, prefix it with `Recurring debt:` after the subsystem tag, for example `Timeout recovery: Recurring debt: retry backoff remains brittle`.
Your output template is at: /Users/user_c042661f/Documents/megaplan/.megaplan/plans/robust-review-v2/critique_output.json
Read this file first — it contains 4 checks, each with a question and guidance.
For each check, investigate the codebase, then add your findings to the findings array for that check.
Each finding needs:
"detail": what you specifically checked and what you found (at least a full sentence)
"flagged": true if this describes a difference, risk, or tension — even if you think it's justified. false only if purely informational with no possible downside.
When in doubt, flag it — the gate can accept tradeoffs, but it can't act on findings it never sees.
Good: {"detail": "Checked callers of nthroot_mod in solveset.py line 1205 — passes prime moduli only, consistent with the fix.", "flagged": false}
Good: {"detail": "The fix handles empty tuples but not single-element tuples which need a trailing comma.", "flagged": true}
Bad: {"detail": "No issue found", "flagged": false} ← too brief, will be rejected
Bad: {"detail": "The hints suggest approach X but the plan uses Y. However Y is consistent with X's intent.", "flagged": false} ← a different approach than the hints IS a flag. You found a divergence — flag it. The gate decides if it's acceptable.
After filling in checks, add any additional concerns to the flags array (e.g., security, performance, dependencies).
Use the standard format (id, concern, category, severity_hint, evidence). This array can be empty.
Workflow: read the file → investigate → read file again → add finding → write file back. Repeat for each check.
code
Additional guidelines:
- Robustness level: standard. Use balanced judgment. Flag significant risks, but do not spend flags on minor polish or executor-obvious boilerplate.
- Over-engineering: prefer the simplest approach that fully solves the problem.
- Reuse existing flag IDs when the same concern is still open.
- `verified_flag_ids`: list flag IDs from prior iterations that the revised plan actually resolves (e.g., if the plan was revised to fix FLAG-001, and you confirm the fix is correct, include "FLAG-001"). Only include flags you've verified — don't guess.
- Verify that the plan follows the expected structure when validator warnings or the outline suggest drift.
- Additional flags may use these categories: correctness, security, completeness, performance, maintainability, other.
- Focus on concrete issues, not structural formatting.
{"checks":[{"id":"issue_hints","question":"Did the work fully address the issue hints, user notes, and approved plan requirements?","findings":[{"detail":"Checked the requested review-loop cap against the actual defaults. The plan relies on execution.max_review_rework_cycles, but megaplan/types.py still defaults that knob to 3, so it does not satisfy the brief's requested 2-iteration cap unless the default or heavy-mode behavior changes.","flagged":true},{"detail":"Checked the heavy-review flow against the brief. The plan runs the legacy review worker first and only then runs parallel_review(...), which leaves the criteria review outside the mirrored parallel architecture the brief asked for.","flagged":true}]},{"id":"correctness","question":"Are the proposed changes technically correct?","findings":[{"detail":"Checked the proposed rework_items[].source field against the live review schemas. Both .megaplan/schemas/review.json and megaplan/schemas.py currently allow only task_id, issue, expected, actual, and evidence_file for review rework items, so emitting source would fail unless both schema definitions are widened.","flagged":true},{"detail":"Checked the planned toolset reuse against megaplan/hermes_worker.py. Review is currently a file-only phase while critique gets file plus web, so reusing critique toolsets would change review permissions and diverge from the existing phase contract.","flagged":true}]},{"id":"scope","question":"Search for related code that handles the same concept. Is the reported issue a symptom of something broader?","findings":[{"detail":"Checked the proposed review-flag lifecycle against the existing critique machinery. Critique carries prior findings and uses verified_flag_ids / disputed_flag_ids to move flags through later iterations, but the plan explicitly leaves those arrays empty for review v1, so it does not actually mirror the existing flag lifecycle.","flagged":true},{"detail":"Checked the schema touch points named in the plan. Step 7 updates only .megaplan/schemas/review.json, but the repo also has an in-process schema registry in megaplan/schemas.py that tests assert against, so the proposed schema work is incomplete as written.","flagged":true}]},{"id":"verification","question":"Is there convincing verification for the change?","findings":[{"detail":"Checked the standard-mode regression test against the stated success criterion. The brief asks for byte-identical standard review output, but the plan only proposes asserting the top-level key set, which would miss payload-content regressions in criteria, summary text, ordering-sensitive fields, or rework formatting.","flagged":true},{"detail":"Checked the proposed heavy-review integration tests against the current test harness. The repo already uses deterministic handler-level review tests with mocked WorkerResult payloads, but the plan's known-bad/known-good heavy-review cases do not identify fixtures for git diffs, finalize.json, or agent outputs, so the verification story is still underspecified.","flagged":true}]}],"flags":[{"id":"FLAG-001","concern":"Review loop: Heavy review still inherits a 3-pass default, so the plan does not meet the requested 2-iteration cap unless it changes configuration semantics.","category":"correctness","severity_hint":"likely-significant","evidence":"megaplan/types.py sets execution.max_review_rework_cycles to 3, while the plan treats the existing knob as already satisfying the brief's requested cap of 2."},{"id":"FLAG-002","concern":"Review schema: The plan adds rework_items.source and new heavy-review payload fields without updating every schema source that currently constrains review output.","category":"correctness","severity_hint":"likely-significant","evidence":"Review schema is defined in both .megaplan/schemas/review.json and megaplan/schemas.py, and both currently restrict rework items to task_id, issue, expected, actual, and evidence_file."},{"id":"FLAG-003","concern":"Review flags: The proposed v1 leaves verified_flag_ids and disputed_flag_ids empty, so review findings will not reuse the existing critique-style flag lifecycle across iterations.","category":"completeness","severity_hint":"likely-significant","evidence":"The repo's current flag progression depends on prior findings plus verified/disputed arrays in critique prompts and flag update logic, but the review plan explicitly defers that mechanism."}],"verified_flag_ids":[],"disputed_flag_ids":[]}
You are an independent reviewer. Critique the plan against the actual repository.
Robust Review Phase for Megaplan (Heavy Mode Only)
Context
Megaplan is a planning/execution harness with phases: prep → plan → critique → gate → (revise → critique → gate)* → finalize → execute → review. Critique already has a "robust" mode where it runs multiple focused checks in parallel (megaplan/parallel_critique.py + megaplan/checks.py), each as an independent sub-agent with its own session. We validated on ~15 random SWE-bench failures that the current single-call review phase misses ~65% of salvageable failures because it anchors to the plan's success criteria instead of the original issue text, and because it evaluates everything in one call without forced enumeration.
Goal
Add a robust review mode that mirrors the robust critique architecture: multiple focused, parallel, issue-anchored checks that produce structured flags with rework directives, which feed back through the existing gate → revise/re-execute loop.
Standard robustness mode must remain exactly as today. This design is heavy-mode only.
What exists today (don't break)
megaplan/prompts/review.py — single-call review prompt; validates execution against finalize.json criteria/task_verdicts/sense_check_verdicts. Works well as the baseline. Keep it.
megaplan/prompts/critique.py + megaplan/parallel_critique.py + megaplan/checks.py — the pattern we're mirroring. Read these to understand the architecture.
megaplan/handlers.pyhandle_review() — entry point. Currently calls a single worker.
The gate → revise/re-execute loop already exists with max iteration cap and ESCALATE semantics.
intent_and_notes_block(state) contains the original issue text — crucial input for issue-anchored checks.
What needs to exist
1. New check table for review
New file megaplan/review_checks.py mirroring megaplan/checks.py. Define REVIEW_CHECKS with these entries (core + extended tiers). Each check has id, question, guidance, category, default_severity, tier:
Core tier (always run in heavy mode):
coverage — Enumerate every concrete failing example, symptom, or "X should Y" statement in the issue. For each, point to the specific line in the diff that addresses it. Flag any not covered. Subsumes intent/opt-in/default and accepted-changes concerns.
placement — Trace the call path from the failing input to where we made the change. Is the fix at the source of the bug or a downstream consumer? Would a maintainer put it here or elsewhere?
parity — Find 2–3 structurally similar classes/functions in the same module. Enumerate the methods/overrides/conventions they share. Does our new code follow the same patterns? If not, why not? (Highest new-leverage check.)
simplicity — What's the smallest possible change that would make the reported issue's example work? Compare against our diff. Every extra line must justify its existence against a specific requirement in the issue.
Extended tier (heavy mode with extended robustness):
dead_guard — For every new if x: / try: block added by the patch, trace whether the guarded branch is actually reachable given how callers invoke this function. Flag guards that never fire.
adjacent_calls — What other code calls the changed function or uses the same pattern? Would the same bug affect them?
parser_source — If the bug is in parsing/transformation, is the fix at the source of the bug or at a downstream consumer?
return_value_downstream — For any value the patch returns or constructs in an error path, trace where it flows next. Will the downstream consumer handle it correctly?
Also include a checks_for_robustness() function mirroring megaplan/checks.py.
2. Mechanical pre-checks (no LLM, run before parallel review)
Add a new module megaplan/review_mechanical.py or inline in handlers:
source_touch — Does the diff touch at least one non-test file in the package? Reject test-only diffs.
diff_size_sanity — Compare diff size (lines/hunks/files) to a rough expectation from the issue (number of code snippets × ~10 lines). Flag >3x or <0.3x.
dead_guard_static — For new if x: blocks, AST-parse the changed file, find the enclosing function, check whether x has a callable signature at the call site where it could be None/False. This is a heuristic; don't overreach.
These are advisory flags, not blocks. They populate a pre_check_flags array that the LLM review checks see as input.
3. Parallel review runner
New file megaplan/parallel_review.py, mirroring megaplan/parallel_critique.py. Same architecture: ThreadPoolExecutor, one agent per check, each with its own session via SessionDB, writes findings to a pre-populated template slot. Concurrency of 2 (same as critique). Include the MiniMax→OpenRouter fallback pattern.
Important: each check agent gets the original issue text + the full git diff + the finalize.json artifacts, nothing else. No plan, no critique history, no gate summary. The whole point is that these checks are anchored to the issue, not the plan.
4. Prompt builders for single-check review
In megaplan/prompts/review.py, add:
single_check_review_prompt(state, plan_dir, root, check, output_path) — mirrors single_check_critique_prompt — single focused prompt for one check.
_write_single_check_review_template(plan_dir, state, check, filename) — pre-populates the output file with the check's ID.
_build_review_checks_template(plan_dir, state, checks) — builds the per-check template list.
Keep _review_prompt() as-is. It still runs as the "criteria_verdict" check in heavy mode.
5. Handler integration
In megaplan/handlers.pyhandle_review():
Read configured_robustness(state)
If standard or light → run the existing single-call review unchanged
If heavy → run the mechanical pre-checks, then run parallel_review() across REVIEW_CHECKS + the existing criteria-based review-as-check. Merge all flags into one review.json
The output shape adds a checks array alongside the existing review_verdict, criteria, issues, rework_items, task_verdicts, sense_check_verdicts, summary. Back-compat: existing consumers that only look at review_verdict / rework_items keep working.
6. Feedback loop — how flags flow back
This is the tricky part. The review runs after execute. If it raises blocking flags, where does control go?
Decision: reuse the existing gate → revise/re-execute loop, not a new review-specific loop.
Concretely:
If review_verdict == "needs_rework" with blocking flags, the handler writes them to rework_items as today.
The execute loop in evals/run_evals.py already handles needs_rework by going back to revise or re-execute based on the rework type. No new routing logic.
Add a new field rework_directive.source = "review_{check_id}" so the executor knows the provenance and can prioritize.
Max review iterations cap at 2 (configurable). After 2 rounds of needs_rework from the review, escalate. Otherwise the same check can fire forever on tasks the model can't solve.
Review flags cannot re-raise concerns the gate already settled. Before raising a coverage/placement/parity flag, the review check must check gate.settled_decisions — if the concern matches a settled decision, downgrade to "significant" (info) rather than "blocking". This prevents the gate-override deadlock we hit before.
7. Severity ladder (mirrors critique)
Each review flag has:
blocking — triggers needs_rework, forces another revise/execute pass
significant — logged, shown to gate for future iterations, doesn't auto-block
minor — info only, aggregated into summary
8. Flag tracking across review iterations
Mirror critique's flag registry. Each review check's findings get IDs like REVIEW-COV-001. Status transitions open → verified → resolved across iterations, just like critique flags. Read megaplan/_core flag registry helpers — reuse them, don't duplicate.
9. Schema updates
Add a review checks schema fragment alongside the existing review schema in schemas/ (wherever step schemas live — look at STEP_SCHEMA_FILENAMES in megaplan/workers.py). The schema should allow the existing top-level fields PLUS a new checks array with per-check findings.
10. Tests
Unit tests for REVIEW_CHECKS structure and checks_for_robustness() behavior
Unit test that standard robustness still calls the single-call review (regression guard)
Unit test for mechanical pre-checks (source_touch, diff_size_sanity)
Integration test: feed a known-bad patch through heavy review, assert it raises the expected flag
Integration test: feed a known-good patch through heavy review, assert no blocking flags
Use the existing test infrastructure patterns.
Generalization beyond review
While implementing, keep these generalizations in mind (don't implement them now, but design so they're easy later):
checks_for_robustness() pattern should be extractable to a shared utility — same function body in checks.py and review_checks.py should be one function.
Parallel focused-agent runner (parallel_critique.py + parallel_review.py) should be refactorable to a single parallel_phase_runner.py that both delegate to. Not in this PR, but leave clean seams.
Template-file-with-preloaded-IDs pattern should be documented as "the preferred way to get structured output" in a short comment at the top of parallel_review.py.
Mechanical pre-checks should be runnable standalone so they can be reused by critique, finalize, or any other phase that wants cheap advisory checks.
Out of scope for this plan
Automatic golden-patch comparison for false-negative detection (we already have auto_improve/check_false_negatives.py)
Running these checks on tasks that already passed
A/B evaluation of which checks actually earn their spot (that's a separate measurement exercise)
Any changes to critique, plan, execute, prep, or finalize phases
Any changes to standard or light robustness mode
New top-level phases between review and execute
Success criteria
Heavy mode review produces a checks array with one entry per REVIEW_CHECK
Standard mode review produces byte-identical output to today for the same input
Blocking flags flow through the existing rework loop without new routing logic
Flag iteration cap prevents infinite review→re-execute loops
Unit + integration tests pass
Code follows the same patterns as parallel_critique.py and checks.py — a reader familiar with critique should find nothing surprising in the review code
Files likely to change
NEW: megaplan/review_checks.py
NEW: megaplan/parallel_review.py
NEW: megaplan/review_mechanical.py (or inline in handlers)
Heavy-mode review adds a parallel, issue-anchored check architecture mirroring robust critique. Standard/light paths stay byte-identical. Revision v2 addresses gate flags on: (a) iteration cap default (FLAG-001 / issue_hints-1), (b) dual schema sources and the new source rework field (FLAG-002 / correctness-1 / scope-2), (c) review flag lifecycle via verified_flag_ids/disputed_flag_ids (FLAG-003 / scope-1), (d) review-specific toolset not critique's (correctness-2), and (e) folding the legacy _review_prompt in as a first-class criteria_verdict check inside the parallel runner so every review check goes through the same mirrored architecture (issue_hints-2).
Verified facts driving the revision:
megaplan/types.py:289 defaults execution.max_review_rework_cycles to 3 — lowering to 2 is a one-line change and governs all modes the same way (standard's single-call review is unchanged in behavior, only the rework cap moves).
Review schema is defined in both.megaplan/schemas/review.json and megaplan/schemas.py:353-411 (STEP_SCHEMA_REGISTRY["review.json"]) and rework_items currently requires exactly task_id|issue|expected|actual|evidence_file. Both must be widened.
megaplan/hermes_worker.py:52-66: _toolsets_for_phase("review") returns file-only; _toolsets_for_phase("critique") returns file+web. Review check agents must use "review" to avoid silently widening permissions.
megaplan/flags.py:53 (update_flags_after_critique) consumes verified_flag_ids / disputed_flag_ids to move prior flags through status transitions. Review v2 will mirror this: the per-check template includes prior REVIEW-* flags so a heavy-mode check can re-verify or dispute them, just like critique.
megaplan/prompts/critique.py:113-160 (_build_checks_template) already shows how to attach prior findings + flag status to a new-iteration template. We reuse that pattern for review.
Verifyintent_and_notes_block, collect_git_diff_summary, load_flag_registry, save_flag_registry are importable from megaplan._core.
Step 2: Lower max_review_rework_cycles default to 2 (megaplan/types.py)
Scope: Small
Changemegaplan/types.py:289 from "execution.max_review_rework_cycles": 3 to ... : 2. This satisfies the brief's "max 2 (configurable)" cap for all modes. Standard mode's single-call review behavior is byte-identical; only the upper bound on rework cycles moves, which aligns standard with the brief's intent too.
Update any existing test that asserts on 3 (search tests/ for the literal) to expect 2; if a test hard-codes 3 as part of an unrelated assertion, adjust to read from the config helper.
Addresses: FLAG-001, issue_hints-1.
Step 3: Widen review schemas in BOTH locations (.megaplan/schemas/review.json, megaplan/schemas.py)
Add optional top-level verified_flag_ids and disputed_flag_ids arrays of strings (mirrors critique schema).
Widen rework_items.items to include an optional source string field; keep existing five as required.
Keep additionalProperties: false at the top level — new fields must be explicit named properties.
Editmegaplan/schemas.py:353-411 (in-process registry) to mirror the same changes exactly. Without this, workers.py validation fails for heavy-mode output.
Runtests/test_schemas.py and tests/test_workers.py targeted slices early to catch divergence between the two sources.
Addresses: FLAG-002, correctness-1, scope-2.
Step 4: Add the review check registry (megaplan/review_checks.py)
Scope: Medium
Createmegaplan/review_checks.py mirroring megaplan/checks.py:1-236. Define ReviewCheckSpec (extends the critique shape with an optional prompt_kind: "focused" | "criteria_verdict", defaulting to "focused") and REVIEW_CHECKS containing:
Core tier (4):coverage, placement, parity, simplicity — all prompt_kind="focused".
Extended tier (4):dead_guard, adjacent_calls, parser_source, return_value_downstream — all prompt_kind="focused".
Special tier (1):criteria_verdict — prompt_kind="criteria_verdict", category "completeness", default_severity "likely-significant", tier "core". This is the legacy _review_prompt flow folded into the parallel runner as a first-class check, so every heavy-mode review path goes through the same mirrored architecture (addresses issue_hints-2).
Provideget_check_ids, get_check_by_id, build_check_category_map, build_empty_template, validate_review_checks, checks_for_robustness (heavy → all 9, standard → () reserved for future light-heavy migration, light → ()). Under the gate decisions, standard/light never reach the parallel path — they use the legacy _review_prompt single call.
Note in a header comment that checks_for_robustness has the same body as megaplan/checks.py:139 and is a candidate for extraction to a shared helper later.
Addresses: provides the criteria_verdict entry needed to satisfy issue_hints-2.
Createmegaplan/review_mechanical.py exposing run_pre_checks(plan_dir, state, project_dir) -> list[dict]. Each entry has id, severity ("advisory"), detail, evidence. Module is importable standalone so other phases could call it (generalization #4).
Implement:
source_touch: use collect_git_diff_summary (or raw git diff --name-only); flag if every changed file has path containing /tests/ or basename matching test_*.py / *_test.py.
diff_size_sanity: count diff lines and fenced code blocks in intent_and_notes_block(state); flag if diff_lines > 3 * max(10, snippets*10) or diff_lines < 0.3 * max(10, snippets*10).
dead_guard_static: walk added if NAME: hunks, AST-parse post-image, find enclosing FunctionDef, flag only the narrow shape where NAME is a parameter whose default is None and is never reassigned in the body AND is invoked (NAME(...)) elsewhere in the same function — per the user's guidance this is acceptable v1 scope. Any AST parse failure → silently skip that hunk.
Add_review_check_context(state, plan_dir) that returns only: project_dir, intent_block, git_diff, finalize_data, settled_decisions (from gate.json's settled_decisions list only). No plan, no critique history, no broader gate summary (GATE-SD-002).
Add_write_single_check_review_template(plan_dir, state, check, filename) pre-populating {checks: [{id, question, guidance, findings: [], prior_findings?}], flags: [], pre_check_flags: [], verified_flag_ids: [], disputed_flag_ids: []}. For iteration > 1, attach prior_findings entries with their REVIEW-* flag status from the registry (mirrors megaplan/prompts/critique.py:113-160).
Add_build_review_checks_template(plan_dir, state, checks) (list form, one entry per check).
Addsingle_check_review_prompt(state, plan_dir, root, check, output_path, pre_check_flags) for prompt_kind="focused" checks — issue-anchored context, settled-decisions downgrade rule, finding schema identical to critique (detail ≥ 40 chars, flagged bool). Includes instructions to populate verified_flag_ids / disputed_flag_ids for prior REVIEW-* flags this check owns.
Addcriteria_verdict_review_prompt(state, plan_dir, root, check, output_path) that wraps the existing _review_prompt body unchanged but routes output into the same per-check template slot (fills the check's findings array with one finding summarizing criteria pass/fail AND also writes criteria, task_verdicts, sense_check_verdicts, review_verdict at the top level of the template file so the handler's merge step can fold it in). This is the one check whose template slot is larger than the others; the runner treats it as a special case.
Leave_review_prompt body untouched — the new builder calls it as a helper so any change to the baseline prompt affects both standard and heavy modes uniformly.
Createmegaplan/parallel_review.py by copying megaplan/parallel_critique.py:1-260 and adapting:
Import single_check_review_prompt, criteria_verdict_review_prompt, _write_single_check_review_template from megaplan.prompts.review.
Toolset: _toolsets_for_phase("review") — file-only, matching the current review phase contract. Do NOT reuse critique's file+web toolset. (Addresses correctness-2.)
Schema: STEP_SCHEMA_FILENAMES["review"] (same file, widened in Step 3).
Concurrency: min(max_concurrent or get_effective("orchestration", "max_critique_concurrency"), len(checks)) — reuses the existing knob per user assumption.
Keep MiniMax → OpenRouter fallback verbatim.
Merge step: for each completed check, extract checks[0] into the aggregate; for the criteria_verdict check specifically, also extract the top-level criteria, task_verdicts, sense_check_verdicts, review_verdict, rework_items, summary, issues fields and return them in a criteria_payload field on the WorkerResult for the handler to merge.
Aggregate verified_flag_ids / disputed_flag_ids across all checks (same _merge_unique helper as critique).
Top-of-file docstring documenting the "template-file-with-preloaded-IDs" convention (generalization #3).
Refactor the synthetic-flag loop in megaplan/flags.py:69-87 into a shared helper _synthesize_flags_from_checks(checks, *, category_map, get_check_def, id_prefix) — used by both critique and review. (Addresses GATE-SD-004.)
Applies verified_flag_ids / disputed_flag_ids from the review payload to existing REVIEW-* flags (identical logic to the critique path, lines 59-67).
Synthesizes new flags from flagged review-check findings using the shared helper with id_prefix="REVIEW"; ids look like REVIEW-COVERAGE-001.
Writes via save_flag_registry.
Review flag lifecycle is now first-class (addresses FLAG-003, scope-1): a coverage finding flagged in iteration 1 becomes REVIEW-COVERAGE-001 with status open. Iteration 2's review template shows it under prior_findings with that status, and the iteration-2 coverage check can put "REVIEW-COVERAGE-001" in verified_flag_ids (fixed) or disputed_flag_ids (reject). Exactly the critique pattern.
Step 9: Handler branch (megaplan/handlers.py)
Scope: Medium
Modifyhandle_review (megaplan/handlers.py:1105):
Read robustness = configured_robustness(state) at the top.
robustness in {"standard", "light"} → existing path completely unchanged (runs worker_module.run_step_with_worker("review", ...) via _review_prompt).
checks = review_checks.checks_for_robustness("heavy") — includes the criteria_verdict check. Do NOT call run_step_with_worker("review", ...) separately; the criteria check inside the parallel runner replaces it so the heavy path is fully mirrored. (Addresses issue_hints-2.)
Build final payload by merging parallel_result.payload["criteria_payload"] (review_verdict/criteria/task_verdicts/sense_check_verdicts/summary/issues/rework_items) with {"checks": [...], "pre_check_flags": [...], "verified_flag_ids": [...], "disputed_flag_ids": [...]}.
For any blocking finding (flagged finding on a check whose default_severity == "likely-significant" that was not downgraded for a settled decision), synthesize a rework item {task_id: "REVIEW", issue, expected, actual, evidence_file, source: "review_<check_id>"} and force review_verdict = "needs_rework". Existing rework items from the criteria check are preserved.
Record history with summed cost_usd and duration_ms.
Downstream _merge_review_verdicts → _resolve_review_outcome unchanged; iteration cap now at 2 via Step 2.
Heavy-mode sentinel task_id="REVIEW" rework items must not trip _merge_review_verdicts validation (megaplan/handlers.py:1026) — verify the loop tolerates unmatched task_id in rework_items (it only strict-checks task_verdicts); add a targeted test if behavior is ambiguous.
No changes to evals/run_evals.py routing.
Step 10: Tests (tests/)
Scope: Medium
tests/test_review_checks.py:
REVIEW_CHECKS contains the 9 expected ids (8 focused + criteria_verdict) with correct tiers and prompt_kinds.
checks_for_robustness("heavy") returns all 9; ("standard") and ("light") return ().
diff_size_sanity flags a 2000-line diff against an issue with one code block.
dead_guard_static returns [] on syntactically broken source (graceful).
tests/test_handle_review_robustness.py:
Regression: robustness="standard" produces review.json with exactly today's key set (no checks, no pre_check_flags). Mock worker payload is byte-identical fixture.
Heavy: mock run_parallel_review → returns one flagged coverage finding + a criteria_payload with review_verdict="approved". Assert merged review.json has both checks and pre_check_flags, review_verdict is needs_rework (because coverage is blocking), rework items include source="review_coverage", and REVIEW-COVERAGE-001 is in the flag registry.
Iteration-2 flag lifecycle: pre-seed flag registry with REVIEW-COVERAGE-001 status=open, mock run_parallel_review to return verified_flag_ids=["REVIEW-COVERAGE-001"]; assert registry transitions to verified.
tests/test_parallel_review.py: stub AIAgent/SessionDB, assert len(checks) futures scheduled, prompt_kind dispatch picks the right builder, _toolsets_for_phase("review") is requested (not critique), results merged in order.
tests/test_schemas.py: add a case asserting both the disk schema and megaplan/schemas.py:STEP_SCHEMA_REGISTRY["review.json"] accept a heavy-mode payload with checks, pre_check_flags, , , and a rework item containing .
Manual: heavy-mode run on a known-bad SWE-bench case; assert at least one of coverage/placement/parity/simplicity fires and the rework loop completes within 2 iterations.
code
Plan metadata:
{
"version": 2,
"timestamp": "2026-04-07T20:45:25Z",
"hash": "sha256:c45f17c026cae4ae158c8abfa5ef0fca5abfa8f02aa77c8ad384496ba16c518f",
"changes_summary": "Revision v2 addresses all 9 significant gate flags with concrete plan-level fixes: (1) Step 2 lowers execution.max_review_rework_cycles default from 3 to 2 in megaplan/types.py:289, satisfying the brief's 2-iteration cap for all modes. (2) Step 3 now widens BOTH schema sources (.megaplan/schemas/review.json AND megaplan/schemas.py:353-411 STEP_SCHEMA_REGISTRY) and adds the optional rework_items[].source field plus verified_flag_ids/disputed_flag_ids top-level arrays. (3) Step 4 adds a criteria_verdict entry to REVIEW_CHECKS with prompt_kind=\"criteria_verdict\", folding the legacy _review_prompt flow into the parallel runner so every heavy-mode review check goes through the same mirrored architecture. (4) Step 7 uses _toolsets_for_phase(\\\"review\\\") (file-only) explicitly, not critique's file+web, preserving the review phase's read-only contract. (5) Step 8 adds full review flag lifecycle via update_flags_after_review that consumes verified_flag_ids/disputed_flag_ids and attaches prior REVIEW-* findings to iteration-2 templates, mirroring critique exactly. (6) Step 9 no longer runs the legacy review worker separately \u2014 criteria_verdict runs inside parallel_review, and the handler merges the criteria_payload it returns. (7) Step 6 adds criteria_verdict_review_prompt as a thin wrapper over _review_prompt so the standard-mode path is untouched. (8) Tests updated to cover dual-schema validation, prompt_kind dispatch, file-only toolset, iteration-2 flag lifecycle, and the new iteration cap. Success criteria updated accordingly.",
"flags_addressed": [
"FLAG-001",
"FLAG-002",
"FLAG-003",
"issue_hints-1",
"issue_hints-2",
"correctness-1",
"correctness-2",
"scope-1",
"scope-2"
],
"questions": [],
"success_criteria": [
{
"criterion": "megaplan/review_checks.py exports REVIEW_CHECKS with exactly 9 entries: coverage, placement, parity, simplicity, dead_guard, adjacent_calls, parser_source, return_value_downstream, criteria_verdict",
"priority": "must"
},
{
"criterion": "checks_for_robustness('heavy') returns all 9 checks; ('standard') and ('light') return ()",
"priority": "must"
},
{
"criterion": "execution.max_review_rework_cycles default is 2 in megaplan/types.py",
"priority": "must"
},
{
"criterion": "Both .megaplan/schemas/review.json and megaplan/schemas.py STEP_SCHEMA_REGISTRY['review.json'] accept heavy-mode payloads with optional , , , , and rework items containing optional ",
"priority": "must"
},
{
"criterion": "With , produces a byte-identical to today's for a fixed worker payload (regression test passes)",
"priority": "must"
},
{
"criterion": "With , runs (including the check) and does NOT separately invoke the legacy worker",
"priority": "must"
},
{
"criterion": "Heavy-mode contains , , , arrays alongside the existing fields",
"priority": "must"
},
{
"criterion": "Heavy-mode blocking findings populate with , set , and flow through the existing loop with no new routing logic",
"priority": "must"
},
{
"criterion": " uses (file-only), not ",
"priority": "must"
},
{
"criterion": "Parallel review check agents receive only issue text + git diff + finalize.json + settled gate decisions \u2014 no plan, no critique history, no broader gate summary",
"priority": "must"
},
{
"criterion": " consumes / to transition prior REVIEW-* flags, and iteration-2 templates expose prior REVIEW findings with their status (mirrors critique lifecycle)",
"priority": "must"
},
{
"criterion": "Review-synthesized flags use ids and live in the existing flag registry via /",
"priority": "must"
},
{
"criterion": "All tests in pass after the change, including new tests for dual-schema validation, prompt_kind dispatch, flag lifecycle across iterations, and the new iteration cap",
"priority": "must"
},
{
"criterion": "Synthetic-flag-from-check logic is shared between critique and review via a single helper in \u2014 no duplicated loop",
"priority": "must"
},
{
"criterion": " is importable and callable standalone so critique/finalize could reuse it later",
"priority": "should"
},
{
"criterion": " is structurally close enough to that a future refactor to a shared runner is mechanical",
"priority": "should"
},
{
"criterion": " is a thin wrapper over so any future change to the baseline criteria prompt affects both standard and heavy modes uniformly",
"priority": "should"
},
{
"criterion": "End-to-end heavy-mode review on a known-bad SWE-bench patch raises at least one blocking flag from coverage/placement/parity/simplicity and completes rework within 2 iterations",
"priority": "info"
},
{
"criterion": "Heavy review meaningfully reduces the ~65% missed-salvageable-failures rate observed on the 15-task validation set",
"priority": "info"
}
],
"assumptions": [
"Lowering the global default from 3 to 2 is acceptable because the brief's 2-cap request applies to the rework loop semantics, not to standard-mode review output shape. Standard-mode single-call review output remains byte-identical; only the upper bound on loops moves.",
"Folding in as a REVIEW_CHECK (rather than running it in parallel alongside the check runner) better matches the brief's 'mirrored architecture' requirement and is what the gate recommended in issue_hints-2.",
"The check is the one slot in the parallel template allowed to write top-level review fields (, , , etc.); all other checks only write to their array. The runner has a small special case for this merge.",
" file-only toolset is sufficient for the focused review check agents \u2014 the brief says they only need to read the diff and finalize.json, no web access.",
"Heavy-mode rework items with sentinel do not trip because that function only strict-checks (not ) against known task IDs. Will verify with a targeted test in Step 10.",
"Review flag ids use format (e.g., ), chosen to be parseable back to the check for lifecycle transitions without colliding with critique's numbering.",
"Optional field on is backward-compatible \u2014 existing consumers that read the five required fields keep working."
],
"delta_from_previous_percent": 79.74,
"structure_warnings": []
}
code
Plan structure warnings from validator:
[]
Existing flags:
[
{
"id": "FLAG-001",
"concern": "Review loop: Heavy review still inherits a 3-pass default, so the plan does not meet the requested 2-iteration cap unless it changes configuration semantics.",
"status": "addressed",
"severity": "significant"
},
{
"id": "FLAG-002",
"concern": "Review schema: The plan adds rework_items.source and new heavy-review payload fields without updating every schema source that currently constrains review output.",
"status": "addressed",
"severity": "significant"
},
{
"id": "FLAG-003",
"concern": "Review flags: The proposed v1 leaves verified_flag_ids and disputed_flag_ids empty, so review findings will not reuse the existing critique-style flag lifecycle across iterations.",
"status": "addressed",
"severity": "significant"
},
{
"id": "issue_hints-1",
"concern": "Did the work fully address the issue hints, user notes, and approved plan requirements?: Checked the requested review-loop cap against the actual defaults. The plan relies on execution.max_review_rework_cycles, but megaplan/types.py still defaults that knob to 3, so it does not satisfy the brief's requested 2-iteration cap unless the default or heavy-mode behavior changes.",
"status": "addressed",
"severity": "significant"
},
{
"id": "issue_hints-2",
"concern": "Did the work fully address the issue hints, user notes, and approved plan requirements?: Checked the heavy-review flow against the brief. The plan runs the legacy review worker first and only then runs parallel_review(...), which leaves the criteria review outside the mirrored parallel architecture the brief asked for.",
"status": "addressed",
"severity": "significant"
},
{
"id": "correctness-1",
"concern": "Are the proposed changes technically correct?: Checked the proposed rework_items[].source field against the live review schemas. Both .megaplan/schemas/review.json and megaplan/schemas.py currently allow only task_id, issue, expected, actual, and evidence_file for review rework items, so emitting source would fail unless both schema definitions are widened.",
"status": "addressed",
"severity": "significant"
},
{
"id": "correctness-2",
"concern": "Are the proposed changes technically correct?: Checked the planned toolset reuse against megaplan/hermes_worker.py. Review is currently a file-only phase while critique gets file plus web, so reusing critique toolsets would change review permissions and diverge from the existing phase contract.",
"status": "addressed",
"severity": "significant"
},
{
"id": "scope-1",
"concern": "Search for related code that handles the same concept. Is the reported issue a symptom of something broader?: Checked the proposed review-flag lifecycle against the existing critique machinery. Critique carries prior findings and uses / to move flags through later iterations, but the plan explicitly leaves those arrays empty for review v1, so it does not actually mirror the existing flag lifecycle.",
"status": "addressed",
"severity": "significant"
},
{
"id": "scope-2",
"concern": "Search for related code that handles the same concept. Is the reported issue a symptom of something broader?: Checked the schema touch points named in the plan. Step 7 updates only , but the repo also has an in-process schema registry in that tests assert against, so the proposed schema work is incomplete as written.",
"status": "addressed",
"severity": "significant"
},
{
"id": "verification-1",
"concern": "Is there convincing verification for the change?: Checked the standard-mode regression test against the stated success criterion. The brief asks for byte-identical standard review output, but the plan only proposes asserting the top-level key set, which would miss payload-content regressions in criteria, summary text, ordering-sensitive fields, or rework formatting.",
"status": "open",
"severity": "minor"
},
{
"id": "verification-2",
"concern": "Is there convincing verification for the change?: Checked the proposed heavy-review integration tests against the current test harness. The repo already uses deterministic handler-level review tests with mocked payloads, but the plan's known-bad/known-good heavy-review cases do not identify fixtures for git diffs, , or agent outputs, so the verification story is still underspecified.",
"status": "open",
"severity": "minor"
}
]
code
Known accepted debt grouped by subsystem:
{
"are-the-proposed-changes-technically-correct": [
{
"id": "DEBT-009",
"concern": "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.",
"occurrence_count": 1,
"plan_ids": [
"move-the-entry-page-into-20260401-0450"
]
},
{
"id": "DEBT-010",
"concern": "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.",
"occurrence_count": 1,
"plan_ids": [
"move-the-entry-page-into-20260401-0450"
]
}
],
"are-the-success-criteria-well-prioritized-and-verifiable": [
{
"id": "DEBT-019",
"concern": "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.",
"occurrence_count": 1,
"plan_ids": [
"move-the-entry-page-into-20260401-0450"
]
}
],
"did-the-work-fully-address-the-issue-hints-user-notes-and-approved-plan-requirements": [
{
"id": "DEBT-011",
"concern": "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 . in the current repo, the mobile sticky nav at 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.",
"occurrence_count": 1,
"plan_ids": [
"move-the-entry-page-into-20260401-0450"
]
},
{
"id": "DEBT-012",
"concern": "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 . the implementer cannot satisfy both instructions as written.",
"occurrence_count": 1,
"plan_ids": [
"move-the-entry-page-into-20260401-0450"
]
}
],
"does-the-change-touch-all-locations-and-supporting-infrastructure": [
{
"id": "DEBT-018",
"concern": "does the change touch all locations and supporting infrastructure?: if the implementation really wants to carry mobile actions, the plan must also include a supporting change in or render a separate mobile control surface outside the card. right now step 4.9 removes the mobile nav but does not list as a place that must change, so the required glue for mobile controls is missing.",
"occurrence_count": 1,
"plan_ids": [
"move-the-entry-page-into-20260401-0450"
]
}
],
"execute-phase-contract": [
{
"id": "DEBT-003",
"concern": "early-killed baselines pass truncated output to the execute worker, which may produce lower-quality diagnosis than full output.",
"occurrence_count": 1,
"plan_ids": [
"design-and-implement-a-20260327-0512"
]
}
],
"find-the-callers-of-the-changed-function-what-arguments-do-they-actually-pass-does-the-fix-handle-all-of-them": [
{
"id": "DEBT-014",
"concern": "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 looks redundant. optimistically adds the id to in , and already reactively filters skipped entries from in . calling immediately afterward is safe, but it duplicates an existing state transition and should be justified as an explicit ux optimization rather than required logic.",
"occurrence_count": 1,
"plan_ids": [
"move-the-entry-page-into-20260401-0450"
]
},
{
"id": "DEBT-015",
"concern": "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. invokes its own prop when an unauthenticated user interacts with the score ui (), which is independent of the scoring hook's internal path. the plan should be read as requiring that caller to dispatch ; otherwise one caller remains broken even if is correctly wired.",
"occurrence_count": 1,
"plan_ids": [
"move-the-entry-page-into-20260401-0450"
]
}
],
"handler-boilerplate": [
{
"id": "DEBT-004",
"concern": "_run_worker() pseudocode hardcodes iteration=state['iteration'] but handle_plan and handle_revise use different failure iteration values.",
"occurrence_count": 1,
"plan_ids": [
"clean-up-and-properly-20260331-0149"
]
},
{
"id": "DEBT-005",
"concern": "same issue as correctness-1: failure iteration would be wrong for plan/revise handlers.",
"occurrence_count": 1,
"plan_ids": [
"clean-up-and-properly-20260331-0149"
]
}
],
"install-paths": [
{
"id": "DEBT-023",
"concern": "local setup path doesn't expose subagent mode",
"occurrence_count": 1,
"plan_ids": [
"refactor-megaplan-skill-so-20260406-1818"
]
},
{
"id": "DEBT-024",
"concern": "no automated guard to keep the mirror file synchronized with source files",
"occurrence_count": 1,
"plan_ids": [
"update-all-documentation-20260406-1902"
]
},
{
"id": "DEBT-025",
"concern": "local setup test only checks agents.md existence, not content",
"occurrence_count": 1,
"plan_ids": [
"update-all-documentation-20260406-1902"
]
}
],
"is-there-convincing-verification-for-the-change": [
{
"id": "DEBT-016",
"concern": "is there convincing verification for the change?: the test-plan details still miss a small but real infrastructure update: the current helper in only renders , so the step 7 requirement to assert cannot be implemented unless that helper is extended to expose . the same pattern exists in the related page tests.",
"occurrence_count": 1,
"plan_ids": [
"move-the-entry-page-into-20260401-0450"
]
},
{
"id": "DEBT-017",
"concern": "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 .",
"occurrence_count": 1,
"plan_ids": [
"move-the-entry-page-into-20260401-0450"
]
}
],
"mobile-ui": [
{
"id": "DEBT-020",
"concern": "mobile ui: removing entrypage's mobile sticky nav and relying on would break mobile navigation and scoring because that footer slot is hidden below the breakpoint.",
"occurrence_count": 1,
"plan_ids": [
"move-the-entry-page-into-20260401-0450"
]
}
],
"search-for-related-code-that-handles-the-same-concept-is-the-reported-issue-a-symptom-of-something-broader": [
{
"id": "DEBT-013",
"concern": "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. already has a pre-existing mobile gap because its score panel is desktop-only and its footer actions are also hidden on mobile ( plus ). 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.",
"occurrence_count": 1,
"plan_ids": [
"move-the-entry-page-into-20260401-0450"
]
}
],
"subagent-safeguards": [
{
"id": "DEBT-021",
"concern": "hermes reference safeguard numbers not validated against actual implementation",
"occurrence_count": 1,
"plan_ids": [
"refactor-megaplan-skill-so-20260406-1818"
]
},
{
"id": "DEBT-022",
"concern": "plan's retry caps (1 phase, 3 execute) may differ from hermes-agent's actual policy",
"occurrence_count": 1,
"plan_ids": [
"refactor-megaplan-skill-so-20260406-1818"
]
}
],
"worker-permissions": [
{
"id": "DEBT-001",
"concern": "codex --full-auto flag only triggers for step == 'execute', not 'loop_execute'",
"occurrence_count": 1,
"plan_ids": [
"build-megaloop-a-minimal-20260327-0250"
]
},
{
"id": "DEBT-002",
"concern": "claude --permission-mode bypasspermissions only triggers for step == 'execute', not 'loop_execute'",
"occurrence_count": 1,
"plan_ids": [
"build-megaloop-a-minimal-20260327-0250"
]
}
],
"workflow-state-machine": [
{
"id": "DEBT-006",
"concern": "_plan_prompt() does not read research.json, so replanning from state_researched would ignore research results.",
"occurrence_count": 1,
"plan_ids": [
"clean-up-and-properly-20260331-0149"
]
},
{
"id": "DEBT-007",
"concern": "same issue as correctness-2: state_researched \u2192 plan path is only partially wired.",
"occurrence_count": 1,
"plan_ids": [
"clean-up-and-properly-20260331-0149"
]
},
{
"id": "DEBT-008",
"concern": "_plan_prompt() is a missed location for the state_researched \u2192 plan change.",
"occurrence_count": 1,
"plan_ids": [
"clean-up-and-properly-20260331-0149"
]
}
]
}
code
Escalated debt subsystems:
[
{
"subsystem": "install-paths",
"total_occurrences": 3,
"plan_count": 2,
"entries": [
{
"id": "DEBT-023",
"concern": "local setup path doesn't expose subagent mode",
"occurrence_count": 1,
"plan_ids": [
"refactor-megaplan-skill-so-20260406-1818"
]
},
{
"id": "DEBT-024",
"concern": "no automated guard to keep the mirror file synchronized with source files",
"occurrence_count": 1,
"plan_ids": [
"update-all-documentation-20260406-1902"
]
},
{
"id": "DEBT-025",
"concern": "local setup test only checks agents.md existence, not content",
"occurrence_count": 1,
"plan_ids": [
"update-all-documentation-20260406-1902"
]
}
]
},
{
"subsystem": "workflow-state-machine",
"total_occurrences": 3,
"plan_count": 1,
"entries": [
{
"id": "DEBT-006",
"concern": "_plan_prompt() does not read research.json, so replanning from state_researched would ignore research results.",
"occurrence_count": 1,
"plan_ids": [
"clean-up-and-properly-20260331-0149"
]
},
{
"id": "DEBT-007",
"concern": "same issue as correctness-2: state_researched \u2192 plan path is only partially wired.",
"occurrence_count": 1,
"plan_ids": [
"clean-up-and-properly-20260331-0149"
]
},
{
"id": "DEBT-008",
"concern": "_plan_prompt() is a missed location for the state_researched \u2192 plan change.",
"occurrence_count": 1,
"plan_ids": [
"clean-up-and-properly-20260331-0149"
]
}
]
}
]
code
Debt guidance:
- These are known accepted limitations. Do not re-flag them unless the current plan makes them worse, broadens them, or fails to contain them.
- Prefix every new concern with a subsystem tag followed by a colon, for example `Timeout recovery: retry backoff remains brittle`.
- When a concern is recurring debt that still needs to be flagged, prefix it with `Recurring debt:` after the subsystem tag, for example `Timeout recovery: Recurring debt: retry backoff remains brittle`.
Your output template is at: /Users/user_c042661f/Documents/megaplan/.megaplan/plans/robust-review-v2/critique_output.json
Read this file first — it contains 4 checks, each with a question and guidance.
For each check, investigate the codebase, then add your findings to the findings array for that check.
Each finding needs:
"detail": what you specifically checked and what you found (at least a full sentence)
"flagged": true if this describes a difference, risk, or tension — even if you think it's justified. false only if purely informational with no possible downside.
When in doubt, flag it — the gate can accept tradeoffs, but it can't act on findings it never sees.
Good: {"detail": "Checked callers of nthroot_mod in solveset.py line 1205 — passes prime moduli only, consistent with the fix.", "flagged": false}
Good: {"detail": "The fix handles empty tuples but not single-element tuples which need a trailing comma.", "flagged": true}
Bad: {"detail": "No issue found", "flagged": false} ← too brief, will be rejected
Bad: {"detail": "The hints suggest approach X but the plan uses Y. However Y is consistent with X's intent.", "flagged": false} ← a different approach than the hints IS a flag. You found a divergence — flag it. The gate decides if it's acceptable.
After filling in checks, add any additional concerns to the flags array (e.g., security, performance, dependencies).
Use the standard format (id, concern, category, severity_hint, evidence). This array can be empty.
Workflow: read the file → investigate → read file again → add finding → write file back. Repeat for each check.
This is critique iteration 2. The template file includes prior findings with their status. Verify addressed flags were actually fixed, re-flag if inadequate, and check for new issues introduced by the revision.
code
Additional guidelines:
- Robustness level: standard. Use balanced judgment. Flag significant risks, but do not spend flags on minor polish or executor-obvious boilerplate.
- Over-engineering: prefer the simplest approach that fully solves the problem.
- Reuse existing flag IDs when the same concern is still open.
- `verified_flag_ids`: list flag IDs from prior iterations that the revised plan actually resolves (e.g., if the plan was revised to fix FLAG-001, and you confirm the fix is correct, include "FLAG-001"). Only include flags you've verified — don't guess.
- Verify that the plan follows the expected structure when validator warnings or the outline suggest drift.
- Additional flags may use these categories: correctness, security, completeness, performance, maintainability, other.
- Focus on concrete issues, not structural formatting.
{"checks":[{"id":"issue_hints","question":"Did the work fully address the issue hints, user notes, and approved plan requirements?","findings":[{"detail":"Checked Step 2 against the actual review loop in megaplan/handlers.py:1065-1102. Lowering execution.max_review_rework_cycles from 3 to 2 does resolve the old default-cap gap, but _resolve_review_outcome() reads that one global setting for every review path, so the revised plan changes standard-mode rework behavior too even though the brief explicitly says standard robustness must remain exactly as today.","flagged":true},{"detail":"Checked the new criteria_verdict approach against the real _review_prompt() and diff helper. _review_prompt() in megaplan/prompts/review.py:112-160 still injects the approved plan, plan metadata, full gate summary, execution summary, and execution audit, while collect_git_diff_summary() in megaplan/_core/io.py:342-359 is only git status --short, not a full patch. Folding that unchanged prompt into parallel_review means at least one heavy-mode review check agent still violates the brief's issue-anchored 'issue text + full diff + finalize (+ settled decisions)' context contract.","flagged":true}]},{"id":"correctness","question":"Are the proposed changes technically correct?","findings":[{"detail":"Checked the schema/source-field fix against the live review schema definitions. The revised plan now updates both .megaplan/schemas/review.json and megaplan/schemas.py, and it explicitly widens rework_items with an optional source field, so the earlier schema mismatch around rework_items[].source is addressed at the plan level.","flagged":false},{"detail":"Checked the toolset decision against megaplan/hermes_worker.py:52-63. The revised plan now explicitly uses _toolsets_for_phase(\"review\") for review checks instead of critique's file-plus-web toolset, which matches the repository's current review-phase permission contract and resolves that earlier drift.","flagged":false}]},{"id":"scope","question":"Search for related code that handles the same concept. Is the reported issue a symptom of something broader?","findings":[{"detail":"Checked the revised review-flag lifecycle against the existing critique machinery in megaplan/prompts/critique.py:113-160 and megaplan/flags.py:53-103. The plan now adds prior REVIEW findings plus verified_flag_ids and disputed_flag_ids, so the earlier lifecycle gap is genuinely addressed and the review loop would mirror critique much more closely.","flagged":false},{"detail":"Checked the new review-check registry contract against megaplan/checks.py:139-144 and the brief's requested 8-check table. The revised plan now puts a ninth criteria_verdict entry inside REVIEW_CHECKS and makes checks_for_robustness(\"standard\") return (), so the new API no longer truly mirrors the repository's existing heavy/all, standard/core, light/none pattern. That divergence may be intentional, but it is still a meaningful contract change rather than a straight mirror of megaplan/checks.py.","flagged":true}]},{"id":"verification","question":"Is there convincing verification for the change?","findings":[{"detail":"Checked the revised regression plan against the new global-cap change. The byte-identical standard-mode fixture does fix the earlier key-set-only test gap, but it still would not catch Step 2's behavior change because it exercises one fixed review payload rather than a standard-mode needs_rework loop that reaches _resolve_review_outcome() and the lowered max_review_rework_cycles threshold. If the plan keeps the global cap change, it needs a standard-mode loop regression test too.","flagged":true},{"detail":"Checked the prior harness-fit concern against the revised validation section. The plan no longer promises automated known-good or known-bad heavy-review fixture tests inside tests/; it keeps deterministic unit and wiring tests in the suite and moves the SWE-bench case to manual validation, which is a better fit for the repository's current test infrastructure.","flagged":false}]}],"flags":[{"id":"FLAG-004","concern":"Review loop: Lowering execution.max_review_rework_cycles globally to 2 changes standard-mode review-loop behavior, so the revised plan no longer keeps non-heavy review exactly as today.","category":"correctness","severity_hint":"likely-significant","evidence":"megaplan/handlers.py:1087-1100 applies get_effective(\"execution\", \"max_review_rework_cycles\") to every review path, and the revised plan explicitly changes that default in megaplan/types.py rather than scoping the cap to heavy mode."},{"id":"FLAG-005","concern":"Review context: The new criteria_verdict check still inherits _review_prompt()'s broad plan/gate/execution context and only a git-status diff summary, so not every heavy-mode check agent is issue-anchored the way the brief requires.","category":"completeness","severity_hint":"likely-significant","evidence":"megaplan/prompts/review.py:112-160 includes approved plan, plan metadata, full gate summary, execution summary, and execution audit, while megaplan/_core/io.py:342-359 shows collect_git_diff_summary() returns git status --short, not a full diff."}],"verified_flag_ids":["FLAG-001","FLAG-002","FLAG-003","issue_hints-1","issue_hints-2","correctness-1","correctness-2","scope-1","scope-2","verification-1","verification-2"],"disputed_flag_ids":[]}
You are an independent reviewer. Critique the plan against the actual repository.
Robust Review Phase for Megaplan (Heavy Mode Only)
Context
Megaplan is a planning/execution harness with phases: prep → plan → critique → gate → (revise → critique → gate)* → finalize → execute → review. Critique already has a "robust" mode where it runs multiple focused checks in parallel (megaplan/parallel_critique.py + megaplan/checks.py), each as an independent sub-agent with its own session. We validated on ~15 random SWE-bench failures that the current single-call review phase misses ~65% of salvageable failures because it anchors to the plan's success criteria instead of the original issue text, and because it evaluates everything in one call without forced enumeration.
Goal
Add a robust review mode that mirrors the robust critique architecture: multiple focused, parallel, issue-anchored checks that produce structured flags with rework directives, which feed back through the existing gate → revise/re-execute loop.
Standard robustness mode must remain exactly as today. This design is heavy-mode only.
What exists today (don't break)
megaplan/prompts/review.py — single-call review prompt; validates execution against finalize.json criteria/task_verdicts/sense_check_verdicts. Works well as the baseline. Keep it.
megaplan/prompts/critique.py + megaplan/parallel_critique.py + megaplan/checks.py — the pattern we're mirroring. Read these to understand the architecture.
megaplan/handlers.pyhandle_review() — entry point. Currently calls a single worker.
The gate → revise/re-execute loop already exists with max iteration cap and ESCALATE semantics.
intent_and_notes_block(state) contains the original issue text — crucial input for issue-anchored checks.
What needs to exist
1. New check table for review
New file megaplan/review_checks.py mirroring megaplan/checks.py. Define REVIEW_CHECKS with these entries (core + extended tiers). Each check has id, question, guidance, category, default_severity, tier:
Core tier (always run in heavy mode):
coverage — Enumerate every concrete failing example, symptom, or "X should Y" statement in the issue. For each, point to the specific line in the diff that addresses it. Flag any not covered. Subsumes intent/opt-in/default and accepted-changes concerns.
placement — Trace the call path from the failing input to where we made the change. Is the fix at the source of the bug or a downstream consumer? Would a maintainer put it here or elsewhere?
parity — Find 2–3 structurally similar classes/functions in the same module. Enumerate the methods/overrides/conventions they share. Does our new code follow the same patterns? If not, why not? (Highest new-leverage check.)
simplicity — What's the smallest possible change that would make the reported issue's example work? Compare against our diff. Every extra line must justify its existence against a specific requirement in the issue.
Extended tier (heavy mode with extended robustness):
dead_guard — For every new if x: / try: block added by the patch, trace whether the guarded branch is actually reachable given how callers invoke this function. Flag guards that never fire.
adjacent_calls — What other code calls the changed function or uses the same pattern? Would the same bug affect them?
parser_source — If the bug is in parsing/transformation, is the fix at the source of the bug or at a downstream consumer?
return_value_downstream — For any value the patch returns or constructs in an error path, trace where it flows next. Will the downstream consumer handle it correctly?
Also include a checks_for_robustness() function mirroring megaplan/checks.py.
2. Mechanical pre-checks (no LLM, run before parallel review)
Add a new module megaplan/review_mechanical.py or inline in handlers:
source_touch — Does the diff touch at least one non-test file in the package? Reject test-only diffs.
diff_size_sanity — Compare diff size (lines/hunks/files) to a rough expectation from the issue (number of code snippets × ~10 lines). Flag >3x or <0.3x.
dead_guard_static — For new if x: blocks, AST-parse the changed file, find the enclosing function, check whether x has a callable signature at the call site where it could be None/False. This is a heuristic; don't overreach.
These are advisory flags, not blocks. They populate a pre_check_flags array that the LLM review checks see as input.
3. Parallel review runner
New file megaplan/parallel_review.py, mirroring megaplan/parallel_critique.py. Same architecture: ThreadPoolExecutor, one agent per check, each with its own session via SessionDB, writes findings to a pre-populated template slot. Concurrency of 2 (same as critique). Include the MiniMax→OpenRouter fallback pattern.
Important: each check agent gets the original issue text + the full git diff + the finalize.json artifacts, nothing else. No plan, no critique history, no gate summary. The whole point is that these checks are anchored to the issue, not the plan.
4. Prompt builders for single-check review
In megaplan/prompts/review.py, add:
single_check_review_prompt(state, plan_dir, root, check, output_path) — mirrors single_check_critique_prompt — single focused prompt for one check.
_write_single_check_review_template(plan_dir, state, check, filename) — pre-populates the output file with the check's ID.
_build_review_checks_template(plan_dir, state, checks) — builds the per-check template list.
Keep _review_prompt() as-is. It still runs as the "criteria_verdict" check in heavy mode.
5. Handler integration
In megaplan/handlers.pyhandle_review():
Read configured_robustness(state)
If standard or light → run the existing single-call review unchanged
If heavy → run the mechanical pre-checks, then run parallel_review() across REVIEW_CHECKS + the existing criteria-based review-as-check. Merge all flags into one review.json
The output shape adds a checks array alongside the existing review_verdict, criteria, issues, rework_items, task_verdicts, sense_check_verdicts, summary. Back-compat: existing consumers that only look at review_verdict / rework_items keep working.
6. Feedback loop — how flags flow back
This is the tricky part. The review runs after execute. If it raises blocking flags, where does control go?
Decision: reuse the existing gate → revise/re-execute loop, not a new review-specific loop.
Concretely:
If review_verdict == "needs_rework" with blocking flags, the handler writes them to rework_items as today.
The execute loop in evals/run_evals.py already handles needs_rework by going back to revise or re-execute based on the rework type. No new routing logic.
Add a new field rework_directive.source = "review_{check_id}" so the executor knows the provenance and can prioritize.
Max review iterations cap at 2 (configurable). After 2 rounds of needs_rework from the review, escalate. Otherwise the same check can fire forever on tasks the model can't solve.
Review flags cannot re-raise concerns the gate already settled. Before raising a coverage/placement/parity flag, the review check must check gate.settled_decisions — if the concern matches a settled decision, downgrade to "significant" (info) rather than "blocking". This prevents the gate-override deadlock we hit before.
7. Severity ladder (mirrors critique)
Each review flag has:
blocking — triggers needs_rework, forces another revise/execute pass
significant — logged, shown to gate for future iterations, doesn't auto-block
minor — info only, aggregated into summary
8. Flag tracking across review iterations
Mirror critique's flag registry. Each review check's findings get IDs like REVIEW-COV-001. Status transitions open → verified → resolved across iterations, just like critique flags. Read megaplan/_core flag registry helpers — reuse them, don't duplicate.
9. Schema updates
Add a review checks schema fragment alongside the existing review schema in schemas/ (wherever step schemas live — look at STEP_SCHEMA_FILENAMES in megaplan/workers.py). The schema should allow the existing top-level fields PLUS a new checks array with per-check findings.
10. Tests
Unit tests for REVIEW_CHECKS structure and checks_for_robustness() behavior
Unit test that standard robustness still calls the single-call review (regression guard)
Unit test for mechanical pre-checks (source_touch, diff_size_sanity)
Integration test: feed a known-bad patch through heavy review, assert it raises the expected flag
Integration test: feed a known-good patch through heavy review, assert no blocking flags
Use the existing test infrastructure patterns.
Generalization beyond review
While implementing, keep these generalizations in mind (don't implement them now, but design so they're easy later):
checks_for_robustness() pattern should be extractable to a shared utility — same function body in checks.py and review_checks.py should be one function.
Parallel focused-agent runner (parallel_critique.py + parallel_review.py) should be refactorable to a single parallel_phase_runner.py that both delegate to. Not in this PR, but leave clean seams.
Template-file-with-preloaded-IDs pattern should be documented as "the preferred way to get structured output" in a short comment at the top of parallel_review.py.
Mechanical pre-checks should be runnable standalone so they can be reused by critique, finalize, or any other phase that wants cheap advisory checks.
Out of scope for this plan
Automatic golden-patch comparison for false-negative detection (we already have auto_improve/check_false_negatives.py)
Running these checks on tasks that already passed
A/B evaluation of which checks actually earn their spot (that's a separate measurement exercise)
Any changes to critique, plan, execute, prep, or finalize phases
Any changes to standard or light robustness mode
New top-level phases between review and execute
Success criteria
Heavy mode review produces a checks array with one entry per REVIEW_CHECK
Standard mode review produces byte-identical output to today for the same input
Blocking flags flow through the existing rework loop without new routing logic
Flag iteration cap prevents infinite review→re-execute loops
Unit + integration tests pass
Code follows the same patterns as parallel_critique.py and checks.py — a reader familiar with critique should find nothing surprising in the review code
Files likely to change
NEW: megaplan/review_checks.py
NEW: megaplan/parallel_review.py
NEW: megaplan/review_mechanical.py (or inline in handlers)
Heavy-mode review adds a parallel, issue-anchored check architecture mirroring robust critique. Standard/light paths stay byte-identical. Revision v3 fixes three plan defects surfaced by the gate:
Iteration cap scope (FLAG-004 / issue_hints-1). v2 lowered the global execution.max_review_rework_cycles default from 3→2, but _resolve_review_outcome (megaplan/handlers.py:1087-1100) reads that single key for every robustness mode, silently changing standard-mode rework behavior. Fix: introduce a new config key execution.max_heavy_review_rework_cycles = 2, read it in _resolve_review_outcome only when configured_robustness(state) == "heavy". Leave max_review_rework_cycles at its current default (3) untouched.
Criteria-verdict context violation (FLAG-005 / issue_hints-2). v2 wrapped _review_prompt verbatim, which injects approved plan, plan metadata, full gate summary, execution summary, and execution audit — directly contradicting GATE-SD-002 ("issue text + full diff + finalize + settled decisions only"). Worse, collect_git_diff_summary at megaplan/_core/io.py:342-359 returns git status --short, not a real diff, so even the focused checks were under-informed. Fix: (a) add a new collect_git_diff_patch(project_dir) helper that runs git diff HEAD for a real unified patch, (b) build a brand-new heavy_criteria_review_prompt from scratch that consumes only intent_block + full diff + finalize.json + settled_decisions, producing the same output shape as _review_prompt for downstream merge compatibility. _review_prompt stays untouched for standard mode.
Registry contract drift (scope). v2 put a 9th criteria_verdict entry inside REVIEW_CHECKS and collapsed checks_for_robustness("standard") → (), diverging from megaplan/checks.py's heavy/all, standard/core, light/none pattern. Fix: keep REVIEW_CHECKS as exactly the 8 brief checks, restore the heavy/all (8), standard/core (4), light/() shape. Criteria-verdict becomes a separate concern owned by parallel_review itself — the runner always schedules it as an additional future in heavy mode via a distinct code path, not an entry in the check table.
Verified facts driving v3:
megaplan/_core/io.py:342-359: collect_git_diff_summary is git status --short. A new full-diff helper is required.
megaplan/handlers.py:1087-1100: the cap is read via get_effective("execution", "max_review_rework_cycles") unconditionally; the branch must read a different key when heavy.
megaplan/types.py:286-300: config defaults live in one dict; adding a new key is a one-line change that preserves backward compatibility.
GATE settled decisions carried forward: GATE-SD-001 through GATE-SD-008 remain in force; v3 does not revisit them.
Step 2: Add heavy-scoped iteration cap config key (megaplan/types.py, megaplan/handlers.py)
Scope: Small
Add a new key to the defaults dict in megaplan/types.py near line 289: "execution.max_heavy_review_rework_cycles": 2, and register it in the effective-config allow-list (same block that lists "execution.max_review_rework_cycles" around line 297). Leave max_review_rework_cycles at its existing default — no change to standard-mode behavior.
Modify_resolve_review_outcome (megaplan/handlers.py:1065-1102) to accept robustness: str (pass it from handle_review which already computes it). Inside, replace the single get_effective("execution", "max_review_rework_cycles") read with:
Addresses: FLAG-004, issue_hints-1. Standard/light modes now demonstrably use the same cap as today.
Step 3: Add a real git-diff helper (megaplan/_core/io.py)
Scope: Small
Addcollect_git_diff_patch(project_dir: Path) -> str alongside collect_git_diff_summary at megaplan/_core/io.py:342. Implementation mirrors the existing helper's error handling but runs git diff HEAD (captures both staged and unstaged changes against HEAD, which is what the heavy review needs after the execute phase has written files). Handles: no .git, timeout, git not found, non-zero exit. On empty output, returns "No git changes detected.".
Export from megaplan/_core/__init__.py alongside the existing helper.
Leavecollect_git_diff_summary untouched to avoid perturbing critique/standard-review/other consumers.
Addresses: prerequisite for FLAG-005.
Step 4: Widen review schemas in BOTH locations (.megaplan/schemas/review.json, megaplan/schemas.py)
Scope: Medium
Edit.megaplan/schemas/review.json: add optional top-level checks, pre_check_flags, verified_flag_ids, disputed_flag_ids arrays; widen rework_items.items to include optional source string. Keep additionalProperties: false.
Editmegaplan/schemas.py:353-411 in lockstep (GATE-SD-005).
Addresses: carries forward GATE-SD-005; no behavioral change from v2.
Createmegaplan/review_checks.py mirroring megaplan/checks.py:1-236 exactly. Define ReviewCheckSpec with the same fields as CritiqueCheckSpec (no prompt_kind — unnecessary now that criteria_verdict lives outside the registry).
REVIEW_CHECKS contains exactly the 8 brief entries:
checks_for_robustness returns: heavy → all 8; standard → the 4 core checks; light → (). This exactly mirrorsmegaplan/checks.py:139-144 (heavy/all, standard/core, light/none). The standard-path consumers never actually call this function because the handler short-circuits to the legacy _review_prompt for standard/light — but the shape is now faithful to critique.
Createmegaplan/review_mechanical.py exposing run_pre_checks(plan_dir, state, project_dir) -> list[dict]. Unchanged from v2: source_touch, diff_size_sanity (uses the new collect_git_diff_patch for accurate line counts), dead_guard_static (narrow AST heuristic).
Leave_review_prompt and _write_review_template completely untouched — the standard-mode worker still uses them verbatim (GATE-SD-001).
Add_heavy_review_context(state, plan_dir) returning only: project_dir, intent_block (via intent_and_notes_block), git_diff (via new collect_git_diff_patch), finalize_data (read finalize.json), settled_decisions (only the settled_decisions list from gate.json). No plan, no plan metadata, no full gate summary, no execution summary, no execution audit. (GATE-SD-002.)
Add_write_single_check_review_template(plan_dir, state, check, filename) pre-populating {checks: [{id, question, guidance, findings: [], prior_findings?}], flags: [], pre_check_flags: [], verified_flag_ids: [], disputed_flag_ids: []}. For iteration > 1, attach prior_findings for the matching REVIEW-* flags from the registry (mirrors megaplan/prompts/critique.py:113-160).
Add_write_criteria_verdict_review_template(plan_dir, state, filename) that pre-populates the full review output shape (criteria, task_verdicts, sense_check_verdicts, review_verdict, issues, rework_items, summary) — reusing the same pre-population logic as _write_review_template so task/sense-check IDs come from finalize.json.
Addsingle_check_review_prompt(state, plan_dir, root, check, output_path, pre_check_flags) — issue-anchored focused prompt using _heavy_review_context. Includes settled-decisions block with the explicit downgrade rule. Finding schema identical to critique.
Addheavy_criteria_review_prompt(state, plan_dir, root, output_path) — a new prompt built from scratch, NOT wrapping _review_prompt. Context: _heavy_review_context only. Task: produce criteria (evaluated against finalize.json success_criteria), task_verdicts, sense_check_verdicts, review_verdict, rework_items, summary, issues — same output keys as _review_prompt so downstream merging is unchanged. The prompt instructs the agent that it sees only the issue text + full diff + finalize + settled decisions, deliberately excluding plan/gate/execution context to force issue-anchored evaluation.
len(checks) futures for the 8 focused REVIEW_CHECKS, each via single_check_review_prompt.
One additional future for the criteria-verdict path, via heavy_criteria_review_prompt writing to a separate criteria_verdict_output.json template. The runner dispatches this via a small _run_criteria_verdict(...) helper alongside _run_check(...).
Merge:
Aggregate checks[] from focused futures (same order as checks arg).
Aggregate verified_flag_ids / disputed_flag_ids from all futures with _merge_unique.
Surface the criteria-verdict future's full review payload as criteria_payload on the returned WorkerResult for the handler to merge in Step 10.
Top-of-file docstring: documents the template-file-with-preloaded-IDs convention (generalization #3) and notes that this module is structurally parallel to parallel_critique.py for future refactoring (generalization #2).
Step 9: Review flag lifecycle (megaplan/flags.py)
Scope: Medium
Refactor the synthetic-flag loop in megaplan/flags.py:69-87 into a shared helper _synthesize_flags_from_checks(checks, *, category_map, get_check_def, id_prefix) used by both update_flags_after_critique and the new update_flags_after_review (GATE-SD-004).
Applies verified_flag_ids / disputed_flag_ids to existing REVIEW-* flags (same transitions as critique).
Synthesizes new flags from flagged review-check findings with id_prefix="REVIEW". Flag ids: REVIEW-<CHECK_ID>-<INDEX> (e.g., REVIEW-COVERAGE-001). Uses review_checks.get_check_by_id for severity defaults.
Build merged payload: take parallel_result.payload["criteria_payload"] (criteria/task_verdicts/sense_check_verdicts/review_verdict/rework_items/summary/issues) and attach checks, pre_check_flags, verified_flag_ids, disputed_flag_ids from the parallel result.
For any flagged focused-check finding whose default_severity == "likely-significant" (and not downgraded by settled-decision rule in the prompt), synthesize a rework item {task_id: "REVIEW", issue, expected, actual, evidence_file, source: "review_<check_id>"} appended to the merged payload's rework_items and force review_verdict = "needs_rework". Preserve existing rework items from the criteria-verdict worker.
Record history with summed cost_usd / duration_ms.
Update_resolve_review_outcome signature (from Step 2) so both branches pass robustness. Heavy reads the new max_heavy_review_rework_cycles = 2; standard/light read unchanged max_review_rework_cycles = 3.
Verify_merge_review_verdicts tolerates rework items with sentinel task_id="REVIEW" — it only strict-checks task_verdicts, not rework_items. Add a targeted test in Step 11.
Step 11: Tests (tests/)
Scope: Medium
tests/test_review_checks.py:REVIEW_CHECKS has exactly 8 ids (no criteria_verdict). checks_for_robustness returns heavy→8, standard→4 core, light→(). validate_review_checks rejects duplicates.
tests/test_io_git_patch.py:collect_git_diff_patch returns a real unified diff on a fixture repo; falls back cleanly on no-git/non-repo/timeout.
tests/test_handle_review_robustness.py:
Standard regression (byte-identical): fixture a review.json golden, mock worker to return the exact payload, assert the file written matches byte-for-byte (not just key set). This strengthens the v2 check in response to verification-1.
Iteration cap scope: call _resolve_review_outcome with robustness="standard" and a history of 2 prior needs_rework → asserts it still returns needs_rework (cap is 3). Call with robustness="heavy" and the same history → asserts it force-proceeds (cap is 2). Directly proves FLAG-004 is fixed.
Heavy path: mock run_parallel_review returning one flagged coverage finding + a criteria_payload with review_verdict="approved". Assert merged review.json has checks, pre_check_flags, verified_flag_ids, disputed_flag_ids; review_verdict is needs_rework (coverage forces it); rework items include source="review_coverage"; REVIEW-COVERAGE-001 exists in the flag registry.
Iteration-2 lifecycle: pre-seed registry with REVIEW-COVERAGE-001 status=open; mock parallel_review to return verified_flag_ids=["REVIEW-COVERAGE-001"]; assert registry status transitions to verified.
tests/test_parallel_review.py: stub AIAgent/SessionDB; assert len(checks) + 1 futures scheduled; assert _toolsets_for_phase("review") is requested; assert the criteria-verdict future calls (not ); assert focused checks call ; assert results merged in order.
pytest tests/test_prompts.py tests/test_parallel_review.py tests/test_handle_review_robustness.py — wiring + the context-contract grep assertion that locks down FLAG-005.
Manual: heavy-mode run on a known-bad SWE-bench case; assert at least one of coverage/placement/parity/simplicity fires and the rework loop terminates within 2 iterations.
code
Plan metadata:
{
"version": 3,
"timestamp": "2026-04-07T20:56:54Z",
"hash": "sha256:2c036ff13234b253db07d0b739db5cb2234c49767e8b076e16141be298cb5c66",
"changes_summary": "Revision v3 addresses the 5 remaining significant flags: (1) FLAG-004/issue_hints-1 \u2014 reverts the global default change; instead, Step 2 introduces a new config key execution.max_heavy_review_rework_cycles = 2 and modifies _resolve_review_outcome to read it only when robustness == 'heavy'. Standard/light modes keep the existing default of 3, guaranteeing byte-identical rework behavior. (2) FLAG-005/issue_hints-2 \u2014 Step 3 adds a new collect_git_diff_patch helper (git diff HEAD, not git status --short) alongside the existing one; Step 7 builds a brand-new heavy_criteria_review_prompt from scratch that consumes only intent_block + full diff + finalize.json + settled_decisions \u2014 NO plan, no plan metadata, no gate summary, no execution summary, no execution audit. The prompt is NOT a wrapper over _review_prompt; it produces the same output keys for downstream merge compatibility. _review_prompt remains untouched for standard mode. (3) scope \u2014 REVIEW_CHECKS now contains exactly the 8 brief checks (criteria_verdict removed); checks_for_robustness returns heavy/all-8, standard/core-4, light/() \u2014 an exact mirror of megaplan/checks.py:139-144. Criteria-verdict becomes a separate future scheduled by parallel_review itself via a distinct _run_criteria_verdict helper, not an entry in the check table. Tests added: grep-assertion on the heavy criteria prompt for forbidden context markers (locks down FLAG-005), explicit cap-scope test for _resolve_review_outcome with both robustness values (locks down FLAG-004), byte-identical standard regression (replaces v2's key-set-only check, addresses previously-resolved verification-1).",
"flags_addressed": [
"FLAG-004",
"FLAG-005",
"issue_hints-1",
"issue_hints-2",
"scope"
],
"questions": [],
"success_criteria": [
{
"criterion": "megaplan/review_checks.py exports REVIEW_CHECKS with exactly 8 entries: coverage, placement, parity, simplicity, dead_guard, adjacent_calls, parser_source, return_value_downstream (no criteria_verdict)",
"priority": "must"
},
{
"criterion": "checks_for_robustness('heavy') returns all 8; ('standard') returns the 4 core checks; ('light') returns () \u2014 exact mirror of megaplan/checks.py:139-144",
"priority": "must"
},
{
"criterion": "execution.max_review_rework_cycles default is UNCHANGED in megaplan/types.py (still 3); a new key execution.max_heavy_review_rework_cycles exists with default 2",
"priority": "must"
},
{
"criterion": " reads only when , and reads otherwise",
"priority": "must"
},
{
"criterion": "Test proves: with and 2 prior needs_rework in history, does NOT force-proceed (cap is still 3); with and the same history, it DOES force-proceed (cap is 2)",
"priority": "must"
},
{
"criterion": "Both and STEP_SCHEMA_REGISTRY['review.json'] accept heavy-mode payloads with optional , , , , and rework items containing optional ",
"priority": "must"
},
{
"criterion": " has a new helper that runs and returns a unified patch; is unchanged",
"priority": "must"
},
{
"criterion": " in is a standalone prompt builder \u2014 NOT a wrapper over \u2014 that consumes only intent_block, full git diff (via ), finalize.json, and settled_decisions",
"priority": "must"
},
{
"criterion": "Snapshot/grep test proves output contains NO 'Approved plan:', 'Plan metadata:', 'Gate summary:', 'Execution summary:', or 'Execution audit' markers, and DOES contain the intent block, the git diff patch, finalize.json content, and settled_decisions",
"priority": "must"
},
{
"criterion": " in is byte-identical to today (standard-mode path unchanged)",
"priority": "must"
},
{
"criterion": "With , produces a byte-identical to today for a fixed worker payload (regression test compares full file bytes, not just keys)",
"priority": "must"
},
{
"criterion": "With , runs which schedules futures (8 focused + 1 criteria_verdict); the legacy worker is NOT invoked separately",
"priority": "must"
},
{
"criterion": "Heavy-mode contains , , , arrays alongside the existing fields",
"priority": "must"
},
{
"criterion": "Heavy-mode blocking findings populate with , set , and flow through the existing loop with no new routing logic",
"priority": "must"
},
{
"criterion": " uses (file-only), not ",
"priority": "must"
},
{
"criterion": "All heavy-mode review check agents (8 focused + criteria_verdict) receive only issue text + full git diff + finalize.json + settled gate decisions \u2014 no plan, no critique history, no broader gate summary, no execution audit",
"priority": "must"
},
{
"criterion": " consumes / to transition prior REVIEW-* flags; iteration-2 templates expose prior REVIEW findings with their status",
"priority": "must"
},
{
"criterion": "Review-synthesized flags use ids and live in the existing flag registry via /",
"priority": "must"
},
{
"criterion": "Synthetic-flag-from-check logic is shared between critique and review via a single helper in ",
"priority": "must"
},
{
"criterion": "All tests in pass, including new tests for the cap-scope split, the heavy criteria prompt context contract, dual-schema validation, and iteration-2 flag lifecycle",
"priority": "must"
},
{
"criterion": " is importable standalone for future reuse by other phases",
"priority": "should"
},
{
"criterion": " is structurally close enough to that a future refactor to a shared runner is mechanical",
"priority": "should"
},
{
"criterion": "End-to-end heavy-mode review on a known-bad SWE-bench patch raises at least one blocking flag from coverage/placement/parity/simplicity and completes rework within 2 iterations",
"priority": "info"
},
{
"criterion": "Heavy review meaningfully reduces the ~65% missed-salvageable-failures rate observed on the 15-task validation set",
"priority": "info"
}
],
"assumptions": [
"Introducing a new config key (default 2) rather than reusing or lowering the existing key is the minimal-scope fix: it changes no standard-mode behavior and makes the heavy cap independently configurable.",
" is the correct invocation for the post-execute heavy review: execute writes files to the working tree without committing, so captures both staged and unstaged changes against the pre-execute baseline.",
"Keeping unchanged (still ) avoids perturbing critique, finalize, and standard-review consumers that may depend on its exact output. A new helper is safer than a refactor.",
" producing the same output key shape as (criteria/task_verdicts/sense_check_verdicts/review_verdict/rework_items/summary/issues) lets the handler merge its output with focused-check results using the same code path, avoiding a divergent heavy-mode schema.",
"Scheduling criteria-verdict as an extra future inside (rather than as a REVIEW_CHECKS entry) keeps the registry a clean mirror of and keeps per-check-kind dispatch out of the check table. The runner schedules futures in heavy mode.",
"Standard/light paths never invoke in practice \u2014 the handler short-circuits to the legacy single-call worker \u2014 so having return the 4 core checks is a consistency-with-critique choice that has no runtime effect today but avoids API surprise later.",
"The grep-assertion test in Step 11 for forbidden markers in (no 'Approved plan:', no 'Gate summary:', etc.) is the simplest enforceable proof that FLAG-005 is fixed; a snapshot test would be noisier."
],
"delta_from_previous_percent": 78.96,
"structure_warnings": []
}
code
Plan structure warnings from validator:
[]
Existing flags:
[
{
"id": "issue_hints-1",
"concern": "Did the work fully address the issue hints, user notes, and approved plan requirements?: Checked Step 2 against the actual review loop in megaplan/handlers.py:1065-1102. Lowering execution.max_review_rework_cycles from 3 to 2 does resolve the old default-cap gap, but _resolve_review_outcome() reads that one global setting for every review path, so the revised plan changes standard-mode rework behavior too even though the brief explicitly says standard robustness must remain exactly as today.",
"status": "addressed",
"severity": "significant"
},
{
"id": "issue_hints-2",
"concern": "Did the work fully address the issue hints, user notes, and approved plan requirements?: Checked the new criteria_verdict approach against the real _review_prompt() and diff helper. _review_prompt() in megaplan/prompts/review.py:112-160 still injects the approved plan, plan metadata, full gate summary, execution summary, and execution audit, while collect_git_diff_summary() in megaplan/_core/io.py:342-359 is only git status --short, not a full patch. Folding that unchanged prompt into parallel_review means at least one heavy-mode review check agent still violates the brief's issue-anchored 'issue text + full diff + finalize (+ settled decisions)' context contract.",
"status": "addressed",
"severity": "significant"
},
{
"id": "FLAG-004",
"concern": "Review loop: Lowering execution.max_review_rework_cycles globally to 2 changes standard-mode review-loop behavior, so the revised plan no longer keeps non-heavy review exactly as today.",
"status": "addressed",
"severity": "significant"
},
{
"id": "FLAG-005",
"concern": "Review context: The new criteria_verdict check still inherits _review_prompt()'s broad plan/gate/execution context and only a git-status diff summary, so not every heavy-mode check agent is issue-anchored the way the brief requires.",
"status": "addressed",
"severity": "significant"
},
{
"id": "scope",
"concern": "Search for related code that handles the same concept. Is the reported issue a symptom of something broader?: Checked the new review-check registry contract against megaplan/checks.py:139-144 and the brief's requested 8-check table. The revised plan now puts a ninth criteria_verdict entry inside REVIEW_CHECKS and makes checks_for_robustness(\"standard\") return (), so the new API no longer truly mirrors the repository's existing heavy/all, standard/core, light/none pattern. That divergence may be intentional, but it is still a meaningful contract change rather than a straight mirror of megaplan/checks.py.",
"status": "addressed",
"severity": "significant"
},
{
"id": "verification",
"concern": "Is there convincing verification for the change?: Checked the revised regression plan against the new global-cap change. The byte-identical standard-mode fixture does fix the earlier key-set-only test gap, but it still would not catch Step 2's behavior change because it exercises one fixed review payload rather than a standard-mode loop that reaches and the lowered threshold. If the plan keeps the global cap change, it needs a standard-mode loop regression test too.",
"status": "open",
"severity": "minor"
}
]
code
Known accepted debt grouped by subsystem:
{
"are-the-proposed-changes-technically-correct": [
{
"id": "DEBT-009",
"concern": "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.",
"occurrence_count": 1,
"plan_ids": [
"move-the-entry-page-into-20260401-0450"
]
},
{
"id": "DEBT-010",
"concern": "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.",
"occurrence_count": 1,
"plan_ids": [
"move-the-entry-page-into-20260401-0450"
]
}
],
"are-the-success-criteria-well-prioritized-and-verifiable": [
{
"id": "DEBT-019",
"concern": "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.",
"occurrence_count": 1,
"plan_ids": [
"move-the-entry-page-into-20260401-0450"
]
}
],
"did-the-work-fully-address-the-issue-hints-user-notes-and-approved-plan-requirements": [
{
"id": "DEBT-011",
"concern": "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 . in the current repo, the mobile sticky nav at 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.",
"occurrence_count": 1,
"plan_ids": [
"move-the-entry-page-into-20260401-0450"
]
},
{
"id": "DEBT-012",
"concern": "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 . the implementer cannot satisfy both instructions as written.",
"occurrence_count": 1,
"plan_ids": [
"move-the-entry-page-into-20260401-0450"
]
}
],
"does-the-change-touch-all-locations-and-supporting-infrastructure": [
{
"id": "DEBT-018",
"concern": "does the change touch all locations and supporting infrastructure?: if the implementation really wants to carry mobile actions, the plan must also include a supporting change in or render a separate mobile control surface outside the card. right now step 4.9 removes the mobile nav but does not list as a place that must change, so the required glue for mobile controls is missing.",
"occurrence_count": 1,
"plan_ids": [
"move-the-entry-page-into-20260401-0450"
]
}
],
"execute-phase-contract": [
{
"id": "DEBT-003",
"concern": "early-killed baselines pass truncated output to the execute worker, which may produce lower-quality diagnosis than full output.",
"occurrence_count": 1,
"plan_ids": [
"design-and-implement-a-20260327-0512"
]
}
],
"find-the-callers-of-the-changed-function-what-arguments-do-they-actually-pass-does-the-fix-handle-all-of-them": [
{
"id": "DEBT-014",
"concern": "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 looks redundant. optimistically adds the id to in , and already reactively filters skipped entries from in . calling immediately afterward is safe, but it duplicates an existing state transition and should be justified as an explicit ux optimization rather than required logic.",
"occurrence_count": 1,
"plan_ids": [
"move-the-entry-page-into-20260401-0450"
]
},
{
"id": "DEBT-015",
"concern": "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. invokes its own prop when an unauthenticated user interacts with the score ui (), which is independent of the scoring hook's internal path. the plan should be read as requiring that caller to dispatch ; otherwise one caller remains broken even if is correctly wired.",
"occurrence_count": 1,
"plan_ids": [
"move-the-entry-page-into-20260401-0450"
]
}
],
"handler-boilerplate": [
{
"id": "DEBT-004",
"concern": "_run_worker() pseudocode hardcodes iteration=state['iteration'] but handle_plan and handle_revise use different failure iteration values.",
"occurrence_count": 1,
"plan_ids": [
"clean-up-and-properly-20260331-0149"
]
},
{
"id": "DEBT-005",
"concern": "same issue as correctness-1: failure iteration would be wrong for plan/revise handlers.",
"occurrence_count": 1,
"plan_ids": [
"clean-up-and-properly-20260331-0149"
]
}
],
"install-paths": [
{
"id": "DEBT-023",
"concern": "local setup path doesn't expose subagent mode",
"occurrence_count": 1,
"plan_ids": [
"refactor-megaplan-skill-so-20260406-1818"
]
},
{
"id": "DEBT-024",
"concern": "no automated guard to keep the mirror file synchronized with source files",
"occurrence_count": 1,
"plan_ids": [
"update-all-documentation-20260406-1902"
]
},
{
"id": "DEBT-025",
"concern": "local setup test only checks agents.md existence, not content",
"occurrence_count": 1,
"plan_ids": [
"update-all-documentation-20260406-1902"
]
}
],
"is-there-convincing-verification-for-the-change": [
{
"id": "DEBT-016",
"concern": "is there convincing verification for the change?: the test-plan details still miss a small but real infrastructure update: the current helper in only renders , so the step 7 requirement to assert cannot be implemented unless that helper is extended to expose . the same pattern exists in the related page tests.",
"occurrence_count": 1,
"plan_ids": [
"move-the-entry-page-into-20260401-0450"
]
},
{
"id": "DEBT-017",
"concern": "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 .",
"occurrence_count": 1,
"plan_ids": [
"move-the-entry-page-into-20260401-0450"
]
}
],
"mobile-ui": [
{
"id": "DEBT-020",
"concern": "mobile ui: removing entrypage's mobile sticky nav and relying on would break mobile navigation and scoring because that footer slot is hidden below the breakpoint.",
"occurrence_count": 1,
"plan_ids": [
"move-the-entry-page-into-20260401-0450"
]
}
],
"search-for-related-code-that-handles-the-same-concept-is-the-reported-issue-a-symptom-of-something-broader": [
{
"id": "DEBT-013",
"concern": "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. already has a pre-existing mobile gap because its score panel is desktop-only and its footer actions are also hidden on mobile ( plus ). 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.",
"occurrence_count": 1,
"plan_ids": [
"move-the-entry-page-into-20260401-0450"
]
}
],
"subagent-safeguards": [
{
"id": "DEBT-021",
"concern": "hermes reference safeguard numbers not validated against actual implementation",
"occurrence_count": 1,
"plan_ids": [
"refactor-megaplan-skill-so-20260406-1818"
]
},
{
"id": "DEBT-022",
"concern": "plan's retry caps (1 phase, 3 execute) may differ from hermes-agent's actual policy",
"occurrence_count": 1,
"plan_ids": [
"refactor-megaplan-skill-so-20260406-1818"
]
}
],
"worker-permissions": [
{
"id": "DEBT-001",
"concern": "codex --full-auto flag only triggers for step == 'execute', not 'loop_execute'",
"occurrence_count": 1,
"plan_ids": [
"build-megaloop-a-minimal-20260327-0250"
]
},
{
"id": "DEBT-002",
"concern": "claude --permission-mode bypasspermissions only triggers for step == 'execute', not 'loop_execute'",
"occurrence_count": 1,
"plan_ids": [
"build-megaloop-a-minimal-20260327-0250"
]
}
],
"workflow-state-machine": [
{
"id": "DEBT-006",
"concern": "_plan_prompt() does not read research.json, so replanning from state_researched would ignore research results.",
"occurrence_count": 1,
"plan_ids": [
"clean-up-and-properly-20260331-0149"
]
},
{
"id": "DEBT-007",
"concern": "same issue as correctness-2: state_researched \u2192 plan path is only partially wired.",
"occurrence_count": 1,
"plan_ids": [
"clean-up-and-properly-20260331-0149"
]
},
{
"id": "DEBT-008",
"concern": "_plan_prompt() is a missed location for the state_researched \u2192 plan change.",
"occurrence_count": 1,
"plan_ids": [
"clean-up-and-properly-20260331-0149"
]
}
]
}
code
Escalated debt subsystems:
[
{
"subsystem": "install-paths",
"total_occurrences": 3,
"plan_count": 2,
"entries": [
{
"id": "DEBT-023",
"concern": "local setup path doesn't expose subagent mode",
"occurrence_count": 1,
"plan_ids": [
"refactor-megaplan-skill-so-20260406-1818"
]
},
{
"id": "DEBT-024",
"concern": "no automated guard to keep the mirror file synchronized with source files",
"occurrence_count": 1,
"plan_ids": [
"update-all-documentation-20260406-1902"
]
},
{
"id": "DEBT-025",
"concern": "local setup test only checks agents.md existence, not content",
"occurrence_count": 1,
"plan_ids": [
"update-all-documentation-20260406-1902"
]
}
]
},
{
"subsystem": "workflow-state-machine",
"total_occurrences": 3,
"plan_count": 1,
"entries": [
{
"id": "DEBT-006",
"concern": "_plan_prompt() does not read research.json, so replanning from state_researched would ignore research results.",
"occurrence_count": 1,
"plan_ids": [
"clean-up-and-properly-20260331-0149"
]
},
{
"id": "DEBT-007",
"concern": "same issue as correctness-2: state_researched \u2192 plan path is only partially wired.",
"occurrence_count": 1,
"plan_ids": [
"clean-up-and-properly-20260331-0149"
]
},
{
"id": "DEBT-008",
"concern": "_plan_prompt() is a missed location for the state_researched \u2192 plan change.",
"occurrence_count": 1,
"plan_ids": [
"clean-up-and-properly-20260331-0149"
]
}
]
}
]
code
Debt guidance:
- These are known accepted limitations. Do not re-flag them unless the current plan makes them worse, broadens them, or fails to contain them.
- Prefix every new concern with a subsystem tag followed by a colon, for example `Timeout recovery: retry backoff remains brittle`.
- When a concern is recurring debt that still needs to be flagged, prefix it with `Recurring debt:` after the subsystem tag, for example `Timeout recovery: Recurring debt: retry backoff remains brittle`.
Your output template is at: /Users/user_c042661f/Documents/megaplan/.megaplan/plans/robust-review-v2/critique_output.json
Read this file first — it contains 4 checks, each with a question and guidance.
For each check, investigate the codebase, then add your findings to the findings array for that check.
Each finding needs:
"detail": what you specifically checked and what you found (at least a full sentence)
"flagged": true if this describes a difference, risk, or tension — even if you think it's justified. false only if purely informational with no possible downside.
When in doubt, flag it — the gate can accept tradeoffs, but it can't act on findings it never sees.
Good: {"detail": "Checked callers of nthroot_mod in solveset.py line 1205 — passes prime moduli only, consistent with the fix.", "flagged": false}
Good: {"detail": "The fix handles empty tuples but not single-element tuples which need a trailing comma.", "flagged": true}
Bad: {"detail": "No issue found", "flagged": false} ← too brief, will be rejected
Bad: {"detail": "The hints suggest approach X but the plan uses Y. However Y is consistent with X's intent.", "flagged": false} ← a different approach than the hints IS a flag. You found a divergence — flag it. The gate decides if it's acceptable.
After filling in checks, add any additional concerns to the flags array (e.g., security, performance, dependencies).
Use the standard format (id, concern, category, severity_hint, evidence). This array can be empty.
Workflow: read the file → investigate → read file again → add finding → write file back. Repeat for each check.
This is critique iteration 3. The template file includes prior findings with their status. Verify addressed flags were actually fixed, re-flag if inadequate, and check for new issues introduced by the revision.
code
Additional guidelines:
- Robustness level: standard. Use balanced judgment. Flag significant risks, but do not spend flags on minor polish or executor-obvious boilerplate.
- Over-engineering: prefer the simplest approach that fully solves the problem.
- Reuse existing flag IDs when the same concern is still open.
- `verified_flag_ids`: list flag IDs from prior iterations that the revised plan actually resolves (e.g., if the plan was revised to fix FLAG-001, and you confirm the fix is correct, include "FLAG-001"). Only include flags you've verified — don't guess.
- Verify that the plan follows the expected structure when validator warnings or the outline suggest drift.
- Additional flags may use these categories: correctness, security, completeness, performance, maintainability, other.
- Focus on concrete issues, not structural formatting.
{"checks":[{"id":"issue_hints","question":"Did the work fully address the issue hints, user notes, and approved plan requirements?","findings":[{"detail":"Checked the heavy-only cap fix against the live review loop in megaplan/handlers.py:1065-1102 and the config defaults in megaplan/types.py:287-300. Introducing a separate execution.max_heavy_review_rework_cycles key and threading robustness into _resolve_review_outcome() would address the prior global-cap regression because the current code really does read one unconditional max_review_rework_cycles value for every review path.","flagged":false},{"detail":"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":true}]},{"id":"correctness","question":"Are the proposed changes technically correct?","findings":[{"detail":"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":true},{"detail":"Checked the schema and toolset carry-forwards against the current repo. v3 still keeps the dual-schema update and _toolsets_for_phase(\"review\") choice from v2, so the earlier schema/source-field mismatch and the review-vs-critique permission drift remain properly addressed at the plan level.","flagged":false}]},{"id":"scope","question":"Search for related code that handles the same concept. Is the reported issue a symptom of something broader?","findings":[{"detail":"Checked the review-check registry contract against megaplan/checks.py:139-144. v3 now restores the clean mirror: 8 concrete REVIEW_CHECKS only, heavy returns all 8, standard returns the 4 core checks, and light returns (), so the scope drift from v2's extra criteria_verdict entry is addressed.","flagged":false},{"detail":"Checked the lifecycle plumbing against the critique pattern in megaplan/prompts/critique.py:113-160 and megaplan/flags.py:53-103. The plan still carries forward prior REVIEW findings plus verified_flag_ids and disputed_flag_ids, so the review flag lifecycle remains aligned with the existing critique architecture rather than introducing a separate tracking system.","flagged":false}]},{"id":"verification","question":"Is there convincing verification for the change?","findings":[{"detail":"Checked the revised regression plan against the prior verification gap. Step 11 now adds the missing cap-scope test for _resolve_review_outcome() with both robustness='standard' and robustness='heavy', so the old standard-mode loop-regression concern is addressed.","flagged":false},{"detail":"Checked the new test list against the v3 diff-helper change. tests/test_io_git_patch.py is described as covering a unified diff plus no-git and timeout fallbacks, but the plan still does not mention an untracked-file case even though git diff HEAD would omit newly created untracked files while the existing review/evidence path counts them via git status --short. That leaves the most likely blind spot introduced by v3 effectively untested.","flagged":true}]}],"flags":[{"id":"FLAG-006","concern":"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.","category":"completeness","severity_hint":"likely-significant","evidence":"The revised plan's Step 7 explicitly introduces a new heavy-only criteria prompt from scratch, while the brief said to keep _review_prompt() as-is and have it still run as the heavy-mode criteria_verdict check."},{"id":"FLAG-007","concern":"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.","category":"correctness","severity_hint":"likely-significant","evidence":"megaplan/evaluation.py:109-175 uses git status --short and _parse_git_status_paths() to compare claimed files against all changed paths, including untracked ones, but the new Step 3 helper is specified as git diff HEAD."}],"verified_flag_ids":["issue_hints-1","issue_hints-2","FLAG-004","FLAG-005","scope","verification"],"disputed_flag_ids":[]}
“You are an independent reviewer. Critique the plan against the actual repository.….” Conversation with gpt-5.4, from the Peter O’Mallet DataClaw Conversations dataset. The Chat Archive, 2026. https://thechatarchive.com/c/01m80eq48akvz7svjw0q99j334
Dataset releases
Not yet included in a published release.
verified_flag_ids
disputed_flag_ids
source
Update any test that reads max_review_rework_cycles=3 (Step 2) to expect 2.
Addresses: FLAG-005, issue_hints-2. No heavy-mode prompt path includes the plan or broader context.
No changes to evals/run_evals.py routing.
heavy_criteria_review_prompt
_review_prompt
single_check_review_prompt
tests/test_prompts.py (extend): snapshot the heavy_criteria_review_prompt output for a fixture state and grep-assert that it does NOT contain "Approved plan:", "Plan metadata:", "Execution summary:", "Execution audit", or "Gate summary:" — proves FLAG-005 is fixed. Assert it DOES contain the intent_and_notes_block text, the patch header, finalize.json's content, and the settled-decisions list.
tests/test_schemas.py: add a heavy-mode payload case covering checks, pre_check_flags, verified_flag_ids, disputed_flag_ids, and rework_items[].source; assert both disk schema and megaplan/schemas.py registry accept it.