@serene-pub/sdk 0.6.0-pr-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +17 -0
  3. package/README.md +368 -0
  4. package/dist/actions.d.ts +572 -0
  5. package/dist/actions.js +829 -0
  6. package/dist/annexFields.d.ts +234 -0
  7. package/dist/annexFields.js +413 -0
  8. package/dist/announce.d.ts +464 -0
  9. package/dist/announce.js +426 -0
  10. package/dist/attributes.d.ts +670 -0
  11. package/dist/attributes.js +904 -0
  12. package/dist/bands.d.ts +125 -0
  13. package/dist/bands.js +256 -0
  14. package/dist/builder.d.ts +683 -0
  15. package/dist/builder.js +677 -0
  16. package/dist/candidates.d.ts +109 -0
  17. package/dist/candidates.js +118 -0
  18. package/dist/capabilities.d.ts +744 -0
  19. package/dist/capabilities.js +679 -0
  20. package/dist/channels.d.ts +106 -0
  21. package/dist/channels.js +129 -0
  22. package/dist/clauses.d.ts +40 -0
  23. package/dist/clauses.js +43 -0
  24. package/dist/component.d.ts +33 -0
  25. package/dist/component.js +27 -0
  26. package/dist/componentBuild.d.ts +48 -0
  27. package/dist/componentBuild.js +84 -0
  28. package/dist/componentClient.d.ts +100 -0
  29. package/dist/componentClient.js +13 -0
  30. package/dist/componentImports.d.ts +51 -0
  31. package/dist/componentImports.js +106 -0
  32. package/dist/componentModule.d.ts +8 -0
  33. package/dist/componentModule.js +270 -0
  34. package/dist/componentWire.d.ts +130 -0
  35. package/dist/componentWire.js +280 -0
  36. package/dist/config.d.ts +295 -0
  37. package/dist/config.js +231 -0
  38. package/dist/connections.d.ts +89 -0
  39. package/dist/connections.js +131 -0
  40. package/dist/declarations.d.ts +290 -0
  41. package/dist/declarations.js +794 -0
  42. package/dist/descriptors.d.ts +1774 -0
  43. package/dist/descriptors.js +1329 -0
  44. package/dist/dev.d.ts +136 -0
  45. package/dist/dev.js +161 -0
  46. package/dist/document.d.ts +202 -0
  47. package/dist/document.js +312 -0
  48. package/dist/engines.d.ts +117 -0
  49. package/dist/engines.js +203 -0
  50. package/dist/eventMapLaws.d.ts +63 -0
  51. package/dist/eventMapLaws.js +128 -0
  52. package/dist/events.d.ts +554 -0
  53. package/dist/events.js +633 -0
  54. package/dist/executor.d.ts +771 -0
  55. package/dist/executor.js +1829 -0
  56. package/dist/extension.d.ts +448 -0
  57. package/dist/extension.js +315 -0
  58. package/dist/facets.d.ts +53 -0
  59. package/dist/facets.js +60 -0
  60. package/dist/foldedSections.d.ts +74 -0
  61. package/dist/foldedSections.js +161 -0
  62. package/dist/genres.d.ts +507 -0
  63. package/dist/genres.js +633 -0
  64. package/dist/guardedConnection.d.ts +138 -0
  65. package/dist/guardedConnection.js +341 -0
  66. package/dist/handlebarsReach.d.ts +122 -0
  67. package/dist/handlebarsReach.js +222 -0
  68. package/dist/hash.d.ts +146 -0
  69. package/dist/hash.js +166 -0
  70. package/dist/hookGrants.d.ts +47 -0
  71. package/dist/hookGrants.js +68 -0
  72. package/dist/hooks.d.ts +290 -0
  73. package/dist/hooks.js +113 -0
  74. package/dist/hostElements.d.ts +447 -0
  75. package/dist/hostElements.js +702 -0
  76. package/dist/i18n.d.ts +94 -0
  77. package/dist/i18n.js +123 -0
  78. package/dist/identity.d.ts +93 -0
  79. package/dist/identity.js +135 -0
  80. package/dist/index.d.ts +85 -0
  81. package/dist/index.js +176 -0
  82. package/dist/layout.d.ts +194 -0
  83. package/dist/layout.js +40 -0
  84. package/dist/media.d.ts +202 -0
  85. package/dist/media.js +70 -0
  86. package/dist/messageBlocks.d.ts +487 -0
  87. package/dist/messageBlocks.js +683 -0
  88. package/dist/migration.d.ts +128 -0
  89. package/dist/migration.js +261 -0
  90. package/dist/names.d.ts +78 -0
  91. package/dist/names.js +136 -0
  92. package/dist/nodeInput.d.ts +399 -0
  93. package/dist/nodeInput.js +178 -0
  94. package/dist/participants.d.ts +291 -0
  95. package/dist/participants.js +252 -0
  96. package/dist/personGate.d.ts +62 -0
  97. package/dist/personGate.js +77 -0
  98. package/dist/pick.d.ts +84 -0
  99. package/dist/pick.js +103 -0
  100. package/dist/pluginHarness.d.ts +235 -0
  101. package/dist/pluginHarness.js +558 -0
  102. package/dist/pluginPermissions.d.ts +25 -0
  103. package/dist/pluginPermissions.js +97 -0
  104. package/dist/pluginRuleRef.d.ts +13 -0
  105. package/dist/pluginRuleRef.js +10 -0
  106. package/dist/predicates.d.ts +182 -0
  107. package/dist/predicates.js +249 -0
  108. package/dist/preview.d.ts +120 -0
  109. package/dist/preview.js +82 -0
  110. package/dist/promptBlocks.d.ts +130 -0
  111. package/dist/promptBlocks.js +197 -0
  112. package/dist/rankingDecisions.d.ts +60 -0
  113. package/dist/rankingDecisions.js +48 -0
  114. package/dist/receipt.d.ts +313 -0
  115. package/dist/receipt.js +60 -0
  116. package/dist/receiverRules.d.ts +24 -0
  117. package/dist/receiverRules.js +94 -0
  118. package/dist/refs.d.ts +117 -0
  119. package/dist/refs.js +137 -0
  120. package/dist/registry.d.ts +230 -0
  121. package/dist/registry.js +273 -0
  122. package/dist/review.d.ts +108 -0
  123. package/dist/review.js +97 -0
  124. package/dist/sampling.d.ts +152 -0
  125. package/dist/sampling.js +712 -0
  126. package/dist/scope.d.ts +65 -0
  127. package/dist/scope.js +128 -0
  128. package/dist/scripts.d.ts +243 -0
  129. package/dist/scripts.js +326 -0
  130. package/dist/sessionLayout.d.ts +339 -0
  131. package/dist/sessionLayout.js +503 -0
  132. package/dist/sessionSettings.d.ts +70 -0
  133. package/dist/sessionSettings.js +2 -0
  134. package/dist/settings.d.ts +501 -0
  135. package/dist/settings.js +604 -0
  136. package/dist/settingsSlot.d.ts +108 -0
  137. package/dist/settingsSlot.js +166 -0
  138. package/dist/shapes.d.ts +373 -0
  139. package/dist/shapes.js +408 -0
  140. package/dist/sheets.d.ts +165 -0
  141. package/dist/sheets.js +251 -0
  142. package/dist/statShapes.d.ts +96 -0
  143. package/dist/statShapes.js +112 -0
  144. package/dist/status.d.ts +103 -0
  145. package/dist/status.js +125 -0
  146. package/dist/storage.d.ts +145 -0
  147. package/dist/storage.js +33 -0
  148. package/dist/storyTime.d.ts +308 -0
  149. package/dist/storyTime.js +560 -0
  150. package/dist/surfaces.d.ts +501 -0
  151. package/dist/surfaces.js +292 -0
  152. package/dist/template.d.ts +312 -0
  153. package/dist/template.js +554 -0
  154. package/dist/templateCheck.d.ts +60 -0
  155. package/dist/templateCheck.js +516 -0
  156. package/dist/templateFit.d.ts +157 -0
  157. package/dist/templateFit.js +349 -0
  158. package/dist/templateIds.d.ts +138 -0
  159. package/dist/templateIds.js +144 -0
  160. package/dist/templateScopeAt.d.ts +131 -0
  161. package/dist/templateScopeAt.js +354 -0
  162. package/dist/testing.d.ts +177 -0
  163. package/dist/testing.js +383 -0
  164. package/dist/tokenizers.d.ts +113 -0
  165. package/dist/tokenizers.js +184 -0
  166. package/dist/turnLock.d.ts +96 -0
  167. package/dist/turnLock.js +79 -0
  168. package/dist/turnOrder.d.ts +143 -0
  169. package/dist/turnOrder.js +128 -0
  170. package/dist/validate.d.ts +74 -0
  171. package/dist/validate.js +1399 -0
  172. package/dist/values.d.ts +212 -0
  173. package/dist/values.js +390 -0
  174. package/dist/variables.d.ts +493 -0
  175. package/dist/variables.js +662 -0
  176. package/dist/verdicts.d.ts +275 -0
  177. package/dist/verdicts.js +348 -0
  178. package/dist/widgetDecls.d.ts +88 -0
  179. package/dist/widgetDecls.js +119 -0
  180. package/dist/widgets.d.ts +1527 -0
  181. package/dist/widgets.js +208 -0
  182. package/dist/wire.d.ts +126 -0
  183. package/dist/wire.js +140 -0
  184. package/dist/worldinfo.d.ts +150 -0
  185. package/dist/worldinfo.js +212 -0
  186. package/host-elements.d.ts +914 -0
  187. package/package.json +67 -0
