@serene-pub/sdk 0.6.0-pr-8 → 0.6.0-pr-9

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 (62) hide show
  1. package/dist/announce.d.ts +36 -3
  2. package/dist/announce.js +59 -4
  3. package/dist/builder.d.ts +5 -7
  4. package/dist/cadences.d.ts +1 -3
  5. package/dist/componentWire.js +28 -0
  6. package/dist/conditions.d.ts +5 -1
  7. package/dist/conditions.js +7 -0
  8. package/dist/declarations.d.ts +63 -1
  9. package/dist/declarations.js +172 -7
  10. package/dist/descriptors.d.ts +86 -12
  11. package/dist/descriptors.js +83 -5
  12. package/dist/document.d.ts +1 -1
  13. package/dist/events.d.ts +68 -25
  14. package/dist/events.js +35 -2
  15. package/dist/executor.d.ts +27 -0
  16. package/dist/executor.js +6 -3
  17. package/dist/exposure.d.ts +35 -1
  18. package/dist/exposure.js +64 -2
  19. package/dist/extension.d.ts +13 -2
  20. package/dist/extension.js +3 -1
  21. package/dist/genres.d.ts +61 -3
  22. package/dist/genres.js +131 -10
  23. package/dist/hostElements.d.ts +3 -3
  24. package/dist/hostElements.js +12 -4
  25. package/dist/index.d.ts +1 -0
  26. package/dist/index.js +1 -0
  27. package/dist/participants.d.ts +30 -0
  28. package/dist/provisos.d.ts +92 -0
  29. package/dist/provisos.js +273 -0
  30. package/dist/receiverRules.js +1 -1
  31. package/dist/registrations.d.ts +154 -14
  32. package/dist/registrations.js +293 -23
  33. package/dist/repertoires.d.ts +13 -1
  34. package/dist/repertoires.js +5 -1
  35. package/dist/rulesetDocument.d.ts +11 -0
  36. package/dist/rulesetDocument.js +17 -0
  37. package/dist/rulesetSections.d.ts +12 -0
  38. package/dist/rulesetSections.js +8 -0
  39. package/dist/rulesets.js +6 -0
  40. package/dist/sceneSettings.d.ts +3 -1
  41. package/dist/sceneSettings.js +3 -1
  42. package/dist/sessionDossier.d.ts +102 -2
  43. package/dist/sessionSettings.d.ts +18 -0
  44. package/dist/shapes.d.ts +9 -0
  45. package/dist/shapes.js +9 -0
  46. package/dist/speech.d.ts +14 -3
  47. package/dist/storyTime.d.ts +77 -1
  48. package/dist/storyTime.js +111 -4
  49. package/dist/surfaces.d.ts +38 -1
  50. package/dist/surfaces.js +3 -0
  51. package/dist/template.d.ts +13 -1
  52. package/dist/templateCheck.js +175 -12
  53. package/dist/templateFit.js +4 -1
  54. package/dist/validate.js +69 -0
  55. package/dist/variableLayouts.d.ts +19 -0
  56. package/dist/variableLayouts.js +19 -0
  57. package/dist/variables.d.ts +202 -13
  58. package/dist/variables.js +258 -32
  59. package/dist/widgets.d.ts +68 -9
  60. package/dist/widgets.js +10 -2
  61. package/host-elements.d.ts +4 -2
  62. package/package.json +1 -1
@@ -78,10 +78,44 @@ export declare function setting(value: unknown, decide?: {
78
78
  export declare const MODEL_PLUMBING: readonly string[];
79
79
  /** Is this setting model plumbing — by its key, or by sourcing its options from a connection? @experimental */
80
80
  export declare const isModelPlumbing: (key: string, decl?: Pick<FieldDecl, 'from'>) => boolean;
81
+ /**
82
+ * Does this setting key name a context template or a variable layout —
83
+ * `template`, `templates` or `variables` — and not source its options from a
84
+ * connection? Core's settings cascade imports this test, so the two never
85
+ * restate the rule.
86
+ * @experimental
87
+ * @ruling G7
88
+ */
89
+ export declare const isTemplateSetting: (key: string, decl?: Pick<FieldDecl, 'from'>) => boolean;
90
+ /**
91
+ * Every place a schema exposes a context template or a variable template to
92
+ * the owner (`reach: 'owner'`): by the slot's kind when the schema belongs to
93
+ * a `template` or `variables` slot (any field in it, whatever its key), else
94
+ * by the key (`template`, `templates`, `variables`). Templates are an
95
+ * administrator's: the exposure is ignored — the declaration stays, core
96
+ * never shows it — and each is a warning sentence, never a refusal (owner
97
+ * ruling G7, 2026-11-16). Connections, sampling and loadouts are still
98
+ * `exposureFindings`' refusals. `defaultReach` is the reach of a field that
99
+ * states none: pass `'owner'` for a genre's fields.
100
+ * @experimental
101
+ * @ruling G7
102
+ */
103
+ export declare function templateExposureWarnings(schema: Readonly<Record<string, FieldDecl>> | undefined, at?: string, slotKind?: string, defaultReach?: 'admin' | 'owner'): string[];
104
+ /**
105
+ * A ruleset's `options.fields` named like a template setting (`template`,
106
+ * `templates`, `variables`), whatever their reach. A ruleset's option reaches
107
+ * the owner's _Rules options_ and only ever picks a rules convention, so a
108
+ * template-like name is a mistake to rename, never an exposure to hide. One
109
+ * warning sentence per field, never a refusal.
110
+ * @experimental
111
+ * @ruling G7
112
+ */
113
+ export declare function rulesetOptionWarnings(schema: Readonly<Record<string, FieldDecl>> | undefined, at?: string): string[];
81
114
  /**
82
115
  * Every exposure fault in a schema: model plumbing declared `reach: 'owner'`
83
116
  * (never — ruled 10-12), an unknown reach, a `fixedAtStart` that is not
84
- * `true`. As sentences that say what to do instead.
117
+ * `true`. As sentences that say what to do instead. A template or variables
118
+ * exposure is not one: it is `templateExposureWarnings`' (G7).
85
119
  * @experimental
86
120
  * @ruling R1, R32
87
121
  */
package/dist/exposure.js CHANGED
@@ -89,10 +89,72 @@ export const MODEL_PLUMBING = Object.freeze([
89
89
  /** Is this setting model plumbing — by its key, or by sourcing its options from a connection? @experimental */
90
90
  export const isModelPlumbing = (key, decl) => MODEL_PLUMBING.includes(key) ||
91
91
  (typeof decl?.from === 'string' && decl.from.startsWith('connection.'));
92
+ /** The keys that name a context template or a variable layout: ignored with a warning, never refused (G7, 2026-11-16). */
93
+ const TEMPLATE_KEYS = ['template', 'templates', 'variables'];
94
+ const isConnectionSourced = (d) => typeof d?.from === 'string' && d.from.startsWith('connection.');
95
+ /**
96
+ * Does this setting key name a context template or a variable layout —
97
+ * `template`, `templates` or `variables` — and not source its options from a
98
+ * connection? Core's settings cascade imports this test, so the two never
99
+ * restate the rule.
100
+ * @experimental
101
+ * @ruling G7
102
+ */
103
+ export const isTemplateSetting = (key, decl) => TEMPLATE_KEYS.includes(key) && !isConnectionSourced(decl);
104
+ /**
105
+ * Every place a schema exposes a context template or a variable template to
106
+ * the owner (`reach: 'owner'`): by the slot's kind when the schema belongs to
107
+ * a `template` or `variables` slot (any field in it, whatever its key), else
108
+ * by the key (`template`, `templates`, `variables`). Templates are an
109
+ * administrator's: the exposure is ignored — the declaration stays, core
110
+ * never shows it — and each is a warning sentence, never a refusal (owner
111
+ * ruling G7, 2026-11-16). Connections, sampling and loadouts are still
112
+ * `exposureFindings`' refusals. `defaultReach` is the reach of a field that
113
+ * states none: pass `'owner'` for a genre's fields.
114
+ * @experimental
115
+ * @ruling G7
116
+ */
117
+ export function templateExposureWarnings(schema, at = 'fields', slotKind, defaultReach) {
118
+ const out = [];
119
+ const byKind = slotKind === 'template' || slotKind === 'variables';
120
+ for (const [key, d] of Object.entries(schema ?? {})) {
121
+ if (!d || typeof d !== 'object')
122
+ continue;
123
+ if ((d.reach ?? defaultReach) === 'owner' && (byKind || isTemplateSetting(key, d)))
124
+ out.push(`${at}.${key} exposes a context or variable template to the owner (reach: 'owner') — templates are an ` +
125
+ `administrator's, so the exposure was ignored and the setting stays administrator-only; ` +
126
+ (defaultReach === 'owner' ? `say reach: 'admin'` : `drop the reach`));
127
+ if (d.type === 'object' && d.fields)
128
+ out.push(...templateExposureWarnings(d.fields, `${at}.${key}`, slotKind, defaultReach));
129
+ }
130
+ return out;
131
+ }
132
+ /**
133
+ * A ruleset's `options.fields` named like a template setting (`template`,
134
+ * `templates`, `variables`), whatever their reach. A ruleset's option reaches
135
+ * the owner's _Rules options_ and only ever picks a rules convention, so a
136
+ * template-like name is a mistake to rename, never an exposure to hide. One
137
+ * warning sentence per field, never a refusal.
138
+ * @experimental
139
+ * @ruling G7
140
+ */
141
+ export function rulesetOptionWarnings(schema, at = 'options.fields') {
142
+ const out = [];
143
+ for (const [key, d] of Object.entries(schema ?? {})) {
144
+ if (!d || typeof d !== 'object')
145
+ continue;
146
+ if (isTemplateSetting(key, d))
147
+ out.push(`${at}.${key}: named like a template setting; a ruleset's option is a rules choice and never picks a template. Rename it.`);
148
+ if (d.type === 'object' && d.fields)
149
+ out.push(...rulesetOptionWarnings(d.fields, `${at}.${key}`));
150
+ }
151
+ return out;
152
+ }
92
153
  /**
93
154
  * Every exposure fault in a schema: model plumbing declared `reach: 'owner'`
94
155
  * (never — ruled 10-12), an unknown reach, a `fixedAtStart` that is not
95
- * `true`. As sentences that say what to do instead.
156
+ * `true`. As sentences that say what to do instead. A template or variables
157
+ * exposure is not one: it is `templateExposureWarnings`' (G7).
96
158
  * @experimental
97
159
  * @ruling R1, R32
98
160
  */
@@ -103,7 +165,7 @@ export function exposureFindings(schema, at = 'fields') {
103
165
  continue;
104
166
  if (d.reach !== undefined && d.reach !== 'admin' && d.reach !== 'owner')
105
167
  out.push(`${at}.${key}.reach: 'admin' or 'owner' — not ${JSON.stringify(d.reach)}`);
106
- if (d.reach === 'owner' && isModelPlumbing(key, d))
168
+ if (d.reach === 'owner' && isModelPlumbing(key, d) && !isTemplateSetting(key, d))
107
169
  out.push(`${at}.${key} is model plumbing (the connection, sampling, loadout, prompts or templates a step ` +
108
170
  `runs on) and declares reach: 'owner' — plumbing is an administrator's, never a member's; drop the reach`);
109
171
  if (d.fixedAtStart !== undefined && d.fixedAtStart !== true)
@@ -40,7 +40,7 @@ import { type AnnexFieldDecl } from './annexFields.js';
40
40
  import type { SurfacesDecl } from './surfaces.js';
41
41
  import type { RulesetDocument } from './rulesetDocument.js';
42
42
  import { type VariableDecl } from './variables.js';
43
- import { type StoredSwapContribution, type SwapContribution } from './declarations.js';
43
+ import { type StoredSwapContribution, type StoredTurnOrderOption, type SwapContribution, type TurnOrderOptionDecl } from './declarations.js';
44
44
  /**
45
45
  * The **handler** implementing a node definition. Data in, expected shape out; the executor is the only caller.
46
46
  * **Private** (the default) means only this extension's pipelines may use the
@@ -478,6 +478,16 @@ export interface ExtensionDecl {
478
478
  * here; the instance checks exposure and fit at install.
479
479
  */
480
480
  swaps?: SwapContribution[];
481
+ /**
482
+ * Turn order options this plugin adds to genres it names — `{ genre: storyGenre,
483
+ * option: register(coreEvents.turnOrderAsked, natural, { label: 'Natural hand-off' }) }`.
484
+ * Each registers on Turn order asked and never marks `default` (a plugin never
485
+ * changes a genre's default); its pipeline is one of `pipelines`. A genre that is
486
+ * not installed is accepted: the instance offers the option once that genre arrives.
487
+ * @experimental
488
+ * @ruling TQ1, TQ2, TQ4 (owner 2026-11-19)
489
+ */
490
+ turnOrderOptions?: TurnOrderOptionDecl[];
481
491
  /**
482
492
  * What this plugin asks the sandbox for: a storage quota, a network
483
493
  * allowlist. **Declared, because nothing else can compile them** — the
@@ -598,11 +608,12 @@ export interface ExtensionDecl {
598
608
  * down to its id — the shapes the packager writes into the manifest.
599
609
  * @experimental
600
610
  */
601
- export interface Extension extends Omit<ExtensionDecl, 'configs' | 'presets' | 'swaps' | 'events'> {
611
+ export interface Extension extends Omit<ExtensionDecl, 'configs' | 'presets' | 'swaps' | 'turnOrderOptions' | 'events'> {
602
612
  readonly __extension: true;
603
613
  configs?: ConfigDecl[];
604
614
  presets?: PresetDecl[];
605
615
  swaps?: StoredSwapContribution[];
616
+ turnOrderOptions?: StoredTurnOrderOption[];
606
617
  events?: StoredEventDeclaration[];
607
618
  /**
608
619
  * The shapes registered under this package's slug when it was declared
package/dist/extension.js CHANGED
@@ -32,7 +32,7 @@ import { listShapes } from './shapes.js';
32
32
  import { preset, storedConfig, storedEventDeclaration, } from './announce.js';
33
33
  import { annexFieldListFindings } from './annexFields.js';
34
34
  import { getVariable, pluginVariableFindings } from './variables.js';
35
- import { declarationFindings, storedSwap, swapInputFindings, } from './declarations.js';
35
+ import { declarationFindings, storedSwap, storedTurnOrderOption, swapInputFindings, } from './declarations.js';
36
36
  /** @public */
37
37
  export function handler(definition, fn, opts = {}) {
38
38
  const descriptor = ('descriptor' in definition ? definition.descriptor : definition);
@@ -301,6 +301,7 @@ export function defineExtension(d) {
301
301
  components: d.components,
302
302
  widgets: d.widgets,
303
303
  swaps: d.swaps,
304
+ turnOrderOptions: d.turnOrderOptions,
304
305
  events,
305
306
  // Declared nothing is `[]`: every key a pipeline of this package
306
307
  // writes to its own annex must be declared (ruling 2026-09-26).
@@ -318,6 +319,7 @@ export function defineExtension(d) {
318
319
  ...(presets ? { presets } : {}),
319
320
  ...(events ? { events } : {}),
320
321
  ...(d.swaps ? { swaps: d.swaps.map(storedSwap) } : {}),
322
+ ...(d.turnOrderOptions ? { turnOrderOptions: d.turnOrderOptions.map(storedTurnOrderOption) } : {}),
321
323
  ...(shapes.length ? { shapes } : {}),
322
324
  };
323
325
  }
package/dist/genres.d.ts CHANGED
@@ -18,7 +18,7 @@ import type { WidgetDecl } from './layout.js';
18
18
  import { type GenreLayoutDecl } from './widgetDecls.js';
19
19
  import { type I18n, type SessionShape, type SlotDecl } from './descriptors.js';
20
20
  import { type LocaleMap } from './i18n.js';
21
- import type { RegistrationDecl } from './registrations.js';
21
+ import type { RegistrationDecl, RoutineGroupDecl } from './registrations.js';
22
22
  import { type SettingValue } from './exposure.js';
23
23
  import { type GenreUses } from './fit.js';
24
24
  import { type HandbookPage, type Rigour } from './rulesets.js';
@@ -182,8 +182,12 @@ export interface GenreDecl {
182
182
  }[];
183
183
  /** 🚧 Who may sit here (ruled 2026-10-19): `'solo'` — never a group session: the form hides the group switch and the host refuses `isGroup`, invites, guest claims and lanes (the Guide: one person's questions about the app). `'group'` (default) — as the shape allows. */
184
184
  readonly members?: 'solo' | 'group';
185
- /** 🚧 Which time this genre keeps — a story clock (`'story'`: Story, the Lair, the Dungeon Crawler), real time (`'real'`: the Guide, Chat) or neither (`'none'`). `rulesetFit` weighs a ruleset's functions' `countsTime` against it; left out, fit does not weigh time. */
185
+ /** 🚧 Which time this genre keeps — a story clock (`'story'`: Story, the Lair, the Dungeon Crawler), real time (`'real'`: the Guide, Chat) or neither (`'none'`). `rulesetFit` weighs a ruleset's functions' `countsTime` against it; left out, fit does not weigh time. It no longer picks a new session's notes' timeline (since 2026-11-16 the default is none; see `timeline`). */
186
186
  readonly keepsTime?: 'story' | 'real' | 'none';
187
+ /**
188
+ * 🚧 This genre's **timeline mandate**: it requires its sessions' new lorebooks to start with a timeline, so no preset may declare `defaults.timeline: false`. Only `'required'` exists (the vocabulary `uses.dice` has). Without it a new session's own notes start with no timeline (owner 2026-11-16: "If the genre/preset supports undated, use undated by default", Story included), whatever `keepsTime` says; a preset's `defaults.timeline` boolean may start one. Needs `keepsTime: 'story'`. Not a lock on a session — a session on an undated lorebook still plays ("genres expect, never lock") — and not `keepsTime`. Absent when unstated.
189
+ */
190
+ readonly timeline?: 'required';
187
191
  /**
188
192
  * 🚧 What this genre **plays best with** (PLAN-genre-restructure §11; RF fix 8, owner ruling
189
193
  * 2026-10-23: "genres expect, never lock"): the verbs its scripts emit (or `'any'`), and the
@@ -258,6 +262,16 @@ export interface GenreDecl {
258
262
  };
259
263
  readonly pipeline: string;
260
264
  }[];
265
+ /**
266
+ * 🚧 The routine groups the genre's routines share — one cadence, one run limit each. Read
267
+ * typed with `genreDefaultsOf`.
268
+ */
269
+ readonly groups?: readonly {
270
+ readonly key: string;
271
+ readonly cadence: {
272
+ readonly id: string;
273
+ };
274
+ }[];
261
275
  readonly settings?: Readonly<Record<string, unknown>>;
262
276
  };
263
277
  /**
@@ -368,6 +382,8 @@ export interface GenreDecl {
368
382
  * story and which are asides is the SPEC's business (its source step's
369
383
  * params), not the genre's. Absent when unstated, so a genre that says
370
384
  * nothing hashes as it did.
385
+ *
386
+ * ⏳ Read for one more release (CP6), then retired: register the pipeline on the summarize-scene action instead.
371
387
  */
372
388
  /**
373
389
  * 🚧 The **rigour** this genre's sessions run rulesets at — the options a
@@ -427,6 +443,8 @@ export interface GenreProps {
427
443
  members?: 'solo' | 'group';
428
444
  /** 🚧 Which time the genre keeps — see `GenreDecl.keepsTime`. */
429
445
  keepsTime?: 'story' | 'real' | 'none';
446
+ /** 🚧 The genre requires new sessions' own notes to start with a timeline (the timeline mandate); without it they start none — see `GenreDecl.timeline`. */
447
+ timeline?: 'required';
430
448
  /** 🚧 What the genre uses of a ruleset — see `GenreDecl.uses`. */
431
449
  uses?: GenreUses;
432
450
  /** 🚧 The genre's defaults — its registrations and setting values; see `GenreDecl.defaults`. */
@@ -452,7 +470,10 @@ export interface GenreProps {
452
470
  omitWidgets?: readonly WidgetDecl[];
453
471
  /** The layouts this genre ships (`layout()`); the first is its default. */
454
472
  layouts?: readonly GenreLayoutDecl[];
455
- /** 🚧 The summarize pipelines this genre owns, by spec id — see `GenreDecl.summarize`. */
473
+ /**
474
+ * 🚧 The summarize pipelines this genre owns, by spec id — see `GenreDecl.summarize`.
475
+ * ⏳ Read for one more release (CP6), then retired: register the pipeline on the summarize-scene action instead.
476
+ */
456
477
  summarize?: {
457
478
  scene?: string;
458
479
  };
@@ -665,6 +686,41 @@ export declare const CONVERSATION_WIDGET_ID = "messages";
665
686
  * @experimental
666
687
  */
667
688
  export declare function genreSummarizeFindings(raw: unknown, at?: string): string[];
689
+ /**
690
+ * A genre's warnings, never refusals: its template exposures, and stated
691
+ * defaults that register no turn order option.
692
+ *
693
+ * Every template exposure in a genre's `shape.fields`. A genre field's reach
694
+ * defaults to `'owner'`, so its `template`, `templates` or `variables` field
695
+ * reaches the session's owner with or without an explicit reach: it warns
696
+ * either way. The field stays in the declaration (hashes do not move) and
697
+ * core shows it to administrators only. A genre whose stated defaults register
698
+ * nothing on `turn-order-asked` is warned, never refused. A shape that still
699
+ * carries `turnSeatChanges` is warned: the key has no effect. A default
700
+ * registration whose `when` reads `session.rounds.<name>` for a name that is
701
+ * not one of the genre's story channels is warned, never refused: it reads as
702
+ * absent, so the condition is false. A field or setting spelled like a rule core
703
+ * enforces that `shape.provisos` does not name is warned, never refused.
704
+ * @experimental
705
+ * @ruling G7, programme 2.3
706
+ */
707
+ export declare function genreWarnings(decl: Pick<GenreDecl, 'id' | 'shape' | 'settings'> & {
708
+ readonly defaults?: GenreDecl['defaults'];
709
+ readonly summarize?: GenreDecl['summarize'];
710
+ }): string[];
711
+ /**
712
+ * What a genre leaves unsaid about Auto-advance. A genre that declares no
713
+ * `autoAdvance` field offers no switch, so nothing starts by itself in its
714
+ * sessions; one that declares it and says nothing of `autoAdvanceRuns` (a field,
715
+ * a pinned setting, or a default setting) never fires. Both are told to the
716
+ * modder here and to the session's owner on the Turn line. A warning, never a
717
+ * refusal: a genre expects, it never locks.
718
+ * @experimental
719
+ * @ruling TA1 (owner 2026-11-19)
720
+ */
721
+ export declare function autoAdvanceWarnings(decl: Pick<GenreDecl, 'id' | 'shape' | 'settings'> & {
722
+ readonly defaults?: GenreDecl['defaults'];
723
+ }): string[];
668
724
  /**
669
725
  * Declare a genre. The id is stated in full, under your plugin's slug
670
726
  * (`acme.dice:genre/table`), and the genre value is what everything else
@@ -700,6 +756,8 @@ export declare function genre<const P extends GenreProps>(id: string, props: P):
700
756
  */
701
757
  export interface GenreDefaults {
702
758
  readonly registrations: readonly RegistrationDecl[];
759
+ /** 🚧 The genre's routine groups; its default preset presents them unchanged (RG1). */
760
+ readonly groups?: readonly RoutineGroupDecl[];
703
761
  readonly settings?: Readonly<Record<string, SettingValue>>;
704
762
  }
705
763
  /** The genre's defaults, typed — `GenreDecl.defaults` read back as what was declared. @experimental */
package/dist/genres.js CHANGED
@@ -1,18 +1,19 @@
1
1
  import { widgetRef } from './widgetDecls.js';
2
2
  import { drawnWidgetIds, layoutWidgetIds, resolveWidgetAlias } from './sessionLayout.js';
3
- import { assertChannelDecls, assertMessageVerbFloors, assertSessionWrites, assertTurnControls, SESSION_CREATION_MODES, channelDecls, lorebookReadOptional, lorebookShapeFindings, widgetDeclsFindings, } from './descriptors.js';
3
+ import { assertChannelDecls, assertMessageVerbFloors, assertSessionWrites, assertTurnControls, SESSION_CREATION_MODES, channelDecls, channelLoreRole, lorebookReadOptional, lorebookShapeFindings, widgetDeclsFindings, } from './descriptors.js';
4
4
  import { assertSceneSettings, declaredScenePlace } from './sceneSettings.js';
5
+ import { assertProvisos, provisoWarnings } from './provisos.js';
5
6
  import { storyCalendarProblems } from './storyTime.js';
6
7
  import { i18nFindings, localeMapOf } from './i18n.js';
7
- import { eventById, notADeclaredEvent } from './events.js';
8
+ import { CORE_EVENTS, eventById, eventIdOf, notADeclaredEvent } from './events.js';
8
9
  import { settingsSchemaFindings } from './settings.js';
9
- import { exposureFindings } from './exposure.js';
10
+ import { exposureFindings, templateExposureWarnings } from './exposure.js';
10
11
  import { genreUsesFindings } from './fit.js';
11
12
  import { _withdrawHostStateOf, declareHostState, HOST_PLACE_KEY } from './hostState.js';
12
13
  import { refuseUnlessIdentical } from './hash.js';
13
14
  import { getRuleset, handbookFindings, isRulesetTemplateId, RIGOURS } from './rulesets.js';
14
15
  import { finding, RULESET_ID_PATTERN, RulesetError } from './repertoires.js';
15
- import { isActionIdentity, parseSpecId, assertSpecId } from './identity.js';
16
+ import { isActionIdentity, parseActionIdentity, parseSpecId, assertSpecId } from './identity.js';
16
17
  import { enabledWhenFindings, normalizeEnabledWhen, } from './predicates.js';
17
18
  /** `owner:genre/name` — lowercase, digits, hyphens, dots in the owner. */
18
19
  const GENRE_ID = /^[a-z0-9]+(?:[.-][a-z0-9]+)*:genre\/[a-z0-9]+(?:-[a-z0-9]+)*$/;
@@ -546,6 +547,111 @@ function assertScenePlaceDeclared(props, id) {
546
547
  if (place.stateKey !== HOST_PLACE_KEY)
547
548
  throw new Error(`${id}.scenes.place.stateKey: '${place.stateKey}' is not a place the host keeps — the place is '${HOST_PLACE_KEY}', the host's own (a genre declares no slots)`);
548
549
  }
550
+ /**
551
+ * A genre's warnings, never refusals: its template exposures, and stated
552
+ * defaults that register no turn order option.
553
+ *
554
+ * Every template exposure in a genre's `shape.fields`. A genre field's reach
555
+ * defaults to `'owner'`, so its `template`, `templates` or `variables` field
556
+ * reaches the session's owner with or without an explicit reach: it warns
557
+ * either way. The field stays in the declaration (hashes do not move) and
558
+ * core shows it to administrators only. A genre whose stated defaults register
559
+ * nothing on `turn-order-asked` is warned, never refused. A shape that still
560
+ * carries `turnSeatChanges` is warned: the key has no effect. A default
561
+ * registration whose `when` reads `session.rounds.<name>` for a name that is
562
+ * not one of the genre's story channels is warned, never refused: it reads as
563
+ * absent, so the condition is false. A field or setting spelled like a rule core
564
+ * enforces that `shape.provisos` does not name is warned, never refused.
565
+ * @experimental
566
+ * @ruling G7, programme 2.3
567
+ */
568
+ export function genreWarnings(decl) {
569
+ const out = templateExposureWarnings(decl.shape?.fields, `${decl.id}.shape.fields`, undefined, 'owner');
570
+ out.push(...autoAdvanceWarnings(decl));
571
+ if (decl.shape && Object.prototype.hasOwnProperty.call(decl.shape, 'turnSeatChanges'))
572
+ out.push(`genre '${decl.id}': \`turnSeatChanges\` has no effect and can be removed.`);
573
+ if (decl.defaults !== undefined) {
574
+ const asked = eventIdOf(CORE_EVENTS.turnOrderAsked);
575
+ const registers = (genreDefaultsOf(decl)?.registrations ?? []).some((r) => r.trigger.family === 'event' && r.trigger.event === asked);
576
+ if (!registers)
577
+ out.push(`${decl.id}.defaults registers nothing on Turn order asked ('${asked}'); its turn order runs on per-event registrations, which core retires — register one: register(coreEvents.turnOrderAsked, …, { default: true })`);
578
+ }
579
+ out.push(...roundsReadWarnings(decl));
580
+ out.push(...summarizeSceneWarnings(decl));
581
+ out.push(...provisoWarnings(decl));
582
+ return out;
583
+ }
584
+ /** A genre that declares `summarize.scene` and registers nothing on the summarize-scene action. */
585
+ function summarizeSceneWarnings(decl) {
586
+ const scene = decl.summarize?.scene;
587
+ if (typeof scene !== 'string' || scene === '')
588
+ return [];
589
+ const registers = (genreDefaultsOf(decl)?.registrations ?? []).some((r) => r.trigger.family === 'action' && parseActionIdentity(r.trigger.action)?.key === 'summarize-scene');
590
+ if (registers)
591
+ return [];
592
+ return [
593
+ `genre '${decl.id}': summarize.scene is read for one more release, then retired — register your pipeline on the summarize-scene action instead.`,
594
+ ];
595
+ }
596
+ /** `session.rounds.<name>` paths a condition reads, walking `on` / `all` / `any` / `not`. */
597
+ function roundsPathsOf(c) {
598
+ if (!c || typeof c !== 'object')
599
+ return [];
600
+ const o = c;
601
+ if (typeof o.on === 'string')
602
+ return [o.on];
603
+ const kids = Array.isArray(o.all) ? o.all : Array.isArray(o.any) ? o.any : o.not !== undefined ? [o.not] : [];
604
+ return kids.flatMap(roundsPathsOf);
605
+ }
606
+ /** A default registration that reads the round of a channel that is not a story channel of the genre. */
607
+ function roundsReadWarnings(decl) {
608
+ if (decl.defaults === undefined)
609
+ return [];
610
+ const story = channelDecls(decl.shape)
611
+ .map((c) => c.slug)
612
+ .filter((slug) => channelLoreRole(decl.shape, slug) === 'story');
613
+ if (!story.includes('main'))
614
+ story.unshift('main');
615
+ const out = [];
616
+ for (const r of genreDefaultsOf(decl)?.registrations ?? []) {
617
+ const names = new Set();
618
+ for (const path of roundsPathsOf(r.when)) {
619
+ if (!path.startsWith('session.rounds.'))
620
+ continue;
621
+ const name = path.slice('session.rounds.'.length);
622
+ if (!story.includes(name))
623
+ names.add(name);
624
+ }
625
+ for (const name of names)
626
+ out.push(`genre '${decl.id}': registration '${r.key}' reads the round of '${name}', which is not one of this genre's story channels (${story.join(', ')}) — it reads as absent, so the condition is false. Name a story channel, or declare '${name}' with lore: 'story'.`);
627
+ }
628
+ return out;
629
+ }
630
+ /**
631
+ * What a genre leaves unsaid about Auto-advance. A genre that declares no
632
+ * `autoAdvance` field offers no switch, so nothing starts by itself in its
633
+ * sessions; one that declares it and says nothing of `autoAdvanceRuns` (a field,
634
+ * a pinned setting, or a default setting) never fires. Both are told to the
635
+ * modder here and to the session's owner on the Turn line. A warning, never a
636
+ * refusal: a genre expects, it never locks.
637
+ * @experimental
638
+ * @ruling TA1 (owner 2026-11-19)
639
+ */
640
+ export function autoAdvanceWarnings(decl) {
641
+ const fields = (decl.shape?.fields ?? {});
642
+ if (!('autoAdvance' in fields))
643
+ return [
644
+ `genre '${decl.id}': This genre declares no Auto-advance, so nothing starts by itself in its sessions; the session's owner is told so on the Turn line. Declare the field to offer the switch.`,
645
+ ];
646
+ const says = 'autoAdvanceRuns' in fields ||
647
+ 'autoAdvanceRuns' in (decl.settings ?? {}) ||
648
+ 'autoAdvanceRuns' in (genreDefaultsOf(decl)?.settings ?? {});
649
+ return says
650
+ ? []
651
+ : [
652
+ `genre '${decl.id}': This genre declares Auto-advance and says nothing of how far it runs, so it never fires; the session's owner is told so on the Turn line. Pin autoAdvanceRuns in the genre's settings, or declare it as a field to offer the choice.`,
653
+ ];
654
+ }
549
655
  /**
550
656
  * Declare a genre. The id is stated in full, under your plugin's slug
551
657
  * (`acme.dice:genre/table`), and the genre value is what everything else
@@ -563,6 +669,7 @@ export function genre(id, props) {
563
669
  // degrade at the write site where nobody is reading.
564
670
  assertSessionWrites(props.shape, id);
565
671
  assertTurnControls(props.shape, id);
672
+ assertProvisos(props.shape, props.settings, id);
566
673
  assertChannelDecls(props.shape, id);
567
674
  {
568
675
  const proposed = props.shape?.creationMode;
@@ -622,9 +729,6 @@ export function genre(id, props) {
622
729
  if (seats === undefined || seats.max === 0)
623
730
  throw new Error(`${at} needs character seats: shape.characters is ${seats === undefined ? 'absent' : 'max: 0'}, so every seat would be refused. Declare characters with room for the cast or drop castFromLorebook.`);
624
731
  }
625
- // 🚧 Seat changes on each turn (owner 2026-11-09): a boolean opt-in, refused otherwise.
626
- if (props.shape?.turnSeatChanges !== undefined && typeof props.shape.turnSeatChanges !== 'boolean')
627
- throw new Error(`${id}.shape.turnSeatChanges must be true or false. Declare turnSeatChanges: true for turn-ended to carry the seats that changed, or leave it out.`);
628
732
  assertScenePlaceDeclared(props, id);
629
733
  const events = { ...(props.events ?? {}) };
630
734
  // The turn-order write's own event is core-internal (PLAN-turn-order
@@ -682,6 +786,10 @@ export function genre(id, props) {
682
786
  throw new Error(`${id}.members: 'solo' or 'group' — not ${JSON.stringify(props.members)}`);
683
787
  if (props.keepsTime !== undefined && props.keepsTime !== 'story' && props.keepsTime !== 'real' && props.keepsTime !== 'none')
684
788
  throw new Error(`${id}.keepsTime: 'story', 'real' or 'none' — not ${JSON.stringify(props.keepsTime)}`);
789
+ if (props.timeline !== undefined && props.timeline !== 'required')
790
+ throw new Error(`${id}.timeline: 'required', or leave it out — not ${JSON.stringify(props.timeline)}`);
791
+ if (props.timeline === 'required' && props.keepsTime !== 'story')
792
+ throw new Error(`${id}.timeline: 'required' needs keepsTime: 'story' — a genre that requires a timeline keeps story time (keepsTime is ${props.keepsTime === undefined ? 'left out' : JSON.stringify(props.keepsTime)})`);
685
793
  const usesFound = genreUsesFindings(props.uses, `${id}.uses`);
686
794
  if (usesFound.length)
687
795
  throw new Error(usesFound.join('\n'));
@@ -707,6 +815,8 @@ export function genre(id, props) {
707
815
  ...(props.members === 'solo' ? { members: 'solo' } : {}),
708
816
  // 🚧 absent when unstated, so a genre that says nothing hashes as it did.
709
817
  ...(props.keepsTime !== undefined ? { keepsTime: props.keepsTime } : {}),
818
+ // 🚧 absent when unstated, so a genre that says nothing hashes as it did.
819
+ ...(props.timeline === 'required' ? { timeline: 'required' } : {}),
710
820
  ...(props.uses ? { uses: Object.freeze(JSON.parse(JSON.stringify(props.uses))) } : {}),
711
821
  // PLAN-layering D4: absent when unstated, so a genre that says nothing hashes as it did.
712
822
  ...(props.defaults ? { defaults: freezeGenreDefaults(props.defaults) } : {}),
@@ -769,7 +879,7 @@ export function genreDefaultsShapeFindings(raw, at = 'defaults') {
769
879
  return [];
770
880
  const out = [];
771
881
  if (!raw || typeof raw !== 'object' || Array.isArray(raw))
772
- return [`${at}: the genre's defaults are { registrations: [ … ], settings? } — got ${Array.isArray(raw) ? 'a list' : typeof raw}`];
882
+ return [`${at}: the genre's defaults are { registrations: [ … ], groups?, settings? } — got ${Array.isArray(raw) ? 'a list' : typeof raw}`];
773
883
  const d = raw;
774
884
  if (!Array.isArray(d.registrations))
775
885
  out.push(`${at}.registrations: a list of registrations — register(trigger, pipeline, { … })`);
@@ -779,11 +889,21 @@ export function genreDefaultsShapeFindings(raw, at = 'defaults') {
779
889
  if (!reg || typeof reg !== 'object' || typeof reg.key !== 'string' || !reg.trigger || typeof reg.trigger.family !== 'string' || typeof reg.pipeline !== 'string')
780
890
  out.push(`${at}.registrations[${i}]: not a registration — make each with register(trigger, pipeline, { … })`);
781
891
  });
892
+ if (d.groups !== undefined) {
893
+ if (!Array.isArray(d.groups))
894
+ out.push(`${at}.groups: a list of routine groups — routineGroup(cadence, { key })`);
895
+ else
896
+ d.groups.forEach((g, i) => {
897
+ const grp = g;
898
+ if (!grp || typeof grp !== 'object' || typeof grp.key !== 'string' || !grp.cadence || typeof grp.cadence.id !== 'string')
899
+ out.push(`${at}.groups[${i}]: not a routine group — make each with routineGroup(cadence, { key })`);
900
+ });
901
+ }
782
902
  if (d.settings !== undefined && (!d.settings || typeof d.settings !== 'object' || Array.isArray(d.settings)))
783
903
  out.push(`${at}.settings: a map of setting key → value (or { value, lock?, askAtStart? })`);
784
904
  for (const k of Object.keys(d))
785
- if (k !== 'registrations' && k !== 'settings')
786
- out.push(`${at}.${k} is not part of the genre's defaults — registrations and settings; the default preset ` +
905
+ if (k !== 'registrations' && k !== 'groups' && k !== 'settings')
906
+ out.push(`${at}.${k} is not part of the genre's defaults — registrations, groups and settings; the default preset ` +
787
907
  `says so itself (preset({ …, default: true }))`);
788
908
  return out;
789
909
  }
@@ -791,6 +911,7 @@ const freezeGenreDefaults = (d) => Object.freeze({
791
911
  // The registrations themselves, not copies: the registration door
792
912
  // recognises what `register()` handed out (a string reference warns, R30).
793
913
  registrations: Object.freeze([...d.registrations]),
914
+ ...(d.groups && d.groups.length ? { groups: Object.freeze([...d.groups]) } : {}),
794
915
  ...(d.settings && Object.keys(d.settings).length ? { settings: Object.freeze({ ...d.settings }) } : {}),
795
916
  });
796
917
  /**
@@ -215,10 +215,10 @@ export declare const SP_HOST_ELEMENTS: {
215
215
  readonly doc: 'A host-owned slider. `input` (while dragging) and `change` (on release) carry `{ value }`.';
216
216
  };
217
217
  readonly 'sp-combobox': {
218
- readonly attributes: readonly ["value", "placeholder", "disabled", "label", "class"];
218
+ readonly attributes: readonly ["value", "placeholder", "disabled", "label", "trigger-label", "class"];
219
219
  readonly events: readonly ["input", "change"];
220
220
  readonly children: readonly ["sp-option"];
221
- readonly doc: 'A host-owned searchable select. `input` carries `{ query }` as the person types; `change` carries `{ value }`.';
221
+ readonly doc: 'A host-owned searchable select. `input` carries `{ query }` as the person types; `change` carries `{ value }`. `trigger-label` names the button that opens the list for a screen reader (absent: "Show options for ‹label›" when `label` is set).';
222
222
  };
223
223
  readonly 'sp-option': {
224
224
  readonly attributes: readonly ["value", "disabled", "class"];
@@ -473,5 +473,5 @@ export declare function hostElementsDts(): string;
473
473
  * the suite says which to bump. `doc` strings are not the shape.
474
474
  * @ruling F1, R22
475
475
  */
476
- export declare const HOST_ELEMENTS_VERSION: '1.8';
476
+ export declare const HOST_ELEMENTS_VERSION: '1.10';
477
477
  //# sourceMappingURL=hostElements.d.ts.map
@@ -138,7 +138,9 @@ export const SP_HOST_ELEMENTS = {
138
138
  '🚧 `playing` (1.8; heading audio control 2026-10-29; core\'s alone) — present, the page plays it; absent after present, the page pauses it. ' +
139
139
  'An element that lands without it is left alone, so `autoplay` still plays. A play the browser refuses is answered with a `pause` event. ' +
140
140
  'The page plays one sound at a time: another player starting pauses this one, and its `pause` arrives. ' +
141
- 'The element\'s own `play` / `pause` / `ended` events stay the truth; to start over, draw a fresh element.', [...ARIA, 'src', 'controls', 'preload', 'autoplay', 'playing'], ['error', 'play', 'pause', 'ended', 'timeupdate', 'loadedmetadata']),
141
+ 'The element\'s own `play` / `pause` / `ended` events stay the truth; to start over, draw a fresh element. ' +
142
+ '🚧 `playlist` (1.10, spoken audio as an ordered list of files) — space-separated app media URLs, each judged as `src`; with it the PAGE owns `src`: it plays the files in order on the same element, moving to the next in its own `ended` handler, skipping one that fails to load, and putting the first back after the last. ' +
143
+ 'On a playlist element the events\' detail adds `playlistIndex` (0-based) and `playlistLength`, and `pause` · `ended` · `timeupdate` · `loadedmetadata` of a move between files are not delivered, so `ended` arrives once, after the last file; `error` carries `{ playlistIndex, playlistLength }` for the file that failed.', [...ARIA, 'src', 'controls', 'preload', 'autoplay', 'playing', 'playlist'], ['error', 'play', 'pause', 'ended', 'timeupdate', 'loadedmetadata']),
142
144
  video: plain('🚧 A moving-picture player (1.3, O11) — `audio`\'s rules, and a `track` of captions inside it.', [...ARIA, 'src', 'controls', 'preload', 'width', 'height'], ['error']),
143
145
  track: plain("🚧 A video's timed text (1.3, O11): `kind` is `captions` · `subtitles` · `descriptions` · `chapters`; `src`, when given, the app's media.", ['kind', 'src', 'srclang', 'label', 'default']),
144
146
  // ── host sp elements ────────────────────────────────────────────────────────
@@ -238,10 +240,10 @@ export const SP_HOST_ELEMENTS = {
238
240
  doc: 'A host-owned slider. `input` (while dragging) and `change` (on release) carry `{ value }`.',
239
241
  },
240
242
  'sp-combobox': {
241
- attributes: ['value', 'placeholder', 'disabled', 'label', 'class'],
243
+ attributes: ['value', 'placeholder', 'disabled', 'label', 'trigger-label', 'class'],
242
244
  events: ['input', 'change'],
243
245
  children: ['sp-option'],
244
- doc: 'A host-owned searchable select. `input` carries `{ query }` as the person types; `change` carries `{ value }`.',
246
+ doc: 'A host-owned searchable select. `input` carries `{ query }` as the person types; `change` carries `{ value }`. `trigger-label` names the button that opens the list for a screen reader (absent: "Show options for ‹label›" when `label` is set).',
245
247
  },
246
248
  'sp-option': {
247
249
  attributes: ['value', 'disabled', 'class'],
@@ -535,6 +537,12 @@ export function hostAttributeValueFinding(tag, attribute, value) {
535
537
  return v === 'async' || v === 'sync' || v === 'auto' ? undefined : `img decoding '${value}' — async, sync or auto`;
536
538
  if ((t === 'audio' || t === 'video') && attribute === 'preload')
537
539
  return v === 'none' || v === 'metadata' || v === 'auto' ? undefined : `${t} preload '${value}' — none, metadata or auto`;
540
+ if (t === 'audio' && attribute === 'playlist') {
541
+ const bad = v.split(/\s+/).find((token) => token && !isAppMedia(token));
542
+ if (!v)
543
+ return `audio playlist '${value}' — the app's media only, space-separated`;
544
+ return bad === undefined ? undefined : `audio playlist '${bad}' — the app's media only, space-separated`;
545
+ }
538
546
  if (t === 'track' && attribute === 'kind')
539
547
  return ['captions', 'subtitles', 'descriptions', 'chapters'].includes(v)
540
548
  ? undefined
@@ -749,5 +757,5 @@ export function hostElementsDts() {
749
757
  * the suite says which to bump. `doc` strings are not the shape.
750
758
  * @ruling F1, R22
751
759
  */
752
- export const HOST_ELEMENTS_VERSION = '1.8';
760
+ export const HOST_ELEMENTS_VERSION = '1.10';
753
761
  //# sourceMappingURL=hostElements.js.map
package/dist/index.d.ts CHANGED
@@ -43,6 +43,7 @@ export * from './rulesetDocument.js';
43
43
  export * from './rulesetTemplates.js';
44
44
  export * from './rulesetSections.js';
45
45
  export * from './sheetLatitude.js';
46
+ export * from './provisos.js';
46
47
  export * from './functions.js';
47
48
  export * from './ties.js';
48
49
  export * from './jsonSchema.js';
package/dist/index.js CHANGED
@@ -90,6 +90,7 @@ export * from './rulesetTemplates.js';
90
90
  export * from './rulesetSections.js';
91
91
  // 🚧 Sheet latitude — how far each role may change sheets and move items by hand, and the one judge (2026-11-05).
92
92
  export * from './sheetLatitude.js';
93
+ export * from './provisos.js';
93
94
  export * from './functions.js';
94
95
  export * from './ties.js';
95
96
  // 🚧 A declared shape as the JSON Schema a model answers against, and the one