fix: bd admin compact --older-than=0 now expires all tombstones

Previously, --older-than=0 was indistinguishable from "flag not set"
because both resulted in compactOlderThan==0. The check `> 0` treated
both as "use default 30 days".

Fix:
- Change flag default to -1 (sentinel for "use default")
- Treat 0 as "expire all tombstones" by passing 1ns TTL
- Explicit positive values work as before (N days)

Closes bd-gigi

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-30 00:00:25 -08:00
parent cb69f1c154
commit 160feb95ea
2 changed files with 10 additions and 4 deletions

View File

@@ -782,7 +782,7 @@ func init() {
compactCmd.Flags().BoolVar(&compactApply, "apply", false, "Apply mode: accept agent-provided summary")
compactCmd.Flags().BoolVar(&compactAuto, "auto", false, "Auto mode: AI-powered compaction (legacy)")
compactCmd.Flags().BoolVar(&compactPrune, "prune", false, "Prune mode: remove expired tombstones from issues.jsonl (by age)")
compactCmd.Flags().IntVar(&compactOlderThan, "older-than", 0, "Prune tombstones older than N days (default: 30)")
compactCmd.Flags().IntVar(&compactOlderThan, "older-than", -1, "Prune tombstones older than N days (0=all, default: 30)")
compactCmd.Flags().BoolVar(&compactPurgeTombstones, "purge-tombstones", false, "Purge mode: remove tombstones with no open deps (by dependency analysis)")
compactCmd.Flags().StringVar(&compactSummary, "summary", "", "Path to summary file (use '-' for stdin)")
compactCmd.Flags().StringVar(&compactActor, "actor", "agent", "Actor name for audit trail")

View File

@@ -175,10 +175,16 @@ func previewPruneTombstones(customTTL time.Duration) (*TombstonePruneResult, err
func runCompactPrune() {
start := time.Now()
// Calculate TTL from --older-than flag (0 means use default 30 days)
// Calculate TTL from --older-than flag
// -1 (default) = use 30 day default, 0 = expire all, >0 = N days
var customTTL time.Duration
if compactOlderThan > 0 {
customTTL = time.Duration(compactOlderThan) * 24 * time.Hour
if compactOlderThan >= 0 {
if compactOlderThan == 0 {
// --older-than=0 means "expire all tombstones"
customTTL = 1 * time.Nanosecond
} else {
customTTL = time.Duration(compactOlderThan) * 24 * time.Hour
}
}
if compactDryRun {