From c24c3ba8737f516af47fc3b828753601872de3b6 Mon Sep 17 00:00:00 2001 From: buzzard Date: Mon, 5 Jan 2026 00:10:07 -0800 Subject: [PATCH] fix: Auto-close session-ended events to prevent accumulation (gt-8tc1v) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Session-ended event beads were accumulating without being processed. Modified costs.go to auto-close these events immediately after creation since they are informational audit events. The event data is preserved in the closed bead and remains queryable. Also bulk-closed 83 existing stale session-ended events. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- internal/cmd/costs.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/internal/cmd/costs.go b/internal/cmd/costs.go index 5e72c684..26b1e3a0 100644 --- a/internal/cmd/costs.go +++ b/internal/cmd/costs.go @@ -605,6 +605,16 @@ func runCostsRecord(cmd *cobra.Command, args []string) error { eventID := strings.TrimSpace(string(output)) + // Auto-close session events immediately after creation. + // These are informational audit events that don't need to stay open. + // The event data is preserved in the closed bead and remains queryable. + closeCmd := exec.Command("bd", "close", eventID, "--reason=auto-closed session event") + if closeErr := closeCmd.Run(); closeErr != nil { + // Non-fatal: event was created, just couldn't auto-close + // The witness patrol can clean these up if needed + fmt.Fprintf(os.Stderr, "warning: could not auto-close session event %s: %v\n", eventID, closeErr) + } + // Output confirmation (silent if cost is zero and no work item) if cost > 0 || recordWorkItem != "" { fmt.Printf("%s Recorded $%.2f for %s (event: %s)", style.Success.Render("✓"), cost, session, eventID)