@webex/plugin-meetings 3.13.0-next.13 → 3.13.0-next.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/.repo-context.json +577 -0
  2. package/.sdd/manifest.json +1320 -428
  3. package/AGENTS.md +528 -72
  4. package/dist/aiEnableRequest/index.js +1 -1
  5. package/dist/breakouts/breakout.js +1 -1
  6. package/dist/breakouts/index.js +1 -1
  7. package/dist/config.js +1 -1
  8. package/dist/interpretation/index.js +1 -1
  9. package/dist/interpretation/siLanguage.js +1 -1
  10. package/dist/webinar/index.js +1 -1
  11. package/docs/adr/0001-migrate-existing-docs-into-sdd.md +141 -0
  12. package/docs/adr/index.md +26 -0
  13. package/docs/architecture.md +816 -0
  14. package/docs/getting-started.md +177 -0
  15. package/docs/index.md +53 -0
  16. package/docs/specs/README.md +126 -0
  17. package/package.json +21 -21
  18. package/schemas/repo-context.schema.json +796 -0
  19. package/src/aiEnableRequest/docs/README.md +376 -0
  20. package/src/annotation/docs/README.md +402 -0
  21. package/src/breakouts/docs/README.md +643 -0
  22. package/src/controls-options-manager/docs/README.md +365 -0
  23. package/src/hashTree/docs/README.md +566 -0
  24. package/src/interceptors/docs/README.md +434 -0
  25. package/src/interpretation/docs/README.md +420 -0
  26. package/src/locus-info/docs/README.md +609 -0
  27. package/src/media/docs/README.md +488 -0
  28. package/src/meeting/docs/README.md +834 -0
  29. package/src/meeting-info/docs/README.md +352 -0
  30. package/src/meetings/docs/README.md +549 -0
  31. package/src/member/docs/README.md +347 -0
  32. package/src/members/docs/README.md +514 -0
  33. package/src/metrics/docs/README.md +287 -0
  34. package/src/multistream/docs/README.md +523 -0
  35. package/src/personal-meeting-room/docs/README.md +322 -0
  36. package/src/reachability/docs/README.md +548 -0
  37. package/src/reactions/docs/README.md +296 -0
  38. package/src/reconnection-manager/docs/README.md +485 -0
  39. package/src/recording-controller/docs/README.md +335 -0
  40. package/src/roap/docs/README.md +444 -0
  41. package/src/webinar/docs/README.md +425 -0
  42. package/.sdd/templates/.source.json +0 -30
  43. package/.sdd/templates/component-repo/module-docs/module-spec-quality.md +0 -111
  44. package/.sdd/templates/component-repo/module-docs/module-spec.template.md +0 -321
  45. package/.sdd/templates/component-repo/reference-docs/adr/_adr-example.md +0 -59
  46. package/.sdd/templates/component-repo/reference-docs/patterns/_pattern-example.md +0 -49
  47. package/.sdd/templates/component-repo/reference-docs/rules/_rule-example.md +0 -42
  48. package/.sdd/templates/component-repo/standing-docs/AGENTS.template.md +0 -120
  49. package/.sdd/templates/component-repo/standing-docs/ARCHITECTURE.template.md +0 -206
  50. package/.sdd/templates/component-repo/standing-docs/CONTRACTS.template.md +0 -90
  51. package/.sdd/templates/component-repo/standing-docs/DATA_MODEL.template.md +0 -68
  52. package/.sdd/templates/component-repo/standing-docs/GETTING_STARTED.template.md +0 -111
  53. package/.sdd/templates/component-repo/standing-docs/GLOSSARY.template.md +0 -57
  54. package/.sdd/templates/component-repo/standing-docs/REVIEW_CHECKLIST.template.md +0 -69
  55. package/.sdd/templates/component-repo/standing-docs/RULES.template.md +0 -96
  56. package/.sdd/templates/component-repo/standing-docs/SECURITY.template.md +0 -84
  57. package/.sdd/templates/component-repo/standing-docs/SERVICE_STATE.template.md +0 -82
  58. package/.sdd/templates/component-repo/standing-docs/SPEC_INDEX.template.md +0 -94
  59. package/.sdd/templates/component-repo/standing-docs/TEST_INDEX.template.md +0 -64
  60. package/.sdd/templates/component-repo/template-map.json +0 -112
  61. package/ai-docs/ARCHITECTURE.md +0 -208
  62. package/ai-docs/CONTRACTS.md +0 -267
  63. package/ai-docs/DATA_MODEL.md +0 -64
  64. package/ai-docs/GETTING_STARTED.md +0 -73
  65. package/ai-docs/GLOSSARY.md +0 -56
  66. package/ai-docs/REVIEW_CHECKLIST.md +0 -45
  67. package/ai-docs/RULES.md +0 -79
  68. package/ai-docs/SECURITY.md +0 -74
  69. package/ai-docs/SERVICE_STATE.md +0 -59
  70. package/ai-docs/SPEC_INDEX.md +0 -85
  71. package/ai-docs/TEST_INDEX.md +0 -45
  72. package/ai-docs/adr/0001-migrate-existing-docs-into-sdd.md +0 -61
  73. package/ai-docs/patterns/defensive-error-propagation.md +0 -55
  74. package/ai-docs/patterns/event-scope-emission.md +0 -46
  75. package/ai-docs/patterns/source-to-test-path-mirroring.md +0 -45
  76. package/ai-docs/patterns/stateless-plugin-request-classes.md +0 -53
  77. package/ai-docs/patterns/typed-constants-and-enum-values.md +0 -47
  78. package/src/aiEnableRequest/ai-docs/ai-enable-request-spec.md +0 -223
  79. package/src/annotation/ai-docs/annotation-spec.md +0 -236
  80. package/src/breakouts/ai-docs/breakouts-spec.md +0 -324
  81. package/src/controls-options-manager/ai-docs/controls-options-manager-spec.md +0 -243
  82. package/src/hashTree/ai-docs/hash-tree-spec.md +0 -267
  83. package/src/interceptors/ai-docs/interceptors-spec.md +0 -247
  84. package/src/interpretation/ai-docs/interpretation-spec.md +0 -256
  85. package/src/locus-info/ai-docs/locus-info-spec.md +0 -293
  86. package/src/media/ai-docs/media-spec.md +0 -267
  87. package/src/meeting/ai-docs/meeting-spec.md +0 -404
  88. package/src/meeting-info/ai-docs/meeting-info-spec.md +0 -261
  89. package/src/meetings/ai-docs/meetings-spec.md +0 -298
  90. package/src/member/ai-docs/member-spec.md +0 -196
  91. package/src/members/ai-docs/members-spec.md +0 -256
  92. package/src/metrics/ai-docs/metrics-spec.md +0 -185
  93. package/src/multistream/ai-docs/multistream-spec.md +0 -295
  94. package/src/personal-meeting-room/ai-docs/personal-meeting-room-spec.md +0 -234
  95. package/src/reachability/ai-docs/reachability-spec.md +0 -261
  96. package/src/reactions/ai-docs/reactions-spec.md +0 -198
  97. package/src/reconnection-manager/ai-docs/reconnection-manager-spec.md +0 -272
  98. package/src/recording-controller/ai-docs/recording-controller-spec.md +0 -223
  99. package/src/roap/ai-docs/roap-spec.md +0 -241
  100. package/src/webinar/ai-docs/webinar-spec.md +0 -243
