@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
@@ -9,6 +9,7 @@
9
9
  */
10
10
  import type { EntityKind } from './entities.js';
11
11
  import type { Finding } from './validate.js';
12
+ import type { GenreProvisos } from './provisos.js';
12
13
  import type { ShapeId } from './shapes.js';
13
14
  import type { CapabilityId } from './capabilities.js';
14
15
  import type { ReviewPosition } from './review.js';
@@ -769,15 +770,6 @@ export interface SessionShape {
769
770
  castFromLorebook?: {
770
771
  field?: string;
771
772
  };
772
- /**
773
- * ๐Ÿšง **Seat changes on each turn** (owner 2026-11-09, "Yes, a read genres opt into"): `true`
774
- * puts `turnSeatChanges` (`TurnSeatChange[]`) on `turn-ended` and on a routine's `cause` โ€” the
775
- * seats added, removed or changed since the previous turn of that lane. Absent = off in core
776
- * (P1): the payload carries nothing. A pass over them is an ordinary registration, e.g.
777
- * `register(afterEachTurn(), pass, { allowStacking: true })`.
778
- * @experimental
779
- */
780
- turnSeatChanges?: boolean;
781
773
  /** What the send surface is. `none` for purely trigger-driven modes. */
782
774
  composer?: 'text' | 'none';
783
775
  /** Whose name the seed line carries (16's seedName rule, declared). */
@@ -790,8 +782,8 @@ export interface SessionShape {
790
782
  fields?: SettingsSchema;
791
783
  /**
792
784
  * Does the session settings form offer a **Scenario** field? Declared,
793
- * never assumed: core's chat, adventure and lair say
794
- * `true`; guide says `false`. Absent = no field.
785
+ * never assumed: core's Chat, Story and the Lair say
786
+ * `true`; Dungeon Crawler and the Guide say `false`. Absent = no field.
795
787
  * @ruling ยง4.11, R12
796
788
  */
797
789
  scenario?: boolean;
@@ -879,6 +871,15 @@ export interface SessionShape {
879
871
  narrate?: TurnControlDecl;
880
872
  retake?: TurnControlDecl;
881
873
  };
874
+ /**
875
+ * ๐Ÿšง Which of the genre's own fields (or pinned settings) carries each rule core
876
+ * enforces: keeping every turn, sheet latitude, item-move latitude, the tool kinds.
877
+ * A genre that names none of a rule has none of it. Absent = โณ core reads each rule
878
+ * under its core spelling (`keepEveryTurn`, `ownerSheetLatitude`, โ€ฆ) from whatever the
879
+ * session's cascade carries there. Validated at `genre()`; read with `provisoFieldOf`.
880
+ * @experimental
881
+ */
882
+ provisos?: GenreProvisos;
882
883
  /**
883
884
  * What sessions of this genre may write beyond messages.
884
885
  * Absent = both on โ€” the standard chat's posture. Enforced server-side at
@@ -936,7 +937,10 @@ export interface SessionShape {
936
937
  * which a session may override (`resolveSceneSettings`). Absent is
937
938
  * `DEFAULT_SCENE_SETTINGS`: **Suggested**, with *day crossed*, *time
938
939
  * action* and *place changed* on, summaries **on request**. Refused at
939
- * the declaration when it does not read (`assertSceneSettings`). A genre
940
+ * the declaration when it does not read (`assertSceneSettings`). A session
941
+ * running the *Summarize finished scenes* routine
942
+ * (`core:spec/scene-summaries`) reads `onRequest` whatever is declared or
943
+ * stored. A genre
940
944
  * whose `writes.scenes` is `false` places nothing, whatever this says.
941
945
  * @ruling PROPOSAL-live-scenes ยง4, ยง5, โ˜…1 (2026-10-13)
942
946
  */
@@ -1137,6 +1141,14 @@ export interface ChannelDecl {
1137
1141
  * Read it with `channelLoreRole`. โš  Not `role` (how the channel enters a prompt).
1138
1142
  */
1139
1143
  lore?: ChannelLoreRole;
1144
+ /**
1145
+ * ๐Ÿšง This channel is the session's **table channel**: the voiceless folio its rules'
1146
+ * outcomes are written to (rolls, checks, totals) and where the host writes a widget's
1147
+ * `say` line. One per shape, declared `voice: 'none'` โ€” refused otherwise
1148
+ * (`assertChannelDecls`). Read it with `tableChannelOf`. โš  Not a database table.
1149
+ * @experimental
1150
+ */
1151
+ table?: true;
1140
1152
  }
1141
1153
  /** ๐Ÿšง What a channel's lines are to a summary (pass 9 S1). @experimental */
1142
1154
  export declare const CHANNEL_LORE_ROLES: readonly ['story', 'aside', 'never'];
@@ -1169,6 +1181,31 @@ export type ChannelRole = (typeof CHANNEL_ROLES)[number];
1169
1181
  export declare const CHANNEL_VOICES: readonly ['character', 'narrator', 'none'];
1170
1182
  /** @experimental */
1171
1183
  export type ChannelVoice = (typeof CHANNEL_VOICES)[number];
1184
+ /**
1185
+ * ๐Ÿšง The table channel's slug in {@link TABLE_CHANNEL_DECL}. Where a genre's
1186
+ * rolls, checks and calculations are written โ€” never the story's history, which
1187
+ * the Narrator would imitate (PLAN-rulesets ยง30, ruled 2026-10-16).
1188
+ * A folio with no voice and no speaker (not the Narrator, not an envoy); each row
1189
+ * is anchored to the message it belongs to (`metadata.anchorMessageId`), so it
1190
+ * reads "at that moment" and retracts with it.
1191
+ * @experimental
1192
+ */
1193
+ export declare const TABLE_CHANNEL = "table";
1194
+ /**
1195
+ * ๐Ÿšง The table channel's declaration, as a genre lists it in
1196
+ * `SessionShape.channels`. The messages widget draws its rows inline under their
1197
+ * anchors (`interleave`), or a copy pinned to it shows them as a log (_Dice_).
1198
+ * @experimental
1199
+ */
1200
+ export declare const TABLE_CHANNEL_DECL: Readonly<{
1201
+ readonly slug: "table";
1202
+ readonly label: {
1203
+ readonly en: 'Dice';
1204
+ };
1205
+ readonly role: 'folio';
1206
+ readonly voice: 'none';
1207
+ readonly table: true;
1208
+ }>;
1172
1209
  /**
1173
1210
  * This shape's channels as full declarations, defaults resolved โ€” the one
1174
1211
  * reader every consumer of `SessionShape.channels` should use, so the short
@@ -1205,6 +1242,16 @@ export declare function channelDecls(shape: unknown): ChannelDecl[];
1205
1242
  export declare function channelAudience(shape: unknown, channel: string): ChannelAudience;
1206
1243
  /** ๐Ÿšง The lore role of `channel` (may be `slug:lane`; the slug decides), default resolved. @experimental */
1207
1244
  export declare function channelLoreRole(shape: unknown, channel: string): ChannelLoreRole;
1245
+ /**
1246
+ * ๐Ÿšง The slug of the shape's table channel โ€” the one declaration marked
1247
+ * `table: true` with voice `none`. โณ A shape with none marked answers an unmarked
1248
+ * `table` channel declared `role: 'folio'`, `voice: 'none'` (bundles built before
1249
+ * the marker). Undefined when the shape keeps no table, when two channels are
1250
+ * marked, or when the marked one has a voice โ€” the declaration refuses those, and
1251
+ * a read never guesses. Never throws: a stored shape is data.
1252
+ * @experimental
1253
+ */
1254
+ export declare function tableChannelOf(shape: unknown): string | undefined;
1208
1255
  /**
1209
1256
  * A channel declaration that cannot mean what it says is refused โ€” with a
1210
1257
  * sentence, at the declaration, on the same terms as `assertMessageVerbFloors`.
@@ -1838,6 +1885,11 @@ export declare function definitionContract(source: ContractSource): DefinitionCo
1838
1885
  * @internal
1839
1886
  */
1840
1887
  export declare function definitionContractHash(source: ContractSource): string;
1888
+ /**
1889
+ * Where a definition's slots expose a context or variable template to the owner (G7): warnings, by slot kind then key.
1890
+ * @internal
1891
+ */
1892
+ export declare function templateExposureOf(d: Pick<Descriptor, 'id' | 'slots'>): string[];
1841
1893
  /**
1842
1894
  * The extras every script site is offered, whatever its slot lists:
1843
1895
  * `session`, the run's settings document. The
@@ -2132,6 +2184,28 @@ export interface EntryShape {
2132
2184
  * `matchMode` already uses.
2133
2185
  */
2134
2186
  amendMode?: 'amend' | 'replace';
2187
+ /**
2188
+ * ๐Ÿšง Whether an entry a session creates begins at the session's story date
2189
+ * (`'began'`) or has always been true (`'perpetual'`). Applied once, at
2190
+ * creation; a person's later setting always wins. Absent: perpetual.
2191
+ *
2192
+ * The layers are the entry type's default โ† the writing step's params
2193
+ * (as declared, or as a preset sets them). A
2194
+ * person's own entry is untouched. The Beginning is set only when the
2195
+ * session reads at a story date on a lorebook with its timeline on. A
2196
+ * type whose entries carry their own date (`year`, `month`, `day` fields)
2197
+ * cannot declare it.
2198
+ * @experimental
2199
+ */
2200
+ defaultBeginning?: 'perpetual' | 'began';
2201
+ /**
2202
+ * ๐Ÿšง The Decay rate, 0 (a fact) to 1, an entry a session creates starts
2203
+ * with. Absent: 0. Same layers, same creation-only rule, and a person's
2204
+ * later setting wins as for `defaultBeginning`; the Decay applies
2205
+ * whatever the timeline.
2206
+ * @experimental
2207
+ */
2208
+ defaultDecayRate?: number;
2135
2209
  }
2136
2210
  /** What an author writes. Flat, because nesting the facets buys nothing here. @experimental */
2137
2211
  export interface EntryTypeDecl<Id extends string = string> extends EntryShape {
@@ -7,7 +7,7 @@
7
7
  * editor work from rows.
8
8
  * @ruling 01 ยง1, 04 ยง3, NOMENCLATURE ยง5, 10 ยง10.2
9
9
  */
10
- import { exposureFindings } from './exposure.js';
10
+ import { exposureFindings, templateExposureWarnings } from './exposure.js';
11
11
  import { pluginRuleRef } from './pluginRuleRef.js';
12
12
  import { checkBandDeclarations, checkRendersDeclarations } from './bands.js';
13
13
  import { settingsSchemaFindings } from './settings.js';
@@ -523,6 +523,29 @@ export const CHANNEL_LANE_MODES = ['shared', 'personal'];
523
523
  export const CHANNEL_ROLES = ['conversation', 'folio'];
524
524
  /** The voices a channel's turn may seed under. `none` seeds no row at all. @experimental */
525
525
  export const CHANNEL_VOICES = ['character', 'narrator', 'none'];
526
+ /**
527
+ * ๐Ÿšง The table channel's slug in {@link TABLE_CHANNEL_DECL}. Where a genre's
528
+ * rolls, checks and calculations are written โ€” never the story's history, which
529
+ * the Narrator would imitate (PLAN-rulesets ยง30, ruled 2026-10-16).
530
+ * A folio with no voice and no speaker (not the Narrator, not an envoy); each row
531
+ * is anchored to the message it belongs to (`metadata.anchorMessageId`), so it
532
+ * reads "at that moment" and retracts with it.
533
+ * @experimental
534
+ */
535
+ export const TABLE_CHANNEL = 'table';
536
+ /**
537
+ * ๐Ÿšง The table channel's declaration, as a genre lists it in
538
+ * `SessionShape.channels`. The messages widget draws its rows inline under their
539
+ * anchors (`interleave`), or a copy pinned to it shows them as a log (_Dice_).
540
+ * @experimental
541
+ */
542
+ export const TABLE_CHANNEL_DECL = Object.freeze({
543
+ slug: TABLE_CHANNEL,
544
+ label: { en: 'Dice' },
545
+ role: 'folio',
546
+ voice: 'none',
547
+ table: true,
548
+ });
526
549
  /**
527
550
  * This shape's channels as full declarations, defaults resolved โ€” the one
528
551
  * reader every consumer of `SessionShape.channels` should use, so the short
@@ -573,6 +596,7 @@ export function channelDecls(shape) {
573
596
  ...(decl.lanes ? { lanes: decl.lanes } : {}),
574
597
  ...(decl.audience ? { audience: decl.audience } : {}),
575
598
  ...(decl.lore ? { lore: decl.lore } : {}),
599
+ ...(decl.table === true ? { table: true } : {}),
576
600
  };
577
601
  };
578
602
  const declared = (Array.isArray(s.channels) ? s.channels : [])
@@ -615,6 +639,25 @@ export function channelLoreRole(shape, channel) {
615
639
  ? 'story'
616
640
  : 'never';
617
641
  }
642
+ /**
643
+ * ๐Ÿšง The slug of the shape's table channel โ€” the one declaration marked
644
+ * `table: true` with voice `none`. โณ A shape with none marked answers an unmarked
645
+ * `table` channel declared `role: 'folio'`, `voice: 'none'` (bundles built before
646
+ * the marker). Undefined when the shape keeps no table, when two channels are
647
+ * marked, or when the marked one has a voice โ€” the declaration refuses those, and
648
+ * a read never guesses. Never throws: a stored shape is data.
649
+ * @experimental
650
+ */
651
+ export function tableChannelOf(shape) {
652
+ const decls = channelDecls(shape);
653
+ const marked = decls.filter((d) => d.table === true);
654
+ if (marked.length > 1)
655
+ return undefined;
656
+ if (marked.length === 1)
657
+ return marked[0].voice === 'none' ? marked[0].slug : undefined;
658
+ const legacy = decls.find((d) => d.slug === TABLE_CHANNEL && d.role === 'folio' && d.voice === 'none');
659
+ return legacy ? TABLE_CHANNEL : undefined;
660
+ }
618
661
  function assertShapeCalendar(shape, who) {
619
662
  const calendar = shape?.calendar;
620
663
  if (calendar === undefined)
@@ -638,13 +681,14 @@ export function assertChannelDecls(shape, who) {
638
681
  return;
639
682
  if (!Array.isArray(channels))
640
683
  throw new Error(`${who} declares a 'channels' that is not an array. A genre's channels are a list ` +
641
- `of slugs, each a bare string or a { slug, role?, voice?, messageVerbs?, label?, turnControls?, lanes?, audience?, lore? } (R-C).`);
684
+ `of slugs, each a bare string or a { slug, role?, voice?, messageVerbs?, label?, turnControls?, lanes?, audience?, lore?, table? } (R-C).`);
685
+ let firstTable;
642
686
  for (const raw of channels) {
643
687
  const isString = typeof raw === 'string';
644
688
  if (!isString && (!raw || typeof raw !== 'object' || Array.isArray(raw)))
645
689
  throw new Error(`${who} declares a channel that is neither a slug nor a declaration: ` +
646
690
  `${JSON.stringify(raw)}. Each channel is a bare string or a ` +
647
- `{ slug, role?, voice?, messageVerbs?, label?, turnControls?, lanes?, audience?, lore? } (R-C).`);
691
+ `{ slug, role?, voice?, messageVerbs?, label?, turnControls?, lanes?, audience?, lore?, table? } (R-C).`);
648
692
  const decl = (isString ? { slug: raw } : raw);
649
693
  const slug = typeof decl.slug === 'string' ? decl.slug.trim() : '';
650
694
  if (!slug)
@@ -697,6 +741,13 @@ export function assertChannelDecls(shape, who) {
697
741
  throw new Error(`${at} declares lore '${String(decl.lore)}'. A channel's lore role is 'story', 'aside' or 'never' โ€” events, context, or nothing a summary reads.`);
698
742
  if (slug === DEFAULT_CHANNEL && decl.lore !== undefined && decl.lore !== 'story')
699
743
  throw new Error(`${at} declares lore '${String(decl.lore)}'. '${DEFAULT_CHANNEL}' is the story's channel; declare another channel for asides.`);
744
+ if (decl.table === true) {
745
+ if (firstTable !== undefined)
746
+ throw new Error(`${who} marks two table channels, '${firstTable}' and '${slug}'. A session keeps one table, where the host writes its table lines: mark one.`);
747
+ firstTable = slug;
748
+ if (decl.voice !== 'none')
749
+ throw new Error(`${at} is marked the table channel without voice 'none'. The table is written in no voice and nobody speaks in it: declare voice 'none'.`);
750
+ }
700
751
  assertMessageVerbFloors({ messageVerbs: decl.messageVerbs }, at);
701
752
  // R6: the display name is display text, and the per-channel turn
702
753
  // controls are judged on exactly the terms the genre's are.
@@ -946,13 +997,25 @@ function register(d) {
946
997
  // A finding, not a refusal: the fallback is documented (inference), the
947
998
  // omission is recorded, and `validate()` says it on every placement.
948
999
  const reviewFinding = reviewFieldsFinding(d);
949
- if (reviewFinding)
950
- registrationFindings.set(d.id, [reviewFinding]);
1000
+ // G7: a template or variables exposure is ignored, with a warning kept here beside it.
1001
+ const noted = [...(reviewFinding ? [reviewFinding] : []), ...templateExposureOf(d)];
1002
+ if (noted.length)
1003
+ registrationFindings.set(d.id, noted);
951
1004
  else
952
1005
  registrationFindings.delete(d.id);
953
1006
  types.set(d.id, d);
954
1007
  return d;
955
1008
  }
1009
+ /**
1010
+ * Where a definition's slots expose a context or variable template to the owner (G7): warnings, by slot kind then key.
1011
+ * @internal
1012
+ */
1013
+ export function templateExposureOf(d) {
1014
+ const out = [];
1015
+ for (const [slotName, slot] of Object.entries(d.slots ?? {}))
1016
+ out.push(...templateExposureWarnings(slot?.schema, `${d.id} slots.${slotName}.schema`, slot?.kind));
1017
+ return out;
1018
+ }
956
1019
  /** ๐Ÿšง A node's settings may reach the owner; model plumbing never does (A10, R1 โ€” ruled 10-12). */
957
1020
  function checkExposure(d) {
958
1021
  const found = [];
@@ -1603,6 +1666,21 @@ function assertEntryShape(id, shape, door = 'core') {
1603
1666
  `in this release. A ruleset's come from its entryable repertoires ` +
1604
1667
  `(deriveRulesetEntryTypes), never by hand โ€” a hand-written plugin type also owns ` +
1605
1668
  `a database constraint and the rows under it, and that half is not built.`);
1669
+ if (shape.defaultBeginning !== undefined &&
1670
+ shape.defaultBeginning !== 'perpetual' &&
1671
+ shape.defaultBeginning !== 'began')
1672
+ throw new Error(`${id} declares defaultBeginning '${String(shape.defaultBeginning)}'. Say 'perpetual' or 'began', or leave it out.`);
1673
+ if (shape.defaultDecayRate !== undefined &&
1674
+ !(typeof shape.defaultDecayRate === 'number' &&
1675
+ Number.isFinite(shape.defaultDecayRate) &&
1676
+ shape.defaultDecayRate >= 0 &&
1677
+ shape.defaultDecayRate <= 1))
1678
+ throw new Error(`${id} declares defaultDecayRate ${String(shape.defaultDecayRate)}. A Decay rate is a number from 0 to 1: 0 is a fact, above 0 a living entry.`);
1679
+ if (shape.defaultBeginning !== undefined) {
1680
+ const parts = ['year', 'month', 'day'].filter((k) => Object.prototype.hasOwnProperty.call(shape.fields ?? {}, k));
1681
+ if (parts.length)
1682
+ throw new Error(`${id} declares defaultBeginning, but its entries carry their own date (its fields declare ${parts.join(', ')}), so a Beginning default would do nothing. Leave it out.`);
1683
+ }
1606
1684
  const unknown = unknownRoles(shape);
1607
1685
  if (unknown.length)
1608
1686
  throw new Error(`${id} declares ${unknown.map((r) => `'${r}'`).join(', ')}, which no engine ` +
@@ -53,7 +53,7 @@ export interface DocNode {
53
53
  status?: I18n;
54
54
  label?: I18n;
55
55
  purpose?: I18n;
56
- /** ๐Ÿšง R54: the session's owner chooses this step's prompt, among those not hidden. */
56
+ /** โณ Transitional (R6): the host offers the owner every model call's prompt choice, whatever this says; kept so existing specs build, its only value is `'owner'`. */
57
57
  promptReach?: 'owner';
58
58
  };
59
59
  /**
package/dist/events.d.ts CHANGED
@@ -56,6 +56,16 @@ export interface EventDef {
56
56
  * @ruling PLAN-turn-order ยงB3, C28
57
57
  */
58
58
  declaredRoot?: true;
59
+ /**
60
+ * ๐Ÿšง **One registration runs** on this event: of the registrations a session's
61
+ * effective list holds on it, the host runs exactly one โ€” the session's choice,
62
+ * else the one marked `default` (`RegistrationDecl.default`). Each registration
63
+ * is one option a session's owner may pick, named by its `label`. Absent: every
64
+ * registration on the event runs, in `order`.
65
+ * โš  Not a lock: a preset adds and drops options as on any event.
66
+ * @ruling programme 2.3, TC2 (owner 2026-11-18)
67
+ */
68
+ runsOne?: true;
59
69
  /**
60
70
  * The shape of what a listener receives. A shape id,
61
71
  * on the same terms as a port's: `pipeline_event_registry.payload_shape`
@@ -460,7 +470,7 @@ export declare const CORE_EVENTS: {
460
470
  readonly sessionArchived: EventDef;
461
471
  /** ๐Ÿšง Raised by the scene handler (sockets/scenes.ts) at the apply; not `scene-closed`, not `lore-entry-created`. */
462
472
  readonly sceneSummaryApplied: EventDef;
463
- /** ๐Ÿšง Raised by `settleThrough` when the session's settle line moves. */
473
+ /** ๐Ÿšง Raised by `settleThrough` once per story lane whose settle line moved. */
464
474
  readonly historySettled: EventDef;
465
475
  /**
466
476
  * ๐Ÿšง A **rest was taken** under the session's rules (lane G3, 2026-10-23;
@@ -580,6 +590,25 @@ export declare const CORE_EVENTS: {
580
590
  * @ruling 13 ยง7c, F32
581
591
  */
582
592
  readonly scheduleTick: EventDef;
593
+ /**
594
+ * ๐Ÿšง Something that can change whose turn it is happened. The host raises it
595
+ * after each event that can change whose turn it is; the payload carries the
596
+ * session, the causing event and its `EventCause`.
597
+ *
598
+ * One registration runs (`runsOne`): the session's choice, else the
599
+ * registration marked `default`. Each registration is a whole turn-order
600
+ * pipeline that ends in `core:outlet/set-turn-order@1`.
601
+ *
602
+ * A genre with no registration here keeps its per-event turn-order
603
+ * registrations, and the ask runs nothing. Payload
604
+ * `core:shape/turn-order-asked@1` (`TurnOrderAskedPayload`).
605
+ *
606
+ * โš  Not `turn-order-changed` โ€” that is the fact after the write, core-internal.
607
+ * An action, like `message-deletion-asked`: a request, not a write's
608
+ * consequence.
609
+ * @ruling programme 2.3, TC1, TC2, TN1 (owner 2026-11-18)
610
+ */
611
+ readonly turnOrderAsked: EventDef;
583
612
  };
584
613
  /**
585
614
  * ๐Ÿšง Core's events as **objects** โ€” what an author passes where an event is
@@ -829,7 +858,7 @@ export declare const coreEvents: {
829
858
  readonly sessionArchived: EventDef;
830
859
  /** ๐Ÿšง Raised by the scene handler (sockets/scenes.ts) at the apply; not `scene-closed`, not `lore-entry-created`. */
831
860
  readonly sceneSummaryApplied: EventDef;
832
- /** ๐Ÿšง Raised by `settleThrough` when the session's settle line moves. */
861
+ /** ๐Ÿšง Raised by `settleThrough` once per story lane whose settle line moved. */
833
862
  readonly historySettled: EventDef;
834
863
  /**
835
864
  * ๐Ÿšง A **rest was taken** under the session's rules (lane G3, 2026-10-23;
@@ -949,6 +978,25 @@ export declare const coreEvents: {
949
978
  * @ruling 13 ยง7c, F32
950
979
  */
951
980
  readonly scheduleTick: EventDef;
981
+ /**
982
+ * ๐Ÿšง Something that can change whose turn it is happened. The host raises it
983
+ * after each event that can change whose turn it is; the payload carries the
984
+ * session, the causing event and its `EventCause`.
985
+ *
986
+ * One registration runs (`runsOne`): the session's choice, else the
987
+ * registration marked `default`. Each registration is a whole turn-order
988
+ * pipeline that ends in `core:outlet/set-turn-order@1`.
989
+ *
990
+ * A genre with no registration here keeps its per-event turn-order
991
+ * registrations, and the ask runs nothing. Payload
992
+ * `core:shape/turn-order-asked@1` (`TurnOrderAskedPayload`).
993
+ *
994
+ * โš  Not `turn-order-changed` โ€” that is the fact after the write, core-internal.
995
+ * An action, like `message-deletion-asked`: a request, not a write's
996
+ * consequence.
997
+ * @ruling programme 2.3, TC1, TC2, TN1 (owner 2026-11-18)
998
+ */
999
+ readonly turnOrderAsked: EventDef;
952
1000
  };
953
1001
  /**
954
1002
  * The id an event is named by: core's `core:event/<slug>@<version>`, a
@@ -1089,7 +1137,7 @@ export interface SessionChangePayload {
1089
1137
  round?: number;
1090
1138
  /** ๐Ÿšง `turn-ended`: whose turn ended, as a participant reference; null for narration. */
1091
1139
  speaker?: string | null;
1092
- /** ๐Ÿšง `turn-ended` ยท `round-ended`: the lane the turn was taken on โ€” a canonical channel string (`main`, `main:2`, `sanctum`) (R51). */
1140
+ /** ๐Ÿšง `turn-ended` ยท `round-ended`: the lane the turn was taken on โ€” a canonical channel string (`main`, `main:2`, `sanctum`) (R51). `history-settled`: the story lane whose settle line moved; absent: `main`. */
1093
1141
  lane?: string;
1094
1142
  /**
1095
1143
  * ๐Ÿšง `turn-ended`: how many turns each speaker has taken this round, this
@@ -1099,8 +1147,6 @@ export interface SessionChangePayload {
1099
1147
  turnsBy?: Record<string, number>;
1100
1148
  /** ๐Ÿšง `round-ended`: who spoke in the round, in order of first turn โ€” `narrator` for the pipeline's own voice (R52). */
1101
1149
  speakers?: string[];
1102
- /** ๐Ÿšง `turn-ended`, when the genre declares `shape.turnSeatChanges: true`: the seats added, removed or changed since the previous turn of this lane; empty when none. */
1103
- turnSeatChanges?: TurnSeatChange[];
1104
1150
  /** ๐Ÿšง `scene-opened` ยท `scene-closed`: the scene. */
1105
1151
  sceneId?: number;
1106
1152
  /** ๐Ÿšง `story-clock-moved`: where the story clock stood and where it stands now (`StoryTime`). */
@@ -1115,28 +1161,9 @@ export interface SessionChangePayload {
1115
1161
  fromMessageId: number;
1116
1162
  throughMessageId: number;
1117
1163
  };
1118
- /** ๐Ÿšง `history-settled`: where the line stood before (`messageId` is where it stands now); null when unset. */
1164
+ /** ๐Ÿšง `history-settled`: where that lane's line stood before (`messageId` is where it stands now); null when unset. */
1119
1165
  previousSettledMessageId?: number | null;
1120
1166
  }
1121
- /**
1122
- * ๐Ÿšง One seat that changed since the previous turn of its lane, as `turn-ended` carries it in
1123
- * `turnSeatChanges` when the session's genre declares `shape.turnSeatChanges: true` (owner 2026-11-09).
1124
- * The host builds it from the seat writer's announcements (`member-added`, `member-removed`,
1125
- * `cast-changed`), netted per seat: a seat that joined and left inside the turn is absent.
1126
- * โš  Not `CastChangePayload` (one event as it happened), and not the host's own `SeatChange`
1127
- * (what one seat-writer call did).
1128
- * @experimental
1129
- */
1130
- export interface TurnSeatChange {
1131
- /** The seat as a participant reference in member form (`seated-member:<id>`, `player-seat:<id>`): pass it on, never parse it. */
1132
- ref: string;
1133
- /** Which kind of seat it is: a character seat or a player seat. */
1134
- seatKind: 'character' | 'player';
1135
- /** The cast member in the seat; null when the seat names none. */
1136
- castMemberId: number | null;
1137
- /** `added`: the seat joined; `removed`: it left; `changed`: it stayed but was switched on or off, or who portrays it moved (a reorder is not a change). */
1138
- change: 'added' | 'removed' | 'changed';
1139
- }
1140
1167
  /**
1141
1168
  * The payload of `core:event/cast-changed@1` (`core:shape/cast-change@1`):
1142
1169
  * one seated participant's row moved. `ref` is the participant reference
@@ -1266,6 +1293,22 @@ export interface RulesetConversionPayload {
1266
1293
  added: Record<string, unknown>;
1267
1294
  };
1268
1295
  }
1296
+ /**
1297
+ * ๐Ÿšง The payload of `core:event/turn-order-asked@1`
1298
+ * (`core:shape/turn-order-asked@1`): something that can change whose turn it
1299
+ * is happened, and the one registration the session runs on the ask answers
1300
+ * it (programme 2.3, TC2, owner 2026-11-18).
1301
+ * @experimental
1302
+ */
1303
+ export interface TurnOrderAskedPayload {
1304
+ sessionId: number;
1305
+ /** When, as epoch milliseconds. */
1306
+ at: number;
1307
+ /** The id of the event that raised the ask โ€” `core:event/message-created@1`. Never `event`, which in other payloads is the payload's own event. */
1308
+ asked: string;
1309
+ /** That event's cause. */
1310
+ cause?: EventCause;
1311
+ }
1269
1312
  /**
1270
1313
  * The payload of `core:event/turn-order-changed@1`
1271
1314
  * (`core:shape/turn-order-changed@1`): the order as
package/dist/events.js CHANGED
@@ -44,6 +44,8 @@ export function defineEvent(def) {
44
44
  }
45
45
  if (def.carries !== undefined && (!Array.isArray(def.carries) || def.carries.some((k) => typeof k !== 'string' || !k)))
46
46
  throw new Error(`event '${def.slug}' declares carries that are not entity kinds โ€” a list such as ['session', 'message']`);
47
+ if (def.runsOne !== undefined && def.runsOne !== true)
48
+ throw new Error(`event '${def.slug}' declares runsOne as ${JSON.stringify(def.runsOne)} โ€” it is true, or left out`);
47
49
  if (def.declaredRoot && def.causedBy?.length) {
48
50
  throw new Error(`event '${def.slug}' is a declared root and declares causedBy โ€” a root starts outside ` +
49
51
  `every pipeline, so nothing writes it. Drop one of the two`);
@@ -819,7 +821,7 @@ export const CORE_EVENTS = {
819
821
  payload: S.sessionChange,
820
822
  description: "A scene's summary was saved into the lorebook โ€” the stretch it was written from is part of the record now. The payload names the scene, its entry and the messages it was written from.",
821
823
  }),
822
- /** ๐Ÿšง Raised by `settleThrough` when the session's settle line moves. */
824
+ /** ๐Ÿšง Raised by `settleThrough` once per story lane whose settle line moved. */
823
825
  historySettled: defineEvent({
824
826
  slug: 'history-settled',
825
827
  name: { en: 'History settled' },
@@ -829,7 +831,7 @@ export const CORE_EVENTS = {
829
831
  carries: ['session', 'message'],
830
832
  affectsUser: false,
831
833
  payload: S.sessionChange,
832
- description: "The session's settle line moved: Back no longer reaches the message the payload names or anything before it.",
834
+ description: "A story lane's settle line moved: Back no longer reaches the message the payload names, or any earlier line on that lane. The payload's lane names the story lane (absent: main, which also carries every line on no story channel); a write that moves several lanes raises one event per lane.",
833
835
  }),
834
836
  /**
835
837
  * ๐Ÿšง A **rest was taken** under the session's rules (lane G3, 2026-10-23;
@@ -1086,6 +1088,37 @@ export const CORE_EVENTS = {
1086
1088
  affectsUser: false,
1087
1089
  description: 'A declared cadence elapsed. Payload: cadence, scheduledFor, scope.',
1088
1090
  }),
1091
+ // โ”€โ”€ Turn order โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
1092
+ /**
1093
+ * ๐Ÿšง Something that can change whose turn it is happened. The host raises it
1094
+ * after each event that can change whose turn it is; the payload carries the
1095
+ * session, the causing event and its `EventCause`.
1096
+ *
1097
+ * One registration runs (`runsOne`): the session's choice, else the
1098
+ * registration marked `default`. Each registration is a whole turn-order
1099
+ * pipeline that ends in `core:outlet/set-turn-order@1`.
1100
+ *
1101
+ * A genre with no registration here keeps its per-event turn-order
1102
+ * registrations, and the ask runs nothing. Payload
1103
+ * `core:shape/turn-order-asked@1` (`TurnOrderAskedPayload`).
1104
+ *
1105
+ * โš  Not `turn-order-changed` โ€” that is the fact after the write, core-internal.
1106
+ * An action, like `message-deletion-asked`: a request, not a write's
1107
+ * consequence.
1108
+ * @ruling programme 2.3, TC1, TC2, TN1 (owner 2026-11-18)
1109
+ */
1110
+ turnOrderAsked: defineEvent({
1111
+ slug: 'turn-order-asked',
1112
+ declaredRoot: true,
1113
+ name: { en: 'Turn order asked' },
1114
+ version: 1,
1115
+ family: 'action',
1116
+ carries: ['session'],
1117
+ affectsUser: true,
1118
+ runsOne: true,
1119
+ payload: S.turnOrderAsked,
1120
+ description: "Something that can change whose turn it is happened โ€” the one turn order option the session runs answers it and prepares the turns. The payload carries the session, the event that caused the ask and that event's cause.",
1121
+ }),
1089
1122
  };
1090
1123
  /**
1091
1124
  * ๐Ÿšง Core's events as **objects** โ€” what an author passes where an event is
@@ -519,6 +519,19 @@ export interface RunOptions {
519
519
  * @ruling F36
520
520
  */
521
521
  timeoutCeilingMs?: number;
522
+ /**
523
+ * ๐Ÿšง Apply no step time limit for this run: neither a definition's `timeoutMs`
524
+ * nor `timeoutCeilingMs`. A pub's diagnostic switch (an administrator finding
525
+ * out whether a time limit is what stops a step); a stuck step then waits until
526
+ * the host stops the run. The executor does not abort a node in flight on
527
+ * `cancelSignal` (it is checked between nodes), so the host's stop must reach
528
+ * the requests the node waits on โ€” core's does: every request it performs
529
+ * listens to the run's own signal. Limits a host enforces inside its own
530
+ * calls (a sandbox's deadline, a connection's idle watchdog) are the host's and
531
+ * are not touched. Read once, at the run's start.
532
+ * @experimental
533
+ */
534
+ stepTimeLimitsOff?: boolean;
522
535
  /**
523
536
  * Force every clause sequential, as an admin may.
524
537
  * @ruling 01 ยง4
@@ -592,6 +605,20 @@ export interface RunOptions {
592
605
  by: string;
593
606
  reason: string;
594
607
  } | undefined;
608
+ /**
609
+ * ๐Ÿšง Promises the host hands this run: every write-class outlet of the run
610
+ * (`effects: 'write'`) waits, before it starts, until every promise given has
611
+ * settled โ€” resolved or rejected. Reads, prompts and model calls do not wait.
612
+ * A rejected promise opens the gate as a resolved one does: the earlier run's
613
+ * failure is its own, and this run proceeds. The wait is not execution, so no
614
+ * timeout clock runs on it. The executor never inspects what the promises
615
+ * stand for; the host decides when each settles. A Stop (`cancelSignal`) is
616
+ * read when the gate opens: a run stopped while waiting ends `cancelled`
617
+ * once released, and writes nothing. Absent or empty: no wait.
618
+ * @experimental
619
+ * @ruling RG3, RN1
620
+ */
621
+ writeAfter?: readonly Promise<unknown>[];
595
622
  /**
596
623
  * Compact a receipt that halts before any effectful node: trigger, spec version,
597
624
  * halt node/reason and elapsed, with no payloads and no node rows.
package/dist/executor.js CHANGED
@@ -232,6 +232,7 @@ export async function run(doc, opts) {
232
232
  const seed = opts.seed ?? 'seed:0';
233
233
  const rng = seededRandom(seed);
234
234
  const now = opts.now ?? (() => Date.now());
235
+ const limitsOff = opts.stepTimeLimitsOff === true;
235
236
  // Clauses are addressed alongside nodes so a clause can carry a setting of
236
237
  // its own โ€” its execution mode. Keys cannot collide: a clause id qualifies
237
238
  // the nodes inside it (`drafting` contains `drafting.item.draft`), so the
@@ -1023,7 +1024,8 @@ export async function run(doc, opts) {
1023
1024
  // the run is worth recording in full whatever happens next.
1024
1025
  if (d.effects && d.effects !== 'none')
1025
1026
  effectfulNodeRan = true;
1026
- const timeoutMs = Math.min(d.timeoutMs ?? Infinity, opts.timeoutCeilingMs ?? Infinity);
1027
+ const ceilingMs = limitsOff ? Infinity : (opts.timeoutCeilingMs ?? Infinity);
1028
+ const timeoutMs = limitsOff ? Infinity : Math.min(d.timeoutMs ?? Infinity, ceilingMs);
1027
1029
  nr.timeoutMsApplied = Number.isFinite(timeoutMs) ? timeoutMs : undefined;
1028
1030
  const controller = new AbortController();
1029
1031
  // F36: `wall` bounds the invocation; `idle` bounds the gap between
@@ -1031,7 +1033,7 @@ export async function run(doc, opts) {
1031
1033
  const clock = nodeClock({
1032
1034
  ms: timeoutMs,
1033
1035
  kind: d.timeoutKind ?? 'wall',
1034
- ceilingMs: opts.timeoutCeilingMs ?? Infinity,
1036
+ ceilingMs,
1035
1037
  }, controller);
1036
1038
  const base = {
1037
1039
  signal: controller.signal,
@@ -1682,7 +1684,8 @@ export async function run(doc, opts) {
1682
1684
  /** Set when the run ended by throwing; rethrown after the run-end hook. */
1683
1685
  let thrown;
1684
1686
  try {
1685
- const outcome = await runLevel({ clauseId: undefined, chain: undefined }, values);
1687
+ const rootGate = (opts.writeAfter ?? []).map((p) => Promise.resolve(p).then(() => undefined, () => undefined));
1688
+ const outcome = await runLevel({ clauseId: undefined, chain: undefined }, values, undefined, undefined, undefined, rootGate);
1686
1689
  if (outcome.kind === 'halt') {
1687
1690
  receipt.outcome = 'halt';
1688
1691
  receipt.haltReason = outcome.reason;