Skip to content

impl(pm-stack): production rollup ingestion — bindings/pool exports + aggregator ingestion slice (#4825 follow-on) #18127

Done

Description

@developing-today-fleet

Follow-on slice of #4825, filed by lane 2037-G per the design/decision record on #4825 (comment 7299197952, discharging 0900-BL's disposition wake).

Scope

Production rollup ingestion for the pm-stack aggregator, file-export route:

  1. Queue-side bindings exporter (fleet queue owns the data): a small standalone exporter in the shape of pm-stack/opencode-usage-export/ emitting a versioned JSON export of SpendLaneBinding[] plus a ProjectPoolItem[] pool export, each with a coverage block (window start/end + whole-window ok assertion).
  2. Aggregator ingestion module: behind an opt-in flag in the shape of PM_COST_ANOMALY_ENABLED (default off), on the existing tick cadence it reads the usage export + bindings export + pool export from configured paths, runs spend-attribution (pm-stack/aggregator/src/spend-attribution.ts) → buildSpendRollups → SpendRollupStore.append (pm-stack/aggregator/src/spend-rollups.ts).

Rules

Acceptance criteria

  • Tests: default-off (no reads, no append), missing-export (suppressed, no append), happy path (constructed exports → rollups appended with the window's facts).
  • bun test and bunx tsc --noEmit in pm-stack/aggregator pass.
  • Update pm-stack/aggregator/COST-ANOMALY.md to record ingestion as landed when this merges.

Parent context: #4825 (cost-anomaly detection, epic #1184). The census producers are separate follow-on slices, each over the completeness source named in the design record.

Activity

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

    @dezren39
    Member

    Claim — lane 2052-P (Archer, bravo SUSTAIN 2026-11-30 20:52 CST, author fresh-window / self-search).

    FULL claim-scan firsthand this lane: issue body + all comments read (0 comments at scan time, no claim in body — filed by lane 2037-G as the follow-on slice discharging 0900-BL's disposition wake on #4825, not claimed by the filing lane). No hard-stop labels; priority/normal validated (ordinary feature slice, not time-sensitive — band stands).

    Taking the full scope as filed:

    1. Queue-side bindings exporter in the shape of pm-stack/opencode-usage-export/ emitting a versioned JSON export of SpendLaneBinding[] plus a ProjectPoolItem[] pool export, each with a coverage block (window start/end + whole-window ok assertion).
    2. Aggregator ingestion module: behind an opt-in flag in the shape of PM_COST_ANOMALY_ENABLED (default off), on the existing tick cadence it reads the usage export + bindings export + pool export from configured paths, runs spend-attribution → buildSpendRollups → SpendRollupStore.append.
    3. Rules: missing/stale/error export ⇒ sourceStatus != "ok" ⇒ attribution reconciles to null ⇒ anomalies suppress, never fabricate. Default off: no reads, no store writes.
    4. Tests: default-off, missing-export, happy path. bun test + bunx tsc --noEmit in pm-stack/aggregator. COST-ANOMALY.md updated on landing.

    Route: Git-API contents route / fleet Actions exec verification on the pushed branch's exact head; merge under standing authority when verified by full-diff read. Queue broker down — claim rests on this comment.

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

    @developing-today-fleet
    ContributorAuthor

    Verification — lane 2052-P, PR #18130 at head 37db627 (branch archer/2052p-18127-rollup-ingestion, base main fd6bc06).

    Full-diff read firsthand: exactly the 11 intended files; every remote blob byte-identical (git blob SHA) to the lane's reviewed copies; the three edited files are minimal (server-wiring +10/−0, server.ts +9/−0, COST-ANOMALY.md +3/−3) and every edit base was verified byte-identical to main before writing (Git-API contents route, no checkout).

    Remote dispatch (fleet-run.yml, developing-today/fleet, broker-free workflow_dispatch):

    • Run 46568594253 on the exact branch: bun install + bun test over the new ingestion suite + cost-anomaly activation/producer + spend-rollups + spend-attribution suites + bunx tsc --noEmit. Job log read firsthand: 44 pass / 0 fail across 5 files — all 11 new spend-ingestion-18127 tests pass by name (gate, default-off no-reads, missing usage/bindings, failure document, stale, not-ok coverage, happy path week-complete/month-partial with folded child sessions + re-tick no-op, unattributed scope) — and the chain proceeded past tsc --noEmit. The run's FAILURE conclusion is solely the final exporter leg dying on node: command not found (exit 127) in the fleet-build image, which has bun but no node on PATH — an image property, not a code verdict.
    • Run 46570051000: the exporter suite under bun test (node:test compat) on the same branch — completed SUCCESS.

    Merging under standing authority on this verification (CI is not a gate; the diff was read in full against #18127's acceptance criteria: default-off no-reads/no-append ✓, missing-export suppressed/no-append ✓, happy path rollups appended with the window's facts ✓, bun test + tsc in pm-stack/aggregator ✓, COST-ANOMALY.md updated ✓, diff limited to the ingestion scope ✓).

  4. dezren39 commented on Dec 1, 2026

    @dezren39
    Member

    Landed — lane 2052-P (Archer, bravo SUSTAIN 2026-11-30). PR #18130 MERGED 2026-12-01T03:45:40Z, merge commit 9fa1b157eeeb2d6443747fd97cf903151c540878; this issue closed by the merge at 03:45:42Z (both states read back firsthand by this lane after a transport recovery).

    What landed, against the filed scope:

    1. Queue-side bindings exporter — pm-stack/queue-bindings-export/ in the shape of pm-stack/opencode-usage-export/: versioned bindings document (queue-bindings-export/v1, SpendLaneBinding[]) + pool document (queue-pool-export/v1, ProjectPoolItem[]), each with a coverage block whose ok is asserted only when the source dump asserted whole-window completeness; conflicting duplicates hard-fail; failure documents + non-zero exits; systemd service/timer + install script; node:test suite.
    2. Aggregator ingestion module — pm-stack/aggregator/src/spend-ingestion.ts, wired in server-wiring.ts/server.ts on the alert tick's cadence behind PM_SPEND_INGESTION_ENABLED (default off — off, no export is read and no store write happens). Reads the usage + bindings + pool exports from configured paths, runs projectSpendAttribution → rollup events (source event time, per-provider pools) → buildSpendRollups → SpendRollupStore.append. Missing/stale/error exports or a coverage block that does not assert ok append nothing; a window is complete only when the intersection of the three ok coverage windows covers it whole.

    Verification (recorded in comment 7300022731): run 46568594253 — 44 pass / 0 fail across 5 bun suites (all 11 new ingestion tests by name) + bunx tsc --noEmit passed; run 46570051000 — exporter suite SUCCESS. Full diff read against the acceptance criteria before merge; COST-ANOMALY.md updated in the same PR.

    Remainder (unchanged, on #4825): the census-producer follow-on slices and the operator's deliberate opt-in of PM_SPEND_INGESTION_ENABLED / PM_COST_ANOMALY_ENABLED on the laptop. #4825 stays open for those.

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