feat(analytics): persist recommendation outcome events#334
Merged
JSONbored merged 2 commits intoJun 3, 2026
Conversation
Adds 'rejected' as a seventh outcome state (PR with CHANGES_REQUESTED review decision after action timestamp), and separates surface and snapshotId on every persisted outcome record so later analytics can slice by product surface and context snapshot. - src/types.ts: add "rejected" to AgentRecommendationOutcomeState; add surface/snapshotId fields to AgentRecommendationOutcomeRecord; add rejected count to AgentRecommendationOutcomeSummary totals and AgentRecommendationOutcomeRepoSummary. - migrations/0018: ALTER TABLE adds surface and snapshot_id columns. - src/db/schema.ts: matching Drizzle column definitions. - src/db/repositories.ts: upsert/mapper/parse/bucket/totals/repo- summary all handle rejected and the new columns. - src/services/recommendation-outcomes.ts: fetch context snapshot per run in evaluateRecommendationOutcomes; thread surface/snapshotId through classifyRecommendationOutcome and baseOutcome; add rejected branch in pullRequestOutcomeState. - tests: fixture for all seven outcome states, surface/snapshotId capture round-trip, and privacy serialization assertion.
JSONbored
approved these changes
Jun 3, 2026
Owner
JSONbored
left a comment
There was a problem hiding this comment.
@web-dev0521 this is the analytics persistence baseline I would land first.
A few notes:
- The migration and repository changes establish the outcome-event surface that later rollups can build on.
- The test coverage is tied to the persistence behavior rather than just the API shape.
- Follow-on analytics PRs should rebase and renumber migrations after this lands.
No code changes requested.
Validation expected:
- Keep the database/unit suite green through merge.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
"rejected"as the seventh outcome state — triggered when a targeted PR receives aCHANGES_REQUESTEDreview decision after the recommendation snapshotsurfaceandsnapshotIdfields to every persisted outcome record so analytics can slice by product surface (api/mcp/github_app/…) and context snapshot0018) addssurfaceandsnapshot_idcolumns withALTER TABLE(nullable, backwards-compatible)Closes: #301
Scope
CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Validation
git diff --checknpm run actionlintnpm run typecheck— cleannpm run test:coveragelocally — 775 pass (1 skipped); pre-existing Windows failures inmcp-cli.test.tsand two syntax-error files confirmed onmainbefore this branch; coverage stays above 97%npm run test:workersnpm run build:mcpnpm run test:mcp-packnpm run ui:openapi:checknpm run ui:lintnpm run ui:typechecknpm run ui:buildnpm audit --audit-level=moderateIf any required check was skipped, explain why:
Safety
Notes
"rejected"is classified only on exacttargetPullNumbermatches withreviewDecision === "CHANGES_REQUESTED"after the action timestamp, consistent with the existing"improved"mirror conditionrejectedis counted asnegativein totals (alongsideclosed,stale,ignored)surface/snapshot_idmap cleanly:surfaceisnull(column is nullable),snapshotIdisnullprivateSummary, and public-safe action copy)