Skip to content

Commit a5fdc66

Browse files
committed
perf(dashboard): index webhook receipt expiry
1 parent 5cb6777 commit a5fdc66

5 files changed

Lines changed: 715 additions & 3 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ checkpoint, and status-only commits are intentionally omitted.
5959

6060
### Fixed
6161

62+
- Indexed webhook receipt expiry by receipt time to avoid scanning and sorting retained history on each accepted delivery, preserving 30-day retention and transactional cleanup.
6263
- Bounded apply/proof/comment-sync record retention to selected records and paired dependencies, avoiding unrelated archive loads during ledger finalization without changing close guards.
6364
- Kept projected GitHub reads out of the durable ETag cache so incompatible response shapes cannot hide requested reviewers from close guards. Thanks @goutamadwant! (#1242)
6465
- Normalized unexpected exact-review failures at the Worker boundary without weakening Durable Object transaction rollback. Thanks @yetval and @vincentkoc! (#1240)

‎dashboard/github-webhook-read-model.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,10 @@ export class GithubWebhookReadModelStore {
271271
watermark INTEGER NOT NULL UNIQUE
272272
) STRICT`,
273273
);
274+
this.storage.sql.exec(
275+
`CREATE INDEX IF NOT EXISTS github_webhook_read_model_deliveries_received_at_v1
276+
ON github_webhook_read_model_deliveries_v1 (received_at)`,
277+
);
274278
this.storage.sql.exec(
275279
`CREATE TABLE IF NOT EXISTS github_webhook_read_model_classes_v1 (
276280
event_class TEXT PRIMARY KEY,

‎docs/github-webhook-read-model.md‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
- Owner: ClawSweeper dashboard and queue maintainers
55
- Source of truth: `dashboard/github-webhook-read-model.ts`, `dashboard/worker.ts`, and `dashboard/exact-review-queue.ts`
66
- Last verified: this document's repository revision
7-
- Update when: ingress coverage, App subscriptions, snapshot schema, TTLs, repair policy, or consumer safety boundaries change
7+
- Update when: ingress coverage, App subscriptions, snapshot schema or indexes, TTLs, repair policy, or consumer safety boundaries change
88

99
The queue Durable Object materializes signed GitHub App deliveries into a bounded, freshness-labelled read model. It serves planning, discovery, hydration, and dashboard reads through publisher-HMAC endpoints. Each response says which webhook watermark it represents, whether the required event class has ever been observed, and whether the object is stale.
1010

@@ -27,14 +27,24 @@ Subscription readiness is detected per event class. A class remains unavailable
2727

2828
## Stored schema and bounds
2929

30-
The Durable Object assigns one monotonic repository-wide watermark to every unique GitHub delivery GUID. Per-object rows retain the source `updated_at`, delivery GUID, object watermark, receipt time, and normalized JSON. Older or duplicate deliveries can advance the global observation watermark but cannot replace a newer object row.
30+
The Durable Object assigns one monotonic repository-wide watermark to every unique GitHub delivery GUID. Per-object rows retain the source `updated_at`, delivery GUID, object watermark, receipt time, and normalized JSON. Older deliveries with previously unseen GUIDs advance the global observation watermark but cannot replace a newer object row.
3131

3232
- One item row per repository and issue/PR number.
3333
- Comments ordered by numeric ID, including deletion tombstones; at most 500 rows per item and 64 KiB per comment body.
3434
- Reviews and inline review comments stored separately with tombstones, counts, and a stable activity digest; at most 500 rows per item.
3535
- Workflow runs, jobs, check runs, and check suites; at most 1,000 current/recent objects.
3636
- Delivery GUID receipts retained for 30 days.
3737

38+
Receipt cleanup uses a single-column `received_at` index, added idempotently by
39+
the store initializer for both new and existing databases. Each accepted unique
40+
delivery and repair still prunes at most 256 receipts strictly older than the
41+
30-day cutoff, ordered by receipt time; equal timestamps have no specified tie
42+
order. Retained GUIDs return their original watermark without pruning, and a
43+
GUID can be accepted again after its receipt is pruned. The index changes only
44+
the SQLite access path, not retention, constraints, transaction rollback, or
45+
the public read-model contract. Building it on existing history has a one-time
46+
initialization cost and adds storage and receipt-write work.
47+
3848
Item snapshots are stale after 15 minutes, comment and review collections after 30 minutes, and workflow state after 5 minutes. Placeholder discovery additionally requires a successful repair census within 6 hours. Missing, stale, incomplete, unsubscribed, or gap-detected snapshots fall back to GitHub and repair the Durable Object before later reads reuse it.
3949

4050
## Read and repair endpoints

0 commit comments

Comments
 (0)