Skip to content

aggregator(feed): sanitizeQuotaView never checks pool-level freshness, and session tokens / freshness dates are value-blind — malformed freshness and negative counts survive the #3921 pass #4546

Closed

Description

@dezren39

Problem

The #3921 sanitization added in PR #4508 (merged today, main c84bbcfa1) validates quota credential rows and active sessions by shape in pm-stack/aggregator/src/feed.ts — but three value/pool-level gaps remain in the same sanitizeQuotaView pass, all verified this run:

  1. Pool-level freshness is never sanitized at all. isQuotaPool (feed.ts:473-480) does not look at pool.freshness, and sanitizeQuotaView (feed.ts:596-625) rewrites only windows, credentials, and activeSessions. isQuotaFreshness exists (feed.ts:486-495) but is applied only inside credential rows. So a pool carrying freshness: "error" (a bare string) or freshness: { measuredAt: "2026-02-30T00:00:00Z", source: "quota-current", state: "banana" } survives sanitization untouched and renders in renderQuota (render.ts:2278-2280) as an empty/bogus "gatherer · · measured — ·" line or a literal banana state; the health error count in render.ts:3306 (pool.freshness?.state === "error") also misses every malformed form. The model's QuotaPool.freshness is PoolFreshness (model.ts:257) — the same shape credential rows are now dropped for failing.
  2. Active-session tokens is finite-only. isQuotaActiveSession (feed.ts:505-512) uses isFiniteNumber(v.tokens), so a cumulative token count of -12345 passes and renders as burning: s-neg (gpt-5) -12,345 tok (render.ts:2262-2267). Every sibling numeric guard in the same section is non-negative for exactly this reason: window used/limit (aggregator(feed): isQuotaWindow accepts any string as resetsAt and any finite used/limit/percent — an impossible reset date is clocked as Mar 2 in guidance, a -50% window reads healthy and a 15000% window walls a pool #3427, isNonNegative), burn-segment tokens (aggregator(feed): isBurnSegment accepts negative tokens, non-date from/to and inverted ranges — garbage burn rows survive sanitizeQuotaView and render as measured history #3428, isNonNegative).
  3. Credential-row freshness measuredAt is never date-checked. isQuotaFreshness accepts any string, so a credential row with freshness.measuredAt: "banana" is kept with droppedCredentials: 0, while window resetsAt and burn from/to in the same file must pass isIsoDate (real calendar dates — "2026-02-30" fails). The sanitized view is projected publicly via /api/quota.json, so the bogus stamp reaches consumers as if measured.

Evidence (verified this run, laptop probe)

Probe: ~/git/fleet/probe-2026-11-02-laneA-quotapool/probe.test.ts on the laptop, importing the real feed.ts/render.ts at main c84bbcfa1 (feed.ts md5 0d344ffcc96d83587ae2aa511da23c1e, render.ts md5 93546815e6efb4e2530a05de67c991aa, identical on sandbox and laptop clones). bun test: 6/6 pass, documenting the current (buggy) behavior:

  • P1: session tokens: -12345 → kept, droppedActiveSessions: 0, HTML contains -12,345 tok.
  • P2: pool freshness: "error" → kept verbatim, droppedPools: 0, HTML contains the empty gatherer · · measured — line.
  • P3: pool freshness {measuredAt: "2026-02-30T00:00:00Z", state: "banana"} → kept verbatim, HTML renders banana.
  • P4: credential row freshness.measuredAt: "banana" → kept, droppedCredentials: 0.
  • P5: pool burnTokensPerMin: -500 → kept and renders -500 tok/min (same unsanitized pool-scalar pattern; render.ts:2281 interpolates it unchecked).
  • C1 control: a well-formed pool (valid freshness, session tokens: 42) passes sanitization unchanged with zero drops — the guards above are the only gap.

Why it matters

sanitizeQuotaView is the feed boundary whose contract (validate.ts header, #2576) is that no consumer, store append, or render sees unvalidated values. #3921 closed the crash class for credential/session shapes; the pool's own freshness stamp — the field that tells Drew whether a pool's numbers are current or walled — still passes through in any shape, and negative cumulative counts render as measured fact on the quota page and in the public /api/quota.json projection.

Acceptance criteria

Related

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    priority/lowNice to have; do when convenient
    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)
    app/pm-stackpm-stack (Pad/Grist) in developing-today/code
    effort/sSmall: expected under 2 hours of work
    on Nov 2, 2026
  2. dezren39 commented on Nov 2, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

  3. dezren39 commented on Nov 2, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · picked up

  4. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed
    queue/queuedHas a queued task in the Supabase agent queue
    on Nov 2, 2026
  5. 9 remaining items

  6. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed
    work/assignedQueue worker lifecycle state
    queue/queuedHas a queued task in the Supabase agent queue
    on Nov 2, 2026
  7. dezren39 commented on Nov 2, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · handed off

  8. dezren39 commented on Nov 2, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · handed off (claimant launch)

  9. dezren39 commented on Nov 3, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    event: picked_up
    task: 7415 (repo-health-code-pilot; worker repo-worker-code; OpenChamber scheduled lane c29174f1-48e0-4b13-b4ff-9b73ab67e9ab)
    state: claimed (attempt 1). Triage: checking for in-flight work first per packet, then verifying at current main.

  10. dezren39 commented on Nov 3, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    event: triaged_done
    task: 7415 (repo-health-code-pilot; worker repo-worker-code; OpenChamber scheduled lane c29174f1-48e0-4b13-b4ff-9b73ab67e9ab)
    state: fix already landed — closing with evidence.
    evidence (all at true remote main ce2f197, worktree ~/git/fleet/6992-2212-phase3):

    • Pool freshness validated: feed.ts:612 drops malformed pool freshness (pool survives), counted at :614 (droppedPoolFreshness), surfaced in view.dropped.poolFreshness.
    • isQuotaFreshness (feed.ts:491) requires isIsoDate(measuredAt) + state in QUOTA_FRESHNESS_STATES — applies to pool and credential rows.
    • isQuotaActiveSession (feed.ts:514) requires isNonNegative(tokens) — negative sessions drop individually into droppedActiveSessions.
    • burnTokensPerMin validated non-negative at feed.ts:616-619, counted + surfaced (droppedBurnTokensPerMin).
    • Regression tests in pm-stack/aggregator/test/feed.test.ts cover P1-P5 (negative session tokens, malformed pool freshness incl. 2026-02-30 and banana, negative burnTokensPerMin, well-formed control); bun test: 65 pass, 0 fail.
    • Landed via repo-keeper snapshot 76ae31f (2026-11-02), following task 6451's implementation (lane code-b + opencode session ses_e5e622dc970ffePxFOyEa65SfO); no separate PR references aggregator(feed): sanitizeQuotaView never checks pool-level freshness, and session tokens / freshness dates are value-blind — malformed freshness and negative counts survive the #3921 pass #4546, but the code and tests are in main and green.
      action: ticking all five acceptance boxes and closing. Labels cleaned (in-flight queue/status/work removed). No new PR needed.
      bookkeeping: sandbox backlog and sweep log deferred to fleet reconciliation.
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)app/pm-stackpm-stack (Pad/Grist) in developing-today/codeeffort/sSmall: expected under 2 hours 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/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions