Fix: write trace domain snapshots even outside a git work tree - #16
Merged
Merged
Conversation
Move the git work-tree check from the function entry to gating just the git block. Domain snapshots (skills, tools, memory, thinking, tool_results, user_prompts, file_attachments, prior_assistant, assistant_text) read transcript entries and filesystem state — never git — so dropping them whenever cwd isn't a git work tree was an over-broad bail. Concrete symptom this fixes: launching CC from a non-repo parent directory (e.g. ~/code as a holder for many repos) produced traces with cc.identity and per-span cc.llm_call only — every cc.<domain> on the trace was missing because postTraceMetrics returned at the git check before reaching the domain loop. After: git block writes when available, domains always write, and the final PATCH is skipped only when both produced nothing. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
postTraceMetricswrites the trace-levelcc.<domain>blocks (skills, tools, memory, thinking, tool_results, user_prompts, file_attachments, prior_assistant, assistant_text) for every closing trace. It also writes acc.gitblock when the current working directory is a git work tree. Today the function bails out entirely if cwd is not a git work tree, dropping all nine domain snapshots even though none of them touch git.Repro
Launch Claude Code from a non-repo parent directory (e.g. `~/code` used as a holder for many sibling repos). Send any prompt with tracing enabled. The resulting Opik trace shows:
Debug log signature: `postTraceMetrics: is not a git work tree`
Fix
Move the git work-tree check inline so it gates only the git block. Domain snapshots always run; the final PATCH is skipped only when both produced nothing.
Test plan
🤖 Generated with Claude Code