Skip to content

fix(miner): retry transient live-state fetch in checkSubmissionFreshness before failing closed#7129

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
bitfathers94:fix/issue-7089
Jul 17, 2026
Merged

fix(miner): retry transient live-state fetch in checkSubmissionFreshness before failing closed#7129
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
bitfathers94:fix/issue-7089

Conversation

@bitfathers94

Copy link
Copy Markdown
Contributor

fix(miner): retry transient live-state fetch in checkSubmissionFreshness before failing closed

checkSubmissionFreshness called fetchLiveIssueSnapshot exactly once and treated
any failed/null result as live_state_unavailable, aborting the whole candidate
right before open_pr on a single transient blip (a brief 5xx or GraphQL-index
propagation lag). Its sibling caller of the same fetch, claim-conflict-resolver.js's
resolveClaimConflict (#6058), already rides out exactly this window with a bounded
retry-with-backoff.

Wrap the pre-submission fetch in the same bounded retry: optional maxAttempts
(default 3, matching DEFAULT_SNAPSHOT_MAX_ATTEMPTS), an injectable sleepFn, and an
injectable backoffMs defaulting to http-retry.js's shared defaultRetryBackoffMs. The
loop stops the instant a real, well-formed snapshot is obtained and never retries a
snapshot's own staleness signals. Once the budget is exhausted with no usable
snapshot it fails closed exactly as before (live_state_unavailable, fresh: false),
logging the abort event once. The new options are optional, so every existing caller
is unchanged.

Closes #7089

…ess before failing closed

checkSubmissionFreshness called fetchLiveIssueSnapshot exactly once and treated
any failed/null result as live_state_unavailable, aborting the whole candidate
right before open_pr on a single transient blip (a brief 5xx or GraphQL-index
propagation lag). Its sibling caller of the same fetch, claim-conflict-resolver.js's
resolveClaimConflict (JSONbored#6058), already rides out exactly this window with a bounded
retry-with-backoff.

Wrap the pre-submission fetch in the same bounded retry: optional maxAttempts
(default 3, matching DEFAULT_SNAPSHOT_MAX_ATTEMPTS), an injectable sleepFn, and an
injectable backoffMs defaulting to http-retry.js's shared defaultRetryBackoffMs. The
loop stops the instant a real, well-formed snapshot is obtained and never retries a
snapshot's own staleness signals. Once the budget is exhausted with no usable
snapshot it fails closed exactly as before (live_state_unavailable, fresh: false),
logging the abort event once. The new options are optional, so every existing caller
is unchanged.

Closes JSONbored#7089
@bitfathers94
bitfathers94 requested a review from JSONbored as a code owner July 17, 2026 22:51
@superagent-security

Copy link
Copy Markdown
Contributor

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

@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.75%. Comparing base (ec15d24) to head (141cf49).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #7129       +/-   ##
===========================================
+ Coverage   49.19%   93.75%   +44.56%     
===========================================
  Files         692      692               
  Lines       68818    68829       +11     
  Branches    18781    18781               
===========================================
+ Hits        33852    64532    +30680     
+ Misses      32463     3302    -29161     
+ Partials     2503      995     -1508     
Flag Coverage Δ
shard-1 43.37% <0.00%> (?)
shard-2 36.87% <100.00%> (?)
shard-3 33.16% <0.00%> (?)
shard-4 34.38% <0.00%> (?)
shard-5 31.73% <0.00%> (-0.56%) ⬇️
shard-6 46.11% <13.33%> (?)

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

Files with missing lines Coverage Δ
...s/loopover-miner/lib/submission-freshness-check.js 100.00% <100.00%> (+100.00%) ⬆️

... and 487 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 17, 2026
@loopover-orb

loopover-orb Bot commented Jul 17, 2026

Copy link
Copy Markdown

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-17 23:03:40 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 bounded retry-with-backoff around the pre-submission live-state fetch in checkSubmissionFreshness, mirroring the existing pattern in claim-conflict-resolver.js's resolveClaimConflict (#6058). The retry loop is correctly scoped: it only retries the fetch itself (null/thrown results), stops immediately on a well-formed snapshot, and never retries a snapshot's own staleness signals (issue_closed/already_addressed still fail on the first attempt). The fail-closed outcome and abort-event logging (once, not per-attempt) are preserved, and the new options parameter is fully optional so existing callers are unaffected — the test suite is thorough and covers both retry-recovery paths, the exhausted-budget path, the maxAttempts clamp, and default-sleep behavior.

Nits — 3 non-blocking
  • packages/loopover-miner/lib/submission-freshness-check.js: DEFAULT_SNAPSHOT_MAX_ATTEMPTS and the sleep/backoff plumbing duplicate claim-conflict-resolver.js's identical implementation almost verbatim — worth factoring into a shared helper in http-retry.js given there are now two near-identical copies.
  • The magic number 3 for DEFAULT_SNAPSHOT_MAX_ATTEMPTS is named via the constant itself, so this is adequately self-documenting despite the external brief's flag.
  • Consider extracting the attempt-loop (fetch-with-retry-until-truthy pattern) shared between submission-freshness-check.js and claim-conflict-resolver.js into a single reusable utility in http-retry.js to avoid future drift between the two nearly identical implementations.

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 #7089
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 ⚠️ 20/25 Preflight is ready, but the PR body does not name the validation run.
Contributor workload ✅ 10/10 Author activity: 0 registered-repo PR(s), 0 merged, 0 issue(s).
Contributor context ℹ️ No public Gittensor match bitfathers94; not a blocker.
Improvement ✅ Minor risk: clean · value: minor · LLM: moderate
Review context
  • Author: bitfathers94
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: not available
  • Contributor context: Public profile only; not a blocker.
  • PR-specific overlap: none found.
Contributor next steps
  • Start here: Add validation command/output.
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

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 2183167 into JSONbored:main Jul 17, 2026
16 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.

checkSubmissionFreshness aborts an entire completed attempt on a single transient live-state fetch failure, unlike its sibling caller

1 participant