Record the git branch a session started on - #54
Merged
Merged
Conversation
Read from .git/HEAD in the working directory the harness already reports: a file read rather than a git subprocess, walking up from the working directory since agents start below the repo root, and following a .git file to its real gitdir so worktrees and submodules resolve. Recorded at session creation and never overwritten. A session that outlives a checkout keeps the branch it began on, because the logs do not say when a checkout happened. Shown beside the agent name and matched by the filter box, so "what ran on release/2.4" is answerable. Not a Prometheus label, against the plan: branch is the classic unbounded dimension, and this fleet's four today would be hundreds on ticket branches, multiplied by every agent. On a fresh ingest of real logs, 146 of 196 sessions got one; the rest are TrueForge, which has no working directory, and stale directories. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NZDHk4yVYP4jMZkTUMQ1Lw
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.
Sessions now carry the branch they ran on, read from
.git/HEADin the working directory the harness already reports.gitsubprocess — no process per session, and it works where git is not installed..gitthat is a file to its real gitdir, which is how worktrees and submodules look.Recorded once at session creation and never overwritten: a session that outlives a checkout keeps the branch it began on, because the logs do not say when a checkout happened and anything else would be invention.
Shown beside the agent name (dimmed) with "repo on branch" as the tooltip, and matched by the filter box, so what ran on
release/2.4is a question the table can answer.One deliberate deviation from the plan: it is not a Prometheus label. Branch is the classic unbounded dimension — this fleet has four today, but a team on ticket branches produces hundreds over a year, multiplied by every agent. Everything else in
/metricshas been kept to bounded labels, and this would undo that.Verified on a fresh ingest of real logs: 146 of 196 sessions got a branch across claude-code, dsh and opencode. TrueForge has none, having no working directory. Tests cover a plain repo, a subdirectory, a worktree, a detached HEAD, a directory that is not a repo, and this repository's own
.git. 87 tests pass.https://claude.ai/code/session_01NZDHk4yVYP4jMZkTUMQ1Lw