Skip to content

impl(pm-stack): census data producers for cost-anomaly certified seams (#4825 follow-on) #18137

Done

Description

@dezren39

Follow-on slice of #4825, filed by lane 2137-E per the design/decision record on #4825 (comment 7299197952, lane 2037-G): "Each census producer becomes a bounded slice as an export-shaped adapter over its named completeness source."

Scope

Pure census producers in pm-stack/aggregator that build the census arrays the certified sources (src/cost-anomaly-rollup-sources.ts) consume, over the completeness sources named in the design record:

  1. Root-session census — from spend attribution output: attribution facts already fold sub-sessions into their root group (spend-attribution.ts); one RootSessionCensusEntry per (epic, pool, root session), tokens = the ingestion scalar convention (totalTokens: input+output+reasoning+cacheRead+cacheWrite, per src/spend-ingestion.ts), pool = providerID ?? "unknown". Completeness source: the usage export's coverage block (caller-supplied spans).
  2. Source-population census — from the session set itself: per-pool totals before attribution, one SourcePopulationCensusEntry (unit tokens) per pool. Completeness source: the pool/usage export coverage (caller-supplied spans).
  3. Closure census — from caller-supplied per-scope child-closure timestamps (the aggregator's GitHub issue reads over the window). Completeness source: the read's window + pagination-exhausted marker — coverage is ok only when the caller asserts the read was complete (pagination exhausted); otherwise the emitted span is non-ok and certification yields partial.

Rules

  • A producer never certifies beyond its source: when the source status is not ok, emitted coverage spans are downgraded to non-ok, so the certified seams return partial/null and anomalies suppress, never fabricate (the impl(pm-stack): cost-anomaly detection to Needs-you via the alert throat (#1259 slice 4) #4825 core rule).
  • Pure and deterministic: no I/O, no clock reads. Invalid inputs (non-finite/negative tokens, unparseable timestamps, closures outside the window) are excluded or counted only in-window, never silently certified.
  • This slice does NOT wire the producers into the production caller and does not change activation (default-off stance unchanged); wiring is a later slice.

Acceptance criteria

  • Tests: root census folding + per-pool split, source-population per-pool totals, closure counting in-window only, non-ok source downgrades coverage (certified seams then report partial), happy path through the real certified seams (certifiedBusiestRoot / certifiedSourceTotal / certifiedClosedChildren) returning complete on whole-window ok coverage.
  • bun test and bunx tsc --noEmit in pm-stack/aggregator pass.
  • Update pm-stack/aggregator/COST-ANOMALY.md to record the census producers as landed when this merges.

Parent context: #4825 (cost-anomaly detection, epic #1184). Production rollup ingestion landed separately as #18127 / PR #18130.

Activity

  1. added
    kind/feature
    priority/normal
    effort/m
    app/pm-stack
    epic/pm-stack
    on Dec 1, 2026
  2. dezren39 commented on Dec 1, 2026

    @dezren39
    MemberAuthor

    Claim — lane 2137-E (Archer, alpha DRIVE 2026-11-30 21:37 CST).

    FULL claim-scan firsthand this lane: #4825 body + all 61 comments read; the 2037-G design record (comment 7299197952) names each census producer as a bounded follow-on slice, and a live search of open issues referencing #4825 found only #18127 (ingestion; live-claimed by 2052-P and landed by its owner via PR #18130, merged 2026-12-01T03:45:40Z) — no census-producer slice was filed, so this lane filed this issue and takes it. #18127 itself was stood off silently (live claim), per lane orders.

    Scope as filed: pure producers for the root-session, source-population, and closure censuses over their named completeness sources, feeding the existing certified seams in cost-anomaly-rollup-sources.ts; non-ok source ⇒ non-ok coverage ⇒ suppression, never fabrication. No production-caller wiring, no activation change.

    Route: Git-API contents route on a branch, verification via targeted tests on the exact head + full-diff read; merge under standing authority when verified. CI is not a gate. Queue broker down — claim rests on this comment.

  3. developing-today-fleet commented on Dec 1, 2026

    @developing-today-fleet
    Contributor

    Resolution — lane 2137-E (Archer, alpha DRIVE 2026-11-30).

    Landed: PR #18138 #18138 MERGED, merge commit 67381ebc45b9481d770ee07f2c814adeb69a550f, head 8ba8d1dc5308c8901a00725e0c964773eed47855 — pm-stack/aggregator/src/cost-anomaly-census-producers.ts: the root-session census (from attribution facts, ingestion pool/token conventions), the source-population census (pre-attribution per-pool totals), and the closure census (in-window counts, ok only on a caller-asserted complete/pagination-exhausted read). Non-ok source, corrupt record, or truncated read downgrades emitted coverage, so the certified seams suppress and never fabricate. COST-ANOMALY.md updated in the same PR.

    Verification: full diff read against this issue's acceptance criteria (3 files, module + test byte-identical to the staged copies tested); targeted bun test on the authored files with their real in-repo dependencies: 8 pass / 0 fail, including happy paths asserted through the real certified seams. CI not used as a gate per standing rules.

    #4825 stays OPEN: the remaining slice is wiring these producers into the production caller (cost-anomaly-activation.ts loader) plus the operator's deliberate opt-in. Claim released.

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

    app/pm-stackeffort/mepic/pm-stackkind/featurepriority/normal

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions