@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
@@ -0,0 +1,794 @@
1
+ /**
2
+ * The checks a package's declarations get, whichever surface declared them (D-1).
3
+ *
4
+ * A package says the same things in two places. `announce()` collects them as a
5
+ * builder and compiles the announcement document; `defineExtension()` carries
6
+ * them as literals the packager reads without executing the author's code. Both
7
+ * are declaring one package, so both get **one set of checks** — the functions
8
+ * here — rather than two that drift and answer the same mistake with two
9
+ * different sentences.
10
+ *
11
+ * Every function returns findings rather than throwing, because the caller owns
12
+ * the refusal: `announce()` collects them into an `AnnouncementError` with the
13
+ * coverage report attached, `defineExtension()` into an `ExtensionError`, and
14
+ * the packager into `CompileFinding`s with a file and a line. A thrown error
15
+ * would let the first mistake hide the other nine.
16
+ *
17
+ * What is deliberately NOT here: the pipeline-namespace rule, which both
18
+ * callers already enforce in their own words (one names the package namespace,
19
+ * the other the plugin slug), and the identity display text, which only an
20
+ * announcement has.
21
+ */
22
+ import { coreWidgetIds, widgetReadsFindings } from './widgetDecls.js';
23
+ import { COMPONENT_FRAMEWORKS } from './extension.js';
24
+ import { CONVERSATION_WIDGET_ID, TURN_ORDER_CHANGED_IS_INTERNAL, sessionEvents } from './genres.js';
25
+ import { drawnWidgetIds, validateSessionLayout, widgetOfInstance } from './sessionLayout.js';
26
+ import { eventsLockFindings, getDefinition, swapFitFinding } from './descriptors.js';
27
+ import { eventById, isEventId, notADeclaredEvent } from './events.js';
28
+ import { actionDocumentFindings, actionsOf, slashCollisions } from './actions.js';
29
+ import { isTodo } from './values.js';
30
+ import { isServableEntry } from './surfaces.js';
31
+ import { i18nFindings } from './i18n.js';
32
+ import { annexDeclarationOf, annexStepFindings } from './annexFields.js';
33
+ /** The stored form of a contribution — the spec and the pin read down to their ids. @experimental */
34
+ export const storedSwap = (c) => ({
35
+ // Read defensively: a JS modder's entry may name nothing at all, and the
36
+ // checks below say so in a sentence rather than a TypeError.
37
+ spec: typeof c?.spec === 'string' ? c.spec : (c?.spec?.id ?? ''),
38
+ node: c?.node,
39
+ definition: typeof c?.definition === 'string' ? c.definition : (c?.definition?.id ?? ''),
40
+ });
41
+ /**
42
+ * Swaps as authored: the spec is a value and the definition a pin. A
43
+ * string is refused here, at the entry — the shared pass below also reads the
44
+ * stored form, where both are rightly ids. With a spec value, the node key is
45
+ * checked against the spec's nodes.
46
+ * @experimental
47
+ */
48
+ export function swapInputFindings(swaps) {
49
+ const out = [];
50
+ for (const c of swaps) {
51
+ const { spec, node, definition } = storedSwap(c);
52
+ if (typeof c?.spec === 'string')
53
+ out.push(`swap names the spec '${spec}' as a string — pass the spec value, or use('${spec}') for one you cannot import`);
54
+ if (typeof c?.definition === 'string')
55
+ out.push(`swap onto '${spec}#${node}' names the definition '${definition}' as a string — pass its pin`);
56
+ const known = c?.spec && typeof c.spec === 'object' && 'nodes' in c.spec ? c.spec : undefined;
57
+ const target = known
58
+ ? known.nodes.find((n) => n.key === node)
59
+ : undefined;
60
+ if (known && node && !target)
61
+ out.push(`swap names node '${node}', which '${spec}' does not have`);
62
+ // The fit, now — including R53's refusal for a node that uses a
63
+ // connection — rather than first at install, when both are known here.
64
+ const pinned = definitionOfNode(target);
65
+ const offered = definition ? getDefinition(definition) : undefined;
66
+ const misfit = pinned && offered && swapFitFinding(node, pinned, offered);
67
+ if (misfit)
68
+ out.push(misfit);
69
+ }
70
+ return out;
71
+ }
72
+ /** A definition id as a swap must name one: `ns:kind/name@N`. */
73
+ const DEFINITION_ID = /^[a-z0-9]+(?:[.-][a-z0-9]+)*:[a-z]+\/[a-z0-9]+(?:-[a-z0-9]+)*@\d+$/;
74
+ /**
75
+ * Swap contributions (R29): a package offers only its own definitions, never
76
+ * on its own specs (those list swaps on the node with `expose.swaps` — one
77
+ * way to do each thing, R26), and each once.
78
+ * @experimental
79
+ */
80
+ export function swapContributionFindings(swaps, ns, declaredSpecs) {
81
+ const out = [];
82
+ const seen = new Set();
83
+ for (const c of swaps) {
84
+ const { spec, node, definition } = storedSwap(c);
85
+ if (!spec?.includes(':spec/'))
86
+ out.push(`swap names spec '${spec}', which is not a spec id`);
87
+ if (!node)
88
+ out.push(`swap onto '${spec}' names no node`);
89
+ if (!DEFINITION_ID.test(definition)) {
90
+ out.push(`swap onto '${spec}#${node}' names definition '${definition}', which is not a pinned id ('ns:kind/name@N') — pass the pin`);
91
+ continue;
92
+ }
93
+ const owner = definition.slice(0, definition.indexOf(':'));
94
+ if (owner !== ns)
95
+ out.push(`swap '${definition}' is owned by '${owner}' — a package contributes its own definitions`);
96
+ if (declaredSpecs.has(spec) || spec.startsWith(`${ns}:`))
97
+ out.push(`'${spec}' is this package's own spec — list the swap on its node with expose.swaps, not as a contribution`);
98
+ const key = `${spec}#${node}#${definition}`;
99
+ if (seen.has(key))
100
+ out.push(`contributes '${definition}' to '${spec}#${node}' twice`);
101
+ seen.add(key);
102
+ }
103
+ return out;
104
+ }
105
+ /**
106
+ * The display text of one labelled declaration (R-20): `label` is required
107
+ * — a config, a preset and a prompt are all listed by it — `description` is
108
+ * not.
109
+ * @experimental
110
+ */
111
+ export function labelFindings(at, meta) {
112
+ return [
113
+ ...i18nFindings(meta.label, `${at}.label`, { required: true }),
114
+ ...i18nFindings(meta.description, `${at}.description`),
115
+ ];
116
+ }
117
+ /**
118
+ * A package declares only its own genres. Referencing another's is done from a
119
+ * spec's input binding, which is a reference rather than a claim of ownership.
120
+ * @experimental
121
+ */
122
+ export function genreOwnershipFindings(genres, ns) {
123
+ const out = [];
124
+ for (const decl of genres) {
125
+ const owner = decl.id.slice(0, decl.id.indexOf(':'));
126
+ if (owner !== ns)
127
+ out.push(`genre '${decl.id}' is owned by '${owner}' — a package declares only its own ` +
128
+ `genres; referencing another's is done from a spec's input binding`);
129
+ }
130
+ return out;
131
+ }
132
+ /** A spec's nodes, built or compiled — both carry `nodes` with `definitionId` and `definitionVersion`. */
133
+ const nodesOf = (s) => s.nodes;
134
+ /** The registered definition a node seats, when this SDK knows it. */
135
+ const definitionOfNode = (n) => n ? getDefinition(`${n.definitionId}@${n.definitionVersion}`) : undefined;
136
+ /**
137
+ * A compiled document's `expose.swaps` (R28), checked as the builder checks
138
+ * them: known ids that do not fit are refused; ids this SDK does not know are
139
+ * the instance's to check at install.
140
+ * @experimental
141
+ */
142
+ export function exposeSwapFindings(pipelines) {
143
+ const out = [];
144
+ for (const s of pipelines)
145
+ for (const n of nodesOf(s)) {
146
+ const pinned = definitionOfNode(n);
147
+ if (!pinned || !n.expose?.swaps?.length)
148
+ continue;
149
+ for (const id of n.expose.swaps) {
150
+ const swap = getDefinition(id);
151
+ const misfit = swap && swapFitFinding(n.key, pinned, swap);
152
+ if (misfit)
153
+ out.push(`pipeline '${s.id}': ${misfit}`);
154
+ }
155
+ }
156
+ return out;
157
+ }
158
+ /**
159
+ * The input lock (24 §4): a spec that answers a session event names the genre it
160
+ * serves, and the event is one core declares or one this package namespaced.
161
+ * A genre the package does not declare is recorded as a requirement.
162
+ * @experimental
163
+ */
164
+ export function inputLockFindings(pipelines, declaredGenres, ns, requires) {
165
+ const out = [];
166
+ for (const s of pipelines) {
167
+ // One `event`, or several `events` (PLAN-turn-order §4.1): judged alike.
168
+ const locked = lockedEvents(s.input);
169
+ if (!locked.length)
170
+ continue;
171
+ const genreId = s.input?.genre;
172
+ if (!genreId) {
173
+ // The builder refuses this at authoring time; a hand-built
174
+ // document gets the same answer here.
175
+ out.push(`pipeline '${s.id}' answers '${locked.join(', ')}' with no genre (24 §4)`);
176
+ continue;
177
+ }
178
+ if (!declaredGenres.has(genreId))
179
+ requires.add(genreId);
180
+ // Core's events, and the events packages declared: a lock on anything
181
+ // else would compile on an event nothing can cause.
182
+ for (const event of locked) {
183
+ if (!eventById(event))
184
+ out.push(`pipeline '${s.id}': ${notADeclaredEvent(event)}`);
185
+ else if (event === sessionEvents.turnOrderChanged)
186
+ out.push(`pipeline '${s.id}': ${TURN_ORDER_CHANGED_IS_INTERNAL}`);
187
+ }
188
+ // The builder checks an `events` lock against its inlet (R33); a
189
+ // compiled document handed in directly gets the same sentence here,
190
+ // wherever the inlet's definition is known to this SDK.
191
+ if (s.input?.events?.length) {
192
+ const inlet = definitionOfNode(nodesOf(s)[0]);
193
+ if (inlet)
194
+ for (const f of eventsLockFindings(inlet, s.input.events))
195
+ out.push(`pipeline '${s.id}': ${f}`);
196
+ }
197
+ }
198
+ return out;
199
+ }
200
+ /**
201
+ * The events an inlet lock answers: the one `event`, or the `events` list
202
+ * (PLAN-turn-order §4.1) — as one list, so every reader of the lock asks
203
+ * one question. Empty for a spec with no lock.
204
+ * @experimental
205
+ */
206
+ export function lockedEvents(input) {
207
+ if (!input)
208
+ return [];
209
+ if (input.events?.length)
210
+ return [...input.events];
211
+ return input.event ? [input.event] : [];
212
+ }
213
+ /** Does this lock answer `event` — as its one `event`, or one of its `events`? @experimental */
214
+ export const lockAnswers = (input, event) => lockedEvents(input).includes(event);
215
+ /** Exactly one create pipeline per declared genre (24 §3). @experimental */
216
+ export function createPipelineFindings(genres, pipelines) {
217
+ const out = [];
218
+ for (const g of genres) {
219
+ const creates = pipelines.filter((s) => s.input?.genre === g.id && s.input?.event === sessionEvents.sessionCreated);
220
+ if (creates.length === 0)
221
+ out.push(`genre '${g.id}' has no create pipeline — every genre needs exactly one ` +
222
+ `spec answering '${sessionEvents.sessionCreated}' (24 §3)`);
223
+ if (creates.length > 1)
224
+ out.push(`genre '${g.id}' has ${creates.length} create pipelines ` +
225
+ `(${creates.map((s) => s.id).join(', ')}) — exactly one (24 §3)`);
226
+ }
227
+ return out;
228
+ }
229
+ /**
230
+ * **A custom pipeline must include a default preset** (owner ruling,
231
+ * 2026-10-02, notes 27/28). The Pipelines view is Genre → Preset →
232
+ * pipelines, and a genre's pipelines are reached only through a session
233
+ * preset: a package that declares a genre and no preset for it ships
234
+ * pipelines nobody can start a session on or find under their genre. The
235
+ * first preset a package declares for its genre is the one an instance makes
236
+ * that genre's default when it has none (`registrySync`); a package that
237
+ * contributes to another package's genre needs none of its own.
238
+ * @experimental
239
+ */
240
+ export function genrePresetFindings(genres, presets) {
241
+ const out = [];
242
+ for (const g of genres) {
243
+ if (presets.some((p) => p.genre === g.id))
244
+ continue;
245
+ out.push(`genre '${g.id}' has no preset — a custom pipeline must include a default preset: ` +
246
+ `declare a preset() for this genre binding its pipelines, so sessions can start ` +
247
+ `on it and the Pipelines view lists them under it (the first one is the genre's default)`);
248
+ }
249
+ return out;
250
+ }
251
+ /**
252
+ * Contributed actions (R-15, U5c): each declaration sound, and one slash name
253
+ * meaning one function across the whole package — the per-document check cannot
254
+ * see two specs of one package claiming `/acme.roll` for two different things,
255
+ * so the package is the first place the collision rule runs across documents;
256
+ * the install is the second.
257
+ * @experimental
258
+ */
259
+ export function contributedActionFindings(pipelines) {
260
+ const out = [];
261
+ const packageActions = [];
262
+ for (const s of pipelines) {
263
+ // A built spec keeps its contributions on `meta`; a document carries
264
+ // them at the top — one reader for both.
265
+ const contributed = { id: s.id, contributes: 'meta' in s ? s.meta.contributes : s.contributes };
266
+ for (const finding of actionDocumentFindings(contributed))
267
+ out.push(`pipeline '${s.id}': ${finding}`);
268
+ packageActions.push(...actionsOf(contributed));
269
+ }
270
+ out.push(...slashCollisions(packageActions));
271
+ return out;
272
+ }
273
+ /**
274
+ * Prompts: slugs unique per POOL, which is `(node type, slot)`.
275
+ *
276
+ * Uniqueness is per pool and not global: `summarize-scene-default` names a row
277
+ * in the batch, synth and naming pools, and they are three different prompts
278
+ * that happen to have been split out of one bundle.
279
+ *
280
+ * A prompt for a node this package does not announce is deliberately NOT
281
+ * recorded as a requirement. It is the whole point of node scoping that a
282
+ * package may ship prose for somebody else's node, and a node type is neither a
283
+ * genre nor a spec slug — the only two shapes an instance can check. Listing one
284
+ * would make every install fail permanently on a requirement nothing can ever
285
+ * satisfy, where the real failure mode is mild and self-announcing: the row
286
+ * seeds into a pool no installed pipeline offers, and is simply never shown.
287
+ * @experimental
288
+ */
289
+ export function promptFindings(prompts) {
290
+ const out = [];
291
+ const seen = new Set();
292
+ for (const pr of prompts) {
293
+ out.push(...i18nFindings(pr.label, `prompt '${pr.slug}'.label`, { required: true }));
294
+ const pool = `${pr.nodeType}#${pr.slot}`;
295
+ const key = `${pool}#${pr.slug}`;
296
+ if (seen.has(key))
297
+ out.push(`duplicate prompt '${pr.slug}' for '${pool}'`);
298
+ seen.add(key);
299
+ }
300
+ return out;
301
+ }
302
+ /** Configs: node keys verified for declared specs; slugs unique per spec. @experimental */
303
+ export function configFindings(configs, declaredSpecs, requires) {
304
+ const out = [];
305
+ const seen = new Set();
306
+ for (const c of configs) {
307
+ out.push(...labelFindings(`config '${c.slug}'`, c));
308
+ const key = `${c.spec}#${c.slug}`;
309
+ if (seen.has(key))
310
+ out.push(`duplicate config '${c.slug}' for '${c.spec}'`);
311
+ seen.add(key);
312
+ const target = declaredSpecs.get(c.spec);
313
+ if (!target) {
314
+ requires.add(c.spec);
315
+ continue;
316
+ }
317
+ for (const nodeKey of Object.keys(c.values))
318
+ if (!target.nodes.some((n) => n.key === nodeKey))
319
+ out.push(`config '${c.slug}' for '${c.spec}' addresses unknown node '${nodeKey}'`);
320
+ }
321
+ return out;
322
+ }
323
+ /** Presets: validated against the genre's event surface, with the coverage (24 §7). @experimental */
324
+ export function presetFindings(presets, declaredGenres, declaredSpecs, configs, requires) {
325
+ const errors = [];
326
+ const coverage = [];
327
+ for (const p of presets) {
328
+ errors.push(...labelFindings(`preset '${p.slug}'`, p));
329
+ const g = declaredGenres.get(p.genre);
330
+ if (!g)
331
+ requires.add(p.genre);
332
+ const surface = g
333
+ ? { ...g.events }
334
+ : {};
335
+ // Slots the preset binds beyond the declared surface are errors when
336
+ // the genre is ours to know; recorded when it is not.
337
+ const slots = [];
338
+ const events = new Set([...Object.keys(surface), ...Object.keys(p.bindings)]);
339
+ for (const event of events) {
340
+ const declared = surface[event];
341
+ const binding = p.bindings[event];
342
+ // A binding is keyed by event ID, whoever owns the genre (R-4).
343
+ // A bare name (`message-respond`) is the pre-fold spelling; a
344
+ // package carrying one would have its keys reverted by every
345
+ // boot's preset sync and bind nothing, silently.
346
+ // A binding keyed by an undeclared event — even to a spec another
347
+ // package ships — fills a slot no event can ever reach.
348
+ if (binding && isEventId(event) && !eventById(event)) {
349
+ errors.push(`preset '${p.slug}': ${notADeclaredEvent(event)}`);
350
+ continue;
351
+ }
352
+ if (binding && !isEventId(event)) {
353
+ errors.push(`preset '${p.slug}' binds '${event}', which is not an event id — bindings ` +
354
+ `are keyed 'owner:event/name@N' (sessionEvents.messageRespond is ` +
355
+ `'${sessionEvents.messageRespond}'), never by bare name (R-4)`);
356
+ continue;
357
+ }
358
+ if (g && !declared && binding) {
359
+ errors.push(`preset '${p.slug}' binds '${event}', which genre '${p.genre}' does not declare`);
360
+ continue;
361
+ }
362
+ if (!binding) {
363
+ const required = !!declared?.required;
364
+ if (required)
365
+ errors.push(`preset '${p.slug}' leaves required slot '${event}' of '${p.genre}' unbound`);
366
+ slots.push({
367
+ event,
368
+ required,
369
+ status: required ? 'MISSING' : 'unbound',
370
+ });
371
+ continue;
372
+ }
373
+ const bound = declaredSpecs.get(binding.spec);
374
+ if (!bound) {
375
+ requires.add(binding.spec);
376
+ slots.push({
377
+ event,
378
+ required: !!declared?.required,
379
+ binding,
380
+ status: 'bound-external',
381
+ });
382
+ }
383
+ else {
384
+ if (!lockAnswers(bound.input, event))
385
+ errors.push(`preset '${p.slug}' binds '${bound.id}' to '${event}', but that spec ` +
386
+ `answers '${lockedEvents(bound.input).join(', ') || 'nothing'}' (24 §4)`);
387
+ if (bound.input?.genre !== p.genre)
388
+ errors.push(`preset '${p.slug}' (genre '${p.genre}') binds '${bound.id}', which ` +
389
+ `serves '${bound.input?.genre ?? 'no genre'}' (24 §4)`);
390
+ if (binding.config &&
391
+ !configs.some((c) => c.spec === binding.spec && c.slug === binding.config))
392
+ errors.push(`preset '${p.slug}' names config '${binding.config}' of ` +
393
+ `'${binding.spec}', which this package does not declare`);
394
+ slots.push({
395
+ event,
396
+ required: !!declared?.required,
397
+ binding,
398
+ status: 'bound',
399
+ });
400
+ }
401
+ }
402
+ // Seeded swaps (R40): the shape is checked here; whether the node offers
403
+ // the definition is the instance's to check at create.
404
+ for (const c of p.defaults?.swaps ?? []) {
405
+ const { spec, node, definition } = storedSwap(c);
406
+ if (!spec?.includes(':spec/'))
407
+ errors.push(`preset '${p.slug}' seeds a swap on '${spec}', which is not a spec id`);
408
+ if (!node)
409
+ errors.push(`preset '${p.slug}' seeds a swap onto '${spec}' that names no node`);
410
+ if (!DEFINITION_ID.test(definition))
411
+ errors.push(`preset '${p.slug}' seeds a swap onto '${spec}#${node}' naming '${definition}', which is not a pinned id — pass the pin`);
412
+ // A spec this package declares is checkable here, so a seed that
413
+ // would be refused at every create is refused now instead (R26):
414
+ // the node must offer the definition, and the spec must serve the
415
+ // preset's genre.
416
+ const own = declaredSpecs.get(spec);
417
+ if (own && node) {
418
+ if (own.input?.genre && own.input.genre !== p.genre)
419
+ errors.push(`preset '${p.slug}' (genre '${p.genre}') seeds a swap on '${spec}', which serves '${own.input.genre}'`);
420
+ const n = own.nodes.find((x) => x.key === node);
421
+ const offered = n ? [`${n.definitionId}@${n.definitionVersion}`, ...(n.expose?.swaps ?? [])] : [];
422
+ if (!n)
423
+ errors.push(`preset '${p.slug}' seeds a swap onto '${spec}#${node}', which has no such node`);
424
+ else if (!n.expose?.session)
425
+ errors.push(`preset '${p.slug}' seeds a swap onto '${spec}#${node}', which is not in session settings (expose)`);
426
+ else if (!offered.includes(definition))
427
+ errors.push(`preset '${p.slug}' seeds '${definition}' onto '${spec}#${node}', which offers ${offered.map((o) => `'${o}'`).join(', ')}`);
428
+ }
429
+ }
430
+ // An included action names a spec by its identity's first half; a spec
431
+ // this package does not declare is a requirement on the install.
432
+ for (const a of p.actions?.include ?? []) {
433
+ const hash = a.lastIndexOf('#');
434
+ const specId = hash === -1 ? a : a.slice(0, hash);
435
+ if (!declaredSpecs.has(specId))
436
+ requires.add(specId);
437
+ }
438
+ coverage.push({ preset: p.slug, genre: p.genre, slots });
439
+ }
440
+ return { errors, coverage };
441
+ }
442
+ /**
443
+ * Surfaces: an entry that does not exist at install is a blank panel nobody can
444
+ * debug, so the shape is checked where the author can still fix it. What is *at*
445
+ * the path is the packager's business.
446
+ * @experimental
447
+ */
448
+ export function surfaceFindings(surfaces) {
449
+ const out = [];
450
+ // A frame placed in the session layout is a widget whose component holds
451
+ // an `sp-frame` — never a declaration of its own.
452
+ if (surfaces?.panels !== undefined)
453
+ out.push('surfaces.panels is gone — declare each panel as a widget in `widgets` naming a component, ' +
454
+ 'and place an `sp-frame` inside the component for the document');
455
+ for (const [where, decl] of [
456
+ ['session-view', surfaces?.['session-view']],
457
+ ['page', surfaces?.page],
458
+ ]) {
459
+ if (decl && !decl.entry)
460
+ out.push(`surfaces.${where} has no entry document`);
461
+ else if (decl?.entry && !isServableEntry(decl.entry))
462
+ out.push(`surfaces.${where} entry '${decl.entry}' is not a path a pub will serve`);
463
+ if (decl?.settings !== undefined)
464
+ out.push(`surfaces.${where}.settings is gone — a ${where} frame is handed no declared values; ` +
465
+ 'declare settings on a widget, which its component reads as `ctx.settings`');
466
+ }
467
+ return out;
468
+ }
469
+ /** A component's slug: it names the built module (`components/<slug>.js`), so never a path. @experimental */
470
+ export const COMPONENT_SLUG = /^[a-z][a-z0-9-]*$/;
471
+ /** A component source hash: SHA-256, lowercase hex. */
472
+ const SOURCE_HASH = /^[0-9a-f]{64}$/;
473
+ /**
474
+ * Components (§3.5, R25): one slug, a label, a servable entry and a
475
+ * framework SDK 1.0 ships. There is no mount point on the declaration — a
476
+ * widget names the component, and that is where it mounts.
477
+ * @experimental
478
+ */
479
+ export function componentFindings(components) {
480
+ const out = [];
481
+ const slugs = new Set();
482
+ for (const [i, c] of components.entries()) {
483
+ const at = `component '${c?.slug ?? `components[${i}]`}'`;
484
+ if (!c?.slug)
485
+ out.push(`components[${i}] has no slug — a widget's component names it`);
486
+ else if (!COMPONENT_SLUG.test(c.slug))
487
+ out.push(`component slug '${c.slug}' is lowercase letters, digits and '-' — it names the built module's file`);
488
+ else if (slugs.has(c.slug))
489
+ out.push(`duplicate component slug '${c.slug}' — a widget's component names it`);
490
+ else
491
+ slugs.add(c.slug);
492
+ out.push(...i18nFindings(c?.label, `${at}.label`, { required: true }));
493
+ if (!c?.entry)
494
+ out.push(`${at} has no entry`);
495
+ // `./dist/x.js` is a module path's ordinary spelling; the manifest
496
+ // carries it without the `./` (the CLI strips it).
497
+ else if (!isServableEntry(c.entry.replace(/^\.\//, '')))
498
+ out.push(`${at} entry '${c.entry}' is not a path a pub will serve`);
499
+ if (c?.surface !== undefined)
500
+ out.push(`${at} names a surface point — a component has none now; declare a widget whose ` +
501
+ `\`component\` is '${c.slug}' (R25)`);
502
+ if (c?.basedOn && (typeof c.basedOn.component !== 'string' || typeof c.basedOn.version !== 'string'))
503
+ out.push(`${at}.basedOn is { component, version, sourceHash? } — the upstream a clone was made from`);
504
+ else if (c?.basedOn?.sourceHash !== undefined && !SOURCE_HASH.test(String(c.basedOn.sourceHash)))
505
+ out.push(`${at}.basedOn.sourceHash is the upstream source's SHA-256, 64 lowercase hex digits`);
506
+ // Svelte and vanilla at SDK 1.0 (R35); the seam takes more later.
507
+ if (c?.framework && !COMPONENT_FRAMEWORKS.includes(c.framework))
508
+ out.push(['react', 'preact'].includes(c.framework)
509
+ ? `component '${c.slug}' declares framework '${c.framework}', which arrives after SDK 1.0 — ` +
510
+ `use ${COMPONENT_FRAMEWORKS.map((f) => `'${f}'`).join(' or ')}`
511
+ : `component '${c.slug}' declares framework '${c.framework}', which is not a component ` +
512
+ `framework — SDK 1.0 ships ${COMPONENT_FRAMEWORKS.map((f) => `'${f}'`).join(' and ')}`);
513
+ }
514
+ return out;
515
+ }
516
+ /**
517
+ * A package's widgets name its own components (R25): every genre panel with
518
+ * a `component` must name a `ComponentDecl` this package declares — a plugin
519
+ * cannot mount core's or another plugin's component by slug.
520
+ * @experimental
521
+ */
522
+ export function widgetComponentFindings(genres, components) {
523
+ const declared = new Set(components.map((c) => c?.slug).filter(Boolean));
524
+ const out = [];
525
+ for (const g of genres)
526
+ for (const w of g.shape?.panels ?? []) {
527
+ if (typeof w?.component !== 'string')
528
+ continue;
529
+ if (!declared.has(w.component))
530
+ out.push(`${g.id} panel '${w.id}' names component '${w.component}', which this package ` +
531
+ `does not declare — add it to \`components\``);
532
+ }
533
+ return out;
534
+ }
535
+ /**
536
+ * A package's widgets (R71): each names a component the package declares
537
+ * (core's own widgets name core components — a plugin's cannot), and each id
538
+ * is unique in the package, because the package's namespace plus the id is
539
+ * the id every layout row keys on.
540
+ * @experimental
541
+ */
542
+ export function packageWidgetFindings(widgets, components) {
543
+ const declared = new Set(components.map((c) => c?.slug).filter(Boolean));
544
+ const out = [];
545
+ const ids = new Set();
546
+ for (const w of widgets) {
547
+ if (ids.has(w?.id))
548
+ out.push(`two widgets are '${w?.id}' — a widget id names one`);
549
+ ids.add(w?.id);
550
+ if (coreWidgetIds().has(w?.id))
551
+ out.push(`widget '${w.id}' is core's widget's id — a layout names core's and yours by bare id, so choose another`);
552
+ if (typeof w?.component === 'string' && !declared.has(w.component))
553
+ out.push(`widget '${w.id}' names component '${w.component}', which this package does not declare — add it to \`components\``);
554
+ if (!w?.component)
555
+ out.push(`widget '${w?.id}' names no component`);
556
+ if (w?.surface !== undefined)
557
+ out.push(`widget '${w.id}': \`surface\` is gone — name a component, and place an \`sp-frame\` inside it for a document`);
558
+ out.push(...widgetReadsFindings(w?.reads, `widget '${w?.id}' reads`));
559
+ }
560
+ return out;
561
+ }
562
+ /**
563
+ * The layouts a package's genres ship, read as a whole package — what
564
+ * `genre()` and `layout()` cannot see, since a layout names widgets by id and
565
+ * only the package holds their declarations:
566
+ *
567
+ * - **The primary floor** (an error). A genre that withholds the
568
+ * conversation draws, in the layout it ships first, a widget of this
569
+ * package declared `role: 'primary'` — the one standing in the
570
+ * conversation's place. `genre()` asks only that the layout draws
571
+ * something. A widget of another package (a namespaced id) is that
572
+ * package's to declare, and is taken as written. Needs the package's
573
+ * widgets, so a package that states none is not judged.
574
+ * - **What draws, but not as written** (warnings): every warning
575
+ * `validateSessionLayout` has for a shipped layout — an id placed but never
576
+ * drawn, two items on one cell, and one of the package's widgets placed
577
+ * more often than its `maxInstances`.
578
+ * @experimental
579
+ */
580
+ export function genreLayoutFindings(genres, widgets, ns) {
581
+ const errors = [];
582
+ const warnings = [];
583
+ // A layout names the package's own widgets by bare id (`someWidget.id`);
584
+ // one written through `widgetRef` carries the package's namespace. Both
585
+ // spellings are the package's widget.
586
+ const own = (id) => {
587
+ const widget = widgetOfInstance(id);
588
+ const bare = widget.startsWith(`${ns}:`) ? widget.slice(ns.length + 1) : widget;
589
+ return widgets?.find((w) => w?.id === bare);
590
+ };
591
+ const capped = (widgets ?? [])
592
+ .filter((w) => typeof w?.maxInstances === 'number')
593
+ .flatMap((w) => [w, { id: `${ns}:${w.id}`, maxInstances: w.maxInstances }]);
594
+ for (const g of genres) {
595
+ const layouts = g.layouts ?? [];
596
+ for (const l of layouts)
597
+ for (const w of validateSessionLayout(l.preset, { widgets: capped }).warnings)
598
+ warnings.push(`${g.id} layout '${l.slug}': ${w}`);
599
+ if (!widgets || !layouts[0] || !(g.omitWidgets ?? []).includes(CONVERSATION_WIDGET_ID))
600
+ continue;
601
+ const drawn = drawnWidgetIds(layouts[0].preset);
602
+ const standsIn = drawn.some((id) => {
603
+ const decl = own(id);
604
+ if (decl)
605
+ return decl.role === 'primary';
606
+ const widget = widgetOfInstance(id);
607
+ return widget.includes(':') && !widget.startsWith(`${ns}:`);
608
+ });
609
+ if (!standsIn)
610
+ errors.push(`${g.id} omits the conversation, and its layout '${layouts[0].slug}' draws none of this package's ` +
611
+ `role: 'primary' widgets${drawn.length ? ` (it draws ${drawn.map((id) => `'${id}'`).join(', ')})` : ''} — ` +
612
+ `declare the widget that stands in its place role: 'primary', and place it (any zone)`);
613
+ }
614
+ return { errors, warnings };
615
+ }
616
+ /** Deliberate holes: `todo()` sentinels found in config values, with their paths (24 §7). @experimental */
617
+ export function todoHoles(configs) {
618
+ const out = [];
619
+ for (const c of configs)
620
+ for (const [nodeKey, slots] of Object.entries(c.values))
621
+ for (const [slot, value] of Object.entries(slots))
622
+ if (isTodo(value))
623
+ out.push({
624
+ path: `${c.spec}#${c.slug} → ${nodeKey}.${slot}`,
625
+ note: value['todo@1'].note,
626
+ });
627
+ return out;
628
+ }
629
+ /**
630
+ * Every check above, over one package's declarations — what both authoring
631
+ * surfaces run so that one mistake gets one sentence wherever it was written.
632
+ * @experimental
633
+ */
634
+ export function declarationFindings(p) {
635
+ const genres = p.genres ?? [];
636
+ const pipelines = p.pipelines ?? [];
637
+ const configs = p.configs ?? [];
638
+ const requires = new Set();
639
+ const declaredGenres = new Map(genres.map((g) => [g.id, g]));
640
+ const declaredSpecs = new Map(pipelines.map((s) => [s.id, s]));
641
+ const errors = [
642
+ ...genreOwnershipFindings(genres, p.ns),
643
+ ...inputLockFindings(pipelines, new Set(declaredGenres.keys()), p.ns, requires),
644
+ ...createPipelineFindings(genres, pipelines),
645
+ ...genrePresetFindings(genres, p.presets ?? []),
646
+ ...contributedActionFindings(pipelines),
647
+ ...exposeSwapFindings(pipelines),
648
+ ...swapContributionFindings(p.swaps ?? [], p.ns, declaredSpecs),
649
+ ...promptFindings(p.prompts ?? []),
650
+ ...configFindings(configs, declaredSpecs, requires),
651
+ ...eventDeclarationFindings(p.events ?? [], p.ns, pipelines, declaredGenres, requires, p.presets ?? []),
652
+ ...annexDeclarationFindings(p.ns, pipelines, p.annexFields),
653
+ ];
654
+ // A genre's surface includes the events this package declares for it (R52).
655
+ const withEvents = new Map([...declaredGenres].map(([id, g]) => {
656
+ const own = (p.events ?? []).filter((e) => e.genre === id);
657
+ if (!own.length)
658
+ return [id, g];
659
+ return [id, { ...g, events: { ...g.events, ...Object.fromEntries(own.map((e) => [e.event, {}])) } }];
660
+ }));
661
+ const presets = presetFindings(p.presets ?? [], withEvents, declaredSpecs, configs, requires);
662
+ errors.push(...presets.errors, ...surfaceFindings(p.surfaces), ...componentFindings(p.components ?? []), ...widgetComponentFindings(genres, p.components ?? []), ...packageWidgetFindings(p.widgets ?? [], p.components ?? []));
663
+ const layouts = genreLayoutFindings(genres, p.widgets, p.ns);
664
+ errors.push(...layouts.errors);
665
+ return {
666
+ errors,
667
+ warnings: layouts.warnings,
668
+ coverage: { presets: presets.coverage, todos: todoHoles(configs) },
669
+ requires: [...requires].sort(),
670
+ };
671
+ }
672
+ /**
673
+ * The binding subjects a spec serves: its inlet lock's events, or — on
674
+ * the action event — its actions' identities (`<spec slug>#<key>`).
675
+ * @internal
676
+ */
677
+ export const subjectsOf = (spec) => {
678
+ const lock = spec.input;
679
+ const locked = lock?.events ? [...lock.events] : lock?.event ? [lock.event] : [];
680
+ if (!locked.includes(sessionEvents.sessionAction))
681
+ return locked;
682
+ const contributes = 'meta' in spec ? spec.meta.contributes : spec.contributes;
683
+ const keys = actionsOf({ id: spec.id, contributes }).map((a) => a.key);
684
+ return [...locked.filter((e) => e !== sessionEvents.sessionAction), ...keys.map((k) => `${spec.id}#${k}`)];
685
+ };
686
+ /**
687
+ * A package's events: each under the package's namespace, declared for a
688
+ * genre (once per genre), recordable by at least one subject or by any spec.
689
+ * Every pipeline of this package that records one of them is locked to a
690
+ * genre the event is declared for and serves a subject in that genre's
691
+ * scope; a lock or a preset naming one uses a genre it is declared for. An
692
+ * event under this package's namespace that `events` does not list is
693
+ * refused — it has no scope. Another package's event is a requirement: its
694
+ * scope is that package's, and the instance checks it.
695
+ * @experimental
696
+ */
697
+ export function eventDeclarationFindings(events, ns, pipelines, declaredGenres, requires, presets = []) {
698
+ const out = [];
699
+ const keyOf = (event, genre) => `${event} ${genre}`;
700
+ const byKey = new Map();
701
+ const genresOf = new Map();
702
+ for (const e of events) {
703
+ const owner = e.event.slice(0, e.event.indexOf(':'));
704
+ if (owner !== ns)
705
+ out.push(`event '${e.event}' is declared by '${ns}' but sits under '${owner}' — a package declares its own`);
706
+ if (!declaredGenres.has(e.genre))
707
+ requires.add(e.genre);
708
+ if (e.recordedBy !== 'any' && !e.recordedBy.length)
709
+ out.push(`event '${e.event}' names nothing that may record it`);
710
+ if (byKey.has(keyOf(e.event, e.genre)))
711
+ out.push(`event '${e.event}' is declared twice for genre '${e.genre}'`);
712
+ byKey.set(keyOf(e.event, e.genre), e);
713
+ genresOf.set(e.event, new Set([...(genresOf.get(e.event) ?? []), e.genre]));
714
+ }
715
+ const isOwn = (id) => id.slice(0, id.indexOf(':')) === ns;
716
+ const unlisted = (id, where) => `${where} names '${id}', this package's own event, but defineExtension({ events }) does not list it — ` +
717
+ `add { event, genre, recordedBy } so it has a genre and a scope`;
718
+ for (const spec of pipelines) {
719
+ const lock = spec.input;
720
+ const lockGenre = lock?.genre;
721
+ // A lock on an own event names a genre the event is declared for.
722
+ for (const heard of lock?.events ?? (lock?.event ? [lock.event] : [])) {
723
+ if (heard.startsWith('core:') || !isOwn(heard))
724
+ continue;
725
+ const genres = genresOf.get(heard);
726
+ if (!genres)
727
+ out.push(unlisted(heard, `pipeline '${spec.id}'`));
728
+ else if (lockGenre && !genres.has(lockGenre))
729
+ out.push(`pipeline '${spec.id}' listens for '${heard}' on '${lockGenre}', but it is declared for ` +
730
+ `${[...genres].join(', ')}`);
731
+ }
732
+ const nodes = spec.nodes;
733
+ for (const n of nodes) {
734
+ const from = getDefinition(`${n.definitionId}@${n.definitionVersion}`)?.causesEventFrom;
735
+ const recorded = from ? n.config?.[from] : undefined;
736
+ if (typeof recorded !== 'string')
737
+ continue;
738
+ const genres = genresOf.get(recorded);
739
+ if (!genres) {
740
+ if (isOwn(recorded))
741
+ out.push(unlisted(recorded, `pipeline '${spec.id}' at '${n.key}'`));
742
+ else
743
+ requires.add(recorded);
744
+ continue;
745
+ }
746
+ const decl = lockGenre ? byKey.get(keyOf(recorded, lockGenre)) : undefined;
747
+ if (!decl) {
748
+ out.push(`pipeline '${spec.id}' records '${recorded}' at '${n.key}' for genre '${lockGenre ?? 'none'}', ` +
749
+ `but it is declared for ${[...genres].join(', ')}`);
750
+ continue;
751
+ }
752
+ if (decl.recordedBy === 'any')
753
+ continue;
754
+ const subjects = subjectsOf(spec);
755
+ if (!subjects.some((sub) => decl.recordedBy.includes(sub)))
756
+ out.push(`pipeline '${spec.id}' records '${recorded}' at '${n.key}', but serves none of the subjects that may ` +
757
+ `record it (${decl.recordedBy.join(', ')}) — add one of its subjects to recordedBy, ` +
758
+ `or declare your own event`);
759
+ }
760
+ }
761
+ // A preset binds an own event only on a genre it is declared for.
762
+ for (const p of presets)
763
+ for (const event of Object.keys(p.bindings ?? {})) {
764
+ if (event.startsWith('core:') || !isOwn(event))
765
+ continue;
766
+ const genres = genresOf.get(event);
767
+ if (!genres)
768
+ out.push(unlisted(event, `preset '${p.slug}'`));
769
+ else if (!genres.has(p.genre))
770
+ out.push(`preset '${p.slug}' binds '${event}' on '${p.genre}', but it is declared for ${[...genres].join(', ')}`);
771
+ }
772
+ return out;
773
+ }
774
+ /**
775
+ * Every `set-session-annex` step of the package's pipelines writes only keys
776
+ * its owner declares (owner ruling 2026-09-26) — the package's own
777
+ * `annexFields`, or, for a step that names another owner, that owner's
778
+ * declaration where this process knows it. Judged where the keys are
779
+ * literal; a wired `value` is the host's to judge at the write.
780
+ * @internal
781
+ */
782
+ export function annexDeclarationFindings(ns, pipelines, fields) {
783
+ if (fields === undefined)
784
+ return [];
785
+ const out = [];
786
+ for (const spec of pipelines) {
787
+ const s = spec;
788
+ for (const hit of annexStepFindings(s, (owner) => (owner === ns ? fields : annexDeclarationOf(owner))))
789
+ for (const r of hit.refusals)
790
+ out.push(`pipeline '${spec.id}' at '${hit.nodeKey}': ${r}`);
791
+ }
792
+ return out;
793
+ }
794
+ //# sourceMappingURL=declarations.js.map