feat(observe): resolve self-improvement attribution via GitHub artifact ownership#693
Conversation
…ct ownership Adds a run_attribution_artifacts reverse-index table so the daemon can resolve inline PR review feedback to the agent run that produced it, even when the human's /agents improve comment does not carry signed metadata. Key changes: - Migration 056: run_attribution_artifacts table mapping GitHub artifact identity (comment_id, review_id, review_comment_id) to span_id - observe/attribution_artifacts.go: CaptureArtifact method and internal lookup helpers (by review comment id, review id, comment id, PR context) - observe/attribution.go: extended AttributionQuery with CommentID, ReviewCommentID, ReviewID, InReplyToID, PullRequestReviewID, FilePath; ResolveRunAttribution now walks artifact chain before falling back to time-window inference; added mode constants (direct, artifact_comment, artifact_parent_comment, artifact_review, artifact_pr_context, commit_trailer); inferRunAttributions skips internal-catalog-analyst - webhook/handler.go: extended webhookComment with InReplyToID and PullRequestReviewID; CaptureArtifact called for every issue_comment, pull_request_review, and pull_request_review_comment delivery, not just /agents improve; feedbackCapture carries new ancestry IDs passed to AttributionQuery - 9 new focused tests covering direct metadata, artifact chain (comment, parent, review), wrong-repo rejection, invalid signature, ambiguous PR context, internal analyst exclusion from inference, unresolved fallback Closes #692 Agents-Run: 428ecb0920459b24 Agents-Agent: coder Agents-Attribution: eyJ2IjoxLCJpbnN0YW5jZV9pZCI6InRzLWxvbmVzdGFyIiwid29ya3NwYWNlIjoiZGVmYXVsdCIsInJlcG8iOiJlbG95bHAvYWdlbnRzIiwic3Bhbl9pZCI6IjQyOGVjYjA5MjA0NTliMjQiLCJhZ2VudF9pZCI6ImFnZW50XzBmYjgyZDFmZTM0ZTQ1NDA4YmQyZmVlMTUzZjcwMDNkIiwiYWdlbnRfbmFtZSI6ImNvZGVyIiwic2lnIjoiZV9KR3RialRrS1lsZm9PM0Vla0x3N2RxLTVENmFjb25kaEcwbUZRMm5iSSJ9
PR Review — pr-reviewerVerdict: APPROVE Findings
What's correct
SummarySolid, well-scoped implementation of artifact-based attribution resolution. The three minor findings are cosmetic; the logic, SQL posture, concurrency model, and test coverage are all correct. |
Agents-Run: d59c959b56587b21 Agents-Agent: coder Agents-Attribution: eyJ2IjoxLCJpbnN0YW5jZV9pZCI6InRzLWxvbmVzdGFyIiwid29ya3NwYWNlIjoiZGVmYXVsdCIsInJlcG8iOiJlbG95bHAvYWdlbnRzIiwic3Bhbl9pZCI6ImQ1OWM5NTliNTY1ODdiMjEiLCJhZ2VudF9pZCI6ImFnZW50XzBmYjgyZDFmZTM0ZTQ1NDA4YmQyZmVlMTUzZjcwMDNkIiwiYWdlbnRfbmFtZSI6ImNvZGVyIiwic2lnIjoiSURtUnRfMjVmOXNjdmpKZ3lEQVlUZnNUa0ZsX0xjMEZQM0V5RjVoYWJkUSJ9
|
Addressed the three low review cleanup findings in
Verified locally:
|
PR Review — pr-reviewerVerdict: APPROVE Findings
SummaryCleanup commit |
|
Requested change before merge: please move the new raw SQL/persistence operations for The feature shape is correct, but the current implementation puts new SQL in Please adjust this PR as follows:
This is release-blocking because the self-improvement feature is about to become a flagship surface, and we do not want to introduce more persistence-boundary drift right before launch. |
PR Review — pr-reviewerVerdict: REQUEST_CHANGES Findings
SummaryThe feature behavior remains on target, but the latest maintainer request narrows the acceptable implementation boundary; this PR needs the artifact persistence moved into |
Route run attribution artifact persistence through typed internal/store APIs and add store-level lookup coverage. Document the SQL ownership rule in agent guidance. Agents-Run: 4964473d8b22a755 Agents-Agent: coder Agents-Attribution: eyJ2IjoxLCJpbnN0YW5jZV9pZCI6InRzLWxvbmVzdGFyIiwid29ya3NwYWNlIjoiZGVmYXVsdCIsInJlcG8iOiJlbG95bHAvYWdlbnRzIiwic3Bhbl9pZCI6IjQ5NjQ0NzNkOGIyMmE3NTUiLCJhZ2VudF9pZCI6ImFnZW50XzBmYjgyZDFmZTM0ZTQ1NDA4YmQyZmVlMTUzZjcwMDNkIiwiYWdlbnRfbmFtZSI6ImNvZGVyIiwic2lnIjoiOEtqNkJSamNOMGEzWUZUc3RxQ3NzQkZtWXk2cUdrV2toY2NLdnMxVW1USSJ9
|
Addressed the release-blocking persistence-boundary request in
Verified locally:
|
PR Review — pr-reviewerVerdict: APPROVE Findings
SummaryThe requested persistence-boundary refactor is resolved: Verified locally:
|
Summary
run_attribution_artifactstable (migration 056) as a narrow reverse-index from GitHub artifact identity (comment_id, review_id, review_comment_id) tospan_id, keepingrun_attributionsas the canonical run-fact sourceAttributionQuerywithCommentID,ReviewCommentID,ReviewID,InReplyToID,PullRequestReviewID,FilePathto carry artifact ancestry context into the resolverResolveRunAttributionnow walks the artifact ownership chain (comment → parent reply → owning review → conservative PR context) before falling back to time-window inference; addedmodeconstants (direct,artifact_comment,artifact_parent_comment,artifact_review,artifact_pr_context,commit_trailer,inferred,unresolved)inferRunAttributionsnow excludesinternal-catalog-analystruns from loose inference — only exact signed metadata or artifact ancestry can resolve to those agentswebhookCommentextended withInReplyToIDandPullRequestReviewID;CaptureArtifactis called for everyissue_comment,pull_request_review, andpull_request_review_commentdelivery (not just/agents improve), storing valid signed artifacts in the reverse-indexTest plan
go test ./internal/observe/...— all 9 new artifact tests passgo test ./internal/webhook/...— existing webhook tests still passgo test ./internal/store/...— migration applied, schema validatesgo test ./...— full suite greenCloses #692