Refactor the worker idle-release feature for tier-3 structure across two repos. WORKER REPO (reigh-worker, current dir): (1) Create source/runtime/worker_protocol.py — stdlib-only, ZERO imports, single line of substance: IDLE_RELEASE_EXIT_CODE = 75. Both source/runtime/worker/server.py AND source/runtime/supervisor.py import from here, DELETE the duplicates. This removes the only real production footgun (two sources of truth for the supervisor↔worker exit-code protocol). (2) Create source/runtime/worker/idle_release.py owning all idle-release logic: IdleReleaseConfig dataclass (idle_minutes: float, grace_seconds: float, is_service_mode: bool); IdleReleaseTracker class with mark_onboarded(), record_empty_poll(), record_claim(), should_release() methods; add_cli_args(parser) helper that adds --idle-release-minutes (default 15.0) and --idle-onboarding-grace-seconds (default 60.0); is_service_mode(client_key) helper; config_from_cli(cli_args, *, client_key) factory. (3) Refactor server.py to use the tracker: delete inline _should_idle_release, _is_service_mode, IDLE_RELEASE_EXIT_CODE constant, and the inline CLI flag adds; replace the EMPTY-branch flag-and-break-and-post-loop-check pattern with a direct sys.exit(IDLE_RELEASE_EXIT_CODE) inside the loop (SystemExit propagates through the existing finally naturally). Also: rename get_oldest_queued_task_supabase → poll_next_task outright in source/core/db/task_claim.py, delete the shim, collapse _poll_next_task_impl + poll_next_task into one function (the worker poll loop is the only runtime caller — verified by earlier critique). (4) Tests: rewrite tests/test_idle_release.py to test the new IdleReleaseTracker / IdleReleaseConfig / is_service_mode / config_from_cli surface directly — no more monkeypatching server.main(). All existing assertions covered. Plus regression test asserting both server.py and supervisor.py import IDLE_RELEASE_EXIT_CODE from worker_protocol (not redefining it). APP REPO (../reigh-app): (5) Create src/shared/components/SettingsModal/hooks/useWorkerLaunchConfig.ts — owns all 6 persistent settings via usePersistentState, returns { config, setters } where config is { computerType, gpuType, memoryProfile, windowsShell, showDebugLogs, idleReleaseMinutes } and setters mirrors the same shape. SettingsModal.tsx uses this hook, drops 12 useState declarations, passes 2 props instead of 12 to GenerationSection. (6) Refactor commandUtils.ts: extract buildWorkerLaunchLine(config) helper that returns the full 'python run_worker.py --reigh-access-token ... --debug ... --wgp-profile ... --idle-release-minutes ...' line with conditional flags, used by ALL FOUR sites in getInstallationCommand and getRunCommand. New flags get added in one place. (7) Create src/shared/components/SettingsModal/commandUtils.test.ts with 6-8 unit tests: buildWorkerLaunchLine includes/excludes --debug based on showDebugLogs; appends --idle-release-minutes for all values including '0'; getInstallationCommand picks cu128 for nvidia-50 / cu124 for nvidia-30-40; getRunCommand uses run_worker.py NOT worker.py for both Linux and Windows; getRunCommand uses correct shell-specific cd-check on Windows. CRITICAL: keep CommandConfig type unchanged from external POV (existing GenerationTokenPanel test fixtures still pass). Light megaplan — minimal critique, no review, just plan → critique → finalize → execute.
Assistant
{"checks":[],"flags":[{"id":"FLAG-001","concern":"DB facade: the plan's Step 5 is not actually safe as written. source/core/db/task_claim.py exports get_oldest_queued_task_supabase, and tests/test_formatting_and_db_facade_coverage.py imports and calls that symbol directly as part of the runtime DB facade contract. Deleting the function and its __all__ entry without revising that broader contract will break the full-suite validation the plan later requires.","category":"correctness","severity_hint":"likely-significant","evidence":"source/core/db/task_claim.py:19-21,281-292 still exposes get_oldest_queued_task_supabase; tests/test_formatting_and_db_facade_coverage.py:91-117 monkeypatches and calls task_claim.get_oldest_queued_task_supabase(\"queue-a\")."},{"id":"FLAG-002","concern":"Cross-repo scope: the plan incorrectly treats as inaccessible from this session and downgrades all app-side success criteria to . In the actual workspace the app repo is present and readable, and the brief explicitly requires those changes. As written, the plan can be marked successful after worker-only work even if , , and their tests are never updated.","category":"completeness","severity_hint":"likely-significant","evidence":" is present and readable in this workspace; the referenced files exist at , , and ."}],"verified_flag_ids":[],"disputed_flag_ids":[]}
code
Plan:
# Implementation Plan: Tier-3 Refactor of Worker Idle-Release
Overview
The brief is well-researched and matches the repo state I verified. Goal is a structural refactor across two repos:
reigh-worker (this dir): extract the supervisor↔worker exit-code constant into a shared worker_protocol.py, hoist all idle-release logic out of server.py into a dedicated worker/idle_release.py module with a tracker class, replace the flag-and-break-and-post-loop-check pattern with a direct sys.exit(IDLE_RELEASE_EXIT_CODE) (SystemExit naturally propagates through the existing finally), collapse task_claim.poll_next_task to a single function with the canonical name (deleting _poll_next_task_impl, get_oldest_queued_task_supabase, and get_oldest_queued_task — verified zero external callers), and rewrite tests/test_idle_release.py to test the new tracker/config surface directly without monkeypatching server.main().
reigh-app: extract useWorkerLaunchConfig hook (consolidating 12 useState into one config object), extract buildWorkerLaunchLine(config) helper used by all four sites in commandUtils.ts, and add unit tests covering 6–8 cases. Keep CommandConfig type unchanged.
Verified in repo:
source/runtime/worker/server.py:36 defines IDLE_RELEASE_EXIT_CODE = 75 (duplicate of source/runtime/supervisor.py:12)
_should_idle_release at server.py:79, _is_service_mode at server.py:66, idle-release CLI flags at server.py:263-264
The break/post-loop-check pattern is at server.py:478-479 and server.py:606-607
task_claim.py has both _poll_next_task_impl (170) and poll_next_task (270), plus dead get_oldest_queued_task_supabase (281) and get_oldest_queued_task (165). Grep confirms zero external callers — only intra-file references.
Existing tests are in tests/test_idle_release.py and reference server._should_idle_release, server._is_service_mode, server._resolve_worker_db_client_key, task_claim.poll_next_task, and server.IDLE_RELEASE_EXIT_CODE.
The reigh-app directory is outside this session's allowed working directory — I cannot read or modify it from this worker. The plan documents the app-side work as a separate phase to be executed in the app-repo session; success criteria for that phase are listed but flagged as info.
Phase 1: Worker Repo — Shared Protocol Constant
Step 1: Create source/runtime/worker_protocol.py
Scope: Small
Create a new stdlib-only module with no imports and a single line of substance: IDLE_RELEASE_EXIT_CODE = 75. Add a one-line module docstring describing it as the supervisor↔worker exit-code protocol contract.
Step 2: Wire supervisor and server to import the constant
Scope: Small
Editsource/runtime/supervisor.py:12: replace the literal IDLE_RELEASE_EXIT_CODE = 75 with from source.runtime.worker_protocol import IDLE_RELEASE_EXIT_CODE.
Editsource/runtime/worker/server.py:36: delete the literal and import from source.runtime.worker_protocol at the top of the file (alongside other source.runtime imports).
DefineIdleReleaseConfig as a frozen @dataclass with fields idle_minutes: float, grace_seconds: float, is_service_mode: bool.
DefineIdleReleaseTracker with constructor taking an IdleReleaseConfig and an injectable clock=time.monotonic (so tests don't need to monkeypatch time):
record_empty_poll() — sets last_successful_empty_poll_at only if currently None (preserving "first empty poll wins" semantics from the existing loop).
record_claim() — clears last_successful_empty_poll_at to None (matches the last_successful_empty_poll_at = None reset at server.py:486).
should_release() -> bool — encapsulates the same five-branch logic currently in _should_idle_release. Returns False if idle_minutes <= 0, is_service_mode, onboarded_at is None, within grace, or no empty poll recorded; else True when idle threshold reached.
Defineadd_cli_args(parser: argparse.ArgumentParser) -> None adding --idle-release-minutes (default 15.0) and --idle-onboarding-grace-seconds (default 60.0) with the same dest/type.
Defineis_service_mode(client_key: str) -> bool — moves the body of server._is_service_mode here verbatim.
Defineconfig_from_cli(cli_args, *, client_key: str) -> IdleReleaseConfig — constructs a config from cli_args.idle_release_minutes, cli_args.idle_onboarding_grace_seconds, and is_service_mode(client_key).
Step 4: Refactor server.py to use the tracker
Scope: Medium
Delete_should_idle_release (server.py:79-98), _is_service_mode (server.py:66-76), and the IDLE_RELEASE_EXIT_CODE = 75 literal.
Delete the inline add_argument calls for --idle-release-minutes and --idle-onboarding-grace-seconds in parse_args() (server.py:263-264); replace with a single idle_release.add_cli_args(parser) call.
Replace the manual onboarded_at / last_successful_empty_poll_at / _idle_release_requested variables before the loop with:
python
from source.runtime.worker import idle_release as _idle_release
idle_tracker = _idle_release.IdleReleaseTracker(
_idle_release.config_from_cli(cli_args, client_key=client_key)
)
idle_tracker.mark_onboarded()
Rewrite the EMPTY branch (server.py:464-481) to call idle_tracker.record_empty_poll(), then check idle_tracker.should_release(), log, and sys.exit(IDLE_RELEASE_EXIT_CODE) directly inside the loop. SystemExit propagates through the existing try/except KeyboardInterrupt/finally and runs cleanup naturally.
Delete the _idle_release_requested flag and the post-loop if _idle_release_requested: sys.exit(...) check (server.py:606-607).
Replacelast_successful_empty_poll_at = None at server.py:486 with idle_tracker.record_claim().
Delete the is_service_mode = _is_service_mode(client_key) line (server.py:450); the tracker's config carries it now.
Step 5: Collapse task_claim.poll_next_task
Scope: Small
Editsource/core/db/task_claim.py: rename _poll_next_task_impl body to become the public poll_next_task (drop the * keyword-only marker — server already calls with kwargs at server.py:458-462).
Delete the wrapper def poll_next_task(...) at line 270.
Deleteget_oldest_queued_task_supabase (line 281) and get_oldest_queued_task (line 165) — both have zero external callers (verified by Grep).
Update__all__ (lines 13-22) accordingly: remove "get_oldest_queued_task" and "get_oldest_queued_task_supabase".
Phase 3: Worker Repo — Tests
Step 6: Rewrite tests/test_idle_release.py
Scope: Medium
Deletetest_should_idle_release_branches and replace with test_idle_release_tracker_branches: instantiate IdleReleaseTracker with an injected fake clock and walk through the same seven branches the original test covered (idle_minutes=0, service mode, no onboard, within grace, no empty poll, reached threshold, not yet at threshold). Use mark_onboarded / record_empty_poll / should_release directly.
Deletetest_is_service_mode_branches against server._is_service_mode and rewrite against idle_release.is_service_mode — same env-mode and key-matching branches (4 cases).
Addtest_record_claim_resets_idle_window: arrange tracker into a state where should_release() is True, call record_claim(), assert should_release() is False.
Addtest_config_from_cli: pass an argparse.Namespace(idle_release_minutes=7.0, idle_onboarding_grace_seconds=42.0) plus a known client_key, assert returned IdleReleaseConfig fields, including is_service_mode.
Addtest_add_cli_args_defaults: build a fresh ArgumentParser, call idle_release.add_cli_args(parser), parse [], assert defaults 15.0 and 60.0.
Updatetest_idle_release_exit_code_constant to assert that source.runtime.worker_protocol.IDLE_RELEASE_EXIT_CODE == 75 AND that both source.runtime.worker.server.IDLE_RELEASE_EXIT_CODE and source.runtime.supervisor.IDLE_RELEASE_EXIT_CODE are the same object (is) imported from worker_protocol — proves both modules import from the canonical source rather than redefining. Use inspect.getsourcefile or import ast; ast.parse(...) on both files to assert no IDLE_RELEASE_EXIT_CODE = literal remains.
Keeptest_resolve_worker_db_client_key_precedence, test_poll_next_task_outcome_mapping, and test_worker_sigterm_handler_raises_keyboardinterrupt — they exercise different code paths and need only minor updates if any imports moved.
Drop the from source.runtime.worker import server direct symbol references that no longer exist (_should_idle_release, _is_service_mode); leave imports for _resolve_worker_db_client_key and bootstrap_runtime_environment (still on server).
Run the broader suite: python -m pytest tests/ -x to catch unexpected fallout (e.g., other tests indirectly importing the deleted _should_idle_release).
Phase 4: App Repo (../reigh-app) — execute in app-repo session
These steps need to be executed in a Claude session whose working directory is reigh-app — they cannot be performed from this worker session due to permission scoping.
Create the hook owning the 6 settings via usePersistentState (computerType, gpuType, memoryProfile, windowsShell, showDebugLogs, idleReleaseMinutes).
Return{ config, setters } shape where setters mirrors config field-for-field.
RefactorSettingsModal.tsx to consume the hook, drop the 12 useState declarations, and pass 2 props (config, setters) to GenerationSection instead of 12.
CreatebuildWorkerLaunchLine(config) returning the full python run_worker.py … line with conditional --debug, --wgp-profile, --idle-release-minutes flags.
Replace all four call sites in getInstallationCommand and getRunCommand (Linux + Windows × install + run) with calls to the helper.
PreserveCommandConfig type signature exactly — existing GenerationTokenPanel test fixtures must keep passing.
Step 10: Add unit tests (src/shared/components/SettingsModal/commandUtils.test.ts)
Scope: Small
Add 6–8 tests covering:
buildWorkerLaunchLine includes --debug when showDebugLogs=true, excludes when false.
buildWorkerLaunchLine appends --idle-release-minutes <n> for all values including '0'.
getInstallationCommand picks cu128 for nvidia-50, cu124 for nvidia-30-40.
getRunCommand uses run_worker.py (not worker.py) on both Linux and Windows.
getRunCommand uses the correct shell-specific cd-check on Windows (cmd vs PowerShell).
Execution Order
Phase 1 (constant extraction) — pure plumbing, low risk, lets us verify imports cleanly.
Phase 2 (idle-release module + server refactor) — biggest behavioral diff; do tracker module first, then server, then task_claim collapse.
Phase 3 (tests) — rewrite + run.
Phase 4 (app repo) — separate session.
Validation Order
After Phase 1: python -c "from source.runtime.worker_protocol import IDLE_RELEASE_EXIT_CODE; from source.runtime.supervisor import IDLE_RELEASE_EXIT_CODE as a; from source.runtime.worker.server import IDLE_RELEASE_EXIT_CODE as b; assert a is b is IDLE_RELEASE_EXIT_CODE" — quick smoke check.
After Phase 2: python -c "import source.runtime.worker.server; import source.runtime.worker.idle_release" — confirms no circular imports or stale references.
After Phase 3: targeted pytest tests/test_idle_release.py -x, then full pytest tests/ -x.
App repo (Phase 4): npm test -- commandUtils.test (or repo equivalent), then full Vitest suite.
code
Plan metadata:
{
"version": 1,
"timestamp": "2026-04-08T03:23:13Z",
"hash": "sha256:215832a1d09f52af1a891c29b1b46b6cfae4c8f7f90fd294d034d7b68436f7b8",
"questions": [
"The brief says idleReleaseMinutes is one of the 6 persistent settings on the app side, but --idle-release-minutes is a number-typed CLI arg with a float default. Should the persisted value be a string (matching what the test bullet appends --idle-release-minutes for all values including '0' implies) or a number? I'll assume string to match the test wording.",
"For IdleReleaseTracker, should record_empty_poll() only set last_successful_empty_poll_at on the first empty poll (preserving current if last_successful_empty_poll_at is None semantics at server.py:465-466), or should every empty poll update the timestamp? I'll preserve current 'first empty poll wins' behavior, but the brief is silent.",
"For the regression test that asserts both server.py and supervisor.py import (rather than redefine) the constant, is AST-level inspection acceptable, or do you want a simpler inspect.getsource(...)-based grep? I'll use AST since it's more robust to whitespace/comment drift.",
"The brief mentions is_service_mode as both a tracker field and a module-level helper. I'm exposing it as a public function in idle_release.py AND storing the resolved boolean inside IdleReleaseConfig. Confirming that's the intended shape rather than the tracker calling is_service_mode lazily."
],
"success_criteria": [
{
"criterion": "source/runtime/worker_protocol.py exists, has zero non-stdlib imports (and ideally zero imports), and defines IDLE_RELEASE_EXIT_CODE = 75 exactly once.",
"priority": "must"
},
{
"criterion": "Neither source/runtime/supervisor.py nor source/runtime/worker/server.py contains a literal IDLE_RELEASE_EXIT_CODE = 75 assignment; both import the symbol from source.runtime.worker_protocol.",
"priority": "must"
},
{
"criterion": "source/runtime/worker/idle_release.py exposes IdleReleaseConfig, IdleReleaseTracker (with mark_onboarded, record_empty_poll, record_claim, should_release), add_cli_args, is_service_mode, and config_from_cli with the signatures specified in the brief.",
"priority": "must"
},
{
"criterion": "server.py no longer defines _should_idle_release, _is_service_mode, or the inline idle-release CLI flag adds; those responsibilities live in idle_release.py.",
"priority": "must"
},
{
"criterion": "The worker poll loop calls sys.exit(IDLE_RELEASE_EXIT_CODE) directly inside the EMPTY branch instead of setting a flag and breaking; the _idle_release_requested variable and the post-loop if _idle_release_requested: sys.exit(...) check are removed.",
"priority": "must"
},
{
"criterion": "source/core/db/task_claim.py has exactly one poll_next_task definition (no _poll_next_task_impl wrapper); get_oldest_queued_task and get_oldest_queued_task_supabase are deleted along with their __all__ entries.",
"priority": "must"
},
{
"criterion": "tests/test_idle_release.py exercises IdleReleaseTracker, IdleReleaseConfig, is_service_mode, config_from_cli, and add_cli_args directly without monkeypatching server.main(); all original assertion intents are preserved.",
"priority": "must"
},
{
"criterion": "A regression test asserts that both supervisor.py and server.py import IDLE_RELEASE_EXIT_CODE from worker_protocol (e.g., via AST inspection or is identity check) rather than redefining it.",
"priority": "must"
},
{
"criterion": "pytest tests/test_idle_release.py passes.",
"priority": "must"
},
{
"criterion": "pytest tests/ (full suite) passes with no new failures introduced by this refactor.",
"priority": "must"
},
{
"criterion": "Worker still exits with code 75 on idle release (verified by reading the EMPTY-branch code path, not just unit tests).",
"priority": "must"
},
{
"criterion": "idle_release.py is independently importable without importing server.py (no circular dependency).",
"priority": "should"
},
{
"criterion": "IdleReleaseTracker accepts an injectable clock so unit tests don't need to monkeypatch time.monotonic.",
"priority": "should"
},
{
"criterion": "server.py line count drops noticeably (target: ~50+ lines smaller) reflecting genuine extraction rather than indirection.",
"priority": "should"
},
{
"criterion": "App repo: useWorkerLaunchConfig hook exists, SettingsModal.tsx passes 2 props (config, setters) to GenerationSection instead of 12, and the 12 useState declarations are removed.",
"priority": "info"
},
{
"criterion": "App repo: buildWorkerLaunchLine(config) exists in commandUtils.ts and is the sole producer of the python run_worker.py \u2026 line at all four sites in getInstallationCommand / getRunCommand.",
"priority": "info"
},
{
"criterion": "App repo: commandUtils.test.ts covers the 6\u20138 cases listed in the brief; CommandConfig type signature is unchanged and existing GenerationTokenPanel test fixtures still pass.",
"priority": "info"
}
],
"assumptions": [
"The reigh-app phase will be executed in a separate Claude session whose CWD is ../reigh-app; this session can only complete worker-repo phases 1\u20133.",
"record_empty_poll() preserves current 'first empty poll wins' semantics (only sets the timestamp when previously None); record_claim() resets it to None.",
"IdleReleaseTracker accepts an injectable clock callable defaulting to time.monotonic, so tests can drive time without monkeypatching.",
"Replacing the break + post-loop sys.exit(IDLE_RELEASE_EXIT_CODE) with an inline sys.exit(...) is safe: SystemExit is not caught by except KeyboardInterrupt or except FatalWorkerError, so it propagates straight to the existing finally which already runs guardian shutdown, heartbeat, and task_queue.stop().",
"get_oldest_queued_task_supabase and the zero-arg get_oldest_queued_task have zero callers outside task_claim.py itself (verified via Grep) \u2014 safe to delete with no shim.",
"CommandConfig type signature stays unchanged from the external POV in the app repo so existing GenerationTokenPanel test fixtures keep passing.",
"The new worker_protocol.py lives at source/runtime/worker_protocol.py (sibling of supervisor.py and the worker/ package) so both modules can reach it without restructuring imports.",
"Existing tests test_resolve_worker_db_client_key_precedence, test_poll_next_task_outcome_mapping, and test_worker_sigterm_handler_raises_keyboardinterrupt continue to live in test_idle_release.py (or move) but are not rewritten \u2014 only updated for any moved imports."
],
"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"
]
}
],
"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"
]
}
],
"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/refactor-the-worker-idle-20260408-0520/critique_output.json
Review the plan with a broad scope. Consider whether the approach is correct, whether it covers
all the places it needs to, whether it would break callers or violate codebase conventions,
and whether its verification strategy is adequate.
Place any concrete concerns in the flags array in the template file using the standard format
(id, concern, category, severity_hint, evidence). Leave checks as an empty array.
Workflow: read the file → investigate → read file again → add findings → write file back.
code
Additional guidelines:
- Robustness level: light. Be pragmatic. Only flag issues that would cause real failures. Ignore style, minor edge cases, and issues the executor will naturally resolve.
- 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.