Repository navigation
fix(trace): attribute commits made inside Bash calls - #3631
waveywaves wants to merge 5 commits into
Conversation
PR validation —
|
| Status | Policy | Material | Messages |
|---|---|---|---|
pr-min-approvals |
pr-info |
PR/MR #3631 has 0 approving reviews, 1 required. | |
| ✅ Passed | pr-description-required |
pr-info |
- |
| ✅ Passed | pr-user-story-linked |
pr-info |
- |
AI Session Checks — ⚠️ no AI session found
Missing AI Coding Sessions
This organization requires every PR to be backed by a Chainloop Trace AI coding session, and none was found for this one.
Please make sure the AI coding session evidence has been sent by the Chainloop CLI, or add the skip-ai-session label to this PR to bypass this check.
Learn more about Chainloop Trace.
Security Checks — ✅ 5 passing
✅ secret-scan
| Status | Policy | Messages |
|---|---|---|
| ✅ Passed | secrets-detection |
- |
✅ sast-scan
| Status | Policy | Messages |
|---|---|---|
| ✅ Passed | owasp-top10-2025 |
- |
| ✅ Passed | sast |
- |
| ✅ Passed | cwe-top25 |
- |
| ✅ Passed | cwe-top26-40-cusp |
- |
Scans not applied (3)
| Scan | Reason |
|---|---|
vulnerability-scan |
no manifest/lockfile changed |
github-actions-scan |
no workflow files changed |
iac-scan |
no IaC files changed |
Security context
This change touches code with 4 recorded security-fix advisories. These are pointers to what past fixes established, not findings in this diff, and they never fail the check.
View in Chainloop ↗ · How this works ↗
Powered by Chainloop and Chainloop Trace
There was a problem hiding this comment.
All reported issues were addressed across 13 files
Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.
View guided diff | Re-trigger cubic
d65514e to
26f4d6d
Compare
|
@jiparis can you take a look at this one? |
Tag the exact Claude Bash call so commit-msg can attribute staged content before PostToolUse runs. Assisted-by: Vibhav's Pi Signed-off-by: Vibhav Bobade <vibhav.bobde@gmail.com>
26f4d6d to
0b7e872
Compare
Honor the effective Git index, preserve recreated paths after staged deletions, and distinguish conflict-stage signatures. Assisted-by: Vibhav's Pi Signed-off-by: Vibhav Bobade <vibhav.bobde@gmail.com>
There was a problem hiding this comment.
All reported issues were addressed across 5 files (changes from recent commits).
Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.
View guided diff | Re-trigger cubic
|
Thanks for this fix. I tested the branch in real headless Claude Code sessions (Claude Code 2.1.301, Results
Scenarios and suggested approach1. Permission check on the rewritten command (blocker)Claude Code applies Suggested approach: do not rewrite the command. Use the snapshot files that this PR already writes (
There is no Notes:
2. Another hook that also returns
|
| Current PR | Minimal version | |
|---|---|---|
| Bash calls with a narrow allowlist | Denied, or a prompt on each call | No change in permissions |
| Another hook that rewrites the command | Trailer lost, with no warning | No conflict |
| Token in the transcript and in prompts | Yes, on each Bash call | No |
| Attribution precision | Exact call | Session. This is sufficient for the trailer. Line ranges can be less exact when calls overlap in one session. |
| Dependency | updatedInput (documented) |
CLAUDE_CODE_SESSION_ID (not documented, as far as we know). If Claude Code stops setting it, the behavior is the same as on the base commit. |
| Background Bash calls | Not attributed | Not attributed |
Estimated size of the change:
| Change | Size |
|---|---|
Delete TagShellCommand, ShellCommandTagger, RawToolInput, the ReadHookInput changes, EncodeShellCallKey/DecodeShellCallKey, and the ShellCallEnv export |
Approximately −100 lines |
Add store.OpenShellSnapshotKeys(sessionID). It lists the shell-index-* files in snapshots/<session>/ and makes each key from the file name. |
Approximately +30 lines |
In checkpointActiveShellAttribution, read the environment variable instead of the token, and do the checkpoint for each key. The diff and checkpoint logic does not change. |
Approximately +15 lines |
Tests: set CLAUDE_CODE_SESSION_ID instead of the token. Add one test with two overlapping calls in the same session. |
Small |
The snapshot, index, checkpoint and cleanup logic of this PR stays. Thus we expect the result to be smaller than the current PR.
Other items
- The
Chainloop AI PoliciesandChainloop PR Validationchecks fail. A possible cause is theAssisted-by: Vibhav's Pitrailer. We did not examine the failure details. - The repository rules require an update to the feature table and the compatibility matrix in
app/cli/internal/trace/README.mdwhen a Trace feature changes. This PR does not change that file.
Claude Code helped with this review.
Read staged blob content from the exact object recorded in the index, even when refs/replace maps it to another object. Assisted-by: Vibhav's Pi Signed-off-by: Vibhav Bobade <vibhav.bobde@gmail.com>
|
Thanks @waveywaves, sorry for the last long ie-vibed response.
|
|
Thanks, this clarifies the scope. I agree that One correction on validation: I did not independently run this branch in Claude Code. I validated it with the automated Go lifecycle/race tests, lint, and build. The live headless Claude Code results in this thread are from your testing, and I should not imply otherwise.
That said, you're right that invoking the Git binary from I will keep the existing regressions, especially the filter/line-ending case. If go-git cannot match Git's semantics there, I will report the concrete compatibility gap rather than hide a subprocess inside Provider scope is Claude-only in this PR because only Claude implements Thanks for the testing and clarification. I will make those GoGit-native and documentation changes next. |
Decode GIT_INDEX_FILE with go-git and keep staged, index, blob, and worktree comparisons inside GoGitClient without native git subprocesses. Assisted-by: Vibhav's Pi Signed-off-by: Vibhav Bobade <vibhav.bobde@gmail.com>
Mark same-call commit attribution as Claude-only and document the foreground Bash limitation. Assisted-by: Vibhav's Pi Signed-off-by: Vibhav Bobade <vibhav.bobde@gmail.com>
Closes #3625
Claude Code can edit, stage, commit, and push within one Bash tool call. The
commit-msghook runs before Claude'sPostToolUsehook, so the staged files previously had no recorded AI attribution and the commit lost itsChainloop-Trace-Sessionstrailer.This change:
tool_inputcommit-msgattribute the exact staged blob changes from that call beforePostToolUseTesting
go test -race -shuffle=on -count=1 ./internal/trace/state ./internal/trace/claude ./internal/trace/git ./pkg/actionGOTOOLCHAIN=go1.27.2 go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.14.0 run --new-from-rev=upstream/maingo build ./...commit-msgCLI help and invalid-argument pathsAI disclosure: this change was made with Vibhav's Pi.