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 an independent reviewer. Critique the plan against the actual repository.
Execute Sprint 4 of the Wan2GP fork migration per docs/WAN2GP_FORK_MIGRATION_PLAN.md (Sprint 4 section L163-187 is authoritative — read it first). Deliverables: (1) extend source/models/wgp/wgp_patches.py using existing runtime-patch primitives (_register_patch_application, begin_runtime_model_patch, rollback_runtime_model_patch), (2) draft upstream PR bodies for bucket (b) items into scripts/sprint4/upstream_prs/ — do NOT actually open PRs (orchestrator handles), (3) land .github/workflows/wan2gp-drift.yml per SD-008, (4) publish docs/wan2gp-rebase-runbook.md per SD-007. Run all Sprint 4 verification gates listed in the plan. Baseline tag wan2gp-mig-sprint-4-baseline already exists on reigh-worker. Sandbox rules learned from Sprints 1-3: executor cannot write .git/ or push to remotes — orchestrator handles those. uv sync fails on darwin-arm64 (decord==0.6.0 wheel gap) — build/reuse a minimal smoke venv. Do NOT commit final reigh-worker work — leave changes staged for user review.
Sprint 4 closes out the migration by (a) consolidating runtime fork behavior into a single wgp_patches.py registry so get_wgp_patch_state() is the one place to see what the fork mutates, (b) drafting upstream PR bodies for the 118 bucket-(b) rows in docs/wan2gp-triage.csv grouped by theme (~13 PRs), (c) landing a weekly drift-detection workflow per SD-008, and (d) publishing the rebase runbook per SD-007.
Key repo shape:
source/models/wgp/wgp_patches.py already has _register_patch_application, get_wgp_patch_state, clear_wgp_patch_context, rollback_wgp_patches, and a context-scoped registry (_PATCH_CONTEXT_STATE, _PATCH_CONTEXT_ROLLBACKS). Today it wraps seven module-level patches.
Assistant
User
Assistant
Updated critique_output.json.
Verified resolved: FLAG-001, FLAG-002, FLAG-003.
New concerns:
FLAG-004: the revised runtime-patch idempotency guard trusts registry state only and does not verify the live model_def still carries the requested patch values.
FLAG-005: the strict path-contract smoke is still specified with bare python, but this workspace’s default python is 3.8.10; that interpreter already fails importing the repo’s 3.10-only code, so the gate needs a pinned 3.10 interpreter.
The JSON was validated successfully.
User
Assistant
Reviewing the iteration-3 plan against the repo and the prior critique template first, then I’ll verify whether the claimed fixes actually close the open flags or introduce new ones.
Assistant
I’ve moved past the template diff and I’m checking the actual runtime-patch mechanics now: the transaction touches both runtime.models_def and the active loaded model, so I’m verifying whether the revised guard and tests cover both live targets or only one.
Assistant
There’s a more interesting edge now: context_id only scopes the registry, but runtime-model patches mutate a single global WGP runtime. I’m checking whether the revised context tests actually validate per-context behavior or just registry bookkeeping.
Assistant
I’ve got two concrete runtime-state problems to record now: the new guard only watches models_def even though the primitive also patches the active loaded model, and the added context_id coverage still treats registry scoping as if it were runtime scoping on a global singleton. I’m writing those into the critique file now.
Assistant
Updated critique_output.json and validated the JSON.
FLAG-006: the revised live-state guard checks only runtime.models_def, but the underlying runtime patch transaction also mutates the active loaded model at runtime.wan_model.model_def.
FLAG-007: context_id scopes only registry bookkeeping, not the shared WGP runtime, so the new cross-context test can pass while rollback semantics across contexts remain incorrect.
Those are both grounded in the current repo mechanics in runtime_registry.py and wgp_patches.py.
User
Assistant
Reviewing the last open edge now is the YAML validation path. The runtime-patch design looks materially tighter, so I’m checking whether the fallback they chose is still a real validation step in this repo environment or just a token-presence heuristic.
Assistant
The last concrete gap is the YAML-check bootstrap path: this repo’s smoke venv has Python 3.10 but no pip binary and no pip module, so the plan’s primary pip install pyyaml step can’t run as written. I’m recording that and marking the other previously open runtime-state concerns as resolved.
Assistant
Updated critique_output.json and validated the JSON.
Verified resolved: FLAG-001 through FLAG-007.
New issue:
FLAG-008: the plan’s primary YAML-validation path assumes .venv/bin/pip exists, but this repo’s smoke venv has no pip binary and no pip module, so Step 5.3 cannot run as written.
source/runtime/wgp_ports/runtime_registry.py:201-222 defines begin_runtime_model_patch / apply_runtime_model_patch / rollback_runtime_model_patch. They mutate runtime.models_def[name] + wan_model.model_def via a _RuntimePatchTransaction snapshot, but no production code calls them — they are the "split runtime patch state" Sprint 4 must fold in.
Baseline tag wan2gp-mig-sprint-4-baseline already exists.
Executor constraints (learned from Sprints 1-3):
Cannot write .git/ or push remotes — orchestrator opens PRs and manages baseline tags.
uv sync fails on darwin-arm64 (decord wheel gap). source.media.structure.{loading,frame_ops,download} import decord lazily, so the 8-file regression suite runs on a minimal smoke venv as long as no test exercises those lazy paths.
Real WanOrchestrator bootstrap imports Wan2GP/wgp.py which eagerly imports decord, so the end-to-end patch-lifecycle smoke is orchestrator-side only; executor ships a stub-form pytest proof.
Do not commit. Stage everything for user review.
Main Phase
Step 1: Audit the existing patch registry and runtime primitives (source/models/wgp/wgp_patches.py, source/runtime/wgp_ports/runtime_registry.py)
Scope: Small
Readwgp_patches.py:27-114 (registry + rollback primitives) and wgp_patches.py:536-580 (apply_all_wgp_patches) to confirm the registration shape and context-id contract.
Readruntime_registry.py:184-222 (_RuntimePatchTransaction, begin_runtime_model_patch, apply_runtime_model_patch, rollback_runtime_model_patch) and wgp_bridge.py:19-21,94-126 to confirm the primitives are already re-exported via the bridge.
Confirm no production caller exists today (only tests/test_runtime_model_patch_contracts.py) — this is the split registry Sprint 4 folds in.
Step 2: Extend wgp_patches.py with a runtime-model-patch wrapper (source/models/wgp/wgp_patches.py)
Scope: Medium
Add imports for begin_runtime_model_patch, apply_runtime_model_patch, rollback_runtime_model_patch from source.runtime.wgp_bridge.
Implementapply_runtime_model_definition_patch(model_name, patch_values, *, patch_name, context_id=None) next to _register_patch_application:
Register in the single registry via _register_patch_application(patch_name, target_key=f"model_def:{model_name}", applied=True, context_id=context_id, rollback=lambda: _rollback_runtime_model_definition(transaction, len(patch_values))) where the inner function wraps rollback_runtime_model_patch(transaction) and returns an int counter consistent with existing rollbacks.
Return True.
Do not wire a concrete per-model override (e.g., svi2pro, res_2s flag) into apply_all_wgp_patches this sprint — scope is to expose the primitive in the single registry. Q1 covers whether a concrete consumer should be added.
Preserve the existing apply_all_wgp_patches return-shape and summary logging; no new entry appended.
Step 3: Prove the single-registry invariant (tests/test_wgp_patch_lifecycle.py)
Build a _FakeRuntime-style stub matching tests/test_runtime_model_patch_contracts.py and monkeypatch runtime_registry.get_wgp_runtime_module to return it.
Call the new wrapper with patch_name="ltx2_runtime_override_smoke", model_name="ltx2_22B", patch_values={"svi2pro": True}.
Assert runtime.models_def["ltx2_22B"]["svi2pro"] is True.
Assert wgp_patches.get_wgp_patch_state()["ltx2_runtime_override_smoke"]["model_def:ltx2_22B"]["applied"] is True.
Call rollback_wgp_patches(patch_name="ltx2_runtime_override_smoke") and assert the key is gone from both models_def and the registry.
Do not introduce a parallel test file — keep all patch-state contracts co-located.
Createscripts/sprint4/upstream_prs/ with a README.md stating drafts only, listing theme → row mapping, and noting that the orchestrator actually opens PRs.
Write one markdown body per theme (≈13 files), named NN-<theme-slug>.md, sections: Title, Summary, Affected files (grep-derived), Manual diff review pointer to the CSV's manual diff review before resync entry, Test plan ("uv run --python 3.10 pytest + upstream smoke; maintainer-directed").
Fetch upstream deepbeepmeep/Wan2GP default-branch SHA via gh api or git ls-remote.
Compare against git -C Wan2GP rev-parse HEAD.
Compute commits-behind via git -C Wan2GP rev-list --count $PINNED..$UPSTREAM after adding upstream remote.
Report via $GITHUB_STEP_SUMMARY; per SD-008 "reports drift for review", do not fail the job on drift (only on command failure). Q2 covers fail-vs-report.
Dry-run the diff snippet locally against the current submodule pointer; verify pointer matches LOCAL_SHA=181bb71a21008032e4771e11663f33e4489c4512 from scripts/sprint3/_handoff/orchestrator_handoff_note_2.txt.
Validate yaml syntax with a lightweight yaml.safe_load check.
Step 6: Publish the rebase runbook per SD-007 (docs/wan2gp-rebase-runbook.md)
Scope: Small
Createdocs/wan2gp-rebase-runbook.md with: Cadence (monthly + event triggers), Pre-flight (baseline tag, green suite), Fork rebase procedure in banodoco/Wan2GP, Submodule bump in reigh-worker, Post-bump verification (8-file suite + strict path smoke + patch-lifecycle smoke), Rollback (orchestrator-only, with executor limitation called out), Drift CI interpretation.
Cross-link to docs/wan2gp-triage.csv and scripts/sprint4/upstream_prs/.
Patch-lifecycle smoke (orchestrator, full bootstrap form): ship scripts/sprint4/patch_lifecycle_smoke.py that drives WanOrchestrator to the apply_all_wgp_patches line and prints get_wgp_patch_state() as JSON. Document as linux-only in the runbook.
Drift CI once-through: orchestrator triggers via workflow_dispatch after merge; executor cannot.
Strict path-contract smoke: re-run the Sprint 2 one-liner from Section 4 of the migration plan.
Doc cross-reference: verify runbook references resolve to existing files.
Leave staged: git add the new/changed files; do NOT commit. Hand a staged-file list to the user.
Yaml-load check for the drift workflow; dry-run the drift diff logic locally.
Visual review of the four drafted deliverables + staged diff hand-off.
code
Plan metadata:
{
"version": 1,
"timestamp": "2026-04-22T01:54:32Z",
"hash": "sha256:24dee72b9c33c405c5b723c04d9d1e0afeb913e6ec1b1d9a085cc9365908e9ce",
"questions": [
"Q1 \u2014 Patch-consolidation scope: is the goal a thin single-registry wrapper in wgp_patches.py (what this plan proposes), or should we ALSO land a concrete runtime-model-definition patch during Sprint 4 (e.g., an off-by-default res_2s / self_refiner runtime flag on the LTX2 model defs per SD-005)? Adding a concrete consumer would give apply_all_wgp_patches a second kind of entry visible in get_wgp_patch_state(), which is a stronger single-registry proof but widens scope.",
"Q2 \u2014 Drift CI severity: SD-008 says the job 'reports drift for review'. Should the workflow exit non-zero on drift (hard fail, forces review via red check) or only report via the summary and issue comment (soft fail)? This plan defaults to soft-report-only.",
"Q3 \u2014 Upstream PR grouping: 118 bucket-(b) rows \u2192 \u224813 drafts grouped by triage theme (one per theme), or finer per-subdirectory splits (e.g., TTS split into index_tts2 vs ace_step15)? This plan defaults to 13 theme-level drafts; the orchestrator can split further when actually opening PRs."
],
"success_criteria": [
{
"criterion": "source/models/wgp/wgp_patches.py imports begin_runtime_model_patch, apply_runtime_model_patch, and rollback_runtime_model_patch from source.runtime.wgp_bridge and defines a new wrapper function (e.g., apply_runtime_model_definition_patch) that routes model-definition patches through those primitives and registers via _register_patch_application.",
"priority": "must",
"requires": [
"read_files",
"parse_diff"
]
},
{
"criterion": "The new wrapper's patch appears in get_wgp_patch_state() under the same registry as existing module-level patches (single-registry invariant), proven by a new test in tests/test_wgp_patch_lifecycle.py that also verifies rollback removes it from both models_def and the registry.",
"priority": "must",
"requires": [
"run_tests"
]
},
{
"criterion": "The full 8-file regression suite passes under uv run --python 3.10 pytest (or a darwin-arm64 smoke-venv fallback): tests/test_travel_guidance_config.py, tests/test_travel_ltx_vpt.py, tests/test_ltx_hybrid_travel.py, tests/test_ltx_hybrid_vgkfi.py, tests/test_travel_payload_contracts.py, tests/test_travel_orchestrator_terminal_gating.py, tests/test_travel_guidance_ic_lora_override.py, tests/test_task_registry_ic_lora_dedup.py.",
"priority": "must",
"requires": [
"run_tests"
]
},
{
"criterion": "tests/test_wgp_patch_lifecycle.py + tests/test_wgp_patch_context_contracts.py + tests/test_runtime_model_patch_contracts.py all pass.",
"priority": "must",
"requires": [
"run_tests"
]
},
{
"criterion": ".github/workflows/wan2gp-drift.yml exists, parses as valid YAML, includes a weekly schedule trigger and workflow_dispatch, checks out submodules, and compares the pinned submodule SHA against upstream deepbeepmeep/Wan2GP HEAD.",
"priority": "must",
"requires": [
"read_files",
"run_shell"
]
},
{
"criterion": "docs/wan2gp-rebase-runbook.md exists and covers: monthly cadence + event triggers (SD-007), pre-flight baseline-tag step, fork rebase steps, submodule bump in reigh-worker, post-bump verification (8-file suite + strict path smoke + patch-lifecycle smoke), rollback procedure (flagged orchestrator-only), and drift CI interpretation.",
"priority": "must",
"requires": [
"read_files"
]
},
{
"criterion": "scripts/sprint4/upstream_prs/ contains a README.md and one markdown draft per upstreamable triage theme (\u224813 files), each with Title / Summary / Affected files / Test plan. No file actually opens a PR.",
"priority": "must",
"requires": [
"read_files"
]
},
{
"criterion": "No git commit is created on the Sprint 4 changes; deliverables are left staged or untracked for user review.",
"priority": "must",
"requires": [
"run_shell"
]
},
{
"criterion": "Strict path-contract smoke from Section 4 of the migration plan still passes after Sprint 4 changes (Wan2GP/ on sys.path plus the three bare-module filesystem existence checks).",
"priority": "must",
"requires": [
"run_shell"
]
},
{
"criterion": "Patch-lifecycle smoke script scripts/sprint4/patch_lifecycle_smoke.py is shipped and documented as orchestrator/linux-only (it drives real WanOrchestrator bootstrap and inspects get_wgp_patch_state() after apply_all_wgp_patches).",
"priority": "should",
"requires": [
"read_files"
]
},
{
"criterion": "Drift CI run-once: the workflow is manually triggered successfully via workflow_dispatch after merge and reports a drift summary.",
"priority": "info",
"requires": []
},
{
"criterion": "Upstream PR drafts are opened against deepbeepmeep/Wan2GP by the orchestrator using the bodies under scripts/sprint4/upstream_prs/.",
"priority": "info",
"requires": []
}
],
"assumptions": [
"Sprint-4 patch extension scope is the single-registry wrapper only \u2014 no concrete res_2s / self_refiner per-model runtime patch lands in this sprint (Q1).",
"Drift CI is report-only (does not fail the job on drift); it only fails on command error (Q2).",
"Upstream PR drafts are grouped one-per-triage-theme (\u224813 files) rather than per-path (Q3). Orchestrator can split further when actually opening PRs.",
"Executor runs the 8-file regression suite via uv run --python 3.10 pytest when possible, falling back to .venv/bin/python -m pytest on darwin-arm64 if the decord wheel gap blocks uv sync. Tests do not exercise the lazy decord import paths.",
"Executor writes only non-.git/ deliverables and leaves changes staged. Orchestrator is responsible for: baseline tagging, committing, pushing, triggering the drift workflow, and opening the upstream PRs.",
"The patch-lifecycle smoke's two forms \u2014 (a) stub pytest in the executor's reach, (b) real bootstrap script for orchestrator/linux \u2014 together satisfy the Sprint-4 verification gate 'Patch-lifecycle smoke drives bootstrap to orchestrator.py:265-266 via apply_all_wgp_patches'.",
"wan2gp-mig-sprint-4-baseline is already recorded (verified via git tag -l), so the rollback plan's tag prerequisite is satisfied without executor action."
],
"structure_warnings": []
}
code
Plan structure warnings from validator:
[]
Existing flags:
[]
Known accepted debt grouped by subsystem:
{
"are-the-proposed-changes-technically-correct": [
{
"id": "DEBT-004",
"concern": "are the proposed changes technically correct?: compared the proposed worker sigterm handling to the existing lifecycle structure in source/task_handlers/queue/task_queue.py:529-579. the queue entrypoint wraps startup and steady-state in one lifecycle block, but worker main() does not enter its cleanup try/finally until source/runtime/worker/server.py:405, so the proposed handler alone is not fully correct for startup-time shutdowns.",
"occurrence_count": 1,
"plan_ids": [
"add-idle-release-feature-for-20260408-0309"
]
},
{
"id": "DEBT-008",
"concern": "are the proposed changes technically correct?: compared the documented startup limitation to the actual lifecycle boundary in source/runtime/worker/server.py. because the cleanup try/finally still begins only at line 405, the proposed sigterm handler is only correct for steady-state shutdowns and not for startup-time sigterm, so the plan remains intentionally incomplete on that case.",
"occurrence_count": 1,
"plan_ids": [
"add-idle-release-feature-for-20260408-0309"
]
}
],
"byte-compare-oracle": [
{
"id": "DEBT-010",
"concern": "clear_conditioning oracle is single-shape",
"occurrence_count": 1,
"plan_ids": [
"execute-sprint-3-of-the-20260422-0132"
]
}
],
"did-the-work-fully-address-the-issue-hints-user-notes-and-approved-plan-requirements": [
{
"id": "DEBT-002",
"concern": "did the work fully address the issue hints, user notes, and approved plan requirements?: checked the revised supervisor command against the original brief and source/task_handlers/worker/fatal_error_handler.py:443-445. rev 3 no longer claims literal argv equality and instead redefines "byte-identical" as "operator-equivalent", but the user note explicitly asked for byte-identical cli args, env, cwd, and python interpreter, so that requirement is still only partially addressed.",
"occurrence_count": 1,
"plan_ids": [
"add-idle-release-feature-for-20260408-0309"
]
},
{
"id": "DEBT-003",
"concern": "did the work fully address the issue hints, user notes, and approved plan requirements?: checked the startup-sigterm scope note against source/runtime/worker/server.py:299-405 and :535-554. the revision documents the startup-window limitation clearly, but it still leaves a user ctrl+c or sigterm during slow startup outside the cleanup path even though the brief did not carve that case out.",
"occurrence_count": 1,
"plan_ids": [
"add-idle-release-feature-for-20260408-0309"
]
}
],
"find-the-callers-of-the-changed-function-what-arguments-do-they-actually-pass-does-the-fix-handle-all-of-them": [
{
"id": "DEBT-005",
"concern": "find the callers of the changed function. what arguments do they actually pass? does the fix handle all of them?: checked caller-visible argv assumptions against source/task_handlers/worker/fatal_error_handler.py:443-445. the absolute .../worker.py child path will satisfy the current substring-based detection, but any future caller that truly requires literal argv preservation would still see a different invocation shape than the brief originally asked for.",
"occurrence_count": 2,
"plan_ids": [
"add-idle-release-feature-for-20260408-0309"
]
}
],
"search-for-related-code-that-handles-the-same-concept-is-the-reported-issue-a-symptom-of-something-broader": [
{
"id": "DEBT-007",
"concern": "search for related code that handles the same concept. is the reported issue a symptom of something broader?: searched related signal-handling code and compared worker main() to source/task_handlers/queue/task_queue.py:529-579. the queue entrypoint wraps startup and steady-state in one lifecycle block, so documenting the worker startup gap as out of scope leaves a broader shutdown-consistency difference in place rather than fully aligning with the existing pattern.",
"occurrence_count": 1,
"plan_ids": [
"add-idle-release-feature-for-20260408-0309"
]
}
],
"supervisor-invocation": [
{
"id": "DEBT-001",
"concern": "supervisor invocation: the revised plan still does not preserve a literally byte-identical worker invocation, because it explicitly redefines the requirement to mean operator-equivalent execution and still uses -u plus an absolute worker.py path.",
"occurrence_count": 1,
"plan_ids": [
"add-idle-release-feature-for-20260408-0309"
]
}
],
"task-registry-ic-lora-wiring": [
{
"id": "DEBT-012",
"concern": "no integration test for get_ic_lora_entry() \u2192 activated_loras/loras_multipliers wiring after dedup extraction",
"occurrence_count": 1,
"plan_ids": [
"execute-sprint-3-of-the-20260422-0132"
]
}
],
"verification-gates": [
{
"id": "DEBT-009",
"concern": "'20 anchor tests' reinterpretation as minimum count",
"occurrence_count": 1,
"plan_ids": [
"execute-sprint-3-of-the-20260422-0132"
]
},
{
"id": "DEBT-011",
"concern": "persistent 20-anchor-tests literal-reading flag",
"occurrence_count": 1,
"plan_ids": [
"execute-sprint-3-of-the-20260422-0132"
]
}
],
"worker-shutdown": [
{
"id": "DEBT-006",
"concern": "worker shutdown: startup-window sigterm remains outside the worker cleanup path, so a user ctrl+c or sigterm during db init, wgp import, or task_queue.start() still will not run the terminated-heartbeat/task_queue.stop sequence.",
"occurrence_count": 1,
"plan_ids": [
"add-idle-release-feature-for-20260408-0309"
]
}
]
}
code
Escalated debt subsystems:
[]
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/reigh-workspace/reigh-worker/.megaplan/plans/execute-sprint-4-of-the-20260422-0347/critique_output.json
Read this file first — it contains 5 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.
Every check must end with at least one finding. Never leave a findings array empty. If you found no issue, add one detailed flagged: false finding explaining what you checked and why it appears clear.
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 authoritative Sprint 4 section in docs/WAN2GP_FORK_MIGRATION_PLAN.md:176-183 against the proposed patch work. The plan explicitly says not to wire any concrete runtime-model-definition patch into apply_all_wgp_patches(), but the authoritative gate says the patch-lifecycle smoke must drive bootstrap to source/models/wgp/orchestrator.py:265-266 via apply_all_wgp_patches() and only then inspect get_wgp_patch_state(); with the current repo shape, apply_all_wgp_patches() still only records the seven existing module-level patches, so this plan only proves the new wrapper in isolation, not through the required bootstrap path.","flagged":true},{"detail":"Checked the executor constraints in the brief against the verification gates in docs/WAN2GP_FORK_MIGRATION_PLAN.md:174-183. The plan correctly respects the user note not to open PRs or write .git/, and it leaves changes staged, but it also defers the required 'Drift CI runs once successfully' gate to a later orchestrator workflow_dispatch, so the Sprint 4 verification set is only partially executed by the proposed work.","flagged":true}]},{"id":"correctness","question":"Are the proposed changes technically correct?","findings":[{"detail":"Compared the proposed apply_runtime_model_definition_patch wrapper to the existing registry mechanics in source/models/wgp/wgp_patches.py:24-100 and the existing idempotence tests in tests/test_wgp_patch_lifecycle.py. The proposed helper has no guard for an already-applied patch_name/target_key pair, so a second call would overwrite _PATCH_CONTEXT_ROLLBACKS with a transaction snapshot taken after the first mutation; rollback_runtime_model_patch() would then restore the already-patched value rather than the pre-patch state, which breaks the rollbackable/idempotent contract the current patch registry is testing for.","flagged":true},{"detail":"Verified the proposed unit-test seam against source/runtime/wgp_ports/runtime_registry.py:86-88 and :201-214. Monkeypatching runtime_registry.get_wgp_runtime_module is sufficient for an isolated smoke test because begin_runtime_model_patch() resolves its mutable runtime through _get_runtime_for_mutation() and that function delegates back to runtime_registry.get_wgp_runtime_module().","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":"Searched source/, tests/, and scripts/ for begin_runtime_model_patch(), apply_runtime_model_patch(), rollback_runtime_model_patch(), and apply_all_wgp_patches(). The runtime patch primitives are currently used only in tests, while the only production bootstrap path is WanOrchestrator importing wgp and then calling apply_all_wgp_patches() in source/models/wgp/orchestrator.py:265-266, so keeping apply_all_wgp_patches() unchanged leaves the broader 'single registry in production bootstrap' symptom unresolved.","flagged":true},{"detail":"Checked for other production callers that would need coordinated edits and did not find any beyond the orchestrator bootstrap. That means the runtime-wrapper addition itself is localized, but it also means the plan's direct helper test does not cover any existing production flow unless the orchestrator path is updated too.","flagged":true}]},{"id":"all_locations","question":"Does the change touch all locations AND supporting infrastructure?","findings":[{"detail":"Checked the triage source file rather than the plan summary. docs/wan2gp-triage.csv has columns path,hunk,bucket,carry_location,owner,verification; there is no separate 'theme' column, and the current upstreamable rows split into 14 distinct hunk groups, not ~13, so the plan's 'theme-level drafts' success criterion is internally inconsistent with the repository data it intends to drive.","flagged":true},{"detail":"Checked the supporting test coverage around the shared patch registry. tests/test_wgp_patch_context_contracts.py currently exercises context_id scoping only through apply_all_wgp_patches(), but the proposed new runtime-wrapper test never passes a non-default context_id even though the helper itself accepts context_id and writes into the same registry buckets, so one piece of required supporting infrastructure remains untested.","flagged":true}]},{"id":"callers","question":"Find the callers of the changed function. What arguments do they actually pass? Does the fix handle all of them?","findings":[{"detail":"Grep shows only one production caller of apply_all_wgp_patches(): source/models/wgp/orchestrator.py:265-266, and it passes only (wgp, self.wan_root) with no context_id and no runtime-model patch arguments. Because the plan keeps that caller unchanged, none of the actual production arguments exercise the proposed runtime wrapper, so the helper sits off to the side of the real call graph.","flagged":true},{"detail":"Grep also shows begin_runtime_model_patch()/apply_runtime_model_patch()/rollback_runtime_model_patch() are called only from tests/test_runtime_model_patch_contracts.py today. Those tests use a single transaction followed by a single rollback; there is no caller coverage for repeated application, non-default context_id values, or a bootstrap-triggered invocation, so the plan does not verify the edge cases the shared patch registry already cares about.","flagged":true}]}],"flags":[{"id":"FLAG-001","concern":"WGP patch consolidation: the plan never routes a runtime-model patch through source/models/wgp/orchestrator.py -> apply_all_wgp_patches(), so the authoritative bootstrap smoke cannot demonstrate that runtime patches now live in the single registry.","category":"completeness","severity_hint":"likely-significant","evidence":"docs/WAN2GP_FORK_MIGRATION_PLAN.md:176-183 requires a bootstrap-driven smoke after apply_all_wgp_patches(); source/models/wgp/wgp_patches.py:536-580 still applies only the seven existing module-level patches, and the plan explicitly says not to wire a concrete runtime-model override into that path."},{"id":"FLAG-002","concern":"Runtime patch wrapper: repeated application with the same patch_name/model_name would overwrite the original rollback closure, so rollback can restore the already-patched value instead of the pre-patch state.","category":"correctness","severity_hint":"likely-significant","evidence":"source/models/wgp/wgp_patches.py:36-57 stores one rollback callable per patch_name/target_key, and tests/test_wgp_patch_lifecycle.py asserts idempotent/rollbackable behavior for analogous patches. The proposed helper description does not include an existing-state guard before registering a new transaction-backed rollback."},{"id":"FLAG-003","concern":"Upstream PR drafting: the plan's '~13 theme' assumption does not match docs/wan2gp-triage.csv, which currently exposes 14 upstreamable hunk groups and no 'theme' column.","category":"completeness","severity_hint":"likely-minor","evidence":"docs/wan2gp-triage.csv headers are path,hunk,bucket,carry_location,owner,verification, and counting upstreamable rows by hunk yields 14 groups: ltx2 hot-zone, preset/config, Wan runtime, TTS, model implementation, shared runtime, LLM engine, shared utility, project metadata, plugin integration, documentation, installer/update script, Gradio UI, and content drift."}],"verified_flag_ids":[],"disputed_flag_ids":[]}
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 an independent reviewer. Critique the plan against the actual repository.
Execute Sprint 4 of the Wan2GP fork migration per docs/WAN2GP_FORK_MIGRATION_PLAN.md (Sprint 4 section L163-187 is authoritative — read it first). Deliverables: (1) extend source/models/wgp/wgp_patches.py using existing runtime-patch primitives (_register_patch_application, begin_runtime_model_patch, rollback_runtime_model_patch), (2) draft upstream PR bodies for bucket (b) items into scripts/sprint4/upstream_prs/ — do NOT actually open PRs (orchestrator handles), (3) land .github/workflows/wan2gp-drift.yml per SD-008, (4) publish docs/wan2gp-rebase-runbook.md per SD-007. Run all Sprint 4 verification gates listed in the plan. Baseline tag wan2gp-mig-sprint-4-baseline already exists on reigh-worker. Sandbox rules learned from Sprints 1-3: executor cannot write .git/ or push to remotes — orchestrator handles those. uv sync fails on darwin-arm64 (decord==0.6.0 wheel gap) — build/reuse a minimal smoke venv. Do NOT commit final reigh-worker work — leave changes staged for user review.
Sprint 4 closes out the migration by (a) consolidating runtime fork behavior into a single wgp_patches.py registry AND wiring a concrete runtime-model-definition patch into the bootstrap so get_wgp_patch_state() after apply_all_wgp_patches() proves the single-registry invariant in the real production path, (b) drafting upstream PR bodies for the 118 bucket-(b) rows in docs/wan2gp-triage.csv grouped into the 14 distinct hunk themes already present in the CSV, (c) landing a weekly drift-detection workflow per SD-008, and (d) publishing the rebase runbook per SD-007. Orchestrator-owned handoff is explicitly documented for the gates the executor cannot run (PR open, drift-CI once-through, baseline tag/commit).
Key repo shape:
source/models/wgp/wgp_patches.py already has _register_patch_application, get_wgp_patch_state, clear_wgp_patch_context, rollback_wgp_patches, _PATCH_CONTEXT_STATE, _PATCH_CONTEXT_ROLLBACKS. Today apply_all_wgp_patches (wgp_patches.py:536-580) records seven module-level patches.
source/runtime/wgp_ports/runtime_registry.py:184-222 defines _RuntimePatchTransaction, begin_runtime_model_patch, apply_runtime_model_patch, rollback_runtime_model_patch. Today no production caller touches them.
Patch application seam: source/models/wgp/orchestrator.py:265-266 (apply_all_wgp_patches(wgp, self.wan_root)). The authoritative Sprint 4 gate drives bootstrap to this line and then inspects get_wgp_patch_state().
Baseline tag wan2gp-mig-sprint-4-baseline already exists.
uv sync fails on darwin-arm64 (decord==0.6.0 wheel gap). source.media.structure.* imports decord lazily, so the 8-file regression suite runs on the existing .venv smoke venv.
Real WanOrchestrator bootstrap imports Wan2GP/wgp.py which eagerly imports decord — full bootstrap smoke is orchestrator/linux-only.
Do not commit. Stage everything for user review.
Main Phase
Step 1: Audit the existing patch registry, runtime primitives, and bootstrap seam (source/models/wgp/wgp_patches.py, source/runtime/wgp_ports/runtime_registry.py, source/models/wgp/orchestrator.py)
Readruntime_registry.py:184-222 + wgp_bridge.py:19-21,94-126 to confirm the three primitives are re-exported.
Readsource/models/wgp/orchestrator.py:245-267 to confirm apply_all_wgp_patches(wgp, self.wan_root) is the single bootstrap seam; note that wgp.models_def is populated before this line, so the extension patch can safely iterate over it.
Step 2: Extend wgp_patches.py with an idempotent runtime-model-def wrapper and a concrete bootstrap-wired fork-marker patch (source/models/wgp/wgp_patches.py)
Scope: Medium
Importbegin_runtime_model_patch, apply_runtime_model_patch, rollback_runtime_model_patch from source.runtime.wgp_bridge.
Implementapply_runtime_model_definition_patch(model_name, patch_values, *, patch_name, context_id=None) with an explicit idempotency guard that mirrors apply_qwen_lora_directory_patch (wgp_patches.py:197-204):
Compute target_key = f"model_def:{model_name}".
Guard:existing = get_wgp_patch_state(context_id=context_id).get(patch_name, {}); if target_key in existing and existing[target_key].get("applied") → return True immediately (do NOT open a second transaction; the first rollback closure is preserved). This fixes FLAG-002 / correctness / callers-2.
Otherwise call transaction = begin_runtime_model_patch(model_name, keys=tuple(patch_values.keys())), then apply_runtime_model_patch(transaction, patch_values).
Register via _register_patch_application(patch_name, target_key, applied=True, context_id=context_id, rollback=_make_runtime_model_def_rollback(transaction, len(patch_values))) where the helper returns a closure that calls rollback_runtime_model_patch(transaction) and returns the int count (match existing rollback-return contract).
Return True.
Implement a concrete bootstrap-wired patch apply_ltx2_runtime_fork_markers_patch(wgp_module, *, context_id=None) that:
Iterates wgp_module.models_def.keys() filtering to k for k in keys if isinstance(k, str) and k.startswith("ltx2").
For each matching key, calls apply_runtime_model_definition_patch(k, {"_banodoco_fork_runtime_patch": True}, patch_name="ltx2_runtime_fork_markers", context_id=context_id).
Returns True if at least one entry was touched OR if no ltx2 entries existed (treat empty-models_def as soft-OK for smoke mode); returns False only on exception.
Rationale: _banodoco_fork_runtime_patch is a private marker key with leading underscore → zero collision risk with upstream model-def fields and no observable generation-path effect. It is the minimum viable concrete patch that satisfies the authoritative gate "bootstrap smoke inspects get_wgp_patch_state() and sees a runtime-model entry"; SD-005 concrete defaults (res_2s, self_refiner) can replace it in a later sprint without widening Sprint 4 scope into product behavior.
Addtest_runtime_model_definition_patch_registers_in_single_registry in tests/test_wgp_patch_lifecycle.py:
Build a _FakeRuntime stub matching tests/test_runtime_model_patch_contracts.py:10-21 (models_def + loaded wan_model.model_def) and monkeypatch runtime_registry.get_wgp_runtime_module to return it.
Call wrapper with patch_name="ltx2_runtime_fork_markers", model_name="ltx2_22B", patch_values={"_banodoco_fork_runtime_patch": True}.
Assert runtime.models_def["ltx2_22B"]["_banodoco_fork_runtime_patch"] is True.
Assert get_wgp_patch_state()["ltx2_runtime_fork_markers"]["model_def:ltx2_22B"]["applied"] is True (single registry).
Call rollback_wgp_patches(patch_name="ltx2_runtime_fork_markers") → assert restored ≥ 1, key gone from both models_def and registry.
After a first successful apply, mutate runtime.models_def["ltx2_22B"]["_banodoco_fork_runtime_patch"] = "intruder" (simulate external change between calls).
Call the wrapper a second time with the same patch_name/model_name/patch_values.
Assert the guard short-circuited: runtime.models_def["ltx2_22B"]["_banodoco_fork_runtime_patch"] == "intruder" (wrapper did NOT open a new transaction or overwrite).
Rollback → assert the "intruder" value is cleared back to absent (the ORIGINAL first-call transaction snapshot restored pre-patch state, not the intruder state). This pins FLAG-002 fix.
Addtest_runtime_model_definition_patch_respects_context_id in tests/test_wgp_patch_context_contracts.py:
Call the wrapper twice with identical args under two distinct context_id values ("ctx.a", "ctx.b").
Assert both contexts report the patch via get_wgp_patch_state(context_id=…).
Call clear_wgp_patch_context("ctx.a") → assert get_wgp_patch_state(context_id="ctx.a") == {} and get_wgp_patch_state(context_id="ctx.b") still has the entry.
Tear down both contexts in a try/finally. This pins all_locations-2.
Addtest_apply_all_wgp_patches_records_ltx2_runtime_fork_markers in (sits next to existing ):
Step 4: Draft bucket-(b) upstream PR bodies, one per CSV hunk theme (scripts/sprint4/upstream_prs/)
Dry-run the diff snippet locally against the current submodule pointer; verify pointer matches LOCAL_SHA=181bb71a21008032e4771e11663f33e4489c4512 from scripts/sprint3/_handoff/orchestrator_handoff_note_2.txt.
Validate yaml syntax: .venv/bin/python -c "import yaml; yaml.safe_load(open('.github/workflows/wan2gp-drift.yml'))" (fall back to actionlint-in-docker if pyyaml isn't in the smoke venv).
Record explicitly in the Sprint 4 handoff note (Step 7 sub-step 7) that the "Drift CI runs once successfully" authoritative gate is orchestrator-owned (requires workflow_dispatch push — executor cannot). This closes the docs loop on issue_hints-2 while keeping the SD-exec-no-git decision intact.
Step 6: Publish the rebase runbook per SD-007 (docs/wan2gp-rebase-runbook.md)
Scope: Small
Createdocs/wan2gp-rebase-runbook.md sections: Cadence (monthly + event-triggered), Pre-flight (tag wan2gp-mig-rebase-YYYY-MM-baseline, green 8-file suite), Fork rebase procedure in banodoco/Wan2GP, Submodule bump in reigh-worker, Post-bump verification (8-file suite + strict path smoke + patch-lifecycle smoke both forms), Rollback (orchestrator-only — flagged with explicit SD-exec-no-git reference), Drift CI interpretation (including that workflow_dispatch once-through is orchestrator-owned).
Cross-link to docs/wan2gp-triage.csv and scripts/sprint4/upstream_prs/.
Full 8-file regression suite:
uv run --python 3.10 pytest tests/test_travel_guidance_config.py tests/test_travel_ltx_vpt.py tests/test_ltx_hybrid_travel.py tests/test_ltx_hybrid_vgkfi.py tests/test_travel_payload_contracts.py tests/test_travel_orchestrator_terminal_gating.py tests/test_travel_guidance_ic_lora_override.py tests/test_task_registry_ic_lora_dedup.py
Fall back to .venv/bin/python -m pytest … on darwin-arm64 if uv run hits the decord wheel gap.
Patch-lifecycle smoke (executor / stub bootstrap): uv run --python 3.10 pytest tests/test_wgp_patch_context_contracts.py::test_apply_all_wgp_patches_records_ltx2_runtime_fork_markers. Proves the concrete runtime-model patch is reached via apply_all_wgp_patches and registered alongside module-level patches in the single registry — the executor-side proof for the authoritative gate.
Patch-lifecycle smoke (orchestrator / full bootstrap): ship scripts/sprint4/patch_lifecycle_smoke.py that:
After init returns, imports get_wgp_patch_state and prints a JSON dump.
Asserts "ltx2_runtime_fork_markers" appears in the dump with at least one model_def:ltx2* entry.
Documented in the runbook as orchestrator/linux-only (decord blocks darwin-arm64).
Drift CI once-through: handoff note to orchestrator (step 5.4); executor cannot trigger.
Strict path-contract smoke: re-run the Sprint 2 one-liner from Section 4 of the migration plan.
Handoff note: write scripts/sprint4/_handoff/orchestrator_handoff_note.txt that lists: staged file paths, gate summary (which gates executor ran green, which are orchestrator-owned — specifically "Drift CI runs once successfully" and any git tag/commit/push), and the two smokes (stub form passed, full form linux-only).
Leave staged: git add the new/changed files via Write-created paths; do NOT commit.
Yaml-load check for the drift workflow; dry-run the drift diff logic locally.
Visual review of the four drafted deliverables + handoff note + staged diff hand-off.
code
Plan metadata:
{
"version": 2,
"timestamp": "2026-04-22T02:05:43Z",
"hash": "sha256:e9006444972ae1f2f0f3c70dc20cada033391a1517f7da55554a2d30b8ca6881",
"changes_summary": "Addressed every significant flag from gate iteration 1. (1) FLAG-001/issue_hints-1/scope-1/scope-2/callers-1: Sprint 4 now wires a concrete runtime-model-def patch (apply_ltx2_runtime_fork_markers_patch) into apply_all_wgp_patches(), so the authoritative bootstrap smoke inspects get_wgp_patch_state() and sees a runtime-model entry alongside the seven module-level patches in the same registry. Chose a private-key marker (_banodoco_fork_runtime_patch) to satisfy the gate without changing generation behavior. (2) FLAG-002/correctness/callers-2: Added an explicit idempotency guard to apply_runtime_model_definition_patch that mirrors apply_qwen_lora_directory_patch \u2014 second call with same patch_name/target_key short-circuits, preserving the first-call rollback closure; added a test that seeds an intruder value between calls and asserts rollback restores pre-patch state. (3) all_locations-1: Corrected the theme count from ~13 to exactly 14, derived from grep ',upstreamable,' docs/wan2gp-triage.csv | cut -d, -f2 | sort -u; PR drafts now use literal CSV hunk strings instead of invented groupings. (4) all_locations-2: Added a context_id-scoped test in tests/test_wgp_patch_context_contracts.py that applies the wrapper under two distinct contexts and verifies clear_wgp_patch_context isolation. (5) issue_hints-2: Made the orchestrator-owns-drift-CI-once handoff explicit in Step 5.4, Step 7.5, a new Sprint 4 handoff note in Step 7.7, and the runbook (Step 6). Q1 resolved by the authoritative gate (wire concrete patch) rather than deferred; Q3 resolved by adopting 14 CSV-literal themes. Success criteria updated to name the concrete marker patch and count themes as 14.",
"flags_addressed": [
"FLAG-001",
"FLAG-002",
"issue_hints-1",
"issue_hints-2",
"correctness",
"scope-1",
"scope-2",
"all_locations-1",
"all_locations-2",
"callers-1",
"callers-2"
],
"questions": [
"Q1 \u2014 RESOLVED: The authoritative gate in docs/WAN2GP_FORK_MIGRATION_PLAN.md:176-183 forces wiring a concrete runtime-model-def patch into apply_all_wgp_patches(). Chosen patch is the minimal-side-effect apply_ltx2_runtime_fork_markers_patch (writes _banodoco_fork_runtime_patch=True on ltx2 model defs). Concrete SD-005 res_2s/self_refiner overrides remain out-of-scope for Sprint 4 (defer to a follow-up sprint) \u2014 confirm this marker-first approach is acceptable, or specify which SD-005 flag should land instead/additionally.",
"Q2 \u2014 RESOLVED: Drift CI is report-only per SD-drift-ci-scope.",
"Q3 \u2014 RESOLVED: 14 upstream PR drafts aligned to the 14 literal hunk strings in docs/wan2gp-triage.csv (verified via ). Orchestrator can refine at PR-open time.",
"Q4 (new) \u2014 Ltx2 model-def filter: the concrete patch matches models_def keys starting with . Should it instead match a curated list (e.g., ) to avoid also marking gguf/quant variants? Plan defaults to prefix match; curated list is a one-line change if preferred."
],
"success_criteria": [
{
"criterion": " imports , , and from and defines with an explicit idempotency guard that short-circuits when is already applied in the given context.",
"priority": "must",
"requires": [
"read_files",
"parse_diff"
]
},
{
"criterion": " in registers at least one runtime-model-definition patch () that iterates ltx2-prefixed keys and writes via the new wrapper \u2014 so bootstrap smoke finds runtime-model entries in alongside the seven existing module-level patches.",
"priority": "must",
"requires": [
"read_files",
"parse_diff"
]
},
{
"criterion": "New tests prove (a) single-registry wrapper behavior incl. rollback, (b) idempotency: second wrapper call with same patch_name/model_name short-circuits and the first-call rollback still restores pre-patch state even if an intruder mutation was made between calls, (c) context_id scoping: same wrapper call under two distinct context_ids both register, isolates, (d) bootstrap: populates for every ltx2 model and not for non-ltx2.",
"priority": "must",
"requires": [
"run_tests"
]
},
{
"criterion": "The full 8-file regression suite passes under (or a darwin-arm64 smoke-venv fallback): , , , , , , , .",
"priority": "must",
"requires": [
"run_tests"
]
},
{
"criterion": " + + all pass including the four new tests.",
"priority": "must",
"requires": [
"run_tests"
]
},
{
"criterion": " exists, parses as valid YAML, includes a weekly trigger and , checks out submodules, compares the pinned submodule SHA against upstream HEAD, and is report-only (does not fail the job on drift; fails only on git command error).",
"priority": "must",
"requires": [
"read_files",
"run_shell"
]
},
{
"criterion": " exists and covers: monthly cadence + event triggers (SD-007), pre-flight baseline-tag step, fork rebase steps, submodule bump in reigh-worker, post-bump verification (8-file suite + strict path smoke + both patch-lifecycle smoke forms), rollback procedure (flagged orchestrator-only), drift CI interpretation, and explicit note that the once-through is orchestrator-owned.",
"priority": "must",
"requires": [
"read_files"
]
},
{
"criterion": " contains a + exactly 14 markdown drafts, one per literal string in the upstreamable bucket of (not invented groupings). Each draft has Title / Summary / Affected files (grep-derived) / Verification / Review pointer. No file runs .",
"priority": "must",
"requires": [
"read_files",
"run_shell"
]
},
{
"criterion": "No git commit is created on the Sprint 4 changes; deliverables are left staged or untracked for user review, and enumerates staged files plus orchestrator-owned gates (Drift CI once-through, any baseline tag moves, PR creation).",
"priority": "must",
"requires": [
"run_shell"
]
},
{
"criterion": "Strict path-contract smoke from Section 4 of the migration plan still passes after Sprint 4 changes (Wan2GP/ on sys.path plus the three bare-module filesystem existence checks).",
"priority": "must",
"requires": [
"run_shell"
]
},
{
"criterion": "Patch-lifecycle smoke script is shipped and documented as orchestrator/linux-only (drives real bootstrap and inspects after , asserting the runtime-model-patch entries are present).",
"priority": "should",
"requires": [
"read_files"
]
},
{
"criterion": "Drift CI run-once: the workflow is manually triggered successfully via after merge and reports a drift summary (orchestrator-owned gate).",
"priority": "info",
"requires": []
},
{
"criterion": "Upstream PR drafts are opened against by the orchestrator using the bodies under .",
"priority": "info",
"requires": []
}
],
"assumptions": [
" is a safe private marker key on ltx2 model defs \u2014 leading underscore makes accidental collision with upstream fields negligible, and the key is not read by any generation code path. Future sprints can replace it with concrete SD-005 overrides (, ) without changing the wrapper or registry mechanics.",
" is populated before executes at (verified via Step 1 audit), so iterating the keys in the new patch is safe; smoke mode (which skips the wgp import path) never reaches this line, so no defensive branching is needed.",
"The existing smoke venv contains pytest + pyyaml + the source-side deps the 8-file regression suite needs; the 8 tests do not exercise the lazy paths in . If pyyaml is missing, the drift workflow's yaml syntax check falls back to in docker.",
"Executor writes non- deliverables only, leaves changes staged, and hands off via . Orchestrator owns: commits, baseline tag moves, PR creation, and the once-through of . Per SD-exec-no-git.",
"Drift CI is report-only (does not fail on drift; fails only on git command error) per SD-drift-ci-scope and SD-008 wording 'reports drift for review'.",
"Upstream PR drafts are one-per-CSV-hunk-theme (14 files) using the CSV's literal strings \u2014 no invented groupings. Orchestrator can split further when actually opening PRs, but the executor deliverable is 14 markdown files aligned to the data source.",
"Two-form patch-lifecycle smoke stands: stub form in (executor-runnable, proves the concrete runtime-model patch flows through into the single registry) + (orchestrator/linux-only, full bootstrap)."
],
"delta_from_previous_percent": 53.12,
"structure_warnings": []
}
code
Plan structure warnings from validator:
[]
Existing flags:
[
{
"id": "FLAG-001",
"concern": "WGP patch consolidation: the plan never routes a runtime-model patch through source/models/wgp/orchestrator.py -> apply_all_wgp_patches(), so the authoritative bootstrap smoke cannot demonstrate that runtime patches now live in the single registry.",
"status": "addressed",
"severity": "significant"
},
{
"id": "FLAG-002",
"concern": "Runtime patch wrapper: repeated application with the same patch_name/model_name would overwrite the original rollback closure, so rollback can restore the already-patched value instead of the pre-patch state.",
"status": "addressed",
"severity": "significant"
},
{
"id": "FLAG-003",
"concern": "Upstream PR drafting: the plan's '~13 theme' assumption does not match docs/wan2gp-triage.csv, which currently exposes 14 upstreamable hunk groups and no 'theme' column.",
"status": "open",
"severity": "minor"
},
{
"id": "issue_hints-1",
"concern": "Did the work fully address the issue hints, user notes, and approved plan requirements?: Checked the authoritative Sprint 4 section in docs/WAN2GP_FORK_MIGRATION_PLAN.md:176-183 against the proposed patch work. The plan explicitly says not to wire any concrete runtime-model-definition patch into apply_all_wgp_patches(), but the authoritative gate says the patch-lifecycle smoke must drive bootstrap to source/models/wgp/orchestrator.py:265-266 via apply_all_wgp_patches() and only then inspect get_wgp_patch_state(); with the current repo shape, apply_all_wgp_patches() still only records the seven existing module-level patches, so this plan only proves the new wrapper in isolation, not through the required bootstrap path.",
"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 executor constraints in the brief against the verification gates in docs/WAN2GP_FORK_MIGRATION_PLAN.md:174-183. The plan correctly respects the user note not to open PRs or write .git/, and it leaves changes staged, but it also defers the required 'Drift CI runs once successfully' gate to a later orchestrator workflow_dispatch, so the Sprint 4 verification set is only partially executed by the proposed work.",
"status": "addressed",
"severity": "significant"
},
{
"id": "correctness",
"concern": "Are the proposed changes technically correct?: Compared the proposed apply_runtime_model_definition_patch wrapper to the existing registry mechanics in source/models/wgp/wgp_patches.py:24-100 and the existing idempotence tests in tests/test_wgp_patch_lifecycle.py. The proposed helper has no guard for an already-applied patch_name/target_key pair, so a second call would overwrite _PATCH_CONTEXT_ROLLBACKS with a transaction snapshot taken after the first mutation; rollback_runtime_model_patch() would then restore the already-patched value rather than the pre-patch state, which breaks the rollbackable/idempotent contract the current patch registry is testing for.",
"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?: Searched source/, tests/, and scripts/ for begin_runtime_model_patch(), apply_runtime_model_patch(), rollback_runtime_model_patch(), and apply_all_wgp_patches(). The runtime patch primitives are currently used only in tests, while the only production bootstrap path is WanOrchestrator importing wgp and then calling apply_all_wgp_patches() in source/models/wgp/orchestrator.py:265-266, so keeping apply_all_wgp_patches() unchanged leaves the broader 'single registry in production bootstrap' symptom unresolved.",
"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 for other production callers that would need coordinated edits and did not find any beyond the orchestrator bootstrap. That means the runtime-wrapper addition itself is localized, but it also means the plan's direct helper test does not cover any existing production flow unless the orchestrator path is updated too.",
"status": "addressed",
"severity": "significant"
},
{
"id": "all_locations-1",
"concern": "Does the change touch all locations AND supporting infrastructure?: Checked the triage source file rather than the plan summary. docs/wan2gp-triage.csv has columns path,hunk,bucket,carry_location,owner,verification; there is no separate 'theme' column, and the current upstreamable rows split into 14 distinct hunk groups, not ~13, so the plan's 'theme-level drafts' success criterion is internally inconsistent with the repository data it intends to drive.",
"status": "addressed",
"severity": "significant"
},
{
"id": "all_locations-2",
"concern": "Does the change touch all locations AND supporting infrastructure?: Checked the supporting test coverage around the shared patch registry. tests/test_wgp_patch_context_contracts.py currently exercises context_id scoping only through apply_all_wgp_patches(), but the proposed new runtime-wrapper test never passes a non-default context_id even though the helper itself accepts context_id and writes into the same registry buckets, so one piece of required supporting infrastructure remains untested.",
"status": "addressed",
"severity": "significant"
},
{
"id": "callers-1",
"concern": "Find the callers of the changed function. What arguments do they actually pass? Does the fix handle all of them?: Grep shows only one production caller of apply_all_wgp_patches(): source/models/wgp/orchestrator.py:265-266, and it passes only (wgp, self.wan_root) with no context_id and no runtime-model patch arguments. Because the plan keeps that caller unchanged, none of the actual production arguments exercise the proposed runtime wrapper, so the helper sits off to the side of the real call graph.",
"status": "addressed",
"severity": "significant"
},
{
"id": "callers-2",
"concern": "Find the callers of the changed function. What arguments do they actually pass? Does the fix handle all of them?: Grep also shows begin_runtime_model_patch()/apply_runtime_model_patch()/rollback_runtime_model_patch() are called only from tests/test_runtime_model_patch_contracts.py today. Those tests use a single transaction followed by a single rollback; there is no caller coverage for repeated application, non-default context_id values, or a bootstrap-triggered invocation, so the plan does not verify the edge cases the shared patch registry already cares about.",
"status": "addressed",
"severity": "significant"
}
]
code
Known accepted debt grouped by subsystem:
{
"are-the-proposed-changes-technically-correct": [
{
"id": "DEBT-004",
"concern": "are the proposed changes technically correct?: compared the proposed worker sigterm handling to the existing lifecycle structure in source/task_handlers/queue/task_queue.py:529-579. the queue entrypoint wraps startup and steady-state in one lifecycle block, but worker main() does not enter its cleanup try/finally until source/runtime/worker/server.py:405, so the proposed handler alone is not fully correct for startup-time shutdowns.",
"occurrence_count": 1,
"plan_ids": [
"add-idle-release-feature-for-20260408-0309"
]
},
{
"id": "DEBT-008",
"concern": "are the proposed changes technically correct?: compared the documented startup limitation to the actual lifecycle boundary in source/runtime/worker/server.py. because the cleanup try/finally still begins only at line 405, the proposed sigterm handler is only correct for steady-state shutdowns and not for startup-time sigterm, so the plan remains intentionally incomplete on that case.",
"occurrence_count": 1,
"plan_ids": [
"add-idle-release-feature-for-20260408-0309"
]
}
],
"byte-compare-oracle": [
{
"id": "DEBT-010",
"concern": "clear_conditioning oracle is single-shape",
"occurrence_count": 1,
"plan_ids": [
"execute-sprint-3-of-the-20260422-0132"
]
}
],
"did-the-work-fully-address-the-issue-hints-user-notes-and-approved-plan-requirements": [
{
"id": "DEBT-002",
"concern": "did the work fully address the issue hints, user notes, and approved plan requirements?: checked the revised supervisor command against the original brief and source/task_handlers/worker/fatal_error_handler.py:443-445. rev 3 no longer claims literal argv equality and instead redefines "byte-identical" as "operator-equivalent", but the user note explicitly asked for byte-identical cli args, env, cwd, and python interpreter, so that requirement is still only partially addressed.",
"occurrence_count": 1,
"plan_ids": [
"add-idle-release-feature-for-20260408-0309"
]
},
{
"id": "DEBT-003",
"concern": "did the work fully address the issue hints, user notes, and approved plan requirements?: checked the startup-sigterm scope note against source/runtime/worker/server.py:299-405 and :535-554. the revision documents the startup-window limitation clearly, but it still leaves a user ctrl+c or sigterm during slow startup outside the cleanup path even though the brief did not carve that case out.",
"occurrence_count": 1,
"plan_ids": [
"add-idle-release-feature-for-20260408-0309"
]
}
],
"find-the-callers-of-the-changed-function-what-arguments-do-they-actually-pass-does-the-fix-handle-all-of-them": [
{
"id": "DEBT-005",
"concern": "find the callers of the changed function. what arguments do they actually pass? does the fix handle all of them?: checked caller-visible argv assumptions against source/task_handlers/worker/fatal_error_handler.py:443-445. the absolute .../worker.py child path will satisfy the current substring-based detection, but any future caller that truly requires literal argv preservation would still see a different invocation shape than the brief originally asked for.",
"occurrence_count": 2,
"plan_ids": [
"add-idle-release-feature-for-20260408-0309"
]
}
],
"search-for-related-code-that-handles-the-same-concept-is-the-reported-issue-a-symptom-of-something-broader": [
{
"id": "DEBT-007",
"concern": "search for related code that handles the same concept. is the reported issue a symptom of something broader?: searched related signal-handling code and compared worker main() to source/task_handlers/queue/task_queue.py:529-579. the queue entrypoint wraps startup and steady-state in one lifecycle block, so documenting the worker startup gap as out of scope leaves a broader shutdown-consistency difference in place rather than fully aligning with the existing pattern.",
"occurrence_count": 1,
"plan_ids": [
"add-idle-release-feature-for-20260408-0309"
]
}
],
"supervisor-invocation": [
{
"id": "DEBT-001",
"concern": "supervisor invocation: the revised plan still does not preserve a literally byte-identical worker invocation, because it explicitly redefines the requirement to mean operator-equivalent execution and still uses plus an absolute path.",
"occurrence_count": 1,
"plan_ids": [
"add-idle-release-feature-for-20260408-0309"
]
}
],
"task-registry-ic-lora-wiring": [
{
"id": "DEBT-012",
"concern": "no integration test for get_ic_lora_entry() \u2192 activated_loras/loras_multipliers wiring after dedup extraction",
"occurrence_count": 1,
"plan_ids": [
"execute-sprint-3-of-the-20260422-0132"
]
}
],
"verification-gates": [
{
"id": "DEBT-009",
"concern": "'20 anchor tests' reinterpretation as minimum count",
"occurrence_count": 1,
"plan_ids": [
"execute-sprint-3-of-the-20260422-0132"
]
},
{
"id": "DEBT-011",
"concern": "persistent 20-anchor-tests literal-reading flag",
"occurrence_count": 1,
"plan_ids": [
"execute-sprint-3-of-the-20260422-0132"
]
}
],
"worker-shutdown": [
{
"id": "DEBT-006",
"concern": "worker shutdown: startup-window sigterm remains outside the worker cleanup path, so a user ctrl+c or sigterm during db init, wgp import, or task_queue.start() still will not run the terminated-heartbeat/task_queue.stop sequence.",
"occurrence_count": 1,
"plan_ids": [
"add-idle-release-feature-for-20260408-0309"
]
}
]
}
code
Escalated debt subsystems:
[]
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/reigh-workspace/reigh-worker/.megaplan/plans/execute-sprint-4-of-the-20260422-0347/critique_output.json
Read this file first — it contains 5 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.
Every check must end with at least one finding. Never leave a findings array empty. If you found no issue, add one detailed flagged: false finding explaining what you checked and why it appears clear.
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.
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 an independent reviewer. Critique the plan against the actual repository.
Execute Sprint 4 of the Wan2GP fork migration per docs/WAN2GP_FORK_MIGRATION_PLAN.md (Sprint 4 section L163-187 is authoritative — read it first). Deliverables: (1) extend source/models/wgp/wgp_patches.py using existing runtime-patch primitives (_register_patch_application, begin_runtime_model_patch, rollback_runtime_model_patch), (2) draft upstream PR bodies for bucket (b) items into scripts/sprint4/upstream_prs/ — do NOT actually open PRs (orchestrator handles), (3) land .github/workflows/wan2gp-drift.yml per SD-008, (4) publish docs/wan2gp-rebase-runbook.md per SD-007. Run all Sprint 4 verification gates listed in the plan. Baseline tag wan2gp-mig-sprint-4-baseline already exists on reigh-worker. Sandbox rules learned from Sprints 1-3: executor cannot write .git/ or push to remotes — orchestrator handles those. uv sync fails on darwin-arm64 (decord==0.6.0 wheel gap) — build/reuse a minimal smoke venv. Do NOT commit final reigh-worker work — leave changes staged for user review.
Sprint 4 closes the migration by (a) consolidating runtime fork behavior into a single wgp_patches.py registry AND wiring a concrete runtime-model-definition patch into the bootstrap so get_wgp_patch_state() after apply_all_wgp_patches() proves the single-registry invariant through the real production path, (b) drafting upstream PR bodies for the 118 bucket-(b) rows grouped into the 14 literal hunk themes already present in docs/wan2gp-triage.csv, (c) landing a weekly drift-detection workflow per SD-008, and (d) publishing the rebase runbook per SD-007.
Key repo shape:
source/models/wgp/wgp_patches.py has _register_patch_application, get_wgp_patch_state, rollback_wgp_patches, clear_wgp_patch_context, and the context-scoped registry. apply_all_wgp_patches (wgp_patches.py:536-580) records seven module-level patches today.
The authoritative idempotency precedent is apply_qwen_lora_directory_patch (wgp_patches.py:197-225) which checks both registry state AND that the live patched target still carries the expected _headless_patch_target_key marker.
source/runtime/wgp_ports/runtime_registry.py:184-222 defines _RuntimePatchTransaction, begin_runtime_model_patch, apply_runtime_model_patch, rollback_runtime_model_patch. No production caller today.
Bootstrap seam: source/models/wgp/orchestrator.py:265-266 (apply_all_wgp_patches(wgp, self.wan_root)); wgp.models_def is populated before this line.
Workspace default python is 3.8.10 and cannot import 3.10-syntax source files. All plan-side invocations pin .venv/bin/python (3.10) or uv run --python 3.10; no bare python -c is used.
.venv is a minimal Python 3.10 smoke venv without pyyaml; plan adds a one-line .venv/bin/pip install --quiet pyyaml prep step before the yaml check (actionlint is not on PATH and no local docker image exists).
uv sync fails on darwin-arm64 (decord==0.6.0 wheel gap); source.media.structure.* imports decord lazily, so the 8-file regression suite runs on .venv.
Executor cannot write .git/ or push remotes; orchestrator opens PRs, tags baselines, triggers workflow_dispatch. Real WanOrchestrator bootstrap imports Wan2GP/wgp.py which eagerly imports decord — full bootstrap smoke is orchestrator/linux-only.
Do not commit. Stage for user review.
Main Phase
Step 1: Audit the patch registry, runtime primitives, bootstrap seam, and idempotency precedent (source/models/wgp/wgp_patches.py, source/runtime/wgp_ports/runtime_registry.py, source/models/wgp/orchestrator.py)
Readruntime_registry.py:184-222 + wgp_bridge.py:19-21,94-126 to confirm the three primitives are re-exported.
Readsource/models/wgp/orchestrator.py:245-267 to confirm the bootstrap seam and that wgp.models_def is populated before apply_all_wgp_patches(wgp, self.wan_root).
Step 2: Extend wgp_patches.py with a live-state-guarded runtime-model-def wrapper and a concrete bootstrap-wired marker patch (source/models/wgp/wgp_patches.py)
Scope: Medium
Importbegin_runtime_model_patch, apply_runtime_model_patch, rollback_runtime_model_patch from source.runtime.wgp_bridge; reuse the existing _get_runtime_for_mutation-equivalent access via the bridge (read runtime.models_def through the same path used by the transaction).
Implementapply_runtime_model_definition_patch(model_name, patch_values, *, patch_name, context_id=None) with a guard modeled on apply_qwen_lora_directory_patch (wgp_patches.py:197-200):
target_key = f"model_def:{model_name}".
Snapshot live state: runtime = _resolve_runtime(); live = dict(runtime.models_def.get(model_name, {})).
Guard A — registry + live match: if target_key in registry AND registry[target_key].get("applied") AND all(live.get(k) == v for k, v in patch_values.items()) → return True (short-circuit; existing rollback closure preserved). This answers FLAG-004 / correctness / callers.
Guard B — registry stale, live drifted: if target_key in registry but live values don't match, call rollback_wgp_patches(patch_name=patch_name, target_key=target_key, context_id=context_id) to discard the stale closure AND restore original pre-patch state. Then fall through to fresh apply.
Fresh apply:transaction = begin_runtime_model_patch(model_name, keys=tuple(patch_values.keys())); apply_runtime_model_patch(transaction, patch_values); _register_patch_application(patch_name, target_key, applied=True, context_id=context_id, rollback=_make_runtime_model_def_rollback(transaction, len(patch_values))); the inner helper closes over the transaction and returns rollback_runtime_model_patch(transaction) then the int count.
Iterate [k for k in wgp_module.models_def.keys() if isinstance(k, str) and k.startswith("ltx2")].
For each, call apply_runtime_model_definition_patch(k, {"_banodoco_fork_runtime_patch": True}, patch_name="ltx2_runtime_fork_markers", context_id=context_id).
Wrap in try/except (RuntimeError, AttributeError, ImportError, TypeError) → return on error; return on success (including the empty-ltx2-keys case, which is soft-OK for smoke mode since the runtime has no ltx2 defs to patch).
Step 3: Prove the single-registry invariant, live-state idempotency, drift-reapply, context_id scoping, and bootstrap registration (tests/test_wgp_patch_lifecycle.py, tests/test_wgp_patch_context_contracts.py)
Scope: Small
Addtest_runtime_model_definition_patch_registers_in_single_registry in tests/test_wgp_patch_lifecycle.py:
_FakeRuntime stub per tests/test_runtime_model_patch_contracts.py:10-21, monkeypatch runtime_registry.get_wgp_runtime_module.
Apply wrapper → assert live + registry state.
rollback_wgp_patches(patch_name=…) → assert key gone from both.
Call wrapper again with identical args → assert guard short-circuited (no new transaction, live state unchanged, registry still has the original entry).
Call wrapper again → assert the value is restored to the expected True (drift-reapply path ran a fresh transaction).
Rollback → assert the key is absent (original pre-patch state, not "drifted"). This pins FLAG-004.
Addtest_runtime_model_definition_patch_respects_context_id in tests/test_wgp_patch_context_contracts.py:
Apply wrapper under "ctx.a" and "ctx.b", assert both contexts report the entry, clear_wgp_patch_context("ctx.a") isolates, try/finally tears down both.
Addtest_apply_all_wgp_patches_records_ltx2_runtime_fork_markers in tests/test_wgp_patch_context_contracts.py:
_make_dummy_wgp_module with models_def={"ltx2_22B": {}, "ltx2_22B_distilled": {}, "t2v": {}}.
Monkeypatch module-level patch helpers → True, and runtime_registry.get_wgp_runtime_module → stub runtime sharing the same models_def.
This removes the tooling-availability uncertainty called out by all_locations-v2; if .venv/bin/pip cannot install (offline sandbox), fall back to a minimal tokenizer check:
code
.venv/bin/python -c "from pathlib import Path; import re; txt=Path('.github/workflows/wan2gp-drift.yml').read_text(); assert re.search(r'(?m)^on:\s*$', txt) and 'workflow_dispatch' in txt and 'schedule' in txt and 'cron' in txt"
Document the tokenizer-check fallback in the handoff note.
Record in the Sprint 4 handoff note (Step 7.7) that the "Drift CI runs once successfully" authoritative gate is orchestrator-owned (workflow_dispatch push). Closes issue_hints-2 documentation loop.
Step 6: Publish the rebase runbook per SD-007 (docs/wan2gp-rebase-runbook.md)
Scope: Small
Createdocs/wan2gp-rebase-runbook.md sections: Cadence (monthly + event-triggered), Pre-flight (tag + green 8-file suite), Fork rebase procedure in banodoco/Wan2GP, Submodule bump in reigh-worker, Post-bump verification (8-file suite + .venv/bin/python-pinned path smoke + both patch-lifecycle smoke forms), Rollback (orchestrator-only, SD-exec-no-git reference), Drift CI interpretation (including orchestrator-owned workflow_dispatch once-through).
Cross-link to docs/wan2gp-triage.csv and scripts/sprint4/upstream_prs/.
Patch-lifecycle smoke (orchestrator / full bootstrap): ship scripts/sprint4/patch_lifecycle_smoke.py that instantiates WanOrchestrator(…), then asserts "ltx2_runtime_fork_markers" appears in get_wgp_patch_state() with ≥1 model_def:ltx2* entry. Documented as orchestrator/linux-only.
Drift CI once-through: orchestrator-owned (Step 5.4 handoff note).
Strict path-contract smoke via pinned .venv/bin/python.
Yaml-load check for drift workflow (pyyaml install or tokenizer fallback); dry-run drift diff locally.
Visual review of four drafted deliverables + handoff note + staged diff hand-off.
code
Plan metadata:
{
"version": 3,
"timestamp": "2026-04-22T02:15:34Z",
"hash": "sha256:be32bc550b07ee42999a153e651f5b97867b8195347f2450a8e3d4859ee76a9f",
"changes_summary": "Addressed the six new open flags from iteration-2 critique (the iteration-1 flags remain addressed in plan_v2 and are not re-edited). (1) FLAG-004 / correctness / callers: the idempotency guard now mirrors apply_qwen_lora_directory_patch by checking BOTH registry state AND live models_def values; if live has drifted, the guard invokes rollback_wgp_patches to discard the stale closure and restore original pre-patch state, then re-applies fresh. This also makes the helper safe for future callers that reuse the same patch_name/model_name with different patch_values (they'll fail the live-value check and get re-applied). Added a new test test_runtime_model_definition_patch_reapplies_when_live_drifted that plants a drifted value and asserts re-apply restores the expected value and rollback returns to the original pre-patch state. (2) FLAG-005 / issue_hints: pinned the strict path-contract smoke to .venv/bin/python -c \"...\" explicitly (workspace default python is 3.8.10 and fails on 3.10-only annotations in wgp_patches.py); the full smoke one-liner is inlined in Step 7.6. (3) all_locations: Step 5.3 now explicitly runs .venv/bin/pip install --quiet pyyaml before the yaml-load check, with a regex-tokenizer fallback documented for the offline-sandbox case; both paths are first-class, no external tooling (actionlint, docker) assumed. Success criteria updated to name the live-state guard, the drift-reapply test, and the pinned .venv/bin/python interpreter. No scope creep; plan stays within Sprint 4 deliverables.",
"flags_addressed": [
"FLAG-004",
"FLAG-005",
"correctness",
"issue_hints",
"all_locations",
"callers"
],
"questions": [
"Q1 \u2014 RESOLVED: Wire apply_ltx2_runtime_fork_markers_patch into apply_all_wgp_patches to satisfy the authoritative gate at docs/WAN2GP_FORK_MIGRATION_PLAN.md:176-183. Marker-first; SD-005 concrete overrides deferred.",
"Q2 \u2014 RESOLVED: Drift CI is report-only per SD-drift-ci-scope.",
"Q3 \u2014 RESOLVED: 14 upstream PR drafts aligned to the CSV's 14 literal hunk strings.",
"Q4 \u2014 Ltx2 model-def filter: the concrete patch uses k.startswith(\"ltx2\") prefix match, which also marks gguf/quant/distilled variants. Confirm prefix match is acceptable, or specify a curated list (e.g., {ltx2_22B, ltx2_22B_distilled, ltx2_22B_distilled_1_1, ltx2_22B_nvfp4}). Plan defaults to prefix match; curated list is a one-line change if preferred.",
"Q5 (new) \u2014 Offline yaml check: if .venv/bin/pip install --quiet pyyaml is blocked by a no-network sandbox, the fallback is a regex-tokenizer check that verifies , , , and appear in the yaml source. Confirm this fallback is sufficient as a Sprint-4 gate, or specify that the gate must be deferred to orchestrator environments where pyyaml is installable."
],
"success_criteria": [
{
"criterion": " imports , , and from and defines with a live-state-aware idempotency guard: short-circuits only when the registry entry is present AND still contains every requested key=value; on drift, calls then re-applies via a fresh transaction.",
"priority": "must",
"requires": [
"read_files",
"parse_diff"
]
},
{
"criterion": " registers a concrete runtime-model-definition patch () that iterates ltx2-prefixed keys and writes via the new wrapper \u2014 so bootstrap smoke finds per-model entries in alongside the seven existing module-level patches under the same registry.",
"priority": "must",
"requires": [
"read_files",
"parse_diff"
]
},
{
"criterion": "New tests prove (a) single-registry wrapper behavior incl. rollback, (b) live-state guard idempotency: second wrapper call with identical args short-circuits cleanly, (c) drift-reapply: when live is externally mutated between calls, the wrapper re-applies to restore the expected values and rollback restores the ORIGINAL pre-patch state, (d) context_id scoping: same wrapper call under two distinct context_ids both register, isolates, (e) bootstrap: populates for every ltx2 model and not for non-ltx2.",
"priority": "must",
"requires": [
"run_tests"
]
},
{
"criterion": "The full 8-file regression suite passes under (or fallback on darwin-arm64): , , , , , , , .",
"priority": "must",
"requires": [
"run_tests"
]
},
{
"criterion": " + + all pass including the five new tests.",
"priority": "must",
"requires": [
"run_tests"
]
},
{
"criterion": " exists, parses as valid YAML (via after , OR via the documented regex-tokenizer fallback), includes a weekly + , checks out submodules, compares the pinned submodule SHA against upstream HEAD, and is report-only (does not fail the job on drift; fails only on git command error).",
"priority": "must",
"requires": [
"read_files",
"run_shell"
]
},
{
"criterion": " covers: monthly cadence + event triggers (SD-007), pre-flight baseline-tag step, fork rebase steps, submodule bump in reigh-worker, post-bump verification (8-file suite + pinned-3.10 strict path smoke + both patch-lifecycle smoke forms), rollback procedure (orchestrator-only), drift CI interpretation, and explicit note that the once-through is orchestrator-owned.",
"priority": "must",
"requires": [
"read_files"
]
},
{
"criterion": " contains a + exactly 14 markdown drafts, one per literal string in the upstreamable bucket of . Each draft has Title / Summary / Affected files (grep-derived) / Verification / Review pointer. No file runs .",
"priority": "must",
"requires": [
"read_files",
"run_shell"
]
},
{
"criterion": "No git commit is created; deliverables are staged or untracked; enumerates staged files, orchestrator-owned gates (Drift CI once-through, baseline tag/commit/push, PR creation), and which yaml-check path was used.",
"priority": "must",
"requires": [
"run_shell"
]
},
{
"criterion": "Strict path-contract smoke runs via (or ), not bare ; it asserts absolute path is on and all five filesystem targets exist. Passes after Sprint 4 changes.",
"priority": "must",
"requires": [
"run_shell"
]
},
{
"criterion": "Patch-lifecycle smoke script is shipped and documented as orchestrator/linux-only (drives real bootstrap and inspects after , asserting has \u22651 entry).",
"priority": "should",
"requires": [
"read_files"
]
},
{
"criterion": "Drift CI run-once: the workflow is manually triggered successfully via after merge and reports a drift summary (orchestrator-owned gate).",
"priority": "info",
"requires": []
},
{
"criterion": "Upstream PR drafts are opened against by the orchestrator using the bodies under (orchestrator-owned gate).",
"priority": "info",
"requires": []
}
],
"assumptions": [
"Live-state guard matches the precedent: short-circuit only when BOTH registry entry exists AND live still satisfies the requested . On drift, run the existing rollback (restores original pre-patch state), then re-apply via a fresh transaction.",
" on ltx2 model defs is a private underscore-prefixed marker \u2014 collision-free and generation-path invisible. SD-005 concrete overrides (, ) can replace it in a later sprint using the same wrapper without widening Sprint 4 scope.",
" is populated before at ; smoke mode skips the wgp-import path so never runs in smoke mode \u2014 no defensive branching needed.",
"Workspace default is 3.8.10 and cannot parse 3.10 annotations in . ; no bare in any gate command.",
" is a minimal Python 3.10 smoke venv without pyyaml by default. Step 5.3 installs pyyaml via ; if pip is blocked (offline sandbox), the regex-tokenizer fallback runs and the handoff note records which path was taken.",
"Executor writes non- deliverables only, leaves changes staged, hands off via . Orchestrator owns: commits, baseline-tag moves, PR creation, and once-through of . Per SD-exec-no-git.",
"Drift CI is report-only (does not fail on drift; fails only on git command error) per SD-drift-ci-scope / SD-008.",
"14 upstream PR drafts aligned to the literal strings in ; one draft per theme; no invented groupings.",
"Two-form patch-lifecycle smoke: stub form (executor-runnable) + (orchestrator/linux-only)."
],
"delta_from_previous_percent": 63.36,
"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 the authoritative Sprint 4 section in docs/WAN2GP_FORK_MIGRATION_PLAN.md:176-183 against the proposed patch work. The plan explicitly says not to wire any concrete runtime-model-definition patch into apply_all_wgp_patches(), but the authoritative gate says the patch-lifecycle smoke must drive bootstrap to source/models/wgp/orchestrator.py:265-266 via apply_all_wgp_patches() and only then inspect get_wgp_patch_state(); with the current repo shape, apply_all_wgp_patches() still only records the seven existing module-level patches, so this plan only proves the new wrapper in isolation, not through the required bootstrap path.",
"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 executor constraints in the brief against the verification gates in docs/WAN2GP_FORK_MIGRATION_PLAN.md:174-183. The plan correctly respects the user note not to open PRs or write .git/, and it leaves changes staged, but it also defers the required 'Drift CI runs once successfully' gate to a later orchestrator workflow_dispatch, so the Sprint 4 verification set is only partially executed by the proposed work.",
"status": "addressed",
"severity": "significant"
},
{
"id": "correctness",
"concern": "Are the proposed changes technically correct?: Compared the revised runtime-wrapper guard to the existing live-target guard in source/models/wgp/wgp_patches.py:197-200. The prior rollback-closure bug is fixed, but the new guard only checks registry state (get_wgp_patch_state(context_id).get(patch_name)) and does not verify that the current model_def still contains the requested patch_values; that means a later caller can receive True even if another code path removed or changed the runtime marker, whereas the existing qwen_lora_directory guard only short-circuits when the live patched function still carries the expected _headless_patch_target_key marker.",
"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?: Searched source/, tests/, and scripts/ for begin_runtime_model_patch(), apply_runtime_model_patch(), rollback_runtime_model_patch(), and apply_all_wgp_patches(). The runtime patch primitives are currently used only in tests, while the only production bootstrap path is WanOrchestrator importing wgp and then calling apply_all_wgp_patches() in source/models/wgp/orchestrator.py:265-266, so keeping apply_all_wgp_patches() unchanged leaves the broader 'single registry in production bootstrap' symptom unresolved.",
"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 for other production callers that would need coordinated edits and did not find any beyond the orchestrator bootstrap. That means the runtime-wrapper addition itself is localized, but it also means the plan's direct helper test does not cover any existing production flow unless the orchestrator path is updated too.",
"status": "addressed",
"severity": "significant"
},
{
"id": "all_locations-1",
"concern": "Does the change touch all locations AND supporting infrastructure?: Checked the triage source file rather than the plan summary. docs/wan2gp-triage.csv has columns path,hunk,bucket,carry_location,owner,verification; there is no separate 'theme' column, and the current upstreamable rows split into 14 distinct hunk groups, not ~13, so the plan's 'theme-level drafts' success criterion is internally inconsistent with the repository data it intends to drive.",
"status": "addressed",
"severity": "significant"
},
{
"id": "all_locations-2",
"concern": "Does the change touch all locations AND supporting infrastructure?: Checked the supporting test coverage around the shared patch registry. tests/test_wgp_patch_context_contracts.py currently exercises context_id scoping only through apply_all_wgp_patches(), but the proposed new runtime-wrapper test never passes a non-default context_id even though the helper itself accepts context_id and writes into the same registry buckets, so one piece of required supporting infrastructure remains untested.",
"status": "addressed",
"severity": "significant"
},
{
"id": "callers-1",
"concern": "Find the callers of the changed function. What arguments do they actually pass? Does the fix handle all of them?: Grep shows only one production caller of apply_all_wgp_patches(): source/models/wgp/orchestrator.py:265-266, and it passes only (wgp, self.wan_root) with no context_id and no runtime-model patch arguments. Because the plan keeps that caller unchanged, none of the actual production arguments exercise the proposed runtime wrapper, so the helper sits off to the side of the real call graph.",
"status": "addressed",
"severity": "significant"
},
{
"id": "callers-2",
"concern": "Find the callers of the changed function. What arguments do they actually pass? Does the fix handle all of them?: Grep also shows begin_runtime_model_patch()/apply_runtime_model_patch()/rollback_runtime_model_patch() are called only from tests/test_runtime_model_patch_contracts.py today. Those tests use a single transaction followed by a single rollback; there is no caller coverage for repeated application, non-default context_id values, or a bootstrap-triggered invocation, so the plan does not verify the edge cases the shared patch registry already cares about.",
"status": "addressed",
"severity": "significant"
},
{
"id": "FLAG-004",
"concern": "Runtime patch wrapper: the revised idempotency guard trusts registry state only, so it can report success after the live model_def has drifted away from the requested patch_values.",
"status": "addressed",
"severity": "significant"
},
{
"id": "FLAG-005",
"concern": "Verification gates: the strict path-contract smoke is still specified as the bare one-liner from the migration doc, but the workspace default is 3.8.10 and cannot import this repo's 3.10-only source files.",
"status": "addressed",
"severity": "significant"
},
{
"id": "issue_hints",
"concern": "Did the work fully address the issue hints, user notes, and approved plan requirements?: Checked the verification commands the plan proposes to reuse from the migration doc. Section 4's strict path-contract smoke still uses bare (docs/WAN2GP_FORK_MIGRATION_PLAN.md:106-108), and the revised plan says to rerun that one-liner verbatim, but in this workspace is 3.8.10 and importing already fails on modern type-annotation syntax in source/models/wgp/wgp_patches.py, so this gate will fail unless the plan pins a 3.10 interpreter such as or .",
"status": "addressed",
"severity": "significant"
},
{
"id": "all_locations",
"concern": "Does the change touch all locations AND supporting infrastructure?: Checked the supporting tooling for Step 5.3 in the current workspace. exists and is Python 3.10, but it does not have installed, is not on PATH, and the fallback Docker image is not present locally, so the revised plan's workflow-syntax validation step still depends on tooling that is not currently available in the repo environment.",
"status": "addressed",
"severity": "significant"
},
{
"id": "callers",
"concern": "Find the callers of the changed function. What arguments do they actually pass? Does the fix handle all of them?: Checked the proposed generic helper signature against likely caller shapes. accepts arbitrary , but the revised idempotency guard keys only on and ignores current runtime values, so any future caller that reuses the same patch_name/model_name with different patch_values in the same context will silently no-op instead of applying the new values; the current plan is safe for the single marker-patch caller, but the helper API is narrower than its signature suggests.",
"status": "addressed",
"severity": "significant"
}
]
code
Known accepted debt grouped by subsystem:
{
"are-the-proposed-changes-technically-correct": [
{
"id": "DEBT-004",
"concern": "are the proposed changes technically correct?: compared the proposed worker sigterm handling to the existing lifecycle structure in source/task_handlers/queue/task_queue.py:529-579. the queue entrypoint wraps startup and steady-state in one lifecycle block, but worker main() does not enter its cleanup try/finally until source/runtime/worker/server.py:405, so the proposed handler alone is not fully correct for startup-time shutdowns.",
"occurrence_count": 1,
"plan_ids": [
"add-idle-release-feature-for-20260408-0309"
]
},
{
"id": "DEBT-008",
"concern": "are the proposed changes technically correct?: compared the documented startup limitation to the actual lifecycle boundary in source/runtime/worker/server.py. because the cleanup try/finally still begins only at line 405, the proposed sigterm handler is only correct for steady-state shutdowns and not for startup-time sigterm, so the plan remains intentionally incomplete on that case.",
"occurrence_count": 1,
"plan_ids": [
"add-idle-release-feature-for-20260408-0309"
]
}
],
"byte-compare-oracle": [
{
"id": "DEBT-010",
"concern": "clear_conditioning oracle is single-shape",
"occurrence_count": 1,
"plan_ids": [
"execute-sprint-3-of-the-20260422-0132"
]
}
],
"did-the-work-fully-address-the-issue-hints-user-notes-and-approved-plan-requirements": [
{
"id": "DEBT-002",
"concern": "did the work fully address the issue hints, user notes, and approved plan requirements?: checked the revised supervisor command against the original brief and source/task_handlers/worker/fatal_error_handler.py:443-445. rev 3 no longer claims literal argv equality and instead redefines "byte-identical" as "operator-equivalent", but the user note explicitly asked for byte-identical cli args, env, cwd, and python interpreter, so that requirement is still only partially addressed.",
"occurrence_count": 1,
"plan_ids": [
"add-idle-release-feature-for-20260408-0309"
]
},
{
"id": "DEBT-003",
"concern": "did the work fully address the issue hints, user notes, and approved plan requirements?: checked the startup-sigterm scope note against source/runtime/worker/server.py:299-405 and :535-554. the revision documents the startup-window limitation clearly, but it still leaves a user ctrl+c or sigterm during slow startup outside the cleanup path even though the brief did not carve that case out.",
"occurrence_count": 1,
"plan_ids": [
"add-idle-release-feature-for-20260408-0309"
]
}
],
"find-the-callers-of-the-changed-function-what-arguments-do-they-actually-pass-does-the-fix-handle-all-of-them": [
{
"id": "DEBT-005",
"concern": "find the callers of the changed function. what arguments do they actually pass? does the fix handle all of them?: checked caller-visible argv assumptions against source/task_handlers/worker/fatal_error_handler.py:443-445. the absolute .../worker.py child path will satisfy the current substring-based detection, but any future caller that truly requires literal argv preservation would still see a different invocation shape than the brief originally asked for.",
"occurrence_count": 2,
"plan_ids": [
"add-idle-release-feature-for-20260408-0309"
]
}
],
"search-for-related-code-that-handles-the-same-concept-is-the-reported-issue-a-symptom-of-something-broader": [
{
"id": "DEBT-007",
"concern": "search for related code that handles the same concept. is the reported issue a symptom of something broader?: searched related signal-handling code and compared worker main() to source/task_handlers/queue/task_queue.py:529-579. the queue entrypoint wraps startup and steady-state in one lifecycle block, so documenting the worker startup gap as out of scope leaves a broader shutdown-consistency difference in place rather than fully aligning with the existing pattern.",
"occurrence_count": 1,
"plan_ids": [
"add-idle-release-feature-for-20260408-0309"
]
}
],
"supervisor-invocation": [
{
"id": "DEBT-001",
"concern": "supervisor invocation: the revised plan still does not preserve a literally byte-identical worker invocation, because it explicitly redefines the requirement to mean operator-equivalent execution and still uses plus an absolute path.",
"occurrence_count": 1,
"plan_ids": [
"add-idle-release-feature-for-20260408-0309"
]
}
],
"task-registry-ic-lora-wiring": [
{
"id": "DEBT-012",
"concern": "no integration test for get_ic_lora_entry() \u2192 activated_loras/loras_multipliers wiring after dedup extraction",
"occurrence_count": 1,
"plan_ids": [
"execute-sprint-3-of-the-20260422-0132"
]
}
],
"verification-gates": [
{
"id": "DEBT-009",
"concern": "'20 anchor tests' reinterpretation as minimum count",
"occurrence_count": 1,
"plan_ids": [
"execute-sprint-3-of-the-20260422-0132"
]
},
{
"id": "DEBT-011",
"concern": "persistent 20-anchor-tests literal-reading flag",
"occurrence_count": 1,
"plan_ids": [
"execute-sprint-3-of-the-20260422-0132"
]
}
],
"worker-shutdown": [
{
"id": "DEBT-006",
"concern": "worker shutdown: startup-window sigterm remains outside the worker cleanup path, so a user ctrl+c or sigterm during db init, wgp import, or task_queue.start() still will not run the terminated-heartbeat/task_queue.stop sequence.",
"occurrence_count": 1,
"plan_ids": [
"add-idle-release-feature-for-20260408-0309"
]
}
]
}
code
Escalated debt subsystems:
[]
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/reigh-workspace/reigh-worker/.megaplan/plans/execute-sprint-4-of-the-20260422-0347/critique_output.json
Read this file first — it contains 5 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.
Every check must end with at least one finding. Never leave a findings array empty. If you found no issue, add one detailed flagged: false finding explaining what you checked and why it appears clear.
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.
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 an independent reviewer. Critique the plan against the actual repository.
Execute Sprint 4 of the Wan2GP fork migration per docs/WAN2GP_FORK_MIGRATION_PLAN.md (Sprint 4 section L163-187 is authoritative — read it first). Deliverables: (1) extend source/models/wgp/wgp_patches.py using existing runtime-patch primitives (_register_patch_application, begin_runtime_model_patch, rollback_runtime_model_patch), (2) draft upstream PR bodies for bucket (b) items into scripts/sprint4/upstream_prs/ — do NOT actually open PRs (orchestrator handles), (3) land .github/workflows/wan2gp-drift.yml per SD-008, (4) publish docs/wan2gp-rebase-runbook.md per SD-007. Run all Sprint 4 verification gates listed in the plan. Baseline tag wan2gp-mig-sprint-4-baseline already exists on reigh-worker. Sandbox rules learned from Sprints 1-3: executor cannot write .git/ or push to remotes — orchestrator handles those. uv sync fails on darwin-arm64 (decord==0.6.0 wheel gap) — build/reuse a minimal smoke venv. Do NOT commit final reigh-worker work — leave changes staged for user review.
Sprint 4 closes the migration by (a) consolidating runtime fork behavior into a single wgp_patches.py registry AND wiring a concrete runtime-model-definition patch into the bootstrap so get_wgp_patch_state() after apply_all_wgp_patches() proves the single-registry invariant through the real production path, (b) drafting upstream PR bodies for the 118 bucket-(b) rows grouped into the 14 literal hunk themes already present in docs/wan2gp-triage.csv, (c) landing a weekly drift-detection workflow per SD-008, and (d) publishing the rebase runbook per SD-007.
Explicit scope decision (resolves iter-3 architectural tension): Sprint 4 uses a single default context_id for the production apply_all_wgp_patches call. Multi-context concurrent runtime-patch isolation (where the same model is patched under two different context_ids against a shared WGP runtime) is out of scope and deferred to a follow-up sprint. The rationale: context_id scopes only the registry bookkeeping; the underlying runtime.models_def / runtime.wan_model.model_def live targets are globally shared. Fixing that is a semantic redesign (runtime isolation or copy-on-write per context) that is not a Sprint 4 deliverable per docs/WAN2GP_FORK_MIGRATION_PLAN.md:163-187. The plan therefore (i) does not ship a test that exercises same-model multi-context apply, (ii) the bootstrap-records test exercises the non-default context_id registry path without triggering the shared-runtime pitfall, and (iii) the runbook flags the deferred work for follow-up.
Key repo shape:
source/models/wgp/wgp_patches.py has _register_patch_application, get_wgp_patch_state, rollback_wgp_patches, clear_wgp_patch_context, and the context-scoped registry. apply_all_wgp_patches (wgp_patches.py:536-580) records seven module-level patches today.
Authoritative idempotency precedent: apply_qwen_lora_directory_patch (wgp_patches.py:197-225) checks registry state AND the live patched target still carries the expected marker.
source/runtime/wgp_ports/runtime_registry.py:184-222 — _RuntimePatchTransaction.__init__ (lines 189-192) writes to two live targets: runtime.models_def.setdefault(model_name, {}) (always) AND runtime.wan_model.model_def (when runtime.transformer_type == model_name and runtime.wan_model is not None). The wrapper guard and tests must cover BOTH targets to match this contract.
Bootstrap seam: source/models/wgp/orchestrator.py:265-266; wgp.models_def is populated before this line.
Readruntime_registry.py:184-222 — confirm _RuntimePatchTransaction targets BOTH runtime.models_def[model_name] AND runtime.wan_model.model_def (when transformer_type == model_name). Confirm wgp_bridge.py:19-21,94-126 re-exports the three primitives.
Readsource/models/wgp/orchestrator.py:245-267 — confirm the bootstrap seam and that wgp.models_def is populated before apply_all_wgp_patches(wgp, self.wan_root); confirm only one production caller exists, with a default context_id.
Step 2: Extend wgp_patches.py with a dual-target-aware runtime-model-def wrapper and a concrete bootstrap-wired marker patch (source/models/wgp/wgp_patches.py)
Scope: Medium
Importbegin_runtime_model_patch, apply_runtime_model_patch, rollback_runtime_model_patch from source.runtime.wgp_bridge.
Implementapply_runtime_model_definition_patch(model_name, patch_values, *, patch_name, context_id=None) with a dual-target live-state guard modeled on apply_qwen_lora_directory_patch (wgp_patches.py:197-200) AND _RuntimePatchTransaction.__init__ (runtime_registry.py:189-192):
target_key = f"model_def:{model_name}".
Resolve the live runtime via the bridge. Snapshot BOTH targets the transaction would touch:
Guard A — registry + BOTH live targets match: if target_key in registry AND registry[target_key].get("applied") AND all(live_models_def.get(k) == v for k, v in patch_values.items()) AND (if is_active: all(live_loaded.get(k) == v for k, v in patch_values.items())) → return True (short-circuit). This addresses FLAG-006 / correctness-v3 / callers-1-v3 / all_locations-v3.
Guard B — registry says applied but any live target drifted: call rollback_wgp_patches(patch_name=patch_name, target_key=target_key, context_id=context_id) to discard the stale closure AND restore the original pre-patch state the existing transaction captured, then fall through to fresh apply.
Fresh apply:transaction = begin_runtime_model_patch(model_name, keys=tuple(patch_values.keys())) — this snapshot now captures BOTH targets per lines 189-198 of runtime_registry. apply_runtime_model_patch(transaction, patch_values) writes BOTH targets per line 210. Register via _register_patch_application(patch_name, target_key, applied=True, context_id=context_id, rollback=_make_runtime_model_def_rollback(transaction, ...)); inner helper calls rollback_runtime_model_patch(transaction) — which restores BOTH targets per lines 213-222 — and returns an int count.
Addtest_runtime_model_definition_patch_registers_in_single_registry in tests/test_wgp_patch_lifecycle.py:
_FakeRuntime stub per tests/test_runtime_model_patch_contracts.py:10-21 with transformer_type=None (inactive model); monkeypatch runtime_registry.get_wgp_runtime_module.
Apply wrapper → assert runtime.models_def[model_name][key] == expected AND registry state.
rollback_wgp_patches(patch_name=…) → assert key gone from models_def AND registry.
Mutate runtime.wan_model.model_def["_banodoco_fork_runtime_patch"] = "drifted_loaded" (leaving models_def untouched) → call wrapper again → assert wan_model.model_def value restored to True AND models_def is also still True (dual-target guard re-applies whenever EITHER target drifts). This directly pins FLAG-006.
Rollback → assert BOTH targets back to pre-patch.
Addtest_apply_all_wgp_patches_records_ltx2_runtime_fork_markers in tests/test_wgp_patch_context_contracts.py (sits next to existing ):
Step 4: Draft bucket-(b) upstream PR bodies, one per literal CSV hunk theme (scripts/sprint4/upstream_prs/)
If .venv/bin/pip is blocked, fall back to the regex-tokenizer check documented in Step 7.7 handoff.
Record in the Sprint 4 handoff note (Step 7.7) that "Drift CI runs once successfully" is orchestrator-owned (workflow_dispatch push).
Step 6: Publish the rebase runbook per SD-007 (docs/wan2gp-rebase-runbook.md)
Scope: Small
Createdocs/wan2gp-rebase-runbook.md sections: Cadence, Pre-flight, Fork rebase, Submodule bump, Post-bump verification (8-file suite + pinned-3.10 strict path smoke + both patch-lifecycle smoke forms), Rollback (orchestrator-only), Drift CI interpretation.
Add a Sprint 5 followup section calling out the deferred work: "Multi-context runtime-patch isolation (context_id semantics beyond registry bookkeeping) is NOT covered by Sprint 4. If multi-context production runtime patches become needed, follow-up work must either make context_id drive a per-context runtime view (copy-on-write against runtime.models_def) or forbid same-model runtime patches under differing contexts." Cross-reference the iter-3 gate's FLAG-007 / scope-v3.
Cross-link to docs/wan2gp-triage.csv and scripts/sprint4/upstream_prs/.
Patch-lifecycle smoke (orchestrator / full bootstrap): ship scripts/sprint4/patch_lifecycle_smoke.py that instantiates WanOrchestrator(…) and asserts "ltx2_runtime_fork_markers" appears in get_wgp_patch_state() with ≥1 model_def:ltx2* entry. Orchestrator/linux-only.
Steps 4 (14 PR drafts), 5 (drift CI yaml + pyyaml prep + handoff), 6 (runbook with Sprint 5 followup section) in parallel after Step 3.
Step 7 verification last; finish with handoff note.
Validation Order
Focused patch tests (5 new tests, all covering dual-target semantics where applicable).
Full 8-file regression suite.
Strict path-contract smoke via pinned .venv/bin/python.
Yaml-load check for drift workflow (pyyaml install or tokenizer fallback); dry-run drift diff locally.
Visual review of four drafted deliverables + handoff note + staged diff hand-off.
code
Plan metadata:
{
"version": 4,
"timestamp": "2026-04-22T02:25:24Z",
"hash": "sha256:cd4657eff797a4ee886679edcf1014433e49cb4b7ff6dda2e0a1496a680f6cce",
"changes_summary": "Addressed the three open iter-3 correctness flags and took option (C) on the architectural tension flagged for tiebreaker. (1) FLAG-006 / correctness-v3 / callers-1-v3 / all_locations-v3 (dual-target live-state coverage): the guard now snapshots BOTH runtime.models_def[model_name] AND runtime.wan_model.model_def (when transformer_type == model_name and wan_model is not None), matching _RuntimePatchTransaction.__init__ at runtime_registry.py:189-192. Guard short-circuits only when registry AND both live targets match; on drift of EITHER target, it runs rollback_wgp_patches then a fresh transaction. Tests 2-4 now exercise the active-model case (transformer_type == model_name with a populated wan_model.model_def): dual-target idempotency, drift in models_def reapplies, drift in wan_model.model_def reapplies. (2) FLAG-007 / callers-2-v3 / scope-v3 (cross-context shared-runtime isolation): explicitly scoped out of Sprint 4 in the Overview, documented as a deferred follow-up in the new runbook Sprint-5 section (Step 6.2), and called out in the handoff note (Step 7.7). The problematic same-model cross-context test is REMOVED; the bootstrap-records test already covers the non-default context_id registry path via context_id=\"test.bootstrap\", which is all that Sprint 4's single-production-caller shape requires. Rationale: the gate rationale itself notes option (C) "defer multi-context semantics" is the correct call, Sprint 4 deliverables do not require cross-context runtime isolation, and shipping a test that quietly accepts broken semantics would be worse than deferring. Success criteria updated: context_id scoping criterion replaced with dual-target live-state coverage; tests criterion renumbered a-e. Plan scope tightened back to Sprint 4 deliverables per the scope-creep warning.",
"flags_addressed": [
"correctness",
"callers-1",
"callers-2",
"all_locations",
"FLAG-006",
"FLAG-007",
"scope"
],
"questions": [
"Q1 \u2014 RESOLVED: Wire apply_ltx2_runtime_fork_markers_patch into apply_all_wgp_patches; marker-first.",
"Q2 \u2014 RESOLVED: Drift CI is report-only.",
"Q3 \u2014 RESOLVED: 14 upstream PR drafts aligned to CSV's 14 literal hunk strings.",
"Q4 \u2014 Ltx2 model-def filter: k.startswith(\"ltx2\") prefix match. Confirm this includes all desired variants (22B, distilled, 1_1, nvfp4, gguf/quant) or specify a curated list.",
"Q5 \u2014 Offline yaml check: pyyaml install with tokenizer fallback for no-network sandboxes. Confirm the fallback is acceptable, or require orchestrator-side pyyaml-installed validation.",
"Q6 (new, RESOLVED by option C per gate rationale) \u2014 Multi-context runtime-patch isolation: taking option (C) \u2014 defer to follow-up sprint, document in runbook + handoff, remove the same-model cross-context test. Sprint 4 uses a single default in production. Confirm this scope decision, or specify a Sprint-4-side redesign (runtime copy-on-write per context, or disallowing same-model multi-context apply via an explicit guard)."
],
"success_criteria": [
{
"criterion": " imports , , and from and defines with a live-state idempotency guard: short-circuits only when registry says applied AND every requested key=value is present in AND (when ) every key=value is also present in . On drift of either target, calls then re-applies via a fresh transaction.",
"priority": "must",
"requires": [
"read_files",
"parse_diff"
]
},
{
"criterion": " registers which iterates ltx2-prefixed keys and writes via the new wrapper. Bootstrap smoke finds per-model entries in alongside the seven existing module-level patches under a single registry.",
"priority": "must",
"requires": [
"read_files",
"parse_diff"
]
},
{
"criterion": "New tests prove (a) single-registry wrapper behavior on inactive-model stub incl. rollback; (b) dual-target live-guard idempotency on active-model stub (transformer_type == model_name, populated wan_model.model_def): second call short-circuits and BOTH live targets remain consistent; (c) drift-reapply when ONLY models_def drifts: wrapper restores both targets; (d) drift-reapply when ONLY wan_model.model_def drifts: wrapper restores both targets (directly pins FLAG-006); (e) bootstrap via populates for every ltx2 model and not for non-ltx2, exercising the non-default context_id registry path.",
"priority": "must",
"requires": [
"run_tests"
]
},
{
"criterion": "The full 8-file regression suite passes under (or fallback on darwin-arm64): , , , , , , , .",
"priority": "must",
"requires": [
"run_tests"
]
},
{
"criterion": " + + all pass including the five new tests.",
"priority": "must",
"requires": [
"run_tests"
]
},
{
"criterion": " exists, parses as valid YAML (via after , OR via the documented regex-tokenizer fallback), includes a weekly + , checks out submodules, compares pinned submodule SHA against upstream HEAD, and is report-only.",
"priority": "must",
"requires": [
"read_files",
"run_shell"
]
},
{
"criterion": " covers: monthly cadence + event triggers (SD-007), pre-flight baseline-tag step, fork rebase steps, submodule bump in reigh-worker, post-bump verification (8-file suite + pinned-3.10 strict path smoke + both patch-lifecycle smoke forms), rollback procedure (orchestrator-only), drift CI interpretation, and a section explicitly deferring multi-context runtime-patch isolation with cross-reference to the iter-3 gate rationale.",
"priority": "must",
"requires": [
"read_files"
]
},
{
"criterion": " contains a + exactly 14 markdown drafts, one per literal string in the upstreamable bucket of . Each draft has Title / Summary / Affected files (grep-derived) / Verification / Review pointer. No file runs .",
"priority": "must",
"requires": [
"read_files",
"run_shell"
]
},
{
"criterion": "No git commit is created; deliverables are staged or untracked; enumerates staged files, orchestrator-owned gates (Drift CI once-through, baseline tag/commit/push, PR creation), which yaml-check path was used, and the explicit Sprint 5 backlog item for multi-context runtime-patch isolation.",
"priority": "must",
"requires": [
"run_shell"
]
},
{
"criterion": "Strict path-contract smoke runs via (not bare ); asserts absolute path is on and all five filesystem targets exist. Passes after Sprint 4 changes.",
"priority": "must",
"requires": [
"run_shell"
]
},
{
"criterion": "Patch-lifecycle smoke script is shipped and documented as orchestrator/linux-only (drives real bootstrap and inspects after , asserting has \u22651 entry).",
"priority": "should",
"requires": [
"read_files"
]
},
{
"criterion": "Drift CI run-once: the workflow is manually triggered successfully via after merge and reports a drift summary (orchestrator-owned gate).",
"priority": "info",
"requires": []
},
{
"criterion": "Upstream PR drafts are opened against by the orchestrator using the bodies under (orchestrator-owned gate).",
"priority": "info",
"requires": []
},
{
"criterion": "Multi-context runtime-patch isolation (same model patched under differing values against a shared WGP runtime) remains broken but is explicitly documented as a deferred Sprint 5 item; no Sprint 4 deliverable depends on it.",
"priority": "info",
"requires": []
}
],
"assumptions": [
"Dual-target semantics: the wrapper's live-state guard and all relevant tests cover BOTH AND (when ), matching at and at . Guard re-applies whenever EITHER target has drifted.",
"Sprint 4 uses a single default in the production call (orchestrator.py:265-266 passes only ). Multi-context concurrent runtime-patch isolation is explicitly deferred to a follow-up sprint and is NOT a Sprint 4 deliverable \u2014 documented in the Overview, the runbook's Sprint-5 followup section, and the handoff note. No same-model cross-context test ships.",
" on ltx2 model defs is a private underscore-prefixed marker \u2014 collision-free and generation-path invisible. Future sprints can replace it with concrete SD-005 overrides using the same wrapper.",
" is populated before at ; smoke mode skips the wgp-import path.",
"Workspace default is 3.8.10 and cannot parse 3.10 annotations in . All plan-side smoke invocations pin (3.10) or .",
" is a minimal Python 3.10 smoke venv without pyyaml. Step 5.3 installs pyyaml; if pip is blocked, the regex-tokenizer fallback runs and the handoff note records which path was taken.",
"Executor writes non- deliverables only, leaves changes staged, hands off via . Orchestrator owns: commits, baseline-tag moves, PR creation, and once-through of .",
"Drift CI is report-only per SD-drift-ci-scope / SD-008.",
"14 upstream PR drafts aligned to the literal strings in ; one draft per theme; no invented groupings.",
"Two-form patch-lifecycle smoke: stub form (executor-runnable, inactive-model branch) + (orchestrator/linux-only, real bootstrap)."
],
"delta_from_previous_percent": 32.82,
"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 the authoritative Sprint 4 section in docs/WAN2GP_FORK_MIGRATION_PLAN.md:176-183 against the proposed patch work. The plan explicitly says not to wire any concrete runtime-model-definition patch into apply_all_wgp_patches(), but the authoritative gate says the patch-lifecycle smoke must drive bootstrap to source/models/wgp/orchestrator.py:265-266 via apply_all_wgp_patches() and only then inspect get_wgp_patch_state(); with the current repo shape, apply_all_wgp_patches() still only records the seven existing module-level patches, so this plan only proves the new wrapper in isolation, not through the required bootstrap path.",
"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 executor constraints in the brief against the verification gates in docs/WAN2GP_FORK_MIGRATION_PLAN.md:174-183. The plan correctly respects the user note not to open PRs or write .git/, and it leaves changes staged, but it also defers the required 'Drift CI runs once successfully' gate to a later orchestrator workflow_dispatch, so the Sprint 4 verification set is only partially executed by the proposed work.",
"status": "addressed",
"severity": "significant"
},
{
"id": "correctness",
"concern": "Are the proposed changes technically correct?: Compared the proposed live-state guard to the actual runtime-patch transaction in source/runtime/wgp_ports/runtime_registry.py:184-222. The transaction mutates two live targets when the patched model is active \u2014 runtime.models_def[model_name] and runtime.wan_model.model_def \u2014 but the revised plan's guard probes only runtime.models_def.get(model_name, {}), so it can incorrectly short-circuit after the loaded model has drifted out of sync while models_def still matches the requested values.",
"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?: Searched source/, tests/, and scripts/ for begin_runtime_model_patch(), apply_runtime_model_patch(), rollback_runtime_model_patch(), and apply_all_wgp_patches(). The runtime patch primitives are currently used only in tests, while the only production bootstrap path is WanOrchestrator importing wgp and then calling apply_all_wgp_patches() in source/models/wgp/orchestrator.py:265-266, so keeping apply_all_wgp_patches() unchanged leaves the broader 'single registry in production bootstrap' symptom unresolved.",
"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 for other production callers that would need coordinated edits and did not find any beyond the orchestrator bootstrap. That means the runtime-wrapper addition itself is localized, but it also means the plan's direct helper test does not cover any existing production flow unless the orchestrator path is updated too.",
"status": "addressed",
"severity": "significant"
},
{
"id": "all_locations-1",
"concern": "Does the change touch all locations AND supporting infrastructure?: Checked the triage source file rather than the plan summary. docs/wan2gp-triage.csv has columns path,hunk,bucket,carry_location,owner,verification; there is no separate 'theme' column, and the current upstreamable rows split into 14 distinct hunk groups, not ~13, so the plan's 'theme-level drafts' success criterion is internally inconsistent with the repository data it intends to drive.",
"status": "addressed",
"severity": "significant"
},
{
"id": "all_locations-2",
"concern": "Does the change touch all locations AND supporting infrastructure?: Checked the supporting test coverage around the shared patch registry. tests/test_wgp_patch_context_contracts.py currently exercises context_id scoping only through apply_all_wgp_patches(), but the proposed new runtime-wrapper test never passes a non-default context_id even though the helper itself accepts context_id and writes into the same registry buckets, so one piece of required supporting infrastructure remains untested.",
"status": "addressed",
"severity": "significant"
},
{
"id": "callers-1",
"concern": "Find the callers of the changed function. What arguments do they actually pass? Does the fix handle all of them?: Checked the caller-visible contract of the runtime patch primitive rather than only the wrapper's one planned caller. is explicitly defined to patch both and, when , the currently loaded ; the revised wrapper logic and planned tests handle only the half of that contract, so they do not fully cover the active-model caller shape the underlying primitive already supports.",
"status": "addressed",
"severity": "significant"
},
{
"id": "callers-2",
"concern": "Find the callers of the changed function. What arguments do they actually pass? Does the fix handle all of them?: Checked the planned caller scenario against the current registry mechanics. Because and are keyed by context while the underlying runtime object is shared, applying the same runtime patch under and then would give a rollback closure whose snapshot already contains the patched value, so rolling back would preserve the marker instead of restoring the original unpatched state.",
"status": "addressed",
"severity": "significant"
},
{
"id": "issue_hints",
"concern": "Did the work fully address the issue hints, user notes, and approved plan requirements?: Checked the verification commands the plan proposes to reuse from the migration doc. Section 4's strict path-contract smoke still uses bare (docs/WAN2GP_FORK_MIGRATION_PLAN.md:106-108), and the revised plan says to rerun that one-liner verbatim, but in this workspace is 3.8.10 and importing already fails on modern type-annotation syntax in source/models/wgp/wgp_patches.py, so this gate will fail unless the plan pins a 3.10 interpreter such as or .",
"status": "addressed",
"severity": "significant"
},
{
"id": "all_locations",
"concern": "Does the change touch all locations AND supporting infrastructure?: Checked the proposed supporting tests against the runtime semantics the repo already documents. proves the primitive updates both and the active , but the new planned tests only assert and registry state, and the new context test clears registry buckets without asserting rollback behavior across contexts, so the supporting coverage still misses the two places where the revised design is most fragile.",
"status": "addressed",
"severity": "significant"
},
{
"id": "callers",
"concern": "Find the callers of the changed function. What arguments do they actually pass? Does the fix handle all of them?: Checked the proposed generic helper signature against likely caller shapes. accepts arbitrary , but the revised idempotency guard keys only on and ignores current runtime values, so any future caller that reuses the same patch_name/model_name with different patch_values in the same context will silently no-op instead of applying the new values; the current plan is safe for the single marker-patch caller, but the helper API is narrower than its signature suggests.",
"status": "addressed",
"severity": "significant"
},
{
"id": "FLAG-006",
"concern": "Runtime patch state: the revised live-state guard checks only , but the actual transaction also patches the active loaded model (), so split live state can go undetected.",
"status": "addressed",
"severity": "significant"
},
{
"id": "FLAG-007",
"concern": "Runtime patch contexts: scopes only registry bookkeeping, not the underlying global WGP runtime, so the new cross-context test can pass while rollback semantics across contexts remain wrong.",
"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?: Looked at the broader context machinery in source/models/wgp/wgp_patches.py:27-100 together with the global runtime mutation path in source/runtime/wgp_ports/runtime_registry.py:184-222. The new plan adds a test, but runtime-model patches still mutate one shared WGP runtime while only scopes the registry dictionaries, so the broader problem is that context bookkeeping can diverge from the single global live runtime rather than truly isolating concurrent patch contexts.",
"status": "addressed",
"severity": "significant"
}
]
code
Known accepted debt grouped by subsystem:
{
"are-the-proposed-changes-technically-correct": [
{
"id": "DEBT-004",
"concern": "are the proposed changes technically correct?: compared the proposed worker sigterm handling to the existing lifecycle structure in source/task_handlers/queue/task_queue.py:529-579. the queue entrypoint wraps startup and steady-state in one lifecycle block, but worker main() does not enter its cleanup try/finally until source/runtime/worker/server.py:405, so the proposed handler alone is not fully correct for startup-time shutdowns.",
"occurrence_count": 1,
"plan_ids": [
"add-idle-release-feature-for-20260408-0309"
]
},
{
"id": "DEBT-008",
"concern": "are the proposed changes technically correct?: compared the documented startup limitation to the actual lifecycle boundary in source/runtime/worker/server.py. because the cleanup try/finally still begins only at line 405, the proposed sigterm handler is only correct for steady-state shutdowns and not for startup-time sigterm, so the plan remains intentionally incomplete on that case.",
"occurrence_count": 1,
"plan_ids": [
"add-idle-release-feature-for-20260408-0309"
]
}
],
"byte-compare-oracle": [
{
"id": "DEBT-010",
"concern": "clear_conditioning oracle is single-shape",
"occurrence_count": 1,
"plan_ids": [
"execute-sprint-3-of-the-20260422-0132"
]
}
],
"did-the-work-fully-address-the-issue-hints-user-notes-and-approved-plan-requirements": [
{
"id": "DEBT-002",
"concern": "did the work fully address the issue hints, user notes, and approved plan requirements?: checked the revised supervisor command against the original brief and source/task_handlers/worker/fatal_error_handler.py:443-445. rev 3 no longer claims literal argv equality and instead redefines "byte-identical" as "operator-equivalent", but the user note explicitly asked for byte-identical cli args, env, cwd, and python interpreter, so that requirement is still only partially addressed.",
"occurrence_count": 1,
"plan_ids": [
"add-idle-release-feature-for-20260408-0309"
]
},
{
"id": "DEBT-003",
"concern": "did the work fully address the issue hints, user notes, and approved plan requirements?: checked the startup-sigterm scope note against source/runtime/worker/server.py:299-405 and :535-554. the revision documents the startup-window limitation clearly, but it still leaves a user ctrl+c or sigterm during slow startup outside the cleanup path even though the brief did not carve that case out.",
"occurrence_count": 1,
"plan_ids": [
"add-idle-release-feature-for-20260408-0309"
]
}
],
"find-the-callers-of-the-changed-function-what-arguments-do-they-actually-pass-does-the-fix-handle-all-of-them": [
{
"id": "DEBT-005",
"concern": "find the callers of the changed function. what arguments do they actually pass? does the fix handle all of them?: checked caller-visible argv assumptions against source/task_handlers/worker/fatal_error_handler.py:443-445. the absolute .../worker.py child path will satisfy the current substring-based detection, but any future caller that truly requires literal argv preservation would still see a different invocation shape than the brief originally asked for.",
"occurrence_count": 2,
"plan_ids": [
"add-idle-release-feature-for-20260408-0309"
]
}
],
"search-for-related-code-that-handles-the-same-concept-is-the-reported-issue-a-symptom-of-something-broader": [
{
"id": "DEBT-007",
"concern": "search for related code that handles the same concept. is the reported issue a symptom of something broader?: searched related signal-handling code and compared worker main() to source/task_handlers/queue/task_queue.py:529-579. the queue entrypoint wraps startup and steady-state in one lifecycle block, so documenting the worker startup gap as out of scope leaves a broader shutdown-consistency difference in place rather than fully aligning with the existing pattern.",
"occurrence_count": 1,
"plan_ids": [
"add-idle-release-feature-for-20260408-0309"
]
}
],
"supervisor-invocation": [
{
"id": "DEBT-001",
"concern": "supervisor invocation: the revised plan still does not preserve a literally byte-identical worker invocation, because it explicitly redefines the requirement to mean operator-equivalent execution and still uses plus an absolute path.",
"occurrence_count": 1,
"plan_ids": [
"add-idle-release-feature-for-20260408-0309"
]
}
],
"task-registry-ic-lora-wiring": [
{
"id": "DEBT-012",
"concern": "no integration test for get_ic_lora_entry() \u2192 activated_loras/loras_multipliers wiring after dedup extraction",
"occurrence_count": 1,
"plan_ids": [
"execute-sprint-3-of-the-20260422-0132"
]
}
],
"verification-gates": [
{
"id": "DEBT-009",
"concern": "'20 anchor tests' reinterpretation as minimum count",
"occurrence_count": 1,
"plan_ids": [
"execute-sprint-3-of-the-20260422-0132"
]
},
{
"id": "DEBT-011",
"concern": "persistent 20-anchor-tests literal-reading flag",
"occurrence_count": 1,
"plan_ids": [
"execute-sprint-3-of-the-20260422-0132"
]
}
],
"worker-shutdown": [
{
"id": "DEBT-006",
"concern": "worker shutdown: startup-window sigterm remains outside the worker cleanup path, so a user ctrl+c or sigterm during db init, wgp import, or task_queue.start() still will not run the terminated-heartbeat/task_queue.stop sequence.",
"occurrence_count": 1,
"plan_ids": [
"add-idle-release-feature-for-20260408-0309"
]
}
]
}
code
Escalated debt subsystems:
[]
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/reigh-workspace/reigh-worker/.megaplan/plans/execute-sprint-4-of-the-20260422-0347/critique_output.json
Read this file first — it contains 5 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.
Every check must end with at least one finding. Never leave a findings array empty. If you found no issue, add one detailed flagged: false finding explaining what you checked and why it appears clear.
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 4. 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.
Not yet included in a published release.
Wire the new patch into apply_all_wgp_patches (wgp_patches.py:552-560):
After this, the final _register_patch_application loop over results at wgp_patches.py:571-578 also registers the aggregate result under the wgp_module:<id> target key, and the per-model entries registered by the wrapper live under the same _PATCH_CONTEXT_STATE[context_id]["ltx2_runtime_fork_markers"] bucket — single registry. This fixes FLAG-001 / issue_hints-1 / scope-1 / scope-2 / callers-1.
Preserveapply_all_wgp_patches return-dict shape and the existing successful/failed summary logging; the new key just slots into results.
tests/test_wgp_patch_context_contracts.py
test_patch_state_is_context_scoped
Build a _make_dummy_wgp_module enriched with models_def={"ltx2_22B": {}, "ltx2_22B_distilled": {}, "t2v": {}}.
Monkeypatch all module-level patch-apply helpers to return True (same pattern as existing test).
Monkeypatch runtime_registry.get_wgp_runtime_module so apply_runtime_model_definition_patch sees the same models_def.
Assert get_wgp_patch_state(context_id="test.bootstrap")["ltx2_runtime_fork_markers"] contains BOTH model_def:ltx2_22B and model_def:ltx2_22B_distilled and NOT model_def:t2v. This proves the concrete patch is reachable from the bootstrap path through the same registry as module-level patches.
Per-model entries the wrapper registers under _PATCH_CONTEXT_STATE[context_id]["ltx2_runtime_fork_markers"]["model_def:<key>"] share the single registry with module-level patches; the trailing _register_patch_application loop also records the aggregate under the wgp_module:<id> target key. This answers FLAG-001 / issue_hints-1 / scope-1/2 / callers-1.
Preserveapply_all_wgp_patches return-dict shape and successful/failed summary logging.
Gate summary (executor-green vs orchestrator-owned).
Explicit orchestrator-owned list: "Drift CI runs once successfully via workflow_dispatch", baseline-tag / commit / push, PR creation against deepbeepmeep/Wan2GP.
Both smokes status (stub form executed; full form linux-only).
If pyyaml install was blocked, note the tokenizer fallback was used for yaml check.
Leave staged: git add non-.git/ Write-created paths; do NOT commit.
Docstring note: "Sprint 4 production usage is a single default context_id. Multi-context concurrent application against a shared WGP runtime is NOT safe with current semantics and is deferred to a follow-up sprint."
Implementapply_ltx2_runtime_fork_markers_patch(wgp_module, *, context_id=None): iterate [k for k in wgp_module.models_def.keys() if isinstance(k, str) and k.startswith("ltx2")], call the wrapper for each with {"_banodoco_fork_runtime_patch": True} and patch_name="ltx2_runtime_fork_markers". try/except (RuntimeError, AttributeError, ImportError, TypeError) → False; else True (empty-ltx2 case soft-OK).
Wire into apply_all_wgp_patches (between existing entries and the trailing summary-registration loop):
Preserveapply_all_wgp_patches return-dict shape and successful/failed summary logging.
test_patch_state_is_context_scoped
_make_dummy_wgp_module with models_def={"ltx2_22B": {}, "ltx2_22B_distilled": {}, "t2v": {}}.
Monkeypatch module-level patch helpers → True, and runtime_registry.get_wgp_runtime_module → stub runtime sharing that models_def with transformer_type=None (so the bootstrap exercise stays on the inactive-model branch — the active-model branch is covered by tests 2-4).
Assert get_wgp_patch_state(context_id="test.bootstrap")["ltx2_runtime_fork_markers"] contains model_def:ltx2_22B + model_def:ltx2_22B_distilled and NOT model_def:t2v.
Tear down clear_wgp_patch_context("test.bootstrap") in a try/finally.
Do NOT add a same-model cross-context test. The shared-runtime multi-context tension (FLAG-007 / callers-2-v3 / scope-v3) is explicitly out of Sprint 4 scope per the Overview's scope decision.
Executor-green vs orchestrator-owned gate summary.
Orchestrator-owned list: "Drift CI runs once successfully via workflow_dispatch", baseline-tag / commit / push, PR creation.
Both smokes status.
Which yaml-check path was used (pyyaml install or tokenizer fallback).
Explicit Sprint 5 backlog item: multi-context runtime-patch isolation is deferred (deliberate Sprint 4 scope decision; see runbook Sprint-5 followup section).
Leave staged: git add non-.git/ Write-created paths; do NOT commit.