@serene-pub/sdk 0.6.0-pr-2 → 0.6.0-pr-5

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.
Files changed (186) hide show
  1. package/README.md +24 -20
  2. package/dist/actions.d.ts +150 -68
  3. package/dist/actions.js +90 -36
  4. package/dist/annexFields.d.ts +8 -4
  5. package/dist/annexFields.js +5 -2
  6. package/dist/announce.d.ts +78 -28
  7. package/dist/announce.js +14 -5
  8. package/dist/attributes.d.ts +9 -6
  9. package/dist/attributes.js +9 -5
  10. package/dist/bands.d.ts +41 -6
  11. package/dist/bands.js +83 -33
  12. package/dist/builder.d.ts +161 -58
  13. package/dist/builder.js +128 -22
  14. package/dist/candidates.d.ts +5 -3
  15. package/dist/candidates.js +3 -2
  16. package/dist/clauses.d.ts +2 -1
  17. package/dist/clauses.js +2 -1
  18. package/dist/component.d.ts +24 -7
  19. package/dist/component.js +16 -6
  20. package/dist/componentBuild.d.ts +16 -5
  21. package/dist/componentBuild.js +14 -5
  22. package/dist/componentClient.d.ts +61 -30
  23. package/dist/componentClient.js +11 -1
  24. package/dist/componentImports.d.ts +8 -5
  25. package/dist/componentImports.js +23 -4
  26. package/dist/componentModule.js +2 -1
  27. package/dist/componentWire.d.ts +2 -1
  28. package/dist/componentWire.js +34 -2
  29. package/dist/config.d.ts +28 -14
  30. package/dist/config.js +20 -10
  31. package/dist/connections.d.ts +9 -4
  32. package/dist/connections.js +7 -4
  33. package/dist/declarations.d.ts +46 -17
  34. package/dist/declarations.js +46 -15
  35. package/dist/descriptors.d.ts +242 -97
  36. package/dist/descriptors.js +145 -41
  37. package/dist/dev.d.ts +6 -5
  38. package/dist/dev.js +6 -5
  39. package/dist/document.d.ts +74 -25
  40. package/dist/document.js +32 -11
  41. package/dist/dowry.d.ts +241 -0
  42. package/dist/dowry.js +315 -0
  43. package/dist/engines.d.ts +16 -7
  44. package/dist/engines.js +6 -4
  45. package/dist/eventMapLaws.d.ts +19 -8
  46. package/dist/eventMapLaws.js +9 -6
  47. package/dist/events.d.ts +101 -39
  48. package/dist/events.js +106 -33
  49. package/dist/executor.d.ts +122 -41
  50. package/dist/executor.js +195 -96
  51. package/dist/extension.d.ts +99 -35
  52. package/dist/extension.js +43 -9
  53. package/dist/facets.d.ts +2 -1
  54. package/dist/facets.js +4 -2
  55. package/dist/foldedSections.d.ts +4 -2
  56. package/dist/foldedSections.js +2 -1
  57. package/dist/genres.d.ts +123 -41
  58. package/dist/genres.js +127 -22
  59. package/dist/guardedConnection.d.ts +4 -3
  60. package/dist/guardedConnection.js +4 -3
  61. package/dist/handlebarsReach.d.ts +1 -1
  62. package/dist/handlebarsReach.js +1 -1
  63. package/dist/hash.d.ts +16 -5
  64. package/dist/hash.js +14 -4
  65. package/dist/hookGrants.d.ts +3 -2
  66. package/dist/hookGrants.js +6 -4
  67. package/dist/hooks.d.ts +21 -16
  68. package/dist/hooks.js +12 -10
  69. package/dist/hostElements.d.ts +41 -17
  70. package/dist/hostElements.js +49 -17
  71. package/dist/i18n.d.ts +5 -3
  72. package/dist/i18n.js +5 -3
  73. package/dist/identity.d.ts +5 -4
  74. package/dist/identity.js +5 -4
  75. package/dist/index.d.ts +5 -0
  76. package/dist/index.js +15 -0
  77. package/dist/layout.d.ts +36 -15
  78. package/dist/layout.js +2 -2
  79. package/dist/loadouts.d.ts +97 -0
  80. package/dist/loadouts.js +81 -0
  81. package/dist/media.d.ts +26 -4
  82. package/dist/media.js +2 -1
  83. package/dist/messageBlocks.d.ts +44 -32
  84. package/dist/messageBlocks.js +23 -18
  85. package/dist/migration.d.ts +16 -8
  86. package/dist/migration.js +14 -8
  87. package/dist/names.d.ts +2 -1
  88. package/dist/names.js +2 -1
  89. package/dist/nodeInput.d.ts +2 -1
  90. package/dist/nodeInput.js +2 -1
  91. package/dist/participants.d.ts +22 -15
  92. package/dist/participants.js +14 -12
  93. package/dist/personGate.d.ts +2 -1
  94. package/dist/personGate.js +2 -1
  95. package/dist/pluginHarness.d.ts +8 -3
  96. package/dist/pluginHarness.js +4 -2
  97. package/dist/pluginPermissions.d.ts +2 -1
  98. package/dist/pluginPermissions.js +12 -1
  99. package/dist/pluginRuleRef.d.ts +2 -2
  100. package/dist/pluginRuleRef.js +1 -1
  101. package/dist/predicates.d.ts +16 -11
  102. package/dist/predicates.js +7 -6
  103. package/dist/preview.d.ts +8 -3
  104. package/dist/preview.js +2 -1
  105. package/dist/promptBlocks.d.ts +5 -3
  106. package/dist/promptBlocks.js +5 -3
  107. package/dist/rankingDecisions.d.ts +2 -1
  108. package/dist/rankingDecisions.js +2 -1
  109. package/dist/receipt.d.ts +65 -29
  110. package/dist/receipt.js +9 -4
  111. package/dist/receiverRules.js +3 -2
  112. package/dist/refs.d.ts +34 -9
  113. package/dist/refs.js +33 -13
  114. package/dist/registry.d.ts +42 -23
  115. package/dist/registry.js +7 -5
  116. package/dist/review.d.ts +16 -5
  117. package/dist/review.js +11 -4
  118. package/dist/sampling.d.ts +54 -0
  119. package/dist/sampling.js +95 -3
  120. package/dist/sceneSettings.d.ts +312 -0
  121. package/dist/sceneSettings.js +425 -0
  122. package/dist/scope.d.ts +6 -4
  123. package/dist/scope.js +4 -3
  124. package/dist/scripts.d.ts +81 -14
  125. package/dist/scripts.js +90 -11
  126. package/dist/sessionDossier.d.ts +521 -0
  127. package/dist/sessionDossier.js +33 -0
  128. package/dist/sessionLayout.d.ts +303 -19
  129. package/dist/sessionLayout.js +354 -40
  130. package/dist/sessionSettings.d.ts +8 -5
  131. package/dist/settings.d.ts +45 -20
  132. package/dist/settings.js +19 -12
  133. package/dist/settingsSlot.d.ts +11 -8
  134. package/dist/settingsSlot.js +11 -8
  135. package/dist/shapes.d.ts +103 -41
  136. package/dist/shapes.js +105 -40
  137. package/dist/sheets.d.ts +4 -2
  138. package/dist/sheets.js +6 -3
  139. package/dist/statShapes.d.ts +2 -1
  140. package/dist/statShapes.js +2 -1
  141. package/dist/status.d.ts +13 -9
  142. package/dist/status.js +8 -6
  143. package/dist/storage.d.ts +2 -1
  144. package/dist/storage.js +2 -1
  145. package/dist/storyTime.d.ts +13 -7
  146. package/dist/storyTime.js +11 -6
  147. package/dist/strokes.d.ts +176 -0
  148. package/dist/strokes.js +281 -0
  149. package/dist/surfaces.d.ts +54 -25
  150. package/dist/surfaces.js +3 -3
  151. package/dist/template.d.ts +9 -5
  152. package/dist/template.js +5 -3
  153. package/dist/templateCheck.d.ts +2 -2
  154. package/dist/templateCheck.js +2 -2
  155. package/dist/templateFit.d.ts +37 -8
  156. package/dist/templateFit.js +92 -8
  157. package/dist/templateIds.d.ts +3 -3
  158. package/dist/templateIds.js +3 -3
  159. package/dist/templateScopeAt.d.ts +21 -11
  160. package/dist/templateScopeAt.js +21 -11
  161. package/dist/testing.d.ts +11 -4
  162. package/dist/testing.js +13 -5
  163. package/dist/tokenizers.d.ts +2 -2
  164. package/dist/tokenizers.js +2 -2
  165. package/dist/turnLock.d.ts +4 -2
  166. package/dist/turnLock.js +2 -1
  167. package/dist/turnOrder.d.ts +17 -11
  168. package/dist/turnOrder.js +9 -5
  169. package/dist/validate.d.ts +11 -8
  170. package/dist/validate.js +81 -10
  171. package/dist/values.d.ts +17 -8
  172. package/dist/values.js +11 -6
  173. package/dist/variables.d.ts +46 -7
  174. package/dist/variables.js +87 -6
  175. package/dist/verdicts.d.ts +20 -13
  176. package/dist/verdicts.js +17 -11
  177. package/dist/widgetDecls.d.ts +8 -4
  178. package/dist/widgetDecls.js +4 -2
  179. package/dist/widgets.d.ts +987 -94
  180. package/dist/widgets.js +93 -18
  181. package/dist/wire.d.ts +13 -6
  182. package/dist/wire.js +3 -3
  183. package/dist/worldinfo.d.ts +11 -6
  184. package/dist/worldinfo.js +8 -4
  185. package/host-elements.d.ts +13 -0
  186. package/package.json +1 -1
