Skip to content

fix(db): age-prune webhook_events via RETENTION_POLICY#8449

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
marktech0813:fix/8381-webhook-events-retention-v2
Jul 24, 2026
Merged

fix(db): age-prune webhook_events via RETENTION_POLICY#8449
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
marktech0813:fix/8381-webhook-events-retention-v2

Conversation

@marktech0813

Copy link
Copy Markdown
Contributor

Summary

Fixes #8381

Supersedes #8430 (auto-closed after build + boot smoke test failed with runner no space left on device — unrelated to this diff; rebased onto latest main).

Test plan

  • npx vitest run test/unit/retention.test.ts (20 passed)
  • npx vitest run test/unit/selfhost-d1-size-probe.test.ts
  • Rebased onto current main

Made with Cursor

Complete the unfinished JSONbored#3896 retention coverage so inbound webhook
delivery rows stop growing unbounded and the D1 size probe monitors them (JSONbored#8381).

Co-authored-by: Cursor <cursoragent@cursor.com>
@marktech0813
marktech0813 requested a review from JSONbored as a code owner July 24, 2026 13:26
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.60%. Comparing base (add1f78) to head (a782cc2).
⚠️ Report is 14 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #8449       +/-   ##
===========================================
+ Coverage   79.34%   89.60%   +10.25%     
===========================================
  Files         791       98      -693     
  Lines       79293    22763    -56530     
  Branches    23952     3892    -20060     
===========================================
- Hits        62915    20396    -42519     
+ Misses      13414     2187    -11227     
+ Partials     2964      180     -2784     
Flag Coverage Δ
shard-1 70.17% <ø> (+12.41%) ⬆️
shard-2 96.49% <ø> (+48.81%) ⬆️
shard-3 12.28% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/db/retention.ts 96.49% <ø> (ø)

... and 693 files with indirect coverage changes

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 24, 2026
@loopover-orb

loopover-orb Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-24 13:55:18 UTC

3 files · 1 AI reviewer · no blockers · readiness 93/100 · CI green · clean

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This PR adds a `webhook_events` retention rule (90-day window on `received_at`) to `RETENTION_POLICY`, finishing the table left out of #3896, and updates all dependent test expectations (retention.test.ts, selfhost-d1-size-probe.test.ts) to match the new pruning/monitoring behavior. The change is a single, well-scoped array addition plus consistent test updates; the deletion logic, SQL injection guard, and batching in `pruneExpiredRecords` are pre-existing and untouched. Tests cover dry-run counts, actual deletion, retention-preview route output, and the D1 size-probe config now including the new table — all correctly reflecting the reachable code path.

Nits — 3 non-blocking
  • src/db/retention.ts:29 — the `90` day window is a bare literal like the other rules in the array; consider a shared `DAYS_90` constant if this literal recurs again, though matching existing style (other rules also use bare literals) is defensible.
  • The updated comment in src/db/retention.ts calls webhook_events rows 'short-lived idempotency lookups, not durable history,' which is worth double-checking against how delivery replay/idempotency actually works elsewhere in the codebase, since the prior comment explicitly called them durable replay records that must not be pruned.
  • Confirm no other code path (e.g. webhook replay/delivery-retry logic) depends on `webhook_events` rows surviving longer than 90 days before merging, since the prior test comment explicitly asserted they were durable and must not be pruned — this policy reversal is the crux of the change and should be justified beyond the code comment.

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ✅ Gate result — Passing (No configured blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #3896, #8381
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (2 linked issues).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 98 registered-repo PR(s), 15 merged, 0 issue(s).
Contributor context ✅ Confirmed Gittensor contributor marktech0813; Gittensor profile; 98 PR(s), 0 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: minor
Linked issue satisfaction

Partially addressed
This PR adds a bounded retention window for webhook_events (one of the five tables the issue names) with tests, but it does not address audit_events, ai_usage_events' 'preserve current UTC day' requirement, product_usage_events' rollup-aware pruning, or agent_context_snapshots beyond what may have pre-existed, and the PR description frames it as finishing a narrower prior issue (#3896/#8381) rathe

Review context
  • Author: marktech0813
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: not available
  • Official Gittensor activity: 98 PR(s), 0 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Start here: Triage stale or unlinked PRs.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
🧪 Chat with LoopOver

Ask LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @loopover ask &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat &lt;question&gt; answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

Full command reference: https://loopover.ai/docs/loopover-commands

🧪 Experimental — new and may change.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

@loopover-orb loopover-orb Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LoopOver approves — the gate is satisfied and CI is green.

@loopover-orb
loopover-orb Bot merged commit 32f37d5 into JSONbored:main Jul 24, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

1 participant