@webex/storage-adapter-spec 3.12.0 → 3.13.0-next.2

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.
@@ -0,0 +1,501 @@
1
+ ---
2
+ type: Module Spec
3
+ title: 'Abstract storage-adapter conformance suite specification'
4
+ description: Responsibilities, boundaries, design, invariants, and verification for the abstract storage-adapter conformance suite.
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: rsarika@cisco.com
12
+ updated_at: 2026-10-01T04:15:02Z
13
+ validation_status: pass-with-warnings
14
+ -->
15
+
16
+ # Abstract storage-adapter conformance suite
17
+
18
+ This source-local document at `src/docs/README.md` owns the stable
19
+ specification for **the abstract storage-adapter conformance suite**. Ground every claim in
20
+ repository evidence and link to the
21
+ [repository architecture](../../docs/architecture.md) instead of repeating broader facts.
22
+
23
+ Related context: [documentation index](../../docs/index.md) ·
24
+ [repository agent instructions](../../AGENTS.md)
25
+
26
+ ## Metadata
27
+
28
+ | Field | Value |
29
+ | ------------- | ------------------------------------------------------------ |
30
+ | Owner | Webex JS SDK storage maintainers |
31
+ | Source path | `src/` |
32
+ | Resource kind | package |
33
+ | Status | Active |
34
+ | Last verified | 2026-10-01 after merging `upstream/next` |
35
+ | Module id | `storage-adapter-spec` |
36
+ | Parent spec | — |
37
+ | Doc kind | Module spec |
38
+ | Coverage score | 95% assessed 2026-09-23 — 21 of 22 mandatory spec fields PRESENT; test strategy scored WEAK because nothing pins the number or shape of the declarations this module emits |
39
+ | Validation status | Pass with warnings — independent gate passed with 0 Blocking findings |
40
+
41
+ ## Applicability
42
+
43
+ Sections preceded by an `Include if` comment are conditional. Retain a
44
+ conditional section only when source evidence or a confirmed developer answer
45
+ satisfies its condition. Record `Unresolved` instead of guessing.
46
+
47
+ | Condition ID | Status | Evidence or reason | Owned section |
48
+ | ------------------------------------ | ----------------------------- | ------------------ | ----------------------------- |
49
+ | `module.has_tiers` | N/A | No tier annotation, SLO configuration, or ownership tiering exists in this package. | Tier |
50
+ | `module.has_ui` | N/A | `src/index.js` declares no component, template, or style. | UI use-case flow |
51
+ | `module.crosses_service_boundaries` | N/A | `src/index.js` performs no network, RPC, or message-queue call. | Cross-boundary use-case flow |
52
+ | `module.holds_client_state` | N/A | `src/index.js` declares no state store; the single mutable binding is a per-run fixture. | Client state model |
53
+ | `module.enforces_domain_rules` | Applicable | `src/index.js` asserts required arguments, value fidelity, namespace isolation, replacement semantics, and rejection behavior. | Business rules and invariants |
54
+ | `module.is_concurrent_async` | Applicable | Every operation in `src/index.js` returns a promise, and one case drives three concurrent writes. | Concurrency and reactive flow |
55
+ | `module.owns_persistence` | N/A | `src/index.js` owns no store, schema, or migration; it exercises a caller-supplied adapter. | Data, schema, and migration |
56
+ | `module.stateful_transitions` | N/A | The exported function in `src/index.js` holds no state across invocations. The key lifecycle it asserts belongs to the adapter under test and is recorded under Requirements. | State machine |
57
+ | `module.exposes_wire_protocol` | N/A | `src/index.js` defines no serialization format or binary frame. | Protocol and wire format |
58
+ | `module.ui_multi_screen` | N/A | No user interface exists in `src/index.js`. | UI flow |
59
+ | `module.large_data_model` | N/A | The fixtures in `src/index.js` are one number, one single-key object, and short arrays. | Data model |
60
+ | `module.returns_caller_errors` | Applicable | `src/index.js` requires specific promise rejections for missing arguments and absent keys. | Caller-visible failure modes |
61
+ | `module.module_specific_conventions` | Applicable | `.eslintrc.js`, `babel.config.js`, `jest.config.js`, and `process` configure this package locally. | Module-specific rules |
62
+ | `module.published_package` | Applicable | `package.json` declares a scoped npm name, both package entry points, and a publish command. | Export stability |
63
+ | `module.embedded_in_host` | N/A | `package.json` declares no host mount point, plugin manifest, or web component. | Host integration and theming |
64
+ | `module.has_design_tradeoff` | Applicable | `src/index.js` declares cases into the caller's runner and shares one handle created in a Jest-global hook. | Key design trade-off |
65
+ | `module.has_submodules` | N/A | This module has no child module in the accepted manifest module tree. | Sub-modules |
66
+
67
+ ## Evidence register
68
+
69
+ The code, configuration, and documentation used to verify this specification. Every statement in this
70
+ document traces to one of these; where none of them settles a question, this document records a gap
71
+ rather than inferring the missing behavior.
72
+
73
+ | Evidence | What it establishes |
74
+ | ---------------- | ------------------- |
75
+ | `src/index.js` | The entire contract: the exported function, its required arguments, every asserted behavior, and every required rejection. |
76
+ | `package.json` | The published surface, the dependency on the assertion helper, the available commands, and the browser build transform. |
77
+ | `README.md` | The package's own consumer-facing usage statement, used as corroborating evidence for the intended call style. |
78
+ | `process` | The browser-target declaration for this package. |
79
+ | `.eslintrc.js` | The package-local lint root. |
80
+ | `babel.config.js` | The transpilation configuration used by the build command. |
81
+ | `jest.config.js` | The jest configuration this package re-exports for consumers' runs. |
82
+
83
+ Commit history was not used as rationale evidence. The package owner confirmed during onboarding that
84
+ it is not trustworthy for explaining why current behavior exists, so every `WHY` below is derived from
85
+ the code and its consumer-facing usage, and gaps are recorded rather than inferred.
86
+
87
+ ## Purpose and boundary
88
+
89
+ - Responsibility: define the behavioral contract that every Webex storage adapter must satisfy, and
90
+ define it as executable cases rather than prose, so the contract is enforced at the moment each
91
+ adapter is tested.
92
+ - In scope: the required shape of `bind`, the required behavior of the bound handle's `put`, `get`,
93
+ `del`, and `clear`, value-fidelity guarantees, namespace isolation, concurrent-write resolution,
94
+ and the rejection behavior callers must be able to rely on. Evidence: `src/index.js`.
95
+ - Out of scope: any storage implementation. This module owns no store, no serialization, and no
96
+ persistence. It also does not own the runner, the environment, or the skip logic that decides
97
+ whether an adapter is applicable — that belongs to each consumer's test file.
98
+ - Consumers: Webex storage adapter packages and `@webex/webex-core`'s storage tests, all of which
99
+ import the default export and call it with their own adapter. Evidence: `package.json`,
100
+ `README.md`.
101
+
102
+ ## Structure and key files
103
+
104
+ | Path | Responsibility |
105
+ | -------- | ---------------------------------- |
106
+ | `src/index.js` | The whole module. It declares the local fixtures, the no-op logger, and the single default-exported function that emits every contract case. It is authoritative because there is no other source file. |
107
+ | `package.json` | Declares the published entry points, the assertion-helper dependency the suite calls, and the commands that build and lint this source. |
108
+ | `process` | Declares `{browser: true}`, marking this package as browser-targeted for the workspace tooling. |
109
+ | `.eslintrc.js` | Sets `root: true` and extends the workspace lint configuration, making this package a self-contained lint root. |
110
+ | `babel.config.js` | Re-exports the workspace babel configuration consumed by the build command. |
111
+ | `jest.config.js` | Re-exports the workspace jest configuration. |
112
+
113
+ The module's internal structure is a single nesting of runner declarations rather than a set of
114
+ collaborating files. One detail is worth knowing before editing: every operation group is declared
115
+ *inside* the outer `#bind()` group and its nested `bound` group, so the `#put()`, `#get()`, `#del()`,
116
+ and `#clear()` groups are descendants of `#bind()` rather than siblings of it. Evidence:
117
+ `src/index.js`.
118
+
119
+ ## Public surface
120
+
121
+ Describe exported APIs, events, commands, files, or UI boundaries. Link exact
122
+ schemas or declarations instead of copying them.
123
+
124
+ | Surface | Consumer | Compatibility commitment | Source |
125
+ | -------- | ---------- | ------------------------ | -------- |
126
+ | `runAbstractStorageAdapterSpec` — the default export, taking one object that exposes `bind` and returning nothing. Contract id `storage-adapter-spec-suite`, published. | Webex storage adapter packages and `@webex/webex-core` storage tests | Published npm API. The parameter shape and the requirement that it be called inside an active test-declaration context are both public. Adding a case tightens the contract for every consumer. | `package.json` declares the published entry points; the declaration is `src/index.js` |
127
+ | The storage adapter interface the caller must implement: `bind(namespace, options)` resolving to a handle owning `put`, `get`, `del`, and `clear`. The argument half of the same contract, not a separate id. | Every package that passes an adapter to the suite | Published, because consumers must implement it and `README.md` documents it to them. It has no machine-readable artifact of its own, which is why it carries no separate contract id; the assertions below are its specification. | `src/index.js` |
128
+
129
+ Both rows describe one registered contract, `storage-adapter-spec-suite`: what the module exports and
130
+ what it demands of the caller. Neither is an HTTP surface, so no OpenAPI document applies. The
131
+ repository-level catalog is in [architecture](../../docs/architecture.md).
132
+
133
+ ## Dependencies
134
+
135
+ | Dependency | Why it is required | Failure behavior |
136
+ | --------------------- | ------------------ | ----------------------------------- |
137
+ | `@webex/test-helper-chai` | Supplies the `assert` used by every case, including the promise-rejection assertion the contract depends on for its error requirements | A runtime dependency declared in `package.json`; if it cannot resolve, the module fails at import and no case is declared |
138
+ | The caller's test runner | The module calls the runner's `describe`, `it`, and `beforeAll` globals at invocation time rather than importing them | Not declared as a dependency in `package.json` because it is supplied ambiently by the consumer. A runner without a Jest-compatible `beforeAll` fails when the module is invoked |
139
+ | The adapter supplied by the caller | The subject of every case | Supplied as the sole argument, as either a constructed instance or a module object exposing `bind`; the module performs no null check, so an absent or malformed adapter surfaces as a failure inside the declared cases |
140
+
141
+ ## Requirements
142
+
143
+ Separate source evidence, test/example evidence, assumptions, and gaps so a
144
+ future contributor can distinguish verified behavior from approved unknowns.
145
+
146
+ | ID | WHAT | WHY | Source evidence | Test or example evidence | Assumptions or gaps | Confidence |
147
+ | --------- | ---------------------------------------------- | ------------------------------ | --------------- | ----------------------------------- | ------------------- | --------------------------------- |
148
+ | `MOD-001` | `bind()` called with no namespace must reject, and the rejection reason must match `` `namespace` is required `` | Callers pass namespaces from configuration; a silent default would let two components share a store they believe is private | `src/index.js` | `src/index.js` — the case is the assertion | Message text is matched by pattern, so adapters must keep that wording | Present |
149
+ | `MOD-002` | `bind(namespace)` without `options.logger` must reject, and the reason must match `` `options.logger` is required `` | The suite asserts the argument is demanded, not that it is used; the requirement exists so every adapter is constructed the same way | `src/index.js` | `src/index.js` | The module does not verify the logger is ever called; an adapter may accept and ignore it | Present |
150
+ | `MOD-003` | `bind(namespace, options)` must resolve to a handle exposing `put`, `get`, `del`, and `clear` | This handle is the entire operational surface of an adapter | `src/index.js` | `src/index.js` | The resolving case only requires the promise to settle; the handle's methods are exercised by later cases | Present |
151
+ | `MOD-004` | A primitive written with `put` must be readable by `get` as the same value | Round-trip fidelity is the base guarantee of a store | `src/index.js` | `src/index.js` | none | Present |
152
+ | `MOD-005` | The falsey primitives `0`, `false`, and `null` must round-trip unchanged | An adapter that tests values for truthiness would silently drop or coerce these; each is asserted separately | `src/index.js` | `src/index.js` | `undefined` is deliberately excluded here — it carries removal semantics, see `MOD-013` | Present |
153
+ | `MOD-006` | An object written with `put` must be readable by `get` as deeply equal | Adapters serialize; structural equality forbids returning a partially reconstructed object | `src/index.js` | `src/index.js` | The assertion is structural only. It is satisfied by returning the very same object reference, so an adapter that never serializes is not distinguished from one that round-trips correctly | Present |
154
+ | `MOD-007` | An array written with `put` must be readable by `get` as deeply equal | Same serialization concern as objects, with ordering preserved | `src/index.js` | `src/index.js` | none | Present |
155
+ | `MOD-008` | Writing a second array to an existing key must replace the stored value, not extend or merge it | An adapter that appended on write would accumulate entries across saves; the case writes a two-element array, reads it back, writes a three-element array, and requires exactly the second value | `src/index.js` | `src/index.js` | none | Present |
156
+ | `MOD-009` | When several writes to one key are issued concurrently, a subsequent read must return the last value issued | Adapters may serialize writes internally; without this the final value would be non-deterministic | `src/index.js` | `src/index.js` | The case issues three writes through a single concurrent batch and requires the third value. It constrains the adapter, but the ordering guarantee it assumes is not otherwise documented in this module | Present |
157
+ | `MOD-010` | The same key bound in two different namespaces must hold two independent values | Namespace isolation is the reason `bind` takes a namespace at all | `src/index.js` | none found | **Gap:** the case exists but its inner assertions are never awaited — the promise chain inside the bind callback is not returned, so the case resolves before the comparisons run and cannot fail. The requirement is declared but unverified | Weak |
158
+ | `MOD-011` | `get` of a key that was never written must reject | Callers distinguish "absent" from "stored `undefined`"; a resolved `undefined` would conflate them | `src/index.js` | `src/index.js` | The rejection reason is not constrained, only that it rejects | Present |
159
+ | `MOD-012` | After `del`, a `get` of that key must reject | Deletion must return the key to the absent state, not to a stored empty value | `src/index.js` | `src/index.js` | Asserted for both a primitive and an object | Present |
160
+ | `MOD-013` | `put` of `undefined` removes the key rather than storing it | Distinguishes `undefined` from the falsey values in `MOD-005`, which must be preserved | `src/index.js` | none found | **Gap:** both cases that describe this behavior call `del` or `clear` immediately after writing `undefined`, so the final rejection is equally explained by the removal call. The described behavior is not isolated by any case | Weak |
161
+ | `MOD-014` | After `clear`, a `get` of the key that was written must reject | Clearing must return that key to the absent state | `src/index.js` | `src/index.js` | **Two gaps.** Scope: every case writes and checks exactly one key, so namespace-wide clearing is asserted nowhere — only the single-key result is observable. Signature: the suite calls `clear()` with no argument in one case and `clear(key)` in two others, while `README.md` documents the method as `clear()`, so whether an argument is accepted, required, or ignored is unspecified | Weak |
162
+
163
+ ## Design overview
164
+
165
+ The module is one function and no classes. Its design question is not how to store data — it stores
166
+ none — but how to make a shared contract executable inside someone else's test run.
167
+
168
+ It resolves that by *declaring* rather than *returning*. `runAbstractStorageAdapterSpec` does not
169
+ build a list of assertions for the caller to run; it calls the ambient `describe` and `it` globals
170
+ directly, so invoking it has the side effect of registering a tree of cases into whatever runner is
171
+ currently collecting. The caller's only job is to call it in the right place. Evidence:
172
+ `src/index.js`, `README.md`.
173
+
174
+ State ownership follows from that choice. The module owns three kinds of state, all trivial and all
175
+ local to one invocation: the literal fixtures (`key`, `namespace`, the object and primitive values),
176
+ the no-op logger object whose six methods satisfy `MOD-002` without producing output, and the single
177
+ `bound` handle. The handle is the only binding assigned after declaration time — it is created once
178
+ in a `beforeAll` hook and then shared by every case in the group beneath it. Nothing else is mutable,
179
+ and no state survives the invocation. Evidence: `src/index.js`.
180
+
181
+ The trade-off in that shared handle is described under [Key design trade-off](#key-design-trade-off).
182
+
183
+ ## Data flow and sequence coverage
184
+
185
+ The transport is direct in-process promise-returning method calls on the adapter object the caller
186
+ supplied. There is no network, serialization, or queue between this module and its subject.
187
+
188
+ The module has four operation groups. Bind is separated because its failures are argument-validation
189
+ rejections matched by message, which no other group has. Round-trip and removal are separated because
190
+ their terminal state differs — one ends with a value present, the other with the key absent.
191
+ Concurrency is separated because its ordering, not its actors, is the behavior under test.
192
+
193
+ | Operation group | Entry and outcome | Diagram or evidence | Failure and recovery coverage |
194
+ | --------------- | ----------------- | ------------------- | ----------------------------- |
195
+ | Bind and argument validation | `bind` is called with zero, one, or two arguments; either rejects with a matched reason or resolves to the handle | Bind diagram below; `src/index.js` | Both rejection branches covered as `alt` paths |
196
+ | Round-trip write and read | `put` then `get` on the same key; the read must return an equal value | Round-trip diagram below; `src/index.js` | The absent-key rejection branch is covered as an `alt` path |
197
+ | Concurrent write resolution | Three writes to one key are issued together; a read must return the last issued | Concurrency diagram below; `src/index.js` | No failure branch — the contract requires deterministic resolution, not an error |
198
+ | Removal | `del`, `clear`, or a write of `undefined`; a following read must reject | Removal diagram below; `src/index.js` | The rejection is the asserted outcome, not a failure branch |
199
+
200
+ ```mermaid
201
+ sequenceDiagram
202
+ autonumber
203
+ participant S as Conformance suite
204
+ participant A as Adapter
205
+ Note over S,A: Operation group 1 — bind and argument validation
206
+ alt no namespace
207
+ S->>A: bind()
208
+ A-->>S: reject — reason must match `namespace` is required
209
+ else namespace but no logger option
210
+ S->>A: bind(namespace)
211
+ A-->>S: reject — reason must match `options.logger` is required
212
+ else namespace and options
213
+ S->>A: bind(namespace, options with no-op logger)
214
+ A-->>S: resolve bound handle
215
+ end
216
+ ```
217
+
218
+ ```mermaid
219
+ sequenceDiagram
220
+ autonumber
221
+ participant S as Conformance suite
222
+ participant B as Bound handle
223
+ Note over S,B: Operation group 2 — round-trip write and read
224
+ S->>B: put(key, value)
225
+ B-->>S: resolve
226
+ S->>B: get(key)
227
+ alt key was written
228
+ B-->>S: resolve with a deeply equal value
229
+ else key was never written
230
+ B-->>S: reject
231
+ end
232
+ Note over S,B: Replacement — a second write must not extend the first
233
+ S->>B: put(key, [1, 2])
234
+ S->>B: get(key)
235
+ B-->>S: resolve [1, 2]
236
+ S->>B: put(key, [1, 2, 3])
237
+ S->>B: get(key)
238
+ B-->>S: resolve exactly [1, 2, 3]
239
+ ```
240
+
241
+ ```mermaid
242
+ sequenceDiagram
243
+ autonumber
244
+ participant S as Conformance suite
245
+ participant B as Bound handle
246
+ Note over S,B: Operation group 3 — concurrent write resolution
247
+ par issued together
248
+ S->>B: put(key, 1)
249
+ and
250
+ S->>B: put(key, 2)
251
+ and
252
+ S->>B: put(key, 3)
253
+ end
254
+ B-->>S: all three settle
255
+ S->>B: get(key)
256
+ B-->>S: resolve 3 — the last value issued
257
+ ```
258
+
259
+ ```mermaid
260
+ sequenceDiagram
261
+ autonumber
262
+ participant S as Conformance suite
263
+ participant B as Bound handle
264
+ Note over S,B: Operation group 4 — removal
265
+ S->>B: put(key, value)
266
+ B-->>S: resolve
267
+ alt explicit delete
268
+ S->>B: del(key)
269
+ else clear the namespace
270
+ S->>B: clear()
271
+ else write undefined, then remove
272
+ S->>B: put(key, undefined)
273
+ S->>B: del(key) or clear(key)
274
+ end
275
+ S->>B: get(key)
276
+ B-->>S: reject — the key must be absent, not present and empty
277
+ ```
278
+
279
+ ## Class and component relationships
280
+
281
+ There are no classes in this module. The relationships that matter are between the exported function,
282
+ the fixtures it closes over, and the caller-supplied objects it drives.
283
+
284
+ ```mermaid
285
+ classDiagram
286
+ class runAbstractStorageAdapterSpec {
287
+ +adapter
288
+ declares case groups
289
+ }
290
+ class Fixtures {
291
+ key
292
+ namespace
293
+ obj
294
+ primitive
295
+ options with no-op logger
296
+ }
297
+ class Adapter {
298
+ +bind(namespace, options) Promise
299
+ }
300
+ class BoundHandle {
301
+ +put(key, value) Promise
302
+ +get(key) Promise
303
+ +del(key) Promise
304
+ +clear(key?) Promise
305
+ }
306
+ class TestRunner {
307
+ describe()
308
+ it()
309
+ beforeAll()
310
+ }
311
+ runAbstractStorageAdapterSpec --> Fixtures : closes over
312
+ runAbstractStorageAdapterSpec --> TestRunner : declares into
313
+ runAbstractStorageAdapterSpec --> Adapter : receives as argument
314
+ Adapter --> BoundHandle : resolves
315
+ runAbstractStorageAdapterSpec --> BoundHandle : drives
316
+ ```
317
+
318
+ `Adapter` and `BoundHandle` are not implemented here — they are the contract this module defines and
319
+ the consumer implements. `TestRunner` is ambient, never imported.
320
+
321
+ `clear` is rendered with an optional parameter because the source is inconsistent about it: one case
322
+ calls `clear()` and two call `clear(key)`, while `README.md` documents `clear()`. The optional marker
323
+ records that unresolved state rather than asserting a signature the code does not settle. Evidence:
324
+ `src/index.js`, `README.md`.
325
+
326
+ ## Use cases and flows
327
+
328
+ | Use case | Actor or caller | Primary steps and outcome | Failure or boundary behavior | Evidence |
329
+ | -------- | --------------- | ----------------------------- | ---------------------------- | ------------------------- |
330
+ | `UC-001` | Adapter author | Import the default export, construct the adapter, and call the export inside a `describe` block; the full contract is registered into the author's own run | If called outside an active declaration context, the ambient `describe` global is unavailable and the call fails immediately | `src/index.js`, `README.md` |
331
+ | `UC-002` | Adapter author | Run the consumer package's unit command; each contract case executes against the real adapter in its real environment | A case that the adapter cannot satisfy fails in the consumer's run, never in this package's | `package.json` |
332
+ | `UC-003` | Suite maintainer | Add a case to tighten the contract | Every consuming adapter must already satisfy it, or its build breaks on the next publish; this package's own commands cannot detect that | `src/index.js`, `package.json` |
333
+ | `UC-004` | Adapter author | Bind a second namespace and confirm the same key holds independent values | Intended boundary behavior, but currently unverified — see `MOD-010` | `src/index.js` |
334
+
335
+ <!-- Include if: the module enforces domain rules or entity invariants. [condition-id: module.enforces_domain_rules] -->
336
+
337
+ ## Business rules and invariants
338
+
339
+ | ID | Invariant | WHY | Enforcement source | Test evidence |
340
+ | --------- | ------------------------------------ | ----------- | ------------------ | ------------- |
341
+ | `INV-001` | A bind without both a namespace and a logger option never yields a usable handle | Every adapter is constructed identically, so no component can reach a store through a partially specified bind | `src/index.js` | `src/index.js` |
342
+ | `INV-002` | A value read back is deeply equal to the value written, for primitives, falsey primitives, objects, and arrays alike | Serialization must be lossless in both directions; truthiness checks and partial reconstruction are both forbidden | `src/index.js` | `src/index.js` |
343
+ | `INV-003` | A write replaces the stored value; it never extends or merges it | An accumulating adapter would grow the stored array on every save cycle | `src/index.js` | `src/index.js` |
344
+ | `INV-004` | A key is either present with a value, or absent and rejecting — never present and empty | Callers distinguish absence from a stored falsey value, which `INV-002` requires be preserved | `src/index.js` | `src/index.js` — enforced for the delete and clear paths only. The write-undefined path is not covered, because every case describing it calls a removal method before reading, so the invariant is unverified for that route |
345
+ | `INV-005` | Two namespaces never share a key's value | Namespace isolation is the reason `bind` is parameterized at all | `src/index.js` | none found — see the gap recorded for requirement MOD-010 |
346
+
347
+ <!-- Include if: the module is concurrent, asynchronous, reactive, or event-driven. [condition-id: module.is_concurrent_async] -->
348
+
349
+ ## Concurrency and reactive flow
350
+
351
+ - Execution model: promises throughout. Every operation the contract defines — `bind`, `put`, `get`,
352
+ `del`, `clear` — is required to return a promise. Most cases return their chain so the runner awaits
353
+ it, but this is a convention the code does not enforce, and one case breaks it: see the
354
+ shared-state and blocking notes below and requirement `MOD-010`. There are no threads, workers,
355
+ subscriptions, or jobs. Evidence: `src/index.js`.
356
+ - Ordering guarantees: the contract requires that concurrently issued writes to one key resolve to
357
+ the last value issued, and asserts it by issuing three writes together and requiring the third
358
+ (`MOD-009`). Within a single case, ordering is whatever the returned chain imposes.
359
+ - Idempotency and retry: neither is defined by this contract. No operation is required to be
360
+ idempotent, no deduplication key exists, and no retry is performed or expected. A failing operation
361
+ fails its case.
362
+ - Shared-state protection: the `bound` handle is created once in a `beforeAll` hook and then shared
363
+ by every case in the group beneath it, and those cases write to the same `key`. Nothing serializes
364
+ them beyond the runner's own case ordering, so the cases are order-dependent by construction — each
365
+ begins by writing the value it expects to read. Evidence: `src/index.js`.
366
+ - Blocking restrictions: no case may assert on a promise it does not return. `MOD-010` is the live
367
+ counter-example in this module: its inner chain is not returned, so the runner never awaits it and
368
+ the assertions cannot fail the case.
369
+
370
+ <!-- Include if: the module returns or raises errors callers must handle. [condition-id: module.returns_caller_errors] -->
371
+
372
+ ## Caller-visible failure modes
373
+
374
+ The failures below are the ones the *contract requires an adapter to produce*. They are the
375
+ observable error surface every consumer inherits.
376
+
377
+ | Condition | Signal or result | Caller behavior | Retry or recovery | Evidence |
378
+ | ----------- | ---------------- | --------------- | ----------------- | -------- |
379
+ | `bind` called with no namespace | Rejected promise whose reason matches `` `namespace` is required `` | Treat as a programming error; the namespace comes from the caller's own configuration | None — retrying with the same arguments fails identically | `src/index.js` |
380
+ | `bind` called without `options.logger` | Rejected promise whose reason matches `` `options.logger` is required `` | Supply a logger with `error`, `warning`, `log`, `info`, `debug`, and `trace` methods | None | `src/index.js` |
381
+ | `get` of a key that was never written | Rejected promise; the reason is unconstrained | Distinguish absence from a stored value; do not treat a rejection as an empty result | The key becomes readable only after a successful write | `src/index.js` |
382
+ | `get` after `del` | Rejected promise | Same as an absent key — deletion restores the absent state | Rewrite the key to make it readable again | `src/index.js` |
383
+ | `get` after `clear` | Rejected promise for the key that was written | Same as an absent key. The contract asserts this for a single key only; whether `clear` empties the whole namespace is not observable from any case | Rewrite the key | `src/index.js` |
384
+
385
+ The rejection *reason* is constrained only for the two `bind` failures, which are matched by message
386
+ pattern. Adapters must keep that wording. For the absent-key failures the contract requires only that
387
+ the promise rejects, so callers must not depend on a particular error type or message.
388
+
389
+ ## Pitfalls and constraints
390
+
391
+ - **Every case here is a requirement for four other packages.** Adding one tightens the contract for
392
+ every consuming adapter, and this package's own commands cannot detect the breakage — no command in
393
+ `package.json` executes the suite. Verify against consumers before publishing.
394
+ - **An assertion chain that is not returned cannot fail.** `MOD-010` is unverified today for exactly
395
+ this reason: the inner promise chain inside the bind callback is not returned, so the case resolves
396
+ before its comparisons run. When editing, check that every nested chain is returned.
397
+ - **A case that both writes `undefined` and calls a removal method proves nothing about writing
398
+ `undefined`.** Two cases have this shape, which is why `MOD-013` is recorded as unverified rather
399
+ than as covered behavior.
400
+ - **`clear` is called inconsistently.** One case calls `clear()` and two call `clear(key)`, while the
401
+ package's usage documentation describes the method as `clear()`. An adapter that treats the
402
+ argument as meaningful and one that ignores it both pass. Evidence: `src/index.js`, `README.md`.
403
+ - **The suite depends on a Jest-compatible runner.** It calls the `beforeAll` global, which is not a
404
+ Mocha global. A consumer running it under a runner without that global fails at declaration time,
405
+ not as an assertion failure. Evidence: `src/index.js`.
406
+ - **Cases share one handle and one key.** They are order-dependent by construction; each writes the
407
+ value it expects to read. Do not assume a clean store at the start of a case.
408
+ - **`dist/` is generated.** It is produced by the build command and git-ignored. Edits there are lost
409
+ on the next build. Evidence: `package.json`.
410
+
411
+ <!-- Include if: the module has conventions beyond repository-wide rules. [condition-id: module.module_specific_conventions] -->
412
+
413
+ ## Module-specific rules
414
+
415
+ - Do: keep every case's promise chain returned, including chains nested inside a `then` callback.
416
+ Evidence for why: `MOD-010` in this document.
417
+ - Do: assert value fidelity with deep equality rather than identity, so that adapters which serialize
418
+ remain conformant. Evidence: `src/index.js`.
419
+ - Do: treat `.eslintrc.js` as this package's lint root — it sets `root: true`, so workspace lint
420
+ configuration above it does not apply. Run `test:style` for this package specifically.
421
+ - Do: keep the module browser-safe. `process` declares a browser target and `package.json` configures
422
+ a browserify transform, so any Node-only API would break the browser build.
423
+ - Do not: add a case whose behavior only one adapter can satisfy. Every case binds all consumers.
424
+ - Do not: introduce a second exported function or a named export. Consumers import the default
425
+ export, and `package.json` resolves both `main` and `devMain` to this single module.
426
+ - Do not: write a case that combines a behavior under test with another operation that would produce
427
+ the same observable outcome — it cannot isolate what it claims to verify. See `MOD-013`.
428
+
429
+ <!-- Include if: the module is published or consumed as a package. [condition-id: module.published_package] -->
430
+
431
+ ## Export stability
432
+
433
+ | Export or entry point | Consumer | Stability | Versioning and deprecation rule | Declaration or API report |
434
+ | --------------------- | ---------- | --------- | ------------------------------- | ------------------------- |
435
+ | Default export `runAbstractStorageAdapterSpec(adapter)` | Webex storage adapter packages and `@webex/webex-core` storage tests | Public and stable | Published to npm through the command in `package.json`; the version is assigned by the workspace release process rather than declared in this package. A new case is a compatibility-affecting change even though the signature is unchanged | `src/index.js` |
436
+ | Package entry points `main` and `devMain` | Package consumers and workspace tooling | Public | `main` resolves to the built output and `devMain` to the source module, so workspace consumers can run against source without a build | `package.json` |
437
+
438
+ The ecosystem-native declaration in `src/index.js` is the authoritative API artifact for this package.
439
+ No separate API report or generated reference is produced, and no OpenAPI document applies.
440
+
441
+ <!-- Include if: the module has a non-obvious design trade-off consumers or maintainers must preserve. [condition-id: module.has_design_tradeoff] -->
442
+
443
+ ## Key design trade-off
444
+
445
+ | Chosen trade-off | Preserved invariant or benefit | Cost or limitation | Decision evidence |
446
+ | ---------------- | ------------------------------ | ------------------ | ----------------- |
447
+ | Declare cases into the caller's ambient runner instead of exporting assertions the caller composes | A consumer adopts the entire contract with a single call, so no adapter can silently adopt a subset of it | The module is coupled to the runner's globals and cannot be invoked outside a declaration context; it also cannot be unit-tested in this package, which is why the package holds no test file | `src/index.js` |
448
+ | Create the bound handle once in a `beforeAll` hook and share it across all cases | The expensive bind happens once, and the cases read as a continuous narrative over one store | The cases become order-dependent and share one key, and the choice of the Jest-specific `beforeAll` global over a runner-neutral hook constrains consumers to a Jest-compatible runner | `src/index.js`, `package.json` |
449
+ | Assert `bind` failures by matching the rejection message | Adapters must fail for the stated reason, not merely fail | Adapter error wording becomes part of the contract, so rewording a message in an adapter breaks conformance | `src/index.js` |
450
+
451
+ ## Verification
452
+
453
+ | Requirement or invariant | Test level | Positive evidence | Negative or boundary evidence | Gap |
454
+ | ------------------------ | ----------------------------- | ----------------- | ----------------------------- | ---------------------- |
455
+ | `MOD-001` | Contract | `src/index.js` | `src/index.js` — asserts rejection, matched by message | none |
456
+ | `MOD-002` | Contract | `src/index.js` | `src/index.js` — asserts rejection, matched by message | Does not verify the logger is ever used |
457
+ | `MOD-003` | Contract | `src/index.js` | none found | Only requires the promise to settle; the handle's shape is exercised indirectly by later cases |
458
+ | `MOD-004` | Contract | `src/index.js` | none found | none |
459
+ | `MOD-005` | Contract | `src/index.js` — one case per falsey value | none found | none |
460
+ | `MOD-006` | Contract | `src/index.js` | none found | none |
461
+ | `MOD-007` | Contract | `src/index.js` | none found | none |
462
+ | `MOD-008` | Contract | `src/index.js` | `src/index.js` — requires exactly the replacement value | none |
463
+ | `MOD-009` | Contract | `src/index.js` | none found | No case covers a concurrent write racing a delete or a clear |
464
+ | `MOD-010` | Contract | none found | none found | **Unverified.** The case exists but its inner assertions are never awaited, so it cannot fail |
465
+ | `MOD-011` | Contract | none found | `src/index.js` — asserts rejection | Rejection reason is unconstrained |
466
+ | `MOD-012` | Contract | none found | `src/index.js` — asserts rejection for a primitive and an object | none |
467
+ | `MOD-013` | Contract | none found | none found | **Unverified.** Both describing cases also call a removal method, which equally explains the outcome |
468
+ | `MOD-014` | Contract | none found | `src/index.js` — asserts rejection for the one written key | Namespace-wide clearing is not asserted, and argument handling for `clear` is inconsistent |
469
+ | `INV-005` | Contract | none found | none found | **Unverified** — carries the same gap as `MOD-010` |
470
+
471
+ Record coverage gaps explicitly and link follow-up work. A module specification
472
+ is complete only when its public surface, invariants, failure modes, and test
473
+ evidence agree with the implementation.
474
+
475
+ ### How this module is actually verified
476
+
477
+ The cases named as evidence above are this module's *output* — the declarations it emits. They are
478
+ executed, in this repository, by a sibling workspace package:
479
+
480
+ | Route | Latest measured result |
481
+ | --- | --- |
482
+ | `yarn workspace @webex/webex-core test:unit --targets storage/storage-adapter.js` | **21 of 21 cases executed and passed** against that package's in-memory adapter |
483
+ | `yarn workspace @webex/storage-adapter-local-storage test:unit` | Exits zero with **all 21 cases skipped** — the consumer wraps its call in a Node skip, so this proves nothing |
484
+ | `yarn workspace @webex/storage-adapter-session-storage test:unit` | Exits zero with **all 21 cases skipped** — the consumer wraps its call in a Node skip, so this proves nothing |
485
+ | `yarn workspace @webex/storage-adapter-local-forage test:unit` | Fails before collection because the package defines no `test:unit` script; its defined conformance route is browser-only |
486
+
487
+ Measured adapter results were refreshed on 2026-10-01. The local-storage and session-storage
488
+ packages skip under Node, while local-forage has no Node unit-test command and its test source also
489
+ uses `skipInNode`. Therefore `@webex/webex-core` is the only Node route that exercises the contract.
490
+ Commands are recorded in `.sdd/manifest.json` under `contract-verify` and the `unit` test tier.
491
+
492
+ **The residual gap is narrower than "untested".** Every case that exists is exercised by the run
493
+ above. What nothing checks is the *set* of declarations: no assertion pins how many cases this module
494
+ emits or what they cover, so deleting a case would silently shrink the contract while every consumer
495
+ run stayed green. That is why the test-strategy field scores WEAK, and it cannot be closed by writing
496
+ documentation.
497
+
498
+ Three source-level follow-ups are open and unassigned: returning the inner chain so `MOD-010` and
499
+ `INV-005` become verifiable; separating the `undefined`-write behavior from the removal call so
500
+ `MOD-013` can be isolated; and settling whether `clear` accepts an argument so `MOD-014` is
501
+ unambiguous.