Skip to content

Commit a635ea8

Browse files
committed
test(trace): check the generated line counts in the e2e suite
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
1 parent 35749ca commit a635ea8

3 files changed

Lines changed: 21 additions & 6 deletions

File tree

‎app/cli/internal/trace/e2e/checks.go‎

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,7 @@ var features = map[string]Feature{
9999
"Shell changes attribution": {Checks: []Check{{scenarioEditAndCommit, checkFileAttributedToAI("shell.txt")}}},
100100
"Partial commits": {Checks: []Check{{scenarioPartial, checkBothCommitsCredited}}},
101101
"Line ranges": {Checks: []Check{{scenarioEditAndCommit, checkLineRanges("greeting.txt", 3)}}},
102-
"Generated line counts": {
103-
NotCovered: "neither the user nor the evidence can see the generated line counts yet",
104-
},
102+
"Generated line counts": {Checks: []Check{{scenarioEditAndCommit, checkGeneratedLineCounts}}},
105103

106104
// User experience
107105
"Welcome message": {Checks: []Check{{scenarioEditAndCommit, checkWelcomeMessage}}},
@@ -196,6 +194,23 @@ func checkFileAttributedToAI(path string) func(s *Session) error {
196194
}
197195
}
198196

197+
// checkGeneratedLineCounts verifies that the evidence reports the lines of
198+
// all the agent edits. Each net AI line came from an agent edit, so the
199+
// generated lines are at least the net AI lines.
200+
func checkGeneratedLineCounts(s *Session) error {
201+
cc := evidence(s).CodeChanges
202+
if cc == nil {
203+
return errors.New("the evidence has no code changes")
204+
}
205+
if cc.AIGeneratedLinesAdded == 0 {
206+
return errors.New("the evidence has no generated lines added")
207+
}
208+
if cc.AIGeneratedLinesAdded < cc.AILinesAdded {
209+
return fmt.Errorf("%d generated lines added, fewer than the %d net AI lines added", cc.AIGeneratedLinesAdded, cc.AILinesAdded)
210+
}
211+
return nil
212+
}
213+
199214
// hookMessage returns the first hook message of an event, or errNotCovered
200215
// when the harness does not report hook messages.
201216
func hookMessage(s *Session, event string) (*HookMessage, error) {

‎internal/schemavalidators/internal_schemas/aicodingsession/ai-coding-session-0.1.schema.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,11 @@
170170
},
171171
"lines_added": {
172172
"type": "integer",
173-
"description": "Net lines added by the session's commits: AI plus human lines"
173+
"description": "Net lines added by the session's commits (AI plus human); raw diff totals if a commit is unreadable"
174174
},
175175
"lines_removed": {
176176
"type": "integer",
177-
"description": "Net lines removed by the session's commits: AI plus human lines"
177+
"description": "Net lines removed by the session's commits (AI plus human); raw diff totals if a commit is unreadable"
178178
},
179179
"ai_lines_added": {
180180
"type": "integer",

‎pkg/attestation/crafter/materials/aicodingsession/aicodingsession.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ type CodeChanges struct {
255255
FilesModified int `json:"files_modified,omitempty"`
256256
FilesCreated int `json:"files_created,omitempty"`
257257
FilesDeleted int `json:"files_deleted,omitempty"`
258-
// Net lines of the session's commits: the AI lines plus the human lines.
258+
// Net lines of the session's commits (AI plus human); raw diff totals if a commit is unreadable.
259259
LinesAdded int `json:"lines_added,omitempty"`
260260
LinesRemoved int `json:"lines_removed,omitempty"`
261261
// Net committed lines attributed to the AI.

0 commit comments

Comments
 (0)