@vellumai/assistant 0.11.6-dev.202608261937.a51ea3f → 0.11.6-dev.202608262202.d09b5d7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/ARCHITECTURE.md +1 -1
  2. package/docs/architecture/security.md +1 -1
  3. package/docs/runbook-trusted-contacts.md +14 -0
  4. package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/__tests__/remote-web-pairing.test.ts +389 -0
  5. package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/remote-web-pairing.ts +502 -18
  6. package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/__tests__/remote-web-pairing.test.ts +389 -0
  7. package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/remote-web-pairing.ts +502 -18
  8. package/node_modules/@vellumai/gateway-client/src/admission-policy-contract.ts +5 -6
  9. package/node_modules/@vellumai/service-contracts/src/__tests__/remote-web-pairing.test.ts +389 -0
  10. package/node_modules/@vellumai/service-contracts/src/remote-web-pairing.ts +502 -18
  11. package/openapi.yaml +45 -6
  12. package/package.json +1 -1
  13. package/src/__tests__/approval-card-edit-inbound-handoff.test.ts +199 -0
  14. package/src/__tests__/approval-card-edit.test.ts +153 -0
  15. package/src/__tests__/config-schema.test.ts +2 -2
  16. package/src/__tests__/conversation-evictor.test.ts +19 -0
  17. package/src/__tests__/evict-conversations-for-reload.test.ts +51 -1
  18. package/src/__tests__/handlers-user-message-approval-consumption.test.ts +0 -2
  19. package/src/__tests__/managed-speech-defaults.test.ts +132 -1
  20. package/src/__tests__/subagent-manager-notify.test.ts +38 -0
  21. package/src/cli/AGENTS.md +3 -1
  22. package/src/cli/commands/contacts.help.ts +16 -4
  23. package/src/cli/commands/contacts.ts +5 -1
  24. package/src/config/feature-flag-registry.json +9 -1
  25. package/src/config/managed-speech-defaults.ts +52 -4
  26. package/src/config/schemas/__tests__/live-voice.test.ts +3 -3
  27. package/src/config/schemas/live-voice.ts +8 -1
  28. package/src/contacts/notify-contacts-changed.ts +5 -2
  29. package/src/daemon/conversation-evictor.ts +2 -4
  30. package/src/daemon/conversation-store.ts +8 -1
  31. package/src/daemon/conversation.ts +0 -4
  32. package/src/daemon/handlers/conversations.ts +0 -2
  33. package/src/daemon/message-types/messages.ts +0 -2
  34. package/src/live-voice/__tests__/live-voice-flux-turn-end.test.ts +12 -3
  35. package/src/live-voice/__tests__/live-voice-managed-speech-fallback.test.ts +8 -3
  36. package/src/live-voice/live-voice-session.ts +2 -1
  37. package/src/oauth/__tests__/seed-providers-managed.test.ts +18 -0
  38. package/src/oauth/seed-providers.ts +0 -4
  39. package/src/permissions/gateway-threshold-reader.test.ts +24 -0
  40. package/src/permissions/gateway-threshold-reader.ts +24 -7
  41. package/src/permissions/prompter.ts +0 -6
  42. package/src/providers/speech-to-text/__tests__/resolve.test.ts +22 -0
  43. package/src/providers/speech-to-text/deepgram-flux-frames.ts +6 -1
  44. package/src/providers/speech-to-text/provider-catalog.ts +18 -0
  45. package/src/providers/speech-to-text/resolve.ts +14 -0
  46. package/src/runtime/AGENTS.md +1 -2
  47. package/src/runtime/routes/approval-routes.ts +0 -12
  48. package/src/runtime/routes/contact-prompt-routes.ts +65 -6
  49. package/src/runtime/routes/guardian-approval-interception.ts +12 -9
  50. package/src/runtime/routes/inbound-message-handler.ts +9 -7
  51. package/src/runtime/routes/inbound-stages/acl-enforcement.ts +11 -6
  52. package/src/runtime/routes/inbound-stages/admission-policy.ts +2 -2
  53. package/src/runtime/routes/stt-routes.ts +25 -1
  54. package/src/subagent/manager.ts +12 -0
package/ARCHITECTURE.md CHANGED
@@ -1659,7 +1659,7 @@ graph TB
1659
1659
 
1660
1660
  ### Auto-Approve Threshold
1661
1661
 
