@kraken-e2e/signaling 0.1.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/LICENSE +674 -0
- package/dist/bus.d.ts +89 -0
- package/dist/bus.d.ts.map +1 -0
- package/dist/bus.js +220 -0
- package/dist/bus.js.map +1 -0
- package/dist/chaos-transport.d.ts +34 -0
- package/dist/chaos-transport.d.ts.map +1 -0
- package/dist/chaos-transport.js +64 -0
- package/dist/chaos-transport.js.map +1 -0
- package/dist/conformance.d.ts +18 -0
- package/dist/conformance.d.ts.map +1 -0
- package/dist/conformance.js +156 -0
- package/dist/conformance.js.map +1 -0
- package/dist/errors.d.ts +43 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +47 -0
- package/dist/errors.js.map +1 -0
- package/dist/in-memory-transport.d.ts +21 -0
- package/dist/in-memory-transport.d.ts.map +1 -0
- package/dist/in-memory-transport.js +142 -0
- package/dist/in-memory-transport.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/near-miss.d.ts +6 -0
- package/dist/near-miss.d.ts.map +1 -0
- package/dist/near-miss.js +30 -0
- package/dist/near-miss.js.map +1 -0
- package/dist/redis-transport.d.ts +46 -0
- package/dist/redis-transport.d.ts.map +1 -0
- package/dist/redis-transport.js +173 -0
- package/dist/redis-transport.js.map +1 -0
- package/dist/types.d.ts +74 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +12 -0
- package/dist/types.js.map +1 -0
- package/package.json +53 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core types of the Kraken signal log (ADR-0003).
|
|
3
|
+
*
|
|
4
|
+
* The transport SPI is a "dumb log": append with acknowledged ordering, blocking
|
|
5
|
+
* reads after a sequence number, scope lifecycle. All intelligence (subscriber
|
|
6
|
+
* cursors, predicates, diagnostics) lives in the SignalBus facade.
|
|
7
|
+
*/
|
|
8
|
+
/** JSON-serializable values only; every transport round-trips payloads through JSON. */
|
|
9
|
+
export type SignalPayload = null | boolean | number | string | SignalPayload[] | {
|
|
10
|
+
[key: string]: SignalPayload;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Isolation unit for signals. `scenarioId` must be unique per scenario INSTANCE
|
|
14
|
+
* (each Examples row gets its own scope). Cross-scenario signals are unsupported.
|
|
15
|
+
*/
|
|
16
|
+
export interface SignalScope {
|
|
17
|
+
readonly runId: string;
|
|
18
|
+
readonly scenarioId: string;
|
|
19
|
+
}
|
|
20
|
+
/** Opaque key transports use for storage isolation (Map key / Redis stream name). */
|
|
21
|
+
export declare function scopeKey(scope: SignalScope): string;
|
|
22
|
+
export interface SignalRecord<P extends SignalPayload = SignalPayload> {
|
|
23
|
+
/** Strictly increasing per scope; assigned by the transport's single sequencer. */
|
|
24
|
+
readonly seq: number;
|
|
25
|
+
readonly name: string;
|
|
26
|
+
/** Subscriber id (actor id) of the publisher. */
|
|
27
|
+
readonly from: string;
|
|
28
|
+
readonly payload: P;
|
|
29
|
+
/** Epoch ms at the sequencer. Diagnostic only — never used for ordering. */
|
|
30
|
+
readonly publishedAt: number;
|
|
31
|
+
}
|
|
32
|
+
export interface SignalQuery {
|
|
33
|
+
readonly name: string;
|
|
34
|
+
/** Only records with seq strictly greater than this match. */
|
|
35
|
+
readonly afterSeq: number;
|
|
36
|
+
/** If set, only records published by this subscriber match. */
|
|
37
|
+
readonly from?: string | undefined;
|
|
38
|
+
}
|
|
39
|
+
export interface TransportWaitOptions {
|
|
40
|
+
/** Waiter-local wall-clock budget. Transport latency counts against it. */
|
|
41
|
+
readonly timeoutMs: number;
|
|
42
|
+
readonly signal?: AbortSignal | undefined;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The transport SPI. Implementations must pass the conformance suite exported
|
|
46
|
+
* at `@kraken-e2e/signaling/conformance` before use (ADR-0003 D7).
|
|
47
|
+
*/
|
|
48
|
+
export interface SignalTransport {
|
|
49
|
+
createScope(scope: SignalScope): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Acknowledged append: resolves once the record is durably ordered.
|
|
52
|
+
* MUST NOT resolve synchronously. Never blocks on receivers; never fails
|
|
53
|
+
* because nobody is listening.
|
|
54
|
+
*/
|
|
55
|
+
publish(scope: SignalScope, signal: {
|
|
56
|
+
name: string;
|
|
57
|
+
from: string;
|
|
58
|
+
payload: SignalPayload;
|
|
59
|
+
}): Promise<SignalRecord>;
|
|
60
|
+
/**
|
|
61
|
+
* Resolves with the earliest record matching the query (name, optional from,
|
|
62
|
+
* seq > afterSeq), replaying history first, then waiting live. Rejects with
|
|
63
|
+
* SignalTimeoutError, ScopeClosedError, SignalWaitAbortedError, or
|
|
64
|
+
* TransportUnavailableError. Never hangs past timeoutMs.
|
|
65
|
+
*/
|
|
66
|
+
waitFor(scope: SignalScope, query: SignalQuery, opts: TransportWaitOptions): Promise<SignalRecord>;
|
|
67
|
+
/** Full in-scope history snapshot (timeout diagnostics, reporters). */
|
|
68
|
+
history(scope: SignalScope): Promise<readonly SignalRecord[]>;
|
|
69
|
+
/** Idempotent. Rejects all pending waiters with ScopeClosedError; frees retention. */
|
|
70
|
+
destroyScope(scope: SignalScope): Promise<void>;
|
|
71
|
+
/** Health probe for `kraken doctor`. */
|
|
72
|
+
ping(): Promise<void>;
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,wFAAwF;AACxF,MAAM,MAAM,aAAa,GACrB,IAAI,GACJ,OAAO,GACP,MAAM,GACN,MAAM,GACN,aAAa,EAAE,GACf;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CAAA;CAAE,CAAC;AAErC;;;GAGG;AACH,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K,EAAE,WAAW,EAClB,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE,oBAAoB,GACzB,OAAO,CAAC,YAAY,CAAC,CAAC;IACzB,uEAAuE;IACvE,OAAO,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,SAAS,YAAY,EAAE,CAAC,CAAC;IAC9D,sFAAsF;IACtF,YAAY,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD,wCAAwC;IACxC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACvB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core types of the Kraken signal log (ADR-0003).
|
|
3
|
+
*
|
|
4
|
+
* The transport SPI is a "dumb log": append with acknowledged ordering, blocking
|
|
5
|
+
* reads after a sequence number, scope lifecycle. All intelligence (subscriber
|
|
6
|
+
* cursors, predicates, diagnostics) lives in the SignalBus facade.
|
|
7
|
+
*/
|
|
8
|
+
/** Opaque key transports use for storage isolation (Map key / Redis stream name). */
|
|
9
|
+
export function scopeKey(scope) {
|
|
10
|
+
return `${scope.runId}/${scope.scenarioId}`;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAoBH,qFAAqF;AACrF,MAAM,UAAU,QAAQ,CAAC,KAAkB;IACzC,OAAO,GAAG,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,UAAU,EAAE,CAAC;AAC9C,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kraken-e2e/signaling",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Standalone multi-actor signal log (scoped append-only log with per-subscriber cursors), transports, and the transport-conformance suite",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"default": "./dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"./conformance": {
|
|
12
|
+
"types": "./dist/conformance.d.ts",
|
|
13
|
+
"default": "./dist/conformance.js"
|
|
14
|
+
},
|
|
15
|
+
"./package.json": "./package.json",
|
|
16
|
+
"./redis": {
|
|
17
|
+
"types": "./dist/redis-transport.d.ts",
|
|
18
|
+
"default": "./dist/redis-transport.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"LICENSE"
|
|
24
|
+
],
|
|
25
|
+
"sideEffects": false,
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=22.13.0"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"vitest": "^4.0.0",
|
|
31
|
+
"redis": "^6.1.0"
|
|
32
|
+
},
|
|
33
|
+
"peerDependenciesMeta": {
|
|
34
|
+
"vitest": {
|
|
35
|
+
"optional": true
|
|
36
|
+
},
|
|
37
|
+
"redis": {
|
|
38
|
+
"optional": true
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@types/node": "^22.15.0",
|
|
43
|
+
"typescript": "~6.0.3",
|
|
44
|
+
"vitest": "^4.1.9",
|
|
45
|
+
"redis": "~6.1.0"
|
|
46
|
+
},
|
|
47
|
+
"license": "GPL-3.0-only",
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "tsc -p tsconfig.build.json",
|
|
50
|
+
"typecheck": "tsc --noEmit",
|
|
51
|
+
"test": "vitest run"
|
|
52
|
+
}
|
|
53
|
+
}
|