MCPcopy Create free account
hub / github.com/github/gh-aw / loadRunSummary

Function loadRunSummary

pkg/cli/logs_cache.go:23–69  ·  view source on GitHub ↗

loadRunSummary attempts to load a run summary from disk Returns the summary and a boolean indicating if it was successfully loaded and is valid

(outputDir string, verbose bool)

Source from the content-addressed store, hash-verified

21// loadRunSummary attempts to load a run summary from disk
22// Returns the summary and a boolean indicating if it was successfully loaded and is valid
23func loadRunSummary(outputDir string, verbose bool) (*RunSummary, bool) {
24 logsCacheLog.Printf("Loading run summary from cache: dir=%s", outputDir)
25 summaryPath := filepath.Join(outputDir, runSummaryFileName)
26
27 // Check if summary file exists
28 if _, err := os.Stat(summaryPath); os.IsNotExist(err) {
29 logsCacheLog.Print("Run summary cache file does not exist")
30 return nil, false
31 }
32
33 // Read the summary file
34 data, err := os.ReadFile(summaryPath)
35 if err != nil {
36 logsCacheLog.Printf("Failed to read run summary cache: %v", err)
37 if verbose {
38 fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Failed to read run summary: %v", err)))
39 }
40 return nil, false
41 }
42
43 // Parse the JSON
44 var summary RunSummary
45 if err := json.Unmarshal(data, &summary); err != nil {
46 logsCacheLog.Printf("Failed to parse run summary JSON: %v", err)
47 if verbose {
48 fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Failed to parse run summary: %v", err)))
49 }
50 return nil, false
51 }
52
53 // Validate CLI version matches
54 currentVersion := GetVersion()
55 if summary.CLIVersion != currentVersion {
56 logsCacheLog.Printf("CLI version mismatch: cached=%s, current=%s", summary.CLIVersion, currentVersion)
57 if verbose {
58 fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Run summary version mismatch (cached: %s, current: %s), will reprocess", summary.CLIVersion, currentVersion)))
59 }
60 return nil, false
61 }
62
63 logsCacheLog.Printf("Successfully loaded cached run summary: run_id=%d", summary.RunID)
64 if verbose {
65 fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Loaded cached run summary for run %d (processed at %s)", summary.RunID, summary.ProcessedAt.Format(time.RFC3339))))
66 }
67
68 return &summary, true
69}
70
71// parseCleanupCutoff resolves a date string (absolute or relative delta) to a
72// time.Time that can be used as a cutoff for the cache cleanup. Accepts the

Callers 15

RunOutcomesFunction · 0.85
downloadRunArtifactsFunction · 0.85
loadRunSummaryForDiffFunction · 0.85
loadCachedRunAICFunction · 0.85
TestAuditCachingBehaviorFunction · 0.85

Calls 5

FormatWarningMessageFunction · 0.92
FormatInfoMessageFunction · 0.92
PrintMethod · 0.80
GetVersionFunction · 0.70
PrintfMethod · 0.45