1662
- Auto-approve thresholds are **gateway-owned** — they live in the gateway's SQLite database and are read by the assistant via IPC (`get_global_thresholds`, `get_conversation_threshold`, `get_contact_threshold`). Users control thresholds via the **Settings UI** (Permissions & Privacy tab) or the **per-conversation risk tolerance picker**. When the gateway is unreachable, the assistant defaults to `"none"` (Strict) — fail-closed with no local fallback.
1662
+ Auto-approve thresholds are **gateway-owned**: they live in the gateway's SQLite database and are read by the assistant via IPC (`get_global_thresholds`, `get_conversation_threshold`, `get_contact_threshold`). A contact ceiling is written via `set_contact_threshold` (`gateway contacts set-risk-threshold` or `POST /v1/contacts`). Users also control thresholds via the **Settings UI** (Permissions & Privacy tab) or the **per-conversation risk tolerance picker**. When the gateway is unreachable, the assistant defaults to `"none"` (Strict): fail-closed with no local fallback.
1663
1663
 
1664
1664
  | `autoApproveUpTo` | Low-risk tools | Medium-risk tools | High-risk tools |
1665
1665
  | ----------------- | -------------- | ----------------- | --------------- |
@@ -34,7 +34,7 @@ The order inside `check()`: the memory-retrospective skill-authoring grant, then
34
34
 
35
35
  ### Auto-Approve Threshold
36
36
 
37
- Thresholds are **gateway-owned**: stored in the gateway's SQLite database, read by the assistant over IPC (`get_global_thresholds`, `get_conversation_threshold`, `get_contact_threshold`), and set from the Settings UI (Permissions & Privacy) or the per-conversation risk tolerance picker. When the gateway is unreachable the assistant resolves `"none"` (Strict), fail-closed with no local fallback.
37
+ Thresholds are **gateway-owned**: stored in the gateway's SQLite database, read by the assistant over IPC (`get_global_thresholds`, `get_conversation_threshold`, `get_contact_threshold`), and written via `set_contact_threshold` (`gateway contacts set-risk-threshold` or `POST /v1/contacts`) as well as the Settings UI (Permissions & Privacy) or the per-conversation risk tolerance picker. When the gateway is unreachable the assistant resolves `"none"` (Strict), fail-closed with no local fallback.
38
38
 
39
39
  Gateway defaults per execution context (`gateway/src/ipc/threshold-handlers.ts`): `interactive` (a conversation with a client) `medium`, `autonomous` (background/scheduled) `low`, `headless` `none`. A per-conversation override wins over the global value; for non-guardian actors a channel-permission cell can only lower the effective threshold.
40
40
 
@@ -37,6 +37,8 @@ assistant contacts list --role contact
37
37
  assistant contacts list --role guardian
38
38
  assistant contacts list --channel-type telegram
39
39
  assistant contacts get <contactId>
40
+ gateway contacts list
41
+ gateway contacts get <contactId>
40
42
  ```
41
43
 
42
44
  ### Via HTTP API
@@ -142,6 +144,18 @@ sqlite3 "file:$GW_DB?mode=ro" \
142
144
 
143
145
  `verification_purpose` is `guardian` for guardian binding flows and `trusted_contact` for the access-request handshake.
144
146
 
147
+ ## 3b. Contact writes
148
+
149
+ All write operations on contacts are gateway-owned. Use the gateway CLI, not
150
+ `assistant contacts`. From the host, run the same command via
151
+ `vellum exec --service gateway --`.
152
+
153
+ ```bash
154
+ gateway contacts set-risk-threshold <contactId> --threshold high
155
+ ```
156
+
157
+ `inherit` clears the risk ceiling so the contact follows room and trust-class settings. Stored vocabulary is `none`, `low`, `medium`, or `high`.
158
+
145
159
  ## 4. Force-Revoke a Trusted Contact
146
160
 
147
161
  ### Via CLI (preferred)
@@ -0,0 +1,389 @@
1
+ import { describe, expect, test } from "bun:test";
2
+
3
+ import {
4
+ buildRemoteWebPairingUrl,
5
+ isDnsIndependentLoopbackUrl,
6
+ isLoopbackPublicUrl,
7
+ isPrivateNetworkPublicUrl,
8
+ isRetryablePairingReason,
9
+ pairingSessionSurvives,
10
+ parsePairingAddress,
11
+ parseRemoteWebPairingParams,
12
+ resolvePublicBaseUrl,
13
+ RETRYABLE_PAIRING_REASONS,
14
+ type PairingFailureReason,
15
+ type PublicBaseUrlRejection,
16
+ } from "../remote-web-pairing.js";
17
+
18
+ describe("parseRemoteWebPairingParams", () => {
19
+ test("reads snake_case fragment parameters", () => {
20
+ expect(
21
+ parseRemoteWebPairingParams(
22
+ "https://assistant.example.com/assistant/pair#device_code=device-1&user_code=ABCD-EFGH",
23
+ ),
24
+ ).toEqual({ deviceCode: "device-1", userCode: "ABCD-EFGH" });
25
+ });
26
+
27
+ test("reads camelCase query parameters", () => {
28
+ expect(
29
+ parseRemoteWebPairingParams(
30
+ "https://assistant.example.com/assistant/pair?deviceCode=device-2&userCode=WXYZ-1234",
31
+ ),
32
+ ).toEqual({ deviceCode: "device-2", userCode: "WXYZ-1234" });
33
+ });
34
+
35
+ test("accepts a relative link", () => {
36
+ expect(
37
+ parseRemoteWebPairingParams("/assistant/pair#device_code=device-3"),
38
+ ).toEqual({ deviceCode: "device-3", userCode: null });
39
+ });
40
+
41
+ test("reports null when no codes are present", () => {
42
+ expect(
43
+ parseRemoteWebPairingParams("https://assistant.example.com/assistant"),
44
+ ).toEqual({ deviceCode: null, userCode: null });
45
+ });
46
+ });
47
+
48
+ describe("parsePairingAddress", () => {
49
+ test("splits a pairing link into its base and device code", () => {
50
+ const link = buildRemoteWebPairingUrl({
51
+ verificationUri: "https://assistant.example.com/assistant/pair",
52
+ deviceCode: "device-1",
53
+ });
54
+
55
+ expect(parsePairingAddress(link)).toEqual({
56
+ ok: true,
57
+ publicBaseUrl: "https://assistant.example.com",
58
+ deviceCode: "device-1",
59
+ });
60
+ });
61
+
62
+ test("accepts the device code in the query string", () => {
63
+ expect(
64
+ parsePairingAddress(
65
+ "https://assistant.example.com/assistant/pair?deviceCode=device-2",
66
+ ),
67
+ ).toEqual({
68
+ ok: true,
69
+ publicBaseUrl: "https://assistant.example.com",
70
+ deviceCode: "device-2",
71
+ });
72
+ });
73
+
74
+ test("preserves a path prefix while dropping the app-route suffix", () => {
75
+ expect(
76
+ parsePairingAddress(
77
+ "https://host.example.com/assistant-123/assistant/pair#device_code=device-3",
78
+ ),
79
+ ).toEqual({
80
+ ok: true,
81
+ publicBaseUrl: "https://host.example.com/assistant-123",
82
+ deviceCode: "device-3",
83
+ });
84
+ });
85
+
86
+ test("drops a trailing app-route suffix from a bare address", () => {
87
+ expect(
88
+ parsePairingAddress("https://assistant.example.com/assistant/pair"),
89
+ ).toEqual({
90
+ ok: true,
91
+ publicBaseUrl: "https://assistant.example.com",
92
+ deviceCode: null,
93
+ });
94
+ });
95
+
96
+ test("accepts a bare address with no device code", () => {
97
+ expect(parsePairingAddress("https://assistant.example.com")).toEqual({
98
+ ok: true,
99
+ publicBaseUrl: "https://assistant.example.com",
100
+ deviceCode: null,
101
+ });
102
+ });
103
+
104
+ test.each<[string, PublicBaseUrlRejection]>([
105
+ ["not a url", "unparseable"],
106
+ ["https://localhost:3000", "loopback"],
107
+ ["https://127.0.0.1:3000", "loopback"],
108
+ ["http://assistant.example.com", "non-https"],
109
+ ["https://login.tailscale.com/admin/invite/abc123", "service-website"],
110
+ ])("rejects %s", (raw, reason) => {
111
+ expect(parsePairingAddress(raw)).toEqual({ ok: false, reason });
112
+ });
113
+ });
114
+
115
+ describe("resolvePublicBaseUrl private-address containment", () => {
116
+ // A host POSTs to whatever address was pasted, so an IP literal aimed at the
117
+ // local network (or at 169.254.169.254, the cloud instance metadata
118
+ // endpoint) is a blind SSRF target and is refused before any request.
119
+ test.each([
120
+ ["https://0.0.0.0", "0/8"],
121
+ ["https://10.0.0.1", "10/8"],
122
+ ["https://10.255.255.254:8443", "10/8 with a port"],
123
+ ["https://169.254.169.254", "169.254/16 cloud metadata"],
124
+ ["https://172.16.0.1", "172.16/12 low edge"],
125
+ ["https://172.31.255.254", "172.16/12 high edge"],
126
+ ["https://192.0.0.8", "192.0.0/24"],
127
+ ["https://192.168.1.5", "192.168/16"],
128
+ ["https://198.18.0.1", "198.18/15"],
129
+ ["https://198.19.255.254", "198.18/15 high half"],
130
+ ["https://224.0.0.1", "224/4 multicast"],
131
+ ["https://240.0.0.1", "240/4 reserved"],
132
+ ["https://255.255.255.255", "broadcast"],
133
+ // WHATWG URL canonicalizes these to a dotted-quad before the check.
134
+ ["https://2130706433", "decimal-encoded 127.0.0.1"],
135
+ ["https://0xa000001", "hex-encoded 10.0.0.1"],
136
+ ["https://[::]", "IPv6 unspecified"],
137
+ ["https://[fd00::1]", "fc00::/7 unique-local"],
138
+ ["https://[fc00::5]", "fc00::/7 low edge"],
139
+ ["https://[fe80::1]", "fe80::/10 link-local"],
140
+ ["https://[ff02::1]", "ff00::/8 multicast"],
141
+ ["https://[::ffff:10.0.0.1]", "IPv4-mapped private"],
142
+ ["https://[::ffff:169.254.169.254]", "IPv4-mapped metadata"],
143
+ ["https://[::192.168.1.5]", "IPv4-compatible private"],
144
+ ])("refuses %s (%s)", (raw) => {
145
+ const result = resolvePublicBaseUrl(raw);
146
+ expect(result.ok).toBe(false);
147
+ if (result.ok) {
148
+ return;
149
+ }
150
+ // 127/8 and ::1 keep their more specific loopback reason.
151
+ expect(["private-address", "loopback"]).toContain(result.reason);
152
+ });
153
+
154
+ test.each([
155
+ "https://10.0.0.1",
156
+ "https://169.254.169.254",
157
+ "https://172.20.3.4",
158
+ "https://192.168.1.5",
159
+ "https://198.18.0.1",
160
+ "https://[fd00::1]",
161
+ "https://[fe80::1]",
162
+ "https://[::ffff:10.0.0.1]",
163
+ ])("reports %s as private-address, not loopback", (raw) => {
164
+ expect(resolvePublicBaseUrl(raw)).toEqual({
165
+ ok: false,
166
+ reason: "private-address",
167
+ });
168
+ });
169
+
170
+ // A wildcard bind reaches a listener on the machine that dials it, so it
171
+ // gets the more specific loopback reason and the "points back at this
172
+ // machine" guidance that goes with it.
173
+ test.each([
174
+ ["https://0.0.0.0", "IPv4 wildcard"],
175
+ ["https://[::]", "IPv6 wildcard"],
176
+ ["https://[::ffff:0.0.0.0]", "IPv4-mapped wildcard"],
177
+ ["https://[::ffff:127.0.0.1]", "IPv4-mapped loopback"],
178
+ ])("reports %s (%s) as loopback", (raw) => {
179
+ expect(isLoopbackPublicUrl(raw)).toBe(true);
180
+ expect(resolvePublicBaseUrl(raw)).toEqual({
181
+ ok: false,
182
+ reason: "loopback",
183
+ });
184
+ });
185
+
186
+ // Tailscale hands out 100.64.0.0/10 CGNAT addresses and `*.ts.net` names are
187
+ // a supported pairing target, so neither the range nor any hostname is
188
+ // filtered. Names are never resolved (see isPrivateNetworkPublicUrl).
189
+ test.each([
190
+ "https://my-box.tail1234.ts.net",
191
+ "https://assistant.example.com",
192
+ "https://100.101.102.103",
193
+ "https://[2606:4700::1111]",
194
+ "https://172.32.0.1",
195
+ "https://192.0.1.1",
196
+ "https://198.20.0.1",
197
+ "https://223.255.255.255",
198
+ ])("still resolves %s", (raw) => {
199
+ expect(resolvePublicBaseUrl(raw)).toEqual({ ok: true, url: raw });
200
+ });
201
+
202
+ test("isPrivateNetworkPublicUrl reports a plain hostname as public", () => {
203
+ expect(isPrivateNetworkPublicUrl("https://my-box.tail1234.ts.net")).toBe(
204
+ false,
205
+ );
206
+ expect(isPrivateNetworkPublicUrl("not a url")).toBe(false);
207
+ expect(isPrivateNetworkPublicUrl("https://192.168.0.1")).toBe(true);
208
+ });
209
+ });
210
+
211
+ describe("resolvePublicBaseUrl localhost normalization", () => {
212
+ // A terminal DNS root dot survives WHATWG parsing, and resolvers read the
213
+ // absolute name as loopback, so the dot is stripped before every host
214
+ // comparison. The whole `.localhost` namespace is reserved (RFC 6761) and
215
+ // resolves to loopback too.
216
+ test.each([
217
+ ["https://localhost.", "absolute localhost name"],
218
+ ["https://localhost.:3000", "absolute localhost name with a port"],
219
+ ["https://LOCALHOST.", "uppercase absolute localhost name"],
220
+ ["https://foo.localhost", "reserved .localhost namespace"],
221
+ ["https://foo.localhost.", "absolute .localhost namespace"],
222
+ ["https://a.b.localhost.", "nested .localhost namespace"],
223
+ ["https://127.0.0.1.", "absolute IPv4 loopback literal"],
224
+ ])("reports %s (%s) as loopback", (raw) => {
225
+ expect(isLoopbackPublicUrl(raw)).toBe(true);
226
+ expect(resolvePublicBaseUrl(raw)).toEqual({
227
+ ok: false,
228
+ reason: "loopback",
229
+ });
230
+ });
231
+
232
+ test("reports an absolute private literal as private-address", () => {
233
+ expect(isPrivateNetworkPublicUrl("https://10.0.0.1.")).toBe(true);
234
+ expect(resolvePublicBaseUrl("https://10.0.0.1.")).toEqual({
235
+ ok: false,
236
+ reason: "private-address",
237
+ });
238
+ });
239
+
240
+ test("reports an absolute vendor-site name as service-website", () => {
241
+ expect(resolvePublicBaseUrl("https://login.tailscale.com.")).toEqual({
242
+ ok: false,
243
+ reason: "service-website",
244
+ });
245
+ });
246
+
247
+ test.each([
248
+ "https://my-box.tail1234.ts.net.",
249
+ "https://assistant.example.com.",
250
+ "https://localhostage.example.com",
251
+ "https://mylocalhost.example.com.",
252
+ ])("still resolves %s", (raw) => {
253
+ expect(isLoopbackPublicUrl(raw)).toBe(false);
254
+ expect(resolvePublicBaseUrl(raw)).toEqual({ ok: true, url: raw });
255
+ });
256
+ });
257
+
258
+ describe("isDnsIndependentLoopbackUrl", () => {
259
+ test.each([
260
+ ["http://localhost:7830", "the exact name"],
261
+ ["http://LOCALHOST.:7830", "the absolute, uppercase name"],
262
+ ["http://127.0.0.1:7830", "an IPv4 loopback literal"],
263
+ ["http://127.9.9.9", "the rest of 127/8"],
264
+ ["http://[::1]:7830", "the IPv6 loopback literal"],
265
+ ["http://[::ffff:127.0.0.1]", "an IPv4-mapped loopback literal"],
266
+ ["http://0.0.0.0:7830", "the IPv4 wildcard bind"],
267
+ ["http://[::]:7830", "the IPv6 wildcard bind"],
268
+ ])("%s reaches this machine (%s)", (raw) => {
269
+ expect(isDnsIndependentLoopbackUrl(raw)).toBe(true);
270
+ expect(isLoopbackPublicUrl(raw)).toBe(true);
271
+ });
272
+
273
+ // RFC 6761 reserves the namespace and says resolvers should map it to
274
+ // loopback, but glibc does not by default, so the name is ordinary DNS and
275
+ // can answer with any address. The wide predicate still refuses it as
276
+ // loopback; the narrow one refuses to hand it a loopback privilege.
277
+ test.each([
278
+ ["https://foo.localhost", "reserved .localhost namespace"],
279
+ ["https://foo.localhost.", "absolute .localhost namespace"],
280
+ ["https://a.b.localhost", "nested .localhost namespace"],
281
+ ])("%s is loopback but not DNS-independent (%s)", (raw) => {
282
+ expect(isLoopbackPublicUrl(raw)).toBe(true);
283
+ expect(isDnsIndependentLoopbackUrl(raw)).toBe(false);
284
+ });
285
+
286
+ test.each([
287
+ "https://assistant.example.com",
288
+ "https://localhostage.example.com",
289
+ "https://10.0.0.5",
290
+ "not a url",
291
+ ])("%s is not loopback at all", (raw) => {
292
+ expect(isDnsIndependentLoopbackUrl(raw)).toBe(false);
293
+ expect(isLoopbackPublicUrl(raw)).toBe(false);
294
+ });
295
+ });
296
+
297
+ /** Every reason, so a classification table cannot silently miss one. */
298
+ const EVERY_PAIRING_REASON: PairingFailureReason[] = [
299
+ "invalid-address",
300
+ "unknown-session",
301
+ "expired",
302
+ "unreachable",
303
+ "gateway-retryable",
304
+ "gateway",
305
+ "import",
306
+ "import-precheck",
307
+ ];
308
+
309
+ describe("isRetryablePairingReason", () => {
310
+ test.each([
311
+ // Nothing reached the assistant, so the session and code are untouched.
312
+ "unreachable",
313
+ // The assistant refused with a status that released the code.
314
+ "gateway-retryable",
315
+ ] as const)("%s is worth another attempt", (reason) => {
316
+ expect(isRetryablePairingReason(reason)).toBe(true);
317
+ });
318
+
319
+ test.each([
320
+ "invalid-address",
321
+ "unknown-session",
322
+ "expired",
323
+ // The assistant answered with something unusable, past which the code is
324
+ // spent rather than released.
325
+ "gateway",
326
+ "import",
327
+ // Nothing was spent, but an identical attempt is refused identically:
328
+ // only a caller that changes the name it asked for gets past this.
329
+ "import-precheck",
330
+ ] as const)("%s settles the attempt", (reason) => {
331
+ expect(isRetryablePairingReason(reason)).toBe(false);
332
+ });
333
+
334
+ test("an absent reason settles the attempt", () => {
335
+ expect(isRetryablePairingReason(undefined)).toBe(false);
336
+ expect(isRetryablePairingReason(null)).toBe(false);
337
+ });
338
+
339
+ test("the exported set is exactly the reasons worth another attempt", () => {
340
+ expect(
341
+ EVERY_PAIRING_REASON.filter(isRetryablePairingReason).sort(),
342
+ ).toEqual(["gateway-retryable", "unreachable"]);
343
+ expect([...RETRYABLE_PAIRING_REASONS].sort()).toEqual([
344
+ "gateway-retryable",
345
+ "unreachable",
346
+ ]);
347
+ });
348
+ });
349
+
350
+ describe("pairingSessionSurvives", () => {
351
+ test.each([
352
+ // Nothing reached the assistant, so the session and code are untouched.
353
+ "unreachable",
354
+ // The assistant released the code before answering.
355
+ "gateway-retryable",
356
+ // The refusal happened before the exchange, so the code is unspent.
357
+ "import-precheck",
358
+ ] as const)("%s leaves the session pollable", (reason) => {
359
+ expect(pairingSessionSurvives(reason)).toBe(true);
360
+ });
361
+
362
+ test.each([
363
+ "invalid-address",
364
+ "unknown-session",
365
+ "expired",
366
+ "gateway",
367
+ // The exchange spent the code; only the local write failed.
368
+ "import",
369
+ ] as const)("%s leaves nothing to poll", (reason) => {
370
+ expect(pairingSessionSurvives(reason)).toBe(false);
371
+ });
372
+
373
+ test("an absent reason leaves nothing to poll", () => {
374
+ expect(pairingSessionSurvives(undefined)).toBe(false);
375
+ expect(pairingSessionSurvives(null)).toBe(false);
376
+ });
377
+
378
+ test("a pre-check refusal is the one reason the two axes disagree on", () => {
379
+ // A caller that reads retryability as "keep the session" throws away a
380
+ // device code that is still good, which is what this reason exists to
381
+ // prevent: nothing was spent, so the same handle completes the pairing
382
+ // once the caller supplies a name that is free.
383
+ const disagreeing = EVERY_PAIRING_REASON.filter(
384
+ (reason) =>
385
+ pairingSessionSurvives(reason) !== isRetryablePairingReason(reason),
386
+ );
387
+ expect(disagreeing).toEqual(["import-precheck"]);
388
+ });
389
+ });