fix: update lock PID with Worker's real process PID after spawn#295
Merged
clonable-eden merged 3 commits intomainfrom Mar 11, 2026
Merged
fix: update lock PID with Worker's real process PID after spawn#295clonable-eden merged 3 commits intomainfrom
clonable-eden merged 3 commits intomainfrom
Conversation
spawn.sh records its own PID ($$) in the issue lock, but it exits immediately after launching the Worker. This causes stale detection (kill -0) to always see a dead PID, potentially allowing duplicate Worker spawns for the same issue. Add backend_get_pid to all backends (headless, tmux, wezterm) and issue_lock_update_pid to issue-lock.sh. After backend_spawn_worker, spawn.sh now retrieves the Worker's actual PID and updates the lock. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
clonable-eden
commented
Mar 11, 2026
Owner
Author
clonable-eden
left a comment
There was a problem hiding this comment.
レビュー結果: Approve ✅
良い点
- Issue の要件(spawn.sh の $$ → Worker 実 PID への更新)を正確に実装
issue_lock_update_pidは既存の lock API パターンに忠実で、引数バリデーション・エラーハンドリングが適切spawn.shでの PID 更新が|| trueで保護されており、backend_get_pidが失敗しても spawn プロセス全体は壊れない- テストは正常系(PID 更新)、異常系(lock なし)、連携(
lock_checkとの統合)を網羅 - CI パス済み
軽微な指摘(non-blocking)
headless.sh、tmux.sh、wezterm.shのファイルヘッダーコメントがImplements 4 external API functionsのまま。backend_get_pid追加で 5 になったので、余裕があれば更新をお勧めしますbackend_get_pidの handle ファイル探索(type 省略時のls ... | head -1)が 3 バックエンドで重複しているが、これは既存のbackend_worker_alive/backend_kill_workerでも同じパターンなのでスコープ外(将来のリファクタリング候補)
backend_get_pid was added but file headers still said "4 external API functions". Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
spawn.sh is used for both Worker and Reviewer spawning, so the variable name should be agent-type neutral. BACKEND_PID clearly indicates the value comes from backend_get_pid and works for any agent type. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #294
概要
spawn.shがissue_lock_acquireで$$(自身の PID)を lock に記録するが、spawn.sh は Worker 起動後すぐに終了する短命プロセスのため、lock の PID が常に dead 状態になる。これにより stale 検知(kill -0)が誤動作し、同一 issue に対して重複 Worker が spawn される可能性があった。変更内容
issue-lock.sh:issue_lock_update_pid関数を追加(既存 lock の PID を更新)backends/headless.sh:backend_get_pid追加(handle がそのまま PID)backends/tmux.sh:backend_get_pid追加(tmux list-panes -F '#{pane_pid}')backends/wezterm.sh:backend_get_pid追加(wezterm cli list --format jsonからパース)backend-adapter.sh: External API ドキュメントを 4→5 に更新spawn.sh: spawn 後にbackend_get_pid+issue_lock_update_pidで実 PID に更新テスト
test-issue-lock.sh:issue_lock_update_pidのテスト 3 件追加(更新成功、lock なし失敗、check との連携)test-backend-headless.sh:backend_get_pidのテスト 2 件追加test-backend-dispatch.sh: API 関数チェックを 4→5 に更新