Skip to content

feat(trace): report the generated line totals of a session - #3680

Merged
jiparis merged 3 commits into
chainloop-dev:mainfrom
jiparis:trace-generated-line-totals
Oct 21, 2026
Merged

jiparis merged 3 commits into
chainloop-dev:mainfrom
jiparis:trace-generated-line-totals

Conversation

@jiparis

@jiparis jiparis commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Chainloop Trace now reports, in the AI coding session evidence, the total lines that the agent edits of a session added and removed. The totals include the lines that never reached a commit. Two new fields in code_changes hold them: ai_generated_lines_added and ai_generated_lines_removed. Compare them with ai_lines_added and ai_lines_removed to see how much of the generated code the session kept.

The CLI already keeps these counts in the trace state (spec issue-3639, R-011). This PR does the follow-up that D-011 and the Non-goal of the spec defer: it reports the totals in the evidence. The change is additive, and a platform that does not know the fields keeps working (R-009). A session with no commit still sends no evidence, so it reports no totals.

This prepares the "Generated" stage of the AI code lifecycle view (PFM-7302).

AI disclosure: Claude Code assisted with this change.

View guided diff

Add ai_generated_lines_added and ai_generated_lines_removed to the
code changes of the AI coding session evidence. They hold the lines
that all the agent edits of the session added and removed, also the
lines that never reached a commit (spec issue-3639, R-011, D-011).

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

Chainloop-Trace-Sessions: d13fc871-d294-4c08-b1d4-e7bdcaef6969
@chainloop-platform

chainloop-platform Bot commented Oct 21, 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 — 🟢 90% · ✅ 0 failing

Avg score Sessions Failing policies Attribution Files Lines Total Duration
🟢 90% 1 ✅ 0 84% AI / 16% Human 6 +108 / -20 42m45s

🟢 90% — 84% AI — ✅ All policies passing

Oct 21, 2026 09:06 UTC · 42m45s · $4.40 · 180 in / 53.7k out · claude-code 2.1.306 (claude-opus-5-5)

View session details ↗

Change Summary

  • Adds ai_generated_lines_added and ai_generated_lines_removed to session evidence and schema.
  • Wires the new totals from the session ledger in attribution.Enrich and clarifies the net-count field descriptions.
  • Adds targeted generated-lines tests and an e2e check for the new evidence fields.

AI Session Overall Score

🟢 90% — Clean, well-scoped follow-up with strong verification and no judge-level concerns.

AI Session Analysis Breakdown

🟢 94% · user-trust-signal

No notes.

🟢 92% · context-and-planning

🟢 The session captured the governing spec before the first code edit. · High Impact

🟢 91% · scope-discipline

No notes.

🟢 90% · solution-quality

No notes.

🟢 89% · alignment

🟢 The diff adds the follow-up evidence fields exactly where the spec-driven task needed them. · High Impact

🟢 88% · verification

🟢 The new generated-lines test failed first, then passed after the implementation landed. · High Impact


File Attribution

████████████████░░░░ 84% AI / 16% Human

Status Attribution File Lines
modified ai app/cli/internal/trace/attribution/enrich_test.go +55 / -0
modified ai pkg/attestation/crafter/materials/aicodingsession/aicodingsession.go +16 / -10
modified ai app/cli/internal/trace/e2e/checks.go +18 / -3
modified ai internal/schemavalidators/internal_schemas/aicodingsession/ai-coding-session-0.1.schema.json +14 / -6
modified ai app/cli/internal/trace/attribution/enrich.go +4 / -0
modified ai app/cli/internal/trace/README.md +1 / -1

Policies (4)

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

Security Checks — ✅ 6 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 -

✅ iac-scan

Status Policy Messages
✅ Passed iac-misconfiguration -
Scans not applied (2)
Scan Reason
vulnerability-scan no manifest/lockfile changed
github-actions-scan no workflow files changed

View attestation ↗

Security context

✅ Nothing this change touches has a recorded security-fix history.

View in Chainloop ↗ · How this works ↗


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.

All reported issues were addressed across 5 files

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

Comment thread app/cli/internal/trace/README.md
Assisted-by: Claude Code
Signed-off-by: Jose I. Paris <jiparis@chainloop.dev>

Chainloop-Trace-Sessions: d13fc871-d294-4c08-b1d4-e7bdcaef6969

@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.

All reported issues were addressed across 2 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

Comment thread pkg/attestation/crafter/materials/aicodingsession/aicodingsession.go Outdated
@jiparis
jiparis requested a review from a team October 21, 2026 09:47
Also note that the session line totals are raw diff totals when a
commit cannot be read.

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

Chainloop-Trace-Sessions: d13fc871-d294-4c08-b1d4-e7bdcaef6969

@migmartri migmartri left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nice

@jiparis
jiparis merged commit 59cdef3 into chainloop-dev:main Oct 21, 2026
17 checks passed
@jiparis
jiparis deleted the trace-generated-line-totals branch October 21, 2026 10:04
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