Commit b022e93
authored
feat(inbox): record disconnect reason and add reconcile safety limits (#1115)
* feat(inbox): record disconnect reason and add reconcile safety limits
Adds `disconnectedAt`/`disconnectReason` columns to Inbox so a channel
disconnect (manual, workspace purge, trial expiry, tenant suspension) has
a forensic trail on every edition, not just where audit logging is
enabled. Threads the reason through inboxService, workspaceLifecycleService,
and every disconnect call site (channel actions, workspace purge, tenant
suspend, trial teardown).
Also adds circuit breakers to reconcileTenants and unsubscribeExpiredTrials
that abort the destructive branch when a batch looks abnormally large,
since that pattern is far more consistent with a quota-worker bug than
real churn.
* fix(inbox): drop reconcile circuit breakers and duplicate audit dispatch
The trial-teardown breaker returned before re-enqueueing its scan cursor,
so it stalled that job permanently once a batch tripped it; the reconcile
breaker's own tests never actually exercised the threshold and were red
on HEAD. Both are removed rather than retuned. The disconnect audit call
in inboxService duplicated each caller's own richer audit entry and
clobbered `source` with `withAuditContext`'s value, so it's deleted in
favor of the callers' records and the disconnectReason column. Reconnect
now clears disconnectedAt/disconnectReason, workspace teardown resolves
`token_revoked` from provider errors instead of leaving it dead, and the
routine per-inbox teardown log is demoted from error to info.1 parent e3303c7 commit b022e93
28 files changed
Lines changed: 43299 additions & 9 deletions
File tree
- apps
- builder
- __tests__
- src/features
- integration-instagram/actions
- integration-messenger/actions
- integration-smtp/services
- integration-telegram/actions
- integration-tiktok/actions
- integration-whatsapp/actions
- integration-zalo/actions
- worker
- __tests__
- src/schedule/handlers
- packages
- business
- __tests__
- src
- enterprise/tenant
- inbox
- __tests__
- integration-api
- integration-webchat
- workspace-lifecycle
- __tests__
- workspace
- database
- drizzle/20260908123255_add-inbox-disconnect-reason
- src
- partials
- schema
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
192 | 192 | | |
193 | 193 | | |
194 | 194 | | |
| 195 | + | |
195 | 196 | | |
196 | 197 | | |
197 | 198 | | |
| |||
227 | 228 | | |
228 | 229 | | |
229 | 230 | | |
| 231 | + | |
230 | 232 | | |
231 | 233 | | |
232 | 234 | | |
| |||
275 | 277 | | |
276 | 278 | | |
277 | 279 | | |
| 280 | + | |
278 | 281 | | |
279 | 282 | | |
280 | 283 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
| 130 | + | |
130 | 131 | | |
131 | 132 | | |
132 | 133 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| 102 | + | |
102 | 103 | | |
103 | 104 | | |
104 | 105 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
| 122 | + | |
122 | 123 | | |
123 | 124 | | |
124 | 125 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
| 188 | + | |
188 | 189 | | |
189 | 190 | | |
190 | 191 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| 93 | + | |
93 | 94 | | |
94 | 95 | | |
95 | 96 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| 68 | + | |
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
24 | 36 | | |
25 | 37 | | |
26 | 38 | | |
| |||
0 commit comments