Chat reliability: durable ntfy outbox, queue recovery retries, unattended cap

- Chat phone pushes (attention items, auto-switch notices) go through a
  durable chat_notifications outbox with leases, bounded attempts and
  backoff, retried by a worker; pushes cleared in the app first are never
  published, and a publication racing a clear is cleared again.
- Queued/scheduled chat prompts are deleted on recovery only when they can
  never be rebuilt; transient failures keep the rows and retry with backoff.
- Unattended chats with live work always keep notifying; the idle cap rises
  from 16 to 64.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-03 00:26:46 +00:00
parent accb9970b6
commit 9f13c93be6
13 changed files with 609 additions and 58 deletions
+4 -6
View File
@@ -11,7 +11,6 @@ import (
"git.a-wan.net/alan/pipelines/internal/claude"
"git.a-wan.net/alan/pipelines/internal/pipeline"
"git.a-wan.net/alan/pipelines/internal/protocol"
"git.a-wan.net/alan/pipelines/internal/stage"
)
// When Claude Code refuses an operator chat's turn because the account ran
@@ -281,10 +280,11 @@ func (h *chatHub) publishAutoSwitchNotice(ctx context.Context, refusal claude.Us
}
title := truncateUTF8("Switched "+name+" to "+singleLine(email)+" and continued", 256)
message := "Claude usage ran out, so Pipelines switched the account and asked the agent to check it is on track before continuing."
click, views := chatAttentionLinks(refusal.SessionID)
click, _ := chatAttentionLinks(refusal.SessionID)
id := "chat:" + refusal.SessionID + ":auto-switch:" + refusalKey(refusal)
if h.notes != nil {
h.notes.record(ctx, pipeline.AppNotificationRecord{
AppNotification: protocol.AppNotification{ID: "chat:" + refusal.SessionID + ":auto-switch:" + refusalKey(refusal), Kind: protocol.NotificationChatReply,
AppNotification: protocol.AppNotification{ID: id, Kind: protocol.NotificationChatReply,
Title: title, Message: message, Click: click, Priority: chatAutoSwitchPriority, Tags: []string{}, Group: "chat:" + refusal.SessionID},
SessionID: refusal.SessionID,
})
@@ -292,7 +292,5 @@ func (h *chatHub) publishAutoSwitchNotice(ctx context.Context, refusal claude.Us
if !chatAttentionConfigured() || !chatNotificationSettings(ctx, h.settings).NtfyEnabled {
return
}
if _, err := chatAttentionPublish(stage.WithNtfyPriority(ctx, chatAutoSwitchPriority), "system", title, message, "", nil, click, views...); err != nil {
log.Printf("claude auto-switch notification session=%s: %v", refusal.SessionID, err)
}
h.pushChatNtfy(ctx, pipeline.ChatNotification{ID: id, SessionID: refusal.SessionID, Title: title, Body: message, Click: click, Priority: chatAutoSwitchPriority})
}