Commit 492e18b
Push-driven team state via team_changed + consumer-loop resilience (#65)
* fix: keep event consumers alive across transient handler failures
Three faults observed live tonight, all the same class: an exception escaping
into a consumer's await-foreach ends that subscription for the rest of the
process, so the feature it drives goes silently dead until the bot restarts.
1. "Map connection-status loop faulted. InvalidOperationException: GetMap
returned no data." — ConnectionSupervisor.GetMonumentsAsync forwarded the
connection-level call (documented "Throws on failure") straight through a
query seam whose own contract promised "or an empty list". It was the sole
query in RustPlusSocketSource without a degrade-to-null/empty catch. It now
catches, logs and returns [], and the failure message names the Rust+ error
code instead of a bare "returned no data".
2. "ConnectionStatusChanged consumer faulted. TimeoutException" from a Discord
REST edit — the Workspace consumer died, leaving the info channels stale.
3. The same shape existed, unguarded, in 21 consumer loops across 11 services.
Add EventBusConsumption.ConsumeAsync<TEvent>(handler, onHandlerFailure, ct):
it subscribes, guards each handler call, reports failures and keeps consuming;
only cancellation of the loop token ends the subscription. Abstractions stays
dependency-free (the callback is Action<Exception>, so each service keeps its
own logger). Every vulnerable consumer now routes through it; each service's
outer try/catch stays as a backstop. ClansHostedService and
CommandsHostedService already isolate per event inline and are left alone —
migrating them would lose the guild/server ids in their failure logs.
Also fixes the unrelated log line that started this: Rust+ sends the token
"apartmentcomplex", which no entry in MonumentTokenMap mapped, so apartment
complexes rendered with no icon ("No monument icon for token ...; mapped type:
null"). MonumentType.ApartmentsComplex and Apartments_Complex.svg were already
in RustMapsApi.Assets — only the token table had not caught up.
Tests: EventBusConsumptionTests (a failing handler costs its own event only;
cancellation still ends the subscription), WorkspaceConsumerResilienceTests and
MapHostedServiceTests (both written failing first, reproducing the live
exceptions), plus a monuments-seam and a token-map case.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(connections): use a query-specific log for the monuments seam
Copilot review: GetMonumentsAsync (the query seam used by map rendering) reused
LogMonumentsFetchFailed, whose message says "rig detection disabled for this
connection" — misleading for a non-rig caller. Give the seam its own generic
LogMonumentsQueryFailed and keep the rig-specific message on the rig path.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* test(map): stop the status-loop regression test flaking on slow CI
AdvancingClock jumped 1 minute per read while MapRefreshInterval is 30 minutes,
so MapRefreshThrottle gated every refresh after the first: the counter only
re-incremented once ~30 clock reads accumulated. Fast enough locally, but on
Windows CI fewer than 30 events were consumed inside the 5s deadline, so calls
stuck at 1 and the assert failed. Advance an hour per read (past the interval)
so the throttle passes every refresh and each event reaches the counter.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* docs(spec): push-driven team state via team_changed (beta.6)
Design for moving team-state detection (connect/disconnect/death/respawn/
AFK) from the 2-5s poll onto RustPlusApi beta.6's OnTeamChanged event,
keeping a 30s team poll as an AFK safety tick. Marker/rig polling stays.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* docs(plan): implementation plan for team_changed push migration
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* build(deps): bump RustPlusApi to 2.0.0-beta.6 (team_changed dispatch)
* refactor(connections): extract shared TeamInfoMapping.ToSnapshot
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat(connections): surface team_changed as IRustServerConnection.TeamChanged
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat(connections): add TeamPollInterval (AFK safety-tick cadence)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat(connections): drive team state from team_changed push + slow AFK tick
* test(connections): cover AFK-during-silence; harden team_changed handler; docs
* style(connections): apply ReSharper formatting to new team tests
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent a1e700c commit 492e18b
14 files changed
Lines changed: 1482 additions & 36 deletions
File tree
- docs/superpowers
- plans
- specs
- src/RustPlusBot.Features.Connections
- Listening
- Supervisor
- tests/RustPlusBot.Features.Connections.Tests
- Fakes
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | | - | |
| 18 | + | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
Large diffs are not rendered by default.
Lines changed: 140 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
45 | 53 | | |
46 | 54 | | |
47 | 55 | | |
| |||
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
172 | 179 | | |
Lines changed: 19 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
141 | 147 | | |
142 | 148 | | |
143 | 149 | | |
| |||
170 | 176 | | |
171 | 177 | | |
172 | 178 | | |
| 179 | + | |
173 | 180 | | |
174 | 181 | | |
175 | 182 | | |
| |||
336 | 343 | | |
337 | 344 | | |
338 | 345 | | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
| 346 | + | |
354 | 347 | | |
355 | 348 | | |
356 | 349 | | |
| |||
466 | 459 | | |
467 | 460 | | |
468 | 461 | | |
| 462 | + | |
| 463 | + | |
469 | 464 | | |
470 | 465 | | |
471 | 466 | | |
| |||
766 | 761 | | |
767 | 762 | | |
768 | 763 | | |
| 764 | + | |
769 | 765 | | |
770 | 766 | | |
771 | 767 | | |
| |||
835 | 831 | | |
836 | 832 | | |
837 | 833 | | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
838 | 842 | | |
839 | 843 | | |
840 | 844 | | |
| |||
Lines changed: 33 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
0 commit comments