Add fallback routing and guard rails to the messaging module #93

Merged
calvin merged 10 commits from messaging-routing into master 2026-11-13 06:40:16 +00:00
Owner

What

Milestone 5 of the messaging plan. Stacked on #91 and the SMS pull request: merge those first.

  • An ordered channel list per message; Karta moves on only on facts: the agent offline longer than wait_for_connector_s, the number not on the channel, a permanent failure, three tries of a failure that sent nothing. Never on a missing delivery tick unless the request sets fallback_after_s (300 or more, refused for sign-in codes), and then both attempts are flagged duplicate_possible.
  • "Cannot tell whether it was sent" (unknown_outcome) stops and reports; nothing else is sent.
  • The answer and the messaging.message.status events always say the channel used, the attempt, fallback_from, the cost and duplicate_possible; skipped steps are listed with the reason.
  • SMS only when the server allows it and the request or the organisation does, with a daily cap and a segment estimate (GSM-7/UCS-2).
  • First-contact rule (no WhatsApp conversation without a stated reason), quiet hours (not for sign-in codes), per-connector send limits across replicas.

Tests: one per row of the routing table, the guard rails, a property test of the pure decision (never more than three attempts on a channel, nothing after unknown, channels only in order) and of quiet hours. Docs: messaging-routing.md.

🤖 Generated with Claude Code

## What Milestone 5 of the messaging plan. **Stacked on #91 and the SMS pull request**: merge those first. - An ordered channel list per message; Karta moves on only on facts: the agent offline longer than `wait_for_connector_s`, the number not on the channel, a permanent failure, three tries of a failure that sent nothing. Never on a missing delivery tick unless the request sets `fallback_after_s` (300 or more, refused for sign-in codes), and then both attempts are flagged `duplicate_possible`. - "Cannot tell whether it was sent" (`unknown_outcome`) stops and reports; nothing else is sent. - The answer and the `messaging.message.status` events always say the channel used, the attempt, `fallback_from`, the cost and `duplicate_possible`; skipped steps are listed with the reason. - SMS only when the server allows it and the request or the organisation does, with a daily cap and a segment estimate (GSM-7/UCS-2). - First-contact rule (no WhatsApp conversation without a stated reason), quiet hours (not for sign-in codes), per-connector send limits across replicas. Tests: one per row of the routing table, the guard rails, a property test of the pure decision (never more than three attempts on a channel, nothing after `unknown`, channels only in order) and of quiet hours. Docs: `messaging-routing.md`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
An optional module (KARTA_MESSAGING) with connectors, conversations,
messages and media, the remote-connector WebSocket (postduif.v1), the
HTTP API and the webhook events, with a test double of the agent.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Merge remote-tracking branch 'origin/master' into messaging
Some checks failed
ci/woodpecker/pr/woodpecker Pipeline failed
113ffb33ff
Format the messaging connect test
Some checks failed
ci/woodpecker/pr/woodpecker Pipeline failed
c339aab79a
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Mark the media downloads for sobelow, with the reason
Some checks failed
ci/woodpecker/pr/woodpecker Pipeline failed
bfbdf14e45
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Keep the sobelow notes within credo's line length
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
cbe1baa69f
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Merge branch 'messaging' into messaging-sms
Some checks are pending
ci/woodpecker/pr/woodpecker Pipeline is pending
2edccd7219
Add fallback routing and guard rails to the messaging module
Some checks are pending
ci/woodpecker/pr/woodpecker Pipeline is pending
218fac5658
Channels are tried in order and moved on from only on facts; first-contact
rule, quiet hours, paid-channel allowance and cap, send limits, segment
estimate.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Reference the plug callback as a callback in the docs
Some checks failed
ci/woodpecker/pr/woodpecker Pipeline failed
6ff755e940
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Merge branch 'messaging-sms' into messaging-routing
Some checks failed
ci/woodpecker/pr/woodpecker Pipeline failed
70e04de019
Allow the Bird plug's two fixed hosts in the HTTP client guard
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
ec3a9f12b4
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Merge branch 'messaging-sms' into messaging-routing
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
56329e4fa0
Fix the review findings in the messaging module (S1, S7, S8, S9 and the notes)
Some checks failed
ci/woodpecker/pr/woodpecker Pipeline was canceled
68de389b7d
The messaging event names are not accepted or listed while the module is off;
the text stays out of the webhook events by default; the large body limit is
for the media route only; the protocol copy is the whole document; resume never
pushes more than 100 commands; a late answer to an expired command flags a
possible duplicate; retention goes on past a file it cannot delete; a file is
attached once, by its own connector; the agent's bye reason is kept.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Copy the whole protocol document, with the answer to change 2
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
a5389eac61
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Merge branch 'messaging' into messaging-sms
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
f326050a93
Merge branch 'messaging-sms' into messaging-routing
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
881fb73c40
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Keep the router functions flat for credo
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
e19797c960
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
calvin merged commit 0135b419a8 into master 2026-11-13 06:40:16 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
external/karta!93
No description provided.