@serene-pub/conformance 0.6.0-pr-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,270 @@
1
+ /**
2
+ * Components (§3.5, C4 / C30): what a host must do with a remote component,
3
+ * as cases a host is run through — the built module's own findings, the
4
+ * protocol round trip, and parity between a widget's native copy and a
5
+ * remote built from the same source.
6
+ */
7
+ import { componentModuleFindings } from '@serene-pub/sdk';
8
+ /**
9
+ * The kit's own component, already built: plain ES, no imports — the
10
+ * protocol with nothing else in the way. It counts the messages it is
11
+ * pushed, continues on a click, and tries one element no page takes.
12
+ * @experimental
13
+ */
14
+ export const COMPONENT_PROTOCOL_FIXTURE = `export default (root, ctx) => {
15
+ const count = document.createElement('p')
16
+ count.setAttribute('class', 'kit-count')
17
+ const go = document.createElement('button')
18
+ go.setAttribute('type', 'button')
19
+ go.setAttribute('class', 'kit-go')
20
+ go.textContent = 'Continue'
21
+ go.addEventListener('click', () => ctx.invoke('advance'))
22
+ const sneaky = document.createElement('script')
23
+ sneaky.textContent = 'globalThis.kitRan = true'
24
+ root.append(count, go, sneaky)
25
+ const draw = () => { count.textContent = String((ctx.messages ?? []).length) }
26
+ draw()
27
+ return ctx.subscribe(draw)
28
+ }
29
+ `;
30
+ const must = (cond, message) => {
31
+ if (!cond)
32
+ throw new Error(message);
33
+ };
34
+ /** @experimental The built module's own findings: its errors fail it; its advisories are said. */
35
+ export function judgeComponentModule(id, code) {
36
+ const { errors, advisories } = componentModuleFindings(code);
37
+ must(!errors.length, `component '${id}': ${errors.join('; ')}`);
38
+ return advisories.map((a) => `component '${id}': ${a}`);
39
+ }
40
+ /** @experimental The protocol round trip, over a view of the fixture a host mounted. */
41
+ export async function componentProtocolCase(view) {
42
+ const count = () => view.queryAll('.kit-count')[0]?.textContent;
43
+ must(count() === '0', `the fixture should render its count ('0'), got ${JSON.stringify(count())}`);
44
+ await view.push('messages', [{ id: 1, role: 'user', content: 'a' }, { id: 2, role: 'assistant', content: 'b' }]);
45
+ must(count() === '2', `a pushed section must reach the component and its redraw the page — count is ${JSON.stringify(count())}`);
46
+ await view.click('.kit-go');
47
+ must(view.invoked.length === 1 && view.invoked[0].key === 'advance', `a click must cross to the component and its invoke back to the host — invoked ${JSON.stringify(view.invoked)}`);
48
+ must(!view.queryAll('script').length, 'an element outside the vocabulary landed in the page (<script>)');
49
+ must(view.refused.some((r) => r.includes('script')), 'an element outside the vocabulary was dropped without being said');
50
+ }
51
+ /** A row's edit field: the page's composer field, or a plain textarea. */
52
+ const EDIT_FIELD = 'sp-composer-field, textarea';
53
+ /**
54
+ * Type into a row's edit field the way the page delivers typing: the page's
55
+ * `sp-composer-field` raises its own `input` with `{ value }` (through
56
+ * `dispatch`); a plain `textarea` takes a value and a DOM `input`.
57
+ */
58
+ async function editField(v, field, value, which) {
59
+ if (field.tagName.toLowerCase() === 'textarea') {
60
+ field.setAttribute('data-kit-edit', '');
61
+ try {
62
+ return await v.input('[data-kit-edit]', value);
63
+ }
64
+ finally {
65
+ field.removeAttribute('data-kit-edit');
66
+ }
67
+ }
68
+ must(v.dispatch, `the row's field is the page's sp-composer-field, and the ${which} view offers no dispatch() to raise its input — ` +
69
+ `supply ComponentView.dispatch (the SDK harness's does)`);
70
+ await v.dispatch(field, 'input', { value });
71
+ }
72
+ const row = (id, role, content, extra = {}) => ({
73
+ id,
74
+ role,
75
+ content,
76
+ channel: 'main',
77
+ createdAt: '2026-09-24T10:00:00Z',
78
+ ...extra,
79
+ });
80
+ /**
81
+ * Parity between a messages widget's native copy and a remote built from the
82
+ * same source: the same rows render the same bodies, a streamed reply is
83
+ * followed the same way, and an edit reaches the host as the same `edit`
84
+ * verb. Both views are mounted by the caller with the same sections (two
85
+ * rows, ids 1 and 2, and a listed `edit`), in the core messages widget's
86
+ * contract: rows are the part `messages.message`
87
+ * (`[data-widget-part~="messages.message"]`), a row's text is its `sp-message-body text`,
88
+ * a row's quick Edit is `button[aria-label="Edit"]`, its edit field is the
89
+ * page's field inside the row — `sp-composer-field`, which core's
90
+ * `MessageComposer` places and a remote drives through the field's own
91
+ * `input` event (`ComponentView.dispatch`), or a plain `textarea` a clone
92
+ * may have swapped in — and Save is the row's button reading "Save".
93
+ * `componentParitySections()` is those sections.
94
+ * @experimental
95
+ */
96
+ export async function componentParityCase(native, remote) {
97
+ const bodies = (v) => v.queryAll('sp-message-body').map((b) => b.getAttribute('text'));
98
+ const streaming = (v) => !!v.queryAll('sp-message-body').at(-1)?.hasAttribute('streaming');
99
+ /**
100
+ * Each row's structure, as a person meets it: who speaks, in what role,
101
+ * the text, and the controls it offers — the same for both copies, or the
102
+ * cutover changes what people see.
103
+ */
104
+ const rows = (v) => v.queryAll('[data-widget-part~="messages.message"]').map((m) => ({
105
+ role: m.getAttribute('data-msg-role'),
106
+ author: m.getAttribute('data-msg-author'),
107
+ name: m.querySelector('[data-widget-part~="messages.message-name"]')?.textContent?.trim() ?? null,
108
+ text: m.querySelector('sp-message-body')?.getAttribute('text') ?? null,
109
+ controls: [...m.querySelectorAll('button[aria-label]')].map((b) => b.getAttribute('aria-label')),
110
+ }));
111
+ const same = (what, a, b) => must(JSON.stringify(a) === JSON.stringify(b), `${what} differ: native ${JSON.stringify(a)}, remote ${JSON.stringify(b)}`);
112
+ const expect = (what, v, got, want) => must(JSON.stringify(got) === JSON.stringify(want), `${what} (${v === native ? 'native' : 'remote'}): ${JSON.stringify(got)}, expected ${JSON.stringify(want)}`);
113
+ same('the rows', rows(native), rows(remote));
114
+ for (const v of [native, remote])
115
+ expect('the rendered bodies', v, bodies(v), ['Hello there', 'Hi!']);
116
+ const steps = [
117
+ [[row(1, 'user', 'Hello there'), row(2, 'assistant', 'Hi!'), row(3, 'assistant', 'Once', { isGenerating: true })], ['Hello there', 'Hi!', 'Once'], true],
118
+ [[row(1, 'user', 'Hello there'), row(2, 'assistant', 'Hi!'), row(3, 'assistant', 'Once upon a time.')], ['Hello there', 'Hi!', 'Once upon a time.'], false],
119
+ ];
120
+ for (const [messages, want, generating] of steps) {
121
+ await native.push('messages', messages);
122
+ await remote.push('messages', messages);
123
+ for (const v of [native, remote]) {
124
+ expect('a streamed reply', v, bodies(v), want);
125
+ expect('the streaming mark on the reply', v, streaming(v), generating);
126
+ }
127
+ same('the rows while streaming', rows(native), rows(remote));
128
+ }
129
+ for (const v of [native, remote]) {
130
+ const which = v === native ? 'native' : 'remote';
131
+ const second = () => v.queryAll('[data-widget-part~="messages.message"]')[1];
132
+ const edit = second()?.querySelector('button[aria-label="Edit"]');
133
+ must(edit, `the second row offers no quick Edit (${which})`);
134
+ await v.click(edit);
135
+ const fields = second()?.querySelectorAll(EDIT_FIELD) ?? [];
136
+ must(fields.length === 1, `Edit opened no field in the row (${which}) — looked for ${EDIT_FIELD}`);
137
+ await editField(v, fields[0], 'Hi, friend!', which);
138
+ const save = [...(second()?.querySelectorAll('button') ?? [])].find((b) => /^\s*save\s*$/i.test(b.textContent ?? ''));
139
+ must(save, `editing offers no Save in the row (${which})`);
140
+ await v.click(save);
141
+ must(!second()?.querySelector(EDIT_FIELD), `Save left the field open (${which})`);
142
+ }
143
+ const edits = (v) => v.invoked.filter((i) => i.key === 'edit');
144
+ for (const v of [native, remote])
145
+ expect('the edit the host was asked for', v, edits(v), [{ key: 'edit', messageId: 2, payload: { content: 'Hi, friend!' } }]);
146
+ }
147
+ /**
148
+ * The sections the parity case's contract names, as a page pushes them to a
149
+ * messages widget: a session, two rows (ids 1 and 2 — a person's, then a
150
+ * character's), core's listed `edit` as a quick message action, a viewer,
151
+ * and the `session_full` dossier core's widget reads its lines, its
152
+ * composer and its turn from (row 3 is the reply the case streams in). Mount
153
+ * a native copy and its remote each with a fresh call — C31 mounts every
154
+ * module with these unless the host names its own.
155
+ * @experimental
156
+ */
157
+ export function componentParitySections() {
158
+ const at = '2026-09-24T10:00:00Z';
159
+ const line = (name, ref) => ({
160
+ controllable: true,
161
+ speaker: { name, ref, face: null, sprite: null },
162
+ swipes: { show: false, right: false },
163
+ embedding: 'hidden',
164
+ });
165
+ return {
166
+ session: { id: 1, name: 'Parity' },
167
+ messages: [
168
+ row(1, 'user', 'Hello there', { characterId: null, personaId: 9, createdAt: at }),
169
+ row(2, 'assistant', 'Hi!', { characterId: 3, personaId: null, createdAt: at }),
170
+ ],
171
+ settings: {},
172
+ actions: {
173
+ message: {
174
+ primary: [
175
+ {
176
+ key: 'edit',
177
+ specSlug: 'core',
178
+ name: 'Edit',
179
+ icon: 'pencil',
180
+ slash: 'edit',
181
+ audience: { see: ['participant'], act: ['item'] },
182
+ venue: 'message',
183
+ origin: 'core',
184
+ canAct: true,
185
+ itemGated: true,
186
+ isNew: false,
187
+ enabled: true,
188
+ quick: true,
189
+ },
190
+ ],
191
+ overflow: [],
192
+ },
193
+ },
194
+ viewer: { userId: 7, isAdmin: false, isGuest: false },
195
+ scoped: {
196
+ session_full: {
197
+ sessionId: 1,
198
+ lines: { 1: line('Pip', 'character:9'), 2: line('Bell', 'character:3'), 3: line('Bell', 'character:3') },
199
+ scenes: [],
200
+ scened: [],
201
+ hasOlder: false,
202
+ loadingOlder: false,
203
+ isOwner: true,
204
+ cast: { sessionPersonas: [], sessionCharacters: [] },
205
+ writes: { scenes: false, lore: false },
206
+ debugPrompts: false,
207
+ selectForSummary: 0,
208
+ summaryEnded: 0,
209
+ composer: {
210
+ draft: { content: '', write: 0 },
211
+ personas: [{ personaId: 9, name: 'Pip' }],
212
+ personaId: 9,
213
+ addPersona: false,
214
+ hidden: false,
215
+ channels: ['main'],
216
+ usage: null,
217
+ tabs: [],
218
+ actions: false,
219
+ notice: false,
220
+ overflow: [],
221
+ palette: [],
222
+ newest: null,
223
+ sendTonal: false,
224
+ },
225
+ turn: { order: [], candidates: [], show: false, canChoose: false },
226
+ readOnly: null,
227
+ state: { ledgers: {}, pending: {}, waiting: [] },
228
+ backdrop: false,
229
+ },
230
+ },
231
+ };
232
+ }
233
+ /**
234
+ * A package's own built module, mounted by the host in a plugin's box (C31):
235
+ * it mounts (the host's `mountComponent` resolved — the harness waits for
236
+ * the component's ready), the guarded connection refused nothing it placed,
237
+ * it raised no `ctx.error`, and it unmounts without throwing or raising one.
238
+ * Behaviour is the package's own component tests'; this is the floor a
239
+ * module must clear before any behaviour is worth asking about. Returns
240
+ * advisories (an empty box).
241
+ * @experimental
242
+ */
243
+ export async function componentMountCase(id, view) {
244
+ const notes = [];
245
+ let unmounted = false;
246
+ try {
247
+ await view.settle?.();
248
+ must(!view.refused.length, `component '${id}': the page refused what it placed — ${view.refused.join('; ')}. A plugin's box takes the ` +
249
+ `host-element vocabulary only; move what was refused inside it`);
250
+ must(view.errors, `component '${id}': the view reports no errors — supply ComponentView.errors (the SDK harness's does)`);
251
+ must(!view.errors.length, `component '${id}': it raised ${view.errors.map((e) => `${e.fatal ? 'a fatal' : 'an'} error '${e.message}'`).join(', ')} on mount`);
252
+ if (!view.html().trim())
253
+ notes.push(`component '${id}': mounted with the kit's sections and rendered nothing`);
254
+ unmounted = true;
255
+ try {
256
+ await view.unmount();
257
+ }
258
+ catch (e) {
259
+ throw new Error(`component '${id}': it did not unmount cleanly — ${e.message}`);
260
+ }
261
+ must(!view.errors.length, `component '${id}': it raised ${view.errors.map((e) => `'${e.message}'`).join(', ')} while unmounting`);
262
+ }
263
+ catch (e) {
264
+ if (!unmounted)
265
+ await view.unmount().catch(() => { });
266
+ throw e;
267
+ }
268
+ return notes;
269
+ }
270
+ //# sourceMappingURL=components.js.map
@@ -0,0 +1,405 @@
1
+ /**
2
+ * The conformance kit (03 §9).
3
+ *
4
+ * This is the artifact SP Core upgrades *against*. The rest of this package is a
5
+ * reference implementation whose runtime half is placeholder — a real executor will have
6
+ * durable gate parking, a persistent run queue, transactions and four transports, none of
7
+ * which are here. What survives the port is **the contracts**, and a contract nobody can
8
+ * execute is a document.
9
+ *
10
+ * So: core implements `HostUnderTest`, runs `conform(host)`, and gets a pass/fail per
11
+ * requirement with the law it comes from. The SDK's own executor runs the same kit, which
12
+ * is what keeps the kit honest — a requirement the reference implementation cannot pass is
13
+ * a requirement stated wrong.
14
+ *
15
+ * Every check states **what would be broken if it failed**, because a red line saying
16
+ * "F13" tells an implementer nothing about what to go and look at.
17
+ */
18
+ import type { SpecDocument } from '@serene-pub/sdk';
19
+ import type { Finding } from '@serene-pub/sdk';
20
+ import type { Receipt } from '@serene-pub/sdk';
21
+ import type { Bindings, RunOptions } from '@serene-pub/sdk';
22
+ import type { VenueListings } from '@serene-pub/sdk';
23
+ import type { GenreDecl, PresetDecl } from '@serene-pub/sdk';
24
+ import type { EventGraph } from '@serene-pub/sdk';
25
+ import { type Door } from '@serene-pub/sdk';
26
+ /**
27
+ * The plugin grant table (plans/29 R-3), imported rather than restated.
28
+ * `pluginHarness.ts` keeps it byte-for-byte with the two sandboxes' programs
29
+ * and the app's `hookCtx.ts`, and its docblock says what a further copy would
30
+ * be: the drift the install-time check exists to catch. C25 judges a host's
31
+ * endowment against this one.
32
+ */
33
+ import { type HookCtxKind } from '@serene-pub/sdk/testing';
34
+ import { type ComponentView } from './components.js';
35
+ import { type NodeHandler, type SwapEvidence } from './packages.js';
36
+ import type { Descriptor } from '@serene-pub/sdk';
37
+ export * from './components.js';
38
+ export * from './packages.js';
39
+ /**
40
+ * One entry of a host's venue listing, as C19 reads it (F40): the action's
41
+ * identity — its `key` and the id of the spec that contributed it, never the
42
+ * declaration object, because a host decorates its entries — and, in the
43
+ * composer, the slash name the host calls it by.
44
+ * @experimental
45
+ */
46
+ export interface ListedAction {
47
+ key: string;
48
+ /** The contributing spec's id: the document's `id` here, core's `specSlug`. */
49
+ specId: string;
50
+ /** The slash name the host lists the action under. Required of a composer entry. */
51
+ slash?: string;
52
+ }
53
+ /** @experimental A built component module a host lists (C30, C31). */
54
+ export interface BuiltComponent {
55
+ id: string;
56
+ /** The built module's code. */
57
+ code: string;
58
+ /** The scopes the page grants it (`session:full`, …) when C31 mounts it. */
59
+ grants?: string[];
60
+ /**
61
+ * The base sections its widget declares it reads (`WidgetDecl.reads`, R75)
62
+ * — C31 mounts it with those and no others, as the page does, so a module
63
+ * that reads a section it never declared fails here rather than on a
64
+ * layout. Omitted: every base section, as a declaration without `reads`
65
+ * gets. `componentsFromManifest` fills it from the package's widgets.
66
+ */
67
+ reads?: string[];
68
+ /** The sections C31 mounts it with; `componentParitySections()` when omitted. */
69
+ sections?: Record<string, unknown>;
70
+ /**
71
+ * The core component this module is a clone of (its manifest's
72
+ * `components[].basedOn.component`). One based on `messages` brings C30's
73
+ * parity half into play; with none, that half is not applicable.
74
+ */
75
+ basedOn?: string;
76
+ }
77
+ /** @experimental */
78
+ export interface HostUnderTest {
79
+ name: string;
80
+ validate(doc: SpecDocument): Finding[];
81
+ run(doc: SpecDocument, opts: RunOptions): Promise<Receipt>;
82
+ replay(doc: SpecDocument, receipt: Receipt, bindings: Bindings): Promise<Receipt>;
83
+ /** Canonical form, for the round-trip law. */
84
+ canonicalHash(doc: SpecDocument): string;
85
+ importDocument(doc: SpecDocument): SpecDocument;
86
+ /**
87
+ * The host's own venue projection of the actions one document
88
+ * contributes, for one channel (F40) — what its composer, message menu
89
+ * and settings tabs render from. C19 judges THIS, entry by entry: the
90
+ * SDK's executor implements it with `placeActions` over `actionsOf(doc)`,
91
+ * each entry decorated with `slashNameOf`; core implements it with
92
+ * `listSessionActions`'s placement (its `specSlug` is `specId` here).
93
+ * Optional because a validator-only host has no listing — C19 then fails
94
+ * naming the missing seam, rather than judging a rule the kit applied on
95
+ * the host's behalf, which any host would pass (U7 review, C1).
96
+ */
97
+ listActions?(doc: SpecDocument, channel: string): VenueListings<ListedAction> | Promise<VenueListings<ListedAction>>;
98
+ /**
99
+ * What this host **ships**: the genres it offers in the picker and the
100
+ * presets that fill their event slots. C24's law is about a catalogue
101
+ * rather than a document — a genre that declares no `form-addressed` event
102
+ * has nowhere to route an answer, and a preset that binds no pipeline to it
103
+ * leaves every form it writes unanswerable — so it is read off what the
104
+ * host ships and nowhere else. Optional: a host that ships no catalogue of
105
+ * its own (a validator, a test harness) is not judged on it.
106
+ */
107
+ shipped?(): ShippedCatalogue | Promise<ShippedCatalogue>;
108
+ /**
109
+ * The **event map** this host draws for one genre, with each node's
110
+ * termination policy — C29's evidence (PLAN-turn-order §B3). The graph is
111
+ * the host's own (the app's `eventMap`), never one the kit derives, and a
112
+ * termination policy is the host's statement of how a loop through that
113
+ * node stops: auto-advance's cause rule and cap, or the run caps that park
114
+ * a run tree for its owner. Optional: a host with no event dispatch has
115
+ * no loops to judge.
116
+ */
117
+ eventMap?(genre: string): EventMapEvidence | Promise<EventMapEvidence>;
118
+ /**
119
+ * The BUILT component modules this host ships or has been handed — C30's
120
+ * evidence for what a module may carry (§3.5).
121
+ */
122
+ components?(): BuiltComponent[] | Promise<BuiltComponent[]>;
123
+ /**
124
+ * Mount a built component module the way this host's page does — its
125
+ * worker, its gate — in a **plugin's box** (never core's), with these
126
+ * sections pushed and, when given, these scopes granted and only these
127
+ * base sections read (`reads`, R75 — the page withholds every other base
128
+ * section, as it does from a widget that declared them); show the kit the
129
+ * result. C30 mounts its own fixture through it; C31 mounts every module
130
+ * `components()` lists. The SDK harness takes both as they are
131
+ * (`mountComponent({ …, grants, reads })`).
132
+ */
133
+ mountComponent?(code: string, sections: Record<string, unknown>, opts?: {
134
+ grants?: string[];
135
+ reads?: string[];
136
+ }): Promise<ComponentView>;
137
+ /**
138
+ * This host's messages widget twice, over the same sections: its native
139
+ * copy and a remote built from the same source (C30's parity half).
140
+ * A package supplies it only when it ships a clone of core's messages
141
+ * (`BuiltComponent.basedOn === 'messages'`); a package that lists its
142
+ * components and ships no such clone has no pair to mirror, and the half
143
+ * is recorded not applicable rather than skipped.
144
+ */
145
+ componentParity?(): Promise<{
146
+ native: ComponentView;
147
+ remote: ComponentView;
148
+ }>;
149
+ /**
150
+ * The swaps offered to this host (R28/R29) — a package's manifest's
151
+ * `swaps`, each with the declaration of the definition it seats
152
+ * (`swapsFromManifest`). C32 fits each against `pinnedDefinition`; C33
153
+ * probes each definition's handler.
154
+ */
155
+ swaps?(): SwapEvidence[] | Promise<SwapEvidence[]>;
156
+ /**
157
+ * The definition this host's own spec `spec` seats at `node` — its
158
+ * compiled document's node, resolved in its own registry
159
+ * (`pinnedDefinitionIn(coreSpec(spec)?.build(), node)` for core's).
160
+ * Undefined when the host has no such spec or node.
161
+ */
162
+ pinnedDefinition?(spec: string, node: string): Descriptor | undefined | Promise<Descriptor | undefined>;
163
+ /**
164
+ * The handler this host would call for a definition id — a package's
165
+ * bundle export, as `manifest.hooks.nodeHandlers` names it (C33).
166
+ */
167
+ nodeHandler?(definitionId: string): NodeHandler | undefined | Promise<NodeHandler | undefined>;
168
+ /**
169
+ * The binding probes' input for a definition whose in-ports the kit has
170
+ * no sample for (`PROBE_SAMPLES`) — one value per in-port. C33.
171
+ */
172
+ probeInput?(definition: Descriptor): Record<string, unknown> | undefined;
173
+ /**
174
+ * The keys a **plugin** hook of this kind finds on its `ctx`, as this host
175
+ * endows them — `Object.keys(ctx)` off the context the host builds, never a
176
+ * list computed for the kit, for the same reason `listActions` is the
177
+ * host's own projection: a list the kit derived would pass any host.
178
+ *
179
+ * `undefined` for a kind this host cannot dispatch leaves that kind
180
+ * unjudged with the gap named; a host with no plugin surface at all omits
181
+ * the seam, and C25 says which law went unchecked.
182
+ */
183
+ hookCtxKeys?(kind: HookCtxKind): readonly string[] | undefined | Promise<readonly string[] | undefined>;
184
+ /**
185
+ * How this host mounts a frame surface (20 §12). Optional; without it C26
186
+ * names the gap rather than judging a boundary the kit cannot see.
187
+ */
188
+ frameMount?(): FrameMount | Promise<FrameMount>;
189
+ /**
190
+ * One entry per door this host has (01 §13). The kit feeds each
191
+ * registered verdict's `failing(door)` input through it and expects
192
+ * `judge(failing).sentence` back (the en text) somewhere in what the door
193
+ * refused with; `null` if the door heard the input and did not refuse —
194
+ * a failure, the rule is not heard there; `undefined` if this host's door
195
+ * does not hear that verdict at all — a gap, named on the result (the
196
+ * SDK's `registry` is `register()`, which never judges what a host can
197
+ * run, so R-2's publication half is the app's to answer there). The entry
198
+ * drives the host's REAL door — `validate` runs its validator on a
199
+ * document built to hit the verdict, `run` runs the executor and answers
200
+ * the receipt's halt or note, `registry` registers a declaration and
201
+ * answers the throw — never the verdict itself, which any host would
202
+ * pass. Optional; without it C27 names the seam, and a door left out is
203
+ * named per verdict.
204
+ */
205
+ doors?: Partial<Record<Door, (verdictId: string, failing: unknown) => string | null | undefined | Promise<string | null | undefined>>>;
206
+ }
207
+ /** @experimental What a host ships, for C24's read of the form surface (R-15). */
208
+ export interface ShippedCatalogue {
209
+ genres: readonly GenreDecl[];
210
+ presets: readonly PresetDecl[];
211
+ }
212
+ /** @experimental C29's evidence: one genre's event map and the termination policy of each node that has one. */
213
+ export interface EventMapEvidence extends EventGraph {
214
+ terminations: Readonly<Record<string, string>>;
215
+ }
216
+ /**
217
+ * The two strings that decide what a frame document can reach, plus what the
218
+ * host will listen to from inside one — C26's evidence.
219
+ *
220
+ * Declared by the host rather than inspected by the kit, because the mount
221
+ * happens in a browser the kit is not in: core mounts its `<iframe>` in
222
+ * `PluginFrame.svelte` and serves the document from `/plugin-ui`, and the
223
+ * preview harness mounts the same attributes over a dev server. What the kit
224
+ * can do is judge the pair, which is where every frame escape has come from.
225
+ * @experimental
226
+ */
227
+ export interface FrameMount {
228
+ /** The iframe's `sandbox` attribute, verbatim — `allow-scripts`. */
229
+ sandbox: string;
230
+ /** The `Content-Security-Policy` the frame document is served under, verbatim. */
231
+ csp: string;
232
+ /**
233
+ * The frame → host message kinds this host answers (`FrameHostMessage`'s
234
+ * `t`). Optional; supplied, C26 holds it to "a frame proposes, the host
235
+ * decides": an action-firing kind is among them and nothing that commits
236
+ * is.
237
+ */
238
+ accepts?: readonly string[];
239
+ }
240
+ /** @experimental What a check may tell the runner besides pass or fail. */
241
+ export interface CheckReport {
242
+ /**
243
+ * A half of the requirement this host could not be judged on, and why.
244
+ * Recorded on the result as `skipped`, never as a failure — for a gap in
245
+ * the host's shape rather than a law broken: C18(b) on a host whose
246
+ * `run` refuses a document `validate()` refuses (U7 review, W1).
247
+ */
248
+ skip(why: string): void;
249
+ /**
250
+ * Something the host should hear that is not a failure — an advisory
251
+ * (C30's element scan: the runtime allowlist is the law). Recorded as
252
+ * `notes`.
253
+ */
254
+ note(what: string): void;
255
+ /**
256
+ * A half of the requirement that does not apply to this host, and why —
257
+ * not a hole in the host's shape (that is `skip`) and not a pass by
258
+ * default: the law has nothing to judge here (C30's parity half on a
259
+ * package that ships no clone of core's messages). Recorded as
260
+ * `notApplicable`.
261
+ */
262
+ notApplicable(why: string): void;
263
+ }
264
+ /** @experimental */
265
+ export interface Requirement {
266
+ id: string;
267
+ law: string;
268
+ title: string;
269
+ /** What breaks in the product if this is not true. Written for whoever sees it go red. */
270
+ consequence: string;
271
+ check(host: HostUnderTest, fx: Fixtures, report: CheckReport): Promise<void> | void;
272
+ }
273
+ /**
274
+ * The kit does not build specs itself — core's builder and the SDK's are the same code,
275
+ * but a host may want to feed documents it produced another way. Fixtures are injected.
276
+ * @experimental
277
+ */
278
+ export interface Fixtures {
279
+ /**
280
+ * A minimal chat turn: input → query → task → provider → write, the write
281
+ * opening the run's **live row** (`create-message` with `generating: true`
282
+ * — F7, W1). C16 holds the host to naming that row; a complete message
283
+ * would be an ordinary write, and a run with none names no live row.
284
+ */
285
+ chatTurn(): SpecDocument;
286
+ /** The same, with a Task that halts before anything effectful. */
287
+ haltsEarly(): SpecDocument;
288
+ /** An async block with three chains, for the equivalence law. */
289
+ gather(): SpecDocument;
290
+ /** A map with a declared max. */
291
+ mapped(): SpecDocument;
292
+ /** A loop with a predicate inside its body. */
293
+ looped(max: number): SpecDocument;
294
+ /**
295
+ * Two `create-message` placeholders (`generating: true`) in one document,
296
+ * an oracle between them (F37). Two live rows, which `validate()`
297
+ * refuses under F7 — that refusal IS the one-live-row law at publish
298
+ * (a complete message beside them would be an ordinary write, W1), and C16(a) holds the host to it. Never run: the run
299
+ * half of the law is proved on `chatTurn()`, a document the host can
300
+ * publish (U7 review, W1).
301
+ */
302
+ twoWrites(): SpecDocument;
303
+ /**
304
+ * A document contributing actions (F40): at least one `quick`, one not,
305
+ * one on a named channel, one whose `key` is a core verb's (a different
306
+ * identity, never shadowing it — plans/31 V2). Every
307
+ * one of them must be reachable from its venue's listing.
308
+ */
309
+ actions(): SpecDocument;
310
+ /**
311
+ * Documents that must be rejected, each paired with the law it violates.
312
+ * The `F39` entries are also RUN, unvalidated, by C18(b) — the wiring that
313
+ * asks for another node's setting must be handed nothing even when the
314
+ * check was skipped. A host whose `run` refuses them is skipped on that
315
+ * half, with the reason on the result (`CheckReport.skip`).
316
+ */
317
+ invalid(): Array<{
318
+ law: string;
319
+ doc: SpecDocument;
320
+ because: string;
321
+ }>;
322
+ /**
323
+ * A document with a **live-row** outlet inside a repeating clause (01 §4,
324
+ * W1) — an `each` or loop body. One reply row per pass is N live rows;
325
+ * other writes may repeat, and any write may sit in a gather or a
326
+ * junction. Optional; without it C21 judges the two-live-rows half alone
327
+ * and names the fixture it is missing.
328
+ */
329
+ writeInClause?(): SpecDocument;
330
+ /**
331
+ * A **parallel** gather whose chains each end in a write, the first chain
332
+ * declared finishing LAST (a slow node before its write). C8 holds the
333
+ * host to committing the writes in declaration order in both modes (01 §4,
334
+ * W1b). Optional; without it C8 judges its results half alone and names
335
+ * the fixture it is missing.
336
+ */
337
+ gatherWrites?(): SpecDocument;
338
+ /**
339
+ * A document contributing a `world` action in a venue the effects line
340
+ * allows (`WORLD_ACTION_VENUES` — composer, message, session settings, admin,
341
+ * review), and nothing else about it matters. C23 names that action's
342
+ * function in a `choices` block, which is the shape a node can publish and
343
+ * no document can be validated for. Optional; without it the block half is
344
+ * not judged.
345
+ */
346
+ worldAction?(): SpecDocument;
347
+ bindings(over?: Bindings): Bindings;
348
+ world: RunOptions['world'];
349
+ /**
350
+ * How many writes the world has taken so far (F38), for a host whose
351
+ * writes the kit cannot watch through `RunOptions.host` — a row count in a
352
+ * test database, say. Optional: the kit's own probe covers a host that
353
+ * routes `ctx.commit` to `RunOptions.host.commit`, and is read first — a
354
+ * probe that saw the commit is never shadowed by a row count it kept from
355
+ * moving. This is the fallback when the probe saw nothing; C16 and C17
356
+ * name the gap when neither shows a write.
357
+ */
358
+ writesSeen?(): number | Promise<number>;
359
+ }
360
+ /** @experimental */
361
+ export declare class ConformanceError extends Error {
362
+ }
363
+ /** @experimental */
364
+ export declare const REQUIREMENTS: Requirement[];
365
+ /** @experimental — held back from the frozen surface until the host seams (`HostUnderTest`) settle */
366
+ export interface ConformanceResult {
367
+ id: string;
368
+ law: string;
369
+ title: string;
370
+ pass: boolean;
371
+ error?: string;
372
+ consequence?: string;
373
+ /**
374
+ * The halves of the requirement this host could not be judged on, each
375
+ * with why (`CheckReport.skip`). A pass with entries here is a pass with
376
+ * a hole named — read them before calling the host conformant.
377
+ */
378
+ skipped?: string[];
379
+ /** What the host should hear that is not a failure (`CheckReport.note`). */
380
+ notes?: string[];
381
+ /** The halves of the requirement that do not apply to this host, each with why (`CheckReport.notApplicable`). */
382
+ notApplicable?: string[];
383
+ }
384
+ /**
385
+ * The requirements a package's own declarations can fail, judged over its
386
+ * BUILT artifact with no fixtures: what it ships (C28, C29), its component
387
+ * modules (C30, C31), and its swaps (C32, C33). The rest judge a host's
388
+ * executor, not a package.
389
+ * @experimental — held back from the frozen surface until the host seams (`HostUnderTest`) settle
390
+ */
391
+ export declare const PACKAGE_REQUIREMENTS: readonly ['C28', 'C29', 'C30', 'C31', 'C32', 'C33'];
392
+ /**
393
+ * `conform` over `PACKAGE_REQUIREMENTS` (or the subset `only` names) — a
394
+ * plugin's test, carrying its artifact on the SDK's executor and harness.
395
+ * These cases read no fixtures.
396
+ * @experimental — held back from the frozen surface until the host seams (`HostUnderTest`) settle
397
+ */
398
+ export declare function conformPackage(host: HostUnderTest, only?: readonly string[]): Promise<ConformanceResult[]>;
399
+ /** @experimental */
400
+ export declare function conform(host: HostUnderTest, fx: Fixtures, opts?: {
401
+ only?: readonly string[];
402
+ }): Promise<ConformanceResult[]>;
403
+ /** @experimental — held back from the frozen surface until the host seams (`HostUnderTest`) settle */
404
+ export declare function renderConformance(results: ConformanceResult[]): string;
405
+ //# sourceMappingURL=index.d.ts.map