Repository navigation
Description
aggregator: PR #3411's out-of-domain guard nulls projectedExhaustionAt but still computes and renders projectedPercentAtReset for negative pct values
Finding
PR #3411 (fix for #2346) guarded projectPace (pm-stack/aggregator/src/derive.ts) so an out-of-domain last pct value (< 0) yields no projection: projectedExhaustionAt stays null. The guard covers only that one field. The very next block computes the sibling projection unconditionally:
let projectedPercentAtReset: number | null = null;
if (last.resetsAt) {
const toReset = (Date.parse(last.resetsAt) - Date.parse(last.ts)) / 86_400_000;
if (toReset > 0) projectedPercentAtReset = Math.round((lastVal + slope * toReset) * 10) / 10;
}There is no lastVal >= 0 condition, so for a stored poisoned series whose last record carries resetsAt, projectPace still returns a projection — a large negative percent. Worked example using the PR's own poison fixture (-1e9 -> -999999999 over 2 days, slope 0.5/day) with resetsAt 7 days after the last read: projectedPercentAtReset = -999999999 + 0.5 * 7 = -999999995.5.
That value is rendered. The service-detail pace list (pm-stack/aggregator/src/render.ts, the paces block in the service page) prints projectedPercentAtReset whenever it is non-null, independent of projectedExhaustionAt:
${p.pace!.projectedPercentAtReset != null ? ` · projected ${p.pace!.projectedPercentAtReset}% at reset` : ""}So the service page can show "projected -999999995.5% at reset" for exactly the stored-poison records #2346/#3411 set out to neutralise. (The quota-card pace line is safe only incidentally: it returns early unless projectedExhaustionAt is set.)
Evidence
- Source PR reviewed: aggregator(derive): projectPace RangeError guard — no projection for out-of-domain pct (#2346) #3411 "aggregator(derive): projectPace RangeError guard — no projection for out-of-domain pct (aggregator(derive): projectPace throws RangeError on validator-passing pct records — one poisoned snapshot breaks the quota card, service page, and service.json #2346)" — aggregator(derive): projectPace RangeError guard — no projection for out-of-domain pct (#2346) #3411 (merged, commit 15e9a54). Its stated contract: an out-of-domain last value "yields no projection (
projectedExhaustionAt: null; slope/points still reported)". - Current main
b830347c2a5398ef5a1846e6ee4a424e9793bd93(verified via gh api x2):derive.tsprojectPace— thelastVal >= 0condition gates only theprojectedExhaustionAtcandidate; theprojectedPercentAtResetblock below it has no domain check.render.ts:2370printsprojectedPercentAtResetwhenever non-null;render.ts:2039(card pace line) is exhaustion-gated. - Test gap: aggregator(derive): projectPace RangeError guard — no projection for out-of-domain pct (#2346) #3411's regression tests (
test/usage.test.ts, "pace: out-of-domain pct yields no projection and never throws (aggregator(derive): projectPace throws RangeError on validator-passing pct records — one poisoned snapshot breaks the quota card, service page, and service.json #2346)") construct the poison records with therec()helper without aresetsAtargument, so theprojectedPercentAtResetpath is never exercised for out-of-domain values; no test on current main asserts it is null for a negative last value. - Reachability: the poisoned records at issue are previously stored snapshot rows read back through
SnapshotStore.readAll()(the aggregator(derive): projectPace RangeError guard — no projection for out-of-domain pct (#2346) #3411 PR itself tests that path); pct snapshot records routinely carryresetsAt(it is part ofSnapshotRecordand set by the quota extractors), so a stored negative-pct row with a reset stamp is the realistic shape. - Dedupe: aggregator(derive): projectPace throws RangeError on validator-passing pct records — one poisoned snapshot breaks the quota card, service page, and service.json #2346 is CLOSED by aggregator(derive): projectPace RangeError guard — no projection for out-of-domain pct (#2346) #3411 and covers the RangeError / exhaustion projection only; a search for
projectedPercentAtResetreturns only aggregator: forecast per-pool quota exhaustion intervals #3983 (OPEN, a separate per-pool forecast-interval feature that complements the pace derivation — it does not cover this guard gap). No open or recently closed issue mentions the at-reset projection for out-of-domain values.
Why it matters
#2346's failure class was one poisoned snapshot record breaking or corrupting the quota surfaces. #3411 closed the crash and the exhaustion date, but left the same poisoned input producing an absurd rendered number on the service page — the projection the PR said would not be yielded is still yielded, just in the sibling field. It is a small, well-bounded remainder of an already-agreed fix, not a new design question.
Acceptance criteria
- For a pct series whose last value is out of domain (
< 0),projectPacereturnsprojectedPercentAtReset: nullas well asprojectedExhaustionAt: null(slope/points still reported, per aggregator(derive): projectPace RangeError guard — no projection for out-of-domain pct (#2346) #3411's contract). - Regression test in
pm-stack/aggregator/test/usage.test.ts: the aggregator(derive): projectPace throws RangeError on validator-passing pct records — one poisoned snapshot breaks the quota card, service page, and service.json #2346 poison fixtures (e.g.-1e9 -> -999999999) withresetsAtset on the last record assert both projection fields are null. - In-domain behaviour unchanged: the existing control case (30 -> 40,
projectedPercentAtReset80) and the rest of the usage suite keep passing. - No change to the
isSnapshotRecordnegative-pct boundary guard or to the render layer required — the fix belongs inprojectPace, the owning derivation.
agent-note:v1 — Agent: pr-diff-review-b; state: filed. Filed from PR #3411 diff review (lane B, 2026-11-05 run); verified against current main b830347.
Activity
developing-today commentedon Nov 5, 2026
CODE-1878
dezren39 commentedon Nov 5, 2026
🤖 Agent note · handed off
152 remaining items
dezren39 commentedon Nov 10, 2026
agent-note:v1 lane=code-f task=11414 stage=awaiting_ci — Resumed task 11414 at stage pr_opened (implementation by lane code-v, commit 0a095da, branch queue/11414-6316-projected-percent-guard). The GitHub rate limit has cleared, so PR #8070 was created from outbox entry OB-2026-11-09-T11414V1803-PR exactly as prepared. Fresh verification by lane code-f: bun test test/usage.test.ts — 49 pass, 0 fail; diff vs main is only pm-stack/aggregator/src/derive.ts + test/usage.test.ts; no Codex findings posted. PR checks still QUEUED after ~5 min, so task 11414 is parked 1200s per the CI rule. Resume: read PR #8070 checks + Codex findings fresh, merge when green, then complete task 11414 fixed_merged.
dezren39 commentedon Nov 10, 2026
🤖 Agent note · parked
dezren39 commentedon Nov 10, 2026
🤖 Agent note · resumed + merging
lastVal >= 0 && last.resetsAt+ regression test in usage.test.ts asserting both projections null (slope/points retained). Laptop:bun test test/usage.test.ts49 pass / 0 fail.bun run typecheck: 8 errors, all in unrelated test files (coverage/feed/roadmap-annotations/saas-extract-surrogate) — identical count on clean origin/main, pre-existing; none in derive.ts or usage.test.ts. Codex review on PR fix(aggregator): suppress projectedPercentAtReset for negative pct (#6316) #8070 did not complete (Codex usage limit) — no review findings exist to disposition.Merge pull request #8070 from developing-today/queue/11414-6316-proje…
dezren39 commentedon Nov 10, 2026
🤖 Agent note · done
dezren39 commentedon Nov 10, 2026
🤖 Agent note · done — already done