@@ -0,0 +1,485 @@
1
+ ---
2
+ type: Module Spec
3
+ title: 'Reconnection manager specification'
4
+ description: Responsibilities, boundaries, design, state, invariants, and verification for the plugin-meetings reconnection manager.
5
+ tags: [module, specification]
6
+ ---
7
+ <!-- sdd-generated-metadata
8
+ doc_kind: module-spec
9
+ generated_from: module-spec@0.3.0
10
+ generated_by: claude-code
11
+ approved_by: rarajes2@cisco.com
12
+ updated_at: 2026-11-17T03:14:21Z
13
+ validation_status: pass-with-warnings
14
+ -->
15
+
16
+ # Reconnection manager
17
+
18
+ This source-local document at `src/reconnection-manager/docs/README.md` owns the stable
19
+ specification for **the reconnection manager**: the `ReconnectionManager` class that one `Meeting`
20
+ creates for itself and uses to recover from network and media failures. It waits a bounded time for
21
+ ICE to come back, then runs one recovery at a time — optionally reconnecting the Mercury websocket,
22
+ syncing meetings, and renewing the media connection — and rejoins the meeting when Locus shows the
23
+ user as LEFT. Ground every claim in package evidence and link to the
24
+ [package architecture](../../../docs/architecture.md) instead of repeating broader facts. No service
25
+ specification exists because this package is a library.
26
+
27
+ Related context: [documentation index](../../../docs/index.md) ·
28
+ [package agent instructions](../../../AGENTS.md) ·
29
+ [module registry](../../../docs/specs/README.md) ·
30
+ [owning Meeting specification](../../meeting/docs/README.md).
31
+ Repo architecture: [package architecture](../../../docs/architecture.md) · Registry:
32
+ [module registry](../../../docs/specs/README.md). Coverage state and contracts baseline:
33
+ `.sdd/manifest.json` routes this module and registers its contract IDs.
34
+
35
+ ## Metadata
36
+
37
+ | Field | Value |
38
+ | ----------------- | ----- |
39
+ | Owner | @webex/web-client, @webex/web-sdk |
40
+ | Source path | `src/reconnection-manager` |
41
+ | Resource kind | module |
42
+ | Status | Draft |
43
+ | Last verified | 2026-11-16 at `0b8c34db7f` |
44
+ | Module id | `plugin-meetings/reconnection-manager` |
45
+ | Parent spec | — |
46
+ | Doc kind | Module spec |
47
+ | Coverage score | Pending coverage assessment |
48
+ | Validation status | not-run |
49
+
50
+ ## Applicability
51
+
52
+ | Condition ID | Status | Evidence or reason | Owned section |
53
+ | ------------------------------------ | ---------- | ------------------ | ------------- |
54
+ | `module.has_tiers` | N/A | No tier policy exists in `package.json` or `src/reconnection-manager/index.ts` | Tier |
55
+ | `module.has_ui` | N/A | `src/reconnection-manager/index.ts` renders nothing; it returns promises and emits meeting events | UI use-case flow |
56
+ | `module.crosses_service_boundaries` | N/A | `src/reconnection-manager/index.ts` sends no request itself; Locus, TURN, Mercury, and metrics traffic goes through the owning Meeting, webex.meetings, and the Mercury and metrics plugins | Cross-boundary use-case flow |
57
+ | `module.holds_client_state` | Applicable | `src/reconnection-manager/index.ts` keeps the reconnection status, the rejoin attempt count, and the ICE wait state | Client state model |
58
+ | `module.enforces_domain_rules` | Applicable | The single-run guard, the rejoin bound, and the LEFT-state rules in `src/reconnection-manager/index.ts` | Business rules and invariants |
59
+ | `module.is_concurrent_async` | Applicable | Every recovery step is awaited, the ICE wait is a timer, and a failed rejoin retries without awaiting (`src/reconnection-manager/index.ts`) | Concurrency and reactive flow |
60
+ | `module.owns_persistence` | N/A | Nothing is stored outside the instance (`src/reconnection-manager/index.ts`) | Data, schema, and migration discipline |
61
+ | `module.stateful_transitions` | Applicable | The status moves between the default, IN_PROGRESS, and FAILURE values of RECONNECTION.STATE in `src/constants.ts` | State machine |
62
+ | `module.exposes_wire_protocol` | N/A | The module builds no payload; the metric and event payloads it hands to other modules are listed under Public surface | Protocol and wire format |
63
+ | `module.ui_multi_screen` | N/A | No UI | UI flow |
64
+ | `module.large_data_model` | N/A | The state is five fields, listed under Client state model | Data model |
65
+ | `module.returns_caller_errors` | Applicable | `src/reconnection-manager/index.ts` throws ReconnectionNotStartedError and ReconnectionError, from `src/common/errors/reconnection-not-started.ts` and `src/common/errors/reconnection.ts` | Caller-visible failure modes |
66
+ | `module.module_specific_conventions` | N/A | The module follows the package rules in `AGENTS.md`; it adds none of its own | Module-specific rules |
67
+ | `module.published_package` | N/A | `src/index.ts` does not export the class; only `src/meeting/index.ts` imports it | Export stability |
68
+ | `module.embedded_in_host` | N/A | No host theme or embed API | Host integration and theming |
69
+ | `module.has_design_tradeoff` | Applicable | Recovery escalates from waiting, to media reconnect, to rejoin, inside the owning Meeting (`src/reconnection-manager/index.ts`) | Key design trade-off |
70
+ | `module.has_submodules` | N/A | The directory holds one source file and no child module | Sub-modules |
71
+
72
+ ## Evidence register
73
+
74
+ Requirements cite current implementation and mirrored unit-test paths. Code wins over prose when
75
+ they conflict, and commit and PR history are excluded as evidence by repository-owner decision.
76
+ Missing test evidence is stated as a gap rather than inferred.
77
+
78
+ | Evidence | What it establishes |
79
+ | -------- | ------------------- |
80
+ | `src/reconnection-manager/index.ts` | `ReconnectionManager` (default export), the module-private `NeedsRetryError` and `NeedsRejoinError`, every public method, and the private `canStartReconnection`, `stopLocalShareStream`, `executeReconnection`, and `reconnectMercuryWebSocket`. Its JSDoc and code comments are the recorded rationale |
81
+ | `src/constants.ts` | `RECONNECTION.STATE` (`IN_PROGRESS`, `FAILURE`, default `''`), `SHARE_STATUS`, `SHARE_STOPPED_REASON` (`SELF_STOPPED`, `MEETING_REJOIN`, `MEDIA_RECONNECTION`, `TRACK_ENDED`), and the `EVENT_TRIGGERS` literals emitted here |
82
+ | `src/config.ts` | `meetings.reconnection` defaults: `enabled` false, `autoRejoin` true, `detection` true, `iceReconnectionTimeout` 10000 ms, `maxRejoinAttempts` 3, with comments that state what the timeout and the attempt limit are for |
83
+ | `src/metrics/constants.ts` | Behavioral metric names `js_sdk_meeting_reconnect_failures` and `js_sdk_meeting_max_rejoin_failure` |
84
+ | `src/common/errors/reconnection.ts`, `src/common/errors/reconnection-not-started.ts` | The two error classes the module throws |
85
+ | `src/meeting/index.ts` | The only importer: the constructor creates the manager; `reconnect()` guards media state, cleans up, passes a completion callback that waits for the remote SDP answer and the media connection, and resolves on ReconnectionNotStartedError; the connection-state listener calls `waitForIceReconnect`, `iceReconnected`, and `resetReconnectionTimer`; `moveTo` calls `cleanUp` |
86
+ | `src/meeting/util.ts` | `MeetingUtil.cleanUp` calls `reconnectionManager.cleanUp()` after closing streams and peer connections |
87
+ | `test/unit/spec/reconnection-manager/index.js` | Mocha and Sinon cases for `reconnect` (sync, reachability, TURN information, media re-request, metrics and events, the two not-started guards), `iceReconnected`, `waitForIceReconnect`, and `cleanUp` |
88
+ | `test/unit/spec/meeting/index.js` | Meeting-side cases for `#reconnect` and for the Disconnected connection state with `waitForIceReconnect` resolving or rejecting |
89
+ | Observation: a failed rejoin retries without waiting | When `meeting.join({rejoin: true})` fails and attempts remain, `rejoinMeeting` calls itself without `await` and without `wasSharing`, then continues to `reconnectMedia()` in the same call (`src/reconnection-manager/index.ts`). No code comment or test states why the retry is not awaited |
90
+ | Observation: a failed meetings sync retries without limit | `NeedsRetryError` resets the status and calls `reconnect({networkDisconnect: true, networkRetry: true})` again, with no attempt counter (`src/reconnection-manager/index.ts`). No code comment or test states a bound |
91
+ | Observation: shareStatus is declared but unused | The class declares `shareStatus`, but sharing is read from `meeting.shareStatus` (`src/reconnection-manager/index.ts`) |
92
+
93
+ ## Purpose and boundary
94
+
95
+ - Responsibility: coordinates network/media recovery for one Meeting, escalating from reconnecting
96
+ media to rejoining the meeting when required. The rejoin is bounded by `maxRejoinAttempts`; a
97
+ failed meetings sync restarts the run with no bound.
98
+ - In scope: the duplicate-run and enabled guards; the bounded ICE wait (`waitForIceReconnect`,
99
+ `iceReconnected`, `resetReconnectionTimer`); one recovery run (`reconnect`), with the optional
100
+ Mercury websocket reconnect, the meetings sync, the ended-meeting and LEFT-state checks, and the
101
+ media reconnect (`reconnectMedia`); the meeting rejoin (`rejoinMeeting`); stopping a local share
102
+ when recovery starts; the reconnection events and metrics; `reset` and `cleanUp`.
103
+ - Out of scope: deciding when to recover (the Meeting's connection-state listener and its
104
+ `reconnect()` wrapper); TURN discovery (`src/roap`); the WebRTC connection and its ICE restart
105
+ (`src/media` and `@webex/internal-media-core`); multistream media requests (`src/multistream`);
106
+ joining (`Meeting.join`); the meetings sync and reachability (`src/meetings`, `src/reachability`);
107
+ the websocket itself (`@webex/internal-plugin-mercury`).
108
+ - Consumers: `src/meeting/index.ts` only. Applications reach it as `meeting.reconnectionManager`, and
109
+ usually through `meeting.reconnect()`.
110
+
111
+ ## Structure and key files
112
+
113
+ `src/reconnection-manager/` contains 1 direct source file and has 1 mirrored unit-test file.
114
+ TypeScript source with Mocha, Sinon, and `@webex/test-helper-chai` unit tests: `test:unit` runs
115
+ `webex-legacy-tools test --unit --runner mocha`, and the build target is
116
+ `yarn workspace @webex/plugin-meetings build:src` (`package.json`).
117
+
118
+ | File | Holds |
119
+ | ---- | ----- |
120
+ | `src/reconnection-manager/index.ts` | module facade and controller: the `ReconnectionManager` default export (its only export), with the module-private `NeedsRetryError` and `NeedsRejoinError` primary control-flow errors |
121
+ | `test/unit/spec/reconnection-manager/index.js` | mirrored characterization/unit coverage of `reconnect`, the ICE wait, and `cleanUp` |
122
+ | `src/reconnection-manager/docs/README.md` | This module specification, the canonical module specification for this folder |
123
+
124
+ ## Public surface
125
+
126
+ | Contract ID | Type | Surface | Purpose | Compatibility / deprecation | Schema / detail link | Root index |
127
+ |---|---|---|---|---|---|---|
128
+ | `reconnection-manager` | SDK / state | `ReconnectionManager.isReconnectInProgress()`, `reset()`, and `cleanUp()` | Expose the duplicate-run guard and reset only reconnection status plus rejoin attempts. | `cleanUp()` calls `reset()`; neither clears `iceState.timer` nor settles/clears the ICE wait. Use `resetReconnectionTimer()` for that separate state. | `src/reconnection-manager/index.ts` | [architecture](../../../docs/architecture.md#public-and-consumer-surfaces) |
129
+ | `reconnection-manager` | SDK / ICE wait | `waitForIceReconnect()`, `iceReconnected()`, and `resetReconnectionTimer()` | Wait for a bounded ICE recovery signal and settle/clear the owned timer and resolver. | Preserve the `iceReconnectionTimeout` duration (10000 ms default), resolve-on-reconnect, reject-on-timeout, the immediately resolved promise while a wait is pending, and reset ordering. | `src/reconnection-manager/index.ts`, `src/config.ts` | [architecture](../../../docs/architecture.md#public-and-consumer-surfaces) |
130
+ | `reconnection-manager` | SDK / recovery | `reconnect({networkDisconnect, networkRetry}, completionCallback)` | Run one guarded recovery sequence, emitting success after the ordinary recovery/completion-callback path and failure on terminal errors. | A successful auto-rejoin returns before `MEETING_RECONNECTION_SUCCESS`; disabled/duplicate starts throw, and terminal failure resets status/attempts in `finally`. | `src/reconnection-manager/index.ts` | [architecture](../../../docs/architecture.md#public-and-consumer-surfaces) |
131
+ | `reconnection-manager` | SDK / recovery | `reconnectMedia()` | Renew the current media connection: forced TURN discovery, `webrtcMediaConnection.reconnect(iceServers)`, and a multistream media-request commit. | No attempt limit of its own; a failure is terminal for `reconnect()` and is rethrown by `rejoinMeeting()`. | `src/reconnection-manager/index.ts` | [architecture](../../../docs/architecture.md#public-and-consumer-surfaces) |
132
+ | `reconnection-manager` | SDK / recovery | `rejoinMeeting(wasSharing)` | Rejoin the meeting up to `maxRejoinAttempts` extra times, stop a share that was active at recovery start with the recovery reason, then reconnect media. | Current code does not restore or republish sharing after recovery. | `src/reconnection-manager/index.ts` | [architecture](../../../docs/architecture.md#public-and-consumer-surfaces) |
133
+
134
+ Contract ID `reconnection-manager` is indexed in the
135
+ [package architecture](../../../docs/architecture.md#public-and-consumer-surfaces) and registered in
136
+ `.sdd/manifest.json`; this module requires `meeting-api` and `media-connection`. The class is not
137
+ exported from `src/index.ts`.
138
+
139
+ Emitted events. Current source emits or forwards these observable literals for this operation
140
+ boundary. Preserve literal values, scope, payload shape, and emission timing; a constant name alone
141
+ is not a substitute for the consumer-visible value.
142
+
143
+ | Event literal | Constant / expression | Emission evidence |
144
+ |---|---|---|
145
+ | `meeting:reconnectionFailure` | `EVENT_TRIGGERS.MEETING_RECONNECTION_FAILURE` | `src/reconnection-manager/index.ts` |
146
+ | `meeting:reconnectionStarting` | `EVENT_TRIGGERS.MEETING_RECONNECTION_STARTING` | `src/reconnection-manager/index.ts` |
147
+ | `meeting:reconnectionSuccess` | `EVENT_TRIGGERS.MEETING_RECONNECTION_SUCCESS` | `src/reconnection-manager/index.ts` |
148
+ | `meeting:stoppedSharingLocal` | `EVENT_TRIGGERS.MEETING_STOPPED_SHARING_LOCAL` | `src/meeting/index.ts`, `src/reconnection-manager/index.ts` |
149
+
150
+ Every event is triggered on the owning Meeting. `meeting:reconnectionFailure` carries
151
+ `{error: ReconnectionError}` and `meeting:stoppedSharingLocal` carries `{reason}`.
152
+ `MEETING_RECONNECTION_SUCCESS` is emitted only after `executeReconnection()` and any completion
153
+ callback finish on the ordinary path. When a `NeedsRejoinError` is handled by successful automatic
154
+ rejoin, `reconnect()` returns immediately after `rejoinMeeting()` and skips that success event.
155
+ Terminal errors still emit `MEETING_RECONNECTION_FAILURE`.
156
+
157
+ Metrics. Through `webex.internal.newMetrics.submitClientEvent` the module submits
158
+ `client.media.reconnecting` (only when `networkRetry` is false), `client.call.aborted` with one
159
+ error `{category: 'expected', errorCode: 2008, fatal: true, name: 'media-engine', shownToUser:
160
+ false}` whenever recovery fails without a retry, and `client.media.recovered` with
161
+ `{recoveredBy: 'new'}` on ordinary success. Through `Metrics.sendBehavioralMetric` it sends
162
+ `MEETING_RECONNECT_FAILURE` (`correlation_id`, `locus_id`, `reason`, `stack`) on a terminal failure
163
+ and `MEETING_MAX_REJOIN_FAILURE` (`locus_id`, `reason`, `stack`) when rejoin attempts run out.
164
+
165
+ Compatibility notes:
166
+
167
+ - Prefer additive options and payload fields. Preserve method/event names, rejection semantics, and
168
+ cleanup timing; route public changes through the owning `Meeting` (`src/meeting/index.ts`), since
169
+ the class is not exported from `src/index.ts`.
170
+
171
+ ## Dependencies
172
+
173
+ Requires the owning Meeting's lifecycle/media methods, its network state callbacks, timers, the
174
+ `reconnection` retry configuration, logging, events, and metrics.
175
+
176
+ Required contract IDs, as registered in `.sdd/manifest.json`: `meeting-api` and
177
+ `media-connection`. The other rows are reached through the owning Meeting's `webex` and carry no
178
+ separate contract for this module.
179
+
180
+ | Dependency | Why it is required | Failure behavior |
181
+ | ---------- | ------------------ | ---------------- |
182
+ | Owning `Meeting` (`src/meeting/index.ts`, contract `meeting-api`) | `config.reconnection`, `id`, `state`, `type`, `shareStatus`, `locusUrl`, `correlationId`, `isMultistream`, `join({rejoin: true})`, `unpublishStreams`, `roap.doTurnDiscovery`, and `mediaRequestManagers` | A rejected join is retried up to the limit; a rejected TURN discovery or media reconnect ends the run with ReconnectionError |
183
+ | Media connection (`src/media`, contract `media-connection`) | `meeting.mediaProperties.webrtcMediaConnection.reconnect(iceServers)` renews the WebRTC connection | A rejection ends the run with ReconnectionError |
184
+ | `webex.meetings` (`src/meetings/index.ts`) | `startReachability('reconnection')`, `syncMeetings({keepOnlyLocusMeetings: false})`, and `getMeetingByType('id', meeting.id)` | Reachability failure is logged and ignored; sync failure restarts the run (`NeedsRetryError`); a missing meeting ends it |
185
+ | `webex.internal.mercury` | `connected`, `disconnect()`, and `connect()` when `networkDisconnect` is true | Either failure ends the run with ReconnectionError and sets FAILURE until the outer reset |
186
+ | `webex.internal.device` | `url` for a log line after the websocket reconnects | — |
187
+ | `webex.internal.newMetrics` | `submitClientEvent` for the client events under Public surface | Not awaited |
188
+ | `src/metrics` (`Metrics.sendBehavioralMetric`) | The two behavioral failure metrics | Not awaited |
189
+ | `src/common/events/trigger-proxy.ts`, `src/common/logs/logger-proxy.ts` | Meeting-scoped events and logging | — |
190
+ | `src/multistream/mediaRequestManager.ts` | The type whose `commit()` resends media requests after a multistream reconnect | — |
191
+
192
+ ## Requirements
193
+
194
+ | ID | WHAT | WHY | Source Evidence | Test / Example Evidence | Assumptions / Gaps | Confidence |
195
+ |---|---|---|---|---|---|---|
196
+ | `RECONNECTION-MANAGER-R-001` | Start, reset, and inspect reconnection state: `isReconnectInProgress()` reports `status === IN_PROGRESS`; `reset()` sets `status` to `''` and `rejoinAttempts` to 0; `cleanUp()` only calls `reset()`; the constructor reads `iceReconnectionTimeout`, `maxRejoinAttempts`, and `autoRejoin` from the meeting config and calls `reset()`. | The constructor comment requires the reconnection state to start in default, and `MeetingUtil.cleanUp` and `moveTo` call `cleanUp()` so the next media session starts without a stale run. | `src/reconnection-manager/index.ts`, `src/meeting/util.ts` | `test/unit/spec/reconnection-manager/index.js` | none | PRESENT |
197
+ | `RECONNECTION-MANAGER-R-002` | Wait for ICE with a timer: `waitForIceReconnect()` marks ICE disconnected and returns a promise that resolves when `iceReconnected()` runs and rejects with `ice reconnection did not occur in <timeout>ms` after `iceReconnectionTimeout`; while a wait is pending it returns a resolved promise. `iceReconnected()` and `resetReconnectionTimer()` resolve the pending promise and clear the timer. | The config comment: the timeout is how long to wait for ICE to reconnect after a disconnect; the Meeting resets the timer on a failed connection because the browser will not recover it any more, and the resolved second promise prevents multiple catch executions of reconnect. | `src/reconnection-manager/index.ts`, `src/config.ts`, `src/meeting/index.ts` | `test/unit/spec/reconnection-manager/index.js`, `test/unit/spec/meeting/index.js` | ICE event/timeout races at the final attempt boundary need explicit coverage | PRESENT |
198
+ | `RECONNECTION-MANAGER-R-003` | Duplicate starts throw `ReconnectionNotStartedError`. Ordinary successful recovery emits `MEETING_RECONNECTION_SUCCESS` after its completion callback, but successful automatic rejoin returns before that emission. Terminal recovery failures emit `MEETING_RECONNECTION_FAILURE` and reject with `ReconnectionError`; some inner paths assign `FAILURE`, but the outer `finally` calls `reset()` and returns status to the default value. | Callers must not treat success-event presence as proof of every successful recovery mode, and must rely on the returned rejection/failure event rather than assume that `FAILURE` persists after settlement. | `src/reconnection-manager/index.ts` | `test/unit/spec/reconnection-manager/index.js` | characterize the absent success event after successful auto-rejoin | PRESENT |
199
+ | `RECONNECTION-MANAGER-R-004` | Any status other than `''` prevents a second recovery run, and so does `config.reconnection.enabled` being false (the default); `rejoinAttempts` is bounded by `maxRejoinAttempts` and both fields are reset by `reconnect()` cleanup. The separate ICE-wait path owns `iceState.timer` and clears it through `resetReconnectionTimer()`; `cleanUp()` does not invoke that method. | Concurrent network/media callbacks must not launch duplicate media negotiations or meeting joins, and lifecycle cleanup must not be documented as settling an independent ICE wait that current code leaves intact. | `src/reconnection-manager/index.ts`, `src/config.ts` | `test/unit/spec/reconnection-manager/index.js` | characterize `cleanUp()` while an ICE wait is pending | PRESENT |
200
+ | `RECONNECTION-MANAGER-R-005` | When recovery starts while sharing (`meeting.shareStatus` is `LOCAL_SHARE_ACTIVE`), current code calls `stopLocalShareStream` with `MEDIA_RECONNECTION` before anything else, and again with `MEETING_REJOIN` after a successful rejoin; each call unpublishes the share video and audio streams and emits `meeting:stoppedSharingLocal` with the reason. It does not republish or restore sharing. | The two reasons are distinct `SHARE_STOPPED_REASON` values beside `SELF_STOPPED` and `TRACK_ENDED`, so an application can tell a recovery stop from a user stop and decide whether to share again; nothing in this module restarts it. | `src/reconnection-manager/index.ts`, `src/constants.ts` | `test/unit/spec/reconnection-manager/index.js` | Possible product defect: user intent may be to restore prior sharing after recovery, but no restoration path exists. | PRESENT |
201
+ | `RECONNECTION-MANAGER-R-006` | `reconnect()` sets IN_PROGRESS, emits `MEETING_RECONNECTION_STARTING`, submits `client.media.reconnecting` only when `networkRetry` is false, and awaits `webex.meetings.startReachability('reconnection')`, logging and ignoring its failure. | The code comments: START metrics are logged only on the initial reconnect, and a reachability failure must not stop the reconnection attempt. | `src/reconnection-manager/index.ts` | `test/unit/spec/reconnection-manager/index.js` | The single start metric across a retry loop is not asserted | PRESENT |
202
+ | `RECONNECTION-MANAGER-R-007` | With `networkDisconnect`, recovery reconnects the Mercury websocket first: it disconnects when `mercury.connected`, then connects; either failure sets FAILURE and ends the run. It then awaits `syncMeetings({keepOnlyLocusMeetings: false})`; a sync failure becomes `NeedsRetryError`, which resets the status and reruns `reconnect({networkDisconnect: true, networkRetry: true}, completionCallback)`. | The code comments: if the socket cannot disconnect the SDK is in too bad a state to reconnect, and meeting data must be updated from the server before media is renewed. | `src/reconnection-manager/index.ts` | `test/unit/spec/reconnection-manager/index.js` (sync call only) | The websocket and retry branches have no unit case; the retry has no bound | PRESENT |
203
+ | `RECONNECTION-MANAGER-R-008` | After the sync, recovery throws `Unable to rejoin a meeting already ended or inactive.` when the meeting is no longer in the collection. When `meeting.state` is LEFT it throws `Unable to rejoin a call in LEFT state.` for type CALL and otherwise `NeedsRejoinError`. A non-retry failure submits `client.call.aborted` (errorCode 2008), then rejoins when the error is `NeedsRejoinError` and `autoRejoin` is on, and otherwise fails. | The code comments: the meeting may have been deleted for inactivity or ended remotely; a LEFT member no longer reconnects media; the aborted event is categorized as expected because a rejoin follows. | `src/reconnection-manager/index.ts`, `src/config.ts` | `test/unit/spec/reconnection-manager/index.js` (client.call.aborted) | The ended, LEFT-call, and rejoin branches have no unit case | PRESENT |
204
+ | `RECONNECTION-MANAGER-R-009` | `reconnectMedia()` calls `meeting.roap.doTurnDiscovery(meeting, true, true)`, passes one ICE server built from `turnServerInfo` (`username` and `password` default to `''`) only when its `urls` list is non-empty, awaits `webrtcMediaConnection.reconnect(iceServers)`, and, for a multistream meeting, calls `commit()` on every media request manager. | The code comments: TURN discovery is redone ignoring reachability because the TURN server might change, and media requests must be resent after the connection is renewed. | `src/reconnection-manager/index.ts` | `test/unit/spec/reconnection-manager/index.js` (TURN TLS, empty urls, transcoded and multistream re-request) | none | PRESENT |
205
+ | `RECONNECTION-MANAGER-R-010` | `rejoinMeeting(wasSharing)` awaits `meeting.join({rejoin: true})`. On a join error it increments `rejoinAttempts`; while the count is at most `maxRejoinAttempts` it calls itself again, otherwise it sends `MEETING_MAX_REJOIN_FAILURE`, sets FAILURE, and rethrows. It then awaits `reconnectMedia()` and rethrows a media error. | The config comment: `maxRejoinAttempts` is the number of times to attempt a rejoin during reconnect. | `src/reconnection-manager/index.ts`, `src/config.ts`, `src/metrics/constants.ts` | None found | The unawaited retry is an Evidence-register observation | PRESENT |
206
+ | `RECONNECTION-MANAGER-R-011` | On the ordinary path `reconnect()` awaits the completion callback, emits `MEETING_RECONNECTION_SUCCESS`, and submits `client.media.recovered` `{recoveredBy: 'new'}`. On a terminal error it emits `MEETING_RECONNECTION_FAILURE` with `{error: ReconnectionError}`, sends `MEETING_RECONNECT_FAILURE` with the correlation id, the last segment of `locusUrl`, the message, and the stack, and throws `ReconnectionError('Reconnection failure event', error)`. | The code comment: the completion callback finalizes the reconnection, and Meeting uses it to wait for the remote SDP answer and the connected media connection before success is reported. | `src/reconnection-manager/index.ts`, `src/meeting/index.ts` | `test/unit/spec/reconnection-manager/index.js` (success and failure metrics and events) | none | PRESENT |
207
+
208
+ ## Design overview
209
+
210
+ The manager serializes one recovery run. It owns retry counters/timers and `stopLocalShareStream()`;
211
+ its media operation reaches into the Meeting's ROAP and media-connection dependencies rather than
212
+ calling a `Meeting.reconnectMedia()` method. After the optional websocket reconnect and the meetings
213
+ sync, it renews media with its own `reconnectMedia()` operation, unless Locus shows the member as
214
+ LEFT, in which case it calls `Meeting.join()` to rejoin and then renews media. A media failure
215
+ does not escalate to a rejoin; it ends the run.
216
+
217
+ The module holds a reference to the owning `Meeting` and its `webex`. Its own TODO comments note that
218
+ a saved meeting instance can be stale when the meeting ends remotely, and that the circular
219
+ dependency between `Meeting` and the manager could move to the meetings collection. Two
220
+ module-private errors steer the run: `NeedsRetryError` restarts it after a failed sync, and
221
+ `NeedsRejoinError` carries `wasSharing` into the rejoin.
222
+
223
+ ## Data flow and sequence coverage
224
+
225
+ Sequence coverage: the call style is in-process async method calls from the owning Meeting; the
226
+ manager awaits Meeting, webex.meetings, and Mercury plugin promises and emits Meeting-scoped events.
227
+
228
+ | Operation group | Entry and outcome | Diagram or evidence | Failure and recovery coverage |
229
+ | --------------- | ----------------- | ------------------- | ----------------------------- |
230
+ | ICE wait | Meeting's Disconnected state calls `waitForIceReconnect`; Connected calls `iceReconnected`; a failed connection calls `resetReconnectionTimer` and `reconnect` | Diagram 1 | Timeout rejects and Meeting treats it as a connection failure |
231
+ | Recovery run | `reconnect` guards, signals start, runs `executeReconnection`, then the completion callback; outcomes are a disabled or duplicate start, ordinary success, rejoin success without the success event, or terminal failure | Diagram 2 | Not-started guard, sync retry, terminal failure, finally reset |
232
+ | Rejoin | `NeedsRejoinError` with `autoRejoin` leads to `rejoinMeeting` | Diagram 3 | Bounded join retries, max-attempt failure, media failure after rejoin |
233
+
234
+ ```mermaid
235
+ flowchart LR
236
+ Network[network / media failure] --> Manager[index.ts]
237
+ Manager --> Ws[Mercury websocket reconnect when networkDisconnect]
238
+ Manager --> Sync[webex.meetings.syncMeetings]
239
+ Manager --> Media[manager-owned reconnectMedia using Meeting ROAP/media properties]
240
+ Manager --> Meeting[Meeting join and stream-unpublish dependencies]
241
+ Manager --> Rejoin[Meeting.join rejoin path]
242
+ Manager --> Timer[bounded ICE wait timer]
243
+ Manager --> Events[start, ordinary-path success, terminal failure]
244
+ Manager --> ShareStop[stopLocalShareStream with recovery reason]
245
+ ```
246
+
247
+ Diagram 1 — the ICE wait:
248
+
249
+ ```mermaid
250
+ sequenceDiagram
251
+ participant H as Meeting connection-state listener
252
+ participant R as ReconnectionManager
253
+ H->>R: waitForIceReconnect() on Disconnected
254
+ R->>R: iceState.disconnected = true, start iceReconnectionTimeout timer
255
+ alt Connected before the timeout
256
+ H->>R: iceReconnected()
257
+ R->>R: resetReconnectionTimer(): resolve, clear timer
258
+ R-->>H: promise resolves
259
+ else timeout
260
+ R-->>H: promise rejects
261
+ H->>R: resetReconnectionTimer() when media had connected once
262
+ H->>R: reconnect({networkDisconnect: true})
263
+ end
264
+ ```
265
+
266
+ Diagram 2 — reconnection and rejoin primary sequence:
267
+
268
+ ```mermaid
269
+ sequenceDiagram
270
+ participant N as Network/media callback
271
+ participant R as ReconnectionManager
272
+ participant M as Meeting
273
+ participant W as webex.meetings and Mercury
274
+ N-->>R: reconnect trigger
275
+ alt reconnection is disabled or another reconnect is already IN_PROGRESS
276
+ R--xN: ReconnectionNotStartedError without resetting status
277
+ else new recovery run
278
+ R->>R: set IN_PROGRESS, emit MEETING_RECONNECTION_STARTING
279
+ R->>W: startReachability('reconnection'), errors ignored
280
+ R->>M: stopLocalShareStream(MEDIA_RECONNECTION) when wasSharing
281
+ opt networkDisconnect
282
+ R->>W: mercury disconnect when connected, then connect
283
+ end
284
+ R->>W: syncMeetings({keepOnlyLocusMeetings: false})
285
+ end
286
+ alt sync fails
287
+ R->>R: NeedsRetryError: reset status, reconnect({networkDisconnect: true, networkRetry: true})
288
+ else ordinary media reconnection succeeds after a new start
289
+ R->>R: reconnectMedia() using Meeting ROAP/media dependencies
290
+ R->>R: run completion callback when supplied
291
+ R-->>N: MEETING_RECONNECTION_SUCCESS and resolved promise
292
+ else NeedsRejoinError and auto-rejoin is enabled
293
+ R->>W: client.call.aborted (errorCode 2008)
294
+ R->>M: join({rejoin:true})
295
+ R->>R: stopLocalShareStream(MEETING_REJOIN) when wasSharing
296
+ R->>R: reconnectMedia()
297
+ R-->>N: resolved promise without MEETING_RECONNECTION_SUCCESS
298
+ else terminal recovery error
299
+ R--xN: MEETING_RECONNECTION_FAILURE and ReconnectionError
300
+ end
301
+ R->>R: finally resets status and rejoin attempts
302
+ ```
303
+
304
+ Diagram 3 — rejoin retries:
305
+
306
+ ```mermaid
307
+ sequenceDiagram
308
+ participant R as ReconnectionManager
309
+ participant M as Meeting
310
+ R->>M: join({rejoin: true})
311
+ alt join resolves
312
+ R->>R: stopLocalShareStream(MEETING_REJOIN) when wasSharing
313
+ else join rejects and rejoinAttempts + 1 <= maxRejoinAttempts
314
+ R-)R: rejoinMeeting() again, not awaited, wasSharing dropped
315
+ else attempts exhausted
316
+ R->>R: MEETING_MAX_REJOIN_FAILURE metric, status FAILURE
317
+ R--xR: rethrow the join error
318
+ end
319
+ R->>M: reconnectMedia(): roap.doTurnDiscovery, webrtcMediaConnection.reconnect
320
+ alt media fails
321
+ R--xR: rethrow the media error
322
+ end
323
+ ```
324
+
325
+ ## Class and component relationships
326
+
327
+ ```mermaid
328
+ classDiagram
329
+ class Network["Meeting connection-state listener"]
330
+ class Manager["ReconnectionManager"]
331
+ class Meeting
332
+ class Media["reconnectMedia via Meeting roap and mediaProperties"]
333
+ class Rejoin["rejoinMeeting via Meeting.join"]
334
+ class Timer["iceState timer"]
335
+ class Events["TriggerProxy and metrics"]
336
+ class ShareStop["stopLocalShareStream"]
337
+ class NeedsRetryError
338
+ class NeedsRejoinError
339
+ Network --> Manager
340
+ Meeting *-- Manager : creates and owns
341
+ Manager --> Meeting
342
+ Manager --> Media
343
+ Manager --> Rejoin
344
+ Manager --> Timer
345
+ Manager --> Events
346
+ Manager --> ShareStop
347
+ Manager ..> NeedsRetryError : sync failed
348
+ Manager ..> NeedsRejoinError : member LEFT
349
+ ```
350
+
351
+ The arrows identify ownership and delegation inside `src/reconnection-manager/`; files that only
352
+ declare types or constants are not presented as transports.
353
+
354
+ ## Use cases and flows
355
+
356
+ | Use case | Actor or caller | Primary steps and outcome | Failure or boundary behavior | Evidence |
357
+ | -------- | --------------- | ------------------------- | ---------------------------- | -------- |
358
+ | `UC-1` | Meeting `reconnect()` | Reject recovery when reconnection is disabled or another `reconnect()` already owns the `IN_PROGRESS` state. | `ReconnectionNotStartedError`; Meeting logs it and resolves | `src/reconnection-manager/index.ts`, `src/meeting/index.ts`, `test/unit/spec/reconnection-manager/index.js` |
359
+ | `UC-2` | Meeting connection-state listener | Wait for bounded ICE reconnection, clearing the timer and resolver when ICE returns or the wait resets. | Timeout rejects, and Meeting then calls `connectionFailed`, which reconnects only when media had connected once | `src/reconnection-manager/index.ts`, `src/meeting/index.ts`, `test/unit/spec/reconnection-manager/index.js`, `test/unit/spec/meeting/index.js` |
360
+ | `UC-3` | Meeting `reconnect()` | Reconnect the websocket when asked, sync meetings, and reconnect media; escalate to meeting rejoin only when Locus shows the member LEFT. Emit success only after the ordinary recovery/completion-callback path; a successful automatic rejoin resolves without that event, while terminal errors emit failure. | A failed sync reruns the whole recovery; an ended meeting or a LEFT call fails | `src/reconnection-manager/index.ts`, `test/unit/spec/reconnection-manager/index.js` |
361
+ | `UC-4` | Recovery run | When recovery began while sharing, stop the local share stream with the matching recovery reason; current code does not restore or republish it. | A rejoin path stops twice, once per reason | `src/reconnection-manager/index.ts`, `src/constants.ts` |
362
+
363
+ ## Client state model
364
+
365
+ The manager stores reconnection `status`, `rejoinAttempts`, the configured attempt limit
366
+ `maxRejoinAttempts`, `autoRejoinEnabled`, and `iceState` (`disconnected`, resolver, timer, timeout
367
+ duration). Sharing is read from the owning Meeting when recovery starts; there is no stored reconnect
368
+ promise or last-recovery-mode field.
369
+
370
+ | State or slice | Owner | Initial state | Transition triggers | Reset or persistence boundary |
371
+ | -------------- | ----- | ------------- | ------------------- | ----------------------------- |
372
+ | `status` | ReconnectionManager | `''` | `reconnect()` sets IN_PROGRESS; websocket, media, or max-rejoin failure sets FAILURE; `NeedsRetryError` sets `''` | `reset()` in the constructor, in the `reconnect()` `finally`, and through `cleanUp()` |
373
+ | `rejoinAttempts` | ReconnectionManager | 0 | Each failed rejoin adds one | `reset()` |
374
+ | `iceState.disconnected`, `resolve`, `timer` | ReconnectionManager | false, a no-op, none | `waitForIceReconnect()`, `iceReconnected()`, the timeout | `resetReconnectionTimer()`; not touched by `reset()` or `cleanUp()` |
375
+ | `maxRejoinAttempts`, `autoRejoinEnabled`, `iceState.timeoutDuration` | ReconnectionManager, from `meeting.config.reconnection` | 3, true, 10000 by default | None | Read once in the constructor |
376
+
377
+ ## Business rules and invariants
378
+
379
+ Only one recovery run is active at a time, and rejoins are bounded; a failed meetings sync is retried
380
+ without a bound. `reconnect()` success/failure resets reconnection status and attempts; the
381
+ independent ICE timer and resolver are cleared only through `iceReconnected()`/`resetReconnectionTimer()`,
382
+ not by `cleanUp()`. A previously active share is stopped with a recovery-specific reason and is not
383
+ restored by this module.
384
+
385
+ | ID | Invariant | WHY | Enforcement source | Test evidence |
386
+ | -- | --------- | --- | ------------------ | ------------- |
387
+ | `INV-001` | A run starts only when `config.reconnection.enabled` is true and `status` is `''`. | Concurrent network and media callbacks must not start duplicate negotiations or joins (RECONNECTION-MANAGER-R-004). | `src/reconnection-manager/index.ts` | `test/unit/spec/reconnection-manager/index.js` |
388
+ | `INV-002` | Every run that passed the guard ends with `status` `''` and `rejoinAttempts` 0. | The `finally` block resets state so the next trigger can start (RECONNECTION-MANAGER-R-003). | `src/reconnection-manager/index.ts` | `test/unit/spec/reconnection-manager/index.js` |
389
+ | `INV-003` | A member in LEFT state is never media-reconnected without a rejoin, and a LEFT call is never rejoined. | The code comment: when the meeting state is LEFT, media is no longer reconnected (RECONNECTION-MANAGER-R-008). | `src/reconnection-manager/index.ts` | None found |
390
+ | `INV-004` | Join is retried at most `maxRejoinAttempts` times after the first failure. | The config comment names it the number of rejoin attempts during reconnect (RECONNECTION-MANAGER-R-010). | `src/reconnection-manager/index.ts`, `src/config.ts` | None found |
391
+
392
+ ## Concurrency and reactive flow
393
+
394
+ - Execution model: promise chains on the JavaScript event loop; the ICE wait is one `setTimeout`.
395
+ - Ordering guarantees: `status === IN_PROGRESS` is the duplicate-run guard for the duration of
396
+ `reconnect()`. Within a run, the share stop, websocket reconnect, sync, checks, media reconnect,
397
+ and completion callback are awaited in that order. The outer `finally` resets status and
398
+ `rejoinAttempts`; the independent ICE-wait timer is cleared by
399
+ `iceReconnected()`/`resetReconnectionTimer()`. A share active at recovery start is stopped with the
400
+ concrete recovery reason and is not republished by a later completion.
401
+ - Idempotency and retry: a sync failure reruns `reconnect()` recursively with `networkRetry`, after
402
+ resetting the status so the guard passes; the inner run's `finally` and the outer one both reset.
403
+ A failed rejoin retries without `await` (Evidence register).
404
+ - Shared-state protection: the single `status` field; no lock.
405
+ - Blocking restrictions: none; every external step is a promise.
406
+
407
+ ## State machine
408
+
409
+ ```mermaid
410
+ stateDiagram-v2
411
+ state "'' (default)" as DEFAULT
412
+ [*] --> DEFAULT
413
+ DEFAULT --> IN_PROGRESS: reconnect()
414
+ IN_PROGRESS --> DEFAULT: recovery succeeds / reset()
415
+ IN_PROGRESS --> DEFAULT: meetings sync failed, NeedsRetryError
416
+ IN_PROGRESS --> FAILURE: websocket, media, or max-rejoin failure
417
+ FAILURE --> DEFAULT: reset() in finally
418
+ ```
419
+
420
+ The diagram uses the concrete `''`, `IN_PROGRESS`, and `FAILURE` values declared for reconnection
421
+ status. A run that fails for another reason, such as an ended meeting, goes from IN_PROGRESS
422
+ straight back to the default through `finally`. A `reconnect()` call is rejected without a transition
423
+ in any state other than the default.
424
+
425
+ ## Caller-visible failure modes
426
+
427
+ | Condition | Signal | Caller recovery |
428
+ |---|---|---|
429
+ | Reconnection is disabled or status is already `IN_PROGRESS` | `reconnect()` throws `ReconnectionNotStartedError`. | Wait for the active run to settle or enable recovery before a new attempt. |
430
+ | Media/WebSocket/rejoin recovery reaches a terminal failure | The manager emits `MEETING_RECONNECTION_FAILURE`, rejects with `ReconnectionError`, and `finally` resets status/attempts; inner `FAILURE` assignments are not persistent terminal state. | Handle the failure event/rejection and inspect current meeting state before another run. |
431
+ | `NeedsRejoinError` is handled by a successful automatic rejoin | `reconnect()` resolves after `rejoinMeeting()` and returns before `MEETING_RECONNECTION_SUCCESS` or the recovered metric is emitted. | Treat the resolved operation/current meeting state as the outcome; do not wait for a success event on this path. |
432
+ | Recovery began while local sharing was active | Current code unpublishes/stops the local share with `MEDIA_RECONNECTION` and, after a rejoin, again with `MEETING_REJOIN`; it does not restore or republish it. | Treat restoration as a separate product decision/operation. |
433
+ | `cleanUp()` runs while `waitForIceReconnect()` is pending | Status and rejoin attempts reset, but the ICE timer and resolver remain active because `cleanUp()` does not call `resetReconnectionTimer()`. | Explicitly invoke the ICE reset path when the owner intends to settle that pending wait. |
434
+ | The meeting left the collection, or a CALL is in LEFT state | `ReconnectionError` wrapping `Unable to rejoin a meeting already ended or inactive.` or `Unable to rejoin a call in LEFT state.` | Do not retry; the meeting is gone. |
435
+ | `autoRejoin` is false and the member is LEFT | `ReconnectionError` wrapping the `NeedsRejoinError` | Rejoin explicitly with `meeting.join()`. |
436
+ | Rejoin fails more than `maxRejoinAttempts` times | `MEETING_MAX_REJOIN_FAILURE` metric and `ReconnectionError` wrapping the join error | Join again explicitly. |
437
+ | `waitForIceReconnect()` times out | Its promise rejects with `ice reconnection did not occur in <timeout>ms` | Meeting treats it as a failed connection. |
438
+
439
+ Evidence: `src/reconnection-manager/index.ts`, `src/meeting/index.ts`, and
440
+ `test/unit/spec/reconnection-manager/index.js`.
441
+
442
+ ## Pitfalls and constraints
443
+
444
+ - Network and media events can request recovery concurrently. Starting a second timer/promise
445
+ produces duplicate joins and stale completion callbacks.
446
+ - `cleanUp()` is not a full ICE-wait teardown: it resets status/attempts only. An owner that needs to
447
+ settle and clear `iceState` must call `resetReconnectionTimer()` explicitly.
448
+ - Public behavior is reachable through the parent `Meeting` (`meeting.reconnectionManager` and
449
+ `meeting.reconnect()`) even though the class is not exported from `src/index.ts`.
450
+ - A failed meetings sync loops back into `reconnect()` with no attempt limit, so a persistently
451
+ failing sync keeps the run going (Evidence register).
452
+ - A failed rejoin schedules the next attempt without awaiting it and then continues to
453
+ `reconnectMedia()`, so the outer promise can settle before the retries do, and the retries do not
454
+ carry `wasSharing` (Evidence register).
455
+ - Reconnection is off by default (`enabled: false` in `src/config.ts`); an application must enable it.
456
+
457
+ ## Key design trade-off
458
+
459
+ Escalating recovery favors continuity over immediate failure, with more lifecycle complexity; the
460
+ ICE wait and the rejoin count are bounded, but the sync retry is not.
461
+
462
+ | Chosen trade-off | Preserved invariant or benefit | Cost or limitation | Decision evidence |
463
+ | ---------------- | ------------------------------ | ------------------ | ----------------- |
464
+ | Wait for ICE, then renew media in place, and rejoin only for a LEFT member | The call survives a network change without a new join when Locus still has the member | Two retry mechanisms with different bounds, and a manager that holds a possibly stale meeting instance (its TODO comments) | `src/reconnection-manager/index.ts`, `src/config.ts` |
465
+
466
+ ## Verification
467
+
468
+ Use the current mirrored suites: `test/unit/spec/reconnection-manager/index.js`, plus the Meeting
469
+ `#reconnect` and Disconnected-state cases in `test/unit/spec/meeting/index.js`. Characterize the
470
+ reconnection-manager-specific use cases above and each listed failure condition; add cleanup or
471
+ transition cases only for resources and state this module actually owns.
472
+
473
+ | Behavior / Requirement | Existing test evidence | Gap |
474
+ |---|---|---|
475
+ | `RECONNECTION-MANAGER-R-001` | `test/unit/spec/reconnection-manager/index.js` | cover state reset after each terminal path; only `cleanUp()` keeping the meeting reference is asserted |
476
+ | `RECONNECTION-MANAGER-R-002` | `test/unit/spec/reconnection-manager/index.js`, `test/unit/spec/meeting/index.js` | ICE event/timeout races at the final attempt boundary need explicit coverage |
477
+ | `RECONNECTION-MANAGER-R-003` | `test/unit/spec/reconnection-manager/index.js` | assert successful auto-rejoin resolves without `MEETING_RECONNECTION_SUCCESS`, both recovery reasons stop an active share, and no completion path republishes it |
478
+ | `RECONNECTION-MANAGER-R-004` | `test/unit/spec/reconnection-manager/index.js` | concurrent and disabled starts are covered; verify exhausted rejoin retries and `cleanUp()` during an ICE wait |
479
+ | `RECONNECTION-MANAGER-R-005` | `test/unit/spec/reconnection-manager/index.js` | characterize both `stopLocalShareStream` recovery reasons; restoration remains a product-decision gap |
480
+ | `RECONNECTION-MANAGER-R-006` | `test/unit/spec/reconnection-manager/index.js` | assert the start metric is not repeated on a network retry |
481
+ | `RECONNECTION-MANAGER-R-007` | `test/unit/spec/reconnection-manager/index.js` | add websocket reconnect, websocket failure, and sync-retry cases |
482
+ | `RECONNECTION-MANAGER-R-008` | `test/unit/spec/reconnection-manager/index.js` | add ended-meeting, LEFT-call, LEFT-meeting rejoin, and autoRejoin-off cases |
483
+ | `RECONNECTION-MANAGER-R-009` | `test/unit/spec/reconnection-manager/index.js` | none |
484
+ | `RECONNECTION-MANAGER-R-010` | None found | add join retry, max-attempt failure, and media-after-rejoin failure cases |
485
+ | `RECONNECTION-MANAGER-R-011` | `test/unit/spec/reconnection-manager/index.js` | assert the completion callback runs before the success event |