-
Notifications
You must be signed in to change notification settings - Fork 445
Fix audit comparison turns delta for cached summaries #43501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
46339c7
8aa9a07
ec0eb83
ef685fd
c0f5919
1349e39
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -127,6 +127,40 @@ func TestIsPermissionErrorStr(t *testing.T) { | |
| } | ||
| } | ||
|
|
||
| func TestProcessedRunFromSummaryBackfillsTurnsFromMetrics(t *testing.T) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [/tdd] Consider also testing the edge case where both 💡 Suggested testfunc TestProcessedRunFromSummaryBothTurnsZero(t *testing.T) {
summary := &RunSummary{
Run: WorkflowRun{DatabaseID: 789, Turns: 0},
Metrics: LogMetrics{Turns: 0},
}
processed := processedRunFromSummary(summary, "/tmp/run-output")
// Both are zero — no backfill occurs, and turns should remain 0.
assert.Equal(t, 0, processed.Run.Turns, "turns should remain zero when neither Run.Turns nor Metrics.Turns is available")
}Documents the known limitation: if a run genuinely has zero turns and Metrics.Turns is also zero, the delta will still reflect 0. @copilot please address this.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added |
||
| summary := &RunSummary{ | ||
| Run: WorkflowRun{DatabaseID: 123, Turns: 0}, | ||
| Metrics: LogMetrics{Turns: 34}, | ||
| } | ||
|
|
||
| processed := processedRunFromSummary(summary, "/tmp/run-output") | ||
|
|
||
| assert.Equal(t, 34, processed.Run.Turns, "run turns should backfill from summary metrics when run turns are missing") | ||
| assert.Equal(t, "/tmp/run-output", processed.Run.LogsPath, "logs path should be set from the current run output directory") | ||
| } | ||
|
|
||
| func TestProcessedRunFromSummaryPreservesExistingTurns(t *testing.T) { | ||
| summary := &RunSummary{ | ||
| Run: WorkflowRun{DatabaseID: 456, Turns: 7}, | ||
| Metrics: LogMetrics{Turns: 34}, | ||
| } | ||
|
|
||
| processed := processedRunFromSummary(summary, "/tmp/run-output") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing test for the both-zeros edge case ( 💡 Suggested testfunc TestProcessedRunFromSummaryBothTurnsZero(t *testing.T) {
summary := &RunSummary{
Run: WorkflowRun{DatabaseID: 789, Turns: 0},
Metrics: LogMetrics{Turns: 0},
}
processed := processedRunFromSummary(summary, "/tmp/run-output")
// Neither field has data; turns should remain 0, not be set to Metrics.Turns.
assert.Equal(t, 0, processed.Run.Turns, "run turns should remain 0 when both Run.Turns and Metrics.Turns are 0")
}
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added |
||
|
|
||
| assert.Equal(t, 7, processed.Run.Turns, "existing run turns should not be overwritten by summary metrics") | ||
| } | ||
|
|
||
| func TestProcessedRunFromSummaryBothTurnsZero(t *testing.T) { | ||
| summary := &RunSummary{ | ||
| Run: WorkflowRun{DatabaseID: 789, Turns: 0}, | ||
| Metrics: LogMetrics{Turns: 0}, | ||
| } | ||
|
|
||
| processed := processedRunFromSummary(summary, "/tmp/run-output") | ||
|
|
||
| assert.Equal(t, 0, processed.Run.Turns, "run turns should remain zero when neither Run.Turns nor Metrics.Turns is available") | ||
| } | ||
|
|
||
| func TestBuildAuditData(t *testing.T) { | ||
| // Create test data | ||
| run := WorkflowRun{ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[/diagnosing-bugs] The fix is correct, but the why is missing — future readers will not know that
Run.Turnscan be stale/zero specifically in the cached-summary rendering path.💡 Suggested comment
Without this context, the next developer may remove it as apparently defensive dead code.
@copilot please address this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the explanatory comment in 3d0db57.