Inline per-trace metrics + Claude Code identity on traces - #11
Merged
Conversation
Captures deterministic git-grounded metrics in the hook itself (no daemon) and stamps every trace with the user's Claude Code OAuth identity. Metrics posted as feedback scores on Stop/Compact/SessionEnd: cc.repository, cc.branch, cc.head_sha_start, cc.head_sha_end, cc.commits_in_trace, cc.lines_committed, cc.uncommitted_lines, cc.uncommitted_files, cc.files_authored, cc.lines_authored, cc.lines_overwritten. Identity from ~/.claude.json oauthAccount is applied to trace.metadata.cc (user_email, user_uuid, user_display_name, org_uuid, org_name) and to trace.tags as `user:<email>` for one-click filtering in the Opik UI. State carries cwd + HEAD SHA captured at trace start so the end-of-trace git ops can compute an accurate start..end commit range.
4 tasks
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
What lands on each trace
Feedback scores (computed in the hook):
cc.repositorygit remote get-url origin→host/org/repocc.branchgit branch --show-currentcc.head_sha_start/cc.head_sha_endgit rev-parse HEADat trace start / endcc.commits_in_tracegit log start..end --shortstatcc.lines_committedcc.uncommitted_lines/cc.uncommitted_filesgit diff HEAD --shortstatat trace closecc.files_authoredcc.lines_authored/cc.lines_overwrittennew_string/old_stringin those entriesTrace metadata (
metadata.cc):Read from
~/.claude.jsonoauthAccount. Email is also pushed ontotrace.tagsasuser:<email>for filtering.Why this shape
git config user.email), so it aligns with billing/auth and gives a stable org primitive for team-level views.metadatakeeps the surface compatible with existing Opik UI filtering, charts, and rollups.What changed
src/state.go— addsCwd,HeadSHAStartso close-time ops can anchor against trace startsrc/api.go— addsPut; addsMetadatatoTracesrc/identity.go—~/.claude.jsonreader +applyToTracehelpersrc/metrics.go— transcript walk for edit aggregates + git wrappers + feedback-score POSTsrc/main.go— captures cwd/HEAD onUserPromptSubmit/PreCompact; applies identity to every created trace; callspostTraceMetricson trace closureTest plan
comet-all/claude-codeproject: 12 cc.* scores landing per trace, identity present inmetadata.cc,user:<email>tag visiblefiles_authored=1,lines_authored=2,lines_overwritten=1)make buildsucceeds on the four target platforms🤖 Generated with Claude Code