You are already running inside the megaplan harness for this step. Do the requested planning/review/execution work directly. Do NOT invoke the megaplan CLI, do NOT read or activate the megaplan skill, do NOT start nested megaplan plans, and do NOT recurse into another planning harness. Treat mentions of megaplan in the repository or environment as implementation context only.
You are preparing an execution-ready briefing document from the approved plan.
Add --from-doc flag to megaplan init plus a standardized ## Settled Decisions section format for doc-mode output. When --from-doc points at a doc-mode megaplan artifact, the CLI validates the path (relative to project_dir, no absolute, no .., must exist), parses any ## Settled Decisions section via a new pure function doc_assembly.extract_settled_decisions, stores the path at state.config.from_doc, and injects extracted decisions into state.meta.imported_decisions. Load-bearing decisions (load_bearing: true) auto-promote to must-priority success criteria for the new plan; non-load-bearing become info-priority. Doc-mode execute prompt is updated to instruct the worker to emit the standard Settled Decisions section format. Reuses existing settled_decisions concept in evaluation.py (name the new imported type SettledDecisionFromDoc to avoid collision). Reuses the _validate_relative_path logic factored from the existing --output validation. Out of scope for this PR: critique-level auto-check for SD-* citation, sidecar settled_decisions.json, verify-against-doc subcommand.
User notes and answers:
PRE-PLAN GUIDANCE (authoritative — do not re-derive):
Files that will be touched
megaplan/cli.py — add --from-doc to the init subparser
megaplan/handlers.py::handle_init — validate --from-doc, call the parser, populate state.config.from_doc and state['meta']['imported_decisions']
megaplan/doc_assembly.py — new extract_settled_decisions(doc_text: str) -> list[dict] pure function
megaplan/types.py — add SettledDecisionFromDoc TypedDict if the shape warrants it
megaplan/data/instructions.md — document --from-doc, the Settled Decisions section format, and how it interacts with success criteria
megaplan/data/prompts/* or wherever doc-mode execute worker prompt lives — update to instruct the worker to emit ## Settled Decisions in the standard format when the subject produces any
tests/test_handle_init_doc_mode.py — add tests for --from-doc validation (path must exist, must be inside project_dir, must parse cleanly)
tests/test_doc_assembly.py OR new tests/test_settled_decisions.py — unit tests for the parser against fixture doc strings
Assistant
Finalize briefing produced. 9 tasks covering all 13 plan steps, with T4/T5 bundling implementation+tests per the plan's incremental-test guidance, and T9 running the full suite plus a throwaway repro script. Watch items highlight the two addressed flags (FLAG-001 unconditional path propagation, FLAG-002 harness-side auto-promotion) and the scope fence.
Load-bearing decisions (pre-settled — don't re-debate in critique)
Parser lives in doc_assembly.py (pure function), not inline in handlers.py. Keeps handler thin and parser testable.
Decision ID format is SD-NNN (SD- prefix + 3-digit zero-padded). Parser is tolerant of the 3-digit convention but stores the ID verbatim as written.
load_bearing: true|false is the gate field. Only load_bearing: true decisions become must success criteria. Non-load-bearing are stored as info criteria for reference.
--from-doc takes a path RELATIVE to --project-dir. Absolute paths rejected. .. rejected. Same safety as --output.
--from-doc is valid with either --mode doc or --mode code, not just code. A doc plan can reference a prior doc.
Missing ## Settled Decisions section is NOT an error. Parser returns empty list; meta.imported_decisions is empty; --from-doc still stores the path for worker context.
Malformed entries within a well-formed section are logged but don't fail the parse (tolerant). Report parse warnings via the init response.
Reuse what already exists, don't duplicate
settled_decisions is already a first-class concept in megaplan/evaluation.py, megaplan/handlers.py, and megaplan/types.py — produced by gate/critique signals. Name the new type SettledDecisionFromDoc (distinct noun) to avoid collision with the existing gate-produced SettledDecision.
--output validation logic at handlers.py::handle_init (absolute path rejection, .. rejection, relative-to-project enforcement) is the template for --from-doc validation. Factor both into a small _validate_relative_path(project_dir, raw_path, flag_name) helper to avoid duplication.
Tests must cover
Parser: 5+ fixture strings (empty doc, doc with no section, doc with 3 well-formed decisions, doc with malformed entry inside well-formed section, doc with section but no entries)
handle_init with --from-doc pointing at a valid doc → config.from_doc set, meta.imported_decisions populated
handle_init with --from-doc pointing at non-existent file → invalid_args with clear message
handle_init with --from-doc pointing at absolute path → rejected
handle_init with --from-doc pointing at a doc with zero decisions → succeeds, imported_decisions is empty list
Full suite: PYENV_VERSION=3.11.11 python -m pytest tests/ must pass 690+ (current baseline 687 passed, 1 skipped).
Out of scope (do NOT scope-creep)
Full critique-level auto-check that verifies each SD-* is cited in the plan — follow-up
Sidecar settled_decisions.json written by doc-mode finalize — follow-up
Migrating existing doc-mode output to the new standard (convention starts with new plans)
code
Approved plan:
# Implementation Plan: `--from-doc` flag + standardized `## Settled Decisions` format
Overview
Add a --from-doc <path> flag to megaplan init that imports a prior doc-mode artifact's settled decisions into the new plan. Concretely:
New pure parser extract_settled_decisions(doc_text) -> tuple[list[dict], list[str]] in megaplan/doc_assembly.py (peer to existing assemble_doc / extract_sections).
New SettledDecisionFromDoc TypedDict in megaplan/types.py (distinct from the existing SettledDecision produced by gate).
handle_init (megaplan/handlers.py:728) validates the path, parses the doc, stores state.config.from_doc and state.meta.imported_decisions.
Always surface config.from_doc (path string + any imported decisions) to the doc-mode execute prompt and the planning prompt, even when the source doc has zero ## Settled Decisions (addresses FLAG-001).
Enforce auto-promotion at the handler level: after handle_plan (and handle_revise) receive the worker payload, a merge helper ensures every load_bearing: true imported decision has a matching must success criterion and every load_bearing: false has a matching info criterion. Idempotent — skips if the worker already produced a criterion referencing the SD-NNN id (addresses FLAG-002).
--output validation block at handlers.py:748-758 is factored into a shared _validate_relative_path(project_dir, raw, flag_name) helper, reused by --from-doc.
Out of scope (per brief): critique-level SD-citation checks, sidecar settled_decisions.json, verify-against-doc subcommand.
Add SettledDecisionFromDoc(TypedDict, total=False) at megaplan/types.py:170 (next to SettledDecision), with: id: str, decision: str, rationale: str, load_bearing: bool. Distinct name — not a subclass or alias of SettledDecision.
Extend PlanState's meta TypedDict to allow optional imported_decisions: list[SettledDecisionFromDoc].
Extend PlanState's config TypedDict to allow optional from_doc: str.
Add def extract_settled_decisions(doc_text: str) -> tuple[list[dict], list[str]]: at the top of megaplan/doc_assembly.py (next to extract_sections at line 13). Returns (decisions, warnings).
Parse from the ## Settled Decisions heading until the next ##/EOF. Item format (markdown list):
Each item starts with - id:; subsequent 2-space-indented key: value lines belong to the preceding item. Store id verbatim (tolerate non-3-digit IDs). Coerce load_bearing to bool (strings true/false, case-insensitive).
Be tolerant: no heading → ([], []). Heading + zero items → ([], []). Item missing required fields (id or decision) → drop, append message to warnings, keep parsing. Never raise.
Extract the three-check validation at megaplan/handlers.py:748-758 into a module-private helper _validate_relative_path(project_dir: Path, raw: str, flag_name: str) -> str that raises CliError("invalid_args", f"{flag_name} ...") for absolute paths, .. traversal, and out-of-project paths.
Replace the inline block with normalized_output_path = _validate_relative_path(project_dir, raw_output_path, "--output"). Keep error message bodies identical (only the flag-name prefix varies) so existing tests/test_handle_init_doc_mode.py::test_output_rejects_absolute_path and test_output_rejects_parent_traversal continue to pass.
Step 4: Add --from-doc CLI flag (megaplan/cli.py)
Scope: Small
Add after megaplan/cli.py:847 (after --output):
python
init_parser.add_argument("--from-doc", default=None,
help="Relative path to a prior doc-mode artifact whose "
"## Settled Decisions section should be imported. "
"Valid with --mode code or --mode doc.")
Step 5: Wire handle_init for --from-doc (megaplan/handlers.py)
Scope: Medium
After the --output block, validate and load:
python
raw_from_doc = getattr(args, "from_doc", None)
from_doc_rel: str | None = None
imported_decisions: list[dict] = []
parse_warnings: list[str] = []
if raw_from_doc:
from_doc_rel = _validate_relative_path(project_dir, raw_from_doc, "--from-doc")
from_doc_abs = project_dir / from_doc_rel
if not from_doc_abs.exists() or not from_doc_abs.is_file():
raise CliError("invalid_args", f"--from-doc path does not exist: {from_doc_rel}")
imported_decisions, parse_warnings = extract_settled_decisions(from_doc_abs.read_text())
No mode coupling — --from-doc is valid with --mode code or --mode doc.
After the state dict is built, unconditionally persist both keys whenever --from-doc was passed (even with zero decisions — this is the load-bearing invariant for FLAG-001):
python
if from_doc_rel is not None:
state["config"]["from_doc"] = from_doc_rel
state["meta"]["imported_decisions"] = imported_decisions
Surface parse_warnings by appending to state["meta"]["notes"] and adding a warnings field to the StepResponse at handlers.py:819-829 when the list is non-empty.
Add from megaplan.doc_assembly import extract_settled_decisions at the top of handlers.py.
In _execute_doc_prompt at megaplan/prompts/execute_doc.py:90, read state["config"].get("from_doc"). When set, render a "Prior doc context" block before the requirements block that shows the path string unconditionally (whether or not decisions were imported), e.g.:
code
Prior doc imported via --from-doc:
docs/prior-design.md
Imported decisions (from the source doc's ## Settled Decisions section): 0
Include the count even when zero, so the worker knows the doc was consulted but had no decisions.
When state["meta"].get("imported_decisions") is non-empty, extend the block to list each decision's id, decision, rationale, load_bearing.
Extend _EXECUTE_DOC_REQUIREMENTS_TEMPLATE at line 67 with a bullet: when the document contains design decisions, emit a top-level ## Settled Decisions section using the standardized format (show the exact markdown shape from Step 2, including load_bearing: true|false and the SD-NNN ID convention). Add a 1-line note: "Downstream plans can import these via megaplan init --from-doc."
Mirror the same path+count block and emission bullet in _execute_doc_batch_prompt at megaplan/prompts/execute_doc.py:219-270.
Do not touch code-mode prompts.
Step 7: Surface from_doc in the planning prompt (megaplan/prompts/planning.py) — addresses FLAG-001
Scope: Small
In _plan_prompt() at megaplan/prompts/planning.py:85-136, read state["config"].get("from_doc"). When set, inject a "Prior doc context" block that always shows the path string, plus the imported decisions list if present (empty list rendered as "No ## Settled Decisions section found — path stored for reference only").
When imported_decisions is non-empty, instruct the planner: "For each imported decision with load_bearing: true, include a success criterion with priority: 'must' referencing the SD-NNN id. For load_bearing: false, include a criterion with priority: 'info'." This is a soft hint — the harness-side merge in Step 8 is the actual guarantee.
Step 8: Enforce auto-promotion in handle_plan and handle_revise (megaplan/handlers.py) — addresses FLAG-002
Scope: Medium
Add a module-private helper _merge_imported_decision_criteria(state: PlanState, criteria: list[dict]) -> list[dict]:
Read state["meta"].get("imported_decisions", []). If empty, return criteria unchanged.
Collect the set of SD-NNN ids already referenced in any existing criterion's criterion text (substring match on id).
For each imported decision whose id is NOT already referenced, append:
python
{
"criterion": f"Plan adheres to imported decision {sd['id']}: {sd['decision']}",
"priority": "must" if sd.get("load_bearing") else "info",
"requires": ["subjective_judgment"] if sd.get("load_bearing") else [],
}
Return the merged list. Idempotent — running it twice on the same state produces the same result.
Call it in handle_plan at megaplan/handlers.py:839-852 immediately before the worker's payload["success_criteria"] is written to plan metadata:
Mirror the same call in handle_revise at megaplan/handlers.py:1104-1118.
This makes auto-promotion a repo-side guarantee, not a prompt suggestion. A worker that omits imported SD-* criteria will have them auto-appended by the harness; a worker that already includes them is preserved unchanged.
Step 9: Document in megaplan/data/instructions.md
Scope: Small
Update the "Modes" section (lines 19-27) and "Start" section (lines 29-34) to include --from-doc <relative-path> in the example invocation and document semantics (relative-to-project, file must exist, works with either mode, imports ## Settled Decisions, harness auto-promotes to must/info criteria).
Add a short "Settled Decisions section format" subsection showing the canonical markdown shape from Step 2.
Step 10: Unit-test the parser (tests/test_doc_assembly.py)
Scope: Small
Add tests covering the 5 brief-specified fixtures:
empty string → ([], [])
doc with no ## Settled Decisions section → ([], [])
doc with three well-formed decisions (mix of load_bearing) → 3 items with correct types
doc with one malformed entry (missing id) in a well-formed section → good items returned, warning surfaced
heading present but no items → ([], [])
Add one extra: load_bearing is case-insensitive and coerces to bool.
Step 11: Handler tests for --from-doc (tests/test_handle_init_doc_mode.py)
Scope: Small
Reuse _bootstrap / _args helpers at tests/test_handle_init_doc_mode.py:16,39. Extend _args with an optional from_doc kwarg.
Add tests:
test_from_doc_valid_path_populates_state — fixture doc with 2 load-bearing + 1 non-load-bearing; assert state["config"]["from_doc"] and state["meta"]["imported_decisions"].
test_from_doc_nonexistent_path_rejected — CliError("invalid_args") with --from-doc in message.
test_from_doc_absolute_path_rejected — same error class.
test_from_doc_valid_with_code_mode — confirm accepted without --output.
Step 12: Merge-helper tests (new tests/test_imported_decision_merge.py or extend tests/test_handle_plan.py if present)
Scope: Small
Unit-test _merge_imported_decision_criteria directly (import from megaplan.handlers):
No imported decisions → criteria list returned unchanged.
Two imported decisions (one load-bearing, one not), no worker criteria → merged list has 2 entries with correct priorities and requires.
Imported decision already referenced in a worker criterion (id substring present) → not duplicated.
Running the helper twice on the same input is a no-op (idempotent).
Integration test through handle_plan: bootstrap a plan with imported_decisions, monkeypatch the worker to return a payload with empty success_criteria, assert the resulting plan metadata contains a must-priority criterion referencing each load-bearing SD-NNN id.
Helper factoring (Step 3) before handler wiring (Step 5) so --output stays green.
CLI flag (Step 4) + handler wiring (Step 5) together.
Merge helper (Step 8) — implement before the planning prompt edit so the harness-side guarantee is landed first; the prompt becomes a soft hint that complements the guarantee.
Prompt edits (Steps 6, 7) and docs (Step 9) after plumbing works.
Tests (Steps 10–12) written incrementally alongside each piece.
Validation Order
Parser unit tests (cheapest, pure function).
Merge-helper unit tests (pure function, no I/O).
Handler tests (CLI + state shape + handle_plan integration).
Full pytest run for regression check on prompt/type integrations.
code
Plan metadata:
{
"version": 2,
"timestamp": "2026-04-21T10:57:37Z",
"hash": "sha256:a108c9fb9ad5cac1006a168fc84d36fa8f2f95c2b5a37c650cf15a396e3a56d5",
"changes_summary": "Addressed both significant flags. FLAG-001: Step 5 already stored config.from_doc unconditionally, but Steps 6 and 7 now explicitly surface the path string (and zero-decision status) in both the doc-mode execute prompt and the planning prompt \u2014 not gated on imported_decisions being non-empty. FLAG-002: Added new Step 8, a harness-side _merge_imported_decision_criteria helper called from handle_plan and handle_revise that guarantees every load-bearing imported decision gets a must-priority criterion and every non-load-bearing gets an info criterion in the plan metadata, idempotent and regardless of what the worker returns. Added Step 12 with merge-helper unit and integration tests. Promoted the planning-prompt criterion from should to must and added two new must criteria for the harness-side enforcement and zero-decision context propagation. Execution order updated so the merge helper lands before the prompt edits (harness guarantee precedes soft hints). Test count bumped from ~12 to ~14 new tests (\u2265701 passed expected).",
"flags_addressed": [
"FLAG-001",
"FLAG-002"
],
"questions": [
"The brief specifies a ## Settled Decisions section format but does not pin down exact markdown syntax. I've proposed - id: SD-NNN with indented key: value lines (Step 2). Is that the intended shape, or would you prefer YAML fenced-blocks, an HTML comment block, or a table?"
],
"success_criteria": [
{
"criterion": "PYENV_VERSION=3.11.11 python -m pytest tests/ passes with \u2265701 passed and 1 skipped (687 baseline + ~14 new tests; minimum floor is 690 per brief).",
"priority": "must",
"requires": [
"run_tests"
]
},
{
"criterion": "megaplan init --from-doc <valid relative path> with a doc containing 3 well-formed decisions populates state.config.from_doc to the normalized relative path and state.meta.imported_decisions to a list of 3 dicts with keys {id, decision, rationale, load_bearing}.",
"priority": "must",
"requires": [
"run_tests",
"read_files"
]
},
{
"criterion": "megaplan init --from-doc <nonexistent> raises CliError(\"invalid_args\", ...) with a message that contains --from-doc.",
"priority": "must",
"requires": [
"run_tests"
]
},
{
"criterion": "megaplan init --from-doc /absolute/path and --from-doc ../escape.md both raise CliError(\"invalid_args\", ...).",
"priority": "must",
"requires": [
"run_tests"
]
},
{
"criterion": "megaplan init --from-doc <doc with no ## Settled Decisions section> succeeds; state.config.from_doc is set; state.meta.imported_decisions == [].",
"priority": "must",
"requires": [
"run_tests"
]
},
{
"criterion": "When state.config.from_doc is set (regardless of whether imported_decisions is empty), the doc-mode execute prompt and the planning prompt both render the from_doc path string and an imported-decision count. Verifiable by asserting the prompt output strings contain the path when the state has from_doc set and imported_decisions == [].",
"priority": "must",
"requires": [
"run_tests",
"read_files"
]
},
{
"criterion": "After handle_plan runs with state.meta.imported_decisions containing one load-bearing and one non-load-bearing decision, the resulting plan metadata's success_criteria contains a must-priority criterion referencing the load-bearing SD id and an info-priority criterion referencing the non-load-bearing SD id \u2014 even when the worker returns an empty success_criteria list. Same guarantee for handle_revise.",
"priority": "must",
"requires": [
"run_tests",
"read_files"
]
},
{
"criterion": "_merge_imported_decision_criteria is idempotent: running it twice on the same state produces the same output, and worker-produced criteria that already reference an SD-NNN id are not duplicated.",
"priority": "must",
"requires": [
"run_tests"
]
},
{
"criterion": "extract_settled_decisions is a pure function in megaplan/doc_assembly.py (no filesystem or state access); its 5+ unit tests pass.",
"priority": "must",
"requires": [
"run_tests",
"read_files"
]
},
{
"criterion": "SettledDecisionFromDoc is a distinct TypedDict in megaplan/types.py, not a subclass or alias of the existing SettledDecision.",
"priority": "must",
"requires": [
"read_files"
]
},
{
"criterion": "A single _validate_relative_path helper in megaplan/handlers.py is used by both --output and --from-doc validation (no duplicated absolute/../out-of-project checks).",
"priority": "must",
"requires": [
"read_files",
"parse_diff"
]
},
{
"criterion": "Doc-mode execute prompt (megaplan/prompts/execute_doc.py) instructs the worker to emit a ## Settled Decisions section in the standardized format when decisions are produced.",
"priority": "must",
"requires": [
"read_files"
]
},
{
"criterion": "Planning prompt (megaplan/prompts/planning.py) surfaces state.meta.imported_decisions as a "Prior doc context" block and instructs the planner to emit must/info criteria referencing SD-NNN ids. (Soft hint complementing the harness-side merge in Step 8.)",
"priority": "must",
"requires": [
"read_files"
]
},
{
"criterion": "megaplan/data/instructions.md documents --from-doc and shows the canonical ## Settled Decisions section format.",
"priority": "must",
"requires": [
"read_files"
]
},
{
"criterion": "No out-of-scope work: no critique-level SD citation check, no sidecar settled_decisions.json writer, no verify-against-doc subcommand.",
"priority": "must",
"requires": [
"parse_diff",
"read_files"
]
},
{
"criterion": "Parse warnings from malformed entries are surfaced to the user either in the StepResponse returned by handle_init or via state.meta.notes.",
"priority": "should",
"requires": [
"read_files",
"run_tests"
]
},
{
"criterion": "Each function added or modified keeps a single responsibility; no change exceeds ~60 lines of net new code per step (Step 8's merge helper + handle_plan/revise wiring is the largest).",
"priority": "should",
"requires": [
"parse_diff"
]
}
],
"assumptions": [
"Standard section format uses markdown list items with - id: SD-NNN followed by indented load_bearing: / decision: / rationale: lines. Parser returns a (decisions, warnings) tuple so the handler can surface tolerant-parse warnings without silently dropping data.",
"--from-doc does not require the target path to itself be a megaplan-produced artifact \u2014 any text file with a parseable section works. Path validity is enforced (exists, is a file, relative to project_dir), but content is handled tolerantly.",
"PlanState/PlanMeta TypedDicts are structurally typed with total=False (or similar), so adding optional imported_decisions and from_doc keys won't require invasive type changes elsewhere. If they are total=True, Step 1 broadens slightly.",
"The existing --output error messages are assumed to be unchanged after factoring into _validate_relative_path \u2014 only the message prefix varies by flag name. This preserves existing tests at tests/test_handle_init_doc_mode.py:64-85.",
"Harness-side auto-promotion uses substring match on SD-NNN ids to detect existing references in worker-produced criteria. This is tolerant (worker can phrase the criterion text freely) but relies on the id string appearing verbatim. If a worker rephrases the id (e.g. 'decision 001' instead of 'SD-001'), the helper will append a duplicate \u2014 acceptable trade-off for simplicity; tests cover both the reference-found and no-reference paths.",
"Generated auto-promoted criteria use requires: ['subjective_judgment'] for must-priority and requires: [] for info-priority. This matches the template guidance (must must have non-empty requires; info may be empty) and is appropriate because 'plan adheres to decision X' is inherently judgmental."
],
"delta_from_previous_percent": 27.4,
"structure_warnings": []
}
code
Gate summary:
{
"recommendation": "ITERATE",
"rationale": "Light robustness: single revision pass to incorporate critique feedback.",
"signals_assessment": "",
"warnings": [],
"settled_decisions": []
}
code
Flag registry:
[
{
"id": "FLAG-001",
"concern": "from-doc context propagation: the plan stores state.config.from_doc, but it only proposes surfacing imported decisions when state[\"meta\"].get(\"imported_decisions\") is non-empty. For the explicitly supported case where the source doc has no ## Settled Decisions section, the path would be persisted yet never shown to the planner/worker, so the brief's requirement to keep the doc path as worker context is still unmet.",
"evidence": "Addressed both significant flags. FLAG-001: Step 5 already stored config.from_doc unconditionally, but Steps 6 and 7 now explicitly surface the path string (and zero-decision status) in both the doc-mode execute prompt and the planning prompt \u2014 not gated on imported_decisions being non-empty. FLAG-002: Added new Step 8, a harness-side _merge_imported_decision_criteria helper called from handle_plan and handle_revise that guarantees every load-bearing imported decision gets a must-priority criterion and every non-load-bearing gets an info criterion in the plan metadata, idempotent and regardless of what the worker returns. Added Step 12 with merge-helper unit and integration tests. Promoted the planning-prompt criterion from should to must and added two new must criteria for the harness-side enforcement and zero-decision context propagation. Execution order updated so the merge helper lands before the prompt edits (harness guarantee precedes soft hints). Test count bumped from ~12 to ~14 new tests (\u2265701 passed expected).",
"status": "addressed",
"severity": "significant"
},
{
"id": "FLAG-002",
"concern": "success-criteria enforcement: the plan's Step 7 makes imported decisions become must/info criteria by prompt instruction alone, but the repository has no harness-side enforcement here. Without post-processing or validation in the plan/revise handlers, load-bearing decisions are not actually auto-promoted; they are only suggested to the model.",
"evidence": "Addressed both significant flags. FLAG-001: Step 5 already stored config.from_doc unconditionally, but Steps 6 and 7 now explicitly surface the path string (and zero-decision status) in both the doc-mode execute prompt and the planning prompt \u2014 not gated on imported_decisions being non-empty. FLAG-002: Added new Step 8, a harness-side _merge_imported_decision_criteria helper called from handle_plan and handle_revise that guarantees every load-bearing imported decision gets a must-priority criterion and every non-load-bearing gets an info criterion in the plan metadata, idempotent and regardless of what the worker returns. Added Step 12 with merge-helper unit and integration tests. Promoted the planning-prompt criterion from should to must and added two new must criteria for the harness-side enforcement and zero-decision context propagation. Execution order updated so the merge helper lands before the prompt edits (harness guarantee precedes soft hints). Test count bumped from ~12 to ~14 new tests (\u2265701 passed expected).",
"status": "addressed",
"severity": "significant"
}
]
"[DEBT] are-the-proposed-changes-technically-correct: are the proposed changes technically correct?: the mobile action-surface plan is technically incorrect for the current component structure. submissioncarouselcard hides footercontent below the md breakpoint (src/components/submissioncarouselcard.tsx:219), while submissionscarouselpage also hides the score panel on mobile via asidecontent={<div classname=\"hidden md:block\">... and passes hideactions to scorepanel at src/pages/submissionscarouselpage.tsx:250-263,347. reusing that pattern for entrypage would leave mobile users with no navigation controls and no scoring controls. (flagged 1 times across 1 plans)",
"[DEBT] are-the-proposed-changes-technically-correct: are the proposed changes technically correct?: i checked the sign-in callback path again. submissionslayout already wires usescoring(..., { onrequiresignin: () => pagemachine.dispatch({ type: 'open_sign_in_modal' }) }) at src/pages/submissionslayout.tsx:38-40, and scorepanel still has its own onrequiresignin prop. the revised step 4.2 is acceptable only if it explicitly rewires that prop to pagemachine.dispatch; otherwise removing local modal state would orphan the direct ui callback. the plan hints at this, but it remains easy to misread because the scoring-context callback and the scorepanel prop are separate mechanisms. (flagged 1 times across 1 plans)",
"[DEBT] are-the-proposed-changes-technically-correct: are the proposed changes technically correct?: checked the new diff-helper proposal against the repo's existing execution-evidence semantics. validate_execution_evidence() in megaplan/evaluation.py:109-175 uses git status --short, so untracked files count as real changed files today, but step 3 proposes collect_git_diff_patch(project_dir) via git diff head; by git behavior that will not include untracked files, so heavy review could miss exactly the newly created files that execute and review already treat as part of the patch. (flagged 1 times across 1 plans)",
"[DEBT] are-the-proposed-changes-technically-correct: are the proposed changes technically correct?: a generated-schema gap remains. tests/test_schemas.py reads the repo-root .megaplan/schemas/review.json directly via _review_disk_schema(), the checked-in local file is currently stale relative to schemas, and ensure_runtime_layout() in megaplan/_core/io.py is the production writer for that file class. the plan says generated schemas must stay aligned, but it never names a regeneration step or a test adjustment for that disk-schema path, so the validation story is still incomplete. (flagged 1 times across 1 plans)",
"[DEBT] are-the-proposed-changes-technically-correct: are the proposed changes technically correct?: the new pre-extraction step that migrates pinnedshotgroups out of core is still under-specified for compatibility. current runtime and test code reads config.pinnedshotgroups directly across hooks/usetimelinecommit.ts, lib/pinned-group-projection.ts, hooks/useshotgroups.ts, components/timelineeditor/timelineeditor.tsx, hooks/usetimelinetrackmanagement.ts, lib/serialize.test.ts, lib/migrate.test.ts, and many other tests, so landing that migration before extraction needs a dual-read/projection shim or a clearly synchronized update plan instead of only a schema/serializer note. (flagged 1 times across 1 plans)",
"[DEBT] are-the-proposed-changes-technically-correct: are the proposed changes technically correct?: runner inputs: the revised auto-mode snippet calls $(cat ${idea_file}) and the chain-mode path runs mp-chain ${chain_spec}, but step 7's deploy flow still only does railway link, railway variables --set, and railway up. there is no corresponding step that copies the idea file or chain spec into /workspace, so a literal implementation would boot into auto/chain mode and immediately fail on missing input files. (flagged 1 times across 1 plans)",
"[DEBT] are-the-success-criteria-well-prioritized-and-verifiable: are the success criteria well-prioritized and verifiable?: mobile behavior is still under-prioritized relative to the actual risk in this repo. the user constraint specifically mentions the mobile bottom nav, but the only mobile-specific success criterion left is 'mobile scoring ux is coherent' at info level. given that the plan currently removes the working mobile nav, there should be at least a should or must criterion stating that mobile users retain navigation and scoring controls. (flagged 1 times across 1 plans)",
"[DEBT] completeness: handle_init() and override flows also emit next_step but aren't listed for next_step_runtime enrichment. (flagged 1 times across 1 plans)",
"[DEBT] completeness: handle_execute() at handlers.py:1152-1175 can clear next_step to none but leave stale next_step_runtime. (flagged 1 times across 1 plans)",
"[DEBT] completeness: next_step_runtime fires on previous step completion, not literally when the next phase starts. (flagged 1 times across 1 plans)",
"[DEBT] completeness: test_command config override unreachable via normal init/cli flow (flagged 1 times across 1 plans)",
"[DEBT] correctness: status-progress gating excludes finalized plans with finalize.json in between-batch and blocked states. (flagged 1 times across 1 plans)",
"[DEBT] correctness: resolve_phase_runtime called on non-phase next_step values would fail. (flagged 1 times across 1 plans)",
"[DEBT] correctness: non-phase next_step values from workflow_next() not filtered. (flagged 1 times across 1 plans)",
"[DEBT] correctness: baseline_test_command schema says string-only but fallback returns none (flagged 1 times across 1 plans)",
"[DEBT] correctness: fallback uses null+baseline_test_note instead of brief's empty-array+meta_commentary (flagged 1 times across 1 plans)",
"[DEBT] correctness: pinnedshotgroups migration lacks a specified compatibility phase for in-tree callers (flagged 1 times across 1 plans)",
"[DEBT] criteria-prompt: criteria prompt: v3 replaces _review_prompt() in heavy mode with a new heavy_criteria_review_prompt, so the plan no longer follows the brief's explicit requirement that _review_prompt() remain the heavy-mode criteria_verdict check. (flagged 1 times across 1 plans)",
"[DEBT] did-the-work-fully-address-the-issue-hints-user-notes-and-approved-plan-requirements: did the work fully address the issue hints, user notes, and approved plan requirements?: a new critical issue is introduced on mobile. step 4.9 says to remove entrypage's mobile sticky bottom nav and 'use the same footercontent slot in submissioncarouselcard', but src/components/submissioncarouselcard.tsx:217-221 renders footercontent inside classname=\"hidden md:block\". in the current repo, the mobile sticky nav at src/pages/entrypage.tsx:283-340 is the only mobile surface for back/next and the score toggle, so the revised plan would remove working mobile controls and replace them with a slot that is explicitly hidden on phones. (flagged 1 times across 1 plans)",
"[DEBT] did-the-work-fully-address-the-issue-hints-user-notes-and-approved-plan-requirements: did the work fully address the issue hints, user notes, and approved plan requirements?: the plan still contradicts itself on mobile behavior. assumption #3 says the browse-mode mobile score toggle will be preserved, but step 4.9 removes the entire mobile sticky nav that contains that toggle in src/pages/entrypage.tsx:314-330. the implementer cannot satisfy both instructions as written. (flagged 1 times across 1 plans)",
"[DEBT] did-the-work-fully-address-the-issue-hints-user-notes-and-approved-plan-requirements: did the work fully address the issue hints, user notes, and approved plan requirements?: checked step 7 against the brief's explicit prompt-builder requirement. the revision fixes the old context leak by introducing a brand-new heavy_criteria_review_prompt, but the brief said _review_prompt() should stay as-is and still run as the criteria_verdict check in heavy mode; v3 solves the problem by replacing that heavy-mode criteria path instead of reusing the baseline review prompt, which is still a material divergence from the requested design. (flagged 1 times across 1 plans)",
"[DEBT] did-the-work-fully-address-the-issue-hints-user-notes-and-approved-plan-requirements: did the work fully address the issue hints, user notes, and approved plan requirements?: issue hints: the plan now wires mode=auto|chain|idle, but the user-requested auto.idea_file and chain.spec still have no deployment path into the container. reigh's readme uploads the idea file explicitly before running megaplan init, and chain.sh exits if /workspace/chain.yaml is missing, so a plan that only sets these paths in cloud.yaml without also staging the files still leaves the requested runner modes incomplete. (flagged 1 times across 1 plans)",
"[DEBT] diff-capture: diff capture: the proposed collect_git_diff_patch(project_dir) helper uses git diff head, which will miss untracked files even though the existing execution-evidence path already treats untracked files as real changed work. (flagged 1 times across 1 plans)",
"[DEBT] does-the-change-touch-all-locations-and-supporting-infrastructure: does the change touch all locations and supporting infrastructure?: if the implementation really wants footercontent to carry mobile actions, the plan must also include a supporting change in src/components/submissioncarouselcard.tsx or render a separate mobile control surface outside the card. right now step 4.9 removes the mobile nav but does not list submissioncarouselcard.tsx:217-221 as a place that must change, so the required glue for mobile controls is missing. (flagged 1 times across 1 plans)",
"[DEBT] does-the-change-touch-all-locations-and-supporting-infrastructure: does the change touch all locations and supporting infrastructure?: the prior missing locations in megaplan/workers.py and tests/test_workers.py are now covered, but one supporting-infrastructure path is still absent from the steps: the repo-root generated schema copy under .megaplan/schemas/review.json and the tests that read it directly. without either explicitly regenerating that file or changing those tests to materialize schemas in a temp root, the plan can still leave the runtime-schema copy out of sync with the raw registry. (flagged 1 times across 1 plans)",
"[DEBT] does-the-change-touch-all-locations-and-supporting-infrastructure: does the change touch all locations and supporting infrastructure?: the plan adds _set_active_step and _clear_active_step helpers to handlers.py. _run_worker (handlers.py:135) is modified to accept a resolved parameter. but _run_worker is also called directly by handle_critique's sequential fallback at line 801 and 803. these calls currently don't pass resolved. the plan's step 2.6 for handle_critique says to set active_step after resolution at line 794 \u2014 but the _run_worker calls at 801/803 would re-resolve the agent internally (since resolved isn't passed). this means the agent is resolved twice on the critique sequential path. the double-resolution is wasteful but correct (same result). however, to match the plan's goal of 'resolve_agent_mode() is called once per handler invocation', the resolved tuple should be passed to these _run_worker calls too. (flagged 1 times across 1 plans)",
"[DEBT] does-the-change-touch-all-locations-and-supporting-infrastructure: does the change touch all locations and supporting infrastructure?: supporting infrastructure is still missing for mode inputs. step 3 ports chain.yaml.example into package templates, but step 5's materialize_deploy_dir() layout does not include it, step 7 deploy does not upload it or auto.idea_file, and the docs/validation steps do not mention any artifact-sync path before boot. that leaves the runner depending on files that the deployment plan never places on the container volume. (flagged 1 times across 1 plans)",
"[DEBT] execute-phase-contract: early-killed baselines pass truncated output to the execute worker, which may produce lower-quality diagnosis than full output. (flagged 1 times across 1 plans)",
"[DEBT] find-the-callers-of-the-changed-function-what-arguments-do-they-actually-pass-does-the-fix-handle-all-of-them: find the callers of the changed function. what arguments do they actually pass? does the fix handle all of them?: i checked the skip caller path against the real hook behavior and removefromqueue(entryid) looks redundant. scoring.skipentry(entryid) optimistically adds the id to skippedentryids in src/hooks/usescoring.ts:245-249, and usecarouselqueue already reactively filters skipped entries from submissions[] in src/hooks/usecarouselqueue.ts:154-165. calling removefromqueue() immediately afterward is safe, but it duplicates an existing state transition and should be justified as an explicit ux optimization rather than required logic. (flagged 1 times across 1 plans)",
"[DEBT] find-the-callers-of-the-changed-function-what-arguments-do-they-actually-pass-does-the-fix-handle-all-of-them: find the callers of the changed function. what arguments do they actually pass? does the fix handle all of them?: the direct ui sign-in caller is still important here. scorepanel invokes its own onrequiresignin prop when an unauthenticated user interacts with the score ui (src/components/scorepanel.tsx:499-515), which is independent of the scoring hook's internal requireauth() path. the plan should be read as requiring that caller to dispatch open_sign_in_modal; otherwise one caller remains broken even if submitscore() is correctly wired. (flagged 1 times across 1 plans)",
"[DEBT] find-the-callers-of-the-changed-function-what-arguments-do-they-actually-pass-does-the-fix-handle-all-of-them: find the callers of the changed function. what arguments do they actually pass? does the fix handle all of them?: i rechecked the caller paths after the revision. the raw-schema caller path through validate_payload() is now accounted for, but the runtime-schema caller path still is not: strict_schema() only reaches the on-disk runtime schemas through ensure_runtime_layout(), while current tests like tests/test_schemas.py and tests/test_parallel_review.py consume the already-written repo copy directly. the plan does not yet say how that caller path gets refreshed or asserted after the code change. (flagged 1 times across 1 plans)",
"[DEBT] find-the-callers-of-the-changed-function-what-arguments-do-they-actually-pass-does-the-fix-handle-all-of-them: find the callers of the changed function. what arguments do they actually pass? does the fix handle all of them?: the real callers for these paths are shell commands that expect actual files. reigh's readme uploads an idea file into /workspace/megaplan-idea-2week.txt before calling megaplan init, and chain.sh immediately checks -f \"$spec\" before running megaplan chain --spec \"$spec\". the revised plan now constructs equivalent callers from auto.idea_file and chain.spec, but still never adds the corresponding file-transfer or materialization step, so those callers would receive nonexistent arguments. (flagged 1 times across 1 plans)",
"[DEBT] handler-boilerplate: _run_worker() pseudocode hardcodes iteration=state['iteration'] but handle_plan and handle_revise use different failure iteration values. (flagged 1 times across 1 plans)",
"[DEBT] handler-boilerplate: same issue as correctness-1: failure iteration would be wrong for plan/revise handlers. (flagged 1 times across 1 plans)",
"[DEBT] install-paths: local setup path doesn't expose subagent mode (flagged 1 times across 1 plans)",
"[DEBT] install-paths: no automated guard to keep the mirror file synchronized with source files (flagged 1 times across 1 plans)",
"[DEBT] install-paths: local setup test only checks agents.md existence, not content (flagged 1 times across 1 plans)",
"[DEBT] is-there-convincing-verification-for-the-change: is there convincing verification for the change?: the test-plan details still miss a small but real infrastructure update: the current locationdisplay helper in src/pages/submissionscarouselpage.test.tsx:289-291 only renders location.pathname, so the step 7 requirement to assert { state: { carousel: true, navdirection: 'forward' } } cannot be implemented unless that helper is extended to expose location.state. the same pattern exists in the related page tests. (flagged 1 times across 1 plans)",
"[DEBT] is-there-convincing-verification-for-the-change: is there convincing verification for the change?: there is still no explicit mobile regression test in the plan, even though the revised implementation proposal removes the only current mobile nav/score surface. given the repository's actual component structure, a mobile-focused test or visual verification step is needed to prove controls remain accessible below md. (flagged 1 times across 1 plans)",
"[DEBT] mobile-ui: mobile ui: removing entrypage's mobile sticky nav and relying on submissioncarouselcard.footercontent would break mobile navigation and scoring because that footer slot is hidden below the md breakpoint. (flagged 1 times across 1 plans)",
"[DEBT] runner-inputs: runner inputs: auto and chain modes still assume auto.idea_file and chain.spec already exist on the container volume, but the deploy plan does not upload or materialize those files anywhere. (flagged 1 times across 1 plans)",
"[DEBT] runtime-schema-sync: runtime schema sync: the plan still does not include an explicit refresh or validation step for the generated .megaplan/schemas/review.json copy that repository tests read directly. (flagged 1 times across 1 plans)",
"[DEBT] search-for-related-code-that-handles-the-same-concept-is-the-reported-issue-a-symptom-of-something-broader: search for related code that handles the same concept. is the reported issue a symptom of something broader?: the mobile problem is broader than entrypage. submissionscarouselpage already has a pre-existing mobile gap because its score panel is desktop-only and its footer actions are also hidden on mobile (src/pages/submissionscarouselpage.tsx:250-263,347-354 plus src/components/submissioncarouselcard.tsx:219). the revised plan says entrypage should 'match the carouselpage pattern', which would spread that existing gap into the one page that currently has working mobile controls. (flagged 1 times across 1 plans)",
"[DEBT] search-for-related-code-that-handles-the-same-concept-is-the-reported-issue-a-symptom-of-something-broader: search for related code that handles the same concept. is the reported issue a symptom of something broader?: the revised plan correctly narrows the schema-shape problem itself back to the six audited mismatches, but the generated runtime-schema consumer path is broader than the plan acknowledges: tests/test_parallel_review.py also reads the runtime review.json schema from schemas_root(repo_root), so stale generated schema copies can affect more than the direct schema tests. (flagged 1 times across 1 plans)",
"[DEBT] search-for-related-code-that-handles-the-same-concept-is-the-reported-issue-a-symptom-of-something-broader: search for related code that handles the same concept. is the reported issue a symptom of something broader?: input provisioning is the broader unresolved concept here. the repo's current railway workflow does not just run commands; it also stages runtime artifacts into /workspace first, such as the uploaded idea text in readme line 103 and the expected /workspace/chain.yaml consumed by chain.sh. the revised plan fixes the runner dispatch itself, but it still treats auto.idea_file and chain.spec as if those files will already exist without describing how cloud deploy makes that true. (flagged 1 times across 1 plans)",
"[DEBT] subagent-safeguards: hermes reference safeguard numbers not validated against actual implementation (flagged 1 times across 1 plans)",
"[DEBT] subagent-safeguards: plan's retry caps (1 phase, 3 execute) may differ from hermes-agent's actual policy (flagged 1 times across 1 plans)",
"[DEBT] worker-permissions: codex --full-auto flag only triggers for step == 'execute', not 'loop_execute' (flagged 1 times across 1 plans)",
"[DEBT] worker-permissions: claude --permission-mode bypasspermissions only triggers for step == 'execute', not 'loop_execute' (flagged 1 times across 1 plans)",
"[DEBT] workflow-state-machine: _plan_prompt() does not read research.json, so replanning from state_researched would ignore research results. (flagged 1 times across 1 plans)",
"[DEBT] workflow-state-machine: same issue as correctness-2: state_researched \u2192 plan path is only partially wired. (flagged 1 times across 1 plans)",
"[DEBT] workflow-state-machine: _plan_prompt() is a missed location for the state_researched \u2192 plan change. (flagged 1 times across 1 plans)"
]
code
Requirements:
- Produce structured JSON only.
- `tasks` must be an ordered array of task objects. Every task object must include:
- `id`: short stable task ID like `T1`
- `description`: concrete work item
- `depends_on`: array of earlier task IDs or `[]`
- `status`: always `"pending"` at finalize time
- `executor_notes`: always `""` at finalize time
- `reviewer_verdict`: always `""` at finalize time
- `watch_items` must be an array of strings covering runtime risks, critique concerns, and assumptions to keep visible during execution.
- `sense_checks` must be an array with one verification question per task. Every sense-check object must include:
- `id`: short stable ID like `SC1`
- `task_id`: the related task ID
- `question`: reviewer verification question
- `verdict`: always `""` at finalize time
- `meta_commentary` must be a single string with execution guidance, gotchas, or judgment calls that help the executor succeed.
- `validation` must be an object that self-checks plan coverage:
- `plan_steps_covered`: enumerate EVERY step from the approved plan. For each step, provide a short `plan_step_summary` (the step's intent in one phrase) and `finalize_task_ids` (array of task IDs that implement it — a single plan step may map to multiple tasks).
- `orphan_tasks`: task IDs that do not correspond to any plan step. Normally empty. If non-empty, explain in `completeness_notes`.
- `completeness_notes`: free-text explanation of any gaps, deviations, or deliberate omissions.
- `coverage_complete`: set to `true` only if every plan step has at least one finalize task AND you have verified the mapping by reviewing each entry. Set to `false` if any plan step is missing coverage.
- Example:
```json
"validation": {
"plan_steps_covered": [
{"plan_step_summary": "Add retry logic to API client", "finalize_task_ids": ["T1", "T2"]},
{"plan_step_summary": "Update configuration schema", "finalize_task_ids": ["T3"]}
],
"orphan_tasks": [],
"completeness_notes": "All plan steps mapped to tasks.",
"coverage_complete": true
}
```
- Preserve information that strong existing artifacts already capture well: execution ordering, watch-outs, reviewer checkpoints, and practical context.
- The structured output should be self-contained: an executor reading only `finalize.json` should have everything needed to work.
- Keep the task count proportional to the work. A simple 1-2 file fix should be 2 tasks: (1) apply the fix, (2) run tests. Do NOT create separate "inspect" or "read" tasks for simple changes — the executor can read and fix in one step. Only create more tasks when the work has genuinely independent stages.
- - The FINAL task MUST always be to run tests and verify the changes work. If specific test IDs or commands are mentioned in the original task, include them. Otherwise, the executor should find and run the tests most relevant to the files changed. If any test fails, read the error, fix the code, and re-run until they pass. Do NOT create new test files — run the project's existing test suite. Additionally, the executor should write a short throwaway script that reproduces the specific bug described in the task, run it to confirm the fix works, then delete the script.