Repository navigation
Description
Problem
pm-stack/aggregator/src/quota-gather-map.ts's shared scalar gate is finite-only, and neither quota-current mapper range-checks the percent it publishes:
num()(quota-gather-map.ts:38) istypeof v === "number" && Number.isFinite(v)— no range.entryFromResult'spushWindow(:197-211) copiesnum(raw?.usedPercent)verbatim into bothvalueandpctOfLimit, with the entry stampedstate: "ok"for a healthy provider result.entryFromFileExport(:137-151) does the same withnum(w.usedPct)for the Meta file-export document, and itslabelWindow(:154-168) accepts any finite USD amount, rendering a negativefreeCreditsUsdas the label"$-42.50".
Downstream, nothing range-checks the percent either:
recordsFromEntries(quota-gather-map.ts:268+) takes any non-nullpctOfLimitas apctsnapshot record stampedlimit: 100— and its pool-level collapse keeps the max pct per key, so one glitched 1e9 reading beats every sane credential's reading for that tick.isSnapshotRecord(snapshots.ts:295-310) is finite-only for numeric values, so the out-of-range records pass the store gate and enter the append-only snapshot store, where rollup min/max preserves the extremum.parseQuotaCurrent(quota-current.ts:90-96) is also finite-only, convertingpctOfLimitinto the pool window'sused/percentserved on /quota.
Evidence (verified this run, main 627cbc9)
Laptop Bun probe importing the real quota-gather-map.ts + snapshots.ts (file md5 86fa3547e81f325f9211dfe1c4577894, identical in the sandbox clone at 627cbc9 and the laptop clone; probe at ~/git/fleet/probe-2026-10-30-laneA-gatherpct/):
entryFromResultwithusedPercent: -20→ entrystate:"ok", windowvalue:-20, pctOfLimit:-20;recordsFromEntriesemits a pct recordvalue:-20, limit:100andisSnapshotRecordreturnstrue.- Same for
usedPercent: 150→ recordvalue:150; andusedPercent: 1e9→ recordvalue:1000000000, gatetrue. entryFromFileExportwith windowsusedPct: 150/usedPct: -20andfreeCreditsUsd: -42.5→ entrystate:"ok", both out-of-range windows published, plus afree_creditslabel windowvalueLabel:"$-42.50";recordsFromEntriesemits pct records150and-20, both passing the store gate.- Control:
usedPercent: 42→ window and record42, as expected.
No existing test pins the out-of-range acceptance (no range cases in test/quota-gather-map.test.ts).
Why it matters
These two mappers are the gatherer's front door for every provider-module result and every laptop file-export: one glitched or drifting upstream read (a provider returning a fraction instead of a percent, a scaled value, a negative placeholder) is published as live, measured, ok quota data, mis-states pool headroom/wall decisions on /quota, and is then permanently appended to the snapshot history as a pct point against limit:100 — the same poisoned-history failure already filed for the sibling writers (#2553 Turso, #2568 provider-usage), through a different, uncovered pair of entry points.
Dedup
- aggregator(quota-gather-map): entryFromTurso never range-checks usage — negative counts publish as live ok data and append negative snapshot records #2553 covers
entryFromTurso's native-unit counts only; aggregator(snapshot-records): recordsFromProviderUsage never range-checks used_percent — a Codex window at -20% or 1e9% is appended as measured pct history against its own limit:100 #2568 coversrecordsFromProviderUsagein snapshot-records.ts only (its packet explicitly scopes out other writers); aggregator(quota-gather-map): entryFromResult throws RangeError on an out-of-range fetchedAt — one bad provider stamp discards the provider's whole tick #2332 isentryFromResult'sfetchedAtRangeError, not its percent range; aggregator(quota-current): parseQuotaCurrent never checks windows entries — one null entry crashes the whole gatherer overlay and provenance still claims it applied #2416 isparseQuotaCurrent's null-window crash. None coversusedPercent/usedPctrange inentryFromResult/entryFromFileExport.
Acceptance criteria
- Triage pins the treatment for an out-of-[0,100] percent in both mappers (skip that window is the file's own pattern for unusable windows —
entryFromFileExportalready skips a window whose pct is null — but pin it explicitly), and pins whether a negativefreeCreditsUsd/paygBalanceUsdlabel is skipped or the entry degrades. - After the fix:
entryFromResultandentryFromFileExportnever publish a window withpctOfLimitoutside [0,100] asstate:"ok"measured data, andrecordsFromEntriestherefore cannot append an out-of-range pct record from these entries. -
test/quota-gather-map.test.tscovers negative, >100, and absurd (1e9)usedPercentandusedPctcases, with the sibling in-range windows of the same result/document unaffected, plus the negative-USD label case per the pinned treatment. - Existing quota-gather-map / quota-current tests stay green.
Activity
dezren39 commentedon Oct 30, 2026
🤖 Agent note · filed
14 remaining items
dezren39 commentedon Nov 2, 2026
🤖 Agent note · picked up
Merge pull request #4218 from developing-today/queue/5386-2571-quota-…
dezren39 commentedon Nov 2, 2026
🤖 Agent note · done