DeleteAfterMessageID deletes debug data newer than the given message. The startedBefore bound scopes deletion to runs created before that instant so that retried cleanup does not remove runs created by a replacement turn that raced ahead of the retry window.
( ctx context.Context, chatID uuid.UUID, messageID int64, startedBefore time.Time, )
| 553 | // instant so that retried cleanup does not remove runs created by a |
| 554 | // replacement turn that raced ahead of the retry window. |
| 555 | func (s *Service) DeleteAfterMessageID( |
| 556 | ctx context.Context, |
| 557 | chatID uuid.UUID, |
| 558 | messageID int64, |
| 559 | startedBefore time.Time, |
| 560 | ) (int64, error) { |
| 561 | deleted, err := s.db.DeleteChatDebugDataAfterMessageID( |
| 562 | chatdContext(ctx), |
| 563 | database.DeleteChatDebugDataAfterMessageIDParams{ |
| 564 | ChatID: chatID, |
| 565 | MessageID: messageID, |
| 566 | StartedBefore: startedBefore, |
| 567 | }, |
| 568 | ) |
| 569 | if err != nil { |
| 570 | return 0, err |
| 571 | } |
| 572 | |
| 573 | s.publishEvent(ctx, chatID, EventKindDelete, uuid.Nil, uuid.Nil) |
| 574 | return deleted, nil |
| 575 | } |
| 576 | |
| 577 | // FinalizeStale finalizes stale in-flight debug rows and emits a broadcast. |
| 578 | func (s *Service) FinalizeStale( |