GeezerVison is showing github.com — aggregator(token-adapter): file-export adapter's fail-closed window check omits the 0-100 usedPct range — out-of-range windows vanish and a partial (or empty) entry publishes as fresh ok · Issue #4269 · developing-today/code
aggregator(token-adapter): file-export adapter's fail-closed window check omits the 0-100 usedPct range — out-of-range windows vanish and a partial (or empty) entry publishes as fresh ok #4269Labels app/aggregatorPackage/app: aggregator (pm-stack in this repo)app/pm-stackpm-stack (Pad/Grist) in developing-today/codeeffort/xsTrivial: expected under 30 minutes of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/lowNice to have; do when convenientsource/creatorFiled by the new-issue-creator jobtask/triageQueue packet kind: verify, reproduce, and route this item DescriptionSummary
collectFileExportAdapter (pm-stack/aggregator/src/token-adapter.ts) is documented as the strict layer over the bare file-export mapping: a success document whose windows are malformed must fail closed as unparseable and retain the previous entry, "instead of a partial one being published" (token-adapter.ts:220-228, and the comment at :271: "drift => unparseable, never partial").
Its window validation (token-adapter.ts:272-296) checks only that each window is an object with a non-empty string name and a finite usedPct. It never checks the 0–100 range — but the mapping it wraps does treat out-of-range as malformed: entryFromFileExport (pm-stack/aggregator/src/quota-gather-map.ts:139-140) silently continues past any window with pct < 0 || pct > 100.
So an out-of-range window passes the adapter's drift check, is silently dropped by the mapping, and the adapter publishes the result as a fresh ok outcome:
- one bad window among good ones → a partial entry (window missing) presented as fresh, not stale, with no error;
- a document whose only window is out of range → a fresh
ok entry with zero windows — an empty reading that is neither the retained previous value nor an error.
Evidence (verified this run, main @ 0858c74)
Laptop probe ~/git/fleet/probe-2026-11-02-laneB-fileexport/ — verbatim copies of token-adapter.ts (md5 9a6c0009), quota-gather-map.ts (ecf44799), validate.ts (2078ddfd), model.ts (6189406b) from main, run with bun run probe.ts, a previous value present in every case:
control 42pct+10pct: status=ok stale=false windows=["5h=42","weekly=10"]
negative -5 + 10: status=ok stale=false windows=["weekly=10"] <- 5h window silently gone
over100 250 + 10: status=ok stale=false windows=["weekly=10"] <- same
only window -5: status=ok stale=false windows=[] <- fresh ok, zero windows
drift control NaN: status=unparseable stale=true windows=["5h=11"] <- retained, as designed
The NaN control proves the fail-closed path works for the shapes the adapter checks; the range is the one malformed shape it does not check, even though the mapping's own rule (quota-gather-map.ts:140, and the same rule for provider results at :199-200) defines it as malformed.
Why it matters
The file-export adapter is the framework's reference adapter (#1153) that the per-provider browser-token adapters copy. A producer whose payload drifts into an out-of-range percentage (a dashboard change, a fraction-vs-percent slip like 0.42 → 4200, a signed bug) currently degrades the dashboard quietly: windows disappear one by one, or the entry goes empty, while everything reports fresh/ok and the retained-value safety net never engages — the exact failure mode this module exists to prevent.
Distinct from
Acceptance criteria
-
collectFileExportAdapter returns the retained unparseable outcome (previous value kept, stale: true) for a success document containing a window with usedPct < 0 or usedPct > 100, naming the window in the detail — consistent with its existing NaN/non-finite handling.
- A success document whose only window(s) are out of range no longer yields a fresh
ok entry with zero windows.
- In-range documents (including exactly 0 and exactly 100) still produce the fresh
ok entry with all windows.
- Tests cover: negative, over-100, boundary 0/100, and the mixed good+bad document case.
Activityadded kind/bugSomething isn't working (prefixed form of the classic bug label) task/triageQueue packet kind: verify, reproduce, and route this item effort/xsTrivial: expected under 30 minutes of work on Nov 2, 2026dezren39 commented on Nov 2, 2026 🤖 Agent note · filed
- Agent: new-issue-creator job (new-issue-creator-code-b)
- Session / ID: cron new-issue-creator-code-b run 2026-11-02 01:50 CST (2026-11-02T08:01Z)
- Found via: filed this run
- Task: Triage the file-export adapter's missing usedPct range check — collectFileExportAdapter's fail-closed window validation checks finiteness only, so a window at -5% or 250% passes the adapter, is silently dropped by entryFromFileExport, and a partial (or zero-window) entry publishes as fresh ok instead of the retained unparseable outcome
- Expectation: effort/xs; done = out-of-range windows fail closed at the adapter (retained unparseable outcome naming the window), boundary 0/100 still publish fresh, with tests for negative / over-100 / boundary / mixed cases
- Links: laptop probe ~/git/fleet/probe-2026-11-02-laneB-fileexport/ (verbatim aggregator src @0858c741, token-adapter.ts md5 9a6c0009 / quota-gather-map.ts md5 ecf44799; probe: -5 and 250 windows silently dropped with status=ok stale=false, only-window -5 → ok with zero windows, NaN control → unparseable retained)
dezren39 commented on Nov 7, 2026 dezren39 commented on Nov 7, 2026
Heartbeat: verification — CONFIRMED at current origin/main. collectFileExportAdapter's fail-closed loop (token-adapter.ts) checks isRecord + non-empty name + finite usedPct and nothing else; the 0–100 range that entryFromFileExport treats as malformed (quota-gather-map silently continues past pct<0 or pct>100) is unchecked, so out-of-range windows publish partial/empty entries as fresh ok — exactly the filing's probe. Implementing the xs fix in this pass: range check in the adapter's validation + regression tests (negative, over-100, only-window-out-of-range, inclusive 0/100 boundaries) in token-adapter.test.ts. dezren39 commented on Nov 7, 2026
Released by repo-worker-code-p (fallback mode): issue #4269 triage CONFIRMED and fixed in the same pass (effort xs), merged via PR #6745 (#6745, merge 34492d5) — collectFileExportAdapter's fail-closed window validation now also rejects usedPct outside the inclusive 0–100 range, so an out-of-range window makes the whole document unparseable (previous entry retained) instead of publishing a partial or empty fresh ok. Verified: token-adapter tests 19/19 (regression examples + a deterministic seeded property sweep added at Codex's P1 request, thread replied), neighboring quota suites 104/104, tsc clean; Codex re-review completed with no findings. Issue auto-closed by the PR's Fixes line. dezren39 commented on Nov 7, 2026
MetadataMetadataapp/aggregatorPackage/app: aggregator (pm-stack in this repo)app/pm-stackpm-stack (Pad/Grist) in developing-today/codeeffort/xsTrivial: expected under 30 minutes of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/lowNice to have; do when convenientsource/creatorFiled by the new-issue-creator jobtask/triageQueue packet kind: verify, reproduce, and route this item DevelopmentNo branches or pull requestsIssue actions
|