@moltzap/protocol 2026.408.0 → 2026.425.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/rpc-registry.d.ts +446 -0
- package/dist/rpc-registry.d.ts.map +1 -0
- package/dist/rpc-registry.js +67 -0
- package/dist/rpc-registry.js.map +1 -0
- package/dist/rpc.d.ts +42 -0
- package/dist/rpc.d.ts.map +1 -0
- package/dist/rpc.js +29 -0
- package/dist/rpc.js.map +1 -0
- package/dist/schema/apps.d.ts +86 -0
- package/dist/schema/apps.d.ts.map +1 -0
- package/dist/schema/apps.js +77 -0
- package/dist/schema/apps.js.map +1 -0
- package/dist/schema/contacts.d.ts +8 -18
- package/dist/schema/contacts.d.ts.map +1 -1
- package/dist/schema/contacts.js +9 -13
- package/dist/schema/contacts.js.map +1 -1
- package/dist/schema/conversations.d.ts +15 -8
- package/dist/schema/conversations.d.ts.map +1 -1
- package/dist/schema/conversations.js +18 -7
- package/dist/schema/conversations.js.map +1 -1
- package/dist/schema/delivery.d.ts +1 -4
- package/dist/schema/delivery.d.ts.map +1 -1
- package/dist/schema/delivery.js +2 -3
- package/dist/schema/delivery.js.map +1 -1
- package/dist/schema/errors.d.ts +13 -0
- package/dist/schema/errors.d.ts.map +1 -1
- package/dist/schema/errors.js +14 -0
- package/dist/schema/errors.js.map +1 -1
- package/dist/schema/events.d.ts +112 -93
- package/dist/schema/events.d.ts.map +1 -1
- package/dist/schema/events.js +84 -25
- package/dist/schema/events.js.map +1 -1
- package/dist/schema/identity.d.ts +19 -17
- package/dist/schema/identity.d.ts.map +1 -1
- package/dist/schema/identity.js +7 -14
- package/dist/schema/identity.js.map +1 -1
- package/dist/schema/index.d.ts +4 -2
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/index.js +4 -2
- package/dist/schema/index.js.map +1 -1
- package/dist/schema/messages.d.ts +3 -7
- package/dist/schema/messages.d.ts.map +1 -1
- package/dist/schema/messages.js +4 -6
- package/dist/schema/messages.js.map +1 -1
- package/dist/schema/methods/apps.d.ts +123 -0
- package/dist/schema/methods/apps.d.ts.map +1 -0
- package/dist/schema/methods/apps.js +93 -0
- package/dist/schema/methods/apps.js.map +1 -0
- package/dist/schema/methods/auth.d.ts +102 -90
- package/dist/schema/methods/auth.d.ts.map +1 -1
- package/dist/schema/methods/auth.js +86 -74
- package/dist/schema/methods/auth.js.map +1 -1
- package/dist/schema/methods/contacts.d.ts +39 -74
- package/dist/schema/methods/contacts.d.ts.map +1 -1
- package/dist/schema/methods/contacts.js +35 -29
- package/dist/schema/methods/contacts.js.map +1 -1
- package/dist/schema/methods/conversations.d.ts +48 -52
- package/dist/schema/methods/conversations.d.ts.map +1 -1
- package/dist/schema/methods/conversations.js +89 -38
- package/dist/schema/methods/conversations.js.map +1 -1
- package/dist/schema/methods/invites.d.ts +1 -3
- package/dist/schema/methods/invites.d.ts.map +1 -1
- package/dist/schema/methods/invites.js +8 -1
- package/dist/schema/methods/invites.js.map +1 -1
- package/dist/schema/methods/messages.d.ts +12 -44
- package/dist/schema/methods/messages.d.ts.map +1 -1
- package/dist/schema/methods/messages.js +22 -28
- package/dist/schema/methods/messages.js.map +1 -1
- package/dist/schema/methods/presence.d.ts +7 -22
- package/dist/schema/methods/presence.d.ts.map +1 -1
- package/dist/schema/methods/presence.js +12 -6
- package/dist/schema/methods/presence.js.map +1 -1
- package/dist/schema/methods/push.d.ts +8 -6
- package/dist/schema/methods/push.d.ts.map +1 -1
- package/dist/schema/methods/push.js +20 -7
- package/dist/schema/methods/push.js.map +1 -1
- package/dist/schema/methods/system.d.ts +4 -0
- package/dist/schema/methods/system.d.ts.map +1 -0
- package/dist/schema/methods/system.js +11 -0
- package/dist/schema/methods/system.js.map +1 -0
- package/dist/schema/presence.d.ts +1 -12
- package/dist/schema/presence.d.ts.map +1 -1
- package/dist/schema/presence.js +2 -7
- package/dist/schema/presence.js.map +1 -1
- package/dist/schema/surfaces.d.ts +31 -25
- package/dist/schema/surfaces.d.ts.map +1 -1
- package/dist/schema/surfaces.js +40 -21
- package/dist/schema/surfaces.js.map +1 -1
- package/dist/testing/agent-registration.d.ts +49 -0
- package/dist/testing/agent-registration.d.ts.map +1 -0
- package/dist/testing/agent-registration.js +77 -0
- package/dist/testing/agent-registration.js.map +1 -0
- package/dist/testing/arbitraries/frames.d.ts +24 -0
- package/dist/testing/arbitraries/frames.d.ts.map +1 -0
- package/dist/testing/arbitraries/frames.js +36 -0
- package/dist/testing/arbitraries/frames.js.map +1 -0
- package/dist/testing/arbitraries/from-typebox.d.ts +37 -0
- package/dist/testing/arbitraries/from-typebox.d.ts.map +1 -0
- package/dist/testing/arbitraries/from-typebox.js +131 -0
- package/dist/testing/arbitraries/from-typebox.js.map +1 -0
- package/dist/testing/arbitraries/index.d.ts +4 -0
- package/dist/testing/arbitraries/index.d.ts.map +1 -0
- package/dist/testing/arbitraries/index.js +4 -0
- package/dist/testing/arbitraries/index.js.map +1 -0
- package/dist/testing/arbitraries/rpc.d.ts +66 -0
- package/dist/testing/arbitraries/rpc.d.ts.map +1 -0
- package/dist/testing/arbitraries/rpc.js +98 -0
- package/dist/testing/arbitraries/rpc.js.map +1 -0
- package/dist/testing/canonicalize.d.ts +38 -0
- package/dist/testing/canonicalize.d.ts.map +1 -0
- package/dist/testing/canonicalize.js +55 -0
- package/dist/testing/canonicalize.js.map +1 -0
- package/dist/testing/captures.d.ts +61 -0
- package/dist/testing/captures.d.ts.map +1 -0
- package/dist/testing/captures.js +99 -0
- package/dist/testing/captures.js.map +1 -0
- package/dist/testing/codec.d.ts +44 -0
- package/dist/testing/codec.d.ts.map +1 -0
- package/dist/testing/codec.js +170 -0
- package/dist/testing/codec.js.map +1 -0
- package/dist/testing/conformance/__divergence_proofs__/executable-proof-helpers.d.ts +6 -0
- package/dist/testing/conformance/__divergence_proofs__/executable-proof-helpers.d.ts.map +1 -0
- package/dist/testing/conformance/__divergence_proofs__/executable-proof-helpers.js +33 -0
- package/dist/testing/conformance/__divergence_proofs__/executable-proof-helpers.js.map +1 -0
- package/dist/testing/conformance/adversity.d.ts +36 -0
- package/dist/testing/conformance/adversity.d.ts.map +1 -0
- package/dist/testing/conformance/adversity.js +360 -0
- package/dist/testing/conformance/adversity.js.map +1 -0
- package/dist/testing/conformance/boundary.d.ts +56 -0
- package/dist/testing/conformance/boundary.d.ts.map +1 -0
- package/dist/testing/conformance/boundary.js +129 -0
- package/dist/testing/conformance/boundary.js.map +1 -0
- package/dist/testing/conformance/client/_fixtures.d.ts +71 -0
- package/dist/testing/conformance/client/_fixtures.d.ts.map +1 -0
- package/dist/testing/conformance/client/_fixtures.js +102 -0
- package/dist/testing/conformance/client/_fixtures.js.map +1 -0
- package/dist/testing/conformance/client/adversity.d.ts +39 -0
- package/dist/testing/conformance/client/adversity.d.ts.map +1 -0
- package/dist/testing/conformance/client/adversity.js +162 -0
- package/dist/testing/conformance/client/adversity.js.map +1 -0
- package/dist/testing/conformance/client/boundary.d.ts +12 -0
- package/dist/testing/conformance/client/boundary.d.ts.map +1 -0
- package/dist/testing/conformance/client/boundary.js +68 -0
- package/dist/testing/conformance/client/boundary.js.map +1 -0
- package/dist/testing/conformance/client/delivery.d.ts +38 -0
- package/dist/testing/conformance/client/delivery.d.ts.map +1 -0
- package/dist/testing/conformance/client/delivery.js +202 -0
- package/dist/testing/conformance/client/delivery.js.map +1 -0
- package/dist/testing/conformance/client/index.d.ts +16 -0
- package/dist/testing/conformance/client/index.d.ts.map +1 -0
- package/dist/testing/conformance/client/index.js +16 -0
- package/dist/testing/conformance/client/index.js.map +1 -0
- package/dist/testing/conformance/client/rpc-semantics.d.ts +26 -0
- package/dist/testing/conformance/client/rpc-semantics.d.ts.map +1 -0
- package/dist/testing/conformance/client/rpc-semantics.js +145 -0
- package/dist/testing/conformance/client/rpc-semantics.js.map +1 -0
- package/dist/testing/conformance/client/runner.d.ts +258 -0
- package/dist/testing/conformance/client/runner.d.ts.map +1 -0
- package/dist/testing/conformance/client/runner.js +228 -0
- package/dist/testing/conformance/client/runner.js.map +1 -0
- package/dist/testing/conformance/client/schema-conformance.d.ts +25 -0
- package/dist/testing/conformance/client/schema-conformance.d.ts.map +1 -0
- package/dist/testing/conformance/client/schema-conformance.js +123 -0
- package/dist/testing/conformance/client/schema-conformance.js.map +1 -0
- package/dist/testing/conformance/client/suite.d.ts +90 -0
- package/dist/testing/conformance/client/suite.d.ts.map +1 -0
- package/dist/testing/conformance/client/suite.js +209 -0
- package/dist/testing/conformance/client/suite.js.map +1 -0
- package/dist/testing/conformance/coverage-policy.d.ts +8 -0
- package/dist/testing/conformance/coverage-policy.d.ts.map +1 -0
- package/dist/testing/conformance/coverage-policy.js +10 -0
- package/dist/testing/conformance/coverage-policy.js.map +1 -0
- package/dist/testing/conformance/delivery.d.ts +40 -0
- package/dist/testing/conformance/delivery.d.ts.map +1 -0
- package/dist/testing/conformance/delivery.js +231 -0
- package/dist/testing/conformance/delivery.js.map +1 -0
- package/dist/testing/conformance/env.d.ts +3 -0
- package/dist/testing/conformance/env.d.ts.map +1 -0
- package/dist/testing/conformance/env.js +14 -0
- package/dist/testing/conformance/env.js.map +1 -0
- package/dist/testing/conformance/index.d.ts +10 -0
- package/dist/testing/conformance/index.d.ts.map +1 -0
- package/dist/testing/conformance/index.js +10 -0
- package/dist/testing/conformance/index.js.map +1 -0
- package/dist/testing/conformance/registry.d.ts +93 -0
- package/dist/testing/conformance/registry.d.ts.map +1 -0
- package/dist/testing/conformance/registry.js +62 -0
- package/dist/testing/conformance/registry.js.map +1 -0
- package/dist/testing/conformance/rpc-semantics.d.ts +67 -0
- package/dist/testing/conformance/rpc-semantics.d.ts.map +1 -0
- package/dist/testing/conformance/rpc-semantics.js +394 -0
- package/dist/testing/conformance/rpc-semantics.js.map +1 -0
- package/dist/testing/conformance/runner.d.ts +78 -0
- package/dist/testing/conformance/runner.d.ts.map +1 -0
- package/dist/testing/conformance/runner.js +65 -0
- package/dist/testing/conformance/runner.js.map +1 -0
- package/dist/testing/conformance/schema-conformance.d.ts +30 -0
- package/dist/testing/conformance/schema-conformance.d.ts.map +1 -0
- package/dist/testing/conformance/schema-conformance.js +229 -0
- package/dist/testing/conformance/schema-conformance.js.map +1 -0
- package/dist/testing/conformance/suite.d.ts +92 -0
- package/dist/testing/conformance/suite.d.ts.map +1 -0
- package/dist/testing/conformance/suite.js +233 -0
- package/dist/testing/conformance/suite.js.map +1 -0
- package/dist/testing/errors.d.ts +78 -0
- package/dist/testing/errors.d.ts.map +1 -0
- package/dist/testing/errors.js +34 -0
- package/dist/testing/errors.js.map +1 -0
- package/dist/testing/index.d.ts +25 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +37 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/models/dispatch.d.ts +61 -0
- package/dist/testing/models/dispatch.d.ts.map +1 -0
- package/dist/testing/models/dispatch.js +197 -0
- package/dist/testing/models/dispatch.js.map +1 -0
- package/dist/testing/models/index.d.ts +3 -0
- package/dist/testing/models/index.d.ts.map +1 -0
- package/dist/testing/models/index.js +3 -0
- package/dist/testing/models/index.js.map +1 -0
- package/dist/testing/models/state.d.ts +37 -0
- package/dist/testing/models/state.d.ts.map +1 -0
- package/dist/testing/models/state.js +14 -0
- package/dist/testing/models/state.js.map +1 -0
- package/dist/testing/test-client.d.ts +70 -0
- package/dist/testing/test-client.d.ts.map +1 -0
- package/dist/testing/test-client.js +266 -0
- package/dist/testing/test-client.js.map +1 -0
- package/dist/testing/test-server.d.ts +62 -0
- package/dist/testing/test-server.d.ts.map +1 -0
- package/dist/testing/test-server.js +134 -0
- package/dist/testing/test-server.js.map +1 -0
- package/dist/testing/toxics/client.d.ts +52 -0
- package/dist/testing/toxics/client.d.ts.map +1 -0
- package/dist/testing/toxics/client.js +120 -0
- package/dist/testing/toxics/client.js.map +1 -0
- package/dist/testing/toxics/defaults.d.ts +43 -0
- package/dist/testing/toxics/defaults.d.ts.map +1 -0
- package/dist/testing/toxics/defaults.js +9 -0
- package/dist/testing/toxics/defaults.js.map +1 -0
- package/dist/testing/toxics/index.d.ts +4 -0
- package/dist/testing/toxics/index.d.ts.map +1 -0
- package/dist/testing/toxics/index.js +4 -0
- package/dist/testing/toxics/index.js.map +1 -0
- package/dist/testing/toxics/profile.d.ts +69 -0
- package/dist/testing/toxics/profile.d.ts.map +1 -0
- package/dist/testing/toxics/profile.js +57 -0
- package/dist/testing/toxics/profile.js.map +1 -0
- package/dist/types.d.ts +7 -11
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -1
- package/dist/validators.d.ts +49 -177
- package/dist/validators.d.ts.map +1 -1
- package/dist/validators.js +77 -48
- package/dist/validators.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +18 -40
- package/LICENSE +0 -21
- package/dist/optional/contact-events.d.ts +0 -3
- package/dist/optional/contact-events.d.ts.map +0 -1
- package/dist/optional/contact-events.js +0 -5
- package/dist/optional/contact-events.js.map +0 -1
- package/dist/optional/contact-methods.d.ts +0 -5
- package/dist/optional/contact-methods.d.ts.map +0 -1
- package/dist/optional/contact-methods.js +0 -5
- package/dist/optional/contact-methods.js.map +0 -1
- package/dist/phone-hash.d.ts +0 -10
- package/dist/phone-hash.d.ts.map +0 -1
- package/dist/phone-hash.js +0 -17
- package/dist/phone-hash.js.map +0 -1
- package/dist/schema/methods/phone-contacts.d.ts +0 -30
- package/dist/schema/methods/phone-contacts.d.ts.map +0 -1
- package/dist/schema/methods/phone-contacts.js +0 -10
- package/dist/schema/methods/phone-contacts.js.map +0 -1
- package/dist/test-client.d.ts +0 -34
- package/dist/test-client.d.ts.map +0 -1
- package/dist/test-client.js +0 -176
- package/dist/test-client.js.map +0 -1
- package/dist/test-fixtures/phone-hashes.d.ts +0 -18
- package/dist/test-fixtures/phone-hashes.d.ts.map +0 -1
- package/dist/test-fixtures/phone-hashes.js +0 -24
- package/dist/test-fixtures/phone-hashes.js.map +0 -1
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
declare const TransportClosedError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
2
|
+
readonly _tag: "TestingTransportClosedError";
|
|
3
|
+
} & Readonly<A>;
|
|
4
|
+
/** Peer closed the underlying WS before a response arrived. */
|
|
5
|
+
export declare class TransportClosedError extends TransportClosedError_base<{
|
|
6
|
+
readonly direction: "outbound" | "inbound";
|
|
7
|
+
readonly code: number;
|
|
8
|
+
readonly reason: string;
|
|
9
|
+
}> {
|
|
10
|
+
}
|
|
11
|
+
declare const TransportIoError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
12
|
+
readonly _tag: "TestingTransportIoError";
|
|
13
|
+
} & Readonly<A>;
|
|
14
|
+
/** Underlying transport raised (socket error, DNS, TLS, etc.). */
|
|
15
|
+
export declare class TransportIoError extends TransportIoError_base<{
|
|
16
|
+
readonly direction: "outbound" | "inbound";
|
|
17
|
+
readonly cause: unknown;
|
|
18
|
+
}> {
|
|
19
|
+
}
|
|
20
|
+
declare const FrameSchemaError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
21
|
+
readonly _tag: "TestingFrameSchemaError";
|
|
22
|
+
} & Readonly<A>;
|
|
23
|
+
/** A frame read off the wire failed `Value.Check` against its schema. */
|
|
24
|
+
export declare class FrameSchemaError extends FrameSchemaError_base<{
|
|
25
|
+
readonly direction: "outbound" | "inbound";
|
|
26
|
+
readonly expected: "request" | "response" | "event";
|
|
27
|
+
readonly raw: string;
|
|
28
|
+
readonly reason: string;
|
|
29
|
+
}> {
|
|
30
|
+
}
|
|
31
|
+
declare const RpcTimeoutError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
32
|
+
readonly _tag: "TestingRpcTimeoutError";
|
|
33
|
+
} & Readonly<A>;
|
|
34
|
+
/** Wall-clock deadline for a request-id expired before a response. */
|
|
35
|
+
export declare class RpcTimeoutError extends RpcTimeoutError_base<{
|
|
36
|
+
readonly method: string;
|
|
37
|
+
readonly requestId: string;
|
|
38
|
+
readonly timeoutMs: number;
|
|
39
|
+
}> {
|
|
40
|
+
}
|
|
41
|
+
declare const RpcResponseError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
42
|
+
readonly _tag: "TestingRpcResponseError";
|
|
43
|
+
} & Readonly<A>;
|
|
44
|
+
/** Server returned a typed `ErrorFrame` for a request. */
|
|
45
|
+
export declare class RpcResponseError extends RpcResponseError_base<{
|
|
46
|
+
readonly method: string;
|
|
47
|
+
readonly requestId: string;
|
|
48
|
+
readonly code: number;
|
|
49
|
+
readonly message: string;
|
|
50
|
+
readonly data?: unknown;
|
|
51
|
+
}> {
|
|
52
|
+
}
|
|
53
|
+
declare const ToxicControlError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
54
|
+
readonly _tag: "TestingToxicControlError";
|
|
55
|
+
} & Readonly<A>;
|
|
56
|
+
/** Toxiproxy HTTP API returned a non-2xx, or the control endpoint is down. */
|
|
57
|
+
export declare class ToxicControlError extends ToxicControlError_base<{
|
|
58
|
+
readonly op: "create-proxy" | "delete-proxy" | "add-toxic" | "remove-toxic";
|
|
59
|
+
readonly status: number;
|
|
60
|
+
readonly body: string;
|
|
61
|
+
}> {
|
|
62
|
+
}
|
|
63
|
+
declare const RealServerAcquireError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
64
|
+
readonly _tag: "TestingRealServerAcquireError";
|
|
65
|
+
} & Readonly<A>;
|
|
66
|
+
/** Consumer-supplied `realServer()` factory threw or the handle was unusable. */
|
|
67
|
+
export declare class RealServerAcquireError extends RealServerAcquireError_base<{
|
|
68
|
+
readonly cause: unknown;
|
|
69
|
+
}> {
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Discriminated union of every error the testing surface can surface.
|
|
73
|
+
* Exhaustiveness over optionality: properties `match` on `_tag` and the
|
|
74
|
+
* compiler flags a missing branch if this union grows.
|
|
75
|
+
*/
|
|
76
|
+
export type TestingError = TransportClosedError | TransportIoError | FrameSchemaError | RpcTimeoutError | RpcResponseError | ToxicControlError | RealServerAcquireError;
|
|
77
|
+
export {};
|
|
78
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/testing/errors.ts"],"names":[],"mappings":";;;AAaA,+DAA+D;AAC/D,qBAAa,oBAAqB,SAAQ,0BAExC;IACA,QAAQ,CAAC,SAAS,EAAE,UAAU,GAAG,SAAS,CAAC;IAC3C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,CAAC;CAAG;;;;AAEL,kEAAkE;AAClE,qBAAa,gBAAiB,SAAQ,sBAEpC;IACA,QAAQ,CAAC,SAAS,EAAE,UAAU,GAAG,SAAS,CAAC;IAC3C,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB,CAAC;CAAG;;;;AAEL,yEAAyE;AACzE,qBAAa,gB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,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tagged errors surfaced by the `@moltzap/protocol/testing` primitives.
|
|
3
|
+
*
|
|
4
|
+
* Every public `TestClient` / `TestServer` operation returns an
|
|
5
|
+
* `Effect.Effect<T, TestingError, ...>`. Downstream fast-check properties
|
|
6
|
+
* discriminate on `_tag` so shrinks land on a named failure mode rather
|
|
7
|
+
* than an anonymous `unknown`.
|
|
8
|
+
*
|
|
9
|
+
* Invariant I3 (schema is source of truth) lives here: frame-level
|
|
10
|
+
* validation failures raise `FrameSchemaError` on both directions.
|
|
11
|
+
*/
|
|
12
|
+
import { Data } from "effect";
|
|
13
|
+
/** Peer closed the underlying WS before a response arrived. */
|
|
14
|
+
export class TransportClosedError extends Data.TaggedError("TestingTransportClosedError") {
|
|
15
|
+
}
|
|
16
|
+
/** Underlying transport raised (socket error, DNS, TLS, etc.). */
|
|
17
|
+
export class TransportIoError extends Data.TaggedError("TestingTransportIoError") {
|
|
18
|
+
}
|
|
19
|
+
/** A frame read off the wire failed `Value.Check` against its schema. */
|
|
20
|
+
export class FrameSchemaError extends Data.TaggedError("TestingFrameSchemaError") {
|
|
21
|
+
}
|
|
22
|
+
/** Wall-clock deadline for a request-id expired before a response. */
|
|
23
|
+
export class RpcTimeoutError extends Data.TaggedError("TestingRpcTimeoutError") {
|
|
24
|
+
}
|
|
25
|
+
/** Server returned a typed `ErrorFrame` for a request. */
|
|
26
|
+
export class RpcResponseError extends Data.TaggedError("TestingRpcResponseError") {
|
|
27
|
+
}
|
|
28
|
+
/** Toxiproxy HTTP API returned a non-2xx, or the control endpoint is down. */
|
|
29
|
+
export class ToxicControlError extends Data.TaggedError("TestingToxicControlError") {
|
|
30
|
+
}
|
|
31
|
+
/** Consumer-supplied `realServer()` factory threw or the handle was unusable. */
|
|
32
|
+
export class RealServerAcquireError extends Data.TaggedError("TestingRealServerAcquireError") {
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/testing/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,+DAA+D;AAC/D,MAAM,OAAO,oBAAqB,SAAQ,IAAI,CAAC,WAAW,CACxD,6BAA6B,CAK7B;CAAG;AAEL,kEAAkE;AAClE,MAAM,OAAO,gBAAiB,SAAQ,IAAI,CAAC,WAAW,CACpD,yBAAyB,CAIzB;CAAG;AAEL,yEAAyE;AACzE,MAAM,OAAO,gBAAiB,SAAQ,IAAI,CAAC,WAAW,CACpD,yBAAyB,CAMzB;CAAG;AAEL,sEAAsE;AACtE,MAAM,OAAO,eAAgB,SAAQ,IAAI,CAAC,WAAW,CACnD,wBAAwB,CAKxB;CAAG;AAEL,0DAA0D;AAC1D,MAAM,OAAO,gBAAiB,SAAQ,IAAI,CAAC,WAAW,CACpD,yBAAyB,CAOzB;CAAG;AAEL,8EAA8E;AAC9E,MAAM,OAAO,iBAAkB,SAAQ,IAAI,CAAC,WAAW,CACrD,0BAA0B,CAK1B;CAAG;AAEL,iFAAiF;AACjF,MAAM,OAAO,sBAAuB,SAAQ,IAAI,CAAC,WAAW,CAC1D,+BAA+B,CAG/B;CAAG"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@moltzap/protocol/testing` — TestClient + TestServer primitives,
|
|
3
|
+
* reference model, arbitrary derivation, Toxiproxy adversity layer, and
|
|
4
|
+
* the five-tier conformance runner.
|
|
5
|
+
*
|
|
6
|
+
* Subpath export wiring lives in `packages/protocol/package.json` and is
|
|
7
|
+
* added by the implement-staff modality (architect charter forbids
|
|
8
|
+
* `package.json` edits in the stub PR).
|
|
9
|
+
*/
|
|
10
|
+
export { type CloseableTestClient, type TestClient, type TestClientConfig, makeCloseableTestClient, makeTestClient, } from "./test-client.js";
|
|
11
|
+
export { type TestServer, type TestServerConfig, type TestServerConnection, makeTestServer, } from "./test-server.js";
|
|
12
|
+
export { type CaptureBuffer, type CapturedFrame, type CaptureKind, makeCaptureBuffer, mergeCaptures, recordFrame, recordMalformed, } from "./captures.js";
|
|
13
|
+
export { type AnyFrame, type MalformedFrameKind, encodeFrame, decodeFrame, malformFrame, } from "./codec.js";
|
|
14
|
+
export { type TestingError, TransportClosedError, TransportIoError, FrameSchemaError, RpcTimeoutError, RpcResponseError, ToxicControlError, RealServerAcquireError, } from "./errors.js";
|
|
15
|
+
export { type TestAgent, AgentRegistrationError, registerTestAgent, } from "./agent-registration.js";
|
|
16
|
+
export * as arbitraries from "./arbitraries/index.js";
|
|
17
|
+
export * as models from "./models/index.js";
|
|
18
|
+
export * as toxics from "./toxics/index.js";
|
|
19
|
+
export { type ConformanceArtifact, type ConformanceRunContext, type ConformanceRunOptions, type ConformanceSuiteOptions, type PropertyCategory, type PropertyFailure, type PropertyRun, type RealServerHandle, type RegisteredProperty, type SuiteResult, type WebhookAdapterProbe, PropertyAssertionFailure, PropertyDeferred, PropertyInvariantViolation, PropertyUnavailable, acquireRunContext, assertProperty, collectProperties, registerAllProperties, registerProperty, runAllProperties, runConformance, runConformanceSuite, } from "./conformance/index.js";
|
|
20
|
+
export * as conformance from "./conformance/index.js";
|
|
21
|
+
export * as clientConformance from "./conformance/client/index.js";
|
|
22
|
+
export type { ClientConformanceRunContext, ClientConformanceRunOptions, ObservedEvent, RealClientCloseEvent, RealClientEventFilter, RealClientEventSubscriber, RealClientFactoryArgs, RealClientHandle, RealClientRpcCaller, RealClientSubscription, } from "./conformance/client/runner.js";
|
|
23
|
+
export { RealClientLifecycleError, RealClientRpcError, } from "./conformance/client/runner.js";
|
|
24
|
+
export type { ClientConformanceSuiteOptions, JointConformanceSuiteOptions, } from "./conformance/client/suite.js";
|
|
25
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,uBAAuB,EACvB,cAAc,GACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,cAAc,GACf,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,eAAe,GAChB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,kBAAkB,EACvB,WAAW,EACX,WAAW,EACX,YAAY,GACb,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,KAAK,YAAY,EACjB,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,KAAK,SAAS,EACd,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,KAAK,WAAW,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAK5C,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACxB,wBAAwB,EACxB,gBAAgB,EAChB,0BAA0B,EAC1B,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACjB,qBAAqB,EACrB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,mBAAmB,GACpB,MAAM,wBAAwB,CAAC;AAIhC,OAAO,KAAK,WAAW,MAAM,wBAAwB,CAAC;AAMtD,OAAO,KAAK,iBAAiB,MAAM,+BAA+B,CAAC;AAKnE,YAAY,EACV,2BAA2B,EAC3B,2BAA2B,EAC3B,aAAa,EACb,oBAAoB,EACpB,qBAAqB,EACrB,yBAAyB,EACzB,qBAAqB,EACrB,gBAAgB,EAChB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,wBAAwB,EACxB,kBAAkB,GACnB,MAAM,gCAAgC,CAAC;AACxC,YAAY,EACV,6BAA6B,EAC7B,4BAA4B,GAC7B,MAAM,+BAA+B,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@moltzap/protocol/testing` — TestClient + TestServer primitives,
|
|
3
|
+
* reference model, arbitrary derivation, Toxiproxy adversity layer, and
|
|
4
|
+
* the five-tier conformance runner.
|
|
5
|
+
*
|
|
6
|
+
* Subpath export wiring lives in `packages/protocol/package.json` and is
|
|
7
|
+
* added by the implement-staff modality (architect charter forbids
|
|
8
|
+
* `package.json` edits in the stub PR).
|
|
9
|
+
*/
|
|
10
|
+
// Primitives.
|
|
11
|
+
export { makeCloseableTestClient, makeTestClient, } from "./test-client.js";
|
|
12
|
+
export { makeTestServer, } from "./test-server.js";
|
|
13
|
+
// Capture + codec primitives.
|
|
14
|
+
export { makeCaptureBuffer, mergeCaptures, recordFrame, recordMalformed, } from "./captures.js";
|
|
15
|
+
export { encodeFrame, decodeFrame, malformFrame, } from "./codec.js";
|
|
16
|
+
// Errors.
|
|
17
|
+
export { TransportClosedError, TransportIoError, FrameSchemaError, RpcTimeoutError, RpcResponseError, ToxicControlError, RealServerAcquireError, } from "./errors.js";
|
|
18
|
+
// Test-agent registration helper.
|
|
19
|
+
export { AgentRegistrationError, registerTestAgent, } from "./agent-registration.js";
|
|
20
|
+
// Arbitraries, models, toxics — namespaced to keep names scoped.
|
|
21
|
+
export * as arbitraries from "./arbitraries/index.js";
|
|
22
|
+
export * as models from "./models/index.js";
|
|
23
|
+
export * as toxics from "./toxics/index.js";
|
|
24
|
+
// Conformance suite — top-level so consumers can write
|
|
25
|
+
// `import { runConformanceSuite } from "@moltzap/protocol/testing";`
|
|
26
|
+
// without having to reach into a namespace.
|
|
27
|
+
export { PropertyAssertionFailure, PropertyDeferred, PropertyInvariantViolation, PropertyUnavailable, acquireRunContext, assertProperty, collectProperties, registerAllProperties, registerProperty, runAllProperties, runConformance, runConformanceSuite, } from "./conformance/index.js";
|
|
28
|
+
// Individual category modules under a namespace for consumers who want
|
|
29
|
+
// to register a subset of properties.
|
|
30
|
+
export * as conformance from "./conformance/index.js";
|
|
31
|
+
// Client-side conformance surface (architect arch-201; spec amendment
|
|
32
|
+
// #200). The `clientConformance` namespace carries the factory types
|
|
33
|
+
// (`RealClientHandle`, `RealClientRpcError`), the dedicated entry
|
|
34
|
+
// `runClientConformanceSuite`, and every `register*Client` registrar.
|
|
35
|
+
export * as clientConformance from "./conformance/client/index.js";
|
|
36
|
+
export { RealClientLifecycleError, RealClientRpcError, } from "./conformance/client/runner.js";
|
|
37
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,cAAc;AACd,OAAO,EAIL,uBAAuB,EACvB,cAAc,GACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAIL,cAAc,GACf,MAAM,kBAAkB,CAAC;AAE1B,8BAA8B;AAC9B,OAAO,EAIL,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,eAAe,GAChB,MAAM,eAAe,CAAC;AACvB,OAAO,EAGL,WAAW,EACX,WAAW,EACX,YAAY,GACb,MAAM,YAAY,CAAC;AAEpB,UAAU;AACV,OAAO,EAEL,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,aAAa,CAAC;AAErB,kCAAkC;AAClC,OAAO,EAEL,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,yBAAyB,CAAC;AAEjC,iEAAiE;AACjE,OAAO,KAAK,WAAW,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAE5C,uDAAuD;AACvD,qEAAqE;AACrE,4CAA4C;AAC5C,OAAO,EAYL,wBAAwB,EACxB,gBAAgB,EAChB,0BAA0B,EAC1B,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACjB,qBAAqB,EACrB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,mBAAmB,GACpB,MAAM,wBAAwB,CAAC;AAEhC,uEAAuE;AACvE,sCAAsC;AACtC,OAAO,KAAK,WAAW,MAAM,wBAAwB,CAAC;AAEtD,sEAAsE;AACtE,qEAAqE;AACrE,kEAAkE;AAClE,sEAAsE;AACtE,OAAO,KAAK,iBAAiB,MAAM,+BAA+B,CAAC;AAiBnE,OAAO,EACL,wBAAwB,EACxB,kBAAkB,GACnB,MAAM,gCAAgC,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reference-model dispatch: one reducer keyed by `RpcMethodName`.
|
|
3
|
+
*
|
|
4
|
+
* The union `RpcModelResult` mirrors every observable shape Tier B must
|
|
5
|
+
* compare against the real server — success, typed error (authz, schema),
|
|
6
|
+
* and the prospective events the server is expected to emit as a side
|
|
7
|
+
* effect of the call.
|
|
8
|
+
*
|
|
9
|
+
* Exhaustiveness: the reducer takes `ArbitraryRpcCall` (discriminated on
|
|
10
|
+
* `method`) so the TS compiler flags an unhandled method name if
|
|
11
|
+
* `rpcMethods` grows without the model being updated.
|
|
12
|
+
*/
|
|
13
|
+
import type { RpcMap, RpcMethodName } from "../../rpc-registry.js";
|
|
14
|
+
import type { EventFrame } from "../../schema/frames.js";
|
|
15
|
+
import type { ArbitraryRpcCall } from "../arbitraries/rpc.js";
|
|
16
|
+
import { type ReferenceState } from "./state.js";
|
|
17
|
+
/**
|
|
18
|
+
* Observable outcome of one RPC against the model, in the same shape the
|
|
19
|
+
* real server puts on the wire. Tier B's B1 asserts
|
|
20
|
+
* `deepEqual(serverResponse, modelResponse)` modulo opaque fields (IDs,
|
|
21
|
+
* tokens — extracted to a named canonicalizer in the implementer step).
|
|
22
|
+
*/
|
|
23
|
+
export type RpcModelResult<M extends RpcMethodName = RpcMethodName> = {
|
|
24
|
+
readonly _tag: "ok";
|
|
25
|
+
readonly result: RpcMap[M]["result"];
|
|
26
|
+
readonly events: ReadonlyArray<EventFrame>;
|
|
27
|
+
} | {
|
|
28
|
+
readonly _tag: "error";
|
|
29
|
+
readonly code: number;
|
|
30
|
+
readonly message: string;
|
|
31
|
+
readonly events: ReadonlyArray<EventFrame>;
|
|
32
|
+
};
|
|
33
|
+
export declare function isIdempotent(method: RpcMethodName): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Authorization oracle (B2 / B3). Returns the expected typed outcome for a
|
|
36
|
+
* call made by `agentId`. Property code compares the real server's error
|
|
37
|
+
* to this.
|
|
38
|
+
*
|
|
39
|
+
* Rules (mirrored from `packages/server/src/app/authz.ts` contract):
|
|
40
|
+
* - Unregistered agent + non-connect method → deny-unauthenticated.
|
|
41
|
+
* - Conversation-scoped method + `authz` entry "denied" → deny-forbidden.
|
|
42
|
+
* - Otherwise allow.
|
|
43
|
+
*/
|
|
44
|
+
export declare function authorizationOutcome(state: ReferenceState, call: ArbitraryRpcCall, agentId: string): "allow" | "deny-unauthenticated" | "deny-forbidden";
|
|
45
|
+
/**
|
|
46
|
+
* Pure reducer: given state + call, yield the next state and the
|
|
47
|
+
* observable outcome. No I/O. No clocks. No exceptions — every failure
|
|
48
|
+
* flows through `_tag: "error"`.
|
|
49
|
+
*
|
|
50
|
+
* Exhaustiveness: the `switch` has a branch for every `RpcMethodName` in
|
|
51
|
+
* `rpcMethods`. A missing branch becomes a compile error at `absurd`.
|
|
52
|
+
* Behaviour is intentionally conservative — the model predicts the
|
|
53
|
+
* server's *observable* outcome (success vs typed error), not its full
|
|
54
|
+
* result shape. Tier B canonicalizers downgrade server responses to the
|
|
55
|
+
* same projection before comparing.
|
|
56
|
+
*/
|
|
57
|
+
export declare function applyCall<M extends RpcMethodName>(state: ReferenceState, call: ArbitraryRpcCall<M>): {
|
|
58
|
+
readonly next: ReferenceState;
|
|
59
|
+
readonly outcome: RpcModelResult<M>;
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=dispatch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../../../src/testing/models/dispatch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAU,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAEzD;;;;;GAKG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,aAAa,GAAG,aAAa,IAC9D;IACE,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;IACrC,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;CAC5C,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;CAC5C,CAAC;AAyBN,wBAAgB,YAAY,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAE3D;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,cAAc,EACrB,IAAI,EAAE,gBAAgB,EACtB,OAAO,EAAE,MAAM,GACd,OAAO,GAAG,sBAAsB,GAAG,gBAAgB,CAcrD;AAiBD;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,aAAa,EAC/C,KAAK,EAAE,cAAc,EACrB,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,GACxB;IAAE,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC,CAAA;CAAE,CA0IxE"}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { ErrorCodes } from "../../schema/errors.js";
|
|
2
|
+
import { mkTick } from "./state.js";
|
|
3
|
+
// `ErrorCodes` is re-used from `../../schema/errors.ts` so the model and
|
|
4
|
+
// the server share one source of truth for code values.
|
|
5
|
+
/**
|
|
6
|
+
* Methods whose contract says replay is a no-op — server must return the
|
|
7
|
+
* same result (same events) for identical params. B5 cross-checks this
|
|
8
|
+
* against the real server.
|
|
9
|
+
*/
|
|
10
|
+
const IDEMPOTENT_METHODS = new Set([
|
|
11
|
+
"agents/lookup",
|
|
12
|
+
"agents/lookupByName",
|
|
13
|
+
"agents/list",
|
|
14
|
+
"conversations/list",
|
|
15
|
+
"conversations/get",
|
|
16
|
+
"messages/list",
|
|
17
|
+
"contacts/list",
|
|
18
|
+
"presence/subscribe",
|
|
19
|
+
"apps/listSessions",
|
|
20
|
+
"apps/getSession",
|
|
21
|
+
"permissions/list",
|
|
22
|
+
"surface/get",
|
|
23
|
+
]);
|
|
24
|
+
export function isIdempotent(method) {
|
|
25
|
+
return IDEMPOTENT_METHODS.has(method);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Authorization oracle (B2 / B3). Returns the expected typed outcome for a
|
|
29
|
+
* call made by `agentId`. Property code compares the real server's error
|
|
30
|
+
* to this.
|
|
31
|
+
*
|
|
32
|
+
* Rules (mirrored from `packages/server/src/app/authz.ts` contract):
|
|
33
|
+
* - Unregistered agent + non-connect method → deny-unauthenticated.
|
|
34
|
+
* - Conversation-scoped method + `authz` entry "denied" → deny-forbidden.
|
|
35
|
+
* - Otherwise allow.
|
|
36
|
+
*/
|
|
37
|
+
export function authorizationOutcome(state, call, agentId) {
|
|
38
|
+
// `connect` + `register` establish identity; pre-identity they are always allowed.
|
|
39
|
+
if (call.method === "auth/connect" || call.method === "auth/register")
|
|
40
|
+
return "allow";
|
|
41
|
+
if (!state.agents.has(agentId))
|
|
42
|
+
return "deny-unauthenticated";
|
|
43
|
+
const conversationId = extractConversationId(call.params);
|
|
44
|
+
if (conversationId !== null) {
|
|
45
|
+
const row = state.authz.get(agentId);
|
|
46
|
+
if (row !== undefined && row.get(conversationId) === "denied") {
|
|
47
|
+
return "deny-forbidden";
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return "allow";
|
|
51
|
+
}
|
|
52
|
+
function hasConversationIdString(value) {
|
|
53
|
+
return (value !== null &&
|
|
54
|
+
typeof value === "object" &&
|
|
55
|
+
"conversationId" in value &&
|
|
56
|
+
typeof value.conversationId === "string");
|
|
57
|
+
}
|
|
58
|
+
function extractConversationId(params) {
|
|
59
|
+
return hasConversationIdString(params) ? params.conversationId : null;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Pure reducer: given state + call, yield the next state and the
|
|
63
|
+
* observable outcome. No I/O. No clocks. No exceptions — every failure
|
|
64
|
+
* flows through `_tag: "error"`.
|
|
65
|
+
*
|
|
66
|
+
* Exhaustiveness: the `switch` has a branch for every `RpcMethodName` in
|
|
67
|
+
* `rpcMethods`. A missing branch becomes a compile error at `absurd`.
|
|
68
|
+
* Behaviour is intentionally conservative — the model predicts the
|
|
69
|
+
* server's *observable* outcome (success vs typed error), not its full
|
|
70
|
+
* result shape. Tier B canonicalizers downgrade server responses to the
|
|
71
|
+
* same projection before comparing.
|
|
72
|
+
*/
|
|
73
|
+
export function applyCall(state, call) {
|
|
74
|
+
const nextTick = mkTick(state.tick + 1);
|
|
75
|
+
const baseNext = { ...state, tick: nextTick };
|
|
76
|
+
// Authorization check first — every method except connect/register requires identity.
|
|
77
|
+
// The model doesn't know which `agentId` is the caller here (the call is
|
|
78
|
+
// unattributed); agent-scoped B2/B3 properties call `authorizationOutcome`
|
|
79
|
+
// directly. `applyCall` assumes an already-authenticated caller for
|
|
80
|
+
// simplicity.
|
|
81
|
+
// Behaviour families the reducer groups by. Grouping keeps the
|
|
82
|
+
// exhaustive switch below small and named.
|
|
83
|
+
//
|
|
84
|
+
// Model-equivalence (rpc-semantics/model-equivalence) uses the
|
|
85
|
+
// asymmetric oracle: only the `"ok"` path is load-bearing for the
|
|
86
|
+
// server-must-agree contract. Methods that require specific
|
|
87
|
+
// params/setup return `"error"` so the model is honest about its
|
|
88
|
+
// uncertainty — the property runs through them without asserting.
|
|
89
|
+
//
|
|
90
|
+
// Criterion for returning `"ok"`: "a freshly-registered agent with
|
|
91
|
+
// empty-or-arbitrary params gets a successful response." Read-only
|
|
92
|
+
// list methods with fully-optional params are the honest `"ok"` set;
|
|
93
|
+
// every other method returns `"error"` (the model is admitting it
|
|
94
|
+
// doesn't know the state-dependent outcome).
|
|
95
|
+
const allowNoEvents = () => ({
|
|
96
|
+
_tag: "ok",
|
|
97
|
+
result: {},
|
|
98
|
+
events: [],
|
|
99
|
+
});
|
|
100
|
+
const uncertainError = () => ({
|
|
101
|
+
_tag: "error",
|
|
102
|
+
code: -32603,
|
|
103
|
+
message: "model-uncertain: requires state or specific params",
|
|
104
|
+
events: [],
|
|
105
|
+
});
|
|
106
|
+
const m = call.method;
|
|
107
|
+
switch (m) {
|
|
108
|
+
// Auth — model isn't sure what auth shape the caller has.
|
|
109
|
+
case "auth/connect":
|
|
110
|
+
case "auth/register":
|
|
111
|
+
case "auth/invite-agent":
|
|
112
|
+
case "auth/selectAgent":
|
|
113
|
+
return { next: baseNext, outcome: uncertainError() };
|
|
114
|
+
// Agents list-shaped — honest "ok" for a fresh authenticated agent.
|
|
115
|
+
case "agents/list":
|
|
116
|
+
return { next: baseNext, outcome: allowNoEvents() };
|
|
117
|
+
// Agents lookup-shaped — need a target; uncertain.
|
|
118
|
+
case "agents/lookup":
|
|
119
|
+
case "agents/lookupByName":
|
|
120
|
+
return { next: baseNext, outcome: uncertainError() };
|
|
121
|
+
// Conversations list — NOT oracle-confident across arbitrary
|
|
122
|
+
// params. Round-8 finding (architect-197 §2.2 literal-probe
|
|
123
|
+
// widening): `conversations/list` accepts `cursor: Type.String()`
|
|
124
|
+
// (any string) at the schema layer, but the server's cursor
|
|
125
|
+
// parser errors on pathological whitespace-only values. The
|
|
126
|
+
// model would be dishonest claiming `ok` across all draws. Move
|
|
127
|
+
// to `uncertainError`; K=1 today (agents/list only). Widening
|
|
128
|
+
// K requires either per-method param filters at the arbitrary
|
|
129
|
+
// layer OR a server-side cursor-parse fix; tracked under #186.
|
|
130
|
+
case "conversations/list":
|
|
131
|
+
return { next: baseNext, outcome: uncertainError() };
|
|
132
|
+
// Conversations with required fields or state — uncertain.
|
|
133
|
+
case "conversations/create":
|
|
134
|
+
case "conversations/get":
|
|
135
|
+
case "conversations/update":
|
|
136
|
+
case "conversations/mute":
|
|
137
|
+
case "conversations/unmute":
|
|
138
|
+
case "conversations/addParticipant":
|
|
139
|
+
case "conversations/removeParticipant":
|
|
140
|
+
case "conversations/leave":
|
|
141
|
+
case "conversations/archive":
|
|
142
|
+
case "conversations/unarchive":
|
|
143
|
+
return { next: baseNext, outcome: uncertainError() };
|
|
144
|
+
// Messages — both require a valid conversationId. Uncertain.
|
|
145
|
+
case "messages/send":
|
|
146
|
+
case "messages/list":
|
|
147
|
+
return { next: baseNext, outcome: uncertainError() };
|
|
148
|
+
// Contacts list — requires user context for a fresh agent, so
|
|
149
|
+
// server returns an error. Uncertain.
|
|
150
|
+
case "contacts/list":
|
|
151
|
+
case "contacts/add":
|
|
152
|
+
case "contacts/accept":
|
|
153
|
+
return { next: baseNext, outcome: uncertainError() };
|
|
154
|
+
// Invites — requires state. Uncertain.
|
|
155
|
+
case "invites/createAgent":
|
|
156
|
+
return { next: baseNext, outcome: uncertainError() };
|
|
157
|
+
// Presence — state-dependent. Uncertain.
|
|
158
|
+
case "presence/update":
|
|
159
|
+
case "presence/subscribe":
|
|
160
|
+
return { next: baseNext, outcome: uncertainError() };
|
|
161
|
+
// Push — requires endpoint registration. Uncertain.
|
|
162
|
+
case "push/register":
|
|
163
|
+
case "push/unregister":
|
|
164
|
+
return { next: baseNext, outcome: uncertainError() };
|
|
165
|
+
// Apps — require app/user context the fresh agent doesn't have.
|
|
166
|
+
case "apps/create":
|
|
167
|
+
case "apps/attestSkill":
|
|
168
|
+
case "permissions/grant":
|
|
169
|
+
case "permissions/list":
|
|
170
|
+
case "permissions/revoke":
|
|
171
|
+
case "apps/closeSession":
|
|
172
|
+
case "apps/getSession":
|
|
173
|
+
case "apps/listSessions":
|
|
174
|
+
return { next: baseNext, outcome: uncertainError() };
|
|
175
|
+
// Surfaces — require surface/app context. Uncertain.
|
|
176
|
+
case "surface/update":
|
|
177
|
+
case "surface/get":
|
|
178
|
+
case "surface/action":
|
|
179
|
+
case "surface/clear":
|
|
180
|
+
return { next: baseNext, outcome: uncertainError() };
|
|
181
|
+
default: {
|
|
182
|
+
// Exhaustiveness check — any new RpcMethodName breaks the build here
|
|
183
|
+
// until a branch is added.
|
|
184
|
+
const _exhaustive = m;
|
|
185
|
+
return {
|
|
186
|
+
next: baseNext,
|
|
187
|
+
outcome: {
|
|
188
|
+
_tag: "error",
|
|
189
|
+
code: ErrorCodes.InternalError,
|
|
190
|
+
message: `model: unhandled method ${String(_exhaustive)}`,
|
|
191
|
+
events: [],
|
|
192
|
+
},
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
//# sourceMappingURL=dispatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatch.js","sourceRoot":"","sources":["../../../src/testing/models/dispatch.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,OAAO,EAAE,MAAM,EAAuB,MAAM,YAAY,CAAC;AAqBzD,yEAAyE;AACzE,wDAAwD;AAExD;;;;GAIG;AACH,MAAM,kBAAkB,GAA+B,IAAI,GAAG,CAAC;IAC7D,eAAe;IACf,qBAAqB;IACrB,aAAa;IACb,oBAAoB;IACpB,mBAAmB;IACnB,eAAe;IACf,eAAe;IACf,oBAAoB;IACpB,mBAAmB;IACnB,iBAAiB;IACjB,kBAAkB;IAClB,aAAa;CACqB,CAAC,CAAC;AAEtC,MAAM,UAAU,YAAY,CAAC,MAAqB;IAChD,OAAO,kBAAkB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AACxC,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,oBAAoB,CAClC,KAAqB,EACrB,IAAsB,EACtB,OAAe;IAEf,mFAAmF;IACnF,IAAI,IAAI,CAAC,MAAM,KAAK,cAAc,IAAI,IAAI,CAAC,MAAM,KAAK,eAAe;QACnE,OAAO,OAAO,CAAC;IACjB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC;QAAE,OAAO,sBAAsB,CAAC;IAE9D,MAAM,cAAc,GAAG,qBAAqB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC1D,IAAI,cAAc,KAAK,IAAI,EAAE,CAAC;QAC5B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AE,QAAQ,EAAE,OAAO,EAAE,cAAc,EAAE,EAAE,CAAC;QAEvD,OAAO,CAAC,CAAC,CAAC;YACR,qEAAqE;YACrE,2BAA2B;YAC3B,MAAM,WAAW,GAAU,CAAC,CAAC;YAC7B,OAAO;gBACL,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE;oBACP,IAAI,EAAE,OAAO;oBACb,IAAI,EAAE,UAAU,CAAC,aAAa;oBAC9B,OAAO,EAAE,2BAA2B,MAAM,CAAC,WAAW,CAAC,EAAE;oBACzD,MAAM,EAAE,EAAE;iBACX;aACF,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/testing/models/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,qBAAqB,GACtB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,KAAK,cAAc,EACnB,SAAS,EACT,YAAY,EACZ,oBAAoB,GACrB,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/testing/models/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,qBAAqB,GACtB,MAAM,YAAY,CAAC;AACpB,OAAO,EAEL,SAAS,EACT,YAAY,EACZ,oBAAoB,GACrB,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reference-model state types.
|
|
3
|
+
*
|
|
4
|
+
* Per Invariant I5 and AC4, the reference model is the contract: its
|
|
5
|
+
* reducer-derived next-state and its predicted event trace are compared
|
|
6
|
+
* against the real server's observable behavior (Tier B). Divergence
|
|
7
|
+
* shrinks to the offending `ArbitraryRpcCall`.
|
|
8
|
+
*
|
|
9
|
+
* Shape: a pure data record keyed by agent id + conversation id. No fibers,
|
|
10
|
+
* no network, no clocks — all actions are total functions.
|
|
11
|
+
*/
|
|
12
|
+
import type { Agent, Conversation, Message } from "../../types.js";
|
|
13
|
+
import type { EventFrame } from "../../schema/frames.js";
|
|
14
|
+
/** Monotonic logical clock — the model does not read wall time. */
|
|
15
|
+
export type LogicalTick = number & {
|
|
16
|
+
readonly __brand: "LogicalTick";
|
|
17
|
+
};
|
|
18
|
+
/** Construct a `LogicalTick` from a raw number. Only call in this module. */
|
|
19
|
+
export declare function mkTick(n: number): LogicalTick;
|
|
20
|
+
/** Every kind of entity the model tracks. */
|
|
21
|
+
export interface ReferenceState {
|
|
22
|
+
readonly tick: LogicalTick;
|
|
23
|
+
/** Registered agents, keyed by `agentId`. */
|
|
24
|
+
readonly agents: ReadonlyMap<string, Agent>;
|
|
25
|
+
/** Conversations, keyed by `conversationId`. */
|
|
26
|
+
readonly conversations: ReadonlyMap<string, Conversation>;
|
|
27
|
+
/** Messages per conversation, append-only, ordered. */
|
|
28
|
+
readonly messages: ReadonlyMap<string, ReadonlyArray<Message>>;
|
|
29
|
+
/** Per-agent outbox of events the model predicts the server will emit. */
|
|
30
|
+
readonly pendingEvents: ReadonlyMap<string, ReadonlyArray<EventFrame>>;
|
|
31
|
+
/** Authorization table — (agentId, conversationId) → role. */
|
|
32
|
+
readonly authz: ReadonlyMap<string, ReadonlyMap<string, "owner" | "participant" | "denied">>;
|
|
33
|
+
/** Request-ids the model has observed, for uniqueness assertions (B4). */
|
|
34
|
+
readonly seenRequestIds: ReadonlySet<string>;
|
|
35
|
+
}
|
|
36
|
+
export declare const initialReferenceState: ReferenceState;
|
|
37
|
+
//# sourceMappingURL=state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../src/testing/models/state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzD,mEAAmE;AACnE,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAA;CAAE,CAAC;AAEvE,6EAA6E;AAC7E,wBAAgB,MAAM,CAAC,CAAC,EAAE,MAAM,GAAG,WAAW,CAE7C;AAED,6CAA6C;AAC7C,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,6CAA6C;IAC7C,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC5C,gDAAgD;IAChD,QAAQ,CAAC,aAAa,EAAE,WAAW,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAC1D,uDAAuD;IACvD,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;IAC/D,0EAA0E;IAC1E,QAAQ,CAAC,aAAa,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC;IACvE,8DAA8D;IAC9D,QAAQ,CAAC,KAAK,EAAE,WAAW,CACzB,MAAM,EACN,WAAW,CAAC,MAAM,EAAE,OAAO,GAAG,aAAa,GAAG,QAAQ,CAAC,CACxD,CAAC;IACF,0EAA0E;IAC1E,QAAQ,CAAC,cAAc,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAC9C;AAED,eAAO,MAAM,qBAAqB,EAAE,cAQnC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Construct a `LogicalTick` from a raw number. Only call in this module. */
|
|
2
|
+
export function mkTick(n) {
|
|
3
|
+
return n;
|
|
4
|
+
}
|
|
5
|
+
export const initialReferenceState = {
|
|
6
|
+
tick: mkTick(0),
|
|
7
|
+
agents: new Map(),
|
|
8
|
+
conversations: new Map(),
|
|
9
|
+
messages: new Map(),
|
|
10
|
+
pendingEvents: new Map(),
|
|
11
|
+
authz: new Map(),
|
|
12
|
+
seenRequestIds: new Set(),
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.js","sourceRoot":"","sources":["../../../src/testing/models/state.ts"],"names":[],"mappings":"AAiBA,6EAA6E;AAC7E,MAAM,UAAU,MAAM,CAAC,CAAS;IAC9B,OAAO,CAAgB,CAAC;AAC1B,CAAC;AAsBD,MAAM,CAAC,MAAM,qBAAqB,GAAmB;IACnD,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;IACf,MAAM,EAAE,IAAI,GAAG,EAAE;IACjB,aAAa,EAAE,IAAI,GAAG,EAAE;IACxB,QAAQ,EAAE,IAAI,GAAG,EAAE;IACnB,aAAa,EAAE,IAAI,GAAG,EAAE;IACxB,KAAK,EAAE,IAAI,GAAG,EAAE;IAChB,cAAc,EAAE,IAAI,GAAG,EAAE;CAC1B,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TestClient — connects to a REAL MoltZap server URL and drives the wire.
|
|
3
|
+
*
|
|
4
|
+
* Per D1 (WS-only) and Invariant I1 (primitives never bypass the wire),
|
|
5
|
+
* every request is serialized and pushed through a real WebSocket transport
|
|
6
|
+
* — `@effect/platform/Socket.makeWebSocket` backed by
|
|
7
|
+
* `@effect/platform-node/NodeSocket.layerWebSocketConstructor` so the wire
|
|
8
|
+
* bytes match `packages/client`'s real production path.
|
|
9
|
+
*
|
|
10
|
+
* Satisfies AC2. Consumed by Tier A / B / C / D / E properties.
|
|
11
|
+
*/
|
|
12
|
+
import { Context, Effect, Scope, Stream } from "effect";
|
|
13
|
+
import type { RpcMap, RpcMethodName } from "../rpc-registry.js";
|
|
14
|
+
import type { EventFrame } from "../schema/frames.js";
|
|
15
|
+
import { type CapturedFrame, type CaptureBuffer } from "./captures.js";
|
|
16
|
+
import { type MalformedFrameKind } from "./codec.js";
|
|
17
|
+
import { FrameSchemaError, RpcResponseError, RpcTimeoutError, TransportClosedError, TransportIoError } from "./errors.js";
|
|
18
|
+
/**
|
|
19
|
+
* Options for connecting a TestClient. `serverUrl` is the `ws://…` URL of
|
|
20
|
+
* the real server; `agentKey` + `agentId` are for the `connect` handshake.
|
|
21
|
+
* `defaultTimeoutMs` bounds each `sendRpc` unless overridden per call.
|
|
22
|
+
*/
|
|
23
|
+
export interface TestClientConfig {
|
|
24
|
+
readonly serverUrl: string;
|
|
25
|
+
readonly agentKey: string;
|
|
26
|
+
readonly agentId: string;
|
|
27
|
+
readonly defaultTimeoutMs: number;
|
|
28
|
+
/** Soft cap on captured frames before the ring buffer drops oldest. */
|
|
29
|
+
readonly captureCapacity: number;
|
|
30
|
+
/**
|
|
31
|
+
* When `true`, send the `auth/connect` handshake automatically after the
|
|
32
|
+
* WS upgrade. Defaults to `true`.
|
|
33
|
+
*/
|
|
34
|
+
readonly autoConnect?: boolean;
|
|
35
|
+
/** Quiescence window (ms) for `sendMalformed` to wait for a response. */
|
|
36
|
+
readonly malformedQuiescenceMs?: number;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Handle surface. Scoped: acquiring the handle opens the WS; releasing the
|
|
40
|
+
* scope closes it. All methods return Effects so property code can compose
|
|
41
|
+
* them inside `Effect.forEach` / `fc.asyncProperty`.
|
|
42
|
+
*/
|
|
43
|
+
export interface TestClient {
|
|
44
|
+
readonly sendRpc: <M extends RpcMethodName>(method: M, params: RpcMap[M]["params"], opts?: {
|
|
45
|
+
readonly timeoutMs?: number;
|
|
46
|
+
}) => Effect.Effect<RpcMap[M]["result"], RpcResponseError | RpcTimeoutError | TransportClosedError | TransportIoError | FrameSchemaError>;
|
|
47
|
+
readonly sendMalformed: (opts: {
|
|
48
|
+
readonly baseMethod: RpcMethodName;
|
|
49
|
+
readonly kind: MalformedFrameKind;
|
|
50
|
+
readonly seed: number;
|
|
51
|
+
}) => Effect.Effect<RpcResponseError | null, TransportClosedError | TransportIoError | FrameSchemaError>;
|
|
52
|
+
readonly events: Stream.Stream<EventFrame, TransportClosedError>;
|
|
53
|
+
readonly captures: CaptureBuffer;
|
|
54
|
+
readonly snapshot: Effect.Effect<ReadonlyArray<CapturedFrame>>;
|
|
55
|
+
readonly waitForEvent: (eventName: string, timeoutMs?: number) => Effect.Effect<EventFrame, Error>;
|
|
56
|
+
readonly drainEvents: Effect.Effect<ReadonlyArray<EventFrame>>;
|
|
57
|
+
}
|
|
58
|
+
export interface CloseableTestClient extends TestClient {
|
|
59
|
+
readonly close: Effect.Effect<void, never>;
|
|
60
|
+
}
|
|
61
|
+
/** Context tag so property code can `Effect.serviceWith(TestClient, …)`. */
|
|
62
|
+
export declare const TestClient: Context.Tag<TestClient, TestClient>;
|
|
63
|
+
/**
|
|
64
|
+
* Open a real WS connection to `config.serverUrl`, complete the `connect`
|
|
65
|
+
* handshake, and yield a `TestClient`. The surrounding `Scope` owns the
|
|
66
|
+
* socket; releasing it closes the WS and drains captures.
|
|
67
|
+
*/
|
|
68
|
+
export declare function makeTestClient(config: TestClientConfig): Effect.Effect<TestClient, TransportIoError | TransportClosedError | RpcResponseError, Scope.Scope>;
|
|
69
|
+
export declare function makeCloseableTestClient(config: TestClientConfig): Effect.Effect<CloseableTestClient, TransportIoError | TransportClosedError | RpcResponseError>;
|
|
70
|
+
//# sourceMappingURL=test-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-client.d.ts","sourceRoot":"","sources":["../../src/testing/test-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAEL,OAAO,EAGP,MAAM,EAGN,KAAK,EACL,MAAM,EACP,MAAM,QAAQ,CAAC;AAGhB,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;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