@webex/internal-plugin-locus 3.13.0-next.4 → 3.13.0-next.6
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.
- package/.repo-context.json +425 -0
- package/.sdd/manifest.json +368 -0
- package/AGENTS.md +194 -0
- package/dist/locus.js +1 -1
- package/docs/adr/0001-retain-product-readme.md +93 -0
- package/docs/adr/index.md +22 -0
- package/docs/architecture.md +257 -0
- package/docs/getting-started.md +112 -0
- package/docs/index.md +48 -0
- package/docs/specs/README.md +71 -0
- package/package.json +9 -9
- package/schemas/repo-context.schema.json +796 -0
- package/src/docs/README.md +498 -0
|
@@ -0,0 +1,498 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: Module Spec
|
|
3
|
+
title: 'Locus plugin specification'
|
|
4
|
+
description: Responsibilities, boundaries, design, invariants, and verification for the Locus internal plugin module.
|
|
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-cowork
|
|
11
|
+
approved_by: akulakum@cisco.com
|
|
12
|
+
updated_at: 2026-11-12T10:59:20Z
|
|
13
|
+
validation_status: pass-with-warnings
|
|
14
|
+
-->
|
|
15
|
+
|
|
16
|
+
# Locus plugin
|
|
17
|
+
|
|
18
|
+
This source-local document at `src/docs/README.md` owns the stable specification for **the Locus
|
|
19
|
+
plugin**: the `webex.internal.locus` client for the Locus call and meeting state service. Ground
|
|
20
|
+
every claim in package evidence and link to the [package architecture](../../docs/architecture.md)
|
|
21
|
+
instead of repeating broader facts. No service specification exists because this package is a
|
|
22
|
+
library.
|
|
23
|
+
|
|
24
|
+
Related context: [documentation index](../../docs/index.md) ·
|
|
25
|
+
[package agent instructions](../../AGENTS.md)
|
|
26
|
+
|
|
27
|
+
## Metadata
|
|
28
|
+
|
|
29
|
+
| Field | Value |
|
|
30
|
+
| ----------------- | ----- |
|
|
31
|
+
| Owner | @webex/web-sdk (CODEOWNERS default rule) |
|
|
32
|
+
| Source path | `src` |
|
|
33
|
+
| Resource kind | package |
|
|
34
|
+
| Status | Draft |
|
|
35
|
+
| Last verified | 2026-10-09 at `e929b6a8bb` |
|
|
36
|
+
| Module id | `internal-plugin-locus` |
|
|
37
|
+
| Parent spec | — |
|
|
38
|
+
| Doc kind | Module spec |
|
|
39
|
+
| Coverage score | 93.3% assessed 2026-10-09 — 14 of 15 mandatory fields PRESENT, critical 8 of 8; test strategy is WEAK (gaps listed under Verification) and no characterization baseline exists |
|
|
40
|
+
| Validation status | pass-with-warnings; validator current-session, run `01a1cf57-d89e-7bc0-9a6a-d3345c695e50`, 2026-11-12; 0 Blocking; test coverage gaps remain |
|
|
41
|
+
|
|
42
|
+
## Applicability
|
|
43
|
+
|
|
44
|
+
| Condition ID | Status | Evidence or reason | Owned section |
|
|
45
|
+
| ------------------------------------ | ---------- | ------------------ | ------------- |
|
|
46
|
+
| `module.has_tiers` | N/A | No tier policy exists in this package or its `package.json` | Tier |
|
|
47
|
+
| `module.has_ui` | N/A | No view or screen. The module issues requests and compares data. | UI use-case flow |
|
|
48
|
+
| `module.crosses_service_boundaries` | Applicable | Every REST method in `src/locus.js` calls the Locus or Janus service through webex.request | Cross-boundary use-case flow |
|
|
49
|
+
| `module.holds_client_state` | N/A | `src/locus.js` defines no props, session, or derived state. Callers hold the Locus working copy. | Client state model |
|
|
50
|
+
| `module.enforces_domain_rules` | Applicable | The Locus sequence comparison and delta merge rules in `src/locus.js` | Business rules and invariants |
|
|
51
|
+
| `module.is_concurrent_async` | Applicable | Promise-returning REST methods, a second request after a WebexHttpError.Conflict rejection, and caller-driven ordering of out-of-order Locus DTOs | Concurrency and reactive flow |
|
|
52
|
+
| `module.owns_persistence` | N/A | Nothing is stored. Results are returned to the caller. | Data, schema, and migration discipline |
|
|
53
|
+
| `module.stateful_transitions` | N/A | The module keeps no state between calls; participant and call states belong to the Locus service | State machine |
|
|
54
|
+
| `module.exposes_wire_protocol` | Applicable | Request bodies, the JSON-string localSdp, the Locus sequence object, and the delta DTO fields read in `src/locus.js` | Protocol and wire format |
|
|
55
|
+
| `module.ui_multi_screen` | N/A | No UI | UI flow |
|
|
56
|
+
| `module.large_data_model` | N/A | The Locus DTO is passed through, not modelled. Only the sequence object and a few fields are read. | Data model |
|
|
57
|
+
| `module.returns_caller_errors` | Applicable | Synchronous throws for missing arguments and promise rejections from webex.request | Caller-visible failure modes |
|
|
58
|
+
| `module.module_specific_conventions` | Applicable | Device URL and sequence in request bodies per INV-007, resolving the response body or a documented field (sendDtmf excepted), and Conflict-to-GET recovery | Module-specific rules |
|
|
59
|
+
| `module.published_package` | Applicable | `package.json` names the package @webex/internal-plugin-locus and deploy:npm publishes it | Export stability |
|
|
60
|
+
| `module.embedded_in_host` | N/A | No host theme or embed API | Host integration and theming |
|
|
61
|
+
| `module.has_design_tradeoff` | Applicable | Stateless compare and merge, Conflict recovery by GET, and per-call memoization | Key design trade-off |
|
|
62
|
+
| `module.has_submodules` | N/A | Computed false by the Repo Annotation module_tree.py script: the manifest has one module | Sub-modules |
|
|
63
|
+
|
|
64
|
+
## Evidence register
|
|
65
|
+
|
|
66
|
+
| Evidence | What it establishes |
|
|
67
|
+
| -------- | ------------------- |
|
|
68
|
+
| `src/index.js` | Mercury side-effect import, internal plugin registration as `locus`, and the public exports |
|
|
69
|
+
| `src/locus.js` | The `Locus` plugin: sequence constants, `compareToAction`, every public method, and the request bodies |
|
|
70
|
+
| `src/event-keys.js` | The exported list of Locus event names |
|
|
71
|
+
| `package.json` | Name, entry points, dependencies, and scripts |
|
|
72
|
+
| `test/unit/spec/locus.js` | Fixture-driven cases for `compareSequence` and `compare` against a `MockWebex` instance |
|
|
73
|
+
| `test/unit/lib/BasicSeqCmp.json` | 88 basic `compareSequence` comparisons |
|
|
74
|
+
| `test/unit/lib/SeqCmp.json` | 25 `compareSequence` comparisons, 21 `compare` update actions, and the descriptions of the ACCEPT_NEW, KEEP_CURRENT, and DESYNC actions |
|
|
75
|
+
| Sibling package webex-core, file src/lib/webex-plugin.js | `WebexPlugin#request` delegates to `webex.request` |
|
|
76
|
+
| Sibling package webex-core, file src/interceptors/auth.js | The authorization header is added when the credentials check passes (catalog service, the u2c service, or an allowed domain while services.validateDomains is on, its default), unless a header or `auth` option is already present |
|
|
77
|
+
| Sibling package webex-core, files src/webex-core.js and src/config.js | The default interceptor set, its replacement by a host-supplied `config.interceptors`, and the `validateCatalogUrls`, `validateDomains`, `maxAuthenticationReplays`, `maxAppLevelRedirects`, and `maxLocusRedirects` defaults, which host config can override |
|
|
78
|
+
| Sibling package webex-core, files src/interceptors/catalog-url.js and src/interceptors/redirect.js | The opt-in catalog URL rejection, and the three redirect forms that share one redirect counter per call |
|
|
79
|
+
| Sibling package http-core, file src/http-error-subtypes.js | Builds the subtype tree in which `Conflict` (409) extends `BadRequest` |
|
|
80
|
+
| Sibling package webex-core, file src/lib/webex-http-error.js | Applies that subtype tree to `WebexHttpError`, giving `WebexHttpError.Conflict` |
|
|
81
|
+
| Sibling package internal-plugin-mercury, SDD module spec src/docs/README.md | The Mercury plugin registered by the side-effect import |
|
|
82
|
+
| Sibling package internal-plugin-lyra, files package.json and test/integration/spec/space.js | Consumer evidence for Purpose and boundary |
|
|
83
|
+
| Product README | Retained product documentation, not the behavioral authority. See ADR 0001. |
|
|
84
|
+
|
|
85
|
+
## Purpose and boundary
|
|
86
|
+
|
|
87
|
+
- Responsibility: give SDK code one place to call the Locus REST operations for a call or meeting,
|
|
88
|
+
and to decide how an incoming Locus DTO relates to the copy the caller already holds.
|
|
89
|
+
- In scope: the `Locus` plugin in `src/locus.js`, its REST wrappers, the sequence comparison and
|
|
90
|
+
delta merge functions, the seven exported comparison constants, the `eventKeys` list, and the
|
|
91
|
+
registration side effect in `src/index.js`.
|
|
92
|
+
- Out of scope: holding or updating a Locus working copy (the caller does this), receiving Locus
|
|
93
|
+
events from Mercury (the package subscribes to none), HTTP transport, authorization, and error
|
|
94
|
+
classes (sibling packages webex-core and http-core), device registration (sibling package
|
|
95
|
+
internal-plugin-device), and the Mercury connection (sibling package internal-plugin-mercury).
|
|
96
|
+
- Consumers: code that reaches `webex.internal.locus`, and importers of the package barrel. In this
|
|
97
|
+
workspace only the sibling package internal-plugin-lyra lists the package, and only its
|
|
98
|
+
integration spec imports it.
|
|
99
|
+
|
|
100
|
+
## Structure and key files
|
|
101
|
+
|
|
102
|
+
| Path | Responsibility |
|
|
103
|
+
| ---- | -------------- |
|
|
104
|
+
| `src/index.js` | Imports `@webex/internal-plugin-mercury` for its side effect, calls `registerInternalPlugin('locus', Locus)`, and re-exports `Locus`, `eventKeys`, and the seven constants |
|
|
105
|
+
| `src/locus.js` | Constants, the private `compareToAction` mapper, and the `Locus` plugin built with `WebexPlugin.extend` and namespace `Locus` |
|
|
106
|
+
| `src/event-keys.js` | `locusEventKeys` array, exported as named and default |
|
|
107
|
+
| `test/unit/spec/locus.js` | The only spec. Generates one test case per fixture entry and calls `compareSequence` or `compare` |
|
|
108
|
+
| `test/unit/lib/BasicSeqCmp.json` | Basic sequence fixtures |
|
|
109
|
+
| `test/unit/lib/SeqCmp.json` | Sequence and update-action fixtures |
|
|
110
|
+
|
|
111
|
+
## Public surface
|
|
112
|
+
|
|
113
|
+
Declarations live in `src/index.js` and `src/locus.js`. This section summarises them and does not
|
|
114
|
+
restate signatures.
|
|
115
|
+
|
|
116
|
+
| Surface | Consumer | Compatibility commitment | Source |
|
|
117
|
+
| ------- | -------- | ------------------------ | ------ |
|
|
118
|
+
| Registration side effect | Every importer | Importing installs `webex.internal.locus` on instances constructed afterwards (`MOD-001`) | `src/index.js` |
|
|
119
|
+
| Sequence constants | Callers of `compare` and `compareSequence` | String values equal their names (`MOD-002`) | `src/locus.js` |
|
|
120
|
+
| `eventKeys` | Callers that subscribe to Locus events themselves | List of event type names (`MOD-018`) | `src/event-keys.js` |
|
|
121
|
+
| `compareSequence(current, incoming)` | Callers comparing raw sequence objects | Returns a comparison result (`MOD-003`) | `src/locus.js` |
|
|
122
|
+
| `compare(current, incoming)`, `compareDelta(current, incoming)` | Callers applying Locus DTOs | Returns an action (`MOD-004`, `MOD-005`); `compareDelta` is JSDoc-private | `src/locus.js` |
|
|
123
|
+
| `merge(current, incoming)` | Callers applying Locus DTOs | Returns the next working copy (`MOD-006`) | `src/locus.js` |
|
|
124
|
+
| `create`, `join`, `createOrJoin` | Call setup code | Resolve the Locus with per-device `mediaConnections` (`MOD-007` to `MOD-009`); `createOrJoin` is JSDoc-private | `src/locus.js` |
|
|
125
|
+
| `alert`, `decline`, `leave`, `updateMedia`, `sendDtmf` | Call control code | Participant and media operations (`MOD-010` to `MOD-012`, `MOD-015`, `MOD-017`) | `src/locus.js` |
|
|
126
|
+
| `get`, `list`, `sync`, `getCallHistory` | Readers | Read operations (`MOD-013`, `MOD-014`) | `src/locus.js` |
|
|
127
|
+
| `requestFloorGrant`, `releaseFloorGrant` | Content-share code | Floor operations on a media share (`MOD-016`) | `src/locus.js` |
|
|
128
|
+
|
|
129
|
+
Contract `locus-sdk` is published with native artifact `package.json`. Required contracts:
|
|
130
|
+
`locus-service-http`, `janus-history-http`, `webex-core-plugin-host`, `webex-device-registration`,
|
|
131
|
+
`mercury-sdk`, `lodash`, and `uuid`.
|
|
132
|
+
|
|
133
|
+
## Dependencies
|
|
134
|
+
|
|
135
|
+
| Dependency | Why it is required | Failure behavior |
|
|
136
|
+
| ---------- | ------------------ | ---------------- |
|
|
137
|
+
| `@webex/webex-core` (`webex-core-plugin-host`) | `WebexPlugin`, `registerInternalPlugin`, `request`, and `WebexHttpError.Conflict` | webex-core's default interceptor set includes `HttpStatusInterceptor`, which converts error statuses to the `WebexHttpError` subtypes built by the sibling package http-core, except 404 responses whose body has Locus `errorCode` 2000002 or App API `code` 404100, which it passes on unconverted. webex-core's redirect interceptor then decides the outcome: it can re-issue the request (for a `cisco-location` header or a body redirect target), reject (for example at the redirect limit), or return the 404 response unchanged, in which case the call resolves (see Caller-visible failure modes); other interceptors in the set can still reject with their own plain errors (rows below), and the catalog check and redirects behave as the architecture Security architecture describes. A host-supplied `config.interceptors` set replaces the defaults: without `HttpStatusInterceptor` that conversion is absent, and whether an error status resolves or rejects, and with which error, depends on the interceptors the host lists. `INV-006` applies only when the rejection is a `WebexHttpError.Conflict` |
|
|
138
|
+
| Locus service (`locus-service-http`) | Every call and participant operation | Rejections propagate, except a `WebexHttpError.Conflict` rejection on `decline` and `leave` (`INV-006`; see the webex-core row) |
|
|
139
|
+
| Janus service (`janus-history-http`) | `getCallHistory` | Rejections propagate |
|
|
140
|
+
| `webex.internal.device` (`webex-device-registration`) | `url` sent as the device URL (`INV-007`) | Not a declared dependency; it is registered transitively because the Mercury index imports the device plugin (sibling package internal-plugin-mercury, file src/index.js). If it is absent, reading `url` throws a TypeError synchronously, before any request. If it is present but `url` is unset (no registration in this session and no persisted value), so request bodies omit `deviceUrl` (and the floor beneficiary device has no `url`) and the request is still sent; register the device before calling these methods |
|
|
141
|
+
| `@webex/internal-plugin-mercury` (`mercury-sdk`) | Side-effect import only; it brings in the device plugin above | Load-time only; Locus calls no Mercury API |
|
|
142
|
+
| `lodash` | `cloneDeep`, `difference`, `first`, `last`, `memoize` | — |
|
|
143
|
+
| `uuid` | `v4` for the DTMF correlation id | — |
|
|
144
|
+
| `@webex/test-helper-chai`, `@webex/test-helper-mock-webex` | Listed under `dependencies` and `devDependencies` but imported only by `test/` | — |
|
|
145
|
+
|
|
146
|
+
## Requirements
|
|
147
|
+
|
|
148
|
+
| ID | WHAT | WHY | Source evidence | Test or example evidence | Assumptions or gaps | Confidence |
|
|
149
|
+
| -- | ---- | --- | --------------- | ------------------------ | ------------------- | ---------- |
|
|
150
|
+
| `MOD-001` | Importing the package imports the Mercury plugin and registers `Locus` as internal plugin `locus` with no config or hooks. | Webex instances constructed after the package is imported get `webex.internal.locus`; registration only adds the plugin to the internal core prototype, so an instance constructed earlier does not gain it. If a plugin named `locus` is already registered, registration is a no-op. | `src/index.js` | none found; the unit spec mounts Locus as a MockWebex child instead | — | Present |
|
|
151
|
+
| `MOD-002` | The barrel exports `Locus` as default, `eventKeys`, and the constants `USE_INCOMING`, `USE_CURRENT`, `EQUAL`, `FETCH`, `GREATER_THAN`, `LESS_THAN`, `DESYNC`, each equal to its own name. | Callers compare results against the exported names. | `src/index.js`, `src/locus.js` | `test/unit/spec/locus.js` imports Locus, DESYNC, USE_INCOMING, USE_CURRENT, FETCH from the package; the fixture strings check the values of EQUAL, GREATER_THAN, LESS_THAN, and DESYNC | The values of `USE_INCOMING`, `USE_CURRENT`, and `FETCH` are not asserted; the spec compares against the imported constants | Present |
|
|
152
|
+
| `MOD-003` | `compareSequence` throws when either argument is missing, and otherwise returns `LESS_THAN`, `GREATER_THAN`, `EQUAL`, or `DESYNC` by the algorithm in `INV-003` and `INV-004`. | Locus sends sequences as ranges plus entries; clients must order DTOs without the server. | `src/locus.js` | `test/unit/spec/locus.js` "basic sequence comparisons" and "sequence comparisons" | No test for the missing-argument throws | Present |
|
|
153
|
+
| `MOD-004` | `compare` returns `USE_INCOMING` when either sequence is empty (`INV-002`), delegates to `compareDelta` when `incoming.baseSequence` is set, and otherwise maps the `compareSequence` result by `INV-001`. | Gives the caller one action per incoming DTO. | `src/locus.js` | `test/unit/spec/locus.js` "delta sequence comparisons" (updt5 to updt7 and updt10 to updt15 have no base) | — | Present |
|
|
154
|
+
| `MOD-005` | `compareDelta` maps a non-`LESS_THAN` result by `INV-001`. When `incoming.sequence` is newer, it compares the current sequence with `incoming.baseSequence`: `GREATER_THAN` or `EQUAL` gives `USE_INCOMING`; anything else gives `FETCH`. | A delta can only be applied to a working copy at or past its base. | `src/locus.js` | `test/unit/spec/locus.js` "delta sequence comparisons" (updt1 to updt4, updt8, updt9, updt18, updt19, updt21, updt23, updt24) | — | Present |
|
|
155
|
+
| `MOD-006` | `merge` returns `incoming` unchanged when it has no `baseSequence`. Otherwise it returns a deep clone of `current` with the delta applied by `INV-005`. | The fixture description of ACCEPT_NEW: merge a delta, replace with a full DTO. | `src/locus.js`, `test/unit/lib/SeqCmp.json` | none found | See Pitfalls for the missing-`participants` throw and falsy values | Present |
|
|
156
|
+
| `MOD-007` | `create` throws synchronously without `options.correlationId`, sends the `create` request, sets each `locus.self.devices[i].mediaConnections` to `[mediaConnections[i]]` from the response, and resolves `body.locus`. | `body.mediaConnections` is deprecated per the source comment; callers read it from the device. | `src/locus.js` | none found | — | Present |
|
|
157
|
+
| `MOD-008` | `join` takes `correlationId` from the Locus, else from `options`, and throws synchronously without one. It sends the `join` request and resolves like `MOD-007`. | Joins an existing Locus with local media. | `src/locus.js` | none found | — | Present |
|
|
158
|
+
| `MOD-009` | `createOrJoin` calls `join` when `target.url` is set, else `create`. | Lets one call path dial a user or join a Locus. The JSDoc says it serves the phone plugin. | `src/locus.js` | none found | — | Present |
|
|
159
|
+
| `MOD-010` | `alert` sends the `alert` request and resolves the response body. | Tells Locus the local user has been notified of the Locus's active state, per the JSDoc. | `src/locus.js` | none found | — | Present |
|
|
160
|
+
| `MOD-011` | `decline` sends the `decline` request and resolves the body. A Conflict is recovered by `INV-006`; other request rejections propagate. | On a Conflict the caller gets the GET result instead of an error (the 409 meaning is assumed; see `INV-006`). | `src/locus.js` | none found | — | Present |
|
|
161
|
+
| `MOD-012` | `leave` sends the `leave` request and resolves `body.locus`. A Conflict is recovered by `INV-006`; other request rejections propagate. | Same as `MOD-011` for leaving. | `src/locus.js` | none found | — | Present |
|
|
162
|
+
| `MOD-013` | `get` resolves the body of a GET on `locus.url`; `list` resolves `body.loci` from the `list` request; `sync` resolves the body of a GET on `locus.syncUrl`, or `{}` when the body is empty. | `sync` returns a delta that the caller passes to `compare` and `merge`; it does not merge. | `src/locus.js` | none found | The `{}` case follows the source comment about 204 No Content | Present |
|
|
163
|
+
| `MOD-014` | `getCallHistory` sends the `call history` request with `from` as the ISO string of `options.from`, or of now when `options.from` is falsy, and resolves the body. | Lists the user's recent sessions. | `src/locus.js` | none found | — | Present |
|
|
164
|
+
| `MOD-015` | `updateMedia` sends the `media update` request and resolves `body.locus`. | Starts or stops sending audio or video, or offers a new SDP. | `src/locus.js` | none found | The JSDoc names `options.localSdp`, but the code reads `sdp` (see Pitfalls) | Present |
|
|
165
|
+
| `MOD-016` | `requestFloorGrant` and `releaseFloorGrant` send the `floor` requests to `share.url` and resolve the body. `releaseFloorGrant` does not use its `locus` argument. | Start and stop an additional shared media stream. | `src/locus.js` | none found | — | Present |
|
|
166
|
+
| `MOD-017` | `sendDtmf` sends the `DTMF` request with a new `uuid.v4()` correlation id and resolves the whole response, not its body. | Plays tones into the call. | `src/locus.js` | none found | — | Present |
|
|
167
|
+
| `MOD-018` | `eventKeys` lists 17 Locus event type names (listed under Protocol and wire format). The package does not subscribe to them. | Callers that listen on Mercury get this package's fixed list of 17 names from one export. It is not an exhaustive list of Locus event types; other workspace packages handle Locus events that it omits. | `src/event-keys.js` | none found | No in-package consumer | Present |
|
|
168
|
+
|
|
169
|
+
## Design overview
|
|
170
|
+
|
|
171
|
+
`Locus` is created with `WebexPlugin.extend` and has no props, session, or derived state. Every
|
|
172
|
+
public method is either a REST wrapper or a pure function over caller-supplied data.
|
|
173
|
+
|
|
174
|
+
The REST wrappers share one shape: build a request with either a catalog service plus resource or an
|
|
175
|
+
absolute URL taken from the Locus DTO, add `deviceUrl` and the caller's sequence where the operation
|
|
176
|
+
needs them (`INV-007`), call `this.request` (which delegates to `webex.request`; the floor methods
|
|
177
|
+
call `this.webex.request` directly), and resolve the response body or one field of it, or the
|
|
178
|
+
whole response for `sendDtmf` (`MOD-017`). The only error handling in the module is the Conflict
|
|
179
|
+
recovery of `INV-006`.
|
|
180
|
+
|
|
181
|
+
The comparison functions implement Locus sequencing. `compareSequence` orders two sequence objects;
|
|
182
|
+
`compare` and `compareDelta` turn that order into one of three actions, and `merge` builds the
|
|
183
|
+
next working copy; the caller's loop is the Sequence reconciliation diagram. Keeping these pure
|
|
184
|
+
lets a caller, not the plugin, decide where the working copy lives. The JSON fixtures under `test/unit/lib` are the executable reference
|
|
185
|
+
for the algorithm.
|
|
186
|
+
|
|
187
|
+
`src/index.js` imports the Mercury plugin before registering; why that import matters is recorded
|
|
188
|
+
under Dependencies.
|
|
189
|
+
|
|
190
|
+
## Data flow and sequence coverage
|
|
191
|
+
|
|
192
|
+
Transport: HTTP through `webex.request` to the Locus and Janus services; in-process synchronous calls
|
|
193
|
+
for comparison and merge.
|
|
194
|
+
|
|
195
|
+
| Operation group | Entry and outcome | Diagram or evidence | Failure and recovery coverage |
|
|
196
|
+
| --------------- | ----------------- | ------------------- | ----------------------------- |
|
|
197
|
+
| Call setup | `create`, `join`, `createOrJoin` → Locus with per-device `mediaConnections` | Call setup diagram below | Synchronous throw without `correlationId`; HTTP rejection |
|
|
198
|
+
| Participant and media updates | `alert`, `decline`, `leave`, `updateMedia`, `sendDtmf`, floor requests → body, `body.locus`, or the whole response for `sendDtmf` | Participant and media updates diagram below | Conflict recovery for `decline` and `leave`; other rejections |
|
|
199
|
+
| Reads | `get`, `list`, `sync`, `getCallHistory` → body, `body.loci` for `list`, or `{}` for an empty `sync` body | Reads diagram below | Empty `sync` body; truthy invalid `from`; HTTP rejection |
|
|
200
|
+
| Sequence reconciliation | `compare` → action → `merge` or fetch | Sequence reconciliation diagram below | `FETCH` path; can throw for malformed data |
|
|
201
|
+
|
|
202
|
+
Call setup:
|
|
203
|
+
|
|
204
|
+
```mermaid
|
|
205
|
+
sequenceDiagram
|
|
206
|
+
participant Caller
|
|
207
|
+
participant Locus
|
|
208
|
+
participant Request as webex.request
|
|
209
|
+
participant Service as Locus service
|
|
210
|
+
Caller->>Locus: createOrJoin(target, options)
|
|
211
|
+
alt target.url set
|
|
212
|
+
Locus->>Locus: join(target, options)
|
|
213
|
+
else no url
|
|
214
|
+
Locus->>Locus: create(target, options)
|
|
215
|
+
end
|
|
216
|
+
alt no correlationId
|
|
217
|
+
Locus-->>Caller: throws synchronously
|
|
218
|
+
else correlationId present
|
|
219
|
+
Locus->>Request: POST loci/call or locus.url/participant
|
|
220
|
+
Request->>Service: request with deviceUrl, localMedias, sequence
|
|
221
|
+
alt success
|
|
222
|
+
Service-->>Locus: response body, code reads locus and mediaConnections
|
|
223
|
+
Locus->>Locus: copy mediaConnections onto self.devices
|
|
224
|
+
Locus-->>Caller: resolve body.locus
|
|
225
|
+
else request rejected (see Dependencies)
|
|
226
|
+
Request-->>Caller: reject with a WebexHttpError subtype or an interceptor error
|
|
227
|
+
end
|
|
228
|
+
end
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
Participant and media updates:
|
|
232
|
+
|
|
233
|
+
```mermaid
|
|
234
|
+
sequenceDiagram
|
|
235
|
+
participant Caller
|
|
236
|
+
participant Locus
|
|
237
|
+
participant Request as webex.request
|
|
238
|
+
participant Service as Locus service
|
|
239
|
+
Caller->>Locus: decline, leave, alert, updateMedia, sendDtmf, or floor request
|
|
240
|
+
Locus->>Request: PUT or POST to a URL from the Locus or share
|
|
241
|
+
Request->>Service: body with deviceUrl and sequence where required
|
|
242
|
+
alt success
|
|
243
|
+
Service-->>Locus: response
|
|
244
|
+
Locus-->>Caller: resolve body, body.locus, or the whole response for sendDtmf
|
|
245
|
+
else WebexHttpError.Conflict on decline or leave
|
|
246
|
+
Locus->>Request: GET locus.url
|
|
247
|
+
Request->>Service: GET
|
|
248
|
+
alt GET succeeds
|
|
249
|
+
Service-->>Locus: GET body
|
|
250
|
+
Locus-->>Caller: resolve current Locus
|
|
251
|
+
else GET fails
|
|
252
|
+
Request-->>Caller: reject with the GET error
|
|
253
|
+
end
|
|
254
|
+
else other error
|
|
255
|
+
Request-->>Caller: reject
|
|
256
|
+
end
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
Reads:
|
|
260
|
+
|
|
261
|
+
```mermaid
|
|
262
|
+
sequenceDiagram
|
|
263
|
+
participant Caller
|
|
264
|
+
participant Locus
|
|
265
|
+
participant Request as webex.request
|
|
266
|
+
participant LocusSvc as Locus service
|
|
267
|
+
participant Janus as Janus service
|
|
268
|
+
Caller->>Locus: get, list, or sync
|
|
269
|
+
Locus->>Request: GET locus.url, loci, or locus.syncUrl
|
|
270
|
+
Request->>LocusSvc: GET
|
|
271
|
+
alt sync with no body
|
|
272
|
+
LocusSvc-->>Locus: empty response
|
|
273
|
+
Locus-->>Caller: resolve empty object
|
|
274
|
+
else body present
|
|
275
|
+
LocusSvc-->>Locus: body
|
|
276
|
+
Locus-->>Caller: resolve body or body.loci
|
|
277
|
+
else request rejected (see Dependencies)
|
|
278
|
+
Request-->>Caller: reject with a WebexHttpError subtype or an interceptor error
|
|
279
|
+
end
|
|
280
|
+
Caller->>Locus: getCallHistory(options)
|
|
281
|
+
alt truthy from that builds an invalid Date
|
|
282
|
+
Locus-->>Caller: throws RangeError synchronously
|
|
283
|
+
else valid from
|
|
284
|
+
Locus->>Request: GET history/userSessions with from
|
|
285
|
+
Request->>Janus: GET
|
|
286
|
+
alt success
|
|
287
|
+
Janus-->>Locus: body
|
|
288
|
+
Locus-->>Caller: resolve body
|
|
289
|
+
else request rejected (see Dependencies)
|
|
290
|
+
Request-->>Caller: reject with a WebexHttpError subtype or an interceptor error
|
|
291
|
+
end
|
|
292
|
+
end
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
Sequence reconciliation, run by the caller for each incoming Locus DTO:
|
|
296
|
+
|
|
297
|
+
```mermaid
|
|
298
|
+
flowchart TD
|
|
299
|
+
start[Incoming Locus DTO] --> cmp[compare current and incoming]
|
|
300
|
+
cmp -->|USE_INCOMING| mrg[merge current and incoming]
|
|
301
|
+
mrg --> keep[Caller stores the result]
|
|
302
|
+
cmp -->|USE_CURRENT| ignore[Caller ignores the DTO]
|
|
303
|
+
cmp -->|FETCH| fetch[Caller calls sync or get]
|
|
304
|
+
fetch --> cmp
|
|
305
|
+
cmp -->|malformed sequence| err[may throw TypeError]
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
## Class and component relationships
|
|
309
|
+
|
|
310
|
+
```mermaid
|
|
311
|
+
classDiagram
|
|
312
|
+
class WebexPlugin {
|
|
313
|
+
+webex
|
|
314
|
+
+request(options)
|
|
315
|
+
}
|
|
316
|
+
class Locus {
|
|
317
|
+
+compare(current, incoming)
|
|
318
|
+
+compareSequence(current, incoming)
|
|
319
|
+
+merge(current, incoming)
|
|
320
|
+
+create(invitee, options)
|
|
321
|
+
+join(locus, options)
|
|
322
|
+
+leave(locus)
|
|
323
|
+
+sync(locus)
|
|
324
|
+
}
|
|
325
|
+
class WebexHttpError
|
|
326
|
+
class BadRequest
|
|
327
|
+
class Conflict
|
|
328
|
+
WebexPlugin <|-- Locus
|
|
329
|
+
WebexHttpError <|-- BadRequest
|
|
330
|
+
BadRequest <|-- Conflict
|
|
331
|
+
Locus ..> Conflict : recovers decline and leave
|
|
332
|
+
Locus ..> compareToAction : maps comparison results
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
| Component | Relationship |
|
|
336
|
+
| --------- | ------------ |
|
|
337
|
+
| `Locus` | Plugin holding every public method; extends `WebexPlugin` |
|
|
338
|
+
| `compareToAction` | Module-private function in `src/locus.js` used by `compare` and `compareDelta` |
|
|
339
|
+
| `WebexHttpError.Conflict` | 409 subtype from the sibling package webex-core, checked with `instanceof` |
|
|
340
|
+
| `locusEventKeys` | Plain array in `src/event-keys.js`, unrelated to the plugin at runtime |
|
|
341
|
+
|
|
342
|
+
## Use cases and flows
|
|
343
|
+
|
|
344
|
+
| Use case | Actor or caller | Primary steps and outcome | Failure or boundary behavior | Evidence |
|
|
345
|
+
| -------- | --------------- | ------------------------- | ---------------------------- | -------- |
|
|
346
|
+
| `UC-001` | Call setup code | Calls `createOrJoin` with a user identifier and `{correlationId, localSdp}`; `create` posts the call and resolves the new Locus | See Caller-visible failure modes | `src/locus.js` |
|
|
347
|
+
| `UC-002` | Meeting join code | Calls `createOrJoin` with a Locus that has `url`; `join` posts to its participant URL | `correlationId` may come from the Locus | `src/locus.js` |
|
|
348
|
+
| `UC-003` | Code applying a Locus event | Runs the loop in the Sequence reconciliation diagram for each incoming DTO and stores the result | `compare` and `merge` can throw on malformed data (see Pitfalls) | `src/locus.js`, `test/unit/spec/locus.js`, `test/unit/lib/SeqCmp.json` |
|
|
349
|
+
| `UC-004` | Call control code | Calls `leave(locus)` the request rejects with a `WebexHttpError.Conflict` (assumed to mean the call state changed) and `INV-006` applies | Other request rejections propagate; see Dependencies | `src/locus.js` |
|
|
350
|
+
| `UC-005` | Content-share code | Calls `requestFloorGrant(locus, share)` and later `releaseFloorGrant(locus, share)` | Rejections propagate | `src/locus.js` |
|
|
351
|
+
| `UC-006` | Caller of `getCallHistory` | Calls `getCallHistory({from})` and receives the Janus response body | See Caller-visible failure modes | `src/locus.js` |
|
|
352
|
+
|
|
353
|
+
### Cross-boundary use-case flow
|
|
354
|
+
|
|
355
|
+
| Boundary | Transport | Ordering | Timeout and retry | Recovery |
|
|
356
|
+
| -------- | --------- | -------- | ----------------- | -------- |
|
|
357
|
+
| Locus service | HTTP through `webex.request`, catalog service `locus` or DTO URLs | One request per call; one extra GET after a Conflict | No retry here; any retry or timeout is the webex-core request pipeline's | `INV-006` for `decline` and `leave`; others reject |
|
|
358
|
+
| Janus service | HTTP through `webex.request`, catalog service `janus` | One request | Same as above | Rejects |
|
|
359
|
+
| Device plugin | In-process property read | Read by every request that `INV-007` lists as carrying the device URL | None | None; see Dependencies |
|
|
360
|
+
| Caller-held Locus copy | In-process | One DTO at a time, per `UC-003` | None | Per `UC-003` |
|
|
361
|
+
|
|
362
|
+
## Business rules and invariants
|
|
363
|
+
|
|
364
|
+
| ID | Invariant | WHY | Enforcement source | Test evidence |
|
|
365
|
+
| -- | --------- | --- | ------------------ | ------------- |
|
|
366
|
+
| `INV-001` | Result to action: `EQUAL` and `GREATER_THAN` give `USE_CURRENT`, `LESS_THAN` gives `USE_INCOMING`, `DESYNC` gives `FETCH`; any other value throws. | Equal or older data must never replace the working copy; a desync must be resolved by a fetch. | `src/locus.js` compareToAction | `test/unit/spec/locus.js` "delta sequence comparisons" |
|
|
367
|
+
| `INV-002` | A sequence is empty when its `entries` is missing or empty and both `rangeStart` and `rangeEnd` are 0. If either side is empty, `compare` returns `USE_INCOMING`. | An empty sequence carries no ordering, so the incoming DTO is taken. | `src/locus.js` compare | `test/unit/spec/locus.js` "delta sequence comparisons" updt5, updt6, updt6b, updt7 |
|
|
368
|
+
| `INV-003` | Bounds: the first value is `rangeStart`, or the first entry when `rangeStart` is 0, or 0; the last value is the last entry, or `rangeEnd` when there are no entries. Current first above incoming last is `GREATER_THAN`; current last below incoming first is `LESS_THAN`. | Disjoint sequences are ordered by their bounds alone. | `src/locus.js` compareSequence | `test/unit/spec/locus.js` "basic sequence comparisons", "sequence comparisons" |
|
|
369
|
+
| `INV-004` | Overlap: entries in one sequence and not the other, and outside the other's range, are that side's only-entries. None on both sides compares `rangeEnd` minus first value (longer is greater, equal is `EQUAL`). Only one side having them makes that side greater. Both having them is `DESYNC` when all four range bounds are 0, or when an only-entry lies strictly inside the other side's bounds; otherwise the side with the larger first only-entry is greater. | Matches the Locus sequencing algorithm captured in the fixtures. | `src/locus.js` compareSequence | `test/unit/spec/locus.js` "basic sequence comparisons", "sequence comparisons" |
|
|
370
|
+
| `INV-005` | Delta merge: every key of the delta except `baseSequence` and `participants` replaces the clone's value when the delta value is truthy. Participants are keyed by `url`: entries with `removed` set are dropped, others replace or append. | Implements the delta rules written in the `merge` source comments. | `src/locus.js` merge | Gap: no test |
|
|
371
|
+
| `INV-006` | When `decline` or `leave` rejects with an instance of `WebexHttpError.Conflict`, the call resolves with `get(locus)` instead of rejecting. Other rejections, including a 409 that the host's interceptors do not convert to that class, propagate. | The code assumes a 409 means the Locus state changed, so it returns the result of a fresh GET instead of an error. What the Locus service means by a 409 is not defined in this repository. | `src/locus.js` decline, leave | Gap: no test |
|
|
372
|
+
| `INV-007` | `create`, `join`, `alert`, `decline`, `leave`, `updateMedia`, and `sendDtmf` send a top-level `deviceUrl` equal to `webex.internal.device.url`; `requestFloorGrant` nests it in the beneficiary devices; `releaseFloorGrant` sends none. `alert`, `decline`, `leave`, and `updateMedia` send `locus.sequence`; `join` sends it or an empty sequence; `create` always sends an empty sequence; `sendDtmf` and the floor requests send no sequence. A key whose value is undefined (an unset device URL or a missing `locus.sequence`) is left out of the serialized body. | The listed operations include device and sequence context exactly as enumerated in this invariant. How the service uses the sequence (for example rejecting stale requests) is service behavior not defined in this repository. | `src/locus.js` | Gap: no test |
|
|
373
|
+
|
|
374
|
+
## Concurrency and reactive flow
|
|
375
|
+
|
|
376
|
+
- Execution model: single JavaScript event loop. REST methods return promises from
|
|
377
|
+
`webex.request`; `compare`, `compareSequence`, `compareDelta`, and `merge` are synchronous.
|
|
378
|
+
- Ordering guarantees: none across calls. Out-of-order Locus DTOs are ordered by the caller, as
|
|
379
|
+
`UC-003` describes.
|
|
380
|
+
- Idempotency and retry: no retry or deduplication in this module. `decline` and `leave` issue one
|
|
381
|
+
follow-up GET after a Conflict (`INV-006`). `sendDtmf` creates a new correlation id per call, so
|
|
382
|
+
repeated calls are distinct requests.
|
|
383
|
+
- Shared-state protection: not needed (see Design overview); `merge` never mutates `current`
|
|
384
|
+
(`MOD-006`).
|
|
385
|
+
- Blocking restrictions: none beyond the synchronous comparison and merge noted under Execution
|
|
386
|
+
model.
|
|
387
|
+
|
|
388
|
+
## Protocol and wire format
|
|
389
|
+
|
|
390
|
+
| Message or frame | Version | Producer or serializer | Consumer or parser | Compatibility and ordering rule |
|
|
391
|
+
| ---------------- | ------- | ---------------------- | ------------------ | ------------------------------- |
|
|
392
|
+
| Locus sequence | Unversioned | Locus service | `src/locus.js` `compareSequence` | Object with `entries` (numbers; the code assumes ascending order and does not check it), `rangeStart`, and `rangeEnd`. Emptiness is defined by `INV-002`. |
|
|
393
|
+
| Locus delta DTO | Unversioned | Locus service | `src/locus.js` `compare`, `merge` | A DTO with `baseSequence` is a delta. Its `participants` items carry `url` and optional `removed`. |
|
|
394
|
+
| `create` request | Unversioned | `src/locus.js` | Locus service | POST service `locus` resource loci/call; body `correlationId`, `invitee: {invitee}`, `localMedias: [{localSdp}]`, plus device URL and sequence per `INV-007`. The code expects a response `{locus, mediaConnections}`; that shape is not defined in this repository. |
|
|
395
|
+
| `join` request | Unversioned | `src/locus.js` | Locus service | POST {locus.url}/participant; body as `create` without `invitee`; sequence per `INV-007`. Same response. |
|
|
396
|
+
| `localSdp` field | Unversioned | `src/locus.js` | Locus service | A JSON string, not an object: `{"type":"SDP","sdp":…}` for create and join; `updateMedia` adds `audioMuted` and `videoMuted` and includes `type` and `sdp` only when `sdp` is truthy. Because the field is built with `JSON.stringify`, keys whose values are undefined are omitted: no `sdp` key when `localSdp` or `sdp` is not passed, and no `audioMuted` or `videoMuted` key when those are not passed. |
|
|
397
|
+
| `alert` and `decline` requests | Unversioned | `src/locus.js` | Locus service | PUT {locus.url}/participant/alert and /participant/decline; body holds only the `INV-007` fields. |
|
|
398
|
+
| `leave` request | Unversioned | `src/locus.js` | Locus service | PUT {locus.self.url}/leave; body holds only the `INV-007` fields. |
|
|
399
|
+
| `media update` request | Unversioned | `src/locus.js` | Locus service | PUT {locus.self.url}/media; body `localMedias: [{localSdp, mediaId}]` (`mediaId` is left out when undefined) plus the `INV-007` fields. |
|
|
400
|
+
| `DTMF` request | Unversioned | `src/locus.js` | Locus service | POST {locus.self.url}/sendDtmf; body `dtmf: {correlationId, tones}` plus the `INV-007` device URL. |
|
|
401
|
+
| `floor` requests | Unversioned | `src/locus.js` | Locus service | PUT {share.url}. Request: `floor` with `disposition: 'GRANTED'` and a `beneficiary` whose `url` is `locus.self.url` and whose devices hold the device URL (`INV-007`). Release: `floor: {disposition: 'RELEASED'}`. |
|
|
402
|
+
| `list` request | Unversioned | `src/locus.js` | Locus service | GET service `locus` resource loci; the code reads `body.loci`. |
|
|
403
|
+
| `call history` request | Unversioned | `src/locus.js` | Janus service | GET service `janus` resource history/userSessions with query `from`. |
|
|
404
|
+
| Locus event names in `eventKeys` (fixed subset) | Unversioned | `src/event-keys.js` | Callers subscribing to Mercury | `locus.summary`, `locus.self_changed`, `locus.participant_joined`, `locus.participant_left`, `locus.participant_declined`, `locus.participant_alerted`, `locus.participant_updated`, `locus.participant_roles_updated`, `locus.participant_audio_muted`, `locus.participant_audio_unmuted`, `locus.participant_video_muted`, `locus.participant_video_unmuted`, `locus.floor_granted`, `locus.floor_released`, `locus.space_users_modified`, `locus.controls_updated`, `locus.participant_controls_updated`. Adding is compatible; renaming is breaking. |
|
|
405
|
+
|
|
406
|
+
## Caller-visible failure modes
|
|
407
|
+
|
|
408
|
+
| Condition | Signal or result | Caller behavior | Retry or recovery | Evidence |
|
|
409
|
+
| --------- | ---------------- | --------------- | ----------------- | -------- |
|
|
410
|
+
| `create` without `options.correlationId` | Synchronous `Error('options.correlationId is required')`, not a rejected promise | Pass a correlation id; wrap in try or call inside a promise chain | None | `src/locus.js` |
|
|
411
|
+
| `join` with no correlation id on the Locus or options | Synchronous `Error('locus.correlationId or options.correlationId is required')` | Same as above | None | `src/locus.js` |
|
|
412
|
+
| `compareSequence` missing an argument | Throws `` `current` is required `` or `` `incoming` is required `` | Pass both sequences | None | `src/locus.js` |
|
|
413
|
+
| An error status converted by the default interceptor set (see Dependencies) | Promise rejects with the `WebexHttpError` subtype for the status | Inspect the class or status | None here | `src/locus.js` |
|
|
414
|
+
| A 404 with Locus `errorCode` 2000002 or App API `code` 404100 that webex-core's redirect interceptor returns unchanged instead of re-issuing (no truthy `cisco-location` header and no applicable body redirect target) | The promise resolves with the method's usual projection of that 404 body (`MOD-007` to `MOD-017`) instead of rejecting (webex-core behavior; see Dependencies). A projected field the body lacks is `undefined`; `create` and `join` reject with a TypeError when the body lacks the structure they read (see Pitfalls). The error-body shape is not defined in this repository | Check the result before applying it | None here | `src/locus.js` |
|
|
415
|
+
| A 401 that the webex-core auth interceptor treats as re-authenticable, with refreshable credentials, still failing after it refreshes and replays the request `maxAuthenticationReplays` times (default 1, host-configurable); a failing `credentials.refresh()` rejects with its own error instead | Promise rejects with a plain `Error` whose message starts `Failed after` and names the replay limit (webex-core behavior; see Evidence register) | Treat as an authentication problem | None here; the `decline` and `leave` Conflict recovery does not apply | `src/locus.js` |
|
|
416
|
+
| `CatalogUrlInterceptor` is active (see Dependencies) and a DTO or redirect URL is not a catalog service, and is not an allowed domain while `config.services.validateDomains` is on (its default) | Promise rejects with a plain `Error` (webex-core behavior; see Evidence register) whose message starts `Request blocked: URL not in service catalog or allowed domains`, before the request to that URL is sent (for a redirect, after the original response) | Treat as a configuration or DTO problem, not an HTTP status | None here; the `decline` and `leave` Conflict recovery does not apply | `src/locus.js` |
|
|
417
|
+
| A call's redirects, which share one counter, exceed the limit of the redirect form being handled: `maxAppLevelRedirects` (default 10) for `cisco-location` header redirects, `maxLocusRedirects` (default 5) for Locus `errorCode` 2000002 and App API `code` 404100 redirects; both limits are host-configurable. The limits are not guaranteed for a request whose counter webex-core's redirect interceptor never starts: it skips idbroker URLs, the configured credentials SAML, token, and authorize URLs, and requests that already carry the `cisco-no-http-redirect` header (sibling package webex-core, file src/interceptors/redirect.js) | Promise rejects with a plain `Error('Maximum redirects exceeded')` (webex-core behavior; see Evidence register) | Treat as a service or routing problem | None here | `src/locus.js` |
|
|
418
|
+
| `decline` or `leave` rejects with a `WebexHttpError.Conflict` | Resolves with the result of `get(locus)` (`INV-006`) | Treat as success with fresh state | A failed follow-up GET rejects with its own error | `src/locus.js` |
|
|
419
|
+
| `sync` returns no body | Resolves `{}` | Do not pass `{}` to `compare`; it has no sequence | Call `get` instead | `src/locus.js` |
|
|
420
|
+
| `getCallHistory` with a truthy `from` that builds an invalid Date | Synchronous RangeError from `toISOString` (a falsy `from`, including `NaN`, falls back to now per `MOD-014`) | Pass a date or millisecond number | None | `src/locus.js` |
|
|
421
|
+
|
|
422
|
+
## Pitfalls and constraints
|
|
423
|
+
|
|
424
|
+
- `merge` tests `incoming.participants || incoming.participants.length`. When a delta has no
|
|
425
|
+
`participants` key the right side runs and throws a TypeError, so every delta must carry a
|
|
426
|
+
`participants` array. The intended test was almost certainly `&&`. Found by code reading; no test.
|
|
427
|
+
- `merge` requires `current.participants` to be an array for any delta, because it calls `reduce` on
|
|
428
|
+
it.
|
|
429
|
+
- Because of the truthiness test in `INV-005`, a delta cannot set a field to `false`, `0`, or an
|
|
430
|
+
empty string; the old value is kept. The source comment speaks only of non-null values.
|
|
431
|
+
- `merge` keys participants by `url`; participants without `url` collapse into one entry.
|
|
432
|
+
- `compare` reads `locus.sequence` without a guard. A DTO without a sequence throws a TypeError
|
|
433
|
+
when that sequence is read; it does not throw when the current sequence is empty, because
|
|
434
|
+
`INV-002` returns `USE_INCOMING` before the incoming sequence is checked.
|
|
435
|
+
- A non-empty sequence (`INV-002`) without an `entries` array can throw a TypeError when
|
|
436
|
+
`compareSequence` computes its bounds (`INV-003`) and reads `entries.length`. An incoming
|
|
437
|
+
sequence without `entries` always throws there; a `baseSequence` without `entries` throws only
|
|
438
|
+
when it is compared, after the incoming sequence compares `LESS_THAN`. A current sequence without
|
|
439
|
+
`entries` throws unless its non-zero `rangeStart` exceeds the incoming last value, which returns
|
|
440
|
+
`GREATER_THAN` before the current entries are read.
|
|
441
|
+
- `create` and `join` mutate the response's `locus.self.devices` and assume `self.devices` and
|
|
442
|
+
`mediaConnections` exist. A missing `mediaConnections` makes the returned promise reject with a
|
|
443
|
+
TypeError once a device is mapped (an empty `self.devices` resolves without reading it); a
|
|
444
|
+
shorter array gives a device `[undefined]`.
|
|
445
|
+
- `updateMedia` destructures `sdp`, `audioMuted`, `videoMuted`, and `mediaId`, but its JSDoc
|
|
446
|
+
documents `options.localSdp`. A caller following the JSDoc sends no SDP.
|
|
447
|
+
- `decline` resolves `res.body` and `leave` resolves `res.body.locus`, while their Conflict paths
|
|
448
|
+
both resolve the GET body. Unless the decline response is itself a bare Locus, `decline` resolves
|
|
449
|
+
different shapes for success and Conflict. The service response is not in this repository.
|
|
450
|
+
|
|
451
|
+
## Module-specific rules
|
|
452
|
+
|
|
453
|
+
- Do: follow `INV-007` for the device URL and sequence in a new or changed request body.
|
|
454
|
+
- Do: resolve the response body or the documented field; do not copy the raw-response return of
|
|
455
|
+
`MOD-017`.
|
|
456
|
+
- Do: add new sequencing cases to the JSON fixtures in `test/unit/lib`, which the spec expands into
|
|
457
|
+
test cases automatically.
|
|
458
|
+
- Do: keep the `localSdp` encoding listed under Protocol and wire format.
|
|
459
|
+
- Do not: add state to the plugin; the first Key design trade-off row depends on it.
|
|
460
|
+
- Do not: change a comparison branch without rerunning every fixture; a changed result changes which
|
|
461
|
+
DTOs callers apply.
|
|
462
|
+
|
|
463
|
+
## Export stability
|
|
464
|
+
|
|
465
|
+
| Export or entry point | Consumer | Stability | Versioning and deprecation rule | Declaration or API report |
|
|
466
|
+
| --------------------- | -------- | --------- | ------------------------------- | ------------------------- |
|
|
467
|
+
| default `Locus` | Tests and importers | Internal plugin | README states the package does not strictly follow semver | `src/index.js` |
|
|
468
|
+
| `eventKeys` | Importers | Internal | Adding a name is compatible; removing or renaming is breaking | `src/index.js` |
|
|
469
|
+
| Seven sequence constants | Callers of `compare` and `compareSequence` | Stable values | Values must stay equal to their names | `src/index.js` |
|
|
470
|
+
| Registration as `locus` | Code reading `webex.internal.locus` | Stable | Renaming is breaking | `src/index.js` |
|
|
471
|
+
|
|
472
|
+
No TypeScript declaration or API report exists for this package.
|
|
473
|
+
|
|
474
|
+
## Key design trade-off
|
|
475
|
+
|
|
476
|
+
| Chosen trade-off | Preserved invariant or benefit | Cost or limitation | Decision evidence |
|
|
477
|
+
| ---------------- | ------------------------------ | ------------------ | ----------------- |
|
|
478
|
+
| Stateless plugin with pure `compare` and `merge` | Callers choose where the working copy lives and when to apply DTOs | Every caller must run the reconcile loop itself | `src/locus.js` |
|
|
479
|
+
| Conflict on `decline` and `leave` resolves with a GET | Callers get current state instead of an error | A real conflict is hidden as success | `src/locus.js` |
|
|
480
|
+
| Memoized bound helpers built per `compareSequence` call and discarded after it | Bound values are computed once per call | No reuse across calls; the source comment notes no measured benefit | `src/locus.js` |
|
|
481
|
+
| `mediaConnections` copied onto devices in `create` and `join` (`MOD-007`) | Callers read media connections from the device | The assumptions listed under Pitfalls | `src/locus.js` |
|
|
482
|
+
|
|
483
|
+
## Verification
|
|
484
|
+
|
|
485
|
+
| Requirement or invariant | Test level | Positive evidence | Negative or boundary evidence | Gap |
|
|
486
|
+
| ------------------------ | ---------- | ----------------- | ----------------------------- | --- |
|
|
487
|
+
| `MOD-003`, `INV-003`, `INV-004` | Unit | `test/unit/spec/locus.js` "basic sequence comparisons" (88 cases) and "sequence comparisons" (25 cases) | DESYNC cases in both fixtures | Missing-argument throws |
|
|
488
|
+
| `MOD-004`, `INV-001`, `INV-002` | Unit | `test/unit/spec/locus.js` "delta sequence comparisons" (21 cases) | DESYNC-to-FETCH cases updt14, updt18, updt19, updt21 | Unrecognized result throw |
|
|
489
|
+
| `MOD-005` | Unit | `test/unit/spec/locus.js` "delta sequence comparisons" | Base check failing to FETCH: updt9 and updt24 | — |
|
|
490
|
+
| `MOD-002` | Unit | `test/unit/spec/locus.js` imports from the package | none found | `eventKeys` not asserted |
|
|
491
|
+
| `MOD-001` | none | `src/index.js` | none found | No registration test |
|
|
492
|
+
| `MOD-006`, `INV-005` | none | `src/locus.js` | none found | No `merge` test, including the missing-`participants` throw |
|
|
493
|
+
| `MOD-007` to `MOD-017`, `INV-006`, `INV-007` | none | `src/locus.js` | none found | No REST wrapper test, no Conflict test, no request-body test |
|
|
494
|
+
| `MOD-018` | none | `src/event-keys.js` | none found | No assertion of the list |
|
|
495
|
+
|
|
496
|
+
Unit checks run with `yarn workspace @webex/internal-plugin-locus test:unit`. No integration specs
|
|
497
|
+
exist; the test tiers and the missing integration script are described in
|
|
498
|
+
[Getting started](../../docs/getting-started.md).
|