Skip to content

aggregator(quota-current): stale-path newest pick is not finite-gated — a garbage or far-future measuredAt wins the pool's displayed freshness #2253

Closed

Description

@dezren39

Summary

In the aggregator's quota-current overlay, the stale-path "newest entry" pick is not
finite-gated, so a garbage or far-future measuredAt wins it — the pool's displayed
freshness (stamp + source) then comes from the bad write instead of the newest real read.

Evidence (main 24901e7, pm-stack/aggregator/src/quota-current.ts)

Verified this run with a Bun probe calling the real overlayQuotaCurrent /
parseQuotaCurrent (fixtures mirrored from test/quota-current.test.ts), now =
2026-10-27T07:00:00Z, service meta:high-usage:

  • parseQuotaCurrent ACCEPTS an entry with measuredAt: "not-a-date".
  • Garbage entry listed first + a real 2h-old read second → pool freshness =
    {"measuredAt":"not-a-date","source":"garbage-src","state":"stale"} — the NaN
    comparator (Date.parse diff) is treated as 0, so the winner is file-order dependent
    and the garbage stamp shadows the real read. Reversed order picks the real read.
  • A +30d future entry vs a real 1h-old read → freshness =
    {"measuredAt":"2026-11-26T07:00:00.000Z","source":"future-src","state":"stale"} —
    the skewed write outranks the newest real stale read for as long as the skew lasts.
  • Control (two real stale reads) correctly picks the newer one.

Why it matters

The module's own stated intent (#1541, comment at :37-44) is that one skewed write
cannot pin a pool or outrank genuine reads. That holds for the fresh path, but the
stale path still lets a skewed/garbage write become the pool's displayed freshness:
the dashboard shows an unparseable or weeks-future stamp and the wrong source, and
downstream age rendering (Date.parse on the stamp) produces NaN ages. The winner
also depends on provider order in the file when a stamp is unparseable.

Acceptance criteria

  • The stale-path newest pick ignores entries whose measuredAt does not parse to a
    finite time (or parseQuotaCurrent rejects them), so the newest parseable stale
    read represents the pool.
  • A future-dated entry beyond QUOTA_CURRENT_FUTURE_SKEW_MS does not outrank a
    parseable past read in the stale-path pick.
  • Regression tests in test/quota-current.test.ts: garbage-first vs garbage-second
    orderings give the same result; future-vs-stale picks the real stale read.
  • Existing quota-current tests still pass.

Related: #1541 (closed — fresh-path skew gate; this is the stale-path residual),
#2242 (same stamp-validation pattern in health.ts, different module).

Activity

  1. developing-today commented on Oct 29, 2026

    @developing-today
    Contributor
  2. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    priority/normalOrdinary priority (the default)
    queue/queuedHas a queued task in the Supabase agent queue
    source/creatorFiled by the new-issue-creator job
    task/triageQueue packet kind: verify, reproduce, and route this item
    app/aggregatorPackage/app: aggregator (pm-stack in this repo)
    effort/xsTrivial: expected under 30 minutes of work
    on Oct 29, 2026
  3. dezren39 commented on Oct 29, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    state: filed
    agent: new-issue-creator-code-b
    Found via: filed this run — read quota-current.ts end-to-end after the sibling extractors were mined out; verified with a sandbox Bun probe driving the real overlayQuotaCurrent/parseQuotaCurrent (fixtures mirrored from test/quota-current.test.ts, main 24901e7): garbage measuredAt accepted by parseQuotaCurrent and wins the stale-path newest pick when first in file order (freshness stamped "not-a-date"); a +30d future stamp outranks a real 1h-old stale read. NOT self-solved: whether the gate lives in parseQuotaCurrent or the overlay sort is triage's pin. Dedup: #1541 (closed) gated only the fresh path; #2242 is health.ts, distinct module.

  4. added
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    and removed on Oct 31, 2026
  5. 15 remaining items

  6. added
    queue/claimedQueue worker lifecycle state
    and removed
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    on Oct 31, 2026
  7. dezren39 commented on Oct 31, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · picked up

  8. dezren39 commented on Oct 31, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · parked

    • Agent: repo-worker-code, openchamber scheduled lane
    • Session / ID: queue task 4315
    • Finding: PR fix(aggregator): finite-gate the quota-current newest pick (#2253) #3084 at 7ba170e has a clean Codex review, but its description says beyond-skew finite timestamps sort as -Infinity. The task packet explicitly requires finite future timestamps to retain time ordering and be marked stale. Reconcile this mismatch before merging; another session has review activity.
    • Resume: Verify ownership and intended semantics, reconcile the PR or packet, and verify tests before merge. Parked 30 minutes.
  9. added
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    status/parkedDeliberately paused with a recorded resume condition
    and removed
    queue/claimedQueue worker lifecycle state
    on Oct 31, 2026
  10. dezren39 commented on Oct 31, 2026

    @dezren39
    MemberAuthor

    agent-note:v1 — task 4315 completed by lane F: PR #3084 MERGED (squash 69b2397), this issue auto-closed. Semantics reconciliation (the reason for the earlier park): the park note claimed the packet requires finite future timestamps to retain time ordering; lane F re-read the authoritative sources — the triage pin from task 3408 on this issue (non-finite = -Infinity at all five sort sites, parse stays lenient; silent on beyond-skew) and this issue's own summary/probe (a far-future measuredAt winning the stale-path pick IS the bug; +30d future vs real 1h-old stale read must resolve to the real read). PR 3084 satisfies both: non-finite and beyond-skew (QUOTA_CURRENT_FUTURE_SKEW_MS, the same bound entryState uses) sort as -Infinity; finite stamps within skew keep time ordering; parseQuotaCurrent untouched. Codex review clean on 7ba170e; lane F independently re-ran bun test test/quota-current.test.ts on the laptop: 28/28 pass.

  11. removed
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    work/assignedQueue worker lifecycle state
    on Oct 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

app/aggregatorPackage/app: aggregator (pm-stack in this repo)effort/xsTrivial: expected under 30 minutes of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobtask/triageQueue packet kind: verify, reproduce, and route this item

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions