You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Build the link table that turns "this session existed" into "this session produced commit X, in PR Y, which CI passed, which has been touched 3 times since (twice to fix bugs)." The single feature that makes outcome metrics trustworthy.
Why now
Yield tab today is per-cwd git log correlation — coarse, no PR awareness, no downstream-touch awareness. Comparative benchmark (Spec 26) and risk recommender (Spec 16) both need real attribution to mean anything.
API: GET /api/attribution/commit/{sha} and /api/attribution/session/{id}.
Meta-agent tools: attribute_commit(sha) and attribute_session(id).
UI: extend Yield tab with PR / CI / "still good after N days" columns.
Implementation plan
v019 migration.
New service stackunderflow/services/attribution.py:
link_session_to_commit(conn, session_id) — heuristic: walk session messages, extract any git commit -m Bash calls + their resulting commit shas (pull from messages.raw_json's tool_result blocks); for sessions without explicit commits, infer from "session edited file F at time T; commit C touched F at time T+ε".
link_pr_to_sessions(conn, pr_id) — match by branch name (sessions that ran git checkout -b <branch> or git push origin <branch>).
downstream_touch_count(conn, repo_slug, file_path, since_ts) — via the same git data Yield uses.
Periodic backfill (CLI: stackunderflow attribute backfill --since 30d) — runs on every PR row + every commit-bearing session.
Surface in API + meta-agent + UI.
Tests
Authored-link: session that runs git commit -m "msg" → assert link with confidence 1.0.
Inferred-link: session edits foo.py, commit C touches foo.py 5min later, no other session touched it → assert link with confidence 0.7+.
PR-link: session pushes branch feat/x, PR opened from feat/x → assert link.
Downstream-touch: PR merged, file touched 3 times in next 30 days → count = 3.
Goal
Build the link table that turns "this session existed" into "this session produced commit X, in PR Y, which CI passed, which has been touched 3 times since (twice to fix bugs)." The single feature that makes outcome metrics trustworthy.
Why now
Yield tab today is per-cwd
git logcorrelation — coarse, no PR awareness, no downstream-touch awareness. Comparative benchmark (Spec 26) and risk recommender (Spec 16) both need real attribution to mean anything.Schema
v019 —
commit_session_link+ extendspr_outcomes:_ADD_COLUMN_GUARDSentry:19: ("pr_outcomes", "linked_session_ids").User-visible surface
stackunderflow attribute commit <sha>→ "this commit came from session X (worked, agent: claude-opus-4-7, $0.42)".stackunderflow attribute session <id>→ "this session produced commits A, B; merged in PR feat: yield analysis — correlate sessions with git commits (productive/reverted/abandoned) #42; CI passed; touched 3 times since (1 revert)".GET /api/attribution/commit/{sha}and/api/attribution/session/{id}.attribute_commit(sha)andattribute_session(id).Implementation plan
stackunderflow/services/attribution.py:link_session_to_commit(conn, session_id)— heuristic: walk session messages, extract anygit commit -mBash calls + their resulting commit shas (pull frommessages.raw_json's tool_result blocks); for sessions without explicit commits, infer from "session edited file F at time T; commit C touched F at time T+ε".link_pr_to_sessions(conn, pr_id)— match by branch name (sessions that rangit checkout -b <branch>orgit push origin <branch>).downstream_touch_count(conn, repo_slug, file_path, since_ts)— via the same git data Yield uses.stackunderflow attribute backfill --since 30d) — runs on every PR row + every commit-bearing session.Tests
git commit -m "msg"→ assert link with confidence 1.0.foo.py, commit C touchesfoo.py5min later, no other session touched it → assert link with confidence 0.7+.feat/x, PR opened fromfeat/x→ assert link.Hard parts
maindirectly — flag aslink_type='inferred-by-touch'with low confidence.git logper file scales poorly. Cache aggressively; backfill incrementally.Out of scope
git log --grep "Revert"heuristic.Dependencies
services/yield_tracker.py.Estimated effort
Size XL — single agent, ~3-4 hr. The heuristics + their test coverage are the bulk.
Hard rules
feat/outcome-attribution-v2off main.