Skip to content

fix(selfhost): send conditional backfill requests on the scheduled cadence (#1942) - #1976

Merged
JSONbored merged 1 commit into
mainfrom
claude/backfill-scheduled-etag
Jul 1, 2026
Merged

fix(selfhost): send conditional backfill requests on the scheduled cadence (#1942)#1976
JSONbored merged 1 commit into
mainfrom
claude/backfill-scheduled-etag

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

#1901 added conditional (ETag / If-Modified-Since) validators for backfill segments, but fetchPagedSegment only loaded the prior segment row — and thus only built the conditional request — when mode === "resume" (src/github/backfill.ts:1289). The scheduled cadence runs in light/full mode, so the 304 fast-path never fired on the path that actually runs: every 30-min light crawl re-listed labels / open-issues / open-PRs at full cost even when nothing had changed.

This loads the prior segment for every mode, so a scheduled light/full crawl sends the stored If-None-Match and an unchanged single-page list returns a 0-body 304 instead of a full re-list — the largest avoidable GitHub cost on the backfill cadence.

Correctness is preserved by the machinery that was already there:

  • Resume pagination stays gated on canResumePreviousScan (mode === "resume"), so light/full still start a fresh page-1 scan — only the conditional header is added.
  • The open-scan segments that must reconcile GitHub-side closes still force allowEtag: false, so they always full-scan; loading previous never lets a dropped close slip through.
  • conditionalRequestForSegment still requires the prior scan to be fresh, complete, single-page, and expectedCount-matched before sending validators.

Advances #1942 (rec #3 from the #1936 audit); builds directly on #1901.

Scope

Validation

  • git diff --check
  • npm run typecheck
  • npm run test:coverage — the single changed line is exercised by the existing backfill segment suite (133 tests); added a regression test proving the light cadence now sends If-None-Match and short-circuits to not_modified (it asserts status: "complete"not_modified and the exact request headers, so it fails without the fix).
  • npm run test:ci
  • npm audit --audit-level=moderate

If any required check was skipped, explain why:

  • No ui:openapi / cf-typegen / migration regen: single-file backend change, no API/schema/binding/DB change.

Safety

  • No secrets/wallets/hotkeys/trust-scores/etc.
  • Public GitHub text unchanged.
  • No auth/CORS/session change.
  • No API/OpenAPI/MCP change. No UI change.

Notes

  • The only behavior change is that light/full crawls now send conditional headers; the open-scan/reconciliation segments are unaffected (allowEtag: false), so close-detection is unchanged.

…dence (#1942)

#1901 added ETag/If-Modified-Since validators for backfill segments, but
fetchPagedSegment loaded the prior segment (and so built the conditional
request) only when mode===resume. The scheduled cadence runs light/full, so
the 304 fast-path never fired on the path that actually runs — every 30-min
light crawl re-listed labels/open-issues/open-PRs at full cost.

Load the prior segment for every mode so a light/full crawl sends If-None-Match
and an unchanged single-page list returns a 0-body 304. Resume pagination stays
gated on canResumePreviousScan; open-scan reconciliation segments still force
allowEtag:false, so close-detection is unchanged.
@dosubot dosubot Bot added the size:XS label Jul 1, 2026
@loopover-orb

loopover-orb Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Warning

🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨

⏸️ Gittensory review result - manual review recommended

Review updated: 2026-07-01 04:06:25 UTC

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

⏸️ Suggested Action - Manual Review

  • Touches a guarded path — held for manual review

Review summary
This change moves prior segment loading out of resume-only mode so the existing conditional-request logic can run on scheduled light/full segment crawls while leaving resume pagination gated by `canResumePreviousScan`. The added regression test exercises the real `backfillRepositorySegment` light-mode path twice and verifies that the second labels request carries the stored validators and returns `not_modified`, which directly covers the bug described. I do not see a reachable correctness break in the visible diff.

Nits — 6 non-blocking
  • nit: `src/github/backfill.ts:1286` adds a five-line explanatory comment that mostly repeats the PR description; keeping only the invariant that matters locally would make this easier to maintain.
  • nit: `test/unit/backfill.test.ts:1288` packs the GraphQL totals response into a long single line; split it for readability alongside the rest of the test file.
  • In `src/github/backfill.ts:1286`, trim the comment to the local contract: prior segment is loaded for validators in every mode, while resume pagination remains gated below and open reconciliation paths disable ETags.
  • In `test/unit/backfill.test.ts:1288`, format the `githubTotalsResponse` object over multiple lines so the labels-only scenario is easier to scan.
  • Readiness score is below the configured threshold — Use the readiness panel as advisory maintainer context; the score does not block this PR.
  • Touches a guarded path — held for manual review — A maintainer must review and merge this change.
Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ⚠️ Missing No linked issue or no-issue rationale found.
Related work ⚠️ 1 scoped overlap Top overlaps are listed below; lower-confidence bulk is hidden.
Change scope ❌ 8/20 High review scope from cached public metadata (size label size:XS; no linked issue context).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 68 registered-repo PR(s), 58 merged, 274 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 68 PR(s), 274 issue(s).
Gate result ⚠️ Not blocking Advisory; not blocking this PR.
Review context
  • Author: JSONbored
  • Role context: owner (maintainer lane)
  • Public audience mode: oss maintainer
  • Lane context: Repository registration is not available in the local Gittensory cache.
  • Public profile languages: not available
  • Official Gittensor activity: 68 PR(s), 274 issue(s).
  • Related work: Titles/paths share 5 meaningful terms. (PR #1933)
Contributor next steps
  • Treat this as maintainer-lane context rather than normal contributor-lane activity.
  • Explain no-issue PR.
  • Review top overlaps.
  • Add a concise scope and risk note.
  • Triage stale or unlinked PRs.
  • No action.
  • Link the issue being solved, or explicitly explain why this is a no-issue PR.
  • 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

@loopover-orb loopover-orb Bot added gittensor gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. labels Jul 1, 2026
@codecov

codecov Bot commented Jul 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.57%. Comparing base (9e2f533) to head (945149d).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1976   +/-   ##
=======================================
  Coverage   95.57%   95.57%           
=======================================
  Files         218      218           
  Lines       24257    24257           
  Branches     8795     8794    -1     
=======================================
  Hits        23184    23184           
  Misses        436      436           
  Partials      637      637           
Files with missing lines Coverage Δ
src/github/backfill.ts 94.65% <100.00%> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JSONbored JSONbored self-assigned this Jul 1, 2026
@JSONbored JSONbored linked an issue Jul 1, 2026 that may be closed by this pull request
@JSONbored
JSONbored merged commit e226c3c into main Jul 1, 2026
12 checks passed
@JSONbored
JSONbored deleted the claude/backfill-scheduled-etag branch July 1, 2026 04:34
@github-project-automation github-project-automation Bot moved this from Todo to Done in gittensory - v1 roadmap Jul 1, 2026
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

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

fix(queue): eliminate duplicate scheduled work and gate jitter

1 participant