Skip to content

A claim with an unparseable claimedAt is never swept by findExpiredClaims #7732

Description

@JSONbored

Context

packages/loopover-engine/src/claim-ledger-expiry.ts:12-14's claimAgeMs returns null when Date.parse(claim.claimedAt) is NaN (an unparseable timestamp), and findExpiredClaims skips any claim with a null age entirely — it's never swept.

claimedAt is always written via new Date().toISOString() in claim-ledger.ts, so this only becomes reachable through a corrupted or hand-edited claim-ledger row — but if it happens, the row is stuck permanently un-expirable, which contradicts this same file's own fail-closed posture used elsewhere (e.g. addApiBaseUrlScope's migration explicitly drops unusable rows rather than leaving them stuck, per its own comment in this file).

Requirements

  • When claimAgeMs cannot parse claim.claimedAt, findExpiredClaims must treat that claim as expired (fail-closed — an unparseable claim age should be swept, not permanently retained), matching this file's own stated posture rather than silently exempting it.
  • Do not change claimAgeMs's return signature or its behavior for valid timestamps — only how findExpiredClaims handles the null-age case.

Deliverables

  • findExpiredClaims in packages/loopover-engine/src/claim-ledger-expiry.ts updated to treat a claim with an unparseable claimedAt (i.e. claimAgeMs returns null) as expired.
  • A new test covering a claim with a malformed/unparseable claimedAt, asserting findExpiredClaims includes it in the swept set.

Test Coverage Requirements

This file is under src/ via the packages/loopover-engine workspace — confirm current coverage.include scoping for this package before assuming the top-level 99% patch gate applies exactly as src/** does; match whatever this package's existing test file already does for its coverage target. The new branch must be covered by the new test.

Expected Outcome

A claim-ledger row with a corrupted/unparseable claimedAt is swept by findExpiredClaims instead of being permanently retained.

Links & Resources

  • packages/loopover-engine/src/claim-ledger-expiry.ts:12-14
  • packages/loopover-engine/src/claim-ledger.ts (where claimedAt is normally written)

Metadata

Metadata

Assignees

No one assigned

    Labels

    gittensor:bugGittensor-scored bug fix — scores a 0.05x multiplier.help wantedExtra attention is needed

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions