Chainloop Trace: AI/human line attribution that survives later human edits #3639
Copy link
Copy link
Open
Labels
Description
Problem
Chainloop Trace gives a wrong AI/human line split for a file when a human changes AI-written lines later. The CLI records AI line ranges at edit time and never updates them. It also adds up the diffs of all commits in a session.
Example: the AI writes 100 lines, then a human changes 20 of them. The correct split is 80 AI / 20 human.
| Case | CLI evidence today |
|---|---|
| Same session, same commit | AI 100 / human 0 |
| Same session, commit 2 not in the session | AI 100 / human 0, commit 2 not recorded |
| Same session, commit 2 in the session | AI 100 / human 20, AI removed 20 |
| Different sessions, commit 2 in session B | A: AI 100. B: human 20, human removed 20 |
| Commit 2 in no session | A: AI 100, commit 2 not recorded |
Other gaps:
- Every removed line in a file that the AI touched counts as an AI removal.
- A commit with only part of the AI lines of a file retires the whole file. A later commit with the rest is not credited.
- Renames, amend, rebase, and squash lose the line ranges.
Scope
- A design spec in
docs/specs/that covers all five cases. - The CLI implementation in Chainloop Trace.
- An update to the feature table and the compatibility matrix in the Trace README.
Reactions are currently unavailable
Activity
spec: address review on issue-3639 line attribution
spec: keep per-edit AI line counts for a generated-lines metric
spec: move R-011 to the end of the requirements
fix(trace): address review of line attribution
fix(trace): report unreadable pre-command HEAD commits
jiparis commentedon Oct 19, 2026
Follow-up spec for line ranges that point into the pushed code: #3650
spec: issue-3639 address review of line ranges spec
spec: issue-3639 keep each session's own lines in its ranges
spec: issue-3639 lines of a joined commit are human
refactor(trace): pick the git client in one factory
fix(trace): address review of net contribution
fix(trace): retry only failed scans of commits in no session