Skip to content

Monitor/watch.sh が resume・recycle で死ぬ(process-bound + Windows liveness 不全) #5

Description

@orangewk

症状

Claude Code の Monitor(watch.sh を背景で回し real-time にメッセージを stream)が、セッションの resume / clear / recycle のたびに stopped になり、real-time 配信にギャップが出る。長いセッション中、繰り返し発生("SessionStart resume" → "Monitor stopped" の連発)、その間の着信は pull(inbox.sh)で回収する運用を強いられた。hub-relay 検証の最中にも発生し、real-time 確認を阻害した。

根本原因(2層)

  1. process-bound: Monitor は当該 Claude Code プロセスに紐づく。resume/clear で旧プロセスごと Monitor task が teardown(harness の expected 動作)。再 establish は SessionStart hook の再発火+手動 re-invoke 依存で、ギャップが出る。
  2. Windows liveness 不全: watch.sh の #67 liveness guard は agent pid(composite instance-id)で生死判定するが、Windows/claude-code では agent pid が解決できず bare instance-id になる → 判定/handoff が機能不全 → orphan watcher が残る("watch processes: N alive" の混乱、clean な handoff 不能)。

観測(本セッション)

  • "Monitor stopped" 通知が resume のたびに発生。
  • delivery.sh status が "2 alive" を示すが、当該セッションの受信可否を反映しない(私も何度も「効いてる?」を誤判断)。
  • real-time 取りこぼし → pull 回収を反復。

提案(fix 候補)

  • held-connection liveness 化rt-monitor-rnd/design-supervisor-liveness.md): 配達接続の生死=セッションの生死。ping/pid 非依存、idle 強い、resume は drop/reconnect で明示 → orphan/ギャップ解消。
  • Windows の agent-pid 解決を直す(bare instance-id を無くす)→ liveness guard を機能させる。
  • per-session の monitor 状態 status(live か / 最終受信時刻 / 購読中 seat)。
  • turn(Stop hook) backstop を既定 on(both) で push 死亡時の無言取りこぼしを防止。

関連

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions