{"record":{"id":"4b41c4ee3ee47f7b","repo":"gastownhall/beads","slug":"failed-to-record-warning-w","errorCode":null,"errorMessage":"failed to record warning: %w","messagePattern":"failed to record warning: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/compact/compactor.go","lineNumber":128,"sourceCode":"\t// Calculate original size\n\toriginalSize := len(issue.Description) + len(issue.Design) + len(issue.Notes) + len(issue.AcceptanceCriteria)\n\n\tif c.config.DryRun {\n\t\treturn fmt.Errorf(\"dry-run: would compact %s (original size: %d bytes)\", issueID, originalSize)\n\t}\n\n\t// Get summary from AI\n\tsummary, err := c.summarizer.SummarizeTier1(ctx, issue)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to summarize: %w\", err)\n\t}\n\n\t// Check if compaction would actually reduce size\n\tcompactedSize := len(summary)\n\tif compactedSize >= originalSize {\n\t\twarningMsg := fmt.Sprintf(\"Tier 1 compaction skipped: summary (%d bytes) not shorter than original (%d bytes)\", compactedSize, originalSize)\n\t\tif err := c.store.AddComment(ctx, issueID, \"compactor\", warningMsg); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to record warning: %w\", err)\n\t\t}\n\t\treturn fmt.Errorf(\"compaction would increase size (%d → %d bytes), keeping original\", originalSize, compactedSize)\n\t}\n\n\t// Archive the original content BEFORE the destructive overwrite, so the\n\t// compaction is reversible (bd restore reads this snapshot). If archiving\n\t// fails we abort with the original content intact rather than lose it.\n\tif err := c.store.SnapshotIssue(ctx, issueID, 1); err != nil {\n\t\treturn fmt.Errorf(\"failed to archive pre-compaction snapshot: %w\", err)\n\t}\n\n\t// Update issue with summarized content\n\tupdates := map[string]interface{}{\n\t\t\"description\":         summary,\n\t\t\"design\":              \"\",\n\t\t\"notes\":               \"\",\n\t\t\"acceptance_criteria\": \"\",\n\t}","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/compact/compactor.go#L110-L146","documentation":"When the AI summary is not shorter than the original content, compaction is aborted. Before aborting, the compactor records a warning comment on the issue via store.AddComment; if that comment write fails, this wrapped error is returned instead. The original issue content is always preserved.","triggerScenarios":"SummarizeTier1 returned a summary whose byte length >= originalSize, and then store.AddComment(ctx, issueID, \"compactor\", warningMsg) also failed (storage write error).","commonSituations":"Compacting already-terse issues where the model cannot compress further; the database became read-only or the connection dropped while posting the warning comment; concurrent writes locking the DB.","solutions":["Check database writability and connection state","Inspect the wrapped AddComment error for the storage root cause","Skip issues whose content is already minimal — filter by original size before compacting","Retry the compaction; the size check is deterministic so the same issue may keep failing"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := c.CompactTier1(ctx, id); err != nil {\n    if strings.Contains(err.Error(), \"failed to record warning\") {\n        // content is safe (original kept); investigate store write failure\n        log.Printf(\"store write failed while recording skip warning: %v\", err)\n    }\n    return err\n}","preventionTips":["Keep the database writable and monitor disk space","Filter out already-tiny issues before compaction so the size-skip path rarely fires","Treat write failures during warning recording as storage health signals"],"tags":["go","storage","write-failure","size-check"],"backgroundTag":"storage-write-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}