@mostra/conformance 0.0.0-stage → 0.3.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.
@@ -0,0 +1,403 @@
1
+ import { _ as StoreResult, a as CallParams, c as EventsResult, d as HarnessFeature, f as InitializeParams, g as StartResult, h as StartParams, i as CallError, l as HARNESS_METHODS, m as ScriptParams, n as ReferenceStore, o as CallResult, p as InitializeResult, r as runReferenceHost, s as EventsParams, t as REFERENCE_FAULTS, u as HARNESS_REVISIONS, v as StoredDelivery } from "./reference-host-BJ-A_Qd_.js";
2
+ import { EventRecord, Frame, FrameTicket, Results, RpcPeer } from "@mostra/protocol";
3
+ //#region src/baseline.d.ts
4
+ /** A baseline: the scenarios a host is expected to fail, each with its reason. */
5
+ interface Baseline {
6
+ /** The baseline format's version: 1. */
7
+ readonly schemaVersion: 1;
8
+ /** Each expected failure: the scenario's ID and why it fails. */
9
+ readonly expectedFailures: Readonly<Record<string, string>>;
10
+ }
11
+ /** An empty baseline: every scenario must pass. */
12
+ export declare const NO_BASELINE: Baseline;
13
+ /**
14
+ * Reads a baseline file. Throws on a file that isn't one, and on a scenario ID no scenario of
15
+ * `known` has (a typo would otherwise expect nothing, silently).
16
+ */
17
+ export declare function readBaseline(path: string, known: readonly string[]): Baseline;
18
+ //#endregion
19
+ //#region src/fixtures.d.ts
20
+ /**
21
+ * The artifacts the scenarios publish, written fresh into the run's authoring directory. They
22
+ * declare their fields with literal IDs, so every answer a scenario writes is covered by the
23
+ * version (D109) and none is orphaned by accident.
24
+ */
25
+ /** A fixture: its files by relative path. */
26
+ type Fixture = Readonly<Record<string, string>>;
27
+ /** The bundled fixtures by name. */
28
+ export declare const FIXTURES: Readonly<Record<string, Fixture>>;
29
+ //#endregion
30
+ //#region src/harness/client.d.ts
31
+ /** An instance's error, carried through the host: its diagnostic code and JSON-RPC code. */
32
+ export declare class InstanceError extends Error {
33
+ /** The diagnostic code (`MOSTRA_…`). */
34
+ readonly code: string;
35
+ /** The JSON-RPC error code. */
36
+ readonly rpcCode: number;
37
+ /** The diagnostic as it arrived. */
38
+ readonly data: CallError["data"];
39
+ constructor(method: string, error: CallError);
40
+ }
41
+ /** A host under test, reached through its harness shim. */
42
+ export declare class HostUnderTest {
43
+ #private;
44
+ /** What the host said about itself. */
45
+ info: InitializeResult | undefined;
46
+ private constructor();
47
+ /** Starts the shim and asks it who it is. */
48
+ static start(command: string, env?: Readonly<Record<string, string>>): Promise<HostUnderTest>;
49
+ /** The host's last stderr lines. */
50
+ get stderr(): readonly string[];
51
+ /** Whether the host serves `port` / supports `feature`. */
52
+ serves(port: string): boolean;
53
+ /** Whether the host supports the harness feature `feature`. */
54
+ supports(feature: string): boolean;
55
+ /** `harness/start`: the host starts or attaches to its instance. */
56
+ startInstance(params: StartParams): Promise<StartResult>;
57
+ /** `harness/call`, raw: the instance's answer or error as the host received it. */
58
+ callRaw(method: string, params: unknown, timeoutMs?: number): Promise<CallResult>;
59
+ /** `harness/call`: the answer, or an {@link InstanceError}. */
60
+ call<T = Record<string, unknown>>(method: string, params: unknown, timeoutMs?: number): Promise<T>;
61
+ /** `harness/stop`: the host ends its session. */
62
+ stopInstance(): Promise<void>;
63
+ /** `harness/store`. */
64
+ store(): Promise<StoreResult>;
65
+ /** `harness/script` (feature `faults`). */
66
+ script(params: ScriptParams): Promise<void>;
67
+ /** `harness/events` (feature `events`). */
68
+ events(params: EventsParams): Promise<EventsResult>;
69
+ /** Ends the shim: stdin closes, then SIGTERM to its process group, then SIGKILL. */
70
+ close(): Promise<void>;
71
+ }
72
+ /** A diagnostic code from an error the kit saw: the instance's, an RPC error's, or none. */
73
+ export declare function codeOf(error: unknown): string | undefined;
74
+ //#endregion
75
+ //#region src/harness/serve.d.ts
76
+ /** What a TypeScript host implements to be driven by the kit. */
77
+ interface HarnessImplementation {
78
+ /** Who the host is, the ports it serves and its features. */
79
+ initialize(): Omit<InitializeResult, "revision"> | Promise<Omit<InitializeResult, "revision">>;
80
+ /** Starts (or attaches to) the host's instance for `params.home`, with its real ports. */
81
+ start(params: StartParams): StartResult | Promise<StartResult>;
82
+ /** Sends one host-protocol request through the host's client; throw an `RpcError` for an error answer. */
83
+ call(method: string, params: unknown, timeoutMs?: number): unknown;
84
+ /** Ends the host's session. */
85
+ stop(): void | Promise<void>;
86
+ /** What the host's own store holds. */
87
+ store(): StoreResult | Promise<StoreResult>;
88
+ /** Feature `faults`: answer a port as the kit asks. */
89
+ script?(params: ScriptParams): void | Promise<void>;
90
+ /** Feature `events`: read pages from the host's own named event stream. */
91
+ events?(params: EventsParams): EventsResult | Promise<EventsResult>;
92
+ }
93
+ /**
94
+ * Serves the harness protocol on this process's stdin and stdout until stdin ends, then stops
95
+ * the host's session and resolves.
96
+ */
97
+ export declare function serveHarness(implementation: HarnessImplementation, io?: {
98
+ input?: NodeJS.ReadableStream;
99
+ output?: NodeJS.WritableStream;
100
+ }): Promise<void>;
101
+ //#endregion
102
+ //#region src/viewer.d.ts
103
+ /** One HTTP answer. */
104
+ interface Answer {
105
+ /** The HTTP status. */
106
+ readonly status: number;
107
+ /** Each header (lowercase name) with every value it was sent with. */
108
+ readonly headers: Readonly<Record<string, readonly string[]>>;
109
+ /** The body as text. */
110
+ readonly body: string;
111
+ /** The body as JSON (`{}` when it isn't). */
112
+ json<T = Record<string, unknown>>(): T;
113
+ }
114
+ /** One request. */
115
+ interface Ask {
116
+ /** The HTTP method; default `GET`. */
117
+ readonly method?: string;
118
+ /** The full URL. */
119
+ readonly url: string;
120
+ /** The request's headers, exactly as sent. */
121
+ readonly headers?: Readonly<Record<string, string>>;
122
+ /** The body, if any. */
123
+ readonly body?: string;
124
+ /** Leave out the jar's cookies. */
125
+ readonly noCookies?: boolean;
126
+ }
127
+ /** Sends one request, never following a redirect. */
128
+ export declare function send(ask: Ask): Promise<Answer>;
129
+ /** A link's parts: its shell origin, artifact, token secret and pinned version. */
130
+ interface ParsedLink {
131
+ /** The shell's origin. */
132
+ readonly origin: string;
133
+ /** The artifact the link opens. */
134
+ readonly artifactId: string;
135
+ /** The token's secret, from the fragment. */
136
+ readonly secret: string;
137
+ /** The version number the link pins, if it pins one. */
138
+ readonly version?: string;
139
+ }
140
+ /** Reads a capability link (`http://host:port/a/<artifactId>[/v/<n>]#t=<secret>`). */
141
+ export declare function parseLink(link: string): ParsedLink;
142
+ /** A browser-like client with a per-host cookie jar. */
143
+ export declare class Browser {
144
+ #private;
145
+ /** The cookies the jar sends to `url`: every cookie of the host whose path matches. */
146
+ cookiesFor(url: string): string;
147
+ /** Sends a request with the jar's cookies and keeps the ones that come back. */
148
+ ask(ask: Ask): Promise<Answer>;
149
+ /** A page on `origin` posting or fetching JSON from its own origin. */
150
+ fetchJson(origin: string, path: string, init?: {
151
+ method?: string;
152
+ body?: unknown;
153
+ csrf?: string;
154
+ headers?: Record<string, string>;
155
+ }): Promise<Answer>;
156
+ }
157
+ /** Why a viewer couldn't open its link: the step and the gateway's answer. */
158
+ export declare class OpenError extends Error {
159
+ /** The HTTP status of the refused step. */
160
+ readonly status: number;
161
+ /** The diagnostic code (`MOSTRA_…`). */
162
+ readonly code: string | undefined;
163
+ constructor(step: string, answer: Answer);
164
+ }
165
+ /** A run's state, as `runs` and `runs/attach` answer it. */
166
+ interface RunState {
167
+ /** The run's ID (`run_…`). */
168
+ readonly runId: string;
169
+ /** `queued`, `running`, `succeeded`, `failed` or `cancelled` (D130). */
170
+ readonly status: string;
171
+ /** Its result, as serializer batches. */
172
+ readonly batches: readonly Frame[][];
173
+ /** The rest of the run's state (progress, log, error). */
174
+ readonly [key: string]: unknown;
175
+ }
176
+ /** One opened view: a shell session, a frame session and the view they show. */
177
+ export declare class Viewer {
178
+ #private;
179
+ /** The cookie jar this viewer's requests use. */
180
+ readonly browser: Browser;
181
+ /** The link it opened. */
182
+ readonly link: ParsedLink;
183
+ /** The frame ticket the shell got: the view, its version, channels and controls. */
184
+ readonly ticket: FrameTicket;
185
+ private constructor();
186
+ /**
187
+ * Opens `link` as the shell does. `headers` go with the session exchange (the request the
188
+ * `identity` port judges, D143). Throws an {@link OpenError} for a refused step.
189
+ */
190
+ static open(link: string, options?: {
191
+ browser?: Browser;
192
+ headers?: Record<string, string>;
193
+ }): Promise<Viewer>;
194
+ /** The view this frame load is (D104). */
195
+ get viewId(): string;
196
+ /** A browser-protocol request from the page. */
197
+ page(path: string, body: unknown): Promise<Answer>;
198
+ /** A request of the shell (its own origin, under `/a/<artifactId>`). */
199
+ shell(path: string, body?: unknown, method?: string): Promise<Answer>;
200
+ /**
201
+ * Writes fields of the viewer's draft (or, with `scope: "artifact"`, the artifact state), with
202
+ * the labels a page sends for them (D106).
203
+ */
204
+ write(fields: Record<string, unknown>, options?: {
205
+ baseRevision?: string;
206
+ scope?: "viewer" | "artifact";
207
+ labels?: Readonly<Record<string, string>>;
208
+ }): Promise<Answer>;
209
+ /** Submits on the artifact channel (D40). */
210
+ submit(expectedRevision: string): Promise<Answer>;
211
+ /** The trusted Submit, on the shell channel (D40, D108). */
212
+ shellSubmit(expectedRevision: string): Promise<Answer>;
213
+ /** Writes `fields`, then submits on `channel`; answers the submit. */
214
+ answer(fields: Record<string, unknown>, channel?: "artifact" | "shell", labels?: Readonly<Record<string, string>>): Promise<Answer>;
215
+ /** Raises a signal from the page (IN-09). */
216
+ signal(name: string, payload?: unknown): Promise<Answer>;
217
+ /** Starts an action run (D130) and follows it until it ends. */
218
+ run(fnId: string, args: unknown[], timeoutMs?: number): Promise<RunState>;
219
+ /** The page's long poll: events after `cursor` (D47). */
220
+ poll(cursor?: string): Promise<Answer>;
221
+ }
222
+ /** A run's result, from its stored batches. */
223
+ export declare function resultOf(state: RunState): Promise<unknown>;
224
+ //#endregion
225
+ //#region src/scenario.d.ts
226
+ /** A scenario: one property of a host integration, with the requirements it covers. */
227
+ interface Scenario {
228
+ /** A stable ID, `group.name`: baselines name scenarios by it. */
229
+ readonly id: string;
230
+ /** What it proves, in one sentence. */
231
+ readonly title: string;
232
+ /** The requirements and host needs it exercises (`HO-05`, `IN-12`, `H-03` …). */
233
+ readonly covers: readonly string[];
234
+ /** Harness features without which it doesn't apply (it is then skipped, never failed). */
235
+ readonly needs?: readonly string[];
236
+ /** Runs it; throws a {@link ScenarioFailure} (or any error) when the property doesn't hold. */
237
+ run(context: ScenarioContext): Promise<void>;
238
+ }
239
+ /** A property that didn't hold. */
240
+ export declare class ScenarioFailure extends Error {
241
+ constructor(message: string);
242
+ }
243
+ /** Thrown to say a scenario doesn't apply to this host (a port or feature it lacks). */
244
+ export declare class NotApplicable extends Error {
245
+ constructor(reason: string);
246
+ }
247
+ /** Fails the scenario with `message` unless `condition` holds. */
248
+ export declare function check(condition: unknown, message: string): asserts condition;
249
+ /** Fails unless `actual` deep-equals `expected` (JSON comparison, key order aside). */
250
+ export declare function same(actual: unknown, expected: unknown, what: string): void;
251
+ /** Options of a run that scenarios see. */
252
+ interface RunSettings {
253
+ /** The host shim's command line. */
254
+ readonly host: string;
255
+ /** Variables for the shim's own process (how it finds its runtime). */
256
+ readonly hostEnv: Readonly<Record<string, string>>;
257
+ /** Publish through verify's gate (needs the verify browser); off, publish skips it, loudly. */
258
+ readonly verify: boolean;
259
+ }
260
+ /** What a scenario works with: its host, its home, its viewers. */
261
+ export declare class ScenarioContext {
262
+ #private;
263
+ /** The run's settings. */
264
+ readonly settings: RunSettings;
265
+ /** The scenario's directory: the home, the authoring directories, the runtime directory. */
266
+ readonly dir: string;
267
+ /** The home the host is told to use (HO-08). */
268
+ readonly home: string;
269
+ /** The host: its name and version. */
270
+ host: HostUnderTest;
271
+ constructor(settings: RunSettings, dir: string);
272
+ /** Starts the scenario's host shim (the runner does this before `run`). */
273
+ open(): Promise<void>;
274
+ /** A second shim of the same host, for scenarios about two hosts of one home. */
275
+ anotherHost(): Promise<HostUnderTest>;
276
+ /** The variables every instance of the run gets: its own runtime and config directories. */
277
+ instanceEnv(extra?: Readonly<Record<string, string>>): Record<string, string>;
278
+ /** `harness/start` on this scenario's home. */
279
+ start(options?: {
280
+ env?: Readonly<Record<string, string>>;
281
+ mode?: StartParams["mode"];
282
+ host?: HostUnderTest;
283
+ }): Promise<StartResult>;
284
+ /** Stops the host's instance and starts it again (the same home). */
285
+ restart(options?: {
286
+ env?: Readonly<Record<string, string>>;
287
+ }): Promise<StartResult>;
288
+ /** Writes a fixture into a fresh authoring directory and returns the directory. */
289
+ author(fixture: Fixture, name?: string): string;
290
+ /** Writes `files` over the authoring directory `dir` (a new version of the same artifact). */
291
+ rewrite(dir: string, fixture: Fixture): void;
292
+ /** Publishes `dir` through the host (`artifact/publish`). */
293
+ publish(dir: string, options?: {
294
+ policy?: unknown;
295
+ requestId?: string;
296
+ }): Promise<{
297
+ artifactId: string;
298
+ versionId: string;
299
+ version: number;
300
+ url?: string;
301
+ tokenId?: string;
302
+ cursor: string;
303
+ }>;
304
+ /** Authors and publishes a fixture; the receipt with its authoring directory. */
305
+ published(fixture: Fixture, options?: {
306
+ policy?: unknown;
307
+ }): Promise<{
308
+ artifactId: string;
309
+ versionId: string;
310
+ version: number;
311
+ url?: string;
312
+ tokenId?: string;
313
+ cursor: string;
314
+ dir: string;
315
+ }>;
316
+ /** A new capability link through the host (`view/url`). */
317
+ link(artifactId: string, params?: Record<string, unknown>): Promise<string>;
318
+ /** Opens a new link as a viewer. */
319
+ viewer(artifactId: string, options?: {
320
+ link?: Record<string, unknown>;
321
+ headers?: Record<string, string>;
322
+ }): Promise<Viewer>;
323
+ /** `results/get` through the host. */
324
+ results(artifactId: string, submission?: string): Promise<Results>;
325
+ /** `events/read` through the host. */
326
+ events(filter: {
327
+ artifacts?: string[];
328
+ types?: string[];
329
+ }, after?: string): Promise<{
330
+ events: EventRecord[];
331
+ cursor: string;
332
+ }>;
333
+ /** The host's store. */
334
+ store(): Promise<StoreResult>;
335
+ /** Waits for `condition` to hold, checking every 100 ms; fails with `what` after `timeoutMs`. */
336
+ eventually<T>(what: string, condition: () => Promise<T | undefined | false> | T | undefined | false, timeoutMs?: number): Promise<T>;
337
+ /** Skips the scenario unless the host serves `port`. */
338
+ requirePort(port: string): void;
339
+ /** Skips the scenario unless the host supports `feature`. */
340
+ requireFeature(feature: string): void;
341
+ /** The socket of the home's running instance, from `instance.json` (D81). */
342
+ socket(): string | undefined;
343
+ /** Ends every shim, stops a daemon the scenario left, and removes the directory. */
344
+ close(): Promise<void>;
345
+ }
346
+ //#endregion
347
+ //#region src/runner.d.ts
348
+ /** How one scenario went. */
349
+ type ScenarioStatus = "passed" | "failed" | "skipped" | "expected-failure" | "unexpected-pass";
350
+ /** One scenario's outcome. */
351
+ interface ScenarioOutcome {
352
+ /** The scenario's ID. */
353
+ readonly id: string;
354
+ /** What the scenario proves. */
355
+ readonly title: string;
356
+ /** The requirements and host needs it exercises. */
357
+ readonly covers: readonly string[];
358
+ /** How it went. */
359
+ readonly status: ScenarioStatus;
360
+ /** Why it failed or was skipped, or what the baseline says. */
361
+ readonly reason?: string;
362
+ /** How long it took. */
363
+ readonly durationMs: number;
364
+ }
365
+ /** A run's report. */
366
+ interface ConformanceReport {
367
+ /** What the host said about itself. */
368
+ readonly host: InitializeResult | undefined;
369
+ /** Each scenario's outcome, in the order they ran. */
370
+ readonly outcomes: readonly ScenarioOutcome[];
371
+ /** Whether the run passes: nothing `failed` and nothing `unexpected-pass`. */
372
+ readonly ok: boolean;
373
+ }
374
+ /** Options of {@link runConformance}. */
375
+ interface RunOptions {
376
+ /** The host's harness shim, as a command line (run through the shell). */
377
+ readonly host: string;
378
+ /** Variables for the shim's process, on top of this process's. */
379
+ readonly hostEnv?: Readonly<Record<string, string>>;
380
+ /** Only the scenarios whose ID equals or starts with one of these (`delivery.`). */
381
+ readonly only?: readonly string[];
382
+ /** The host's expected failures. */
383
+ readonly baseline?: Baseline;
384
+ /** Publish through verify's gate (needs the verify browser). Default false. */
385
+ readonly verify?: boolean;
386
+ /** Each scenario's time limit. Default 240 s. */
387
+ readonly timeoutMs?: number;
388
+ /** Where scenario directories go. Default a fresh directory under `/tmp` (short socket paths). */
389
+ readonly workDir?: string;
390
+ /** Each outcome as it is known. */
391
+ readonly onOutcome?: (outcome: ScenarioOutcome) => void;
392
+ /** The scenarios to choose from. Default every scenario of the kit. */
393
+ readonly scenarios?: readonly Scenario[];
394
+ }
395
+ /** Runs the kit's scenarios against a host and judges them against its baseline. */
396
+ export declare function runConformance(options: RunOptions): Promise<ConformanceReport>;
397
+ //#endregion
398
+ //#region src/scenarios/index.d.ts
399
+ /** Every scenario. */
400
+ export declare const SCENARIOS: readonly Scenario[];
401
+ //#endregion
402
+ export { type Answer, type Ask, type Baseline, type CallError, type CallParams, type CallResult, type ConformanceReport, type EventsParams, type EventsResult, type Fixture, HARNESS_METHODS, HARNESS_REVISIONS, type HarnessFeature, type HarnessImplementation, type InitializeParams, type InitializeResult, type ParsedLink, REFERENCE_FAULTS, ReferenceStore, type RunOptions, type RunSettings, type RunState, type Scenario, type ScenarioOutcome, type ScenarioStatus, type ScriptParams, type StartParams, type StartResult, type StoreResult, type StoredDelivery, runReferenceHost };
403
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/baseline.ts","../src/fixtures.ts","../src/harness/client.ts","../src/harness/serve.ts","../src/viewer.ts","../src/scenario.ts","../src/runner.ts","../src/scenarios/index.ts"],"mappings":";;;;UAciB;;WAEN;;WAEA,kBAAkB,SAAS;;;qBASzB,aAAa;;;;;wBAMV,aAAa,cAAc,2BAA2B;;;;;;;;;KC1B1D,UAAU,SAAS;;qBA2ElB,UAAU,SAAS,eAAe;;;;qBC3ClC,sBAAsB;;WAExB;;WAEA;;WAEA,MAAM;EAEf,YAAY,gBAAgB,OAAO;;;qBAUxB;;;EAMX,MAAM;UAEE;;SAwCK,MACX,iBACA,MAAK,SAAS,0BACb,QAAQ;;MAgBP;;EAKJ,OAAO;;EAIP,SAAS;;EAST,cAAoB,QAAQ,cAAc,QAAQ;;EAKlD,QAAc,gBAAgB,iBAAiB,qBAAqB,QAAQ;;EAW5E,KAAW,IAA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;EAMf;;EAYA,SAAe;;;;;KCtRL;;UAaK;;WAEN;;WAEA;;WAEA;;WAEA,QAAQ;;WAER;;WAEA;;;UAIM;;WAEN,MAAM;;WAEN,mBAAmB;;WAEnB;;;UAIM;;WAEN;;WAEA,UAAU,SAAS;;WAEnB;;WAEA,WAAW;;WAEX;;WAEA;;WAEA;;WAEA,aAAa,SAAS;;WAEtB,qBAAqB;;;wBAqDV,eAAe,SAAS,aAAa,QAAQ;;;;qBC9GtD,oBAAoB"}
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ import { _ as FIXTURES, a as ScenarioFailure, c as Browser, d as parseLink, f as resultOf, g as codeOf, h as InstanceError, i as ScenarioContext, l as OpenError, m as HostUnderTest, n as SCENARIOS, o as check, p as send, r as NotApplicable, s as same, t as runConformance, u as Viewer, v as NO_BASELINE, y as readBaseline } from "./runner-CvoSJlfk.js";
2
+ import { a as HARNESS_METHODS, o as HARNESS_REVISIONS } from "./protocol-RQ9lbehE.js";
3
+ import { i as serveHarness, n as ReferenceStore, r as runReferenceHost, t as REFERENCE_FAULTS } from "./reference-host-d6gs3Tal.js";
4
+ export { Browser, FIXTURES, HARNESS_METHODS, HARNESS_REVISIONS, HostUnderTest, InstanceError, NO_BASELINE, NotApplicable, OpenError, REFERENCE_FAULTS, ReferenceStore, SCENARIOS, ScenarioContext, ScenarioFailure, Viewer, check, codeOf, parseLink, readBaseline, resultOf, runConformance, runReferenceHost, same, send, serveHarness };
@@ -0,0 +1,207 @@
1
+ import { readFileSync } from "node:fs";
2
+ import * as z from "zod";
3
+ import { dirname, join } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ //#region src/version.ts
6
+ /** The kit's own release, from its package.json (found upwards from this module). */
7
+ let found;
8
+ /** This kit's release: what it reports to a host's shim and to an instance. */
9
+ function kitVersion() {
10
+ if (found !== void 0) return found;
11
+ let dir = dirname(fileURLToPath(import.meta.url));
12
+ for (;;) {
13
+ try {
14
+ const manifest = JSON.parse(readFileSync(join(dir, "package.json"), "utf8"));
15
+ if (manifest.name === "@mostra/conformance" && manifest.version) {
16
+ found = manifest.version;
17
+ return found;
18
+ }
19
+ } catch {}
20
+ const parent = dirname(dir);
21
+ if (parent === dir) throw new Error("Couldn't find @mostra/conformance's package.json.");
22
+ dir = parent;
23
+ }
24
+ }
25
+ //#endregion
26
+ //#region src/harness/protocol.ts
27
+ /**
28
+ * The conformance harness protocol (D143 item 3): how the kit drives a host under test. A host
29
+ * ships a small shim, a program the kit starts, that speaks JSON-RPC 2.0 over its stdin and
30
+ * stdout (one message per line, as the host protocol does) and answers these methods with its
31
+ * real integration: its own client, its own ports, its own store. Any language can implement it;
32
+ * TypeScript hosts get `serveHarness`, and the Rust reference host shows it in Rust.
33
+ *
34
+ * | Method | What the host does |
35
+ * |---|---|
36
+ * | `harness/initialize` | names itself, the ports it serves and the features it supports |
37
+ * | `harness/start` | starts (spawns or attaches to) its Mostra instance for a home, with its ports |
38
+ * | `harness/call` | sends one host-protocol request through its own client and returns the answer |
39
+ * | `harness/stop` | ends its session (a spawned instance exits) |
40
+ * | `harness/store` | reports what its own store holds: deliveries, mirrors, activations, calls |
41
+ * | `harness/script` | (feature `faults`) answers a port the way the kit asks |
42
+ * | `harness/events` | (feature `events`) reads pages from its own named event stream |
43
+ *
44
+ * Within a revision the protocol changes only additively, like the host protocol (D32).
45
+ */
46
+ /** The harness protocol revisions this kit speaks, newest last. */
47
+ const HARNESS_REVISIONS = ["2026-10-21"];
48
+ /** The harness methods by name. */
49
+ const HARNESS_METHODS = {
50
+ initialize: "harness/initialize",
51
+ start: "harness/start",
52
+ call: "harness/call",
53
+ stop: "harness/stop",
54
+ store: "harness/store",
55
+ script: "harness/script",
56
+ events: "harness/events"
57
+ };
58
+ /** The schema of `InitializeResult`. */
59
+ const InitializeResult = z.object({
60
+ revision: z.string(),
61
+ host: z.object({
62
+ name: z.string(),
63
+ version: z.string()
64
+ }),
65
+ ports: z.array(z.string()),
66
+ features: z.array(z.string())
67
+ });
68
+ /** The schema of `StartParams`. */
69
+ const StartParams = z.object({
70
+ home: z.string(),
71
+ env: z.record(z.string(), z.string()),
72
+ mode: z.enum(["spawn", "attach"]).exactOptional()
73
+ });
74
+ /** The schema of `StartResult`. */
75
+ const StartResult = z.object({
76
+ revision: z.string(),
77
+ instance: z.object({
78
+ home: z.string(),
79
+ mode: z.string(),
80
+ pid: z.number(),
81
+ version: z.string(),
82
+ platform: z.string()
83
+ }),
84
+ warnings: z.array(z.looseObject({ code: z.string() }))
85
+ });
86
+ /** The schema of `CallParams`. */
87
+ const CallParams = z.object({
88
+ method: z.string(),
89
+ params: z.unknown(),
90
+ timeoutMs: z.number().exactOptional()
91
+ });
92
+ /** The schema of `CallResult`. */
93
+ const CallResult = z.union([z.object({ error: z.object({
94
+ code: z.number(),
95
+ data: z.looseObject({ code: z.string() })
96
+ }) }), z.object({ result: z.unknown() })]);
97
+ /** The schema of `StoreResult`. */
98
+ const StoreResult = z.object({
99
+ deliveries: z.array(z.object({
100
+ deliveryId: z.string(),
101
+ submissionId: z.string(),
102
+ artifactId: z.string(),
103
+ calls: z.number(),
104
+ stored: z.number(),
105
+ attempts: z.array(z.number()),
106
+ kind: z.string(),
107
+ channel: z.string(),
108
+ viewerKind: z.string(),
109
+ viewerRef: z.string().optional(),
110
+ order: z.number()
111
+ })),
112
+ drafts: z.array(z.object({
113
+ artifactId: z.string(),
114
+ viewerId: z.string(),
115
+ revision: z.string(),
116
+ kind: z.string()
117
+ })),
118
+ activations: z.array(z.object({
119
+ artifactId: z.string(),
120
+ control: z.string(),
121
+ viewId: z.string()
122
+ })),
123
+ identity: z.array(z.object({
124
+ artifactId: z.string(),
125
+ via: z.string(),
126
+ headers: z.array(z.string()),
127
+ answer: z.union([z.object({
128
+ ref: z.string(),
129
+ name: z.string().optional()
130
+ }), z.null()]).optional()
131
+ })),
132
+ policies: z.array(z.object({
133
+ artifactId: z.string(),
134
+ answer: z.object({
135
+ submitChannels: z.array(z.string()),
136
+ controls: z.array(z.string()).optional()
137
+ }).optional()
138
+ })),
139
+ secrets: z.array(z.object({
140
+ artifactId: z.string(),
141
+ name: z.string()
142
+ }))
143
+ });
144
+ /** The schema of `ScriptParams`. */
145
+ const ScriptParams = z.union([
146
+ z.object({
147
+ port: z.literal("submissions"),
148
+ answer: z.enum([
149
+ "accept",
150
+ "retry",
151
+ "undeliverable",
152
+ "reject",
153
+ "fail",
154
+ "hang"
155
+ ])
156
+ }),
157
+ z.object({
158
+ port: z.literal("trustedControls"),
159
+ answer: z.union([
160
+ z.literal("fail"),
161
+ z.literal("hang"),
162
+ z.object({
163
+ submitChannels: z.array(z.string()),
164
+ controls: z.array(z.string()).optional()
165
+ })
166
+ ])
167
+ }),
168
+ z.object({
169
+ port: z.literal("identity"),
170
+ answer: z.union([
171
+ z.literal("fail"),
172
+ z.literal("hang"),
173
+ z.literal("headers"),
174
+ z.null(),
175
+ z.object({
176
+ ref: z.string(),
177
+ name: z.string().optional()
178
+ })
179
+ ])
180
+ }),
181
+ z.object({
182
+ port: z.literal("secrets"),
183
+ answer: z.record(z.string(), z.string())
184
+ })
185
+ ]);
186
+ /** The schema of `EventsParams`. */
187
+ const EventsParams = z.object({
188
+ name: z.string(),
189
+ filter: z.object({
190
+ artifacts: z.array(z.string()).optional(),
191
+ types: z.array(z.string()).optional()
192
+ }),
193
+ pages: z.number(),
194
+ timeoutMs: z.number()
195
+ });
196
+ /** The schema of `EventsResult`. */
197
+ const EventsResult = z.object({ pages: z.array(z.object({
198
+ cursor: z.string(),
199
+ events: z.array(z.looseObject({
200
+ cursor: z.string(),
201
+ type: z.string()
202
+ }))
203
+ })) });
204
+ //#endregion
205
+ export { HARNESS_METHODS as a, ScriptParams as c, StoreResult as d, kitVersion as f, EventsResult as i, StartParams as l, CallResult as n, HARNESS_REVISIONS as o, EventsParams as r, InitializeResult as s, CallParams as t, StartResult as u };
206
+
207
+ //# sourceMappingURL=protocol-RQ9lbehE.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol-RQ9lbehE.js","names":[],"sources":["../src/version.ts","../src/harness/protocol.ts"],"sourcesContent":["/** The kit's own release, from its package.json (found upwards from this module). */\nimport { readFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nlet found: string | undefined;\n\n/** This kit's release: what it reports to a host's shim and to an instance. */\nexport function kitVersion(): string {\n if (found !== undefined) return found;\n let dir = dirname(fileURLToPath(import.meta.url));\n for (;;) {\n try {\n const manifest = JSON.parse(readFileSync(join(dir, \"package.json\"), \"utf8\")) as {\n name?: string;\n version?: string;\n };\n if (manifest.name === \"@mostra/conformance\" && manifest.version) {\n found = manifest.version;\n return found;\n }\n } catch {\n // Keep looking upwards.\n }\n const parent = dirname(dir);\n if (parent === dir) throw new Error(\"Couldn't find @mostra/conformance's package.json.\");\n dir = parent;\n }\n}\n","/**\n * The conformance harness protocol (D143 item 3): how the kit drives a host under test. A host\n * ships a small shim, a program the kit starts, that speaks JSON-RPC 2.0 over its stdin and\n * stdout (one message per line, as the host protocol does) and answers these methods with its\n * real integration: its own client, its own ports, its own store. Any language can implement it;\n * TypeScript hosts get `serveHarness`, and the Rust reference host shows it in Rust.\n *\n * | Method | What the host does |\n * |---|---|\n * | `harness/initialize` | names itself, the ports it serves and the features it supports |\n * | `harness/start` | starts (spawns or attaches to) its Mostra instance for a home, with its ports |\n * | `harness/call` | sends one host-protocol request through its own client and returns the answer |\n * | `harness/stop` | ends its session (a spawned instance exits) |\n * | `harness/store` | reports what its own store holds: deliveries, mirrors, activations, calls |\n * | `harness/script` | (feature `faults`) answers a port the way the kit asks |\n * | `harness/events` | (feature `events`) reads pages from its own named event stream |\n *\n * Within a revision the protocol changes only additively, like the host protocol (D32).\n */\nimport * as z from \"zod\";\n\n/** The harness protocol revisions this kit speaks, newest last. */\nexport const HARNESS_REVISIONS: readonly string[] = [\"2026-10-21\"];\n\n/** The harness methods by name. */\nexport const HARNESS_METHODS: {\n readonly initialize: \"harness/initialize\";\n readonly start: \"harness/start\";\n readonly call: \"harness/call\";\n readonly stop: \"harness/stop\";\n readonly store: \"harness/store\";\n readonly script: \"harness/script\";\n readonly events: \"harness/events\";\n} = {\n initialize: \"harness/initialize\",\n start: \"harness/start\",\n call: \"harness/call\",\n stop: \"harness/stop\",\n store: \"harness/store\",\n script: \"harness/script\",\n events: \"harness/events\",\n};\n\n/**\n * What a host can do beyond the required methods: `attach` (`harness/start` with\n * `mode: \"attach\"`), `faults` (`harness/script`, for reference and test hosts) and `events`\n * (`harness/events`). Unknown features are ignored.\n */\nexport type HarnessFeature = \"attach\" | \"faults\" | \"events\" | (string & {});\n\n/** `harness/initialize`'s params. */\nexport interface InitializeParams {\n /** The harness protocol revision. */\n readonly revision: string;\n /** The kit that drives the host. */\n readonly kit: { readonly name: string; readonly version: string };\n}\n\n/** `harness/initialize`'s result. */\nexport interface InitializeResult {\n /** The harness protocol revision. */\n readonly revision: string;\n /** The host: its name and version. */\n readonly host: { readonly name: string; readonly version: string };\n /** The ports the host registers in `mostra/initialize`. */\n readonly ports: readonly string[];\n /** The harness features the host supports. */\n readonly features: readonly HarnessFeature[];\n}\n\n/** The schema of `InitializeResult`. */\nexport const InitializeResult: z.ZodType<InitializeResult> = z.object({\n revision: z.string(),\n host: z.object({ name: z.string(), version: z.string() }),\n ports: z.array(z.string()),\n features: z.array(z.string()),\n});\n\n/** `harness/start`'s params. */\nexport interface StartParams {\n /** The home the host must use: its own choice in production (HO-08), the kit's in a run. */\n readonly home: string;\n /** Variables the host adds to its instance's environment (test switches, fault points). */\n readonly env: Readonly<Record<string, string>>;\n /** Spawn an instance over stdio (default) or attach to the home's daemon (feature `attach`). */\n readonly mode?: \"spawn\" | \"attach\";\n}\n\n/** The schema of `StartParams`. */\nexport const StartParams: z.ZodType<StartParams> = z.object({\n home: z.string(),\n env: z.record(z.string(), z.string()),\n mode: z.enum([\"spawn\", \"attach\"]).exactOptional(),\n});\n\n/** `harness/start`'s result: what `mostra/initialize` answered the host. */\nexport interface StartResult {\n /** The harness protocol revision. */\n readonly revision: string;\n /** The instance the host's session reached: its home, mode, PID, release and platform. */\n readonly instance: {\n readonly home: string;\n readonly mode: string;\n readonly pid: number;\n readonly version: string;\n readonly platform: string;\n };\n /** The session's warnings, such as an unsupported port. */\n readonly warnings: readonly { readonly code: string }[];\n}\n\n/** The schema of `StartResult`. */\nexport const StartResult: z.ZodType<StartResult> = z.object({\n revision: z.string(),\n instance: z.object({\n home: z.string(),\n mode: z.string(),\n pid: z.number(),\n version: z.string(),\n platform: z.string(),\n }),\n warnings: z.array(z.looseObject({ code: z.string() })),\n});\n\n/** `harness/call`'s params: one host-protocol request. */\nexport interface CallParams {\n /** The host-protocol method. */\n readonly method: string;\n /** Its params. */\n readonly params: unknown;\n /** How long the host waits for the answer, in milliseconds. */\n readonly timeoutMs?: number;\n}\n\n/** The schema of `CallParams`. */\nexport const CallParams: z.ZodType<CallParams> = z.object({\n method: z.string(),\n params: z.unknown(),\n timeoutMs: z.number().exactOptional(),\n});\n\n/** An instance's error as the host received it: the JSON-RPC code and the diagnostic. */\nexport interface CallError {\n /** The diagnostic code (`MOSTRA_…`). */\n readonly code: number;\n /** The diagnostic as it arrived. */\n readonly data: { readonly code: string; readonly message?: string } & Record<string, unknown>;\n}\n\n/** `harness/call`'s result: the answer, or the instance's error as it arrived. */\nexport type CallResult = { readonly result: unknown } | { readonly error: CallError };\n\n/** The schema of `CallResult`. */\nexport const CallResult: z.ZodType<CallResult> = z.union([\n z.object({ error: z.object({ code: z.number(), data: z.looseObject({ code: z.string() }) }) }),\n z.object({ result: z.unknown() }),\n]) as z.ZodType<CallResult>;\n\n/** One delivery the host's submissions port received, as its store records it. */\nexport interface StoredDelivery {\n /** The delivery's stable ID (`dlv_…`). */\n readonly deliveryId: string;\n /** The submission it delivers. */\n readonly submissionId: string;\n /** The artifact. */\n readonly artifactId: string;\n /** How many times the port was called with this delivery. */\n readonly calls: number;\n /** How many copies the host's store holds: one for a conformant host (H-03). */\n readonly stored: number;\n /** The attempt numbers it saw, in order. */\n readonly attempts: readonly number[];\n /** `envelope.kind` as received. */\n readonly kind: string;\n /** `results.submission.channel`, `.viewer.kind` and `.viewer.ref`. */\n readonly channel: string;\n /** `results.submission.viewer.kind`. */\n readonly viewerKind: string;\n /** `results.submission.viewer.ref`, when the viewer has one. */\n readonly viewerRef?: string;\n /** The order the host stored it in, from 1. */\n readonly order: number;\n}\n\n/** What the host's own store and port handlers saw. */\nexport interface StoreResult {\n /** The deliveries the host's store holds, in the order it stored them. */\n readonly deliveries: readonly StoredDelivery[];\n /** Draft mirrors, in arrival order. */\n readonly drafts: readonly {\n readonly artifactId: string;\n readonly viewerId: string;\n readonly revision: string;\n readonly kind: string;\n }[];\n /** `trustedControls.activated` calls, in arrival order. */\n readonly activations: readonly {\n readonly artifactId: string;\n readonly control: string;\n readonly viewId: string;\n }[];\n /**\n * `identity.resolve` calls: the artifact, how the request arrived, the header names, and what\n * the host answered (absent when it failed or never answered). Scenarios judge the session by\n * this answer, so a host may name people however it likes.\n */\n readonly identity: readonly {\n readonly artifactId: string;\n readonly via: string;\n readonly headers: readonly string[];\n readonly answer?: { readonly ref: string; readonly name?: string } | null;\n }[];\n /**\n * `trustedControls.policy` calls, with what the host answered (absent when it failed or never\n * answered). Scenarios judge the view by this answer when they can't script one.\n */\n readonly policies: readonly {\n readonly artifactId: string;\n readonly answer?: {\n readonly submitChannels: readonly string[];\n readonly controls?: readonly string[];\n };\n }[];\n /** `secrets.get` calls. */\n readonly secrets: readonly { readonly artifactId: string; readonly name: string }[];\n}\n\n/** The schema of `StoreResult`. */\nexport const StoreResult: z.ZodType<StoreResult> = z.object({\n deliveries: z.array(\n z.object({\n deliveryId: z.string(),\n submissionId: z.string(),\n artifactId: z.string(),\n calls: z.number(),\n stored: z.number(),\n attempts: z.array(z.number()),\n kind: z.string(),\n channel: z.string(),\n viewerKind: z.string(),\n viewerRef: z.string().optional(),\n order: z.number(),\n }),\n ),\n drafts: z.array(\n z.object({\n artifactId: z.string(),\n viewerId: z.string(),\n revision: z.string(),\n kind: z.string(),\n }),\n ),\n activations: z.array(\n z.object({ artifactId: z.string(), control: z.string(), viewId: z.string() }),\n ),\n identity: z.array(\n z.object({\n artifactId: z.string(),\n via: z.string(),\n headers: z.array(z.string()),\n answer: z\n .union([z.object({ ref: z.string(), name: z.string().optional() }), z.null()])\n .optional(),\n }),\n ),\n policies: z.array(\n z.object({\n artifactId: z.string(),\n answer: z\n .object({\n submitChannels: z.array(z.string()),\n controls: z.array(z.string()).optional(),\n })\n .optional(),\n }),\n ),\n secrets: z.array(z.object({ artifactId: z.string(), name: z.string() })),\n}) as z.ZodType<StoreResult>;\n\n/** How a scripted port answers from now on (feature `faults`). */\nexport type ScriptParams =\n | {\n readonly port: \"submissions\";\n readonly answer: \"accept\" | \"retry\" | \"undeliverable\" | \"reject\" | \"fail\" | \"hang\";\n }\n | {\n readonly port: \"trustedControls\";\n readonly answer:\n | \"fail\"\n | \"hang\"\n | {\n readonly submitChannels: readonly string[];\n readonly controls?: readonly string[];\n };\n }\n | {\n readonly port: \"identity\";\n /** `headers`: the person named by `x-forwarded-user`, else none. */\n readonly answer:\n | \"fail\"\n | \"hang\"\n | \"headers\"\n | null\n | { readonly ref: string; readonly name?: string };\n }\n | { readonly port: \"secrets\"; readonly answer: Readonly<Record<string, string>> };\n\n/** The schema of `ScriptParams`. */\nexport const ScriptParams: z.ZodType<ScriptParams> = z.union([\n z.object({\n port: z.literal(\"submissions\"),\n answer: z.enum([\"accept\", \"retry\", \"undeliverable\", \"reject\", \"fail\", \"hang\"]),\n }),\n z.object({\n port: z.literal(\"trustedControls\"),\n answer: z.union([\n z.literal(\"fail\"),\n z.literal(\"hang\"),\n z.object({\n submitChannels: z.array(z.string()),\n controls: z.array(z.string()).optional(),\n }),\n ]),\n }),\n z.object({\n port: z.literal(\"identity\"),\n answer: z.union([\n z.literal(\"fail\"),\n z.literal(\"hang\"),\n z.literal(\"headers\"),\n z.null(),\n z.object({ ref: z.string(), name: z.string().optional() }),\n ]),\n }),\n z.object({ port: z.literal(\"secrets\"), answer: z.record(z.string(), z.string()) }),\n]) as z.ZodType<ScriptParams>;\n\n/** `harness/events`'s params: read pages from the host's own named stream (feature `events`). */\nexport interface EventsParams {\n /** The subscriber name: the stream resumes after what this name acknowledged. */\n readonly name: string;\n /** The events filter. */\n readonly filter: { readonly artifacts?: readonly string[]; readonly types?: readonly string[] };\n /** Stop after this many pages, or when `timeoutMs` passes. */\n readonly pages: number;\n /** How long the host waits for the answer, in milliseconds. */\n readonly timeoutMs: number;\n}\n\n/** The schema of `EventsParams`. */\nexport const EventsParams: z.ZodType<EventsParams> = z.object({\n name: z.string(),\n filter: z.object({\n artifacts: z.array(z.string()).optional(),\n types: z.array(z.string()).optional(),\n }),\n pages: z.number(),\n timeoutMs: z.number(),\n}) as z.ZodType<EventsParams>;\n\n/** `harness/events`'s result: the pages read, every one handled and acknowledged. */\nexport interface EventsResult {\n /** The pages read, in cursor order. */\n readonly pages: readonly {\n readonly cursor: string;\n readonly events: readonly ({ readonly cursor: string; readonly type: string } & Record<\n string,\n unknown\n >)[];\n }[];\n}\n\n/** The schema of `EventsResult`. */\nexport const EventsResult: z.ZodType<EventsResult> = z.object({\n pages: z.array(\n z.object({\n cursor: z.string(),\n events: z.array(z.looseObject({ cursor: z.string(), type: z.string() })),\n }),\n ),\n}) as z.ZodType<EventsResult>;\n"],"mappings":";;;;;;AAKA,IAAI;;AAGJ,SAAgB,aAAqB;CACnC,IAAI,UAAU,KAAA,GAAW,OAAO;CAChC,IAAI,MAAM,QAAQ,cAAc,YAAY,GAAG,CAAC;CAChD,SAAS;EACP,IAAI;GACF,MAAM,WAAW,KAAK,MAAM,aAAa,KAAK,KAAK,cAAc,GAAG,MAAM,CAAC;GAI3E,IAAI,SAAS,SAAS,yBAAyB,SAAS,SAAS;IAC/D,QAAQ,SAAS;IACjB,OAAO;GACT;EACF,QAAQ,CAER;EACA,MAAM,SAAS,QAAQ,GAAG;EAC1B,IAAI,WA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