Skip to content

impl(quota-plane): stage-3 S5 — anomaly detectors: burn spike, adapter schema drift, vendor plan change #12699

Open

Description

@dezren39

Stage-3 epic #12694, slice S5. Design record: doc/2026-11-22T22-35-00Z_design_quota-plane-stage-3/ (issue #1177; hub copy files/stage-3-design-2026-11-22.md in the usage-billing-hub goal files).

Gate: work starts after Drew's review of the Stage-3 design doc (per #1177's method).

Scope: Three detectors running beside the gatherer tick (quota-watchdog pattern), each emitting into the evidence-baseline record and the alerts ledger rather than new plumbing: (a) burn spike — realized burn residual outside the forecast band from S1/S2; (b) adapter schema drift — a provider response whose parsed shape changes (fields appearing/disappearing, parse falling to the fail-closed unparseable state); (c) vendor plan change — a window limit/denominator change in consecutive snapshot records for the same service+metric.

Acceptance criteria

  • Each detector fires on at least one replayed historical incident from the snapshot store (named in the implementation PR) and stays silent across a replayed clean week.
  • A live finding lands as an evidence-baseline diff record plus an alert-ledger entry, demonstrated once (real or replay-injected).

Activity

  1. added
    kind/featureNew feature or capability request
    priority/normalOrdinary priority (the default)
    app/pm-stackpm-stack (Pad/Grist) in developing-today/code
    on Nov 22, 2026
  2. developing-today commented on Nov 22, 2026

    @developing-today
    Contributor
  3. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Picked up by felix — working this now. (Fleet queue fallback mode: the queue backend is down, so this issue's comments carry the claim. The claim stays live while felix posts progress markers; after 30 minutes of silence any other worker may pick this up.)

  4. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Progress from felix: still working

  5. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Progress from felix: still working

  6. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Implementation record — S5 anomaly detectors landed as PR #12754 (unmerged; Felix reviews).

    What was built (pm-stack/aggregator/src/quota-anomaly.ts, wired fail-soft into the gatherer tick after the S1 forecast publish):

    • Burn spike — realized next-hour burn vs the projectWindow forecast rate + the pool/window's own matured-residual p99 band (S2's construction); a spike clears band × 1.25 with ≥ 1 pt/h excess; one finding per episode, re-arm after 2h inside the band; spike residuals trimmed at maturation so the band can't ratchet. The known weekly model bias is inside the residual band by construction — bias never fires as an anomaly.
    • Adapter schema drift — parsed shape (usage keys + canonical window kinds; renames fold, models are data not schema) vs a recorded per-service baseline; additions and parse→unparseable fire at once, removals after consecutive confirming parses.
    • Vendor plan change — limit/denominator moves between consecutive snapshot records, plus per-pool window-kind set changes.

    Honesty: a series that cannot evaluate reports unevaluable with a named reason (never "no anomaly" from absent data); baselines establish silently; state loss re-baselines without an alert storm. Findings land as evidence-baseline diff records in quota-anomaly-history.jsonl + alerts-ledger incidents (postIncident, source quota-anomaly); no alerts store → the history record still stands.

    Evidence (venue: Muse sandbox; full detail in PR #12754): fail-before on pristine main (suite fails, module absent); 15 new unit fixtures + neighbouring quota suites 72/72 pass; tsc --noEmit and biome clean; no new dependencies. Store replay (20,663 records, 2026-10-20 → 2026-11-23): 84 findings — burn 35, schema 28, plan 21. The plan-change limit leg fires exactly the 9 real turso limit changes (2026-11-08, 2026-11-14); burn fires on opencode-go's 2026-10-29 blowout (72.2 pts/h vs threshold 8.3) and _openai.alt's 2026-11-11 near-total 5h burn (98.1 vs 91.2). Clean weeks: plan-change silent 2026-11-16 → 2026-11-23; burn-spike's longest silent span 2026-10-20 → 2026-10-28 with per-series gatherer-era silence (anthropic:claude-pro finding-free until 2026-11-12); schema-drift has no ≥7-day finding-free span in the store — the estate restructured adapters continuously; stated plainly in the replay report, with per-service silence (19 of 55 silent, 21 baseline-only) and the unit fixtures as the clean-data proof. The unparseable leg has no replay trace (the store records no parse outcomes) — covered by the live path + fixtures, and the report says so. The landing demonstration (history record + incident input for one replay finding) is in the replay report's final section.

    Activation: no new schedule (rides the existing quota-gatherer.timer; registry row already exists). The detectors are not live yet: the laptop aggregator runs a deployed build, so first live ticks wait on the next laptop rebuild — the same gate as #12718 and S1's live acceptance. This issue stays open for that live acceptance, like #12695.

  7. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Released by felix (outcome: done). S5 anomaly detectors implemented: PR #12754 (open, Felix reviews; not merged by the lane). Three detectors (burn spike / schema drift / plan change) in pm-stack/aggregator/src/quota-anomaly.ts, fail-soft tick hook in gather-quota.ts, replay tool scripts/quota-anomaly-replay.ts. Evidence (sandbox): fail-before on pristine main; 72/72 quota tests; tsc + biome clean; no new deps. Store replay: 84 findings (burn 35, schema 28, plan 21) incl. exactly the 9 real turso limit changes and the named burn incidents; clean weeks stated per detector (schema-drift has none in-store — stated plainly). Records: issue comment 7089090765, epic #12694 comment 7089091354. Issue stays open for live acceptance after the next laptop aggregator rebuild (same gate as #12718 / S1).

  8. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    event: implementation merged; live acceptance pending rebuild
    by: agent felix (kind muse, Muse sandbox seat)
    at: 2026-11-22

    Merged: PR #12754 — the three Stage-3 anomaly detectors (burn spike, adapter schema drift, vendor plan change). Felix re-ran the detector suite at review: 15/15, 61 expects. Findings land as evidence-baseline diff records in quota-anomaly-history.jsonl and as alerts-ledger incidents (source quota-anomaly); a series that cannot evaluate reports unevaluable with a named reason — never a silent all-clear. The burn detector's band is built from matured residuals (S2's construction), so the known weekly model bias sits inside the band and does not fire as anomaly. Store replay over 20,663 records: 84 findings after calibration (the first cut's 137 and the calibration fixes are recorded on the PR); the plan-change limit leg fires exactly the 9 real turso limit changes and nothing else in the clean week 2026-11-16 → 11-23; schema drift has no ≥7-day silent span in the store — stated plainly, with the fixtures as the clean-data proof.

    #12699 stays open for live acceptance: the detectors ride the existing quota-gatherer timer, and first live ticks wait on the laptop aggregator running the merged build — the same rebuild gate as #12718, S1 and S3.

  9. added a commit that references this issue on Nov 23, 2026
  10. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    event: correction — merged now
    by: agent felix (kind muse, Muse sandbox seat)
    at: 2026-11-22

    Correction to comment 7089106951: that note said "Merged: PR #12754", but the first merge attempt had in fact failed on a merge conflict (against S3's gather-quota.ts hook, PR #12748, which landed after the S5 branch was cut) and the PR did not land at that time. The conflict is now resolved (merge commit a507828 on the branch: both fail-soft tick hooks survive — shadow placement, then anomaly detectors — with all suites re-run green on the merged tree: anomaly 15/15, shadow 14/14, forecast 31/31, tsc clean) and PR #12754 is MERGED as of this note. Everything else in the earlier note (detector behaviour, replay results, live-acceptance state) stands as written.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions