Skip to content

refactor(selfhost): remove or wire the dead checkAndMarkDelivery helper#2572

Merged
JSONbored merged 1 commit into
mainfrom
fix/remove-dead-check-and-mark-delivery
Jul 2, 2026
Merged

refactor(selfhost): remove or wire the dead checkAndMarkDelivery helper#2572
JSONbored merged 1 commit into
mainfrom
fix/remove-dead-check-and-mark-delivery

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

  • checkAndMarkDelivery (the documented webhook-delivery-dedup helper in src/selfhost/redis-cache.ts) was exported but never called anywhere in src/. The real webhook dedup path in src/server.ts implements its own get-then-set inline instead, duplicating the same logic with a deliberate and correct mark-after-success ordering difference: it marks a delivery ID as seen only once the response is confirmed ok, so a failed/rejected webhook stays retryable.
  • checkAndMarkDelivery marked as seen on the FIRST call regardless of outcome — a real (if unreachable, since it had zero call sites) bug: had anything called it, it would have incorrectly suppressed GitHub's retry of a webhook whose processing actually failed.
  • Deleted it rather than refactoring server.ts to call it: the inline version is already correct and live, and fixing checkAndMarkDelivery's mark-timing to match it first (per the issue's option 2) would be strictly more code for no behavior change, when option 1 is the smaller, safer change.
  • Removed its now-unreachable test suite (test/unit/selfhost-redis-cache.test.ts); the still-live createRedisCache coverage (get/set/del/claim) is untouched and stays at 100%.

Closes #2506.

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 an issue, or this is small enough that the summary explains why an issue is not needed.

Validation

  • git diff --check
  • npm run actionlint
  • npm run typecheck
  • npm run test:coverage locally; codecov/patch requires ≥99% coverage of the lines AND branches you changed (aim for 100% on your diff so CI variance does not fail near the threshold). Global coverage is a non-blocking trend with a loose 90% backstop, not the gate. (A pure deletion — createRedisCache stays at 100%.)
  • npm run test:workers
  • npm run build:mcp
  • npm run test:mcp-pack
  • npm run ui:openapi:check
  • npm run ui:lint
  • npm run ui:typecheck
  • npm run ui:build
  • npm audit --audit-level=moderate
  • New or changed behavior has unit/integration tests for new branches, fallback paths, and sanitizer boundaries

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. — N/A.
  • API/OpenAPI/MCP behavior is updated and tested where needed. — N/A, webhook dedup behavior is unchanged (the live inline implementation is untouched).
  • UI changes use live API data or real empty/error/loading states, not production mock/demo fallbacks. — N/A, no UI changes.
  • Visible UI changes include a UI Evidence section below — N/A, no UI changes.
  • Public docs/changelogs are updated where needed; changelogs are only edited for release-prep PRs.

Notes

checkAndMarkDelivery (the documented webhook-delivery-dedup helper in
redis-cache.ts) was exported but never called anywhere in src/. The
real webhook dedup path in server.ts implements its own get-then-set
inline, duplicating the same logic with a deliberate and CORRECT
mark-after-success ordering difference: it marks a delivery ID as seen
only once the response is confirmed ok, so a failed/rejected webhook
stays retryable. checkAndMarkDelivery marked on the FIRST call
regardless of outcome, which would have incorrectly suppressed a retry
of a webhook whose processing actually failed, had anything called it.

Delete it -- the inline version in server.ts is already correct and
live, and two divergent implementations of the same dedup logic can
silently drift out of sync.
@dosubot dosubot Bot added the size:S label Jul 2, 2026
@loopover-orb

loopover-orb Bot commented Jul 2, 2026

Copy link
Copy Markdown

Tip

🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩

✅ Gittensory review result - approve/merge recommended

Review updated: 2026-07-02 09:20:44 UTC

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

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This removes the unused checkAndMarkDelivery export and the tests that only exercised that removed helper, leaving createRedisCache and its live get/set/del/claim coverage intact. The change is coherent with the stated choice to delete the dead helper rather than route server webhook dedup through a subtly different mark-before-success API. I do not see a reachable break in the provided changed files; the only residual cleanup is that the redis-cache module header still describes delivery-level successful-processing behavior that now lives outside this file.

Nits — 4 non-blocking
  • src/selfhost/redis-cache.ts:1: nit: The module header still describes GitHub delivery suppression and mark-after-success semantics, but this file now only exposes a generic Redis cache wrapper.
  • src/selfhost/redis-cache.ts:1: Update the file header to describe the remaining RedisCache wrapper API, or move the delivery-id success-ordering explanation to the live server webhook path where that behavior now exists.
  • PR author also opened the linked issue — Link an issue that was opened by a different contributor, or provide a rationale for why this self-authored issue represents genuine discovery work.
  • Code changes lack test evidence — Add focused regression tests or explain why existing coverage is sufficient.
Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ✅ Linked #2506
Related work ⚠️ 3 scoped overlaps Top overlaps are listed below; lower-confidence bulk is hidden.
Change scope ❌ 8/20 High review scope from cached public metadata (size label size:S; 1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 65 registered-repo PR(s), 55 merged, 553 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 65 PR(s), 553 issue(s).
Gate result ✅ Passing No configured blocker found.
Review context
Contributor next steps
  • Treat this as maintainer-lane context rather than normal contributor-lane activity.
  • Review top overlaps.
  • Add a concise scope and risk note.
  • Triage stale or unlinked PRs.
  • No action.
  • Check active issues and PRs before submitting.
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.

🟩 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 Gittensory, a quiet PR intelligence layer for OSS maintainers.

  • Re-run Gittensory review

@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.98%. Comparing base (1217863) to head (0544a58).
⚠️ Report is 28 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2572      +/-   ##
==========================================
+ Coverage   95.95%   95.98%   +0.02%     
==========================================
  Files         226      229       +3     
  Lines       25425    25807     +382     
  Branches     9244     9390     +146     
==========================================
+ Hits        24397    24771     +374     
- Misses        417      425       +8     
  Partials      611      611              
Files with missing lines Coverage Δ
src/selfhost/redis-cache.ts 100.00% <ø> (ø)

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JSONbored
JSONbored merged commit 8f71d2c into main Jul 2, 2026
13 checks passed
@JSONbored
JSONbored deleted the fix/remove-dead-check-and-mark-delivery branch July 2, 2026 09:25
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.

Development

Successfully merging this pull request may close these issues.

refactor(selfhost): remove or wire the dead checkAndMarkDelivery helper

1 participant