package/dist/genres.js CHANGED
@@ -1,12 +1,13 @@
1
1
  import { widgetRef } from './widgetDecls.js';
2
- import { drawnWidgetIds, layoutWidgetIds, widgetOfInstance } from './sessionLayout.js';
2
+ import { drawnWidgetIds, layoutWidgetIds, resolveWidgetAlias } from './sessionLayout.js';
3
3
  import { assertChannelDecls, assertMessageVerbFloors, assertSessionWrites, assertTurnControls, channelDecls, widgetDeclsFindings, } from './descriptors.js';
4
+ import { assertSceneSettings, declaredScenePlace } from './sceneSettings.js';
4
5
  import { i18nFindings, localeMapOf } from './i18n.js';
5
6
  import { eventById, notADeclaredEvent } from './events.js';
6
7
  import { settingsSchemaFindings } from './settings.js';
7
8
  import { getAttributeSlot } from './attributes.js';
8
9
  import { refuseUnlessIdentical } from './hash.js';
9
- import { isActionIdentity } from './identity.js';
10
+ import { isActionIdentity, parseSpecId, assertSpecId } from './identity.js';
10
11
  import { enabledWhenFindings, normalizeEnabledWhen, } from './predicates.js';
11
12
  /** `owner:genre/name` — lowercase, digits, hyphens, dots in the owner. */
12
13
  const GENRE_ID = /^[a-z0-9]+(?:[.-][a-z0-9]+)*:genre\/[a-z0-9]+(?:-[a-z0-9]+)*$/;
@@ -18,30 +19,35 @@ export function assertGenreId(id) {
18
19
  `lifetime; the display name lives in the declaration.`);
19
20
  }
20
21
  /**
21
- * The core session events (24 §5), as **event ids** — `core:event/<name>@1`.
22
+ * The core session events, as **event ids** — `core:event/<name>@1`.
22
23
  *
23
- * Constants so the core vocabulary is typo-proof. Since R-4 (ruled 2026-09-15,
24
- * landed 2026-09-16) these ARE `CORE_EVENTS` entries (`events.ts`): one
24
+ * Constants so the core vocabulary is typo-proof. Since 2026-09-16
25
+ * these ARE `CORE_EVENTS` entries (`events.ts`): one
25
26
  * registry, and a genre's event surface, a preset's `bindings` map and a spec's
26
27
  * inlet lock are all keyed by these ids. The bare names (`session-created`)
27
28
  * were the keys until the fold; a host migrates its stored keys once.
28
29
  * @public
30
+ * @ruling 24 §5, R-4 (ruled 2026-09-15)
29
31
  */
