buildLogsData creates structured logs data from processed runs
(processedRuns []ProcessedRun, outputDir string, continuation *ContinuationData)
| 153 | |
| 154 | // buildLogsData creates structured logs data from processed runs |
| 155 | func buildLogsData(processedRuns []ProcessedRun, outputDir string, continuation *ContinuationData) LogsData { |
| 156 | reportLog.Printf("Building logs data from %d processed runs", len(processedRuns)) |
| 157 | |
| 158 | // Build summary |
| 159 | var totalDuration time.Duration |
| 160 | var totalAIC float64 |
| 161 | var totalTokens int |
| 162 | var totalActionMinutes float64 |
| 163 | var totalTurns int |
| 164 | var totalSteeringEvents int |
| 165 | var totalErrors int |
| 166 | var totalWarnings int |
| 167 | var totalMissingTools int |
| 168 | var totalMissingData int |
| 169 | var totalSafeItems int |
| 170 | var runsWithTemporaryIDChains int |
| 171 | var runsWithDelegatedTempTargets int |
| 172 | var runsWithMissingTemporaryIDMap int |
| 173 | var runsWithInvalidTemporaryIDMap int |
| 174 | var totalTemporaryIDMappings int |
| 175 | var totalChainedTargets int |
| 176 | var totalChainedFollowupActions int |
| 177 | var totalClosedTempTargets int |
| 178 | var totalGitHubAPICalls int |
| 179 | // engineCounts tracks the number of runs per engine_id, sourced from aw_info.json. |
| 180 | // This is the authoritative engine classification — do not infer engine type from |
| 181 | // lock file contents, which contain "copilot" in allowed-domains and source paths |
| 182 | // regardless of which engine the workflow uses. |
| 183 | engineCounts := make(map[string]int) |
| 184 | |
| 185 | // Build runs data |
| 186 | // Initialize as empty slice to ensure JSON marshals to [] instead of null |
| 187 | runs := make([]RunData, 0, len(processedRuns)) |
| 188 | for _, pr := range processedRuns { |
| 189 | run := pr.Run |
| 190 | |
| 191 | if run.Duration > 0 { |
| 192 | totalDuration += run.Duration |
| 193 | } |
| 194 | if pr.TokenUsage != nil { |
| 195 | totalAIC += pr.TokenUsage.TotalAIC |
| 196 | } |
| 197 | totalTokens += run.TokenUsage |
| 198 | totalActionMinutes += run.ActionMinutes |
| 199 | totalTurns += run.Turns |
| 200 | if pr.TokenUsage != nil { |
| 201 | totalSteeringEvents += pr.TokenUsage.TotalSteeringEvents |
| 202 | } |
| 203 | totalErrors += run.ErrorCount |
| 204 | totalWarnings += run.WarningCount |
| 205 | totalMissingTools += run.MissingToolCount |
| 206 | totalMissingData += run.MissingDataCount |
| 207 | totalSafeItems += run.SafeItemsCount |
| 208 | |
| 209 | // Accumulate GitHub API call counts |
| 210 | var gitHubAPICalls int |
| 211 | if pr.GitHubRateLimitUsage != nil { |
| 212 | gitHubAPICalls = pr.GitHubRateLimitUsage.TotalRequestsMade |