Skip to content

fix(trace): exclude generated files from the AI-generated line counts - #3790

Merged
jiparis merged 1 commit into
chainloop-dev:mainfrom
jiparis:jiparis/pfm-8130-exclude-generated-files-from-the-ai-generated-line-counts-of
Nov 6, 2026
Merged

jiparis merged 1 commit into
chainloop-dev:mainfrom
jiparis:jiparis/pfm-8130-exclude-generated-files-from-the-ai-generated-line-counts-of

Conversation

@jiparis

@jiparis jiparis commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

The AI coding session evidence already leaves out files that .gitattributes marks linguist-generated from files and from its line and file counts. The ai_generated_lines_added and ai_generated_lines_removed totals still included them. So when the agent ran a generator such as wire or make generate, the generated diff counted as lines the AI wrote.

The trace state now keeps the lines of the agent edits per file. At push time, the totals leave out generated files with the same matcher that filters the code changes. The trace README is updated to match.

Fixes PFM-8130. Related to spec issue-3639 (R-011, D-011).

AI disclosure: this change was developed with the assistance of Claude Code.

View guided diff

The trace state now keeps the lines of the agent edits per file, so the
push can leave out the files that .gitattributes marks linguist-generated
from ai_generated_lines_added and ai_generated_lines_removed, as it
already does for the other line counts.

Fixes PFM-8130

Assisted-by: Claude Code
Signed-off-by: Jose Ignacio Paris Prieto <jiparis@chainloop.dev>

Chainloop-Trace-Sessions: d38ce0e4-9555-422b-a581-9ee2f03c8a78
@chainloop-platform

chainloop-platform Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

PR validation — ✅ 3 passing

Status Policy Material Messages
✅ Passed pr-min-approvals pr-info -
✅ Passed pr-description-required pr-info -
✅ Passed pr-user-story-linked pr-info -

View attestation ↗

AI Session Checks — 🟢 89% · ✅ 0 failing

Avg score Sessions Failing policies Attribution Files Lines Total Duration
🟢 89% 1 ✅ 0 100% AI / 0% Human 10 +177 / -78 38m36s

🟢 89% — 100% AI — ✅ All policies passing

Nov 6, 2026 09:21 UTC · 38m36s · $4.22 · 154 in / 40.2k out · claude-code 2.1.319 (claude-opus-5-5)

View session details ↗

Change Summary

  • Captured edits retain agent-edit line totals per file and exclude generated files during evidence aggregation.
  • Update attribution callers and migrate count tests to the filtered aggregation entry point.
  • Add generated-file regression coverage and document generated-line exclusions. Final cumulative PR diff was not provided.

AI Session Overall Score

🟢 89% — Focused, regression-tested session; light planning and absent final diff limit review confidence.

AI Session Analysis Breakdown

🟢 94% · scope-discipline

No notes.

🟢 93% · user-trust-signal

No notes.

🟢 90% · alignment

🟢 The final explanation separates generated-file attribution from rebase inflation instead of claiming the narrow fix explains every anomalous total. · High Impact

🟢 90% · solution-quality

🟢 Captured state edits preserve per-file counts and filter during aggregation instead of clamping or subtracting guessed totals. · High Impact

🟢 88% · verification

🟢 The generated-file integration test passes using a real temporary repository and explicit emitted-count assertions. · High Impact

🟡 Lint could not complete because the local tool could not decode current compiler output. · Low Severity

🟡 75% · context-and-planning

🟠 Per-file state, attribution, callers, and tests changed without a consolidated pre-edit plan; only incremental directions appear. · Medium Severity

💡 Before editing, outline the state change, filtered aggregation, caller updates, and regression checks together.


File Attribution

████████████████████ 100% AI / 0% Human

Status Attribution File Lines
modified ai app/cli/internal/trace/attribution/generated_test.go +64 / -0
modified ai app/cli/internal/trace/attribution/enrich_test.go +0 / -55
modified ai app/cli/pkg/action/trace_line_attribution_test.go +46 / -7
modified ai app/cli/internal/trace/state/ailines.go +31 / -7
modified ai app/cli/internal/trace/state/ailines_test.go +16 / -2
modified ai app/cli/internal/trace/attribution/generated.go +15 / -0
modified ai app/cli/pkg/action/trace_codex_hook_test.go +3 / -2
modified ai app/cli/internal/trace/attribution/enrich.go +0 / -4
modified ai app/cli/internal/trace/README.md +1 / -1
modified ai app/cli/pkg/action/trace_hook_handler.go +1 / -0

Policies (4)

Status Policy Material Messages
✅ Passed ai-config-ai-agents-allowed ai-coding-session-d38ce0 -
✅ Passed ai-config-no-dangerous-commands ai-coding-session-d38ce0 -
✅ Passed ai-config-no-secrets ai-coding-session-d38ce0 -
✅ Passed ai-config-mcp-servers-allowed ai-coding-session-d38ce0 -

Security Checks — ✅ 5 passing

✅ Reviewed this change against the project's security context (4 concerns hunted) — no introduced risk found.

View in Chainloop ↗ · How this works ↗
✅ Reviewed this change against the project's security context (4 concerns hunted) — no introduced risk found.

View in Chainloop ↗ · How this works ↗
✅ Reviewed this change against the project's security context (4 concerns hunted) — no introduced risk found.

View in Chainloop ↗ · How this works ↗
✅ Reviewed this change against the project's security context (4 concerns hunted) — no introduced risk found.

View in Chainloop ↗ · How this works ↗

✅ 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

View attestation ↗


Powered by Chainloop and Chainloop Trace

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 10 files

View guided diff | Re-trigger cubic

@jiparis
jiparis requested a review from a team November 6, 2026 10:08
@jiparis
jiparis merged commit ae32fa6 into chainloop-dev:main Nov 6, 2026
17 checks passed
@jiparis
jiparis deleted the jiparis/pfm-8130-exclude-generated-files-from-the-ai-generated-line-counts-of branch November 6, 2026 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants