gastownhall/beads · error
failed to record warning: %w
Error message
failed to record warning: %w
What it means
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.
Source
Thrown at internal/compact/compactor.go:128
// Calculate original size
originalSize := len(issue.Description) + len(issue.Design) + len(issue.Notes) + len(issue.AcceptanceCriteria)
if c.config.DryRun {
return fmt.Errorf("dry-run: would compact %s (original size: %d bytes)", issueID, originalSize)
}
// Get summary from AI
summary, err := c.summarizer.SummarizeTier1(ctx, issue)
if err != nil {
return fmt.Errorf("failed to summarize: %w", err)
}
// Check if compaction would actually reduce size
compactedSize := len(summary)
if compactedSize >= originalSize {
warningMsg := fmt.Sprintf("Tier 1 compaction skipped: summary (%d bytes) not shorter than original (%d bytes)", compactedSize, originalSize)
if err := c.store.AddComment(ctx, issueID, "compactor", warningMsg); err != nil {
return fmt.Errorf("failed to record warning: %w", err)
}
return fmt.Errorf("compaction would increase size (%d → %d bytes), keeping original", originalSize, compactedSize)
}
// Archive the original content BEFORE the destructive overwrite, so the
// compaction is reversible (bd restore reads this snapshot). If archiving
// fails we abort with the original content intact rather than lose it.
if err := c.store.SnapshotIssue(ctx, issueID, 1); err != nil {
return fmt.Errorf("failed to archive pre-compaction snapshot: %w", err)
}
// Update issue with summarized content
updates := map[string]interface{}{
"description": summary,
"design": "",
"notes": "",
"acceptance_criteria": "",
}View on GitHub (pinned to 71377f2769)
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
Defensive patterns
Strategy: try-catch
Try / catch
if err := c.CompactTier1(ctx, id); err != nil {
if strings.Contains(err.Error(), "failed to record warning") {
// content is safe (original kept); investigate store write failure
log.Printf("store write failed while recording skip warning: %v", err)
}
return err
} Prevention
- 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
When it happens
Trigger: SummarizeTier1 returned a summary whose byte length >= originalSize, and then store.AddComment(ctx, issueID, "compactor", warningMsg) also failed (storage write error).
Common situations: 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.
Related errors
- failed to archive pre-compaction snapshot: %w
- no store is open for this workspace
- not found
- db: ChildCounterSQLRepository.NextChildID: parentID must not
- db: DependencySQLRepository.Insert: dep must not be nil
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/4b41c4ee3ee47f7b.
Report an issue: GitHub.