Skip to content

fix(db): retain notification_deliveries on the same 90d schedule as webhook_events - #8941

Merged
loopover-orb[bot] merged 2 commits into
JSONbored:mainfrom
galuis116:fix/8899-notification-deliveries-retention
Jul 26, 2026
Merged

fix(db): retain notification_deliveries on the same 90d schedule as webhook_events#8941
loopover-orb[bot] merged 2 commits into
JSONbored:mainfrom
galuis116:fix/8899-notification-deliveries-retention

Conversation

@galuis116

Copy link
Copy Markdown
Contributor

Summary

  • Add { table: "notification_deliveries", column: "created_at", days: 90 } to RETENTION_POLICY, matching the append-only sibling webhook_events.
  • Use anonymous ? cutoff binds in pruneExpiredRecords so node:sqlite tests (and D1) bind reliably.
  • Add a prune test that deletes expired notification_deliveries rows and keeps recent ones.

Closes #8899

Scope

  • The PR title follows type(scope): short summary Conventional Commit format, for example fix(api): restore profile access checks.
  • This PR is focused and does not mix unrelated backend, UI, MCP, docs, dependency, and deploy changes.
  • This follows CONTRIBUTING.md and does not reintroduce GitHub Pages, VitePress, site/, or CNAME.
  • I linked a currently open issue this PR resolves (e.g. Closes #123) — a linked open issue is required for every contributor PR.

Validation

  • git diff --check
  • npx vitest run test/unit/retention.test.ts -t "notification_deliveries|webhook_events older|policy only targets" (3 passed)
  • npx vitest run test/unit/selfhost-pg-retention.test.ts -t "translates the numbered" (1 passed — cutoff still becomes $1)
  • New or changed behavior has unit/integration tests for new branches, fallback paths, and sanitizer boundaries

If any required check was skipped, explain why:

  • Narrow retention-policy addition; focused vitest cover. Full monorepo typecheck/coverage not re-run locally.

Safety

  • No secrets, wallet details, hotkeys, coldkeys, user PATs, private keys, raw trust scores, private rankings, or private maintainer evidence are exposed.
  • Public GitHub text stays sanitized, low-noise, and does not imply compensation guarantees or optimization tactics.
  • Auth, cookie, CORS, GitHub App, Cloudflare, or session changes include negative-path tests.
  • API/OpenAPI/MCP behavior is updated and tested where needed.
  • UI changes use live API data or real empty/error/loading states, not production mock/demo fallbacks.
  • Visible UI changes include a UI Evidence section below with JPG/JPEG or PNG screenshots arranged as organized, captioned, clickable thumbnails. SVG screenshots are not used as review evidence. Review-only screenshots or recordings are not committed to the repository.
  • Public docs/changelogs are updated where needed; changelogs are only edited for release-prep PRs.

UI Evidence

N/A — DB retention policy only; no UI surface change.

Notes

…ebhook_events

notification_deliveries is an append-only delivery log with created_at and
an index ready for pruning, but it was missing from RETENTION_POLICY so rows
accumulated forever. Add the 90-day rule and cover prune behavior.

Closes JSONbored#8899
@galuis116
galuis116 requested a review from JSONbored as a code owner July 26, 2026 13:53
@superagent-security

Copy link
Copy Markdown
Contributor

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

@codecov

codecov Bot commented Jul 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.58%. Comparing base (1eeaae1) to head (6452275).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8941      +/-   ##
==========================================
+ Coverage   90.56%   90.58%   +0.02%     
==========================================
  Files          96       97       +1     
  Lines       22490    22547      +57     
  Branches     3884     3904      +20     
==========================================
+ Hits        20367    20424      +57     
  Misses       1945     1945              
  Partials      178      178              
Flag Coverage Δ
backend 100.00% <100.00%> (?)

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

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

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

loopover-orb Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-26 14:19:15 UTC

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

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This PR adds notification_deliveries to RETENTION_POLICY with the same 90d window as webhook_events, and separately fixes retentionWhere to use anonymous `?` binds instead of numbered `?1` since node:sqlite's DatabaseSync rejects numbered binds — both changes are correct given only one placeholder is ever bound per query call in pruneExpiredRecords. The new test correctly seeds notification_deliveries rows at 100/95/1 days old and verifies exactly the 2 old rows are pruned while the recent one is kept, matching the real code path (not a fabricated scenario). The diff is narrow, well-tested, and consistent with the existing sibling pattern for webhook_events.

Nits — 3 non-blocking
  • src/db/retention.ts:31 — the `90` day literal is unexplained by itself, but this matches the existing convention of inline day literals for every other RETENTION_POLICY entry, so it's not a new inconsistency.
  • test/unit/retention.test.ts's new notification_deliveries test doesn't assert the RETENTION_POLICY membership check inline with the other prune tests' style — minor structural nit, not a defect.
  • Confirm there's no existing migration gap for notification_deliveries — since the test only inserts, it implies the table already exists pre-PR, so no migration is needed for this policy-only change.

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 #8899
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 (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 1858 registered-repo PR(s), 1210 merged, 54 issue(s).
Contributor context ✅ Confirmed Gittensor contributor galuis116; Gittensor profile; 1858 PR(s), 54 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: moderate
Linked issue satisfaction

Addressed
The PR adds the exact RETENTION_POLICY entry requested for notification_deliveries with a 90-day window matching webhook_events, and includes a dedicated test that inserts old/recent rows and confirms pruneExpiredRecords deletes only the expired ones via the existing index.

Review context
  • Author: galuis116
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: JavaScript, Python, TypeScript, Dart, HTML, MDX, Rust, C++
  • Official Gittensor activity: 1858 PR(s), 54 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 f59db68 into JSONbored:main Jul 26, 2026
8 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

Development

Successfully merging this pull request may close these issues.

fix(db): notification_deliveries is missing from RETENTION_POLICY, unlike its structurally identical sibling webhook_events

1 participant