feat(worker): auto-purge processed events on mark_processed in WebhookStore DO#235
Merged
liplus-lin-lay merged 1 commit intoJun 25, 2026
Conversation
DO 移行 (#71) で失われた auto-purge 機能 (#29) を WebhookStore DO に再移植する。 mark_processed 実行時に processed=1 かつ received_at が保持期間 (PURGE_AFTER_DAYS 日, 既定 7) より古いイベントを DELETE し, 処理済み死蔵行による DO ストレージ肥大を止める。 未処理イベントは保持期間に関わらず削除しない。戻り値に削除件数 purged を追加した。 env 型は store.ts にローカル最小定義 (StoreEnv) し index.ts の Env への循環 import を避けた。 wrangler.toml の [vars] に PURGE_AFTER_DAYS=7 を追加。docs/0-requirements{,.ja}.md に auto-purge 仕様 (F2.4 / F3.5 purged 戻り値 / N2.7 構成) を同一 PR で復活させた。 既存 store.test.ts の mark-processed テストは絶対日付 received_at が 7 日 purge で即削除 され壊れるため, received_at を now 相対に変更して新挙動へ整合させた。保持期間超過の処理済み 削除 / 未処理は残す / purged 件数の検証テストを追加 (DO テスト 25→28)。 Refs #29 #71 Closes #234
7 tasks
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
github-webhook-mcp | 289bfe3 | Jun 25 2026, 05:01 PM |
liplus-lin-lay
commented
Jun 25, 2026
liplus-lin-lay
left a comment
Member
Author
There was a problem hiding this comment.
AI セルフレビュー (auto mode / 親)
差分を確認し、完了条件 7 項目すべて達成を確認。
- purge ロジック: mark_processed 時に
processed=1 AND received_at < cutoffを DELETE。cutoff = now - PURGE_AFTER_DAYS 日。received_at/cutoff とも ISO8601 UTC で文字列順序比較が時系列順と整合 (received_at は ingest 側でサーバ生成、クライアント非制御)。 - 未処理イベントは age に関わらず保持 (テスト purge-keeps-unprocessed で検証)。
- 戻り値 purged 件数 = cursor.rowsWritten。
- env: DurableObject + ローカル最小型で循環 import 回避。PURGE_AFTER_DAYS 未設定/非数値/負値は既定 7 にフォールバック、0 は即削除。
- 既存テスト整合: 旧 mark-processed テストを now 相対 received_at に修正。pending-events テストは e3 が purge されても pending から外れる主張は不変で green 維持。
- scope: quota decrement 連動は意図的に対象外 (別軸、別 issue 候補)。
- 成果物言語: PR/commit title とも ASCII。
判定: PASS。auto mode につき squash merge を実行する。
This was referenced Jun 25, 2026
Closed
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.
概要
DO 移行 (#71) で失われた auto-purge 機能 (#29 / PR#30) を Durable Objects 版
WebhookStoreに再移植する。処理済み webhook イベントの無制限蓄積による DO ストレージ肥大を止める。変更内容
mark_processed実行時にprocessed=1かつreceived_atが保持期間より古いイベントをDELETE。未処理イベントは保持期間に関わらず削除しない。戻り値に削除件数purgedを追加。env 型はStoreEnvとしてローカル最小定義し、index.tsのEnvへの循環 import を回避。[vars]にPURGE_AFTER_DAYS = "7"を追加(保持期間, 既定 7 日,0で即削除)。received_atが 7 日 purge で即削除され壊れるため、received_atを now 相対に変更して新挙動へ整合。purge 検証テストを 3 本追加(保持期間超過の処理済み削除 / 未処理は残す /purged件数)。purged戻り値 / N2.7PURGE_AFTER_DAYS構成)。完了条件の対応
テスト
ローカルで
npm test全 green(tsx 単体 54 / DO テスト 28)。wrangler deploy --dry-run成功、PURGE_AFTER_DAYS ("7")バインド確認済み。scope out
events_stored) の decrement 連動は本 PR の対象外(軸が別, 別 issue 候補)。Refs #29 #71
Closes #234