Land verified WI-4942 dispatcher release chain - #44
Conversation
soft_reset now prunes stale/orphaned dispatch-runs sidecars (workers with an exit_code present, or dead/unparseable PIDs) so the live-worker count is accurate after a soft reset and cannot spuriously saturate the per-cycle LO ceiling. Genuinely-live workers (PID alive, no exit_code) are preserved - a soft reset must not drop a live worker. Adds DISPATCH_RUNS_DIR_NAME, _dispatch_run_pid_alive (local liveness probe, preserving module dep direction), _prune_stale_dispatch_runs, and ResetResult.stale_dispatch_runs_pruned. Purely additive; hard_reset inherits via soft_reset. 4 spec-derived tests pass; ruff check + format clean. Bundles proposal -001, Cursor GO -002, report -003. Project: PROJECT-GTKB-DISPATCHER-RELIABILITY / WI-4861 PAUTH: PAUTH-PROJECT-GTKB-DISPATCHER-RELIABILITY-DAEMON-RESIDUE-CLEANUP-2026-06-27 DELIB-20266268 (owner AUQ S20260627) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 174e8c5f15
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| with contextlib.suppress(Exception): | ||
| import signal | ||
|
|
||
| os.killpg(os.getpgid(pid_int), signal.SIGKILL) |
There was a problem hiding this comment.
Avoid killing the inherited process group
On POSIX, a drain timeout calls os.killpg(os.getpgid(pid_int), SIGKILL) for a dispatched worker, but the trigger launches workers without creating a new session/process group on non-Windows, so the wrapper inherits the caller's process group. In that environment, draining one stuck worker can SIGKILL unrelated processes in the same group, including the invoking shell/harness, rather than just the worker tree; use a PID-scoped tree kill or ensure dispatched workers are started in their own process group before using killpg.
Useful? React with 👍 / 👎.
| pid_create_time = _pid_create_time_epoch(process.pid) | ||
| meta.update({"launched": True, "pid": process.pid}) | ||
| if pid_create_time is not None: | ||
| meta[PID_CREATE_TIME_META_KEY] = pid_create_time | ||
| # WI-4472: live-process accounting sidecar. Written only for a | ||
| # successful launch; consumed by _count_live_dispatched_processes. | ||
| try: | ||
| (runs_dir / f"{dispatch_id}.pid").write_text(str(process.pid), encoding="utf-8") | ||
| if pid_create_time is not None: | ||
| (runs_dir / f"{dispatch_id}{PID_CREATE_TIME_SUFFIX}").write_text( | ||
| f"{pid_create_time:.6f}", | ||
| encoding="utf-8", | ||
| ) |
There was a problem hiding this comment.
Declare psutil before requiring PID provenance
In environments without psutil installed (it is not declared in groundtruth-kb/pyproject.toml or the test requirements), _pid_create_time_epoch() returns None here, so successful launches omit the .create_time_epoch sidecar. The new live-worker accounting and drain paths now require that sidecar to count or terminate a worker, which means fresh dispatches are immediately treated as non-live/stale and the concurrency cap/drain protection is effectively disabled on clean installs.
Useful? React with 👍 / 👎.
| try: | ||
| if tmp.exists(): | ||
| tmp.unlink() | ||
| except OSError: |
| json.dumps(list(merged.values()), sort_keys=True), | ||
| encoding="utf-8", | ||
| ) | ||
| except OSError: |
| import pytest | ||
| from click.testing import CliRunner | ||
|
|
||
| import groundtruth_kb.bridge_dispatch_reset as reset_module |
🧪 Test & Coverage Report
Lowest Coverage
|
Summary
research-branch approach by excluding WI-4944 and later unresolved daemon/runtime/topology work.Verification
python -m pytest groundtruth-kb/tests/test_bridge_dispatch_reset.py platform_tests/scripts/test_bridge_dispatch_config.py platform_tests/groundtruth_kb/cli/test_bridge_config_cli.py -q --tb=short21 passed, 1 warning189 passed, 1 warningscripts/update_wiki_pages.py compare --project-root ... --wiki-dir .tmp/groundtruth-kb.wiki --jsondrift_count=0;Release-Health.mdcurrentscripts/gtkb_dashboard/refresh_dashboard_db.py --db-path .tmp/gtkb-dashboard-health-full.sqlite --project-root ...completedNotes
researchapproach and does not include WI-4944 or later unresolved daemon/runtime/topology changes.git diff --check origin/main..HEADreports CRLF/trailing-whitespace noise in committed cherry-picked files; the branch is otherwise clean and functionally verified.