Skip to content

fix: session-guard の生存判定・reap認可を安全側へ統一する - #427

Merged
rebuildup merged 1 commit into
release-0-9-0from
423
Nov 26, 2026
Merged

rebuildup merged 1 commit into
release-0-9-0from
423

Conversation

@rebuildup

Copy link
Copy Markdown
Contributor

概要

Closes #423

session-guard の pid 生存判定を alive / dead / unknown の三値へ統一し、死亡証明を要する経路(reap・verify-exit)と生存証明を要する経路(authorizeRecovery・session confirmation)が unknown を証拠にしないよう fail-closed 化した。

変更点

  • session-guard.mjs
    • 新規 pidLiveness(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: runner unknown → 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.mjs
    • authorizeRecovery: probes.pidLiveness(tri-state)を優先受理、legacy pidAlive も後方互換で受理。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: pidLiveness probe を追加受理。process channel が unknown を表現可能になり、clean / crash-verified に進まない。legacy pidAlive は 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)へ到達し得た。
  • candidates 0 件時に attested aePid の liveness が unknown → 旧実装は CLEAN と判定し marker を削除(証拠喪失 + false clean)。
  • authorizeRecovery は stamp probe が null を返しても素通り → PID 再利用・identity 不明のまま GUI mutation 認可へ進み得た。
  • verifyHostExit / confirmGuiSession は boolean probe の false を dead として扱い、unknown を clean / dead 帰属へ化けさせ得た(false green)。

検証

  • レベル: automated test(fake/injected probe レベル。実 AE・実 GUI なし。real-host 受入は freeze 後の包括実機受入に委譲)。
  • 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。
  • mcp-server / vscode-extension / dev-loop / trusted-execution / scripting-adapters / a8n-transport / diagnostics / jsx-toolchain / cep-extension / agent-loop / vscode-debugger: 全 green。
  • 補足: 負荷時に aeProcessSnapshot(real-run-kit、今回未変更)の ps exec が散発的に timeout する既存フレークを観測。単独再実行では green。今回の diff とは無関係。

スコープ外・維持事項

  • run marker / CLI / MCP / VSCode の残留診断経路は維持(marker 保持・reapable 表示ともに fail-closed 側へ)。
  • AE host 認可の最終正本は ae-a8n(ADR-0005 D2/D7)。ownership/attestation ゲートは変更なし。
  • ae-a8n の defaultPidAlive(ESRCH-only death)は lease inspection 用に ae-a8n 側の契約として維持し、本 repo 側の death-proof 経路とは意図的に別 semantics。

@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0a937375-f8cf-4b16-b398-2ca774e7e882

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@rebuildup
rebuildup marked this pull request as ready for review November 26, 2026 14:33
@rebuildup
rebuildup merged commit efe5c74 into release-0-9-0 Nov 26, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant