Repository navigation
Description
Problem
applySupabaseExport (pm-stack/aggregator/src/saas-extract.ts:701) is the trust boundary for the supabase-export file document: live.ts reads the file with JSON.parse (src/sources/live.ts:833-835) and passes the result straight in. The overlay checks shapes only loosely — typeof === "number" && Number.isFinite for metric values and billing, and a Date.parse freshness check for measuredAt — so values the producer could never legitimately emit are accepted and stamped on the Supabase card as live, measured, sourceClass: "api" data:
- Negative numbers pass. saas-extract.ts:721-722 accepts any finite
used/limit; :741-743 accepts any finitebilling.billedUsd. Verified against the real module (main 7d1b081): a fresh,status:"ok"doc withused: -3.25for db-size yieldsused = -3.25,percent = -650;billedUsd: -42.5is stored verbatim (renders as a measured$-42.50billed line);limit: -0.5is stored as the metric's limit. measuredAtis never type-checked. saas-extract.ts:707-708 only requires truthiness and a finiteDate.parse(doc.measuredAt).Date.parsecoerces its argument, so a JSON arraymeasuredAt: ["2026-10-29T11:59:00.000Z"]passes the freshness gate, and :753doc.measuredAt.slice(0, 10)then stores the array itself as the service'smeasuredAt(verified:typeofbecomesobject). Downstream,freshness()(derive.ts:899) treats its length (1) as a date-only stamp and builds an unparseable string, andtsFor(snapshot-records.ts:37-39) interpolates the array slice into a snapshot record'sts, producing2026-10-29T11:59:00.000ZT12:00:00Z.
The module's own contract says the opposite: "Missing, failed, unparseable or stale documents change nothing", and the billing branch's comment says a failed billing probe must never render as a measured amount. A corrupted, hand-edited, or older-producer export file currently changes the card — with negative or type-corrupted values presented as the live API read.
House precedent in the same codebase: the quota-current overlay gate rejects a document outright when typeof p.measuredAt !== "string" (src/quota-current.ts:60), and the producer's own parsers reject negative sizes/counts (supabase-export parseDbSize/parseRequestCount).
Evidence
Probe (real applySupabaseExport + extractSaasServices imported from main 7d1b081, Bun): hidden_files/probe-2026-10-29-laneB-supaoverlay/probe.ts
- Case 1 (negative used/billed):
used= -3.25 percent= -650 billedUsd= -42.5 sourceClass= api - Case 2 (negative limit):
used= 1 limit= -0.5 - Case 3 (array measuredAt):
typeof= object value= ["2026-10-29T11:59:00.000Z"] sourceClass= api - Case 4 (control, well-formed fresh doc): applies cleanly,
measuredAta string - Case 5 (control, garbage-string measuredAt): correctly rejected, services unchanged
Related but distinct: #2492 is the producer (billedFromAddons in supabase-quota-export.mjs) accepting negatives at write time. This issue is the consumer gate: even with the producer fixed, the overlay reads a file from disk and must not trust values outside the domain the card renders. #2451 (isFleetFeed saas) is the feed gate for a different input and does not cover this overlay.
Why it matters
The Supabase card is the fleet's paid-trigger surface for the muse-dev project (80%-of-Free-limit flag, billed amounts). Negative or corrupted "measured" values suppress or invert the percent math, fabricate a negative billed amount, and poison snapshot history with an unparseable ts — all under an "api / measured" provenance stamp that tells the reader the numbers are trustworthy.
Acceptance criteria
-
applySupabaseExportrejects (changes nothing) or drops the offending metric whenusedorlimitis negative; percent is never computed from a negative used/limit. - A negative
billing.billedUsdis treated as "no valid billing measurement" (the existingbilledUsd = nullpath), never stored. -
doc.measuredAtmust be a string before the freshness check (mirror quota-current.ts:60); non-string values change nothing. - Regression tests in aggregator/test/supabase-export.test.ts for: negative used, negative limit, negative billedUsd, array measuredAt — each leaves the services unchanged (or the metric/billing unset), while the existing fresh-doc tests still pass.
Activity
dezren39 commentedon Oct 30, 2026
🤖 Agent note · state: filed
16 remaining items
dezren39 commentedon Nov 2, 2026
🤖 Agent note · parked
queue/5410-2508-supabase-overlay-guards@types/bunis absent in the worktree.dezren39 commentedon Nov 2, 2026
Lane E resumed task 5410: PR #4230 head fd268a0 revalidated — MERGEABLE, Codex review on this head completed with no findings, bun test test/supabase-export.test.ts 12/12 documented in the task checkpoint. The pm-aggregator test check is QUEUED (infra stall pattern). Merging per standing merge authority.
dezren39 commentedon Nov 2, 2026
Done: PR #4230 merged (merge commit 6cdfaee). applySupabaseExport now rejects corrupt measurements at the overlay boundary: non-string/invalid measuredAt makes the doc a no-op, negative used/limit rows are dropped, negative billedUsd becomes null while other valid overlay data applies. Codex clean; bun tests 12/12. Closing as complete.