Skip to content

fix(miner): fail closed on an unparseable lease in portfolio-queue findStuckItems - #8033

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
lourincedaging0-commits:fix/portfolio-queue-expiry-unparseable-lease-8007
Jul 22, 2026
Merged

fix(miner): fail closed on an unparseable lease in portfolio-queue findStuckItems#8033
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
lourincedaging0-commits:fix/portfolio-queue-expiry-unparseable-lease-8007

Conversation

@lourincedaging0-commits

Copy link
Copy Markdown
Contributor

Closes #8007

What

findStuckItems (packages/loopover-miner/lib/portfolio-queue-expiry.ts) skipped any in_progress item whose leasedAt couldn't be parsed — leaseAgeMs returns null, and the old if (ageMs === null) continue; dropped it — so a corrupted or hand-edited lease timestamp stranded that item in_progress forever, never reclaimed by the stuck-item sweep.

claim-ledger-expiry.ts's findExpiredClaims already fails closed on the exact same shape post-#7732 (an unparseable claimedAt is treated as expired). This matches that posture: an item whose leasedAt is missing/unparseable is now returned as stuck (swept back to queued) instead of silently skipped.

Changes

  • findStuckItems: if (ageMs === null || ageMs > maxLeaseMs) stuck.push(item) — fail closed on the null (unparseable) case.
  • Updated the function's doc comment (it previously said unparseable leases "are never returned").
  • Split the existing test: fresh/non-in_progress items still assert "ignored"; missing/unparseable leases now assert the fail-closed sweep.

Verification

Miner-lib lane, verified locally: 15 tests pass; the changed || branch is covered both ways (unparseable → swept, in-window → not). Test file typechecks clean against the project's exact CI types. .js is gitignored (rebuilt in CI from the .ts).

…ndStuckItems

findStuckItems skipped any in_progress item whose leasedAt couldn't be parsed
(leaseAgeMs returns null -> the old 'if (ageMs === null) continue'), so a corrupted or
hand-edited lease timestamp stranded that item 'in_progress' forever, never reclaimed by
the stuck-item sweep. claim-ledger-expiry.ts's findExpiredClaims already fails closed on
the same shape post-JSONbored#7732 (an unparseable claimedAt is treated as expired).

Match that posture: an item whose leasedAt is missing/unparseable is now returned as stuck
(swept back to queued) rather than silently skipped. Updated the doc comment and split the
existing test so unparseable/missing leases assert the fail-closed sweep instead of being
bundled into the 'ignored' case.

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

loopover-orb Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-22 14:17:34 UTC

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

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This is a small, correct fail-closed fix: `findStuckItems` now treats an unparseable/missing `leasedAt` as stuck (swept back to `queued`) instead of silently skipping it forever, mirroring `findExpiredClaims`'s post-#7732 posture. The diff is minimal, the doc comment is updated to match the new behavior, and the test is properly split so both the 'ignored' and 'fail-closed sweep' cases are asserted with concrete `noLease`/`bogus` fixtures rather than a fabricated scenario. This closes #8007 and is directly scoped to the linked issue.

Nits — 4 non-blocking
  • portfolio-queue-expiry.ts:31 the inline `//` comment restates what the docblock above the function already says — one of the two is redundant.
  • test/unit/miner-portfolio-queue-expiry.test.ts:118-124 the comment above the new test also duplicates the doc comment's rationale; consider trimming to avoid triple-repeating the same portfolio-queue-expiry's findStuckItems skips the fail-closed fix its sibling findExpiredClaims got in #7732 #8007/A claim with an unparseable claimedAt is never swept by findExpiredClaims #7732 explanation across code and tests.
  • Consider a follow-up test asserting the fail-closed sweep also flows correctly through `sweepStuckItems`/`reclaimStuckItem` with an unparseable lease, since the current sweep-level tests only use valid old timestamps.
  • Since `.js`/`.d.ts` build artifacts are checked into the repo and lag this `.ts` change (per the reference content shown), confirm the CI build step regenerates them before merge rather than relying on stale committed output.

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 #8007
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: 82 registered-repo PR(s), 33 merged, 5 issue(s).
Contributor context ✅ Confirmed Gittensor contributor lourincedaging0-commits; Gittensor profile; 82 PR(s), 5 issue(s).
Improvement ✅ Minor risk: clean · value: minor
Linked issue satisfaction

Addressed
The diff changes findStuckItems to fail closed via `ageMs === null || ageMs > maxLeaseMs`, exactly mirroring findExpiredClaims's post-#7732 pattern, and updates both the doc comment and the previously stale test to assert the sweep behavior for null/unparseable leasedAt.

Review context
  • Author: lourincedaging0-commits
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: HTML
  • Official Gittensor activity: 82 PR(s), 5 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Keep the PR focused and include validation evidence before maintainer review.
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 <question> answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat <question> 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 bf8bb14 into JSONbored:main Jul 22, 2026
10 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.

portfolio-queue-expiry's findStuckItems skips the fail-closed fix its sibling findExpiredClaims got in #7732

1 participant