Repository navigation
fix: session-guard の生存判定・reap認可を安全側へ統一する - #427
Merged
Merged
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
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 #423
session-guard の pid 生存判定を alive / dead / unknown の三値へ統一し、死亡証明を要する経路(reap・verify-exit)と生存証明を要する経路(authorizeRecovery・session confirmation)が unknown を証拠にしないよう fail-closed 化した。
変更点
session-guard.mjspidLiveness(pid): kill(pid,0) 成功・EPERM →alive、ESRCH のみ →dead、それ以外の errno / 非 errno throw / 不正 pid →unknown。pidAliveは「証明済み alive」の boolean view として維持(alive-only consumer 向け)。livenessValue: 注入 probe の戻り値を正規化。tri-state 文字列と legacy boolean を受理し、それ以外(null/undefined/任意値)はunknown。runnerLiveness(): listRuns / reapRun 共有の runner 判定。alive + start stamp 不一致 → 再利用として dead、alive + stamp 読取不可 → unknown、probe throw → unknown。reapRun: runnerunknown→REFUSED / RUNNER_LIVENESS_UNKNOWN(scan・osascript 不実行・marker 保持)。attested aePid の liveness unknown →REFUSED / ATTESTED_PID_LIVENESS_UNKNOWN(従来は CLEAN と誤判定し marker を閉じていた)。attested pid の start stamp 読取不可 →REFUSED / PID_IDENTITY_UNKNOWN(従来は PID_REUSED に混同)。listRuns:runnerLivenessを出力に追加し、reapBlockReasonにRUNNER_LIVENESS_UNKNOWNを追加。runnerAlive/reapableは unknown を false 側へ倒す。recovery-orchestrator/orchestrator.mjsauthorizeRecovery:probes.pidLiveness(tri-state)を優先受理、legacypidAliveも後方互換で受理。runner / aePid ともalive証明のみ許可。dead → 従来通り refuse、unknown → refuse(理由を区別)。記録済み start stamp が probe で null(読取不可)→ identity unproven として refuse(従来は素通りしていた)。stamp probe 自体が無い場合も unreadable 扱い。confirmGuiSession:deps.pidLiveness優先、unknownは confirmed:false(従来は pidAttribution "dead" に化けて confirmed:true になり得た)。verifyHostExit:pidLivenessprobe を追加受理。process channel がunknownを表現可能になり、clean / crash-verified に進まない。legacypidAliveは false→dead の従来意味を維持。recovery-orchestrator/cli.mjs: recover の probes・confirmSession・verify-exit にpidLivenessを配線。devtools-cli/cli.mjs: doctor 出力にrunnerLivenessを追加。誤判定→mutation 経路(T001)
pidAliveは EPERM 以外の全エラー(ESRCH 以外の予期しない errno 含む)を dead 扱い → reapRun が RUNNER_ALIVE gate を通過 → ownership/attestation/app identity を経て osascript quit(AE 終了 mutation)へ到達し得た。検証
node devtools-cli/tests/run.mjs: 65 tests passed(新規 8 件: pidLiveness/pidAlive/livenessValue 契約、RUNNER_LIVENESS_UNKNOWN・ATTESTED_PID_LIVENESS_UNKNOWN・PID_IDENTITY_UNKNOWN・listRuns unknown・marker 保持)。node recovery-orchestrator/tests/run.mjs: 69 passed(新規 3 件: authorizeRecovery unknown/stamp-unreadable、confirmGuiSession unknown、verifyHostExit unknown)。node scripts/check-syntax.mjs: 144 files pass。aeProcessSnapshot(real-run-kit、今回未変更)のpsexec が散発的に timeout する既存フレークを観測。単独再実行では green。今回の diff とは無関係。スコープ外・維持事項
defaultPidAlive(ESRCH-only death)は lease inspection 用に ae-a8n 側の契約として維持し、本 repo 側の death-proof 経路とは意図的に別 semantics。