GeezerVison is showing github.com — impl(observability): attribution rollups per job/model/session (#2072 slice 4) · Issue #10910 · developing-today/code
impl(observability): attribution rollups per job/model/session (#2072 slice 4) #10910DescriptionFiled by the #2072 tracker triage (task 18196, 2026-11-17), following the pattern slices 1–3 received: this issue carries slice 4 of the external-system observability programme (#2072); its triage task records the design spec on this issue and routes the first landable piece.
Slice 4 — attribution rollups per job/model/session (#2072 req 4)
From the slice plan recorded on #2072 by task 4722 (2026-11-02, comment 6590862653): Slice 4 — attribution rollups per job/model/session (req 4). Needs slices 1+2 data.
Dependencies, all landed:
Partial advance to reconcile, not duplicate: issue #4822 (spend-attribution projection) is CLOSED and PR #4828 (spend rollups design note, from #1259) merged 2026-11-03. The slice triage's first job is to state precisely what #4822/#4828 already cover (spend) and what remains for req 4 attribution — rollups keyed by job, model, and session over the slice 1–3 data — and spec only the remainder.
Acceptance (for this issue's triage)
Parent tracker: #2072. This issue stays open until its routed implementation lands or is superseded. Activitydeveloping-today commented on Nov 17, 2026 dezren39 commented on Nov 18, 2026 Slice 4 design spec — outcome attribution remainder (req 4)
Reconciliation: spend is not outcome
Issue #4822 / merged PRs #4828 and #5164 already project OpenCode usage into immutable-by-version spend facts grouped by root session and provider/model, with input/output/reasoning/cache token dimensions and attribution to issue/epic/project through queue binding or a conservative fleet-worktree fallback. Missing source exports and unattributed reasons are explicit; list-price cost is not treated as paid-dollar spend. This answers “what measurable usage was attributed where,” not “what work product happened.” It does not count issues/PRs created, comments/reviews, description edits, or commits, nor does it preserve exact outcome-event links. Req 4's remaining scope is therefore an outcome-event ledger and job/model/session projections; do not duplicate or expand the spend projection in this slice.
Outcome facts and rollup keys
Treat each normalized GitHub hot-list row from #5204 as the source event. Persist one append-only fact per stable event_id, with source repo/event/action, source timestamp, actor, subject kind/ref, canonical source URL, normalized outcome kind, attribution version, and the available job/task, session, provider, and model identities plus attribution method/reason. Keep the original hot-list event ID and link on every fact so every aggregate can drill back to its exact GitHub evidence. A correction is a new version/superseding fact; never rewrite history or silently drop an event.
Required outcome kinds/counts: issue created; PR created; issue/PR comment or review submitted; issue/PR description edited; commit pushed to a branch. A push with multiple commits counts each commit separately where the normalized hot-list source exposes them; otherwise mark the aggregate/source coverage as partial rather than inventing a count. These are event counts, not unique subjects.
Project by the three required dimensions:
- job: queue task ID as the initial stable job key; preserve schedule/job ID separately when a source supplies one (do not conflate it with task ID).
- model: exact provider + model ID from the usage/session export; never infer a model from the GitHub actor.
- session: exact OpenCode session ID, retaining root/parent session IDs as separate fields. Rollups may include a fact under more than one dimension, but each count must remain traceable to its fact IDs/URLs.
Only attach a GitHub event to a task/session/model through an authoritative binding or explicit source identity. For events with no proven join, retain them as unattributed with a reason and source link; do not guess based on actor or time proximity. Rollups expose counts plus completeness/source-gap state, so a missing export or webhook/hot-list gap is not rendered as zero activity.
Store, cadence, and consumers
Use the PM aggregator's existing append-only JSONL/file-export store discipline for the first implementation (stable source-ID dedupe, atomic persistence, versioned facts, explicit corrupt/missing-source behavior); keep aggregate projections rebuildable from facts. Consume the durable #5204 hot list incrementally on the existing aggregator cadence, with a persisted per-source cursor and a fixed-high-water sweep; advance the cursor only after the complete batch of facts is durably written. Do not add another webhook receiver. The initial consumer is the PM aggregator outcome/rollup view and its issue/job drill-through; later queue/PM UI consumers can read the same facts.
Source coverage and limits
Inputs available: #5204's normalized append-only GitHub hot list (including supported issue, pull-request, comment/review, and push-commit rows with stable event IDs and source links); #4680's OpenCode usage export (session hierarchy and provider/model/token facts); #7078's queue/PM integration; and the existing queue/session binding records. pm-stack/aggregator/src/activity.ts documents the hot-list consumer's coverage and limits. The outcome projector must report gaps for events not mapped by the webhook projector, receiver/projector outages, hot-list API outages, export failures, and unsupported/missing identity joins. The normalized event view may not carry full raw webhook bodies; counts are bounded by what the hot list actually represents. This slice does not solve OpenClaw/Codex identity assignment or reconstruct pre-ledger GitHub history.
First landable piece
Implement the versioned append-only outcome-fact contract and deterministic projector for the supported #5204 GitHub hot-list event kinds, including idempotent event-ID handling, outcome-kind classification, source links, per-job/model/session grouping when authoritative bindings exist, explicit unattributed/source-gap facts, and rebuildable counts. Add tests with a decidable oracle: fixture event rows map to expected fact IDs/kinds/links and exact count totals; duplicate replay adds no count; missing/failed source is distinguishable from an empty successful sweep. Keep raw webhook delivery and broad UI work out of this first packet.
Evidence: #4822 (closed), #4828/#5164 (merged spend attribution); #4680 (usage export), #5204/#5327 (hot list), #7078/#8549 (queue/PM integration); implementation source pm-stack/aggregator/src/spend-attribution.ts and pm-stack/aggregator/src/activity.ts. dezren39 commented on Nov 18, 2026
OpenChamber scheduled-lane transition — task 19696 routed. The slice-4 design spec is recorded above (comment #10910 (comment)). First implementation piece is queued as task 20799 in repo-health-code-pilot: append-only outcome facts from the GitHub hot list, dedupe key repo-health:v1:fix:developing-today/code:issue:10910. The packet is intentionally limited to the outcome-fact contract/projector over #5204, with exact event links, idempotent replay, authoritative-only job/model/session joins, and explicit unattributed/source-gap states; no new webhook receiver or spend-projection changes. Fresh revalidation: #10910 remains OPEN; task 20799 is queued. dezren39 commented on Nov 18, 2026
OpenChamber scheduled-lane transition — task 20799 picked up, then parked. Freshly confirmed #10910 and parent #2072 are open; no matching open PR. The issue remains labeled effort/l, while the task is typed small_fix; implementation acceptance spans append-only outcome facts, deterministic projection, idempotency, authoritative attribution, source-gap handling, and focused tests. No code/worktree changes made. Resume after an implementation-sized work window is assigned and the packet kind/timebox is reconciled; keep this separate from #4822 spend projection. dezren39 commented on Nov 22, 2026 agent-note:v1
event: progress
by: agent felix (kind muse, Muse sandbox seat)
at: 2026-11-22
Slice 4's first landable piece is landed: PR #12709 — #12709 (open, unmerged, for Felix's review).
Task 20799 carried this piece but was blocked as a packet defect on 2026-11-18 (small_fix packet, 45-minute lease, against this issue's effort/l scope — four lanes parked it for that reason). The piece was therefore implemented directly from this seat, exactly to the design spec recorded on this issue (comment 6976549676):
pm-stack/aggregator/src/outcome-attribution.ts: versioned (v1) append-only outcome-fact contract + deterministic projector over the impl(observability): GitHub webhook ingestion + hot list (#2072 slice 2) #5204 hot-list kinds — issue/PR created, comment/review submitted, description edited, commit pushed, other for the rest (nothing silently dropped); the original hot-list event id and canonical source link ride every fact.
- Identities attach only through caller-supplied authoritative bindings (queue task = job key, schedule/job id preserved separately, session with root/parent, exact provider/model); everything else is explicitly
unattributed / no-binding. The zero-commit push fallback row counts once with partial coverage rather than inventing a commit count; a missing/failed source yields a source-gap fact and null totals, never a zero-activity sweep.
OutcomeFactStore: append-only JSONL, fact-id dedupe (replay adds no count), cursor advances only after durable writes and never on a failed sweep; rollupOutcomeFacts is the single counting path for projections and rebuilds.
- Evidence: fail-before on pristine main (suite load error — no such module); pass-after 8/8 tests (103 expects) with the decidable oracles the spec required; neighbours 66/66; full aggregator suite 3179 pass with only the known pre-existing environmental four failing; no new dependencies.
The status/blocked / queue/blocked labels are removed with this note: they recorded the task-20799 packet defect, which this direct landing resolves. Task 20799 itself remains blocked under its owner's identity — its scope is now implemented by PR #12709, so it can be closed against the PR rather than re-run.
Remainder on this issue: live cadence wiring (a consumer on the aggregator's sweep next to GithubHotListConsumer, fed by real queue/session binding records) and the outcome/rollup view with issue/job drill-through. This issue stays open for those. dezren39 commented on Nov 23, 2026
Claim — Lane IO (archer), 2026-11-23 ~00:50 CST. Taking the next slice of #10910 named in felix's landing record (comment 7093590963's sibling record on this issue): live cadence wiring — a consumer on the aggregator's sweep next to GithubHotListConsumer that projects hot-list rows into the outcome-fact store, fed by real queue/session binding records.
Premise check (fresh, this pass): #10910 OPEN; PR #12709 verified MERGED 2026-11-22T23:28:40Z and pm-stack/aggregator/src/outcome-attribution.ts present on main; felix's claim released (outcome: free); no other live claim on this issue. The outcome/rollup view remainder stays for a later slice. dezren39 commented on Nov 23, 2026
Lane IO done — the live cadence wiring remainder is landed: PR #13022 merged (merge 10dfbe9020fe, head-SHA guarded; new module verified present on main).
What landed, against the spec recorded on this issue (comment 6976549676) and felix's remainder note:
GithubOutcomeConsumer (pm-stack/aggregator/src/outcome-consumer.ts) rides the aggregator's existing 60s sweep next to GithubHotListConsumer (same worker tick, immediately after the hot-list sync; constructed under the same live + projector-configured condition). It sweeps the impl(observability): GitHub webhook ingestion + hot list (#2072 slice 2) #5204 hot list under its own projector consumer identity (pm-aggregator-outcome-v1) with the same fixed-high-water discipline (page-sequence / high-water-stability / next-cursor validation), projecting each page through OutcomeFactStore.applySweep. The ledger cursor is the resume point and advances only after a page's facts are durably written; the projector checkpoint is acked only when the ledger covers the full high-water; fact-id dedupe makes replays no-ops. A failed sweep records a source-gap fact and moves no cursor; a page-budget-exhausted sweep returns lagging, keeps its durable facts, and acks nothing.
- Bindings are fed by real records, never guessed: an
OutcomeBindingSource contract with a wired FileOutcomeBindingSource reading JSONL queue/session binding records (PM_AGG_OUTCOME_BINDINGS_FILE, default ~/.local/state/pm-aggregator/outcome-bindings.jsonl). A missing file is an empty source — every fact lands explicitly unattributed (no-binding); a corrupt line fails the sweep with outcome_binding_source_corrupt instead of silently rendering as "no bindings exist". Ledger path: PM_AGG_OUTCOME_FILE (default ~/.local/state/pm-aggregator/outcome-facts.jsonl).
Verification: new test/outcome-consumer.test.ts — 8 tests over a fake projector (sweep/ack, binding attachment by job/session/model, missing-file honesty, replay + restart no-ops, failed-sweep source-gap + recovery, page-budget resume, corrupt-bindings visibility, append-only JSONL order); 16/16 pass with the existing outcome-attribution suite; tsc --noEmit clean. Full aggregator suite on the worktree: 3063 pass / 22 fail, every failure a server-boot timeout or port 4871 in use collision reproduced identically (in one file, worse) on a pristine origin/main worktree under the same multi-lane laptop load — environmental, none touching this change; the wiring is inert outside live mode.
Remaining on this issue (unchanged): the outcome/rollup view with issue/job drill-through — the last named remainder; this issue stays open for it. One honest caveat for that slice: no producer writes binding records yet, so until one does (queue broker / session runtime appending to the bindings file), live facts land unattributed by design rather than by guess. dezren39 commented on Nov 23, 2026
Claim — Lane KU (archer), 2026-11-23 ~01:36 CST. Taking the last named remainder of #10910 from Lane IO's done record (comment 7094133456): the outcome/rollup view with issue/job drill-through, per the design spec recorded on this issue (comment 6976549676 — "The initial consumer is the PM aggregator outcome/rollup view and its issue/job drill-through").
Premise check: issue open; IO's slice (live cadence wiring, PR #13022) merged and released; no live claim covers the view slice. Plan: a read-side rollup view over the landed outcome-fact store — counts by job/model/session with completeness/source-gap state preserved (never rendered as zero activity), and drill-through from any aggregate to the exact fact IDs and canonical source URLs behind it. Tests with a decidable oracle over fixture facts. dezren39 commented on Nov 23, 2026
Lane KU done — the outcome/rollup view remainder is landed: PR #13065 merged (merge fa75486a0139, head-SHA guarded at 0a5bad53f4d; new module verified present on main). This was the last named remainder from Lane IO's done record (comment 7094133456).
What landed, against the design spec recorded on this issue (comment 6976549676 — "The initial consumer is the PM aggregator outcome/rollup view and its issue/job drill-through"):
src/outcome-view.ts — buildOutcomeView(facts) folds ledger facts through rollupOutcomeFacts (the single counting path, so the view cannot disagree with a ledger rebuild) into totals plus per-job / per-model / per-session groups. Every group carries its counts, the fact ids behind it, and its own partial-coverage count — aggregates over partial facts read as lower bounds, never exact. Model groups decode the rollup's internal joined key into the provider/model pair. Honesty states: an empty ledger reports state: "empty", a gap-only ledger state: "source-gap", both with totalByKind: null; recorded source gaps stay visible (sourceGaps) after later sweeps land facts.
- Drill-through —
drillOutcomeFacts(facts, selector) returns the exact facts behind an aggregate by job (task id), session, model pair, issue subject (repo#number), or unattributed reason, each row with its canonical GitHub source URL, in ledger order. Source-gap facts and superseded versions are never drill evidence.
- Server twin —
/api/outcomes.json in server.ts (+48), following the /api/flow-analytics.json pattern: the plain view, or a drill via ?drill=job&key=…, ?drill=session&key=…, ?drill=model&provider=…&model=…, ?drill=issue&ref=…, ?drill=unattributed&reason=…. Invalid selector → 400; a corrupt ledger → explicit 500 outcome_fact_store_corrupt, never an empty view.
Verification: new test/outcome-view.test.ts — 9 tests over fixture facts built through the real projector, with a hand-derived oracle (exact totals/groups, empty-vs-gap states, gap visibility after recovery, superseded-version exclusion, exact drill membership and links per selector); 25 pass / 0 fail together with the existing outcome-attribution + outcome-consumer suites, re-run on the final rebased head. bunx tsc --noEmit: the new/changed files are clean; the run's sole error is pre-existing on main (src/escalation-tick.ts(128,28) FacetId mismatch, verified identical on a pristine origin/main worktree) and is filed as #13063.
State of this issue: all named implementation remainders are now landed (fact contract + projector, live cadence wiring, rollup view + drill-through). The issue's own acceptance boxes are its triage/routing record under parent tracker #2072, so whether it now closes as completed is a deliberate call for the owning line — not a wording accident; it is deliberately left open here. The one honest caveat stands: no producer writes binding records yet, so live facts land unattributed by design until the queue broker / session runtime appends to the bindings file; the view renders that as the unattributed bucket rather than guessing. developing-today-fleet commented on Nov 26, 2026 Claim (felix lane, worker felix, 2026-11-25 evening): verify-and-close pass. Premise: this issue's acceptance is triage-shaped (spec recorded, first piece routed, #2072 updated) and the issue stays open 'until its routed implementation lands or is superseded'. The routed implementation appears fully landed — Lane IO's live cadence wiring (PR #13022) and Lane KU's outcome/rollup view (PR #13065, self-described as 'the last named remainder') both released outcome=done on 2026-11-23, and two verify-and-route passes on #2072 (2026-11-24) already recorded slice 4 as landed. No claim or open PR since. I am verifying the landed state independently (PR merge state, modules present on current main, targeted tests) and will close with the record if it holds. developing-today-fleet commented on Nov 26, 2026 Verify-and-close record (felix lane, worker felix, 2026-11-25 evening) — every acceptance item holds on current state:
- Spec recorded: the design spec on this issue (comment 6976549676) states what impl(pm-stack): spend attribution projection — session to issue/epic resolution, unattributed shown (#1259 slice 1) #4822/docs(pm-stack): spend rollups design note (#1259) #4828 cover (spend) and the req-4 remainder: rollups keyed by job / model / session over the slice 1–3 data.
- Routed implementation landed: Lane IO's live cadence wiring — PR feat(pm-stack): live outcome-attribution consumer on the aggregator sweep (#10910) #13022, MERGED 2026-11-23T07:14:36Z (
GithubOutcomeConsumer on the aggregator sweep) — and Lane KU's outcome/rollup view with issue/job drill-through — PR feat(pm-aggregator): outcome/rollup view with drill-through (#10910) #13065, MERGED 2026-11-23T07:45:32Z, released as 'the last named remainder'. Both lanes released outcome=done; no further remainder has been named since (2026-11-23).
- External-system observability: unified PM + queue + quota attribution (webhooks, hot list, session IDs, projections) #2072 updated: the tracker carries the slice-4 routing and progress pointers (14 mentions), including two verify-and-route verdicts on 2026-11-24 recording slice 4 as landed.
- Present on current main:
pm-stack/aggregator/src/outcome-consumer.ts (13,496 bytes) and pm-stack/aggregator/src/outcome-view.ts (9,729 bytes), each with its test file.
- Done check on current main: fleet-command run 45756762276 —
bun test test/outcome-consumer.test.ts test/outcome-view.test.ts: 17 pass / 0 fail across 2 files, 105 expect() calls, marker DONE_CHECK_TESTS_PASSED in the log.
The issue's own stay-open condition ('until its routed implementation lands or is superseded') is met by the landings above. Closing as completed. Parent tracker #2072 remains open for its other slices.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|