@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,548 @@
1
+ ---
2
+ type: Module Spec
3
+ title: 'Reachability specification'
4
+ description: Responsibilities, boundaries, discovery and probe flows, timers, stored results, report formats, invariants, and verification for the reachability module of plugin-meetings.
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
+ # Reachability
17
+
18
+ This source-local document at `src/reachability/docs/README.md` owns the stable specification for
19
+ **the reachability module** of `@webex/plugin-meetings`: the `Reachability` controller that
20
+ `webex.meetings.reachability` exposes. It fetches the media cluster list from the discovery service
21
+ (Orpheus, API `calliopeDiscovery`), probes each cluster over UDP, TCP, and TLS (`xtls`) with browser
22
+ peer connections, detects a symmetric NAT, stores the results and the join cookie in bounded storage,
23
+ and formats them for join requests, ROAP messages, and metrics. Ground every claim in package evidence
24
+ and link to the [package architecture](../../../docs/architecture.md) instead of repeating broader
25
+ facts. No service specification exists because this package is a library.
26
+
27
+ Related context — start here: root [package agent instructions](../../../AGENTS.md) · router
28
+ [documentation index](../../../docs/index.md) · system [package architecture](../../../docs/architecture.md).
29
+ This is the canonical source-local spec for `src/reachability/`.
30
+
31
+ Repo architecture: [package architecture](../../../docs/architecture.md) · Registry:
32
+ [documentation index](../../../docs/index.md) · Coverage state and contracts baseline: `.sdd/manifest.json`.
33
+
34
+ ## Metadata
35
+
36
+ | Field | Value |
37
+ |---|---|
38
+ | Owner | @webex/web-client, @webex/web-sdk |
39
+ | Source path | `src/reachability` |
40
+ | Resource kind | module |
41
+ | Status | Draft |
42
+ | Last verified | 2026-11-16 at `0b8c34db7f` |
43
+ | Module id | `plugin-meetings/reachability` |
44
+ | Parent spec | — |
45
+ | Doc kind | Module spec |
46
+ | Coverage score | Pending coverage assessment |
47
+ | Validation status | not-run |
48
+
49
+ ## Applicability
50
+
51
+ | Condition ID | Status | Evidence or reason | Owned section |
52
+ | ------------ | ------ | ------------------ | ------------- |
53
+ | `module.has_tiers` | N/A | No tier policy exists in `package.json` or `.sdd/manifest.json` | Tier |
54
+ | `module.has_ui` | N/A | `src/reachability/index.ts` renders nothing | UI use-case flow |
55
+ | `module.crosses_service_boundaries` | Applicable | `src/reachability/request.ts` calls the discovery service; `src/reachability/reachabilityPeerConnection.ts` contacts media cluster STUN and TURN servers | Cross-boundary use-case flow |
56
+ | `module.holds_client_state` | Applicable | Per-run cluster objects, counters, timers, NAT type, and discovery options on the instance in `src/reachability/index.ts` | Client state model |
57
+ | `module.enforces_domain_rules` | Applicable | Protocol selection, video-mesh exclusions, candidate classification, and query rules in `src/reachability/index.ts` and `src/reachability/reachabilityPeerConnection.ts` | Business rules and invariants |
58
+ | `module.is_concurrent_async` | Applicable | Parallel probes, three timers, and event-driven result updates in `src/reachability/index.ts` and `src/reachability/clusterReachability.ts` | Concurrency and reactive flow |
59
+ | `module.owns_persistence` | Applicable | `src/reachability/index.ts` writes the results and the join cookie to bounded storage under the namespace and keys in `src/constants.ts` | Data, schema, and migration discipline |
60
+ | `module.stateful_transitions` | N/A | The run lifecycle is covered by the timers under Concurrency and reactive flow in `src/reachability/index.ts` | State machine |
61
+ | `module.exposes_wire_protocol` | Applicable | The discovery request and response, the backend result format, and the ROAP and join payloads in `src/reachability/request.ts` and `src/reachability/reachability.types.ts` | Protocol and wire format |
62
+ | `module.ui_multi_screen` | N/A | No UI | UI flow |
63
+ | `module.large_data_model` | N/A | The result types in `src/reachability/reachability.types.ts` are listed under Protocol and wire format | Data model |
64
+ | `module.returns_caller_errors` | Applicable | The gather rejects when disabled, cluster discovery rejects after its retry, and the STUN converters in `src/reachability/util.ts` throw | Caller-visible failure modes |
65
+ | `module.module_specific_conventions` | N/A | Repository-wide rules in `AGENTS.md` apply unchanged | Module-specific rules |
66
+ | `module.published_package` | N/A | `src/index.ts` does not re-export the module | Export stability |
67
+ | `module.embedded_in_host` | N/A | No mount or theme contract | Host integration and theming |
68
+ | `module.has_design_tradeoff` | Applicable | Bounded waiting with results that keep arriving after the gather promise resolves, in `src/reachability/index.ts` | Key design trade-off |
69
+ | `module.has_submodules` | N/A | The module directory has no child module | Sub-modules |
70
+
71
+ ## Evidence register
72
+
73
+ Requirements cite current implementation and mirrored unit-test paths. Current code wins over retained
74
+ prose when they conflict; commit and PR history are excluded by repository-owner decision. Missing
75
+ test evidence is stated as a gap rather than inferred.
76
+
77
+ | Evidence | What it establishes |
78
+ | -------- | ------------------- |
79
+ | `src/reachability/index.ts` | `Reachability` (extends `EventsScope`): discovery with one retry, the run (`performReachabilityChecks`), the 1 s video-mesh, 3 s public, and 15 s overall timers, fallback, stop, queries, report formatting, the completion metric, and the three emitted events |
80
+ | `src/reachability/clusterReachability.ts` | `ClusterReachability`: one `ReachabilityPeerConnection` per cluster, or one per UDP URL plus one for TCP and TLS when `enablePerUdpUrlReachability` is set; relays `resultReady`, `clientMediaIpsUpdated`, and `natTypeUpdated`; collects `reachedSubnets` |
81
+ | `src/reachability/reachabilityPeerConnection.ts` | `ReachabilityPeerConnection`: builds the ICE server list, gathers candidates, classifies `srflx` as UDP and `relay` as TCP or, on port 443, TLS, records the first latency, detects a symmetric NAT, and closes the peer connection when gathering completes or on abort |
82
+ | `src/reachability/request.ts` | `ReachabilityRequest.getClusters` (`POST` to `calliopeDiscovery` `clusters`) and the uncalled `remoteSDPForClusters`; `ClusterNode` and `ClusterList` |
83
+ | `src/reachability/util.ts` | `resolveReachabilityProtocols`, `isReachabilityEnabled`, `convertStunUrlToTurn`, `convertStunUrlToTurnTls` |
84
+ | `src/reachability/reachability.types.ts` | Protocol, result, metrics, backend, report, and media-preference types; `NatType` and `ReachabilityPeerConnectionEvents` |
85
+ | `src/constants.ts`, `src/config.ts` | Storage namespace `Reachability` with keys `reachability.result` and `reachability.joinCookie`; defaults `enableReachabilityChecks: true`, `reachabilityGetClusterTimeout: 5000`, `enablePerUdpUrlReachability: false` |
86
+ | `src/meetings/index.ts` | `new Reachability(this.webex)` in the constructor; `getReachability()`; `startReachability(trigger = 'client')`; registration calls `startReachability('registration')` and logs a failure as a warning |
87
+ | `src/meeting/index.ts`, `src/meeting/util.ts`, `src/roap/request.ts`, `src/roap/turnDiscovery.ts` | The in-package callers of `getClientMediaPreferences`, `getReachabilityReportToAttachToRoap`, `stopReachability`, `getReachabilityMetrics`, `isSubnetReachable`, `isAnyPublicClusterReachable`, `isWebexMediaBackendUnreachable`, and `isAnyClusterReachableViaProtocol` |
88
+ | `test/unit/spec/reachability/index.ts`, `test/unit/spec/reachability/clusterReachability.ts`, `test/unit/spec/reachability/request.js`, `test/unit/spec/reachability/util.ts` | The mirrored suites |
89
+ | Observation, no stated WHY | `gatherReachability(trigger)` always asks discovery with trigger `startup`; the caller's `trigger` only reaches the completion metric (`src/reachability/index.ts`, `test/unit/spec/reachability/index.ts`) |
90
+ | Observation, no stated WHY | `isAnyPublicClusterReachable` counts only UDP and TCP results; a public cluster reachable only over `xtls` yields `false` (`src/reachability/index.ts`, `test/unit/spec/reachability/index.ts`) |
91
+ | Observation, no stated WHY | The client sets no limit on fallback rounds; the loop ends only when a run reaches the discovery minimum, the minimum is `0` or absent, or the list is empty (`src/reachability/index.ts`, `test/unit/spec/reachability/index.ts`) |
92
+
93
+ ## Purpose and boundary
94
+
95
+ - Responsibility: Discovers media clusters, probes protocol reachability with peer connections,
96
+ determines NAT characteristics, and reports results.
97
+ - In scope: cluster discovery and the join cookie; UDP, TCP, and `xtls` probing; the timers, fallback,
98
+ and stop of a run; stored results; queries over them; the formats sent with joins, ROAP messages,
99
+ discovery fallbacks, and metrics; the `reachability:*` events.
100
+ - Out of scope: when reachability runs (`Meetings.register` and `startReachability`); media
101
+ connections and TURN discovery (the media and roap modules); IP version detection
102
+ (`webex.internal.device.ipNetworkDetector`); the behavioral metric transport (the metrics module);
103
+ what the discovery service decides.
104
+ - Consumers: `src/meetings/index.ts` owns the instance; `src/meeting/index.ts`, `src/meeting/util.ts`,
105
+ `src/roap/request.ts`, and `src/roap/turnDiscovery.ts` read it through `webex.meetings.reachability`;
106
+ applications can reach it as `webex.meetings.getReachability()` and start it with
107
+ `webex.meetings.startReachability()`.
108
+
109
+ ## Structure and key files
110
+
111
+ `src/reachability` contains 6 direct source/reference file(s) and has 4 mirrored unit-test file(s).
112
+ Stack: TypeScript/JavaScript in the Node 22.14 Yarn workspace; Webex core/plugin abstractions and Mocha/Sinon/`@webex/test-helper-chai` tests. Build target: `yarn workspace @webex/plugin-meetings build:src`.
113
+
114
+ ```text
115
+ src/reachability/
116
+ ├── clusterReachability.ts — clusterReachability implementation responsibility (one cluster's probes)
117
+ ├── index.ts — module facade/controller or primary exports (Reachability)
118
+ ├── reachability.types.ts — module type declarations
119
+ ├── reachabilityPeerConnection.ts — reachabilityPeerConnection implementation responsibility (one RTCPeerConnection)
120
+ ├── request.ts — HTTP request boundary (cluster discovery)
121
+ ├── util.ts — normalization/helper functions (protocol config, STUN to TURN URLs)
122
+ └── docs/README.md — canonical module specification
123
+ ```
124
+
125
+ | File | Holds |
126
+ |---|---|
127
+ | `src/reachability/clusterReachability.ts` | clusterReachability implementation responsibility: `ClusterReachability`, its `Events`, and the event data types |
128
+ | `src/reachability/index.ts` | module facade/controller or primary exports: default export `Reachability` |
129
+ | `src/reachability/reachability.types.ts` | module type declarations: protocol, result, metrics, backend, report, and media-preference types |
130
+ | `src/reachability/reachabilityPeerConnection.ts` | reachabilityPeerConnection implementation responsibility: `ReachabilityPeerConnection`, candidate handling, and NAT detection |
131
+ | `src/reachability/request.ts` | HTTP request boundary: `ReachabilityRequest` and the cluster list types |
132
+ | `src/reachability/util.ts` | normalization/helper functions: protocol resolution and STUN URL conversion |
133
+ | `test/unit/spec/reachability/clusterReachability.ts` and 3 sibling test file(s) | mirrored characterization/unit coverage: `index.ts`, `request.js`, and `util.ts` |
134
+
135
+ ## Public surface
136
+
137
+ | Contract ID | Type | Surface | Purpose | Compatibility / deprecation | Schema / detail link | Root index |
138
+ |---|---|---|---|---|---|---|
139
+ | `reachability-service` | SDK / remote | `Reachability.getClusters()` and `gatherReachability()` | Fetch cluster discovery data, cache the join cookie, and start a configured reachability run. | Disabled reachability rejects before the catch boundary; missing WebRTC capability or caught discovery/probe failure returns `{}`; a started successful run resolves its defer promise with `undefined` after storing results. | `src/reachability/index.ts`, `src/reachability/request.ts` | [package architecture](../../../docs/architecture.md) |
140
+ | `reachability-service` | SDK / async | `ClusterReachability.getResult()`, `start()`, `abort()` and `ReachabilityPeerConnection.getResult()`, `start()`, `abort()` | Run and settle per-cluster/per-protocol WebRTC probes with owned peer connections; the timers belong to `Reachability`. | Preserve the `udp`, `tcp`, and `xtls` protocol names and one-settlement cleanup; `start()` never rejects. | `src/reachability/clusterReachability.ts`, `src/reachability/reachabilityPeerConnection.ts` | [package architecture](../../../docs/architecture.md) |
141
+ | `reachability-service` | SDK / lifecycle | `gatherReachabilityFallback()` and `stopReachability()` | Restart with fallback discovery when the minimum cluster target is missed, or abort an active run. | Both paths absorb their documented internal failures; stop emits `reachability:stopped` only for an active timer. | `src/reachability/index.ts` | [package architecture](../../../docs/architecture.md) |
142
+ | `reachability-service` | SDK / query | `isSubnetReachable()`, `isAnyPublicClusterReachable()`, `isWebexMediaBackendUnreachable()`, and `isAnyClusterReachableViaProtocol()` | Answer media-selection questions from the latest stored cluster results; `isSubnetReachable()` reads the in-memory server IPs of the latest run. | Preserve boolean/null semantics and current public/video-mesh distinctions; the three async queries resolve `false` when storage is empty or unreadable. | `src/reachability/index.ts` | [package architecture](../../../docs/architecture.md) |
143
+ | `reachability-service` | SDK / report | `getJoinCookie()`, `getReachabilityReport()`, `getReachabilityMetrics()`, `getReachabilityResults()`, `getClientMediaPreferences()`, and `getReachabilityReportToAttachToRoap()` | Read cached/stored results and format local metrics, media preferences, or ROAP attachment data. | These methods construct/return data; they do not submit a reachability report to the service themselves; callers send it with joins and ROAP, and fallback sends it as `previous-report`. | `src/reachability/index.ts` | [package architecture](../../../docs/architecture.md) |
144
+ | `reachability-service` | exported utilities | `resolveReachabilityProtocols()`, `isReachabilityEnabled()`, `convertStunUrlToTurn()`, and `convertStunUrlToTurnTls()` | Resolve configured protocol sets and transform validated STUN URLs for probe setup. | Invalid STUN input throws; preserve `xtls` and URL conversion behavior. | `src/reachability/util.ts` | [package architecture](../../../docs/architecture.md) |
145
+ | `reachability-service` | exported events/types | `Events`, `ResultEventData`, `ClientMediaIpsUpdatedEventData`, `NatTypeUpdatedEventData`, `Protocol`, `ResolvedReachabilityProtocols`, `ReachabilityProtocolConfig`, `EnableReachabilityChecksConfig`, `ReachabilityPeerConnectionEvents`, `TransportResult`, `NatType`, `ClusterReachabilityResult`, `ReachabilityMetrics`, `TransportResultForBackend`, `ReachabilityResultForBackend`, `ReachabilityResultsForBackend`, `ReachabilityResults`, `ReachabilityReportV0`, `ReachabilityReportV1`, `ClientMediaPreferences`, `GetClustersTrigger`, `ClusterNode`, and `ClusterList` | Share the exact probe/result vocabulary with Meetings, metrics, and ROAP code. | Add fields compatibly and preserve raw result/protocol/NAT values. | `src/reachability/clusterReachability.ts`, `src/reachability/reachability.types.ts`, `src/reachability/request.ts` | [package architecture](../../../docs/architecture.md) |
146
+ | `reachability-service` | dormant request helper | `ReachabilityRequest.remoteSDPForClusters()` | POST local SDP offers to the reachability resource and return remote SDP bodies when called directly. | No current package code invokes this exported helper; do not present it as part of `gatherReachability()`. | `src/reachability/request.ts` | [package architecture](../../../docs/architecture.md) |
147
+
148
+ Contract ID `reachability-service` is internal to the package: `src/index.ts` does not re-export the
149
+ module, and applications reach the instance through the meetings plugin. It is indexed in the
150
+ [package architecture](../../../docs/architecture.md) and registered in `.sdd/manifest.json`; the
151
+ module requires `browser-webrtc` and `webex-core-plugin-host`.
152
+
153
+ Current source emits these observable literals from the `Reachability` controller. Preserve literal
154
+ values and the current terminal/progress timing.
155
+
156
+ | Event literal | Constant / expression | Emission evidence |
157
+ |---|---|---|
158
+ | `reachability:done` | inline literal | `src/reachability/index.ts` |
159
+ | `reachability:firstResultAvailable` | inline literal | `src/reachability/index.ts` |
160
+ | `reachability:stopped` | inline literal | `src/reachability/index.ts` |
161
+
162
+ `reachability:done` (payload `{}`) is emitted when every expected result has arrived, when the 15 s
163
+ overall timer fires, or at once for an empty cluster list. `reachability:firstResultAvailable` carries
164
+ `{protocol}` and is emitted once per protocol per run. `reachability:stopped` (payload `{}`) is
165
+ emitted by `stopReachability()` while a run is in progress.
166
+
167
+ Compatibility notes:
168
+
169
+ - Prefer additive options and payload fields. Preserve method/event names, rejection semantics, and cleanup timing; route public changes through `src/index.ts` or the documented owning object.
170
+
171
+ ## Dependencies
172
+
173
+ Webex reachability services, browser RTCPeerConnection, STUN/TURN candidates, timers, and metrics/request access.
174
+
175
+ | Dependency | Why it is required | Failure behavior |
176
+ | ---------- | ------------------ | ---------------- |
177
+ | Discovery service through `webex.request` (`api: 'calliopeDiscovery'`, resource `clusters`) | The cluster list, the join cookie, and the discovery options | One retry, then the rejection reaches `getClusters`' caller; `gatherReachability` and fallback absorb it |
178
+ | Browser `RTCPeerConnection` (contract `browser-webrtc`) and `@webex/web-capabilities` | ICE gathering against each cluster; `supportsRTCPeerConnection()` gates the run | Not capable: `gatherReachability` resolves `{}`; a constructor error leaves that probe `untested` |
179
+ | `webex.boundedStorage` (contract `webex-core-plugin-host`) | Stores the join cookie and the results between runs and for the queries | Read failures make the queries resolve `false` or `undefined`; a write failure inside the gather is caught and resolves `{}`, and one inside a result handler is an unhandled rejection |
180
+ | `webex.internal.newMetrics.callDiagnosticLatencies.measureLatency` | Times the `startup` discovery call as `internal.get.cluster.time` | — |
181
+ | `webex.internal.device.ipNetworkDetector` | `detect(true)` starts IP version detection (not awaited); its results are reported in the completion metric | — |
182
+ | `MeetingUtil.getIpVersion` (`src/meeting/util.ts`) | `ipver` for the discovery request | — |
183
+ | The metrics module (`src/metrics/index.ts`, `src/metrics/constants.ts`) | Sends `js_sdk_reachability_completed` | See the metrics module specification |
184
+ | `@webex/common` `Defer`, `lodash` (`isEqual`, `mapValues`, `mean`), `EventsScope`, `LoggerProxy` | The gather promise, result counting and formatting, events, and logs | — |
185
+
186
+ ## Requirements
187
+
188
+ | ID | WHAT | WHY | Source Evidence | Test / Example Evidence | Assumptions / Gaps | Confidence |
189
+ |---|---|---|---|---|---|---|
190
+ | `REACHABILITY-R-001` | fetch and normalize candidate clusters: `getClusters` POSTs to the discovery service, marks each cluster `isVideoMesh` when it is listed in `clusterClasses.hybridMedia`, keeps `early-call-min-clusters` and `report-version`, writes the join cookie to bounded storage, and retries once on failure. | Joins and ROAP messages carry the join cookie and the report format selected by `report-version`, and fallback depends on the cluster minimum. | `src/reachability/index.ts`, `src/reachability/request.ts` | `test/unit/spec/reachability/index.ts`, `test/unit/spec/reachability/request.js` | none | PRESENT |
191
+ | `REACHABILITY-R-002` | Run the `udp`, `tcp`, and `xtls` reachability probes used by code and metric keys, as enabled by `enableReachabilityChecks`; video-mesh clusters are probed over UDP only. | Callers and telemetry consumers need the exact wire/field name rather than an ambiguous prose-only TLS label; the code comments say Linus does not support TCP or xTLS checks on video mesh nodes. | `src/reachability/index.ts`, `src/reachability/clusterReachability.ts`, `src/reachability/reachability.types.ts`, `src/reachability/util.ts` | `test/unit/spec/reachability/index.ts`, `test/unit/spec/reachability/util.ts` | none | PRESENT |
192
+ | `REACHABILITY-R-003` | `gatherReachability()` throws from its `async` body when reachability is disabled before entering its `try`, so the returned promise rejects; it returns `{}` when WebRTC is unavailable or when discovery/probe setup fails inside the `try`. A started successful run returns the defer promise, which resolves with `undefined` after results are stored. `getClusters()` retries once and can reject its direct caller on the second failure; fallback catches and logs its own failures. | Callers must distinguish the disabled-config rejection, empty-object skip/failure sentinel, and successful void settlement instead of treating every gather outcome as `{}` or a rejection. | `src/reachability/index.ts`, `src/reachability/clusterReachability.ts`, `src/reachability/reachabilityPeerConnection.ts` | `test/unit/spec/reachability/index.ts`, `test/unit/spec/reachability/clusterReachability.ts` | none | PRESENT |
193
+ | `REACHABILITY-R-004` | Each peer-connection probe settles once — when ICE gathering completes or on abort — and closes its peer connection; a protocol with URLs starts `unreachable` and becomes `reachable` on its first matching candidate, a protocol without URLs stays `untested`, and the run's timers are owned and cleared by `Reachability`. | ICE events and timeouts race; deterministic cleanup and aggregation prevent false success and leaks. | `src/reachability/clusterReachability.ts`, `src/reachability/reachabilityPeerConnection.ts`, `src/reachability/index.ts` | `test/unit/spec/reachability/clusterReachability.ts` | none | PRESENT |
194
+ | `REACHABILITY-R-005` | The aggregate results preserve per-cluster protocol outcomes, latency, client media IPs, and video-mesh flag; the discovery request carries the IP version, the previous report, and the trigger; the NAT type is reported in the metrics. | The backend and media selection need comparable current results rather than a single boolean. | `src/reachability/index.ts`, `src/reachability/reachability.types.ts`, `src/reachability/request.ts` | `test/unit/spec/reachability/index.ts`, `test/unit/spec/reachability/request.js` | none | PRESENT |
195
+ | `REACHABILITY-R-006` | Once probes start, the gather defer resolves when every expected result has arrived, after 1 s if only video-mesh results are missing, or at the latest after 3 s; at 15 s any probe still running is aborted, `reachability:done` is emitted, and the completion metric is sent. Results that arrive after the defer resolves still update the stored results. | The code comments: the 3 s resolve keeps the client from being blocked on `meetings.register()` too long, and video-mesh results are likely to fail off the corporate network. | `src/reachability/index.ts` | `test/unit/spec/reachability/index.ts` | none | PRESENT |
196
+ | `REACHABILITY-R-007` | When a run resolves with fewer reachable clusters than `early-call-min-clusters`, `gatherReachabilityFallback` sends the current report as `previous-report` with trigger `early-call/no-min-reached`, aborts the running checks, and probes the returned list. A stop or an empty list never triggers fallback. | The JSDoc: when the minimum number of clusters required by Orpheus is not reached, the results go to Orpheus and a new list is tried. | `src/reachability/index.ts` | `test/unit/spec/reachability/index.ts` | none | PRESENT |
197
+ | `REACHABILITY-R-008` | `stopReachability()` acts only while the overall timer is pending: it aborts every probe, clears the timers, emits `reachability:stopped`, sends the completion metric with `aborted: true`, and resolves the defer without fallback. | Meeting stops reachability before creating a media connection because ongoing checks slow new media connections, especially on Firefox (code comment in `Meeting.createMediaConnection`). | `src/reachability/index.ts`, `src/meeting/index.ts` | `test/unit/spec/reachability/index.ts` | none | PRESENT |
198
+ | `REACHABILITY-R-009` | With `report-version` 0 or absent, `getClientMediaPreferences` returns `{ipver, joinCookie, preferTranscoding}` and `getReachabilityReportToAttachToRoap` returns the backend-format results; with version 1, the media preferences carry the version 1 report and the join cookie, and ROAP gets `undefined`. `preferTranscoding` is `!isMultistream`. | The code comments: for version 1 the report goes into `clientMediaPreferences` and nothing is attached to ROAP messages. | `src/reachability/index.ts`, `src/roap/request.ts`, `src/meeting/util.ts` | `test/unit/spec/reachability/index.ts`, `test/unit/spec/roap/request.ts`, `test/unit/spec/meeting/utils.js` | none | PRESENT |
199
+ | `REACHABILITY-R-010` | `isAnyPublicClusterReachable` is true when a non-video-mesh cluster is reachable over UDP or TCP; `isWebexMediaBackendUnreachable` is true only when UDP, TCP, and `xtls` were all tested and none reached any cluster; `isAnyClusterReachableViaProtocol` is true when any cluster reached the protocol; all three read the stored results and resolve `false` on a missing or unreadable entry. `isSubnetReachable` compares the first octet with the server IPs reached in the latest run. | TURN discovery is skipped when a public cluster is reachable, a TLS-only media retry needs `xtls` reachability, and media-failure reporting must not claim unreachability for an untested protocol (JSDoc of `isWebexMediaBackendUnreachable`). | `src/reachability/index.ts`, `src/roap/turnDiscovery.ts`, `src/meeting/index.ts` | `test/unit/spec/reachability/index.ts` | none | PRESENT |
200
+ | `REACHABILITY-R-011` | Each run first writes every cluster's initial result to bounded storage, then rewrites the stored results on each result and client-IP update; a run that fails before storing keeps the previous run's results. | The code comment: the initialized results are saved in case no result event arrives at all, and the queries and reports read storage, not the instance. | `src/reachability/index.ts` | `test/unit/spec/reachability/index.ts` | none | PRESENT |
201
+ | `REACHABILITY-R-012` | Each run sends `js_sdk_reachability_completed` once — on completion, on the overall timeout, or on stop — with flattened fields: `aborted`, min/max/average latency per protocol for public and video-mesh clusters (`-1` without a reachable result), the IP detection results, and the trigger. | The JSDoc: a metric with all the statistics about how long reachability took. | `src/reachability/index.ts`, `src/metrics/constants.ts` | `test/unit/spec/reachability/index.ts` | none | PRESENT |
202
+
203
+ ## Design overview
204
+
205
+ `Reachability` fetches media clusters with `request.ts`, builds a `ClusterReachability` aggregate per
206
+ cluster, and runs UDP/TCP/`xtls` probes through `ReachabilityPeerConnection`; each probe owns and
207
+ closes its peer connection, while the timeouts belong to `Reachability`.
208
+
209
+ A probe needs no signalling: `ReachabilityPeerConnection` creates an offer, sets it as the local
210
+ description to start ICE gathering, and never sends it. The cluster's UDP URLs are STUN servers; to
211
+ test TCP and TLS the module presents the cluster as a TURN server (`turn:` with `transport=tcp`, and
212
+ `turns:` with `transport=tcp`) with fixed probe credentials, because STUN is contacted only over UDP
213
+ (code comment in `buildPeerConnectionConfig`). A server-reflexive candidate proves UDP; a relay
214
+ candidate proves TCP, or TLS when its port is 443. Two server-reflexive candidates with the same
215
+ address and related port but different ports mark a symmetric NAT.
216
+
217
+ `Reachability` counts expected results (one per protocol with URLs per cluster) against received
218
+ ones to decide completion, keeps the latest run's `ClusterReachability` objects in memory for
219
+ `isSubnetReachable` and the metric, and writes the per-cluster results to bounded storage for every
220
+ other reader.
221
+
222
+ ## Data flow and sequence coverage
223
+
224
+ Call style: in-process promise-returning methods and `EventsScope` events; HTTPS `POST` through
225
+ `webex.request` to the discovery service; ICE (STUN and TURN over UDP, TCP, and TLS) from browser peer
226
+ connections to the media clusters; bounded storage reads and writes. Operation groups: discovery and
227
+ probing (gather), fallback, stop, and reading results (queries, reports, metrics).
228
+
229
+ ```mermaid
230
+ flowchart LR
231
+ Caller[Meetings registration / diagnostics] --> Reach[index.ts]
232
+ Reach --> Request[request.ts cluster discovery]
233
+ Request --> Service[reachability service]
234
+ Reach --> Cluster[clusterReachability.ts]
235
+ Cluster --> Probe[reachabilityPeerConnection.ts]
236
+ Probe --> ICE[WebRTC ICE candidate gathering]
237
+ Probe --> Cluster
238
+ Cluster --> Reach
239
+ Reach --> Storage[bounded storage results / join cookie]
240
+ Reach --> Local[local report / metrics / ROAP attachment]
241
+ ```
242
+
243
+ Sequence coverage:
244
+
245
+ | Operation group | Diagram | Failure coverage |
246
+ |---|---|---|
247
+ | UC-1…UC-5 — reachability discovery and probe operation groups | Reachability discovery and probe primary sequence | second discovery failure, absorbed gather failure, overall-timeout abort, and peer cleanup |
248
+ | UC-1…UC-5 — reachability discovery and probe alternate/failure paths | Reachability discovery and probe alternate/failure sequence | ICE gathering that completes without a matching candidate, peer-connection creation failure, untested protocol, or abort by timer or explicit stop |
249
+ | UC-4 — fallback discovery | Fallback sequence | discovery failure is logged; an empty list or zero minimum ends the loop |
250
+ | UC-6 — stop before media | Stop sequence | no run in progress: nothing happens |
251
+ | UC-5 — join and ROAP reports | Report sequence | empty or unreadable storage yields `undefined` results |
252
+
253
+ Reachability discovery and probe primary sequence:
254
+
255
+ ```mermaid
256
+ sequenceDiagram
257
+ participant C as Caller
258
+ participant R as Reachability index.ts
259
+ participant Q as request.ts
260
+ participant S as bounded storage
261
+ participant K as ClusterReachability
262
+ participant P as ReachabilityPeerConnection
263
+ C->>R: gatherReachability(trigger)
264
+ R->>Q: fetch clusters (trigger startup), retry once
265
+ Q-->>R: candidate cluster list, joinCookie, discoveryOptions
266
+ R->>S: put join cookie
267
+ R->>S: put initial results (unreachable or untested)
268
+ R->>R: start 1 s, 3 s, and 15 s timers
269
+ loop per cluster
270
+ R->>K: new ClusterReachability, start() not awaited
271
+ K->>P: start probe (UDP, TCP, xtls URLs)
272
+ end
273
+ R-->>C: defer promise
274
+ P-->>K: resultReady when a protocol is reached
275
+ K-->>R: resultReady, clientMediaIpsUpdated, natTypeUpdated
276
+ R->>S: put updated results
277
+ alt every expected result arrived
278
+ R->>R: emit reachability:done, send metric, resolve defer
279
+ else 3 s public timer (or 1 s when only video mesh is missing)
280
+ R->>R: resolve defer, check cluster minimum
281
+ else 15 s overall timer
282
+ R->>K: abort()
283
+ R->>R: emit reachability:done, send metric
284
+ end
285
+ R-->>C: defer settles undefined, disabled rejects, skipped/caught failure returns empty object
286
+ ```
287
+
288
+ Reachability discovery and probe alternate/failure sequence:
289
+
290
+ ```mermaid
291
+ sequenceDiagram
292
+ participant R as Reachability
293
+ participant P as Protocol probe
294
+ participant W as RTCPeerConnection
295
+ R->>P: probe cluster with udp, tcp, or xtls
296
+ P->>W: gather ICE candidates
297
+ alt candidate proves reachable
298
+ W-->>P: matching candidate
299
+ P-->>R: reachable result (first latency, client IP)
300
+ else gathering completes without a matching candidate
301
+ W-->>P: iceGatheringState complete
302
+ P->>P: result stays unreachable, close connection
303
+ else peer connection could not be created
304
+ P-->>R: start() resolves with untested results
305
+ else overall timer or stopReachability
306
+ R->>P: abort()
307
+ P->>P: close connection, resolve start()
308
+ end
309
+ ```
310
+
311
+ Fallback sequence:
312
+
313
+ ```mermaid
314
+ sequenceDiagram
315
+ participant R as Reachability
316
+ participant S as bounded storage
317
+ participant Q as request.ts
318
+ R->>R: defer resolved with fewer reachable clusters than early-call-min-clusters
319
+ R->>S: read results and join cookie
320
+ R->>Q: getClusters('early-call/no-min-reached', previous report)
321
+ alt clusters returned
322
+ Q-->>R: new list and options
323
+ R->>R: abort current checks and timers
324
+ R->>R: performReachabilityChecks(new list)
325
+ else discovery fails twice
326
+ R->>R: log the error, keep the stored results
327
+ end
328
+ ```
329
+
330
+ Stop sequence:
331
+
332
+ ```mermaid
333
+ sequenceDiagram
334
+ participant M as Meeting.createMediaConnection
335
+ participant R as Reachability
336
+ participant K as ClusterReachability
337
+ M->>R: stopReachability()
338
+ opt overall timer pending
339
+ R->>R: clear timers
340
+ R->>K: abort()
341
+ R->>R: emit reachability:stopped
342
+ R->>R: send metric (aborted true)
343
+ R->>R: resolve defer, no fallback
344
+ end
345
+ ```
346
+
347
+ Report sequence:
348
+
349
+ ```mermaid
350
+ sequenceDiagram
351
+ participant J as Join or ROAP request code
352
+ participant R as Reachability
353
+ participant S as bounded storage
354
+ J->>R: getClientMediaPreferences(isMultistream, ipver)
355
+ alt report-version 1
356
+ R->>S: read results and join cookie
357
+ R-->>J: {ipver, preferTranscoding, joinCookie, reachability: version 1 report}
358
+ else version 0 or absent
359
+ R->>S: read join cookie
360
+ R-->>J: {ipver, joinCookie, preferTranscoding}
361
+ end
362
+ J->>R: getReachabilityReportToAttachToRoap()
363
+ R-->>J: backend-format results (version 0) or undefined (version 1)
364
+ ```
365
+
366
+ ## Class and component relationships
367
+
368
+ ```mermaid
369
+ classDiagram
370
+ class Caller
371
+ class Reach
372
+ class Request
373
+ class Service
374
+ class Cluster
375
+ class Probe
376
+ class ICE
377
+ class EventsScope
378
+ EventsScope <|-- Reach
379
+ EventsScope <|-- Cluster
380
+ EventsScope <|-- Probe
381
+ Caller --> Reach
382
+ Reach --> Request
383
+ Request --> Service
384
+ Reach "1" *-- "many" Cluster
385
+ Cluster "1" *-- "1..many" Probe
386
+ Probe --> ICE
387
+ Probe ..> Cluster : events
388
+ Cluster ..> Reach : events
389
+ ```
390
+
391
+ The arrows identify ownership and delegation inside `src/reachability/`; files that only declare types
392
+ or constants are not presented as transports. `Caller` is the meetings plugin, `Reach` is
393
+ `Reachability`, `Request` is `ReachabilityRequest`, `Service` is the discovery service, `Cluster` is
394
+ `ClusterReachability`, `Probe` is `ReachabilityPeerConnection`, and `ICE` is the browser
395
+ `RTCPeerConnection`.
396
+
397
+ ## Use cases and flows
398
+
399
+ | Use case | Actor or caller | Primary steps and outcome | Failure or boundary behavior | Evidence |
400
+ | -------- | --------------- | ------------------------- | ---------------------------- | -------- |
401
+ | `UC-1` | `Meetings.register` or an application through `startReachability` | Fetch clusters with one retry, store the returned join cookie, and start enabled `udp`, `tcp`, and `xtls` probes. | Disabled config rejects; no WebRTC or a caught failure resolves `{}` | `src/reachability/index.ts`, `src/reachability/request.ts`, `test/unit/spec/reachability/index.ts` |
402
+ | `UC-2` | `Reachability` during a run | Settle each cluster/protocol probe once and close its peer connection on ICE gathering completion, failure, or abort; the overall timer aborts what is left. | A probe whose peer connection could not be created reports `untested` | `src/reachability/clusterReachability.ts`, `src/reachability/reachabilityPeerConnection.ts`, `test/unit/spec/reachability/clusterReachability.ts` |
403
+ | `UC-3` | Caller of `gatherReachability` | Reject before probing when reachability is disabled, return `{}` when WebRTC is unavailable or a discovery/probe setup failure is caught, and otherwise resolve the run's defer with `undefined` after storing results. | Results keep arriving after the defer resolves | `src/reachability/index.ts`, `test/unit/spec/reachability/index.ts` |
404
+ | `UC-4` | `Reachability` after a run resolves | Trigger fallback discovery when the minimum reachable-cluster threshold is missed, aborting the previous run before probing the replacement list. | A failed fallback is logged; the loop continues until the minimum is met or not requested | `src/reachability/index.ts`, `test/unit/spec/reachability/index.ts` |
405
+ | `UC-5` | Join, ROAP, TURN discovery, and media metrics code | Read results as metrics, client media preferences, or a ROAP attachment without calling the dormant `ReachabilityRequest.remoteSDPForClusters()` helper. | Empty storage yields zero metrics, `undefined` results, and `false` queries | `src/reachability/index.ts`, `src/reachability/request.ts`, `src/meeting/util.ts`, `src/roap/request.ts` |
406
+ | `UC-6` | `Meeting.createMediaConnection` | Call `stopReachability()` so running probes do not slow the new media connection. | No effect when no run is in progress | `src/meeting/index.ts`, `src/reachability/index.ts`, `test/unit/spec/reachability/index.ts` |
407
+
408
+ ### Cross-boundary use-case flow
409
+
410
+ | Boundary | Transport and ordering | Compatibility | Timeout, retry, and recovery |
411
+ | -------- | ---------------------- | ------------- | ---------------------------- |
412
+ | Discovery service (`UC-1`, `UC-4`) | HTTPS `POST` through `webex.request`, `api: 'calliopeDiscovery'`, resource `clusters`, `shouldRefreshAccessToken: false` | Request and response fields under Protocol and wire format; `supported-options` advertises report version 1 and the early-call minimum | `reachabilityGetClusterTimeout` (5000 ms default) per call; one retry; fallback repeats while the minimum is missed |
413
+ | Media clusters (`UC-2`) | ICE from one `RTCPeerConnection` per cluster (or per UDP URL), all clusters in parallel | STUN for UDP; TURN `transport=tcp` for TCP; TURNS `transport=tcp` for TLS | No per-probe timer; the 15 s overall timer aborts |
414
+ | Bounded storage (`UC-1`, `UC-5`) | Asynchronous put and get under namespace `Reachability` | JSON strings | Read failures are absorbed by the readers |
415
+
416
+ ## Client state model
417
+
418
+ Cluster/protocol probe state, peer connections, timers, and partial results exist for one reachability
419
+ run; the stored results, the join cookie, the NAT type, and the discovery options outlive the run.
420
+
421
+ | State or slice | Owner | Initial state | Transition triggers | Reset or persistence boundary |
422
+ | -------------- | ----- | ------------- | ------------------- | ----------------------------- |
423
+ | `clusterReachability` map | `Reachability` | `{}` | Replaced at the start of each run | Instance memory; the latest run only |
424
+ | `expectedResultsCount`, `resultsCount` | `Reachability` | All zero | Reset and recounted per run; `resultReady` increments | Instance memory |
425
+ | `vmnTimer`, `publicCloudTimer`, `overallTimer` | `Reachability` | `undefined` | Set when probes start; cleared on resolve, completion, abort, or stop | Instance memory; `overallTimer` marks a run in progress |
426
+ | `reachabilityDefer` | `Reachability` | `undefined` | New per `gatherReachability` | Instance memory |
427
+ | `natType` | `Reachability` | `unknown` | `natTypeUpdated` sets `symmetric-nat` | Instance memory; never reset to `unknown` by a later run |
428
+ | `minRequiredClusters`, `orpheusApiVersion` | `Reachability` | `undefined` | Each successful discovery | Instance memory |
429
+ | `lastTrigger`, `startTime`, `totalDuration` | `Reachability` | `undefined` | Gather start, run start, defer resolve | Instance memory |
430
+ | Stored results `reachability.result` | bounded storage | Absent | Each run's initial write and every update | Survives runs; in a browser build the bounded adapter is local storage, so it can survive a reload |
431
+ | Stored join cookie `reachability.joinCookie` | bounded storage | Absent | Each successful discovery | Same as the stored results |
432
+
433
+ ## Business rules and invariants
434
+
435
+ - Each probe settles once and closes its peer connection; unsupported or failed protocols are reported
436
+ rather than inferred reachable. Enforced by `src/reachability/index.ts` and supporting code under
437
+ `src/reachability/`.
438
+
439
+ | ID | Invariant | WHY | Enforcement source | Test evidence |
440
+ | -- | --------- | --- | ------------------ | ------------- |
441
+ | `INV-001` | A protocol is `reachable` only after a matching candidate (server-reflexive for UDP, relay for TCP, relay on port 443 for TLS); before that a tested protocol is `unreachable` and one without URLs is `untested`. | No false success (`REACHABILITY-R-004`). | `src/reachability/reachabilityPeerConnection.ts`, `src/reachability/index.ts` | `test/unit/spec/reachability/clusterReachability.ts` |
442
+ | `INV-002` | Video-mesh clusters get no TCP or TLS URLs, and a protocol disabled in `enableReachabilityChecks` gets none on any cluster; UDP is disabled only by `enableReachabilityChecks: false`. | Linus does not support TCP or xTLS checks on video mesh nodes (code comments); the config resolves to per-protocol flags (`REACHABILITY-R-002`). | `src/reachability/index.ts`, `src/reachability/util.ts` | `test/unit/spec/reachability/index.ts`, `test/unit/spec/reachability/util.ts` |
443
+ | `INV-003` | The latency recorded for a protocol is the time to its first matching candidate; later candidates only add client IPs. | Comparable results across clusters (`REACHABILITY-R-005`). | `src/reachability/reachabilityPeerConnection.ts` | `test/unit/spec/reachability/clusterReachability.ts` |
444
+ | `INV-004` | In per-UDP-URL mode a cluster relays only its first reachable UDP result, and its UDP result is the first reachable one among its URLs. | One UDP result per cluster keeps the result counting exact (`REACHABILITY-R-006`). | `src/reachability/clusterReachability.ts` | `test/unit/spec/reachability/clusterReachability.ts` |
445
+ | `INV-005` | Backend-format results use strings: `reachable` is `'true'` or `'false'`, `untested` is `'true'`, and `latencyInMilliseconds` is a string; a missing protocol is reported as untested. | The type comment: this is the format the backend requires. | `src/reachability/index.ts`, `src/reachability/reachability.types.ts` | `test/unit/spec/reachability/index.ts` |
446
+
447
+ ## Concurrency and reactive flow
448
+
449
+ - Each cluster/protocol probe owns one peer connection, settles once from its ICE gathering or abort path, and closes it before its start promise resolves; the run's timeouts belong to `Reachability`. Cluster discovery is requested remotely; report/metric/ROAP shapes are constructed locally. Only failures inside `gatherReachability()`'s `try` are absorbed as `{}`; disabled configuration rejects before that boundary.
450
+ - Execution model: one JavaScript event loop; every cluster's `start()` is called without awaiting,
451
+ so all probes run in parallel; results arrive as events.
452
+ - Ordering guarantees: the initial results are stored before any probe starts; `reachability:done` is
453
+ emitted at most once per run; the defer resolves once (later `resolve` calls have no effect).
454
+ - Idempotency and retry: discovery is retried once; probes are not retried; a fallback starts a new run.
455
+ - Shared-state protection: none. A second `gatherReachability` during a run replaces the cluster map,
456
+ the counters, and the timer references without aborting the old probes or clearing the old timers;
457
+ only fallback calls `abortCurrentChecks` first. Storage writes from overlapping runs are not
458
+ serialized.
459
+ - Blocking restrictions: `Meeting` stops a run before creating a media connection because the probes
460
+ slow it down.
461
+
462
+ ## Data, schema, and migration discipline
463
+
464
+ | Store or schema | Owned entities or keys | Source of truth | Migration and compatibility rule |
465
+ | --------------- | ---------------------- | --------------- | -------------------------------- |
466
+ | `webex.boundedStorage`, namespace `Reachability` | `reachability.result`: JSON of `ReachabilityResults`, one entry per cluster with `udp`, `tcp`, `xtls` (each `{result, latencyInMilliseconds?, clientMediaIPs?}`) and `isVideoMesh` | `src/reachability/index.ts`, `src/reachability/reachability.types.ts`, `src/constants.ts` | No version field and no migration: each run overwrites the whole entry with its initial results before probing. Readers tolerate older or partial shapes: a missing protocol is reported as untested, a missing `isVideoMesh` counts as a public cluster, and a parse failure makes the readers resolve `undefined`, all-zero metrics, or `false` |
467
+ | `webex.boundedStorage`, namespace `Reachability` | `reachability.joinCookie`: JSON of the discovery response's `joinCookie`, treated as opaque | `src/reachability/index.ts`, `src/constants.ts` | Overwritten by every successful discovery; a parse failure is logged and `getJoinCookie` resolves `undefined` |
468
+
469
+ Retention and deletion are not handled here: the module never removes either key, and the entries
470
+ last as long as the host's bounded storage adapter keeps them (local storage in the browser build,
471
+ memory in Node). The stored shape is also the input of the backend formats under Protocol and wire
472
+ format, so a field rename here changes what joins and ROAP messages carry.
473
+
474
+ ## Protocol and wire format
475
+
476
+ - External payloads are parsed/serialized by files under `src/reachability/` and existing Webex/media
477
+ dependencies. Preserve current field names, enum/raw values, sequence identifiers, and compatibility
478
+ behavior; do not treat the normalized client model as the wire schema.
479
+
480
+ | Message or frame | Version | Producer or serializer | Consumer or parser | Compatibility and ordering rule |
481
+ | ---------------- | ------- | ---------------------- | ------------------ | ------------------------------- |
482
+ | Discovery request body `{ipver, 'supported-options': {'report-version': 1, 'early-call-min-clusters': true}, 'previous-report', 'client-environment', trigger}` | — | `ReachabilityRequest.getClusters` | Discovery service | `client-environment` is `{components: {[appType]: appVersion}}`, sent only when both support config values are set; `trigger` is `startup` or `early-call/no-min-reached` |
483
+ | Discovery response `{clusters, joinCookie, discoveryOptions, clusterClasses}` | — | Discovery service | `ReachabilityRequest.getClusters` | Each cluster has `udp`, `tcp`, and `xtls` URL arrays; `clusterClasses.hybridMedia` lists video-mesh clusters |
484
+ | ICE servers per probe | — | `ReachabilityPeerConnection` | Browser `RTCPeerConnection` | UDP URLs as given with empty credentials; TCP as `turn:` plus `transport=tcp`; TLS as `turns:` plus `transport=tcp`; `iceCandidatePoolSize: 0`, `iceTransportPolicy: 'all'` |
485
+ | Backend results `{<cluster>: {udp, tcp, xtls}}` (report version 0) | 0 | `getReachabilityResults` | Discovery service, ROAP and join backends | String values (`INV-005`) |
486
+ | Report version 1 `{version: 1, result: {usedDiscoveryOptions: {'early-call-min-clusters'}, metrics: {'total-duration-ms'}, tests}}` plus `joinCookie` | 1 | `getReachabilityReport` | Join `clientMediaPreferences` and fallback `previous-report` | `tests` holds the version 0 results |
487
+ | `clientMediaPreferences` `{ipver, joinCookie, preferTranscoding, reachability?}` | 0 or 1 | `getClientMediaPreferences` | Meeting join and ROAP requests | `reachability` only for version 1 |
488
+ | Stored `reachability.result` and `reachability.joinCookie` | — | `Reachability` | `Reachability` readers | JSON strings in bounded storage namespace `Reachability` |
489
+ | Metric fields of `js_sdk_reachability_completed` | — | `sendMetric` through `Metrics.prepareMetricFields` | Metrics service | Flattened keys such as `public_udp_average` and `ipver_firstIpV4` |
490
+
491
+ ## Caller-visible failure modes
492
+
493
+ | Condition | Signal | Caller recovery |
494
+ |---|---|---|
495
+ | Reachability is disabled in configuration | `gatherReachability()` throws `enableReachabilityChecks is disabled in config` from its `async` body before entering the catch block, which rejects the returned promise. | Enable the configured checks or handle the rejection; do not expect `{}` for this path. |
496
+ | Cluster discovery still fails after `getClusters()` retries once | A direct `getClusters()` caller receives the rejection; `gatherReachability()` and fallback callers catch it and resolve with their documented empty/void outcome. | Distinguish direct discovery from the failure-absorbing gather APIs. |
497
+ | ICE gathering completes, or the overall timer aborts the probe, before a supported protocol is reached | The protocol keeps its initial `unreachable` result; the probe closes its peer connection and its start promise resolves (it never rejects). | Record the explicit unreachable result; do not retain the probe connection. |
498
+ | Every expected `udp`, `tcp`, and `xtls` result arrives | The module stores aggregate protocol/cluster/IP results, emits `reachability:done`, sends the completion metric, and resolves the gather defer with `undefined`; the report itself is sent later, with a join, a ROAP message, or a fallback discovery request. | Read the stored/local report through the query/report helpers rather than expecting the gather promise to carry the result object. |
499
+ | A STUN URL passed to `convertStunUrlToTurn` or `convertStunUrlToTurnTls` is invalid or not `stun:` | Throws `TypeError` from `URL`, or `Error('Not a STUN URL: …')`; inside a probe this lands in the peer-connection catch, the probe reports `untested`, and the stored result keeps its initial `unreachable`. | Fix the cluster URL; nothing is retried. |
500
+ | Stored results are missing or unreadable | `getReachabilityResults` resolves `undefined`; `getReachabilityMetrics` resolves all-zero counters; the three async queries resolve `false`. | Treat as no reachability data. |
501
+
502
+ ## Pitfalls and constraints
503
+
504
+ - Browser ICE callbacks and timeout can race. Cleanup must be idempotent and partial results must not be presented as a complete success.
505
+ - Public behavior may be reachable through a parent `Meeting`/`Meetings` object even when the source helper is not exported directly.
506
+ - The gather promise can resolve before all results arrive; results written later are still stored and
507
+ read by later queries.
508
+ - The caller's `trigger` is not sent to discovery; only the completion metric carries it.
509
+ - `getJoinCookie` logs parse errors with the prefix `MeetingRequest#constructor`, and
510
+ `getReachabilityMetrics` logs with `Roap:request#getReachabilityMetrics`; search logs by those
511
+ strings.
512
+ - `natType` is never reset, so a symmetric NAT seen once is reported for every later run of the
513
+ instance.
514
+
515
+ ## Key design trade-off
516
+
517
+ - Parallel probes reduce startup time but require per-probe isolation and deterministic aggregation.
518
+
519
+ | Chosen trade-off | Preserved invariant or benefit | Cost or limitation | Decision evidence |
520
+ | ---------------- | ------------------------------ | ------------------ | ----------------- |
521
+ | Probe every cluster in parallel and resolve the gather promise after at most 3 s, letting results keep arriving until 15 s | Registration is not blocked for long (`REACHABILITY-R-006`) | A join right after registration may use partial results | `src/reachability/index.ts` |
522
+ | Store results in bounded storage and answer queries from storage | The latest results survive a failed later run and are shared by every reader (`REACHABILITY-R-011`) | Each update rewrites the whole entry; readers parse it on every call | `src/reachability/index.ts` |
523
+
524
+ ## Verification
525
+
526
+ Use the current mirrored suites: `test/unit/spec/reachability/clusterReachability.ts`,
527
+ `test/unit/spec/reachability/index.ts`, `test/unit/spec/reachability/request.js`,
528
+ `test/unit/spec/reachability/util.ts`. Characterize the reachability-specific use cases above and each
529
+ listed failure condition; add cleanup or transition cases only for resources and state this module
530
+ actually owns.
531
+
532
+ | Behavior / Requirement | Existing test evidence | Gap |
533
+ |---|---|---|
534
+ | `REACHABILITY-R-001` | `test/unit/spec/reachability/index.ts`, `test/unit/spec/reachability/request.js` | discovery, probe, fallback, stop, query, and report-format groups now have cases; the `clusterClasses.hybridMedia` mapping is not asserted |
535
+ | `REACHABILITY-R-002` | `test/unit/spec/reachability/index.ts`, `test/unit/spec/reachability/util.ts` | protocol selection and the video-mesh exclusion are covered; second discovery failure versus absorbed gather failure is asserted by the two failed getClusters calls case |
536
+ | `REACHABILITY-R-003` | `test/unit/spec/reachability/index.ts` | keep paired assertions for disabled-config rejection, WebRTC/caught-failure `{}`, successful `undefined` defer settlement, and no `remoteSDPForClusters()` invocation |
537
+ | `REACHABILITY-R-004` | `test/unit/spec/reachability/clusterReachability.ts` | verify callback/timeout races |
538
+ | `REACHABILITY-R-005` | `test/unit/spec/reachability/index.ts`, `test/unit/spec/reachability/request.js` | verify partial/mixed protocol reports |
539
+ | `REACHABILITY-R-006` | `test/unit/spec/reachability/index.ts` | none |
540
+ | `REACHABILITY-R-007` | `test/unit/spec/reachability/index.ts` | no case for a fallback whose discovery fails |
541
+ | `REACHABILITY-R-008` | `test/unit/spec/reachability/index.ts` | none |
542
+ | `REACHABILITY-R-009` | `test/unit/spec/reachability/index.ts`, `test/unit/spec/roap/request.ts`, `test/unit/spec/meeting/utils.js` | none |
543
+ | `REACHABILITY-R-010` | `test/unit/spec/reachability/index.ts` | none |
544
+ | `REACHABILITY-R-011` | `test/unit/spec/reachability/index.ts` | none |
545
+ | `REACHABILITY-R-012` | `test/unit/spec/reachability/index.ts` | none |
546
+
547
+ A module specification is complete only when its public surface, invariants, failure modes, and test
548
+ evidence agree with the implementation.