Skip to content

fix(timekeeper): セッション・ハングによる無言の永続停止を防止 (#128) - #129

Merged
rebuildup merged 1 commit into
release-0-3-5from
128
Nov 22, 2026
Merged

rebuildup merged 1 commit into
release-0-3-5from
128

Conversation

@rebuildup

Copy link
Copy Markdown
Collaborator

Summary

Issue #128 対応。2026-11-22 の本番障害 (タイムキーパー無発火・ログ保持圧縮) の再発防止。

  • スケジュール・タイマー発火時に timekeeper session timer fired を info ログ出力し、「タイマー不発」と「セッション内ハング」を切り分け可能に
  • runSession の pre-flight (チャンネル解決・voice connect・engagement 生成) にタイムアウトを付与し、REST ゾンビ化を fail-loud 化
  • セッション・ウォッチドッグ (総時間 + 10分マージン) を追加。超過時に generation をインクリメントして旧ループを abort、voice connection を破棄、割り込みセッションを永続化し、次回分を必ず再スケジュール — 「一度ハングしたら永久停止」を構造的に解消
  • セッション実行後の再スケジュールで同一 startAt を再武装しない (pre-start 失敗時のゼロディレイ・ホットループ防止。テストで実際に再現・修正)
  • scheduled-announcements の idle ログを遷移時1回のみに削減 (約1440行/日 → ログ保持期間の圧縮を解消)

Test plan

  • bun run lint / bun run type-check / bun run biome グリーン
  • tests/timekeeper-watchdog.test.ts 新規: pre-flight ハング時の翌日再スケジュール、ウォッチドッグによる abort + connection 破棄 + 翌日再発火を検証
  • tests/scheduled-announcements.test.ts: idle ログが複数 tick で1回のみ出力されることを検証
  • bun run test: 1051 件パス (anon-audit-store の POSIX 権限テスト2件は Windows 環境起因の既存失敗で本変更と無関係)

Generated with Devin

A wedged runSession (unbounded Discord REST / storage await) previously
left the daily schedule disarmed forever: the reschedule only ran in
.finally, which never fires for a hung promise, and nothing logged
between the schedule timer and the first session event.

- Log when the schedule timer fires so timer-vs-session hangs are
  distinguishable in logs.
- Bound pre-flight awaits (channel resolution, voice connect, session
  engagement) with timeouts so a zombie gateway fails loudly.
- Add a session watchdog (session budget + margin) that bumps a
  generation counter, destroys the tracked voice connection, persists
  the interrupted session, and re-arms the next day even when
  runSession never settles.
- Skip re-arming the same start slot after a run so a pre-start
  failure cannot hot-loop on a zero delay.
- Log the scheduled-announcements idle transition once instead of every
  60s tick, which was flooding ~1440 lines/day and shrinking log
  retention to ~2.5 days.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Nov 22, 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: 8fb4d719-51ae-4fa0-9866-d10f1bfb4de0

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 22, 2026 13:48
@rebuildup
rebuildup merged commit 4300838 into release-0-3-5 Nov 22, 2026
6 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