package/dist/dev.d.ts ADDED
@@ -0,0 +1,136 @@
1
+ /**
2
+ * Dev mode: point at an entry file, load it in memory, hot reload (13 §11).
3
+ *
4
+ * ## The collision, stated before it is resolved
5
+ *
6
+ * F6 says **core imports documents, never authoring JS**, and 04 §5a says nothing is
7
+ * discovered by executing. A dev loader that evaluates `src/index.ts` and pulls pipelines,
8
+ * hooks and components out of memory looks exactly like the thing both rules forbid.
9
+ *
10
+ * It is not, and the distinction is worth being precise about rather than waving at.
11
+ *
12
+ * **What F6 protects is the *importer*.** The claim it makes is that no code path reachable
13
+ * from installing or running a plugin evaluates authoring JavaScript — so a malicious
14
+ * document cannot become a malicious program, and a plugin cannot announce capabilities at
15
+ * runtime that its manifest did not declare. That claim survives here, because the dev
16
+ * loader does not hand core an `Extension`. It **compiles** — same packager, same manifest,
17
+ * same documents — and hands core the same plain data an installed plugin does. The
18
+ * evaluation happens in the dev harness, on the developer's own machine, on their own code,
19
+ * exactly as it does inside `serene-pub build`.
20
+ *
21
+ * So the rule that actually holds is narrower and truer than "core never evaluates JS":
22
+ *
23
+ * > **Every path into core carries a manifest and documents. Dev mode changes where they
24
+ * > were produced, not what core receives.**
25
+ *
26
+ * Three constraints follow, and they are not negotiable if the loader is to stay honest:
27
+ *
28
+ * 1. **Memory only.** A dev overlay never writes `pipeline_definition_registry`, spec or preset rows. A dev
29
+ * plugin whose rows outlived the session would leave a user's chats pinning types that no
30
+ * longer exist — a broken install with no install to uninstall.
31
+ * 2. **Permissions are compiled and enforced identically.** Dev mode changes the source of
32
+ * the code, never the trust in it. The runtime double-check (F28) does not know or care
33
+ * that a plugin came from a file path.
34
+ * 3. **Provenance is recorded.** Every run from a dev-loaded plugin marks its receipt
35
+ * `source: 'dev'`, because "it worked on my machine" needs to be distinguishable in the
36
+ * record from "it worked."
37
+ *
38
+ * ## Hot reload has one hard rule
39
+ *
40
+ * **An in-flight run never changes underneath itself.** A receipt claims to describe a run
41
+ * of a specific spec version; swapping a node's implementation halfway through makes that
42
+ * claim false, and a receipt that lies is worse than no receipt. So a reload that touches
43
+ * anything a running pipeline is using is *deferred*, not applied — and `reloadPlan` says
44
+ * which runs are holding it up, so the developer sees "waiting on 1 run" rather than
45
+ * silence.
46
+ */
47
+ import { type SpecDocument } from './document.js';
48
+ import type { Extension } from './extension.js';
49
+ import { type RegistryEntry } from './registry.js';
50
+ import type { Bindings } from './executor.js';
51
+ /** @experimental */
52
+ export interface DevOverlay {
53
+ slug: string;
54
+ version: string;
55
+ /** Absolute path to the entry module, so a reload knows what to re-evaluate. */
56
+ entry: string;
57
+ /** Registry rows that shadow the persisted table for this session only. */
58
+ types: RegistryEntry[];
59
+ documents: SpecDocument[];
60
+ bindings: Bindings;
61
+ components: Extension['components'];
62
+ /** Stamped into every receipt this overlay produces. */
63
+ source: 'dev';
64
+ loadedAt: number;
65
+ }
66
+ /**
67
+ * Build the in-memory overlay for a loaded extension.
68
+ *
69
+ * Deliberately takes an already-evaluated `Extension` rather than a path: *loading* is the
70
+ * host's job — it owns the module cache, the watcher and the sandbox — and keeping that out
71
+ * of here means this function is pure and testable, and that the SDK is not quietly a
72
+ * module loader.
73
+ * @experimental
74
+ */
75
+ export declare function devOverlay(extension: Extension, entry: string, now: number): DevOverlay;
76
+ /** @experimental */
77
+ export type ChangeKind = 'type-added' | 'type-removed' | 'type-changed' | 'pipeline-added' | 'pipeline-removed' | 'pipeline-changed' | 'component-changed' | 'binding-changed';
78
+ /** @experimental */
79
+ export interface Change {
80
+ kind: ChangeKind;
81
+ id: string;
82
+ /** Whether this change may be applied while runs are in flight. */
83
+ hot: boolean;
84
+ note?: string;
85
+ }
86
+ /** @experimental */
87
+ export interface ReloadPlan {
88
+ changes: Change[];
89
+ /** Applied immediately. */
90
+ hot: Change[];
91
+ /** Held until the runs below finish. */
92
+ deferred: Change[];
93
+ blockedBy: string[];
94
+ summary: string;
95
+ }
96
+ /**
97
+ * Diff two overlays and decide what may be applied now.
98
+ *
99
+ * The interesting judgement is which changes are hot. A **binding** may be swapped freely
100
+ * between runs — that is the whole point of the loop a developer is in. A **type's ports**
101
+ * may not be swapped while a run is using it, because the run's edges were validated against
102
+ * the old shape and the executor would be moving a value into a port that no longer accepts
103
+ * it. A **pipeline document** may not change mid-run for the same reason its version exists.
104
+ *
105
+ * Components are always hot: they render, they do not participate in a run, and a developer
106
+ * iterating on a message renderer should never be told to wait.
107
+ * @experimental
108
+ */
109
+ export declare function reloadPlan(prev: DevOverlay, next: DevOverlay, inFlight?: ReadonlyArray<{
110
+ runId: string;
111
+ specId: string;
112
+ typeIds: string[];
113
+ }>): ReloadPlan;
114
+ /**
115
+ * What a dev overlay must never do. Exported as data so the host can assert it rather than
116
+ * remember it — the persistence rule is the one that silently stops being true.
117
+ * @experimental
118
+ */
119
+ export declare const DEV_INVARIANTS: readonly [{
120
+ readonly id: 'D1';
121
+ readonly rule: 'a dev overlay writes no rows';
122
+ readonly breaks: 'a dev plugin whose rows outlive the session leaves chats pinning types with no install to uninstall';
123
+ }, {
124
+ readonly id: 'D2';
125
+ readonly rule: 'permissions are compiled and double-checked identically';
126
+ readonly breaks: 'dev mode would become a way to hold permissions the manifest never declared (F28)';
127
+ }, {
128
+ readonly id: 'D3';
129
+ readonly rule: "every receipt records source: 'dev'";
130
+ readonly breaks: '"it worked on my machine" stops being distinguishable from "it worked"';
131
+ }, {
132
+ readonly id: 'D4';
133
+ readonly rule: 'no in-flight run changes underneath itself';
134
+ readonly breaks: 'a receipt claims to describe a run of a specific spec version, and that claim becomes false';
135
+ }];
136
+ //# sourceMappingURL=dev.d.ts.map
package/dist/dev.js ADDED
@@ -0,0 +1,161 @@
1
+ /**
2
+ * Dev mode: point at an entry file, load it in memory, hot reload (13 §11).
3
+ *
4
+ * ## The collision, stated before it is resolved
5
+ *
6
+ * F6 says **core imports documents, never authoring JS**, and 04 §5a says nothing is
7
+ * discovered by executing. A dev loader that evaluates `src/index.ts` and pulls pipelines,
8
+ * hooks and components out of memory looks exactly like the thing both rules forbid.
9
+ *
10
+ * It is not, and the distinction is worth being precise about rather than waving at.
11
+ *
12
+ * **What F6 protects is the *importer*.** The claim it makes is that no code path reachable
13
+ * from installing or running a plugin evaluates authoring JavaScript — so a malicious
14
+ * document cannot become a malicious program, and a plugin cannot announce capabilities at
15
+ * runtime that its manifest did not declare. That claim survives here, because the dev
16
+ * loader does not hand core an `Extension`. It **compiles** — same packager, same manifest,
17
+ * same documents — and hands core the same plain data an installed plugin does. The
18
+ * evaluation happens in the dev harness, on the developer's own machine, on their own code,
19
+ * exactly as it does inside `serene-pub build`.
20
+ *
21
+ * So the rule that actually holds is narrower and truer than "core never evaluates JS":
22
+ *
23
+ * > **Every path into core carries a manifest and documents. Dev mode changes where they
24
+ * > were produced, not what core receives.**
25
+ *
26
+ * Three constraints follow, and they are not negotiable if the loader is to stay honest:
27
+ *
28
+ * 1. **Memory only.** A dev overlay never writes `pipeline_definition_registry`, spec or preset rows. A dev
29
+ * plugin whose rows outlived the session would leave a user's chats pinning types that no
30
+ * longer exist — a broken install with no install to uninstall.
31
+ * 2. **Permissions are compiled and enforced identically.** Dev mode changes the source of
32
+ * the code, never the trust in it. The runtime double-check (F28) does not know or care
33
+ * that a plugin came from a file path.
34
+ * 3. **Provenance is recorded.** Every run from a dev-loaded plugin marks its receipt
35
+ * `source: 'dev'`, because "it worked on my machine" needs to be distinguishable in the
36
+ * record from "it worked."
37
+ *
38
+ * ## Hot reload has one hard rule
39
+ *
40
+ * **An in-flight run never changes underneath itself.** A receipt claims to describe a run
41
+ * of a specific spec version; swapping a node's implementation halfway through makes that
42
+ * claim false, and a receipt that lies is worse than no receipt. So a reload that touches
43
+ * anything a running pipeline is using is *deferred*, not applied — and `reloadPlan` says
44
+ * which runs are holding it up, so the developer sees "waiting on 1 run" rather than
45
+ * silence.
46
+ */
47
+ import { compile } from './document.js';
48
+ import { bindingsOf, handlersOf } from './extension.js';
49
+ import { snapshotRegistry } from './registry.js';
50
+ /**
51
+ * Build the in-memory overlay for a loaded extension.
52
+ *
53
+ * Deliberately takes an already-evaluated `Extension` rather than a path: *loading* is the
54
+ * host's job — it owns the module cache, the watcher and the sandbox — and keeping that out
55
+ * of here means this function is pure and testable, and that the SDK is not quietly a
56
+ * module loader.
57
+ * @experimental
58
+ */
59
+ export function devOverlay(extension, entry, now) {
60
+ return {
61
+ slug: extension.slug,
62
+ version: extension.version,
63
+ entry,
64
+ types: snapshotRegistry(handlersOf(extension).map((h) => h.type), { owner: extension.slug, release: 'dev' }),
65
+ documents: (extension.pipelines ?? []).map(compile),
66
+ bindings: bindingsOf(extension),
67
+ components: extension.components ?? [],
68
+ source: 'dev',
69
+ loadedAt: now,
70
+ };
71
+ }
72
+ /**
73
+ * Diff two overlays and decide what may be applied now.
74
+ *
75
+ * The interesting judgement is which changes are hot. A **binding** may be swapped freely
76
+ * between runs — that is the whole point of the loop a developer is in. A **type's ports**
77
+ * may not be swapped while a run is using it, because the run's edges were validated against
78
+ * the old shape and the executor would be moving a value into a port that no longer accepts
79
+ * it. A **pipeline document** may not change mid-run for the same reason its version exists.
80
+ *
81
+ * Components are always hot: they render, they do not participate in a run, and a developer
82
+ * iterating on a message renderer should never be told to wait.
83
+ * @experimental
84
+ */
85
+ export function reloadPlan(prev, next, inFlight = []) {
86
+ const changes = [];
87
+ const prevTypes = new Map(prev.types.map((t) => [`${t.id}@${t.version}`, t]));
88
+ const nextTypes = new Map(next.types.map((t) => [`${t.id}@${t.version}`, t]));
89
+ for (const [id, t] of nextTypes)
90
+ if (!prevTypes.has(id))
91
+ changes.push({ kind: 'type-added', id, hot: true, note: 'nothing can be using it yet' });
92
+ else if (JSON.stringify(prevTypes.get(id).ports) !== JSON.stringify(t.ports))
93
+ changes.push({
94
+ kind: 'type-changed',
95
+ id,
96
+ hot: false,
97
+ note: 'ports moved; a run validated against the old shape would be moving a value into a port that no longer accepts it',
98
+ });
99
+ for (const id of prevTypes.keys())
100
+ if (!nextTypes.has(id))
101
+ changes.push({ kind: 'type-removed', id, hot: false, note: 'a run may be mid-node' });
102
+ const prevDocs = new Map(prev.documents.map((d) => [d.id, d]));
103
+ const nextDocs = new Map(next.documents.map((d) => [d.id, d]));
104
+ for (const [id, d] of nextDocs)
105
+ if (!prevDocs.has(id))
106
+ changes.push({ kind: 'pipeline-added', id, hot: true });
107
+ else if (JSON.stringify(prevDocs.get(id)) !== JSON.stringify(d))
108
+ changes.push({ kind: 'pipeline-changed', id, hot: false, note: 'a receipt names the spec version it ran' });
109
+ for (const id of prevDocs.keys())
110
+ if (!nextDocs.has(id))
111
+ changes.push({ kind: 'pipeline-removed', id, hot: false });
112
+ for (const key of Object.keys(next.bindings))
113
+ if (key in prev.bindings && next.bindings[key] !== prev.bindings[key])
114
+ changes.push({ kind: 'binding-changed', id: key, hot: true, note: 'swapped between runs — this is the loop' });
115
+ const prevC = new Map((prev.components ?? []).map((c) => [c.slug, JSON.stringify(c)]));
116
+ for (const c of next.components ?? [])
117
+ if (prevC.get(c.slug) !== JSON.stringify(c))
118
+ changes.push({ kind: 'component-changed', id: c.slug, hot: true, note: 'components render; they do not participate in a run' });
119
+ // A cold change is only actually blocked if something is using the thing it touches.
120
+ const touching = (c) => inFlight.filter((r) => r.specId === c.id || r.typeIds.some((t) => c.id.startsWith(t))).map((r) => r.runId);
121
+ const deferred = changes.filter((c) => !c.hot && touching(c).length > 0);
122
+ const blockedBy = [...new Set(deferred.flatMap(touching))];
123
+ const hot = changes.filter((c) => c.hot || !deferred.includes(c));
124
+ return {
125
+ changes,
126
+ hot,
127
+ deferred,
128
+ blockedBy,
129
+ summary: deferred.length
130
+ ? `${hot.length} applied, ${deferred.length} waiting on ${blockedBy.length} run(s): ${blockedBy.join(', ')}`
131
+ : `${hot.length} applied`,
132
+ };
133
+ }
134
+ /**
135
+ * What a dev overlay must never do. Exported as data so the host can assert it rather than
136
+ * remember it — the persistence rule is the one that silently stops being true.
137
+ * @experimental
138
+ */
139
+ export const DEV_INVARIANTS = [
140
+ {
141
+ id: 'D1',
142
+ rule: 'a dev overlay writes no rows',
143
+ breaks: 'a dev plugin whose rows outlive the session leaves chats pinning types with no install to uninstall',
144
+ },
145
+ {
146
+ id: 'D2',
147
+ rule: 'permissions are compiled and double-checked identically',
148
+ breaks: 'dev mode would become a way to hold permissions the manifest never declared (F28)',
149
+ },
150
+ {
151
+ id: 'D3',
152
+ rule: "every receipt records source: 'dev'",
153
+ breaks: '"it worked on my machine" stops being distinguishable from "it worked"',
154
+ },
155
+ {
156
+ id: 'D4',
157
+ rule: 'no in-flight run changes underneath itself',
158
+ breaks: 'a receipt claims to describe a run of a specific spec version, and that claim becomes false',
159
+ },
160
+ ];
161
+ //# sourceMappingURL=dev.js.map
@@ -0,0 +1,202 @@
1
+ /**
2
+ * Document compilation (04 §5a, F3, F6).
3
+ *
4
+ * The builder chain is an *authoring format only*. SP imports the document and
5
+ * never the JS — there is no importer path that evaluates a builder chain.
6
+ *
7
+ * Edges are derived here, 1:1 with pipeline_edges rows: the linear chain carries a
8
+ * default edge, and every $ref becomes an explicit one.
9
+ */
10
+ import type { BuiltSpec } from './builder.js';
11
+ import { type ConnectionRequirement } from './connections.js';
12
+ import type { I18n } from './i18n.js';
13
+ /** @experimental */
14
+ export interface DocEdge {
15
+ from: string;
16
+ fromPort: string;
17
+ to: string;
18
+ toPort: string;
19
+ shape?: string;
20
+ streaming?: boolean;
21
+ /** true when derived from chain order rather than an explicit $ref */
22
+ implicit?: boolean;
23
+ }
24
+ /** @experimental */
25
+ export interface DocNode {
26
+ key: string;
27
+ kind: string;
28
+ definitionId: string;
29
+ definitionVersion: number;
30
+ config: Record<string, unknown>;
31
+ clauseId?: string;
32
+ clauseKind?: string;
33
+ clauseChain?: string;
34
+ position: number;
35
+ /** Config references resolved at publish and stored explicitly (16 §5b-i). */
36
+ resolvedRefs?: Record<string, string>;
37
+ /**
38
+ * What the node shows beyond the admin panel — the session-settings mark
39
+ * (PLAN-turn-order §4.11, R28), the streaming step and the step status
40
+ * (lair pass B3/B18, 2026-09-27), and the step label and step purpose
41
+ * the settings name it by (2026-09-30) — see `BuiltNode.expose`. Present
42
+ * only when stated.
43
+ */
44
+ expose?: {
45
+ session?: boolean;
46
+ swaps?: string[];
47
+ stream?: true;
48
+ status?: I18n;
49
+ label?: I18n;
50
+ purpose?: I18n;
51
+ };
52
+ }
53
+ /** @experimental */
54
+ export interface SpecDocument {
55
+ schemaVersion: 1;
56
+ id: string;
57
+ version: string;
58
+ /** The genre declaration a create pipeline carries (24 §3). */
59
+ genre?: unknown;
60
+ /** Contributed surfaces (19 §3–§4) — content like `genre`, hashed with the document. */
61
+ contributes?: unknown;
62
+ /** Catalogue claims (ruled 2026-08-27) — content like the two above, hashed with the document. */
63
+ taxonomy?: unknown;
64
+ /**
65
+ * The usage lock (24 §4): { genre, event } the inlet declared. Hashed with
66
+ * the document. **The only subscription** (R-4) — `subscribes` was deleted
67
+ * 2026-09-16 with `.on()`.
68
+ */
69
+ input?: {
70
+ genre?: string;
71
+ event?: string;
72
+ events?: string[];
73
+ };
74
+ includes: Array<{
75
+ key: string;
76
+ fragmentId: string;
77
+ }>;
78
+ /** Author-shipped presets. Execution-affecting, so they round-trip (F4). */
79
+ presets: BuiltSpec['presets'];
80
+ nodes: DocNode[];
81
+ edges: DocEdge[];
82
+ clauses: BuiltSpec['clauses'];
83
+ }
84
+ /** A clause's own ports; a junction's fired-branch ports never shadow them (M4). @experimental */
85
+ export declare const JUNCTION_CLAUSE_PORTS: ReadonlySet<string>;
86
+ /**
87
+ * A junction's branch-end nodes (M4): the last node of each chain, by
88
+ * position. What a junction publishes beyond its clause ports is read off
89
+ * these.
90
+ * @experimental
91
+ */
92
+ export declare function junctionBranchEnds(nodes: ReadonlyArray<{
93
+ key: string;
94
+ clauseId?: string;
95
+ clauseChain?: string;
96
+ position: number;
97
+ definitionId: string;
98
+ definitionVersion: number;
99
+ }>, clause: {
100
+ id: string;
101
+ chains: string[];
102
+ }, clauses?: ReadonlyArray<{
103
+ id: string;
104
+ clauseId?: string;
105
+ clauseChain?: string;
106
+ position: number;
107
+ }>): Array<{
108
+ chain: string;
109
+ node?: {
110
+ key: string;
111
+ definitionId: string;
112
+ definitionVersion: number;
113
+ };
114
+ }>;
115
+ /**
116
+ * Compile a built spec to the document a host stores. A document that is
117
+ * already compiled (a helper such as `turnOrderSpec()` returns one) comes back
118
+ * as a copy, so a list of pipelines can hold either; one written for another
119
+ * document schema is refused. Its graph checks are the host's publish
120
+ * `validate()`, which every stored document meets.
121
+ * @experimental
122
+ */
123
+ export declare function compile(built: BuiltSpec | SpecDocument): SpecDocument;
124
+ /**
125
+ * Follow the spine forward from `fromKey` to the first oracle. Linearity is what
126
+ * makes this well-defined (F25). Ambiguity or absence is a publish error that names
127
+ * the candidates — the teaching-error pattern (15 §1.3).
128
+ * @experimental
129
+ */
130
+ export declare function resolveDownstreamOracle(built: BuiltSpec, fromKey: string): string;
131
+ /**
132
+ * Canonical form — stable key order, for hashing and round-trip identity (F3).
133
+ *
134
+ * The sort and the digest below moved to `hash.ts` unchanged, because the type
135
+ * registries now need the same two and a document and a declaration must not
136
+ * disagree about what identical content is. Same bytes in, same string out.
137
+ * @experimental
138
+ */
139
+ export declare function canonical(doc: SpecDocument): string;
140
+ /** Cheap deterministic content hash — stands in for the real canonical_hash (02 §3). @experimental */
141
+ export declare function canonicalHash(doc: SpecDocument): string;
142
+ /** Import: document → the same in-memory form. `import(export(x))` is identity (F3). @experimental */
143
+ export declare function importDocument(doc: SpecDocument): SpecDocument;
144
+ /** @experimental */
145
+ export interface ExportOptions {
146
+ /**
147
+ * Which presets travel. The app lets a user choose; SDK compile has no instance to
148
+ * choose from, so it ships everything the author wrote.
149
+ */
150
+ presets?: 'all' | 'none' | string[];
151
+ /**
152
+ * How preset bindings travel — the same explicit fork pipeline export already offers
153
+ * (02 §6), never decided silently.
154
+ *
155
+ * - `base` keeps `$ref` references by slug. Portable only where the target is itself a
156
+ * seeded, slugged row; a reference to something a user made locally resolves to
157
+ * nothing on the far side.
158
+ * - `flattened` inlines the values. Always portable, and it forks the config — the
159
+ * importing instance can no longer swap the named thing in one place.
160
+ */
161
+ bindings?: 'base' | 'flattened';
162
+ /** Resolve a `$ref` when flattening. Absent values are dropped and reported. */
163
+ resolve?: (slot: string, ref: string) => unknown;
164
+ }
165
+ /** @experimental */
166
+ export interface ExportResult {
167
+ doc: SpecDocument;
168
+ /** What did not travel, and why — so an export is never quietly lossy. */
169
+ omitted: Array<{
170
+ what: string;
171
+ reason: string;
172
+ }>;
173
+ /**
174
+ * Every connection the importing instance must wire, derived from the types rather
175
+ * than from what this instance happened to have configured (13 §10a). Complete even
176
+ * when the exporter never set one up.
177
+ */
178
+ requires: ConnectionRequirement[];
179
+ }
180
+ /**
181
+ * Export a document, with the presets a user selected (12 §7).
182
+ *
183
+ * **A filtered export is a different document, not a lossy copy of the same one**, so its
184
+ * canonical hash legitimately differs from the source's. F3's identity law is about a
185
+ * given export round-tripping — `import(export(x)) === export(x)` — and that still holds
186
+ * exactly.
187
+ * @experimental
188
+ */
189
+ export declare function exportDocument(doc: SpecDocument, opts?: ExportOptions): ExportResult;
190
+ /**
191
+ * The envoy config addresses a document references — every `resolvedRefs`
192
+ * target spelled `envoy:<key>`, once each. The executor resolves config for
193
+ * these beside the nodes and clauses; the host projects the genre's
194
+ * declaration at exactly these keys.
195
+ * @internal
196
+ */
197
+ export declare function envoyConfigKeysOf(doc: {
198
+ nodes: ReadonlyArray<{
199
+ resolvedRefs?: Record<string, string>;
200
+ }>;
201
+ }): string[];
202
+ //# sourceMappingURL=document.d.ts.map