Skip to content

impl(pm-stack): spend rollup store — weekly/monthly per project/epic, versioned restatement (#1259 slice 2) #4823

Open

Description

@dezren39

Part of epic #1184; implementation follow-up of design issue #1259 (spend rollups). Design note: doc/spend-rollups-design-1259.md. Depends on the attribution projection slice of #1259.

Scope

Persist weekly and monthly spend rollups per project and per epic from the snapshot history, in the existing append-only snapshot store pattern (pm-stack/aggregator/src/snapshots.ts): one rollup record per (window, scope, unit) with full unit separation.

Rules (per the design note)

  • Three unit families are stored and rendered as distinct measures, never merged: tokens per pool; PAYG dollars (real charges only); plan-pool share-of-window (percent of a pool window consumed).
  • A week/month counts only if the source was available for the whole window; partial windows are labelled partial, never read as zero spend.
  • Rollups are immutable once written for an attributionVersion. When attribution rules change, history is restated as a new version alongside the old, with the version labelled in output — raw events are never edited and old rollups are never silently overwritten.
  • Backfill horizon: from the start of retained snapshot history; the rollup record names its coverage start so a short history cannot masquerade as a long one.

Acceptance criteria

  • Rollup writer + reader with tests: complete window, partial window, restatement under a new attribution version, and coverage-start labelling.
  • Reconciliation test: rollup totals equal projection totals for the same window/version.
  • No merged cross-unit figure exists anywhere in the stored schema (schema review + a test that rejects a synthetic merged field).

Checks

  • bun test and bunx tsc --noEmit in pm-stack/aggregator pass (CI on the PR).

Activity

  1. added
    kind/featureNew feature or capability request
    priority/normalOrdinary priority (the default)
    effort/mMedium: expected under 1 day of work
    app/pm-stackpm-stack (Pad/Grist) in developing-today/code
    on Nov 3, 2026
  2. added
    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
    on Nov 3, 2026
  3. dezren39 commented on Nov 3, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    state: triaged (coverage pass)
    Coverage pass 2026-11-03: reviewed in the fleet-wide per-issue pass (drift / overlap / already-handled / stale / blockers / ordering). Verdict: still live; queued in repo-health-code-pilot as triage at priority 40 (priority/normal). If this is already handled at current main, the triage closes it with evidence; if it needs splitting, the triage files the split.
    Found via: coverage pass 2026-11-03

  4. dezren39 commented on Nov 3, 2026

    @dezren39
    MemberAuthor

    Triage at current main (3e363c9), queue task 8439

    Verdict: still live, not routable yet. No queue task is enqueued from this triage. The implementation should be queued after #4822 merges, and the blocker stays on this issue until then. Priority and effort labels unchanged.

    Found via: coverage pass 2026-11-03

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

Metadata

Metadata

Assignees

Labels

app/pm-stackpm-stack (Pad/Grist) in developing-today/codeeffort/mMedium: expected under 1 day of workkind/featureNew feature or capability requestpriority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobtask/triageQueue packet kind: verify, reproduce, and route this item

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions