@moltzap/protocol 2026.408.0 → 2026.425.1

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 (287) hide show
  1. package/dist/index.d.ts +2 -1
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +2 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/rpc-registry.d.ts +446 -0
  6. package/dist/rpc-registry.d.ts.map +1 -0
  7. package/dist/rpc-registry.js +67 -0
  8. package/dist/rpc-registry.js.map +1 -0
  9. package/dist/rpc.d.ts +42 -0
  10. package/dist/rpc.d.ts.map +1 -0
  11. package/dist/rpc.js +29 -0
  12. package/dist/rpc.js.map +1 -0
  13. package/dist/schema/apps.d.ts +86 -0
  14. package/dist/schema/apps.d.ts.map +1 -0
  15. package/dist/schema/apps.js +77 -0
  16. package/dist/schema/apps.js.map +1 -0
  17. package/dist/schema/contacts.d.ts +8 -18
  18. package/dist/schema/contacts.d.ts.map +1 -1
  19. package/dist/schema/contacts.js +9 -13
  20. package/dist/schema/contacts.js.map +1 -1
  21. package/dist/schema/conversations.d.ts +15 -8
  22. package/dist/schema/conversations.d.ts.map +1 -1
  23. package/dist/schema/conversations.js +18 -7
  24. package/dist/schema/conversations.js.map +1 -1
  25. package/dist/schema/delivery.d.ts +1 -4
  26. package/dist/schema/delivery.d.ts.map +1 -1
  27. package/dist/schema/delivery.js +2 -3
  28. package/dist/schema/delivery.js.map +1 -1
  29. package/dist/schema/errors.d.ts +13 -0
  30. package/dist/schema/errors.d.ts.map +1 -1
  31. package/dist/schema/errors.js +14 -0
  32. package/dist/schema/errors.js.map +1 -1
  33. package/dist/schema/events.d.ts +112 -93
  34. package/dist/schema/events.d.ts.map +1 -1
  35. package/dist/schema/events.js +84 -25
  36. package/dist/schema/events.js.map +1 -1
  37. package/dist/schema/identity.d.ts +19 -17
  38. package/dist/schema/identity.d.ts.map +1 -1
  39. package/dist/schema/identity.js +7 -14
  40. package/dist/schema/identity.js.map +1 -1
  41. package/dist/schema/index.d.ts +4 -2
  42. package/dist/schema/index.d.ts.map +1 -1
  43. package/dist/schema/index.js +4 -2
  44. package/dist/schema/index.js.map +1 -1
  45. package/dist/schema/messages.d.ts +3 -7
  46. package/dist/schema/messages.d.ts.map +1 -1
  47. package/dist/schema/messages.js +4 -6
  48. package/dist/schema/messages.js.map +1 -1
  49. package/dist/schema/methods/apps.d.ts +123 -0
  50. package/dist/schema/methods/apps.d.ts.map +1 -0
  51. package/dist/schema/methods/apps.js +93 -0
  52. package/dist/schema/methods/apps.js.map +1 -0
  53. package/dist/schema/methods/auth.d.ts +102 -90
  54. package/dist/schema/methods/auth.d.ts.map +1 -1
  55. package/dist/schema/methods/auth.js +86 -74
  56. package/dist/schema/methods/auth.js.map +1 -1
  57. package/dist/schema/methods/contacts.d.ts +39 -74
  58. package/dist/schema/methods/contacts.d.ts.map +1 -1
  59. package/dist/schema/methods/contacts.js +35 -29
  60. package/dist/schema/methods/contacts.js.map +1 -1
  61. package/dist/schema/methods/conversations.d.ts +48 -52
  62. package/dist/schema/methods/conversations.d.ts.map +1 -1
  63. package/dist/schema/methods/conversations.js +89 -38
  64. package/dist/schema/methods/conversations.js.map +1 -1
  65. package/dist/schema/methods/invites.d.ts +1 -3
  66. package/dist/schema/methods/invites.d.ts.map +1 -1
  67. package/dist/schema/methods/invites.js +8 -1
  68. package/dist/schema/methods/invites.js.map +1 -1
  69. package/dist/schema/methods/messages.d.ts +12 -44
  70. package/dist/schema/methods/messages.d.ts.map +1 -1
  71. package/dist/schema/methods/messages.js +22 -28
  72. package/dist/schema/methods/messages.js.map +1 -1
  73. package/dist/schema/methods/presence.d.ts +7 -22
  74. package/dist/schema/methods/presence.d.ts.map +1 -1
  75. package/dist/schema/methods/presence.js +12 -6
  76. package/dist/schema/methods/presence.js.map +1 -1
  77. package/dist/schema/methods/push.d.ts +8 -6
  78. package/dist/schema/methods/push.d.ts.map +1 -1
  79. package/dist/schema/methods/push.js +20 -7
  80. package/dist/schema/methods/push.js.map +1 -1
  81. package/dist/schema/methods/system.d.ts +4 -0
  82. package/dist/schema/methods/system.d.ts.map +1 -0
  83. package/dist/schema/methods/system.js +11 -0
  84. package/dist/schema/methods/system.js.map +1 -0
  85. package/dist/schema/presence.d.ts +1 -12
  86. package/dist/schema/presence.d.ts.map +1 -1
  87. package/dist/schema/presence.js +2 -7
  88. package/dist/schema/presence.js.map +1 -1
  89. package/dist/schema/surfaces.d.ts +31 -25
  90. package/dist/schema/surfaces.d.ts.map +1 -1
  91. package/dist/schema/surfaces.js +40 -21
  92. package/dist/schema/surfaces.js.map +1 -1
  93. package/dist/testing/agent-registration.d.ts +49 -0
  94. package/dist/testing/agent-registration.d.ts.map +1 -0
  95. package/dist/testing/agent-registration.js +77 -0
  96. package/dist/testing/agent-registration.js.map +1 -0
  97. package/dist/testing/arbitraries/frames.d.ts +24 -0
  98. package/dist/testing/arbitraries/frames.d.ts.map +1 -0
  99. package/dist/testing/arbitraries/frames.js +36 -0
  100. package/dist/testing/arbitraries/frames.js.map +1 -0
  101. package/dist/testing/arbitraries/from-typebox.d.ts +37 -0
  102. package/dist/testing/arbitraries/from-typebox.d.ts.map +1 -0
  103. package/dist/testing/arbitraries/from-typebox.js +131 -0
  104. package/dist/testing/arbitraries/from-typebox.js.map +1 -0
  105. package/dist/testing/arbitraries/index.d.ts +4 -0
  106. package/dist/testing/arbitraries/index.d.ts.map +1 -0
  107. package/dist/testing/arbitraries/index.js +4 -0
  108. package/dist/testing/arbitraries/index.js.map +1 -0
  109. package/dist/testing/arbitraries/rpc.d.ts +66 -0
  110. package/dist/testing/arbitraries/rpc.d.ts.map +1 -0
  111. package/dist/testing/arbitraries/rpc.js +98 -0
  112. package/dist/testing/arbitraries/rpc.js.map +1 -0
  113. package/dist/testing/canonicalize.d.ts +38 -0
  114. package/dist/testing/canonicalize.d.ts.map +1 -0
  115. package/dist/testing/canonicalize.js +55 -0
  116. package/dist/testing/canonicalize.js.map +1 -0
  117. package/dist/testing/captures.d.ts +61 -0
  118. package/dist/testing/captures.d.ts.map +1 -0
  119. package/dist/testing/captures.js +99 -0
  120. package/dist/testing/captures.js.map +1 -0
  121. package/dist/testing/codec.d.ts +44 -0
  122. package/dist/testing/codec.d.ts.map +1 -0
  123. package/dist/testing/codec.js +170 -0
  124. package/dist/testing/codec.js.map +1 -0
  125. package/dist/testing/conformance/__divergence_proofs__/executable-proof-helpers.d.ts +6 -0
  126. package/dist/testing/conformance/__divergence_proofs__/executable-proof-helpers.d.ts.map +1 -0
  127. package/dist/testing/conformance/__divergence_proofs__/executable-proof-helpers.js +33 -0
  128. package/dist/testing/conformance/__divergence_proofs__/executable-proof-helpers.js.map +1 -0
  129. package/dist/testing/conformance/adversity.d.ts +36 -0
  130. package/dist/testing/conformance/adversity.d.ts.map +1 -0
  131. package/dist/testing/conformance/adversity.js +360 -0
  132. package/dist/testing/conformance/adversity.js.map +1 -0
  133. package/dist/testing/conformance/boundary.d.ts +56 -0
  134. package/dist/testing/conformance/boundary.d.ts.map +1 -0
  135. package/dist/testing/conformance/boundary.js +129 -0
  136. package/dist/testing/conformance/boundary.js.map +1 -0
  137. package/dist/testing/conformance/client/_fixtures.d.ts +71 -0
  138. package/dist/testing/conformance/client/_fixtures.d.ts.map +1 -0
  139. package/dist/testing/conformance/client/_fixtures.js +102 -0
  140. package/dist/testing/conformance/client/_fixtures.js.map +1 -0
  141. package/dist/testing/conformance/client/adversity.d.ts +39 -0
  142. package/dist/testing/conformance/client/adversity.d.ts.map +1 -0
  143. package/dist/testing/conformance/client/adversity.js +162 -0
  144. package/dist/testing/conformance/client/adversity.js.map +1 -0
  145. package/dist/testing/conformance/client/boundary.d.ts +12 -0
  146. package/dist/testing/conformance/client/boundary.d.ts.map +1 -0
  147. package/dist/testing/conformance/client/boundary.js +68 -0
  148. package/dist/testing/conformance/client/boundary.js.map +1 -0
  149. package/dist/testing/conformance/client/delivery.d.ts +38 -0
  150. package/dist/testing/conformance/client/delivery.d.ts.map +1 -0
  151. package/dist/testing/conformance/client/delivery.js +202 -0
  152. package/dist/testing/conformance/client/delivery.js.map +1 -0
  153. package/dist/testing/conformance/client/index.d.ts +16 -0
  154. package/dist/testing/conformance/client/index.d.ts.map +1 -0
  155. package/dist/testing/conformance/client/index.js +16 -0
  156. package/dist/testing/conformance/client/index.js.map +1 -0
  157. package/dist/testing/conformance/client/rpc-semantics.d.ts +26 -0
  158. package/dist/testing/conformance/client/rpc-semantics.d.ts.map +1 -0
  159. package/dist/testing/conformance/client/rpc-semantics.js +145 -0
  160. package/dist/testing/conformance/client/rpc-semantics.js.map +1 -0
  161. package/dist/testing/conformance/client/runner.d.ts +258 -0
  162. package/dist/testing/conformance/client/runner.d.ts.map +1 -0
  163. package/dist/testing/conformance/client/runner.js +228 -0
  164. package/dist/testing/conformance/client/runner.js.map +1 -0
  165. package/dist/testing/conformance/client/schema-conformance.d.ts +25 -0
  166. package/dist/testing/conformance/client/schema-conformance.d.ts.map +1 -0
  167. package/dist/testing/conformance/client/schema-conformance.js +123 -0
  168. package/dist/testing/conformance/client/schema-conformance.js.map +1 -0
  169. package/dist/testing/conformance/client/suite.d.ts +90 -0
  170. package/dist/testing/conformance/client/suite.d.ts.map +1 -0
  171. package/dist/testing/conformance/client/suite.js +209 -0
  172. package/dist/testing/conformance/client/suite.js.map +1 -0
  173. package/dist/testing/conformance/coverage-policy.d.ts +8 -0
  174. package/dist/testing/conformance/coverage-policy.d.ts.map +1 -0
  175. package/dist/testing/conformance/coverage-policy.js +10 -0
  176. package/dist/testing/conformance/coverage-policy.js.map +1 -0
  177. package/dist/testing/conformance/delivery.d.ts +40 -0
  178. package/dist/testing/conformance/delivery.d.ts.map +1 -0
  179. package/dist/testing/conformance/delivery.js +231 -0
  180. package/dist/testing/conformance/delivery.js.map +1 -0
  181. package/dist/testing/conformance/env.d.ts +3 -0
  182. package/dist/testing/conformance/env.d.ts.map +1 -0
  183. package/dist/testing/conformance/env.js +14 -0
  184. package/dist/testing/conformance/env.js.map +1 -0
  185. package/dist/testing/conformance/index.d.ts +10 -0
  186. package/dist/testing/conformance/index.d.ts.map +1 -0
  187. package/dist/testing/conformance/index.js +10 -0
  188. package/dist/testing/conformance/index.js.map +1 -0
  189. package/dist/testing/conformance/registry.d.ts +93 -0
  190. package/dist/testing/conformance/registry.d.ts.map +1 -0
  191. package/dist/testing/conformance/registry.js +62 -0
  192. package/dist/testing/conformance/registry.js.map +1 -0
  193. package/dist/testing/conformance/rpc-semantics.d.ts +67 -0
  194. package/dist/testing/conformance/rpc-semantics.d.ts.map +1 -0
  195. package/dist/testing/conformance/rpc-semantics.js +394 -0
  196. package/dist/testing/conformance/rpc-semantics.js.map +1 -0
  197. package/dist/testing/conformance/runner.d.ts +78 -0
  198. package/dist/testing/conformance/runner.d.ts.map +1 -0
  199. package/dist/testing/conformance/runner.js +65 -0
  200. package/dist/testing/conformance/runner.js.map +1 -0
  201. package/dist/testing/conformance/schema-conformance.d.ts +30 -0
  202. package/dist/testing/conformance/schema-conformance.d.ts.map +1 -0
  203. package/dist/testing/conformance/schema-conformance.js +229 -0
  204. package/dist/testing/conformance/schema-conformance.js.map +1 -0
  205. package/dist/testing/conformance/suite.d.ts +92 -0
  206. package/dist/testing/conformance/suite.d.ts.map +1 -0
  207. package/dist/testing/conformance/suite.js +233 -0
  208. package/dist/testing/conformance/suite.js.map +1 -0
  209. package/dist/testing/errors.d.ts +78 -0
  210. package/dist/testing/errors.d.ts.map +1 -0
  211. package/dist/testing/errors.js +34 -0
  212. package/dist/testing/errors.js.map +1 -0
  213. package/dist/testing/index.d.ts +25 -0
  214. package/dist/testing/index.d.ts.map +1 -0
  215. package/dist/testing/index.js +37 -0
  216. package/dist/testing/index.js.map +1 -0
  217. package/dist/testing/models/dispatch.d.ts +61 -0
  218. package/dist/testing/models/dispatch.d.ts.map +1 -0
  219. package/dist/testing/models/dispatch.js +197 -0
  220. package/dist/testing/models/dispatch.js.map +1 -0
  221. package/dist/testing/models/index.d.ts +3 -0
  222. package/dist/testing/models/index.d.ts.map +1 -0
  223. package/dist/testing/models/index.js +3 -0
  224. package/dist/testing/models/index.js.map +1 -0
  225. package/dist/testing/models/state.d.ts +37 -0
  226. package/dist/testing/models/state.d.ts.map +1 -0
  227. package/dist/testing/models/state.js +14 -0
  228. package/dist/testing/models/state.js.map +1 -0
  229. package/dist/testing/test-client.d.ts +70 -0
  230. package/dist/testing/test-client.d.ts.map +1 -0
  231. package/dist/testing/test-client.js +266 -0
  232. package/dist/testing/test-client.js.map +1 -0
  233. package/dist/testing/test-server.d.ts +62 -0
  234. package/dist/testing/test-server.d.ts.map +1 -0
  235. package/dist/testing/test-server.js +134 -0
  236. package/dist/testing/test-server.js.map +1 -0
  237. package/dist/testing/toxics/client.d.ts +52 -0
  238. package/dist/testing/toxics/client.d.ts.map +1 -0
  239. package/dist/testing/toxics/client.js +120 -0
  240. package/dist/testing/toxics/client.js.map +1 -0
  241. package/dist/testing/toxics/defaults.d.ts +43 -0
  242. package/dist/testing/toxics/defaults.d.ts.map +1 -0
  243. package/dist/testing/toxics/defaults.js +9 -0
  244. package/dist/testing/toxics/defaults.js.map +1 -0
  245. package/dist/testing/toxics/index.d.ts +4 -0
  246. package/dist/testing/toxics/index.d.ts.map +1 -0
  247. package/dist/testing/toxics/index.js +4 -0
  248. package/dist/testing/toxics/index.js.map +1 -0
  249. package/dist/testing/toxics/profile.d.ts +69 -0
  250. package/dist/testing/toxics/profile.d.ts.map +1 -0
  251. package/dist/testing/toxics/profile.js +57 -0
  252. package/dist/testing/toxics/profile.js.map +1 -0
  253. package/dist/types.d.ts +7 -11
  254. package/dist/types.d.ts.map +1 -1
  255. package/dist/types.js +3 -0
  256. package/dist/types.js.map +1 -1
  257. package/dist/validators.d.ts +49 -177
  258. package/dist/validators.d.ts.map +1 -1
  259. package/dist/validators.js +77 -48
  260. package/dist/validators.js.map +1 -1
  261. package/dist/version.d.ts +1 -1
  262. package/dist/version.js +1 -1
  263. package/package.json +12 -34
  264. package/dist/optional/contact-events.d.ts +0 -3
  265. package/dist/optional/contact-events.d.ts.map +0 -1
  266. package/dist/optional/contact-events.js +0 -5
  267. package/dist/optional/contact-events.js.map +0 -1
  268. package/dist/optional/contact-methods.d.ts +0 -5
  269. package/dist/optional/contact-methods.d.ts.map +0 -1
  270. package/dist/optional/contact-methods.js +0 -5
  271. package/dist/optional/contact-methods.js.map +0 -1
  272. package/dist/phone-hash.d.ts +0 -10
  273. package/dist/phone-hash.d.ts.map +0 -1
  274. package/dist/phone-hash.js +0 -17
  275. package/dist/phone-hash.js.map +0 -1
  276. package/dist/schema/methods/phone-contacts.d.ts +0 -30
  277. package/dist/schema/methods/phone-contacts.d.ts.map +0 -1
  278. package/dist/schema/methods/phone-contacts.js +0 -10
  279. package/dist/schema/methods/phone-contacts.js.map +0 -1
  280. package/dist/test-client.d.ts +0 -34
  281. package/dist/test-client.d.ts.map +0 -1
  282. package/dist/test-client.js +0 -176
  283. package/dist/test-client.js.map +0 -1
  284. package/dist/test-fixtures/phone-hashes.d.ts +0 -18
  285. package/dist/test-fixtures/phone-hashes.d.ts.map +0 -1
  286. package/dist/test-fixtures/phone-hashes.js +0 -24
  287. package/dist/test-fixtures/phone-hashes.js.map +0 -1
@@ -0,0 +1,170 @@
1
+ /**
2
+ * Frame codec for the testing primitives.
3
+ *
4
+ * Satisfies §5.A1/A2/A3/A4 and Invariant I3: every frame crossing a
5
+ * primitive is `Value.Check`-validated before it is surfaced to property
6
+ * code. Malformed-frame arbitraries are generated *here* so Tier A can
7
+ * inject bit-flips, truncations, and oversized frames without leaking the
8
+ * malformation strategy into the primitives.
9
+ */
10
+ import { Effect } from "effect";
11
+ import { Value } from "@sinclair/typebox/value";
12
+ import { RequestFrameSchema, ResponseFrameSchema, EventFrameSchema, } from "../schema/frames.js";
13
+ import { FrameSchemaError } from "./errors.js";
14
+ /** Serialize a typed frame to the wire bytes. */
15
+ export function encodeFrame(frame) {
16
+ return JSON.stringify(frame);
17
+ }
18
+ /**
19
+ * Parse + `Value.Check` an inbound frame. `FrameSchemaError` captures
20
+ * the failing branch so Tier A can assert "drop or typed error, never
21
+ * crash."
22
+ */
23
+ export function decodeFrame(raw, direction) {
24
+ return Effect.suspend(() => {
25
+ let parsed;
26
+ try {
27
+ parsed = JSON.parse(raw);
28
+ }
29
+ catch (err) {
30
+ return Effect.fail(new FrameSchemaError({
31
+ direction,
32
+ expected: "request",
33
+ raw,
34
+ reason: `json parse failed: ${err instanceof Error ? err.message : String(err)}`,
35
+ }));
36
+ }
37
+ if (parsed === null ||
38
+ typeof parsed !== "object" ||
39
+ !("type" in parsed) ||
40
+ typeof parsed.type !== "string") {
41
+ return Effect.fail(new FrameSchemaError({
42
+ direction,
43
+ expected: "request",
44
+ raw,
45
+ reason: "frame missing required `type` discriminator",
46
+ }));
47
+ }
48
+ const type = parsed.type;
49
+ switch (type) {
50
+ case "request":
51
+ if (Value.Check(RequestFrameSchema, parsed)) {
52
+ return Effect.succeed(parsed);
53
+ }
54
+ return Effect.fail(new FrameSchemaError({
55
+ direction,
56
+ expected: "request",
57
+ raw,
58
+ reason: firstValueError(RequestFrameSchema, parsed),
59
+ }));
60
+ case "response":
61
+ if (Value.Check(ResponseFrameSchema, parsed)) {
62
+ return Effect.succeed(parsed);
63
+ }
64
+ return Effect.fail(new FrameSchemaError({
65
+ direction,
66
+ expected: "response",
67
+ raw,
68
+ reason: firstValueError(ResponseFrameSchema, parsed),
69
+ }));
70
+ case "event":
71
+ if (Value.Check(EventFrameSchema, parsed)) {
72
+ return Effect.succeed(parsed);
73
+ }
74
+ return Effect.fail(new FrameSchemaError({
75
+ direction,
76
+ expected: "event",
77
+ raw,
78
+ reason: firstValueError(EventFrameSchema, parsed),
79
+ }));
80
+ default:
81
+ return Effect.fail(new FrameSchemaError({
82
+ direction,
83
+ expected: "request",
84
+ raw,
85
+ reason: `unknown frame type: ${type}`,
86
+ }));
87
+ }
88
+ });
89
+ }
90
+ function firstValueError(schema, value) {
91
+ const iter = Value.Errors(schema, value);
92
+ for (const err of iter) {
93
+ return `${err.path}: ${err.message}`;
94
+ }
95
+ return "schema check failed";
96
+ }
97
+ /**
98
+ * Produce a malformed wire payload from a valid frame. The mutation is
99
+ * deterministic given the `kind` + `seed`; replaying with the same seed
100
+ * reproduces the exact bytes. Used by Tier A (A4) and Tier D (D3).
101
+ */
102
+ export function malformFrame(base, kind, seed) {
103
+ const rawJson = encodeFrame(base);
104
+ // Deterministic LCG so a `seed` reproduces byte-for-byte. Not crypto.
105
+ const rand = lcg(seed);
106
+ switch (kind) {
107
+ case "bit-flip": {
108
+ if (rawJson.length === 0)
109
+ return rawJson;
110
+ const pos = Math.floor(rand() * rawJson.length);
111
+ const ch = rawJson.charCodeAt(pos);
112
+ // Flip one bit in the low byte (XOR with 1<<bit).
113
+ const bit = Math.floor(rand() * 8);
114
+ const flipped = String.fromCharCode(ch ^ (1 << bit));
115
+ return rawJson.slice(0, pos) + flipped + rawJson.slice(pos + 1);
116
+ }
117
+ case "truncated": {
118
+ if (rawJson.length <= 1)
119
+ return "";
120
+ const keep = Math.max(1, Math.floor(rawJson.length * rand()));
121
+ return rawJson.slice(0, keep);
122
+ }
123
+ case "oversized": {
124
+ // Pad with a long run of whitespace-in-string to exceed likely frame caps.
125
+ // Uses `_padding` field at top level of the JSON object, which
126
+ // `additionalProperties: false` rejects — also triggers "extra-property"
127
+ // under different framing, but here the point is byte-size.
128
+ const padLen = 64 * 1024;
129
+ const pad = "X".repeat(padLen);
130
+ // Splice "_padding":"...", before the closing `}`.
131
+ const idx = rawJson.lastIndexOf("}");
132
+ if (idx === -1)
133
+ return rawJson + pad;
134
+ return `${rawJson.slice(0, idx)},"_padding":"${pad}"}`;
135
+ }
136
+ case "invalid-utf8": {
137
+ // Insert a lone surrogate. JSON parser may accept; TypeBox Check rejects
138
+ // because frame strings (method, id) are expected to be UTF-8 clean.
139
+ const pos = Math.floor(rand() * rawJson.length);
140
+ return rawJson.slice(0, pos) + "\uD800" + rawJson.slice(pos);
141
+ }
142
+ case "missing-required-field": {
143
+ // Remove the `jsonrpc` required property.
144
+ return rawJson.replace(/"jsonrpc":"2\.0",?/, "");
145
+ }
146
+ case "extra-property": {
147
+ const idx = rawJson.lastIndexOf("}");
148
+ if (idx === -1)
149
+ return rawJson;
150
+ return `${rawJson.slice(0, idx)},"__extra":${seed}}`;
151
+ }
152
+ default: {
153
+ const _exhaustive = kind;
154
+ throw new Error(`malformFrame: unexpected kind ${String(_exhaustive)}`);
155
+ }
156
+ }
157
+ }
158
+ /**
159
+ * Deterministic LCG (Numerical Recipes constants). Given the same seed,
160
+ * yields the same sequence of floats in [0, 1). Good enough for reproducible
161
+ * mutation offsets; not for cryptographic use.
162
+ */
163
+ function lcg(seed) {
164
+ let s = seed >>> 0 || 1;
165
+ return () => {
166
+ s = (Math.imul(s, 1664525) + 1013904223) >>> 0;
167
+ return s / 0x100000000;
168
+ };
169
+ }
170
+ //# sourceMappingURL=codec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codec.js","sourceRoot":"","sources":["../../src/testing/codec.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,GAIjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAwB/C,iDAAiD;AACjD,MAAM,UAAU,WAAW,CAAC,KAAe;IACzC,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CACzB,GAAW,EACX,SAAiC;IAEjC,OAAO,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE;QACzB,IAAI,MAAe,CAAC;QACpB,IAAI,CAAC;YACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;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AAE;QACV,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;QAC/C,OAAO,CAAC,GAAG,WAAW,CAAC;IACzB,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { Effect } from "effect";
2
+ import { type PropertyFailure, type RegisteredProperty } from "../registry.js";
3
+ export declare function runExpectingFailure(property: RegisteredProperty): Effect.Effect<PropertyFailure>;
4
+ export declare function expectInvariant(failure: PropertyFailure, propertyName: string): void;
5
+ export declare function expectAssertionFailure(failure: PropertyFailure, propertyName: string): void;
6
+ //# sourceMappingURL=executable-proof-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executable-proof-helpers.d.ts","sourceRoot":"","sources":["../../../../src/testing/conformance/__divergence_proofs__/executable-proof-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,MAAM,EAAU,MAAM,QAAQ,CAAC;AACtD,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACxB,MAAM,gBAAgB,CAAC;AAExB,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,kBAAkB,GAC3B,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,CAiBhC;AAED,wBAAgB,eAAe,CAC7B,OAAO,EAAE,eAAe,EACxB,YAAY,EAAE,MAAM,GACnB,IAAI,CAON;AAED,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,eAAe,EACxB,YAAY,EAAE,MAAM,GACnB,IAAI,CAON"}
@@ -0,0 +1,33 @@
1
+ import { Cause, Chunk, Effect, Option } from "effect";
2
+ import { PropertyAssertionFailure, PropertyInvariantViolation, } from "../registry.js";
3
+ export function runExpectingFailure(property) {
4
+ return Effect.gen(function* () {
5
+ const exit = yield* Effect.exit(property.run);
6
+ if (exit._tag === "Success") {
7
+ return yield* Effect.die(new Error(`${property.category}/${property.name} unexpectedly passed`));
8
+ }
9
+ const failures = Cause.failures(exit.cause);
10
+ const failure = Option.getOrNull(Chunk.head(failures));
11
+ if (failure === null) {
12
+ return yield* Effect.die(new Error(`expected typed failure, got ${exit.cause.toString()}`));
13
+ }
14
+ return failure;
15
+ });
16
+ }
17
+ export function expectInvariant(failure, propertyName) {
18
+ if (!(failure instanceof PropertyInvariantViolation)) {
19
+ throw new Error(`expected invariant failure, got ${failure._tag}`);
20
+ }
21
+ if (failure.name !== propertyName) {
22
+ throw new Error(`expected ${propertyName}, got ${failure.name}`);
23
+ }
24
+ }
25
+ export function expectAssertionFailure(failure, propertyName) {
26
+ if (!(failure instanceof PropertyAssertionFailure)) {
27
+ throw new Error(`expected assertion failure, got ${failure._tag}`);
28
+ }
29
+ if (failure.name !== propertyName) {
30
+ throw new Error(`expected ${propertyName}, got ${failure.name}`);
31
+ }
32
+ }
33
+ //# sourceMappingURL=executable-proof-helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executable-proof-helpers.js","sourceRoot":"","sources":["../../../../src/testing/conformance/__divergence_proofs__/executable-proof-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACtD,OAAO,EACL,wBAAwB,EACxB,0BAA0B,GAG3B,MAAM,gBAAgB,CAAC;AAExB,MAAM,UAAU,mBAAmB,CACjC,QAA4B;IAE5B,OAAO,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QACzB,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAC9C,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC5B,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CACtB,IAAI,KAAK,CAAC,GAAG,QAAQ,CAAC,QAAQ,IAAI,QAAQ,CAAC,IAAI,sBAAsB,CAAC,CACvE,CAAC;QACJ,C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owner + participant route through a latency proxy. Owner
4
+ * sends `messages/send`; participant observes ≥1 inbound message
5
+ * event. Latency merely slows delivery; it must not drop events.
6
+ */
7
+ export declare function registerLatencyResilience(ctx: ConformanceRunContext): void;
8
+ /** Backpressure — DEFERRED to epic #186. */
9
+ export declare function registerBackpressure(ctx: ConformanceRunContext): void;
10
+ /**
11
+ * Slicer — partial-frame splits must not corrupt payload. Owner sends
12
+ * a message with a distinctive token; participant's snapshot contains
13
+ * that token verbatim.
14
+ */
15
+ export declare function registerSlicerFraming(ctx: ConformanceRunContext): void;
16
+ /**
17
+ * reset_peer — mid-flight the toxic forcibly resets the connection.
18
+ * Spec invariant: sender's RPCs surface a typed `TransportClosedError`,
19
+ * never hang, never crash. Full store-and-replay (reconnect + missed-
20
+ * event replay) is a consumer-side concern driven by each real client
21
+ * against `TestServer`; protocol-level guarantee is that the TestClient
22
+ * surfaces the transport failure as a typed outcome.
23
+ */
24
+ export declare function registerResetPeerRecovery(ctx: ConformanceRunContext): void;
25
+ /**
26
+ * timeout — the toxic black-holes forwarding; the client must surface
27
+ * a typed `RpcTimeoutError` within its own timeout budget (not hang).
28
+ */
29
+ export declare function registerTimeoutSurface(ctx: ConformanceRunContext): void;
30
+ /**
31
+ * slow_close — close-frames are delayed by the toxic. The scope
32
+ * release must still complete within a bounded window so the suite
33
+ * doesn't leak descriptors.
34
+ */
35
+ export declare function registerSlowCloseCleanup(ctx: ConformanceRunContext): void;
36
+ //# sourceMappingURL=adversity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adversity.d.ts","sourceRoot":"","sources":["../../../src/testing/conformance/adversity.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AA4IzD;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,qBAAqB,GAAG,IAAI,CAiE1E;AAED,4CAA4C;AAC5C,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,qBAAqB,GAAG,IAAI,CAcrE;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,qBAAqB,GAAG,IAAI,CAgEtE;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,qBAAqB,GAAG,IAAI,CAkD1E;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,qBAAqB,GAAG,IAAI,CAgEvE;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,qBAAqB,GAAG,IAAI,CAyCzE"}
@@ -0,0 +1,360 @@
1
+ /**
2
+ * Adversity — each toxic property asserts the specific invariant spec
3
+ * #181 §5 names for that toxic. Not a one-size-fits-all body: the
4
+ * toxics have different failure modes, and the spec's contract for each
5
+ * is different.
6
+ *
7
+ * Historical grouping note: spec #181 §5 calls this "Tier D". Code uses
8
+ * semantic names only. Backpressure is a tombstone (→ #186).
9
+ *
10
+ * | Toxic | Spec asks (paraphrased) |
11
+ * |-------------|------------------------------------------------------|
12
+ * | latency | delivery invariant still holds under added latency |
13
+ * | slicer | delivery holds + payload byte-identical through splits |
14
+ * | reset_peer | sender's RPCs surface typed TransportClosedError |
15
+ * | timeout | caller surfaces typed RpcTimeoutError within budget |
16
+ * | slow_close | scope release completes within a bounded window |
17
+ *
18
+ * Principle 3: every property body is `Effect<void, PropertyFailure>`
19
+ * — no bare throws, no `Effect.void` shortcuts.
20
+ */
21
+ import { Clock, Effect } from "effect";
22
+ import { defaultToxicProfile } from "../toxics/defaults.js";
23
+ import { makeTestClient } from "../test-client.js";
24
+ import { registerTestAgent } from "../agent-registration.js";
25
+ import { PropertyDeferred, PropertyInvariantViolation, PropertyUnavailable, registerProperty, } from "./registry.js";
26
+ const CATEGORY = "adversity";
27
+ const DEFAULT_CAPTURE_CAPACITY = 128;
28
+ /** Acquire a TestClient that routes through the Toxiproxy proxy. */
29
+ function acquireProxiedClient(ctx, proxy, name, defaultTimeoutMs, unavailable) {
30
+ // Preserve the upstream path (e.g., `/ws`) when building the
31
+ // proxy-facing URL: Toxiproxy is a raw TCP forwarder, so the client's
32
+ // upgrade path must match what the server's HTTP router expects.
33
+ const upstreamPath = new URL(ctx.realServer.wsUrl).pathname;
34
+ const proxiedUrl = `${proxy.listenUrl}${upstreamPath}`;
35
+ return Effect.gen(function* () {
36
+ const agent = yield* registerTestAgent({
37
+ baseUrl: ctx.realServer.baseUrl,
38
+ name,
39
+ }).pipe(Effect.mapError((e) => unavailable(`register: ${e.body}`)));
40
+ const client = yield* makeTestClient({
41
+ serverUrl: proxiedUrl,
42
+ agentKey: agent.apiKey,
43
+ agentId: agent.agentId,
44
+ defaultTimeoutMs,
45
+ captureCapacity: DEFAULT_CAPTURE_CAPACITY,
46
+ }).pipe(Effect.mapError((e) => unavailable(`makeTestClient: ${String(e)}`)));
47
+ return { agent, client };
48
+ });
49
+ }
50
+ /**
51
+ * Factory — wire a Toxiproxy proxy + attach the toxic; hand a body the
52
+ * proxy. Hard-deadlines each property body so a hanging toxic can't
53
+ * block the suite indefinitely; if the deadline fires, the property
54
+ * reports `PropertyUnavailable` (not a pass, not a crash).
55
+ */
56
+ const PROPERTY_BUDGET_MS = 15_000;
57
+ function withToxicProxy(opts) {
58
+ const { ctx, propertyName, description, proxyName, profile, body } = opts;
59
+ const toxiproxy = ctx.toxiproxy;
60
+ const run = toxiproxy === null
61
+ ? Effect.fail(new PropertyUnavailable({
62
+ category: CATEGORY,
63
+ name: propertyName,
64
+ reason: "Toxiproxy client not provisioned for this run",
65
+ }))
66
+ : (() => {
67
+ const upstreamHostPort = ctx.realServer.wsUrl
68
+ .replace(/^ws:\/\//, "")
69
+ .replace(/\/.*$/, "");
70
+ const unavailable = (reason) => new PropertyUnavailable({
71
+ category: CATEGORY,
72
+ name: propertyName,
73
+ reason,
74
+ });
75
+ return Effect.scoped(Effect.gen(function* () {
76
+ const proxy = yield* toxiproxy
77
+ .proxy({ name: proxyName, upstream: upstreamHostPort })
78
+ .pipe(Effect.mapError((e) => unavailable(`proxy: ${e.body}`)));
79
+ const attachToxic = proxy
80
+ .withToxic(profile)
81
+ .pipe(Effect.mapError((e) => unavailable(`toxic: ${e.body}`)), Effect.asVoid);
82
+ yield* body({ proxy, unavailable, attachToxic });
83
+ })).pipe(Effect.timeoutFail({
84
+ duration: `${PROPERTY_BUDGET_MS} millis`,
85
+ onTimeout: () => unavailable(`property exceeded ${PROPERTY_BUDGET_MS}ms budget under toxic`),
86
+ }));
87
+ })();
88
+ registerProperty(ctx, CATEGORY, propertyName, description, run);
89
+ }
90
+ /**
91
+ * Latency — owner + participant route through a latency proxy. Owner
92
+ * sends `messages/send`; participant observes ≥1 inbound message
93
+ * event. Latency merely slows delivery; it must not drop events.
94
+ */
95
+ export function registerLatencyResilience(ctx) {
96
+ withToxicProxy({
97
+ ctx,
98
+ propertyName: "latency-resilience",
99
+ description: "fan-out delivery survives added latency + jitter",
100
+ proxyName: `lat-${ctx.seed}-${Math.random().toString(36).slice(2, 8)}`,
101
+ profile: defaultToxicProfile.latency,
102
+ body: ({ proxy, unavailable, attachToxic }) => Effect.gen(function* () {
103
+ const owner = yield* acquireProxiedClient(ctx, proxy, `lat-${ctx.seed}-o`, 6000, unavailable);
104
+ const participant = yield* acquireProxiedClient(ctx, proxy, `lat-${ctx.seed}-p`, 6000, unavailable);
105
+ const conv = yield* createOneOnOneConversation(owner, participant);
106
+ if (conv.kind !== "ok") {
107
+ return yield* Effect.fail(new PropertyInvariantViolation({
108
+ category: CATEGORY,
109
+ name: "latency-resilience",
110
+ reason: conv.reason,
111
+ }));
112
+ }
113
+ yield* Effect.scoped(Effect.gen(function* () {
114
+ yield* attachToxic;
115
+ yield* owner.client
116
+ .sendRpc("messages/send", {
117
+ conversationId: conv.conversationId,
118
+ parts: [{ type: "text", text: "lat-ping" }],
119
+ })
120
+ .pipe(Effect.either);
121
+ // 100ms latency + 50ms jitter → 600ms window is generous.
122
+ yield* Effect.sleep("600 millis");
123
+ }));
124
+ const snap = yield* participant.client.snapshot;
125
+ const delivered = snap.filter((s) => s.kind === "inbound" &&
126
+ s.frame?.type === "event" &&
127
+ typeof s.frame.event === "string" &&
128
+ s.frame.event.includes("message")).length;
129
+ if (delivered === 0) {
130
+ return yield* Effect.fail(new PropertyInvariantViolation({
131
+ category: CATEGORY,
132
+ name: "latency-resilience",
133
+ reason: "latency toxic dropped all events",
134
+ }));
135
+ }
136
+ }),
137
+ });
138
+ }
139
+ /** Backpressure — DEFERRED to epic #186. */
140
+ export function registerBackpressure(ctx) {
141
+ registerProperty(ctx, CATEGORY, "backpressure", "backpressure property deferred to #186 — BackpressurePolicy not extant", Effect.fail(new PropertyDeferred({
142
+ category: CATEGORY,
143
+ name: "backpressure",
144
+ followUp: "https://github.com/chughtapan/moltzap/issues/186",
145
+ })));
146
+ }
147
+ /**
148
+ * Slicer — partial-frame splits must not corrupt payload. Owner sends
149
+ * a message with a distinctive token; participant's snapshot contains
150
+ * that token verbatim.
151
+ */
152
+ export function registerSlicerFraming(ctx) {
153
+ withToxicProxy({
154
+ ctx,
155
+ propertyName: "slicer-framing",
156
+ description: "partial-frame slicing preserves payload byte-identity",
157
+ proxyName: `sli-${ctx.seed}-${Math.random().toString(36).slice(2, 8)}`,
158
+ profile: defaultToxicProfile.slicer,
159
+ body: ({ proxy, unavailable, attachToxic }) => Effect.gen(function* () {
160
+ const owner = yield* acquireProxiedClient(ctx, proxy, `sli-${ctx.seed}-o`, 8000, unavailable);
161
+ const participant = yield* acquireProxiedClient(ctx, proxy, `sli-${ctx.seed}-p`, 8000, unavailable);
162
+ const conv = yield* createOneOnOneConversation(owner, participant);
163
+ if (conv.kind !== "ok") {
164
+ return yield* Effect.fail(new PropertyInvariantViolation({
165
+ category: CATEGORY,
166
+ name: "slicer-framing",
167
+ reason: conv.reason,
168
+ }));
169
+ }
170
+ const token = `sli-token-${ctx.seed}-${Date.now().toString(36)}`;
171
+ yield* Effect.scoped(Effect.gen(function* () {
172
+ yield* attachToxic;
173
+ yield* owner.client
174
+ .sendRpc("messages/send", {
175
+ conversationId: conv.conversationId,
176
+ parts: [{ type: "text", text: token }],
177
+ })
178
+ .pipe(Effect.either);
179
+ yield* Effect.sleep("1200 millis"); // slicer fragments are slow
180
+ }));
181
+ const snap = yield* participant.client.snapshot;
182
+ const matched = snap.some((s) => s.kind === "inbound" &&
183
+ s.frame?.type === "event" &&
184
+ s.raw.includes(token));
185
+ if (!matched) {
186
+ return yield* Effect.fail(new PropertyInvariantViolation({
187
+ category: CATEGORY,
188
+ name: "slicer-framing",
189
+ reason: `token ${token} not reassembled in participant's frames`,
190
+ }));
191
+ }
192
+ }),
193
+ });
194
+ }
195
+ /**
196
+ * reset_peer — mid-flight the toxic forcibly resets the connection.
197
+ * Spec invariant: sender's RPCs surface a typed `TransportClosedError`,
198
+ * never hang, never crash. Full store-and-replay (reconnect + missed-
199
+ * event replay) is a consumer-side concern driven by each real client
200
+ * against `TestServer`; protocol-level guarantee is that the TestClient
201
+ * surfaces the transport failure as a typed outcome.
202
+ */
203
+ export function registerResetPeerRecovery(ctx) {
204
+ withToxicProxy({
205
+ ctx,
206
+ propertyName: "reset-peer-recovery",
207
+ description: "reset_peer surfaces TransportClosedError without hanging",
208
+ proxyName: `rst-${ctx.seed}-${Math.random().toString(36).slice(2, 8)}`,
209
+ profile: defaultToxicProfile.reset_peer,
210
+ body: ({ proxy, unavailable, attachToxic }) => Effect.gen(function* () {
211
+ const sender = yield* acquireProxiedClient(ctx, proxy, `rst-${ctx.seed}-s`,
212
+ // Deadline > reset_peer.timeoutMs (2000); bounded so a
213
+ // never-firing reset doesn't hang the suite.
214
+ 4000, unavailable);
215
+ const observed = yield* Effect.scoped(Effect.gen(function* () {
216
+ yield* attachToxic;
217
+ const start = yield* Clock.currentTimeMillis;
218
+ for (let i = 0; i < 10; i++) {
219
+ const outcome = yield* sender.client
220
+ .sendRpc("conversations/list", {})
221
+ .pipe(Effect.either);
222
+ if (outcome._tag === "Left" &&
223
+ outcome.left._tag === "TestingTransportClosedError") {
224
+ return true;
225
+ }
226
+ yield* Effect.sleep("300 millis");
227
+ const elapsed = (yield* Clock.currentTimeMillis) - start;
228
+ if (elapsed > 3500)
229
+ return false;
230
+ }
231
+ return false;
232
+ }));
233
+ if (!observed) {
234
+ return yield* Effect.fail(new PropertyUnavailable({
235
+ category: CATEGORY,
236
+ name: "reset-peer-recovery",
237
+ reason: "reset_peer toxic did not close within 3.5s budget",
238
+ }));
239
+ }
240
+ }),
241
+ });
242
+ }
243
+ /**
244
+ * timeout — the toxic black-holes forwarding; the client must surface
245
+ * a typed `RpcTimeoutError` within its own timeout budget (not hang).
246
+ */
247
+ export function registerTimeoutSurface(ctx) {
248
+ withToxicProxy({
249
+ ctx,
250
+ propertyName: "timeout-surface",
251
+ description: "timeout toxic surfaces typed RpcTimeoutError within budget",
252
+ proxyName: `to-${ctx.seed}-${Math.random().toString(36).slice(2, 8)}`,
253
+ profile: defaultToxicProfile.timeout,
254
+ body: ({ proxy, unavailable, attachToxic }) => Effect.gen(function* () {
255
+ // Client timeout must be LESS than the toxic's forwarding
256
+ // timeout so the RPC hits the client-side deadline first.
257
+ // defaultToxicProfile.timeout.timeoutMs = 5000. Set client to
258
+ // 1500ms for a fast, clear timeout surface.
259
+ const proxied = yield* acquireProxiedClient(ctx, proxy, `to-${ctx.seed}-c`, 1500, unavailable);
260
+ const { outcomeTag, elapsed } = yield* Effect.scoped(Effect.gen(function* () {
261
+ yield* attachToxic;
262
+ const start = yield* Clock.currentTimeMillis;
263
+ const outcome = yield* proxied.client
264
+ .sendRpc("conversations/list", {})
265
+ .pipe(Effect.either);
266
+ const elapsed = (yield* Clock.currentTimeMillis) - start;
267
+ return {
268
+ outcomeTag: outcome._tag === "Right" ? "success" : outcome.left._tag,
269
+ elapsed,
270
+ };
271
+ }));
272
+ if (outcomeTag === "success") {
273
+ return yield* Effect.fail(new PropertyInvariantViolation({
274
+ category: CATEGORY,
275
+ name: "timeout-surface",
276
+ reason: "RPC through timeout toxic unexpectedly succeeded",
277
+ }));
278
+ }
279
+ if (outcomeTag !== "TestingRpcTimeoutError") {
280
+ return yield* Effect.fail(new PropertyInvariantViolation({
281
+ category: CATEGORY,
282
+ name: "timeout-surface",
283
+ reason: `expected RpcTimeoutError, got ${outcomeTag}`,
284
+ }));
285
+ }
286
+ if (elapsed > 3000) {
287
+ return yield* Effect.fail(new PropertyInvariantViolation({
288
+ category: CATEGORY,
289
+ name: "timeout-surface",
290
+ reason: `timeout fired at ${elapsed}ms, expected <3000ms`,
291
+ }));
292
+ }
293
+ }),
294
+ });
295
+ }
296
+ /**
297
+ * slow_close — close-frames are delayed by the toxic. The scope
298
+ * release must still complete within a bounded window so the suite
299
+ * doesn't leak descriptors.
300
+ */
301
+ export function registerSlowCloseCleanup(ctx) {
302
+ withToxicProxy({
303
+ ctx,
304
+ propertyName: "slow-close-cleanup",
305
+ description: "slow_close toxic does not leak descriptors beyond 2s",
306
+ proxyName: `sc-${ctx.seed}-${Math.random().toString(36).slice(2, 8)}`,
307
+ profile: defaultToxicProfile.slow_close,
308
+ body: ({ proxy, unavailable, attachToxic }) => Effect.gen(function* () {
309
+ const start = yield* Clock.currentTimeMillis;
310
+ yield* attachToxic.pipe(Effect.orElseSucceed(() => undefined));
311
+ // Open + close a client scoped to this Effect.gen block; when
312
+ // Effect.scoped unwinds, the client must release within the
313
+ // 2s budget even though the toxic delays its close-frame.
314
+ yield* Effect.scoped(Effect.gen(function* () {
315
+ const _client = yield* acquireProxiedClient(ctx, proxy, `sc-${ctx.seed}-c`, 2000, unavailable);
316
+ // A single RPC proves the socket is alive before close.
317
+ yield* _client.client
318
+ .sendRpc("conversations/list", {})
319
+ .pipe(Effect.either);
320
+ }));
321
+ const elapsed = (yield* Clock.currentTimeMillis) - start;
322
+ if (elapsed > 5000) {
323
+ return yield* Effect.fail(new PropertyInvariantViolation({
324
+ category: CATEGORY,
325
+ name: "slow-close-cleanup",
326
+ reason: `scope release took ${elapsed}ms under slow_close (budget 5000ms)`,
327
+ }));
328
+ }
329
+ }),
330
+ });
331
+ }
332
+ function createOneOnOneConversation(owner, participant) {
333
+ return Effect.gen(function* () {
334
+ const create = yield* owner.client
335
+ .sendRpc("conversations/create", {
336
+ type: "group",
337
+ name: `adv-conv-${owner.agent.name}`,
338
+ participants: [
339
+ { type: "agent", id: participant.agent.agentId },
340
+ ],
341
+ })
342
+ .pipe(Effect.either);
343
+ if (create._tag === "Left") {
344
+ return {
345
+ kind: "error",
346
+ reason: `conversations/create under toxic: ${create.left._tag}`,
347
+ };
348
+ }
349
+ const id = create.right.conversation
350
+ ?.id;
351
+ if (typeof id !== "string" || id.length === 0) {
352
+ return {
353
+ kind: "error",
354
+ reason: "conversations/create returned no conversation.id",
355
+ };
356
+ }
357
+ return { kind: "ok", conversationId: id };
358
+ });
359
+ }
360
+ //# sourceMappingURL=adversity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adversity.js","sourceRoot":"","sources":["../../../src/testing/conformance/adversity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,EAAc,MAAM,QAAQ,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAG5D,OAAO,EAAE,cAAc,EAAmB,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAkB,MAAM,0BAA0B,CAAC;AAE7E,OAAO,EACL,gBAAgB,EAChB,0BAA0B,EAC1B,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,eAAe,CAAC;AAEvB,MAAM,QAAQ,GAAG,WAAoB,CAAC;AACtC,MAAM,wBAAwB,GAAG,GAAG,CAAC;AAErC,oEAAoE;AACpE,SAAS,oBAAoB,CAC3B,GAA0B,EAC1B,KAAY,EACZ,IAAY,EACZ,gBAAwB,EACxB,WAAoD;IAMpD,6DAA6D;IAC7D,sEAAsE;IACtE,iEAAiE;IACjE,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,GAA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