Repository navigation
feat(pm-stack): outcome attribution projector over the GitHub hot list (#2072 slice 4) - #12709
Conversation
#2072 slice 4) Implements the first landable piece of the #10910 design spec: a versioned append-only outcome-fact contract and deterministic projector for the supported #5204 hot-list event kinds. - projectOutcomeAttribution maps normalized hot-list rows to outcome facts (issue/PR created, comment or review submitted, description edited, commit pushed, other) with the original event id and canonical source link on every fact, so each aggregate drills back to its exact GitHub evidence. - Identities (queue task, schedule job, session/root/parent session, provider/model) attach only through caller-supplied authoritative bindings; everything else is explicitly unattributed with a reason. A model is never inferred from the GitHub actor. - A push row that exposes no commit list counts once with partial coverage instead of inventing an exact commit count. - A missing/failed source yields a source-gap fact and null totals: unknown, never a zero-activity sweep. - OutcomeFactStore persists facts as append-only JSONL with fact-id dedupe (replay adds no count) and a cursor that advances only after the batch is durably written; rollupOutcomeFacts is the single counting path for projections and ledger rebuilds alike. - Malformed hot-list rows throw the activity contract's invalid_hot_event_* errors instead of minting facts. Tests: test/outcome-attribution.test.ts, 8 tests / 103 expects — fixture rows map to expected fact ids/kinds/links and exact totals; duplicate replay adds no count; missing source is distinguishable from an empty successful sweep. Full aggregator suite: 3179 pass, 4 fail (the known pre-existing environmental set, identical at pristine main: charges-feed-gate, curation-1497, deriveEpicEta under load, phase-mapping without planning/ materialized). No new dependencies. Live cadence wiring (a consumer on the aggregator's sweep, next to GithubHotListConsumer) and the outcome view are the follow-on pieces on #10910.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 9 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: beaa3cd7b7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const perCommit = event.event_id.split(":").includes("commit"); | ||
| return perCommit | ||
| ? { outcomeKind: "commit-pushed", subjectKind: "commit", coverage: "complete" } | ||
| : { outcomeKind: "commit-pushed", subjectKind: "push", coverage: "partial" }; |
There was a problem hiding this comment.
Avoid counting empty pushes as committed work
For branch/tag deletions and other pushes with an empty commit list, this fallback adds one commit-pushed outcome even though no commits were pushed. In pm-stack/projector/src/projector.ts:400-407, the producer emits a push:<after> row whenever commits.length === 0, not only when commit information is unavailable. Marking the count as partial does not satisfy the documented lower-bound contract: one is not a lower bound on zero. Preserve these rows as push/other outcomes or represent their commit quantity as unknown rather than incrementing the commit count.
Useful? React with 👍 / 👎.
| const projection = projectOutcomeAttribution(input); | ||
| const existing = new Set((await this.readFacts()).map((fact) => fact.factId)); | ||
| const fresh = projection.facts.filter((fact) => !existing.has(fact.factId)); |
There was a problem hiding this comment.
Return replay projections consistent with persisted attribution
If an event is first persisted without a binding and then replayed with an authoritative binding, the new projection contains attributed byJob/byModel/bySession counts, but the fact-ID dedupe discards that updated fact. applySweep() therefore reports attribution that cannot be rebuilt from its ledger, which still contains the original unattributed fact. The immutable-by-version policy can remain intact, but existing IDs need to resolve to their stored attribution or explicitly require a correction/version change instead of returning an unpersisted projection.
Useful? React with 👍 / 👎.
| const existing = new Set((await this.readFacts()).map((fact) => fact.factId)); | ||
| const fresh = projection.facts.filter((fact) => !existing.has(fact.factId)); | ||
| const cursor = await this.cursor(); | ||
| if (fresh.length > 0) { | ||
| await mkdir(dirname(this.file), { recursive: true }); | ||
| await appendFile(this.file, fresh.map((fact) => `${JSON.stringify(fact)}\n`).join(""), "utf8"); |
There was a problem hiding this comment.
Serialize the complete sweep persistence operation
When two applySweep() calls overlap on the same store, both can read the ledger before either appends and classify the same fact as fresh. Both then append it, and rollupOutcomeFacts() counts both copies, permanently inflating reconstructed totals. Overlapping checkpoint writes also share the same .state.json.tmp path, so they can interfere or fail during rename. Serialize the entire read/dedupe/append/checkpoint operation, as the sibling IngestionStore.ingest() does in activity.ts:619-631; serializing only individual writes would leave the duplicate-count race intact.
Useful? React with 👍 / 👎.
Implements the first landable piece of the #10910 design spec (slice 4 of #2072, req 4 outcome attribution). Task 20799, which carried this piece, was blocked as a packet defect on 2026-11-18 (a
small_fixpacket against aneffort/lscope); this PR lands the piece directly.What it does
projectOutcomeAttribution— deterministic projector from normalized impl(observability): GitHub webhook ingestion + hot list (#2072 slice 2) #5204 hot-list rows (GithubHotEvent) to append-only outcome facts: issue created, PR created, comment/review submitted, description edited, commit pushed, andotherfor everything else the projector emits (nothing is silently dropped). Every fact keeps the original hot-listevent_idand the canonical source link (reusinggithubHotEventDelivery's validation and link derivation), so every aggregate drills back to its exact GitHub evidence.unattributedfact with reasonno-binding. A model is never inferred from the GitHub actor.coverage: "partial"and surfaces inpartialCoverage, never as an exact commit count. A missing/failed source produces a source-gap fact andtotalByKind: null— unknown, not a zero-activity sweep. Malformed rows throw the activity contract'sinvalid_hot_event_*errors.OutcomeFactStore— append-only JSONL ledger with stable fact-id dedupe (replay adds no count), a cursor persisted (tmp + rename) only after the batch is durably written and never advanced on a failed sweep, and an explicitoutcome_fact_store_corrupterror on a corrupt line.rollupOutcomeFactsis the single counting path for live projections and ledger rebuilds, and counts only the current attribution version, so a re-projection supersedes rather than double-counts.Evidence
Cannot find module '../src/outcome-attribution.ts'.test/outcome-attribution.test.ts8/8 (103 expects) — fixture rows map to expected fact ids/kinds/links and exact totals; duplicate replay adds no count; a bound event rolls up by job/model/session while the other 11 stay unattributed; missing source is distinguishable from an empty successful sweep.planning/materialized).tsc --noEmit: no errors in the touched files (only the known sparse-worktree grist/roadmap.json set). Biome-formatted;git diff --checkclean.Remainder on #10910 after this: live cadence wiring (a consumer on the aggregator's sweep next to
GithubHotListConsumer, feeding real binding records) and the outcome/rollup view with drill-through.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.