30
32
  export const sessionEvents = Object.freeze({
31
33
  /** The create slot — required; exactly one pipeline per genre declares it. */
32
34
  sessionCreated: 'core:event/session-created@1',
33
35
  /** The primary turn. A swipe is this pipeline re-run, not a new event. */
34
36
  messageRespond: 'core:event/message-respond@1',
35
- /** Arbitrary buttons/triggers — the existing functions surface (19 §3). */
37
+ /**
38
+ * Arbitrary buttons/triggers — the existing functions surface.
39
+ * @ruling 19 §3
40
+ */
36
41
  sessionAction: 'core:event/session-action@1',
37
42
  /** A character or persona joined; payload carries the kind. */
38
43
  memberAdded: 'core:event/member-added@1',
39
44
  /** A character or persona left; payload carries the kind. */
40
45
  memberRemoved: 'core:event/member-removed@1',
41
46
  /**
42
- * A form in a message was addressed to a participant the AI portrays
43
- * (R-15 *Forms*; U5d). Optional in every genre's surface: a genre that
47
+ * A form in a message was addressed to a participant the AI portrays.
48
+ * Optional in every genre's surface: a genre that
44
49
  * binds nothing leaves such a form waiting, as it would for a person.
50
+ * @ruling R-15 *Forms*, U5d
45
51
  */
46
52
  formAddressed: 'core:event/form-addressed@1',
47
53
  // ── Turn order as event-driven state (PLAN-turn-order §4.1, 2026-09-21) ──
@@ -55,7 +61,10 @@ export const sessionEvents = Object.freeze({
55
61
  messageDeleted: 'core:event/message-deleted@1',
56
62
  /** A message was hidden from the prompt, or shown again. */
57
63
  messageHidden: 'core:event/message-hidden@1',
58
- /** A line's shown sprite changed — a picker's choice or a person's (DESIGN-sprites). */
64
+ /**
65
+ * A line's shown sprite changed — a picker's choice or a person's.
66
+ * @ruling DESIGN-sprites
67
+ */
59
68
  spriteShown: 'core:event/sprite-shown@1',
60
69
  /** A seated participant's row changed — active, position, visibility or portrayal. */
61
70
  castChanged: 'core:event/cast-changed@1',
@@ -68,6 +77,12 @@ export const sessionEvents = Object.freeze({
68
77
  * `core:outlet/set-session-annex@1`; the payload names the owner.
69
78
  */
70
79
  annexChanged: 'core:event/annex-changed@1',
80
+ /**
81
+ * 🚧 The session's backdrop was set or cleared — by
82
+ * `core:outlet/set-backdrop@1` or by a person.
83
+ * @ruling DESIGN-image-generation §6.4
84
+ */
85
+ backdropSet: 'core:event/backdrop-set@1',
71
86
  /**
72
87
  * `metadata.turnOrder` was written. **For typing only**: core-internal,
73
88
  * read by the auto-advance listener and the `sessions:turnOrder` push;
@@ -76,10 +91,11 @@ export const sessionEvents = Object.freeze({
76
91
  turnOrderChanged: 'core:event/turn-order-changed@1',
77
92
  });
78
93
  /**
79
- * Why no genre may list, and no spec may lock, `turn-order-changed`
80
- * (PLAN-turn-order §4.1): the turn-order write's own event is core-internal.
94
+ * Why no genre may list, and no spec may lock, `turn-order-changed`:
95
+ * the turn-order write's own event is core-internal.
81
96
  * One sentence for `genre()`, the builder's `.inlet()` and the package pass.
82
97
  * @experimental
98
+ * @ruling PLAN-turn-order §4.1
83
99
  */
84
100
  export const TURN_ORDER_CHANGED_IS_INTERNAL = `'${sessionEvents.turnOrderChanged}' is core-internal — the auto-advance listener and the ` +
85
101
  `turn-order push read it, and a pipeline bound to it would recompute the order it was told ` +
@@ -88,11 +104,12 @@ export const TURN_ORDER_CHANGED_IS_INTERNAL = `'${sessionEvents.turnOrderChanged
88
104
  export const genreAllowsCustomAttributes = (g) => (typeof g === 'string' ? registry.get(g) : g)?.customAttributes === 'allow';
89
105
  /**
90
106
  * The name a line nobody claims is shown and prompted under when its genre
91
- * declares no fallback envoy (`EnvoyDecl.fallback`) — display text (R-20), read
107
+ * declares no fallback envoy (`EnvoyDecl.fallback`) — display text, read
92
108
  * in the viewer's language. The host's last resort, so no line is ever
93
109
  * attributed to "Unknown" (ruled 2026-09-26). The same word the host already
94
110
  * gives narration with no narrator name.
95
111
  * @experimental
112
+ * @ruling R-20
96
113
  */
97
114
  export const UNCLAIMED_LINE_NAME = Object.freeze({ en: 'Narrator' });
98
115
  /** An envoy's key: a lowercase kebab token. Dots are reserved for an action's namespace. @experimental */
@@ -102,10 +119,11 @@ export const ENVOY_IMAGE = /^(?:https?:\/\/\S+|data:image\/[a-z0-9.+-]+(?:;[^,]*
102
119
  const ENVOY_SPEAKS = new Set(['in-turn', 'on-action']);
103
120
  /**
104
121
  * Every fault in one envoy declaration, as sentences (the teaching-error
105
- * pattern, 15 §1.3). Empty when it is sound. `owner` says which of the two
122
+ * pattern). Empty when it is sound. `owner` says which of the two
106
123
  * declaring places this is, because an action's envoy has one rule of its own:
107
124
  * it may only be `on-action`.
108
125
  * @internal
126
+ * @ruling 15 §1.3
109
127
  */
110
128
  export function envoyFindings(raw, at, owner = 'genre') {
111
129
  const out = [];
@@ -162,8 +180,9 @@ export function envoyFindings(raw, at, owner = 'genre') {
162
180
  /**
163
181
  * The findings on a genre's whole list: each entry's, plus unique keys, at
164
182
  * most one default, and — given the genre's `channels` (slugs, `main`
165
- * included; R6) — a greeting on a channel the genre does not declare.
183
+ * included) — a greeting on a channel the genre does not declare.
166
184
  * @internal
185
+ * @ruling R6
167
186
  */
168
187
  export function envoysFindings(raw, at = 'envoys', channels) {
169
188
  if (raw === undefined)
@@ -239,13 +258,14 @@ function assertEnabledWhen(decl, genreId) {
239
258
  return Object.freeze(out);
240
259
  }
241
260
  /**
242
- * Every display string a genre carries (R-20): `name` (required) and
261
+ * Every display string a genre carries: `name` (required) and
243
262
  * `description`; the shape's `fields` schema and its `panels[]` titles; and
244
263
  * the `label` / `description` of every slot and sheet it brings. The slots and
245
264
  * sheets passed their own doors already; they are read again here because a
246
265
  * genre is the declaration a session is created under, and a picker card that
247
266
  * lists a slot with no label is this genre's defect to hear about.
248
267
  * @experimental
268
+ * @ruling R-20
249
269
  */
250
270
  export function genreDisplayTextFindings(props, at) {
251
271
  const out = [];
@@ -271,10 +291,11 @@ function assertDisplayText(props, genreId) {
271
291
  throw new Error(findings.join('\n'));
272
292
  }
273
293
  /**
274
- * `GenreProps.playerLabel` (R4), checked and normalised: display text with an
275
- * `en` (R-20), as a frozen locale map — and refused for a genre where a
294
+ * `GenreProps.playerLabel`, checked and normalised: display text with an
295
+ * `en`, as a frozen locale map — and refused for a genre where a
276
296
  * persona always names the person's line (`shape.personas.min ≥ 1`), because
277
297
  * nothing there would ever carry it.
298
+ * @ruling R4, R-20
278
299
  */
279
300
  function assertPlayerLabel(props, genreId) {
280
301
  if (props.playerLabel === undefined)
@@ -298,7 +319,10 @@ function assertEnvoys(envoys, genreId, shape) {
298
319
  }
299
320
  /** Core's conversation widget — the primary widget a genre must replace if it withholds it. @internal */
300
321
  export const CONVERSATION_WIDGET_ID = 'messages';
301
- /** `omitWidgets` read down to ids, and `layouts` checked (R71). */
322
+ /**
323
+ * `omitWidgets` read down to ids, and `layouts` checked.
324
+ * @ruling R71
325
+ */
302
326
  function assertGenreWidgets(props, id) {
303
327
  const problems = [];
304
328
  const omitWidgets = [];
@@ -325,9 +349,13 @@ function assertGenreWidgets(props, id) {
325
349
  problems.push(`${id} layouts: two layouts are '${l.slug}' — a slug names one`);
326
350
  slugs.add(l.slug);
327
351
  // By widget, not by instance: `messages#sanctum` places the conversation.
328
- for (const w of layoutWidgetIds(l.preset))
329
- if (omitWidgets.includes(widgetOfInstance(w)))
352
+ // An aliased id (`world-state`) is both the widget it became and the
353
+ // one it was: omitting either withholds it.
354
+ for (const w of layoutWidgetIds(l.preset)) {
355
+ const read = resolveWidgetAlias(w);
356
+ if (omitWidgets.includes(read.widgetId) || (read.aliasedFrom !== null && omitWidgets.includes(read.aliasedFrom)))
330
357
  problems.push(`${id} layout '${l.slug}' places '${w}', which the genre omits`);
358
+ }
331
359
  }
332
360
  // The primary floor: a session always draws its primary widget. A genre
333
361
  // that withholds the conversation says what stands in its place — its
@@ -346,6 +374,63 @@ function assertGenreWidgets(props, id) {
346
374
  throw new Error(problems.join('\n'));
347
375
  return { omitWidgets: [...new Set(omitWidgets)], layouts };
348
376
  }
377
+ /**
378
+ * 🚧 What is wrong with a genre's `summarize` declaration — one sentence per
379
+ * problem, empty when it is sound. Each entry is a spec id with an owner
380
+ * (`core:spec/lair-summarize-scene`): a bare slug is a hand-imported
381
+ * document's, which no genre can be sure an install holds.
382
+ * @experimental
383
+ */
384
+ export function genreSummarizeFindings(raw, at = 'summarize') {
385
+ if (raw === undefined)
386
+ return [];
387
+ if (!raw || typeof raw !== 'object' || Array.isArray(raw))
388
+ return [`${at}: an object of spec ids — { scene: 'owner:spec/name' } — not ${JSON.stringify(raw)}`];
389
+ const out = [];
390
+ for (const [key, value] of Object.entries(raw)) {
391
+ if (key !== 'scene') {
392
+ out.push(`${at}.${key}: not a summarize pipeline a genre can own — only 'scene' is read`);
393
+ continue;
394
+ }
395
+ if (value === undefined)
396
+ continue;
397
+ if (typeof value !== 'string') {
398
+ out.push(`${at}.scene: a spec id, as a string — not ${JSON.stringify(value)}`);
399
+ continue;
400
+ }
401
+ try {
402
+ assertSpecId(value);
403
+ }
404
+ catch (e) {
405
+ out.push(`${at}.scene: ${e.message}`);
406
+ continue;
407
+ }
408
+ if (!parseSpecId(value).owner)
409
+ out.push(`${at}.scene: '${value}' names no owner — use 'owner:spec/name', e.g. 'core:spec/chat-summarize-scene'`);
410
+ }
411
+ return out;
412
+ }
413
+ /** A slot id as a template reads it: `core:slot/location@1` → `location`. */
414
+ const slotLocalKey = (slotId) => slotId.replace(/^.*:slot\//, '').replace(/@\d+$/, '');
415
+ /**
416
+ * 🚧 A genre's `shape.scenes.place` (live scenes §15 G2) must name a slot the
417
+ * genre declares — in its `slots` or its `sheets` — by the key a template
418
+ * reads it under: a place the genre's state never holds would name no scene
419
+ * and fire no *place changed*. Refused here, where the author is.
420
+ */
421
+ function assertScenePlaceDeclared(props, id) {
422
+ const place = declaredScenePlace(props.shape);
423
+ if (!place)
424
+ return;
425
+ const keys = new Set([
426
+ ...(props.slots ?? []).map((s) => slotLocalKey(s.id)),
427
+ ...(props.sheets ?? []).flatMap((sheet) => (sheet.slots ?? []).map((e) => slotLocalKey(e.id))),
428
+ ]);
429
+ if (!keys.has(place.stateKey))
430
+ throw new Error(`${id}.scenes.place.stateKey: '${place.stateKey}' is not a slot this genre declares` +
431
+ (keys.size ? ` (${[...keys].join(', ')})` : ' — it declares none') +
432
+ ` — the place must be a state value its sessions hold`);
433
+ }
349
434
  /**
350
435
  * Declare a genre. The id is stated in full, under your plugin's slug
351
436
  * (`acme.dice:genre/table`), and the genre value is what everything else
@@ -364,6 +449,11 @@ export function genre(id, props) {
364
449
  assertSessionWrites(props.shape, id);
365
450
  assertTurnControls(props.shape, id);
366
451
  assertChannelDecls(props.shape, id);
452
+ // 🚧 The scene settings (live scenes §4): refused here on the same terms —
453
+ // a mode or a trigger that does not read is an authoring mistake, not a
454
+ // default to fall back to silently.
455
+ assertSceneSettings(props.shape, id);
456
+ assertScenePlaceDeclared(props, id);
367
457
  const events = { ...(props.events ?? {}) };
368
458
  // The turn-order write's own event is core-internal (PLAN-turn-order
369
459
  // §4.1): the recompute must not be able to answer itself, so no genre
@@ -403,6 +493,10 @@ export function genre(id, props) {
403
493
  if (props.customAttributes !== undefined && props.customAttributes !== 'allow' && props.customAttributes !== 'deny')
404
494
  throw new Error(`${id}.customAttributes: 'allow' or 'deny' — not ${JSON.stringify(props.customAttributes)}`);
405
495
  const playerLabel = assertPlayerLabel(props, id);
496
+ const summarizeFindings = genreSummarizeFindings(props.summarize, `${id}.summarize`);
497
+ if (summarizeFindings.length)
498
+ throw new Error(summarizeFindings.join('\n'));
499
+ const summarize = props.summarize?.scene !== undefined ? Object.freeze({ scene: props.summarize.scene }) : undefined;
406
500
  const decl = Object.freeze({
407
501
  id,
408
502
  name: props.name,
@@ -426,6 +520,8 @@ export function genre(id, props) {
426
520
  // R71: absent when unstated, so a genre that says nothing hashes as it did.
427
521
  ...(omitWidgets.length ? { omitWidgets: Object.freeze(omitWidgets) } : {}),
428
522
  ...(layouts.length ? { layouts: Object.freeze(layouts) } : {}),
523
+ // Live scenes §13: absent when unstated, so a genre that says nothing hashes as it did.
524
+ ...(summarize ? { summarize } : {}),
429
525
  });
430
526
  const existing = registry.get(id);
431
527
  if (existing)
@@ -486,8 +582,16 @@ export function _registerPackageGenre(packageId, raw) {
486
582
  throw new Error(`genre '${id}' has no name or family — not a genre declaration`);
487
583
  const events = { ...(raw.events ?? {}) };
488
584
  events[sessionEvents.sessionCreated] = { ...(events[sessionEvents.sessionCreated] ?? {}), required: true };
585
+ // A stored `summarize` the authoring door would refuse is dropped rather
586
+ // than refused: the host then runs core's default summarizer, which is the
587
+ // standing "fall back, never strand the session" rule for a stale binding.
588
+ const { summarize: storedSummarize, ...rest } = raw;
589
+ const summarize = storedSummarize !== undefined && !genreSummarizeFindings(storedSummarize).length
590
+ ? storedSummarize
591
+ : undefined;
489
592
  const decl = Object.freeze({
490
- ...raw,
593
+ ...rest,
594
+ ...(summarize?.scene !== undefined ? { summarize: Object.freeze({ scene: summarize.scene }) } : {}),
491
595
  events: Object.freeze(events),
492
596
  ...(raw.slots ? { slots: Object.freeze([...raw.slots]) } : {}),
493
597
  ...(raw.sheets ? { sheets: Object.freeze([...raw.sheets]) } : {}),
@@ -583,7 +687,7 @@ export const genreIdOf = (g) => {
583
687
  return id;
584
688
  };
585
689
  /**
586
- * The configurable surface of one envoy, as a slot declaration (R-18 (2)).
690
+ * The configurable surface of one envoy, as a slot declaration.
587
691
  *
588
692
  * An envoy is not a node and has no registry row to carry a declaration —
589
693
  * so the SDK declares its slot from the two facts the genre does carry, its
@@ -600,6 +704,7 @@ export const genreIdOf = (g) => {
600
704
  * is the name the reading node's own slot has and the name `slot.prompts({
601
705
  * envoy })` resolves at; the fields are that node's fields.
602
706
  * @internal
707
+ * @ruling R-18 (2)
603
708
  */
604
709
  export function envoyPromptsSlotFor(envoy) {
605
710
  return {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * 🚧 The guarded connection (C7): the ONE judge of the records a remote
2
+ * 🚧 The guarded connection: the ONE judge of the records a remote
3
3
  * component's worker sends, before a Remote DOM receiver applies them. The
4
4
  * page's receiver (the app's `receiverPolicy.ts`, inside `ComponentMount`)
5
5
  * and the component harness (`@serene-pub/cli/testing`) both run it, so what
@@ -38,10 +38,11 @@
38
38
  * is, and what crosses back when a listener fires.
39
39
  *
40
40
  * Remote DOM's types only: the SDK carries no runtime import of the renderer
41
- * (a component never bundles it, R23), so its protocol numbers are held here
41
+ * (a component never bundles it), so its protocol numbers are held here
42
42
  * — the ones `@remote-dom/core` exports, which the SDK's tests pin.
43
43
  *
44
- * @experimental 🚧 provisional with the vocabulary it enforces (C7, R21).
44
+ * @experimental 🚧 provisional with the vocabulary it enforces.
45
+ * @ruling C7, R23, C7, R21
45
46
  */
46
47
  import { type FnHandle } from './componentWire.js';
47
48
  import { type ReceiverAttribute } from './receiverRules.js';
@@ -1,5 +1,5 @@
1
1
  /**
2
- * 🚧 The guarded connection (C7): the ONE judge of the records a remote
2
+ * 🚧 The guarded connection: the ONE judge of the records a remote
3
3
  * component's worker sends, before a Remote DOM receiver applies them. The
4
4
  * page's receiver (the app's `receiverPolicy.ts`, inside `ComponentMount`)
5
5
  * and the component harness (`@serene-pub/cli/testing`) both run it, so what
@@ -38,10 +38,11 @@
38
38
  * is, and what crosses back when a listener fires.
39
39
  *
40
40
  * Remote DOM's types only: the SDK carries no runtime import of the renderer
41
- * (a component never bundles it, R23), so its protocol numbers are held here
41
+ * (a component never bundles it), so its protocol numbers are held here
42
42
  * — the ones `@remote-dom/core` exports, which the SDK's tests pin.
43
43
  *
44
- * @experimental 🚧 provisional with the vocabulary it enforces (C7, R21).
44
+ * @experimental 🚧 provisional with the vocabulary it enforces.
45
+ * @ruling C7, R23, C7, R21
45
46
  */
46
47
  import { isFnHandle } from './componentWire.js';
47
48
  import { SP_HOST_ELEMENTS, hostEventAllowed } from './hostElements.js';
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * What a Handlebars reference can reach, at one point in a template.
3
3
  *
4
- * Typed templates P4. The template checker (`@serene-pub/sdk/template-check`)
4
+ * The template checker (`@serene-pub/sdk/template-check`)
5
5
  * and a host's editor assist both need the same three answers — what `../`
6
6
  * climbs to, what a block param is bound to, and what one `{{#each}}` element
7
7
  * is — and when they were two copies they drifted: the assist treated an
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * What a Handlebars reference can reach, at one point in a template.
3
3
  *
4
- * Typed templates P4. The template checker (`@serene-pub/sdk/template-check`)
4
+ * The template checker (`@serene-pub/sdk/template-check`)
5
5
  * and a host's editor assist both need the same three answers — what `../`
6
6
  * climbs to, what a block param is bound to, and what one `{{#each}}` element
7
7
  * is — and when they were two copies they drifted: the assist treated an
package/dist/hash.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * One canonical form, one digest, one re-declaration rule.
3
3
  *
4
4
  * Two things in the SDK have to answer "is this the same content as that": a
5
- * spec document's `canonicalHash` (02 §3), and every registry here that refuses
5
+ * spec document's `canonicalHash`, and every registry here that refuses
6
6
  * a second declaration under an id it already holds. They must not answer
7
7
  * differently, so the sort and the digest live here once and both call in — a
8
8
  * second hashing scheme is how two places quietly start disagreeing about what
@@ -23,22 +23,32 @@
23
23
  * not gated on `import.meta.hot` or `NODE_ENV`: an identical re-declaration is
24
24
  * harmless everywhere, and an environment check would only hide the case where
25
25
  * it is *not* identical — which is the case the guard exists for.
26
+ * @ruling 02 §3
27
+ */
28
+ /**
29
+ * Canonical form — stable key order, for hashing and round-trip identity.
30
+ * @experimental
31
+ * @ruling F3
26
32
  */
27
- /** Canonical form — stable key order, for hashing and round-trip identity (F3). @experimental */
28
33
  export declare function canonicalize(v: unknown): string;
29
- /** Cheap deterministic content hash — stands in for the real canonical_hash (02 §3). @experimental */
34
+ /**
35
+ * Cheap deterministic content hash — stands in for the real canonical_hash.
36
+ * @experimental
37
+ * @ruling 02 §3
38
+ */
30
39
  export declare function contentHash(v: unknown): string;
31
40
  /**
32
41
  * What this strip is *for*, said once so nobody reads it as the whole rule:
33
42
  * the denylist below is the re-declaration guard of every registry whose
34
43
  * declarations are hashed whole — genres, scripts, engines, wire formats,
35
44
  * events, facets, variables, sheets, attributes. A **node definition** is the
36
- * exception (plans/31 V6, 2026-09-17): its hash is an *allowlist* of its
45
+ * exception (since 2026-09-17): its hash is an *allowlist* of its
37
46
  * contract — `definitionContract` in `descriptors.ts` — and everything else on
38
47
  * a `Descriptor` is policy, never hashed. `provisional`, `reviewDefault`,
39
48
  * `timeoutMs`, `timeoutKind`, `toggleable`, `public` and `usage` are policy,
40
49
  * so flipping one moves no pin; the digest and the canonical form are still
41
50
  * this file's.
51
+ * @ruling plans/31 V6 (2026-09-17)
42
52
  */
43
53
  /**
44
54
  * What a registry knows about its own declarations that this file cannot.
@@ -112,11 +122,12 @@ export declare function declarationMaterial(v: unknown, opts?: DisplayKeys): unk
112
122
  *
113
123
  * The node-definition contract (`definitionContract`) reads its fields
114
124
  * through this. A definition's contract is what a registry row carries so
115
- * core can judge a plugin without executing it (F6), and a row cannot carry
125
+ * core can judge a plugin without executing it, and a row cannot carry
116
126
  * a function — so a function is not contract, and its source text is not
117
127
  * either. No `Descriptor` field is a function today; the rule is here so the
118
128
  * day one is, it is classified rather than digested by accident.
119
129
  * @experimental
130
+ * @ruling F6
120
131
  */
121
132
  export declare function declarationData(v: unknown, opts?: DisplayKeys): unknown;
122
133
  /** The content hash of a declaration — see `declarationMaterial` for what counts. @experimental */
package/dist/hash.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * One canonical form, one digest, one re-declaration rule.
3
3
  *
4
4
  * Two things in the SDK have to answer "is this the same content as that": a
5
- * spec document's `canonicalHash` (02 §3), and every registry here that refuses
5
+ * spec document's `canonicalHash`, and every registry here that refuses
6
6
  * a second declaration under an id it already holds. They must not answer
7
7
  * differently, so the sort and the digest live here once and both call in — a
8
8
  * second hashing scheme is how two places quietly start disagreeing about what
@@ -23,6 +23,7 @@
23
23
  * not gated on `import.meta.hot` or `NODE_ENV`: an identical re-declaration is
24
24
  * harmless everywhere, and an environment check would only hide the case where
25
25
  * it is *not* identical — which is the case the guard exists for.
26
+ * @ruling 02 §3
26
27
  */
27
28
  const sortDeep = (v) => {
28
29
  if (Array.isArray(v))
@@ -34,11 +35,19 @@ const sortDeep = (v) => {
34
35
  }
35
36
  return v;
36
37
  };
37
- /** Canonical form — stable key order, for hashing and round-trip identity (F3). @experimental */
38
+ /**
39
+ * Canonical form — stable key order, for hashing and round-trip identity.
40
+ * @experimental
41
+ * @ruling F3
42
+ */
38
43
  export function canonicalize(v) {
39
44
  return JSON.stringify(sortDeep(v));
40
45
  }
41
- /** Cheap deterministic content hash — stands in for the real canonical_hash (02 §3). @experimental */
46
+ /**
47
+ * Cheap deterministic content hash — stands in for the real canonical_hash.
48
+ * @experimental
49
+ * @ruling 02 §3
50
+ */
42
51
  export function contentHash(v) {
43
52
  const s = canonicalize(v);
44
53
  let h1 = 0xdeadbeef;
@@ -122,11 +131,12 @@ export function declarationMaterial(v, opts) {
122
131
  *
123
132
  * The node-definition contract (`definitionContract`) reads its fields
124
133
  * through this. A definition's contract is what a registry row carries so
125
- * core can judge a plugin without executing it (F6), and a row cannot carry
134
+ * core can judge a plugin without executing it, and a row cannot carry
126
135
  * a function — so a function is not contract, and its source text is not
127
136
  * either. No `Descriptor` field is a function today; the rule is here so the
128
137
  * day one is, it is classified rather than digested by accident.
129
138
  * @experimental
139
+ * @ruling F6
130
140
  */
131
141
  export function declarationData(v, opts) {
132
142
  return stripDisplay(v, displaySet(opts), 'omit');
@@ -1,10 +1,11 @@
1
1
  /**
2
- * The grant table (plans 29 R-3): which members each kind of plugin hook finds
2
+ * The grant table: which members each kind of plugin hook finds
3
3
  * on its `ctx`. The ONE copy — the app's sandboxes derive every call's grants
4
4
  * from it, the boot check reads each kind's keys from it, an author's harness
5
5
  * builds its context from it, and the plugin permissions guide is rendered
6
- * from it (K1c). Nothing else in here, so the runtime can import it without
6
+ * from it. Nothing else in here, so the runtime can import it without
7
7
  * the test harness behind it.
8
+ * @ruling plans 29 R-3, K1c
8
9
  */
9
10
  /**
10
11
  * The kinds of hook the host dispatches — the four node kinds a plugin may
@@ -1,10 +1,11 @@
1
1
  /**
2
- * The grant table (plans 29 R-3): which members each kind of plugin hook finds
2
+ * The grant table: which members each kind of plugin hook finds
3
3
  * on its `ctx`. The ONE copy — the app's sandboxes derive every call's grants
4
4
  * from it, the boot check reads each kind's keys from it, an author's harness
5
5
  * builds its context from it, and the plugin permissions guide is rendered
6
- * from it (K1c). Nothing else in here, so the runtime can import it without
6
+ * from it. Nothing else in here, so the runtime can import it without
7
7
  * the test harness behind it.
8
+ * @ruling plans 29 R-3, K1c
8
9
  */
9
10
  /** @experimental */
10
11
  export const HOOK_CTX_KINDS = [
@@ -19,13 +20,14 @@ export const HOOK_CTX_KINDS = [
19
20
  /**
20
21
  * The table.
21
22
  *
22
- * - **task**, **chain-link** — neither. A task is pure (F11) and a chain link
23
+ * - **task**, **chain-link** — neither. A task is pure and a chain link
23
24
  * is a script: the in-app script host hands one `{ random, log }` and a
24
25
  * plugin's link gets the same.
25
- * - **query**, **outlet**, **event**, **lifecycle** — storage. F32: an
26
+ * - **query**, **outlet**, **event**, **lifecycle** — storage: an
26
27
  * extension's own rows, no network.
27
28
  * - **oracle** — storage and fetch. The one kind that calls out, which is what
28
29
  * `effects: 'external'` names.
30
+ * @ruling F11, F32
29
31
  */
30
32
  const GRANTS = {
31
33
  task: { storage: false, fetch: false },
package/dist/hooks.d.ts CHANGED
@@ -1,15 +1,16 @@
1
1
  /**
2
- * The three kinds of extension callable and their injected surfaces (01 §9, F10, F32).
2
+ * The three kinds of extension callable and their injected surfaces.
3
3
  *
4
- * A **hook** is a declared point where authored code may run (NOMENCLATURE §12); the
5
- * three callables are named for what they are (R-1, ruled 2026-09-14): a **handler**
4
+ * A **hook** is a declared point where authored code may run; the
5
+ * three callables are named for what they are: a **handler**
6
6
  * implements a node definition, a **lifecycle callback** answers a core moment, an
7
- * **event listener** answers a core event. 01's *pipeline hook* / *lifecycle hook* /
8
- * *event hook* are the same three under the old word; the code moved 2026-09-16 (U3).
7
+ * **event listener** answers a core event. The older *pipeline hook* / *lifecycle hook* /
8
+ * *event hook* are the same three under the old word.
9
9
  *
10
10
  * The rules are enforced by *what is in the object*, not by a document someone reads.
11
11
  * A capability that isn't on the surface cannot be called, which is why these are
12
12
  * types rather than a checklist.
13
+ * @ruling 01 §9, F10, F32, NOMENCLATURE §12, R-1 (ruled 2026-09-14), 01, U3 (2026-09-16)
13
14
  */
14
15
  import type { Result } from './executor.js';
15
16
  import type { ExtensionStorage } from './storage.js';
@@ -26,12 +27,13 @@ export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
26
27
  /**
27
28
  * Data in, expected shape out; the executor is the only caller. Private = only the
28
29
  * owning extension's specs may pin it. Public = any spec may, which is how peer
29
- * composition happens — as a node on the spine, never a peer call mid-run (F10).
30
+ * composition happens — as a node on the spine, never a peer call mid-run.
30
31
  *
31
32
  * Both are enumerated in the manifest. Listing private ones costs nothing and the
32
33
  * manifest is already the audit surface, since permissions are compiled from SDK
33
- * usage (13 §7c).
34
+ * usage.
34
35
  * @experimental
36
+ * @ruling F10, 13 §7c
35
37
  */
36
38
  export interface HandlerRules {
37
39
  kind: 'pipeline';
@@ -114,12 +116,13 @@ export interface EventListenerInput<T = unknown> {
114
116
  /** The event that fired, exactly as the subscription pinned it. */
115
117
  event: string;
116
118
  /**
117
- * The occurrence, snapshotted at emit time (11 §3) — a hook never reads live
119
+ * The occurrence, snapshotted at emit time — a hook never reads live
118
120
  * state through this.
119
121
  *
120
122
  * Read-only in the sense that matters: mutating it, or returning something
121
123
  * else in its place, changes nothing for the subscribers after you and
122
124
  * nothing for the action that emitted it. An event states what happened.
125
+ * @ruling 11 §3
123
126
  */
124
127
  payload: T;
125
128
  }
@@ -169,7 +172,7 @@ export interface LifecycleCallbackSurface {
169
172
  * The moments a lifecycle callback may be registered against:
170
173
  *
171
174
  * - `startup` — at boot, before the ready-gate opens.
172
- * - `load` — declared, and not called yet (INTEGRATING.md §5c, Gaps).
175
+ * - `load` — declared, and not called yet.
173
176
  * - `enable` — after the plugin is switched on.
174
177
  * - `disable` — before it is switched off. Bounded; a failure never stops the switch.
175
178
  * - `update` — once, after a reinstall replaced its bundle, on the new bundle's
@@ -230,11 +233,11 @@ export interface LifecycleUpdateInput {
230
233
  * - **You are isolated.** Throwing, overrunning or being stopped costs you
231
234
  * your own call and nothing else: no sibling's result changes, no sibling's
232
235
  * storage rolls back with yours, and the action that caused the event still
233
- * succeeds (01 §9c).
236
+ * succeeds.
234
237
  * - **You cannot rely on order, and you cannot rely on being alone.** Dispatch
235
238
  * order is **declaration order** — the order you wrote your own
236
239
  * subscriptions in, tie-broken across extensions by plugin id — so a bug
237
- * reproduces, but nothing about completion order is promised (11 §3). There
240
+ * reproduces, but nothing about completion order is promised. There
238
241
  * is no `priority` to raise: it would promise a sequencing core declines to
239
242
  * give, and be its own collision the moment two extensions claimed one
240
243
  * number.
@@ -244,8 +247,9 @@ export interface LifecycleUpdateInput {
244
247
  * chain and a pipeline node hook are for.
245
248
  *
246
249
  * Returning `halt(reason)` is the normal way to say "not applicable to me", and
247
- * is a success rather than a failure (11 §3).
250
+ * is a success rather than a failure.
248
251
  * @experimental
252
+ * @ruling 01 §9c, 11 §3
249
253
  */
250
254
  export type EventListener = (input: EventListenerInput, ctx: EventListenerSurface) => Result | Promise<Result>;
251
255
  /**
@@ -267,10 +271,11 @@ export type EventListener = (input: EventListenerInput, ctx: EventListenerSurfac
267
271
  */
268
272
  export type LifecycleCallback = (input: unknown, ctx: LifecycleCallbackSurface) => Result | Promise<Result>;
269
273
  /**
270
- * F32, checked rather than documented. The probe reads the surface an implementation
271
- * actually hands out — a regression that adds `callProvider` back fails here instead
274
+ * The forbidden surface members, checked rather than documented. The probe
275
+ * reads the surface an implementation actually hands out — a regression that adds `callProvider` back fails here instead
272
276
  * of shipping.
273
277
  * @experimental
278
+ * @ruling F32
274
279
  */
275
280
  export declare function assertHookSurface(kind: 'event' | 'lifecycle', surface: object): {
276
281
  ok: true;
@@ -279,9 +284,9 @@ export declare function assertHookSurface(kind: 'event' | 'lifecycle', surface:
279
284
  found: string[];
280
285
  };
281
286
  /**
282
- * The scheduled-work path, stated as code so it is discoverable from the SDK rather
283
- * than only from 13 §7c.
287
+ * The scheduled-work path, stated as code so it is discoverable from the SDK.
284
288
  * @experimental
289
+ * @ruling 13 §7c
285
290
  */
286
291
  export declare const SCHEDULED_WORK_PATH: {
287
292
  readonly instead: 'core:event/schedule-tick@1';