{"record":{"id":"ebdd743e74827d28","repo":"JuliusBrussee/caveman","slug":"ccr-summary-scan-w","errorCode":null,"errorMessage":"ccr summary scan: %w","messagePattern":"ccr summary scan: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/ccr/store_sqlite.go","lineNumber":678,"sourceCode":"\t}\n\treturn obj, nil\n}\n\n// Summary aggregates stored recoveries into totals + per-content-type buckets.\nfunc (s *Store) Summary() (Stats, error) {\n\tout := Stats{ByContentType: map[string]Bucket{}, Basis: \"inferred\"}\n\trows, err := s.db.Query(\n\t\t`SELECT content_type, COUNT(*), COALESCE(SUM(tokens_before),0), COALESCE(SUM(tokens_after),0)\n\t\t FROM recoveries GROUP BY content_type`)\n\tif err != nil {\n\t\treturn out, fmt.Errorf(\"ccr summary: %w\", err)\n\t}\n\tdefer rows.Close()\n\tfor rows.Next() {\n\t\tvar ct string\n\t\tvar b Bucket\n\t\tif err := rows.Scan(&ct, &b.Count, &b.TokensBefore, &b.TokensAfter); err != nil {\n\t\t\treturn out, fmt.Errorf(\"ccr summary scan: %w\", err)\n\t\t}\n\t\tb.Ratio = ratio(b.TokensBefore, b.TokensAfter)\n\t\tout.ByContentType[ct] = b\n\t\tout.Totals.Count += b.Count\n\t\tout.Totals.TokensBefore += b.TokensBefore\n\t\tout.Totals.TokensAfter += b.TokensAfter\n\t}\n\tif err := rows.Err(); err != nil {\n\t\treturn out, fmt.Errorf(\"ccr summary rows: %w\", err)\n\t}\n\tif err := rows.Close(); err != nil {\n\t\treturn out, fmt.Errorf(\"ccr summary close: %w\", err)\n\t}\n\tout.Totals.Ratio = ratio(out.Totals.TokensBefore, out.Totals.TokensAfter)\n\tused, err := s.storageBytes()\n\tif err != nil {\n\t\treturn out, fmt.Errorf(\"ccr summary storage: %w\", err)\n\t}","sourceCodeStart":660,"sourceCodeEnd":696,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/engine/ccr/store_sqlite.go#L660-L696","documentation":"Wraps a row Scan failure inside Store.Summary's aggregation loop. One content-type bucket row could not be scanned into its struct, usually a schema mismatch (columns added/changed by a foreign writer) or corrupt numeric values.","triggerScenarios":"Thrown at engine/ccr/store_sqlite.go:678 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the wrapped error for the mismatched column","Migrate or repair the recoveries table schema","Recreate the store if the schema is unrepairable"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"766dce6b1394ebb56a3090748d5a0240a5aefb36","analyzedAt":"2026-08-18T03:14:35.516Z","contentChangedAt":"2026-08-18T03:14:35.516Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}