{"record":{"id":"651f4aac25dc435b","repo":"gastownhall/beads","slug":"compaction-would-increase-size-d-d-bytes-ke","errorCode":null,"errorMessage":"compaction would increase size (%d → %d bytes), keeping original","messagePattern":"compaction would increase size \\((.+?) → (.+?) bytes\\), keeping original","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/compact/compactor.go","lineNumber":130,"sourceCode":"\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}\n\tif err := c.store.UpdateIssue(ctx, issueID, updates, \"compactor\"); err != nil {\n\t\treturn fmt.Errorf(\"failed to update issue: %w\", err)","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/compact/compactor.go#L112-L148","documentation":"Deliberate abort: the AI summary's byte length is >= the original content size (description + design + notes + acceptance criteria), so compacting would not save space (or would grow the issue). The compactor keeps the original and returns this message as an error after logging a warning comment on the issue.","triggerScenarios":"SummarizeTier1(ctx, issue) returns a summary with len(summary) >= originalSize — e.g. the issue's text fields are already very short, or the model produced a verbose summary with no reduction.","commonSituations":"Running Tier 1 compaction on small issues where compression is impossible; a model returning verbose preambles; batch jobs that don't pre-filter by content size; repeated runs hitting the same borderline-sized issues every time.","solutions":["Pre-filter issues by original size and only compact those above a meaningful threshold","Treat this message as an expected skip in batch aggregation rather than a hard failure","Use a stronger model or prompt if many summaries fail to shrink content","Disable compaction for issues whose fields are already minimal"],"exampleFix":"// before\nfor _, id := range ids { c.CompactTier1(ctx, id) }\n// after\nfor _, id := range ids {\n    if issueSize(id) < 2048 { continue }\n    if err := c.CompactTier1(ctx, id); err != nil {\n        if strings.Contains(err.Error(), \"compaction would increase size\") { continue }\n        return err\n    }\n}","handlingStrategy":"fallback","validationCode":"origSize := len(iss.Description)+len(iss.Design)+len(iss.Notes)+len(iss.AcceptanceCriteria)\nif origSize < 1024 {\n    return fmt.Errorf(\"issue %s too small (%d bytes) to benefit from compaction\", id, origSize)\n}","typeGuard":null,"tryCatchPattern":"if err := c.CompactTier1(ctx, id); err != nil {\n    if strings.Contains(err.Error(), \"compaction would increase size\") {\n        return nil // benign skip: original kept\n    }\n    return err\n}","preventionTips":["Pre-filter issues below a size threshold (e.g. 1-2KB) before compaction","Aggregate batch results so this expected skip doesn't fail the whole run","If it fires constantly, review the summarizer prompt/model for verbosity"],"tags":["go","ai","size-guard","expected-failure","skip"],"backgroundTag":"compaction-no-size-reduction","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}