Skip to content

fix(miner): sweep stale active soft-claims to expired#2885

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
james3773:fix/miner-claim-ledger-expiry-sweep
Jul 4, 2026
Merged

fix(miner): sweep stale active soft-claims to expired#2885
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
james3773:fix/miner-claim-ledger-expiry-sweep

Conversation

@james3773

Copy link
Copy Markdown
Contributor

Summary

  • Add pure findExpiredClaims and sweepExpiredClaims helpers so stale active soft-claims can be expired locally without network calls.
  • Extend the claim ledger with expireClaim, mirroring the active-only transition guard used by releaseClaim.
  • Cover empty, all-stale, mixed, boundary (age === maxAgeMs), and SQLite sweep integration in unit tests.

Closes #2316.

Scope

Validation

  • npm run test:ci locally — CI will run the full gate on push.
  • Unit tests cover pure expiry selection, boundary behavior, and SQLite sweep integration.

Safety

  • No secrets, wallet details, hotkeys, or private scoring output in code or PR text.
  • Deterministic, read/write-local only: no network calls.

UI Evidence

Not applicable — miner library only.

Notes

  • Default max age is 14 days (DEFAULT_MAX_CLAIM_AGE_MS).
  • Claims whose age equals maxAgeMs exactly remain active; only strictly older rows expire.

Add pure findExpiredClaims and sweepExpiredClaims plus expireClaim store support so local soft-claims older than the max age transition to expired. Closes JSONbored#2316.

Co-authored-by: Cursor <cursoragent@cursor.com>
@james3773
james3773 requested a review from JSONbored as a code owner July 4, 2026 04:05
@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 4, 2026
@loopover-orb

loopover-orb Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Warning

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

⏸️ Gittensory review result - manual review recommended

Review updated: 2026-07-04 04:09:10 UTC

6 files · 1 AI reviewer · no blockers · readiness 80/100 · CI green · clean

⏸️ Suggested Action - Manual Review

Review summary
The diff adds a small pure expiry selector plus a SQLite-backed transition that mirrors the existing active-only release guard, and the visible tests cover the main strict-age and idempotency paths. The ledger status vocabulary already includes `expired`, so no schema/migration drift is introduced in the changed files. The notable remaining risk is wiring: this PR provides the sweep primitive but the provided diff does not show any production caller that actually runs it.

Nits — 5 non-blocking
  • nit: `packages/gittensory-miner/lib/claim-ledger-expiry.js:29` leaves the new sweep helper uninvoked in the visible diff, so confirm a caller is added in the miner path that is supposed to expire stale active rows.
  • nit: `packages/gittensory-miner/lib/claim-ledger-expiry.js:6` silently ignores malformed `claimedAt` values; that is defensible for a sweep, but a test documenting the fail-open behavior would make the contract explicit.
  • nit: `test/unit/miner-claim-ledger-expiry.test.ts:111` says “second sweep” but directly calls `expireClaim`, so the test name should match the behavior it exercises.
  • Add or point to the production call site for `sweepExpiredClaims` so the new helper is not just library surface.
  • Add a small `findExpiredClaims` test for an invalid `claimedAt` row to lock down the current skip behavior.
Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ✅ Linked #2316
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 ❌ 5/25 Preflight is holding this PR: the review lane is unavailable, so it is not ready for automated review.
Contributor workload ✅ 10/10 Author activity: 906 registered-repo PR(s), 642 merged, 38 issue(s).
Contributor context ✅ Confirmed Gittensor contributor jony376; Gittensor profile; 906 PR(s), 38 issue(s).
Gate result ✅ Passing No configured blocker found.
Review context
  • Author: jony376
  • Role context: outside_contributor
  • 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: 906 PR(s), 38 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Await review-lane availability.
  • Refresh registry data or choose a registered active repo.
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 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@1e62742). Learn more about missing BASE report.
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2885   +/-   ##
=======================================
  Coverage        ?   96.03%           
=======================================
  Files           ?      259           
  Lines           ?    28393           
  Branches        ?    10326           
=======================================
  Hits            ?    27266           
  Misses          ?      491           
  Partials        ?      636           
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@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.

Gittensory approves — the gate is satisfied and CI is green.

@loopover-orb
loopover-orb Bot merged commit 6ceabfa into JSONbored:main Jul 4, 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.

feat(miner-foundation): claim-ledger staleness/expiry sweep

1 participant