@byollm/relay 0.1.0-alpha.9 → 0.1.0-alpha.91

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,77 @@
1
+ import { R as RoutingStore } from './store-BNhCedHZ.js';
2
+ import '@byollm/protocol';
3
+
4
+ /**
5
+ * The routing store's behaviour, written once and run against every
6
+ * implementation — cloud_008 finding 54.
7
+ *
8
+ * There were two copies. This package tested `RelayState`; `byollm-cloud`
9
+ * tested `ValkeyRoutingStore` with a file that opened by explaining it was
10
+ * "written once and parameterised… a second copy of the scenario is a second
11
+ * place for two implementations to quietly diverge" — and was itself the
12
+ * second copy. It had drifted to sixteen cases against the eighteen in the
13
+ * ledger, which is exactly the divergence the sentence predicted, happening
14
+ * to the sentence.
15
+ *
16
+ * So the contract lives here, in the package that declares `RoutingStore`,
17
+ * and both repositories import it. A store that cannot pass this is not a
18
+ * routing store, whatever it implements.
19
+ *
20
+ * ## Why this ships in the published package
21
+ *
22
+ * Because the implementation that matters most is in another repository. A
23
+ * contract only the author can run is a description; one a third party runs
24
+ * against their own implementation is a contract. `@byollm/relay/store-contract`
25
+ * is a subpath export so nothing that imports the relay itself pulls in a
26
+ * test framework.
27
+ *
28
+ * ## What this cannot prove
29
+ *
30
+ * `CLAIM_ATOMIC` is a MUST and every case here would pass against a store
31
+ * that read, decided and wrote in three steps — in one process there is
32
+ * nothing to interleave. Concurrency belongs with the implementation that
33
+ * has a network in it, and `byollm-cloud`'s suite runs it against Valkey with
34
+ * many connections. Named here so the omission is a decision rather than an
35
+ * oversight.
36
+ */
37
+ /** The control-plane site id these cases route under. */
38
+ declare const CONTRACT_SITE = "site_store";
39
+ interface StoreContractOptions {
40
+ /**
41
+ * A fresh, empty store, and how to dispose of it.
42
+ *
43
+ * Arrow-typed rather than a method, because the caller passes these
44
+ * around: a method signature lets `this` travel with the call, and a
45
+ * factory read off an options object is exactly where that goes wrong.
46
+ */
47
+ readonly make: () => Promise<{
48
+ store: RoutingStore;
49
+ done: () => Promise<void>;
50
+ }>;
51
+ /**
52
+ * Whether this store writes stubs as bytes and reads them back.
53
+ *
54
+ * An in-process store holds typed objects and cannot hold a stub it cannot
55
+ * parse; a serialising one can, because what it wrote may have been written
56
+ * by a previous version. The case that covers it is skipped rather than
57
+ * hidden — a reader should know which half of this contract each store is
58
+ * proving (cloud_008 §2.1a).
59
+ */
60
+ readonly serialising?: boolean;
61
+ /**
62
+ * Move this store's clock, for the cases that are about time — B187.
63
+ *
64
+ * Optional, and the cases that need it skip without it, on the same
65
+ * reasoning `serialising` is written down: a reader should know which half
66
+ * of this contract each store is proving. A store that cannot be advanced
67
+ * is not broken, it is untested here — and the sticky re-offer is exactly
68
+ * the rule a second implementation would get wrong quietly.
69
+ */
70
+ readonly advance?: (store: RoutingStore, ms: number) => Promise<void>;
71
+ /** Write a stub's raw bytes, bypassing serialisation. */
72
+ readonly writeRawStub?: (store: RoutingStore, id: string, raw: string) => Promise<void>;
73
+ }
74
+ /** Run the contract. Call inside a suite; it declares its own `describe`. */
75
+ declare function describeStoreContract(name: string, options: StoreContractOptions): void;
76
+
77
+ export { CONTRACT_SITE, type StoreContractOptions, describeStoreContract };