fix: Auto-close session-ended events to prevent accumulation (gt-8tc1v)
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 <noreply@anthropic.com>
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user