@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.
- package/LICENSE +202 -0
- package/NOTICE +17 -0
- package/README.md +368 -0
- package/dist/actions.d.ts +572 -0
- package/dist/actions.js +829 -0
- package/dist/annexFields.d.ts +234 -0
- package/dist/annexFields.js +413 -0
- package/dist/announce.d.ts +464 -0
- package/dist/announce.js +426 -0
- package/dist/attributes.d.ts +670 -0
- package/dist/attributes.js +904 -0
- package/dist/bands.d.ts +125 -0
- package/dist/bands.js +256 -0
- package/dist/builder.d.ts +683 -0
- package/dist/builder.js +677 -0
- package/dist/candidates.d.ts +109 -0
- package/dist/candidates.js +118 -0
- package/dist/capabilities.d.ts +744 -0
- package/dist/capabilities.js +679 -0
- package/dist/channels.d.ts +106 -0
- package/dist/channels.js +129 -0
- package/dist/clauses.d.ts +40 -0
- package/dist/clauses.js +43 -0
- package/dist/component.d.ts +33 -0
- package/dist/component.js +27 -0
- package/dist/componentBuild.d.ts +48 -0
- package/dist/componentBuild.js +84 -0
- package/dist/componentClient.d.ts +100 -0
- package/dist/componentClient.js +13 -0
- package/dist/componentImports.d.ts +51 -0
- package/dist/componentImports.js +106 -0
- package/dist/componentModule.d.ts +8 -0
- package/dist/componentModule.js +270 -0
- package/dist/componentWire.d.ts +130 -0
- package/dist/componentWire.js +280 -0
- package/dist/config.d.ts +295 -0
- package/dist/config.js +231 -0
- package/dist/connections.d.ts +89 -0
- package/dist/connections.js +131 -0
- package/dist/declarations.d.ts +290 -0
- package/dist/declarations.js +794 -0
- package/dist/descriptors.d.ts +1774 -0
- package/dist/descriptors.js +1329 -0
- package/dist/dev.d.ts +136 -0
- package/dist/dev.js +161 -0
- package/dist/document.d.ts +202 -0
- package/dist/document.js +312 -0
- package/dist/engines.d.ts +117 -0
- package/dist/engines.js +203 -0
- package/dist/eventMapLaws.d.ts +63 -0
- package/dist/eventMapLaws.js +128 -0
- package/dist/events.d.ts +554 -0
- package/dist/events.js +633 -0
- package/dist/executor.d.ts +771 -0
- package/dist/executor.js +1829 -0
- package/dist/extension.d.ts +448 -0
- package/dist/extension.js +315 -0
- package/dist/facets.d.ts +53 -0
- package/dist/facets.js +60 -0
- package/dist/foldedSections.d.ts +74 -0
- package/dist/foldedSections.js +161 -0
- package/dist/genres.d.ts +507 -0
- package/dist/genres.js +633 -0
- package/dist/guardedConnection.d.ts +138 -0
- package/dist/guardedConnection.js +341 -0
- package/dist/handlebarsReach.d.ts +122 -0
- package/dist/handlebarsReach.js +222 -0
- package/dist/hash.d.ts +146 -0
- package/dist/hash.js +166 -0
- package/dist/hookGrants.d.ts +47 -0
- package/dist/hookGrants.js +68 -0
- package/dist/hooks.d.ts +290 -0
- package/dist/hooks.js +113 -0
- package/dist/hostElements.d.ts +447 -0
- package/dist/hostElements.js +702 -0
- package/dist/i18n.d.ts +94 -0
- package/dist/i18n.js +123 -0
- package/dist/identity.d.ts +93 -0
- package/dist/identity.js +135 -0
- package/dist/index.d.ts +85 -0
- package/dist/index.js +176 -0
- package/dist/layout.d.ts +194 -0
- package/dist/layout.js +40 -0
- package/dist/media.d.ts +202 -0
- package/dist/media.js +70 -0
- package/dist/messageBlocks.d.ts +487 -0
- package/dist/messageBlocks.js +683 -0
- package/dist/migration.d.ts +128 -0
- package/dist/migration.js +261 -0
- package/dist/names.d.ts +78 -0
- package/dist/names.js +136 -0
- package/dist/nodeInput.d.ts +399 -0
- package/dist/nodeInput.js +178 -0
- package/dist/participants.d.ts +291 -0
- package/dist/participants.js +252 -0
- package/dist/personGate.d.ts +62 -0
- package/dist/personGate.js +77 -0
- package/dist/pick.d.ts +84 -0
- package/dist/pick.js +103 -0
- package/dist/pluginHarness.d.ts +235 -0
- package/dist/pluginHarness.js +558 -0
- package/dist/pluginPermissions.d.ts +25 -0
- package/dist/pluginPermissions.js +97 -0
- package/dist/pluginRuleRef.d.ts +13 -0
- package/dist/pluginRuleRef.js +10 -0
- package/dist/predicates.d.ts +182 -0
- package/dist/predicates.js +249 -0
- package/dist/preview.d.ts +120 -0
- package/dist/preview.js +82 -0
- package/dist/promptBlocks.d.ts +130 -0
- package/dist/promptBlocks.js +197 -0
- package/dist/rankingDecisions.d.ts +60 -0
- package/dist/rankingDecisions.js +48 -0
- package/dist/receipt.d.ts +313 -0
- package/dist/receipt.js +60 -0
- package/dist/receiverRules.d.ts +24 -0
- package/dist/receiverRules.js +94 -0
- package/dist/refs.d.ts +117 -0
- package/dist/refs.js +137 -0
- package/dist/registry.d.ts +230 -0
- package/dist/registry.js +273 -0
- package/dist/review.d.ts +108 -0
- package/dist/review.js +97 -0
- package/dist/sampling.d.ts +152 -0
- package/dist/sampling.js +712 -0
- package/dist/scope.d.ts +65 -0
- package/dist/scope.js +128 -0
- package/dist/scripts.d.ts +243 -0
- package/dist/scripts.js +326 -0
- package/dist/sessionLayout.d.ts +339 -0
- package/dist/sessionLayout.js +503 -0
- package/dist/sessionSettings.d.ts +70 -0
- package/dist/sessionSettings.js +2 -0
- package/dist/settings.d.ts +501 -0
- package/dist/settings.js +604 -0
- package/dist/settingsSlot.d.ts +108 -0
- package/dist/settingsSlot.js +166 -0
- package/dist/shapes.d.ts +373 -0
- package/dist/shapes.js +408 -0
- package/dist/sheets.d.ts +165 -0
- package/dist/sheets.js +251 -0
- package/dist/statShapes.d.ts +96 -0
- package/dist/statShapes.js +112 -0
- package/dist/status.d.ts +103 -0
- package/dist/status.js +125 -0
- package/dist/storage.d.ts +145 -0
- package/dist/storage.js +33 -0
- package/dist/storyTime.d.ts +308 -0
- package/dist/storyTime.js +560 -0
- package/dist/surfaces.d.ts +501 -0
- package/dist/surfaces.js +292 -0
- package/dist/template.d.ts +312 -0
- package/dist/template.js +554 -0
- package/dist/templateCheck.d.ts +60 -0
- package/dist/templateCheck.js +516 -0
- package/dist/templateFit.d.ts +157 -0
- package/dist/templateFit.js +349 -0
- package/dist/templateIds.d.ts +138 -0
- package/dist/templateIds.js +144 -0
- package/dist/templateScopeAt.d.ts +131 -0
- package/dist/templateScopeAt.js +354 -0
- package/dist/testing.d.ts +177 -0
- package/dist/testing.js +383 -0
- package/dist/tokenizers.d.ts +113 -0
- package/dist/tokenizers.js +184 -0
- package/dist/turnLock.d.ts +96 -0
- package/dist/turnLock.js +79 -0
- package/dist/turnOrder.d.ts +143 -0
- package/dist/turnOrder.js +128 -0
- package/dist/validate.d.ts +74 -0
- package/dist/validate.js +1399 -0
- package/dist/values.d.ts +212 -0
- package/dist/values.js +390 -0
- package/dist/variables.d.ts +493 -0
- package/dist/variables.js +662 -0
- package/dist/verdicts.d.ts +275 -0
- package/dist/verdicts.js +348 -0
- package/dist/widgetDecls.d.ts +88 -0
- package/dist/widgetDecls.js +119 -0
- package/dist/widgets.d.ts +1527 -0
- package/dist/widgets.js +208 -0
- package/dist/wire.d.ts +126 -0
- package/dist/wire.js +140 -0
- package/dist/worldinfo.d.ts +150 -0
- package/dist/worldinfo.js +212 -0
- package/host-elements.d.ts +914 -0
- package/package.json +67 -0
package/dist/validate.js
ADDED
|
@@ -0,0 +1,1399 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validation — the Fixed Ledger laws that can be checked statically.
|
|
3
|
+
*
|
|
4
|
+
* Every finding names what to do instead (15 §1.3). A prohibition without a stated
|
|
5
|
+
* alternative is a bug, and there is a test asserting exactly that.
|
|
6
|
+
*/
|
|
7
|
+
import { pluginRuleRef } from './pluginRuleRef.js';
|
|
8
|
+
import { JUNCTION_CLAUSE_PORTS, junctionBranchEnds } from './document.js';
|
|
9
|
+
import { notADeclaredEvent, packageEventById } from './events.js';
|
|
10
|
+
import { annexDeclarationOf, annexStepFindings } from './annexFields.js';
|
|
11
|
+
import { settingsSlotFor } from './settingsSlot.js';
|
|
12
|
+
import { ANSWER_FORM_OUTLET_ID, FORM_ADDRESSED_INLET_ID, getDefinition, isBuiltInOutlet, isBuiltInSpec, LIVE_ROW_PORTS, reviewFieldsFinding, widgetDeclsFindings, } from './descriptors.js';
|
|
13
|
+
import { i18nFindings, i18nText } from './i18n.js';
|
|
14
|
+
import { formatChannel, parseChannel } from './channels.js';
|
|
15
|
+
import { PREDICATE_CONDITION_KEYS } from './predicates.js';
|
|
16
|
+
import { provisionalVerdict, settingsTravelVerdict } from './verdicts.js';
|
|
17
|
+
import { settingsSchemaFindings } from './settings.js';
|
|
18
|
+
import { actionDocumentFindingsByLaw } from './actions.js';
|
|
19
|
+
import { templateLawFindings } from './templateFit.js';
|
|
20
|
+
import { isSlotRef } from './refs.js';
|
|
21
|
+
import { assignable, isStreaming, JSON_SHAPE } from './shapes.js';
|
|
22
|
+
import { isModelCall, stepPurposeRefusal } from './builder.js';
|
|
23
|
+
import { capabilityLabel, FEATURES, IO_KINDS, isTransformId, parseTransform, transformId, } from './capabilities.js';
|
|
24
|
+
/**
|
|
25
|
+
* The port shapes a spec may assemble field by field (`templateContext: {
|
|
26
|
+
* advertisement: …, results: … }`): the permissive sink, and the object a
|
|
27
|
+
* context template renders against — the tool loop's prompt builds the
|
|
28
|
+
* latter from two text ports, and nothing publishes it whole for that spec.
|
|
29
|
+
* A field edge into any other port is held to the port's shape.
|
|
30
|
+
*/
|
|
31
|
+
const FIELD_ASSEMBLED_SHAPES = new Set([
|
|
32
|
+
JSON_SHAPE,
|
|
33
|
+
'core:shape/template-context@1',
|
|
34
|
+
]);
|
|
35
|
+
/**
|
|
36
|
+
* A verdict's sentence or fix as a finding's string (01 §13): findings are
|
|
37
|
+
* `en`, the locale every map carries. An absent fix is the empty string —
|
|
38
|
+
* every verdict this file quotes declares one.
|
|
39
|
+
*/
|
|
40
|
+
const en = (v) => (v === undefined ? '' : (i18nText(v) ?? ''));
|
|
41
|
+
/** @experimental */
|
|
42
|
+
export function validate(doc, options = {}) {
|
|
43
|
+
const f = [];
|
|
44
|
+
const byKey = new Map(doc.nodes.map((n) => [n.key, n]));
|
|
45
|
+
const desc = (k) => {
|
|
46
|
+
const n = byKey.get(k);
|
|
47
|
+
return n ? getDefinition(`${n.definitionId}@${n.definitionVersion}`) : undefined;
|
|
48
|
+
};
|
|
49
|
+
// ── 01 §2 — exactly one inlet, positionally first ─────────────────────────
|
|
50
|
+
const inlets = doc.nodes.filter((n) => n.kind === 'inlet');
|
|
51
|
+
if (inlets.length !== 1) {
|
|
52
|
+
f.push({
|
|
53
|
+
law: '01 §2',
|
|
54
|
+
severity: 'error',
|
|
55
|
+
message: `a spec has exactly one inlet; found ${inlets.length}`,
|
|
56
|
+
fix: 'declare a single .inlet() as the first step',
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
else if (inlets[0].position !== 0) {
|
|
60
|
+
f.push({
|
|
61
|
+
law: '01 §2',
|
|
62
|
+
severity: 'error',
|
|
63
|
+
nodeKey: inlets[0].key,
|
|
64
|
+
message: 'the inlet is not the first node',
|
|
65
|
+
fix: 'move .inlet() to the top of the chain',
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
// ── R-2 — a provisional definition cannot be placed ───────────────────────
|
|
69
|
+
//
|
|
70
|
+
// Declared, not bound (plans/29 R-2): the definition is published because a
|
|
71
|
+
// plan owns it, and no handler runs it. A document placing one would
|
|
72
|
+
// publish, seed configs and halt at the node with "no binding registered"
|
|
73
|
+
// pointing at the wrong file — so it is refused here, where the author is,
|
|
74
|
+
// with the two things they can do. The executor refuses the same node with
|
|
75
|
+
// the same sentence (defence in depth: a stored document predates the flag);
|
|
76
|
+
// `core:verdict/provisional` owns it, and both doors quote it (01 §13).
|
|
77
|
+
for (const n of doc.nodes) {
|
|
78
|
+
const heard = provisionalVerdict.judge({
|
|
79
|
+
kind: 'placement',
|
|
80
|
+
nodeKey: n.key,
|
|
81
|
+
definitionId: n.definitionId,
|
|
82
|
+
definitionVersion: n.definitionVersion,
|
|
83
|
+
provisional: desc(n.key)?.provisional === true,
|
|
84
|
+
});
|
|
85
|
+
if (heard.ok)
|
|
86
|
+
continue;
|
|
87
|
+
f.push({
|
|
88
|
+
law: provisionalVerdict.law,
|
|
89
|
+
severity: 'error',
|
|
90
|
+
nodeKey: n.key,
|
|
91
|
+
message: en(heard.sentence),
|
|
92
|
+
fix: en(heard.fix),
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
// ── F7 — one live row; other writes unlimited (R44, W1) ────────────────
|
|
96
|
+
//
|
|
97
|
+
// A pipeline may write as often as it likes. What a run has one of is its
|
|
98
|
+
// LIVE ROW — the row a stream lands in and Stop finalises: a `liveRow`
|
|
99
|
+
// outlet's write that is still being written (`generating` fed, or a
|
|
100
|
+
// claimed `row` — LIVE_ROW_PORTS). The same outlet writing a complete
|
|
101
|
+
// message is an ordinary write. Beside the live row, a second MESSAGE on
|
|
102
|
+
// its channel is two rows racing for one place: refused here where the
|
|
103
|
+
// channel is a literal (or unset = main), and by the host where it is
|
|
104
|
+
// wired. A port fed by an edge or a reference counts as fed — the
|
|
105
|
+
// document cannot prove it will be falsy.
|
|
106
|
+
//
|
|
107
|
+
// Beside, not after (amended 2026-09-27, lair pass B16): once a write has
|
|
108
|
+
// FINISHED the live row — an outlet whose `target` is the live row's own
|
|
109
|
+
// result — the row is settled and holds its place, so a message that runs
|
|
110
|
+
// strictly after that write lands after it and races nothing. That is how
|
|
111
|
+
// a turn writes its narrator's row and then a row per speaker. The host
|
|
112
|
+
// applies the same rule at run time (`racesLiveRow`).
|
|
113
|
+
//
|
|
114
|
+
// Per EXECUTION PATH (amended 2026-09-28, lair pass R8), as the
|
|
115
|
+
// streaming law already reads (W2): two live-row outlets that can never
|
|
116
|
+
// run in the same execution — mutually exclusive branches of one junction
|
|
117
|
+
// (`exclusiveSteps`) — are each the run's one live row on their own path.
|
|
118
|
+
// That is how one spec opens its row where each branch needs it: the
|
|
119
|
+
// Lair's delver after the Sanctum's beats row, its Castellan's narration,
|
|
120
|
+
// its Sanctum talk. Anything not provably exclusive is still one path.
|
|
121
|
+
const writes = doc.nodes.filter((n) => n.kind === 'outlet' && desc(n.key)?.effects === 'write');
|
|
122
|
+
const fed = (n, port) => {
|
|
123
|
+
const v = n.config?.[port];
|
|
124
|
+
if (v !== undefined && v !== null && v !== false)
|
|
125
|
+
return true;
|
|
126
|
+
return doc.edges.some((e) => e.to === n.key && e.toPort.split('.')[0] === port);
|
|
127
|
+
};
|
|
128
|
+
const opensLive = (n) => Boolean(desc(n.key)?.liveRow) && LIVE_ROW_PORTS.some((p) => fed(n, p));
|
|
129
|
+
const liveRows = writes.filter(opensLive);
|
|
130
|
+
const pathClauses = new Map(doc.clauses.map((c) => [c.id, c]));
|
|
131
|
+
const onOnePath = liveRows.filter((a) => liveRows.some((b) => b !== a && !exclusiveSteps(pathClauses, a, b)));
|
|
132
|
+
if (onOnePath.length > 1) {
|
|
133
|
+
f.push({
|
|
134
|
+
law: 'F7',
|
|
135
|
+
severity: 'error',
|
|
136
|
+
nodeKey: onOnePath[1].key,
|
|
137
|
+
message: `a run has at most one live row; found ${onOnePath.length} (${onOnePath.map((w) => w.key).join(', ')})`,
|
|
138
|
+
fix: 'keep one row that is written into (a placeholder or a claimed row) and fill it with update-message; write anything else beside it — complete messages on other channels, the annex, lore — as many as you like. Two may each open one only from mutually exclusive branches of one junction',
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
// The channel a message write lands on, canonical, when this document
|
|
142
|
+
// fixes it: a literal, or unset (= main). A wired channel (a ref) is
|
|
143
|
+
// known only at run time — the host refuses there.
|
|
144
|
+
const channelOf = (n) => {
|
|
145
|
+
const v = n.config?.channel;
|
|
146
|
+
if (v !== undefined && v !== null && typeof v !== 'string')
|
|
147
|
+
return undefined;
|
|
148
|
+
return formatChannel(parseChannel(v ?? 'main'));
|
|
149
|
+
};
|
|
150
|
+
// Each live row against the writes that can run beside it: a write on
|
|
151
|
+
// an exclusive path can never race it, whatever channel it names.
|
|
152
|
+
const raced = new Set();
|
|
153
|
+
for (const live of liveRows) {
|
|
154
|
+
const liveChannel = !fed(live, 'row') ? channelOf(live) : undefined;
|
|
155
|
+
if (liveChannel === undefined)
|
|
156
|
+
continue;
|
|
157
|
+
const finishers = writes.filter((w) => doc.edges.some((e) => e.from === live.key && e.to === w.key && e.toPort.split('.')[0] === 'target'));
|
|
158
|
+
for (const w of writes) {
|
|
159
|
+
if (liveRows.includes(w) || raced.has(w.key))
|
|
160
|
+
continue;
|
|
161
|
+
if (!desc(w.key)?.ports.in?.channel)
|
|
162
|
+
continue;
|
|
163
|
+
if (channelOf(w) !== liveChannel)
|
|
164
|
+
continue;
|
|
165
|
+
if (exclusiveSteps(pathClauses, live, w))
|
|
166
|
+
continue;
|
|
167
|
+
if (finishers.some((f) => runsStrictlyAfter(doc, w, f)))
|
|
168
|
+
continue;
|
|
169
|
+
raced.add(w.key);
|
|
170
|
+
f.push({
|
|
171
|
+
law: 'F7',
|
|
172
|
+
severity: 'error',
|
|
173
|
+
nodeKey: w.key,
|
|
174
|
+
message: `'${w.key}' writes a message on channel '${liveChannel}', the live row's channel ('${live.key}') — two rows racing for one place`,
|
|
175
|
+
fix: `put it on the live row as blocks, or on another channel — a second message beside the reply belongs somewhere the reply is not`,
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
// ── F25 — no branching. A node may not feed two divergent spine successors ─
|
|
180
|
+
const spine = doc.nodes.filter((n) => !n.clauseId).sort((a, b) => a.position - b.position);
|
|
181
|
+
const spineKeys = new Set(spine.map((n) => n.key));
|
|
182
|
+
const outByNode = new Map();
|
|
183
|
+
for (const e of doc.edges) {
|
|
184
|
+
if (!spineKeys.has(e.from) || !spineKeys.has(e.to))
|
|
185
|
+
continue;
|
|
186
|
+
if (!outByNode.has(e.from))
|
|
187
|
+
outByNode.set(e.from, new Set());
|
|
188
|
+
outByNode.get(e.from).add(e.to);
|
|
189
|
+
}
|
|
190
|
+
for (const [from, tos] of outByNode) {
|
|
191
|
+
if (tos.size <= 1)
|
|
192
|
+
continue;
|
|
193
|
+
// fan-in-to-a-common-successor is legal; genuine divergence is not.
|
|
194
|
+
const positions = [...tos].map((k) => byKey.get(k).position).sort((a, b) => a - b);
|
|
195
|
+
const between = spine.filter((n) => n.position > positions[0] && n.position < positions[positions.length - 1]);
|
|
196
|
+
const diverges = between.some((n) => !reaches(doc, n.key, spine[spine.length - 1].key));
|
|
197
|
+
if (diverges) {
|
|
198
|
+
f.push({
|
|
199
|
+
law: 'F25',
|
|
200
|
+
severity: 'error',
|
|
201
|
+
nodeKey: from,
|
|
202
|
+
message: `'${from}' feeds divergent paths (${[...tos].join(', ')})`,
|
|
203
|
+
fix: 'pipelines are linear: use .gather() for parallel work, .each() for per-item work, .junction() for declared branching, or halt() to stop early',
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
// ── Port shape compatibility (01 §3) ──────────────────────────────────────
|
|
208
|
+
for (const e of doc.edges) {
|
|
209
|
+
if (e.implicit)
|
|
210
|
+
continue;
|
|
211
|
+
const up = desc(e.from);
|
|
212
|
+
const down = desc(e.to);
|
|
213
|
+
if (!up || !down)
|
|
214
|
+
continue;
|
|
215
|
+
const outShape = up.ports.out?.[e.fromPort];
|
|
216
|
+
const inShape = down.ports.in?.[e.toPort.split('.')[0]];
|
|
217
|
+
if (!outShape || !inShape)
|
|
218
|
+
continue;
|
|
219
|
+
// A reference wired into a FIELD of a port (`templateContext.results`)
|
|
220
|
+
// assembles the port's value from parts, and a part has no declared
|
|
221
|
+
// shape to be held to — but only where the port's whole shape is one
|
|
222
|
+
// a spec builds field by field (U5d review, W9 then S-c). Any other
|
|
223
|
+
// port is a whole value, and a field edge into it is held to the
|
|
224
|
+
// port's shape like a whole-port edge: `messages.x: $.lore.hits` is
|
|
225
|
+
// the mistake 01 §3 exists to catch, not an object under construction.
|
|
226
|
+
const wholePort = !e.toPort.includes('.') || !FIELD_ASSEMBLED_SHAPES.has(inShape);
|
|
227
|
+
// R-a (U5d review, 2026-09-17) — a transcript is not a candidates list.
|
|
228
|
+
// `messages@1` was assignable to `context-candidates@1` for one day
|
|
229
|
+
// (W9), which legalised a wiring the host silently drops: a row
|
|
230
|
+
// handed to `concat-candidates` is keyed `undefined:<id>`, the
|
|
231
|
+
// ranker's `select` excludes it as `excluded_unknown_source`, and
|
|
232
|
+
// `assemble` given rows as its candidates halts on "no ranking
|
|
233
|
+
// decisions". A warning rather than 01 §3's error, so a document
|
|
234
|
+
// built from the older teaching corpus still compiles — and is told.
|
|
235
|
+
const transcriptAsCandidates = wholePort &&
|
|
236
|
+
outShape === 'core:shape/messages@1' &&
|
|
237
|
+
inShape === 'core:shape/context-candidates@1';
|
|
238
|
+
if (transcriptAsCandidates) {
|
|
239
|
+
f.push({
|
|
240
|
+
law: '16 §5a',
|
|
241
|
+
severity: 'warning',
|
|
242
|
+
nodeKey: e.to,
|
|
243
|
+
message: `'${e.from}.${e.fromPort}' is the transcript (core:shape/messages@1), wired into ` +
|
|
244
|
+
`'${e.to}.${e.toPort}' as candidates — the rows are not ranked there, they are dropped`,
|
|
245
|
+
fix: `wire '${e.from}.band' into the merge or concat that feeds the ranker (the ` +
|
|
246
|
+
`transcript's share of the window rides the band intent), and hand the rows ` +
|
|
247
|
+
`themselves to core:task/process-messages@1; assemble's 'candidates' takes the ` +
|
|
248
|
+
`ranked list, not the transcript`,
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
else if (wholePort && !assignable(outShape, inShape)) {
|
|
252
|
+
// The write-result case gets its own message, because the generic one
|
|
253
|
+
// ("insert a converter") is the wrong advice: there is nothing to convert.
|
|
254
|
+
// A write publishes a discriminated result, and a port that wants
|
|
255
|
+
// anything but row ids from it has to say so (13 §7j-b). Row ids
|
|
256
|
+
// themselves are assignable — see `S.writeResult`.
|
|
257
|
+
if (outShape === 'core:shape/write-result@1') {
|
|
258
|
+
f.push({
|
|
259
|
+
law: '13 §7j-b',
|
|
260
|
+
severity: 'error',
|
|
261
|
+
nodeKey: e.to,
|
|
262
|
+
message: `'${e.to}' expects ${inShape} from '${e.from}.${e.fromPort}', but a gate-eligible ` +
|
|
263
|
+
`write publishes core:shape/write-result@1 — a discriminated result carrying the ` +
|
|
264
|
+
`row ids, not the value itself`,
|
|
265
|
+
fix: `declare '${e.to}' with an input port of core:shape/write-result@1 or ` +
|
|
266
|
+
`core:shape/row-ids@1 and read the ids off the result in its hook`,
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
else {
|
|
270
|
+
f.push({
|
|
271
|
+
law: '01 §3',
|
|
272
|
+
severity: 'error',
|
|
273
|
+
nodeKey: e.to,
|
|
274
|
+
message: `'${e.from}.${e.fromPort}' produces ${outShape}; '${e.to}.${e.toPort}' needs ${inShape}`,
|
|
275
|
+
fix: `insert a node that converts ${outShape} to ${inShape}, or pick a type whose port accepts ${outShape}`,
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
// F22 — earlyExit only means something on a stream-capable input
|
|
280
|
+
if (down.earlyExit && !isStreaming(outShape)) {
|
|
281
|
+
f.push({
|
|
282
|
+
law: 'F22',
|
|
283
|
+
severity: 'warning',
|
|
284
|
+
nodeKey: e.to,
|
|
285
|
+
message: `'${e.to}' declares earlyExit but '${e.from}.${e.fromPort}' does not stream`,
|
|
286
|
+
fix: 'remove earlyExit, or connect it to a stream-shaped port — on a settled value there is nothing to exit early from',
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
// ── F39 — settings never travel; only data does (12 §2 P3, 29 §5d) ───────
|
|
291
|
+
//
|
|
292
|
+
// `<nodeKey>.settings.*` is the substrate's address — `enabled`, `review`,
|
|
293
|
+
// `mode` — read by the executor at its owner and handed to nobody. It is
|
|
294
|
+
// not a port: a data edge drawn from it carries nothing at run time, and a
|
|
295
|
+
// document that draws one has made a node depend on another node's switch
|
|
296
|
+
// (a plugin node keyed to whether `save` is reviewed), which is exactly
|
|
297
|
+
// the coupling that stops two configs from being independent. Refused as
|
|
298
|
+
// the law it breaks rather than as an unknown port, because the fix is
|
|
299
|
+
// different: read a value the owner publishes, or reference its slot.
|
|
300
|
+
// `core:verdict/settings-travel` judges each edge and each reference; the
|
|
301
|
+
// registry and the executor quote the same verdict (01 §13).
|
|
302
|
+
for (const e of doc.edges) {
|
|
303
|
+
if (e.implicit)
|
|
304
|
+
continue;
|
|
305
|
+
const heard = settingsTravelVerdict.judge({
|
|
306
|
+
kind: 'edge',
|
|
307
|
+
from: e.from,
|
|
308
|
+
fromPort: e.fromPort,
|
|
309
|
+
to: e.to,
|
|
310
|
+
toPort: e.toPort,
|
|
311
|
+
});
|
|
312
|
+
if (heard.ok)
|
|
313
|
+
continue;
|
|
314
|
+
f.push({
|
|
315
|
+
law: settingsTravelVerdict.law,
|
|
316
|
+
severity: 'error',
|
|
317
|
+
nodeKey: e.to,
|
|
318
|
+
message: en(heard.sentence),
|
|
319
|
+
fix: en(heard.fix),
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
// The same law through the other door: a config reference naming the
|
|
323
|
+
// substrate's slot. `SlotRef.slot` cannot spell it and `slot.*` never
|
|
324
|
+
// produces it, so one here is a hand-written document; the executor
|
|
325
|
+
// resolves it to nothing and notes why (`resolveInput`), and the document
|
|
326
|
+
// is refused before it gets that far.
|
|
327
|
+
for (const n of doc.nodes)
|
|
328
|
+
for (const [k, v] of Object.entries(n.config)) {
|
|
329
|
+
if (!isSlotRef(v))
|
|
330
|
+
continue;
|
|
331
|
+
const slotName = v.slot;
|
|
332
|
+
// A reference naming no slot at all is a shape fault, said as one:
|
|
333
|
+
// before this guard it was a TypeError out of `validate()`, and a
|
|
334
|
+
// publish that crashes is worse than one refused (U7 delta review, 3).
|
|
335
|
+
if (typeof slotName !== 'string' || !slotName) {
|
|
336
|
+
f.push({
|
|
337
|
+
law: '12 §2',
|
|
338
|
+
severity: 'error',
|
|
339
|
+
nodeKey: n.key,
|
|
340
|
+
message: `'${n.key}.${k}' is a slot reference that names no slot — ` +
|
|
341
|
+
`{ __ref: 'slot', slot } names one of connection, sampling, prompts, template, ` +
|
|
342
|
+
`params, variables`,
|
|
343
|
+
fix: `write the reference with slot.<name>() — slot.params(), slot.connection(), ` +
|
|
344
|
+
`slot.prompts() — or give '${n.key}.${k}' a value`,
|
|
345
|
+
});
|
|
346
|
+
continue;
|
|
347
|
+
}
|
|
348
|
+
const heard = settingsTravelVerdict.judge({
|
|
349
|
+
kind: 'reference',
|
|
350
|
+
node: n.key,
|
|
351
|
+
key: k,
|
|
352
|
+
slot: slotName,
|
|
353
|
+
target: n.resolvedRefs?.[k] ?? v.ofNode ?? n.key,
|
|
354
|
+
});
|
|
355
|
+
if (heard.ok)
|
|
356
|
+
continue;
|
|
357
|
+
f.push({
|
|
358
|
+
law: settingsTravelVerdict.law,
|
|
359
|
+
severity: 'error',
|
|
360
|
+
nodeKey: n.key,
|
|
361
|
+
message: en(heard.sentence),
|
|
362
|
+
fix: en(heard.fix),
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
// ── R-15 — a built-in outlet only in the built-in's own spec ─────────────
|
|
366
|
+
//
|
|
367
|
+
// The five built-in writes perform the item rule's write: the venue's
|
|
368
|
+
// handler judged who may act on which row before `runBuiltIn` started the
|
|
369
|
+
// spec, and the host re-checks the actor at the commit. A document that is
|
|
370
|
+
// not one of the five placing `delete-message@1` would reach that commit
|
|
371
|
+
// with a payload nobody judged — an event subscriber deleting whatever it
|
|
372
|
+
// was handed. Refused here at publish, and again by the host at the write
|
|
373
|
+
// (defence in depth, U5b review W8). A manifest permission letting a plugin
|
|
374
|
+
// spec place one is the future this leaves room for; nothing grants it yet.
|
|
375
|
+
if (!isBuiltInSpec(doc.id)) {
|
|
376
|
+
for (const n of doc.nodes) {
|
|
377
|
+
const id = `${n.definitionId}@${n.definitionVersion}`;
|
|
378
|
+
if (n.kind !== 'outlet' || !isBuiltInOutlet(id))
|
|
379
|
+
continue;
|
|
380
|
+
f.push({
|
|
381
|
+
law: 'R-15',
|
|
382
|
+
severity: 'error',
|
|
383
|
+
nodeKey: n.key,
|
|
384
|
+
message: `'${n.key}' places ${id}, a built-in write, in '${doc.id}' — only the built-in's own ` +
|
|
385
|
+
`spec (core:spec/builtin-*) may perform one, because the write's permission was judged ` +
|
|
386
|
+
`by the handler that started that spec and by nothing this document can supply`,
|
|
387
|
+
fix: `remove '${n.key}' and let the person act through the message menu, whose handler runs the ` +
|
|
388
|
+
`built-in for them; a manifest permission for a plugin spec to place a built-in write is ` +
|
|
389
|
+
`not granted in this release`,
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
// ── R-15 forms — `answer-form@1` commits an oracle's answer as a click:
|
|
394
|
+
// it fires the block's action AS the addressee. Only a document reached
|
|
395
|
+
// by `form-addressed@1` has a form to answer, so the outlet is refused
|
|
396
|
+
// anywhere else (U5d); the host refuses the commit on the same test.
|
|
397
|
+
for (const n of doc.nodes) {
|
|
398
|
+
const id = `${n.definitionId}@${n.definitionVersion}`;
|
|
399
|
+
if (n.kind !== 'outlet' || id !== ANSWER_FORM_OUTLET_ID)
|
|
400
|
+
continue;
|
|
401
|
+
const inlet = inlets[0];
|
|
402
|
+
const inletId = inlet ? `${inlet.definitionId}@${inlet.definitionVersion}` : '(none)';
|
|
403
|
+
if (inletId === FORM_ADDRESSED_INLET_ID)
|
|
404
|
+
continue;
|
|
405
|
+
f.push({
|
|
406
|
+
law: 'R-15',
|
|
407
|
+
severity: 'error',
|
|
408
|
+
nodeKey: n.key,
|
|
409
|
+
message: `'${n.key}' places ${ANSWER_FORM_OUTLET_ID}, which answers a form as its addressee, in a ` +
|
|
410
|
+
`document whose inlet is ${inletId} — only a pipeline on ${FORM_ADDRESSED_INLET_ID} ` +
|
|
411
|
+
`has a form to answer`,
|
|
412
|
+
fix: `bind the document to core:event/form-addressed@1 through ${FORM_ADDRESSED_INLET_ID}, ` +
|
|
413
|
+
`or remove '${n.key}' — a form is answered by the genre's answer pipeline, never by ` +
|
|
414
|
+
`a spec that was not asked`,
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
// ── R-15 review fields — an effectful definition says what a reviewer
|
|
418
|
+
// may edit. A finding at registration (`definitionFindings`), repeated
|
|
419
|
+
// here on every placement as a warning so a document built on such a
|
|
420
|
+
// definition says so; inference is the documented fallback.
|
|
421
|
+
for (const n of doc.nodes) {
|
|
422
|
+
const d = desc(n.key);
|
|
423
|
+
const finding = d ? reviewFieldsFinding(d) : null;
|
|
424
|
+
if (!finding)
|
|
425
|
+
continue;
|
|
426
|
+
f.push({
|
|
427
|
+
law: 'R-15',
|
|
428
|
+
severity: 'warning',
|
|
429
|
+
nodeKey: n.key,
|
|
430
|
+
message: `'${n.key}': ${finding}`,
|
|
431
|
+
fix: `declare review: { fields: [...] } on ${d.id} — the in-ports a reviewer may edit, [] for none`,
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
// ── R-15 — contributed actions declare a venue core offers, a slash name in
|
|
435
|
+
// the spec's own namespace, a localised label; F41 — the effects line ────
|
|
436
|
+
//
|
|
437
|
+
// The builder refuses these at construction; a document from any other
|
|
438
|
+
// source (an import, a hand-written JSON) gets the same answer here. Two actions of one spec
|
|
439
|
+
// claiming one slash name for two different functions is a collision the
|
|
440
|
+
// namespace rule cannot prevent — refused as such. Each finding carries
|
|
441
|
+
// the law it comes from (`ActionFinding`): the declaration's shape is
|
|
442
|
+
// R-15's, a `world` action across the line — in a message venue, or
|
|
443
|
+
// acted on by a participant — is F41's (U7 review, W3), so the
|
|
444
|
+
// conformance kit's C20 keys on the label and never on a word. An F41
|
|
445
|
+
// finding carries the fix `core:verdict/effects-line` states; a shape
|
|
446
|
+
// finding gets the one alternative there is.
|
|
447
|
+
for (const { law, message, fix } of actionDocumentFindingsByLaw(doc)) {
|
|
448
|
+
f.push({
|
|
449
|
+
law,
|
|
450
|
+
severity: 'error',
|
|
451
|
+
message,
|
|
452
|
+
fix: fix ?? 'declare the action as `contributes.actions[]` describes — see the SDK\'s actions.ts',
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
// ── R-20 — every author-facing string the document carries is display text
|
|
456
|
+
// (a string or a locale map with `en`, never blank; U5i, ruled 2026-09-17):
|
|
457
|
+
// each author preset's label and description; the genre a create pipeline
|
|
458
|
+
// carries — its name and description, its shape's fields schema and panel
|
|
459
|
+
// titles, each envoy's name and description. An action's label is R-15's
|
|
460
|
+
// above, through `actionDocumentFindingsByLaw`. The builder, `genre()` and
|
|
461
|
+
// `announce.build()` refuse these at authoring; a document from any other
|
|
462
|
+
// source gets the same sentence here, and the host's publish runs this.
|
|
463
|
+
for (const message of documentDisplayTextFindings(doc))
|
|
464
|
+
f.push({
|
|
465
|
+
law: 'R-20',
|
|
466
|
+
severity: 'error',
|
|
467
|
+
message,
|
|
468
|
+
fix: "write display text a person reads — a plain string ('Lore-heavy') or a locale map " +
|
|
469
|
+
"with 'en' ({ en: 'Lore-heavy', fr: '…' }); a bare string reads as en",
|
|
470
|
+
});
|
|
471
|
+
// Writes inside a clause are allowed since W1 (R44): a gather's writes
|
|
472
|
+
// land as its chains complete, a junction's only on the branch that
|
|
473
|
+
// fires, and a repeating clause's once per pass, bounded by its `max`.
|
|
474
|
+
// The one refusal left is the live row in a repeat, below.
|
|
475
|
+
// ── Repetition bounds (01 §4, §4a) ────────────────────────────────────────
|
|
476
|
+
const clauseById = new Map(doc.clauses.map((b) => [b.id, b]));
|
|
477
|
+
const repeats = (clauseId) => {
|
|
478
|
+
let cur = clauseId;
|
|
479
|
+
while (cur) {
|
|
480
|
+
const b = clauseById.get(cur);
|
|
481
|
+
if (!b)
|
|
482
|
+
return undefined;
|
|
483
|
+
if (b.kind === 'each' || b.kind === 'loop')
|
|
484
|
+
return b.id;
|
|
485
|
+
cur = b.clauseId;
|
|
486
|
+
}
|
|
487
|
+
return undefined;
|
|
488
|
+
};
|
|
489
|
+
const within = (inner, outer) => {
|
|
490
|
+
let cur = inner;
|
|
491
|
+
while (cur) {
|
|
492
|
+
if (cur === outer)
|
|
493
|
+
return true;
|
|
494
|
+
cur = clauseById.get(cur)?.clauseId;
|
|
495
|
+
}
|
|
496
|
+
return false;
|
|
497
|
+
};
|
|
498
|
+
/**
|
|
499
|
+
* What a branch may state, counted off ONE list (D-4a, 2026-09-17).
|
|
500
|
+
*
|
|
501
|
+
* This read the three words out of a literal, so the night `equalsPath`
|
|
502
|
+
* joined the grammar it was legal in an action's enabled-when and refused
|
|
503
|
+
* here as "states no conditions" — the same predicate meaning two things at
|
|
504
|
+
* two doors, which is the one thing a shared shape exists to prevent.
|
|
505
|
+
* `default` is the junction's own fourth: only a branch can fire because
|
|
506
|
+
* nothing else did.
|
|
507
|
+
*/
|
|
508
|
+
const BRANCH_CONDITIONS = [...PREDICATE_CONDITION_KEYS, 'default'];
|
|
509
|
+
for (const b of doc.clauses) {
|
|
510
|
+
if (b.kind !== 'junction')
|
|
511
|
+
continue;
|
|
512
|
+
const branches = b.branches ?? {};
|
|
513
|
+
const on = b.on;
|
|
514
|
+
if (!on || on.__ref !== 'data') {
|
|
515
|
+
f.push({
|
|
516
|
+
law: '20 §10',
|
|
517
|
+
severity: 'error',
|
|
518
|
+
message: `junction '${b.id}' has no value to branch on`,
|
|
519
|
+
fix: 'reference a port with on:, e.g. on: $ => $.parse.call — the decision is data a task computed',
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
if (!b.chains.length) {
|
|
523
|
+
f.push({
|
|
524
|
+
law: '20 §10',
|
|
525
|
+
severity: 'error',
|
|
526
|
+
message: `junction '${b.id}' declares no branches`,
|
|
527
|
+
fix: 'declare at least one when() branch',
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
let defaults = 0;
|
|
531
|
+
for (const chain of b.chains) {
|
|
532
|
+
const p = branches[chain];
|
|
533
|
+
if (!p) {
|
|
534
|
+
f.push({
|
|
535
|
+
law: '20 §10',
|
|
536
|
+
severity: 'error',
|
|
537
|
+
message: `junction '${b.id}' branch '${chain}' has no predicate`,
|
|
538
|
+
fix: 'declare it with when(name, predicate) or otherwise(name)',
|
|
539
|
+
});
|
|
540
|
+
continue;
|
|
541
|
+
}
|
|
542
|
+
const stated = BRANCH_CONDITIONS.filter((k) => p[k] !== undefined);
|
|
543
|
+
if (p.default)
|
|
544
|
+
defaults++;
|
|
545
|
+
if (stated.length !== 1) {
|
|
546
|
+
f.push({
|
|
547
|
+
law: '20 §10',
|
|
548
|
+
severity: 'error',
|
|
549
|
+
message: `junction '${b.id}' branch '${chain}' states ${stated.length || 'no'} conditions`,
|
|
550
|
+
fix: `exactly one of ${BRANCH_CONDITIONS.join(' / ')} per branch — a richer decision belongs in a Task the junction reads`,
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
if (defaults > 1) {
|
|
555
|
+
f.push({
|
|
556
|
+
law: '20 §10',
|
|
557
|
+
severity: 'error',
|
|
558
|
+
message: `junction '${b.id}' declares ${defaults} default branches`,
|
|
559
|
+
fix: "at most one otherwise() — 'fires when nothing else did' cannot be true of two branches",
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
for (const b of doc.clauses) {
|
|
564
|
+
if (b.kind !== 'each' && b.kind !== 'loop')
|
|
565
|
+
continue;
|
|
566
|
+
if (!b.max || b.max <= 0) {
|
|
567
|
+
f.push({
|
|
568
|
+
law: b.kind === 'each' ? '01 §4' : '01 §4a',
|
|
569
|
+
severity: 'error',
|
|
570
|
+
message: `${b.kind} '${b.id}' has no declared maximum`,
|
|
571
|
+
fix: b.kind === 'each'
|
|
572
|
+
? 'declare max — an unbounded each is the most likely source of a surprise bill in the system'
|
|
573
|
+
: 'declare max — for a loop it is also the only thing between a bad predicate and a run that never ends',
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
if (b.kind !== 'loop')
|
|
577
|
+
continue;
|
|
578
|
+
const ref = b.repeatWhile;
|
|
579
|
+
if (!ref || ref.__ref !== 'data') {
|
|
580
|
+
f.push({
|
|
581
|
+
law: '01 §4a',
|
|
582
|
+
severity: 'error',
|
|
583
|
+
message: `loop '${b.id}' has no repeatWhile predicate`,
|
|
584
|
+
fix: 'reference a port on a node inside the loop body, e.g. repeatWhile: $ => $.tools.item.generate.hasToolCalls',
|
|
585
|
+
});
|
|
586
|
+
continue;
|
|
587
|
+
}
|
|
588
|
+
// A predicate that cannot change is a loop that always runs to max.
|
|
589
|
+
const source = doc.nodes.find((n) => n.key === ref.node);
|
|
590
|
+
if (!source || !within(source.clauseId, b.id)) {
|
|
591
|
+
f.push({
|
|
592
|
+
law: '01 §4a',
|
|
593
|
+
severity: 'error',
|
|
594
|
+
message: `loop '${b.id}' repeats on '${ref.node}', which is not inside the loop body`,
|
|
595
|
+
fix: `reference a node declared inside '${b.id}' — a predicate computed outside the body never changes, so the loop would always run to its max of ${b.max}`,
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
// ── A junction's result ports (M4, PLAN-turn-order §4.14) ──────────────────
|
|
600
|
+
// A ref to a junction port beyond its clause ports reads the fired
|
|
601
|
+
// branch's own port, so every branch must end in a node publishing it,
|
|
602
|
+
// with one shape — or a branch that fires hands the consumer nothing.
|
|
603
|
+
for (const e of doc.edges) {
|
|
604
|
+
if (e.implicit)
|
|
605
|
+
continue;
|
|
606
|
+
const clause = doc.clauses.find((c) => c.id === e.from);
|
|
607
|
+
if (!clause || clause.kind !== 'junction' || JUNCTION_CLAUSE_PORTS.has(e.fromPort))
|
|
608
|
+
continue;
|
|
609
|
+
const ends = junctionBranchEnds(doc.nodes, clause, doc.clauses);
|
|
610
|
+
const shapes = new Set();
|
|
611
|
+
// A junction with no `otherwise` can fire nothing, and then its result
|
|
612
|
+
// port is empty — a consumer handed `undefined` in silence (R26).
|
|
613
|
+
if (!Object.values(clause.branches ?? {}).some((b) => b?.default))
|
|
614
|
+
f.push({
|
|
615
|
+
law: '20 §10',
|
|
616
|
+
severity: 'error',
|
|
617
|
+
nodeKey: e.to,
|
|
618
|
+
message: `'${e.from}.${e.fromPort}' reads junction '${e.from}''s result, but it has no otherwise branch, so it can fire nothing and hand on nothing`,
|
|
619
|
+
fix: `add .otherwise(...) to '${e.from}', or read $.${e.from}.values`,
|
|
620
|
+
});
|
|
621
|
+
for (const { chain, node } of ends) {
|
|
622
|
+
const shape = node
|
|
623
|
+
? getDefinition(`${node.definitionId}@${node.definitionVersion}`)?.ports.out?.[e.fromPort]
|
|
624
|
+
: undefined;
|
|
625
|
+
if (!shape) {
|
|
626
|
+
f.push({
|
|
627
|
+
law: '20 §10',
|
|
628
|
+
severity: 'error',
|
|
629
|
+
nodeKey: e.to,
|
|
630
|
+
message: `'${e.from}.${e.fromPort}' is not published by every branch of junction '${e.from}' — ` +
|
|
631
|
+
`'${chain}' ends in ${node ? `'${node.key}', which has no '${e.fromPort}'` : 'no node'}`,
|
|
632
|
+
fix: `end every branch in a node publishing '${e.fromPort}', or read $.${e.from}.values`,
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
else
|
|
636
|
+
shapes.add(shape);
|
|
637
|
+
}
|
|
638
|
+
if (shapes.size > 1)
|
|
639
|
+
f.push({
|
|
640
|
+
law: '20 §10',
|
|
641
|
+
severity: 'error',
|
|
642
|
+
nodeKey: e.to,
|
|
643
|
+
message: `the branches of junction '${e.from}' publish '${e.fromPort}' as different shapes (${[...shapes].join(', ')})`,
|
|
644
|
+
fix: 'end every branch in nodes whose port shapes agree',
|
|
645
|
+
});
|
|
646
|
+
else if (shapes.size === 1) {
|
|
647
|
+
const outShape = [...shapes][0];
|
|
648
|
+
const inShape = desc(e.to)?.ports.in?.[e.toPort.split('.')[0]];
|
|
649
|
+
if (inShape && !e.toPort.includes('.') && !assignable(outShape, inShape))
|
|
650
|
+
f.push({
|
|
651
|
+
law: '01 §3',
|
|
652
|
+
severity: 'error',
|
|
653
|
+
nodeKey: e.to,
|
|
654
|
+
message: `'${e.from}.${e.fromPort}' produces ${outShape}; '${e.to}.${e.toPort}' needs ${inShape}`,
|
|
655
|
+
fix: `insert a node that converts ${outShape} to ${inShape}, or pick a type whose port accepts ${outShape}`,
|
|
656
|
+
});
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
// ── Referencing into a repeating clause from outside (01 §4a) ─────────────
|
|
660
|
+
for (const e of doc.edges) {
|
|
661
|
+
if (e.implicit)
|
|
662
|
+
continue;
|
|
663
|
+
const from = byKey.get(e.from);
|
|
664
|
+
const to = byKey.get(e.to);
|
|
665
|
+
if (!from || !to)
|
|
666
|
+
continue;
|
|
667
|
+
const repeating = repeats(from.clauseId);
|
|
668
|
+
if (!repeating || within(to.clauseId, repeating))
|
|
669
|
+
continue;
|
|
670
|
+
f.push({
|
|
671
|
+
law: '01 §4a',
|
|
672
|
+
severity: 'error',
|
|
673
|
+
nodeKey: e.to,
|
|
674
|
+
message: `'${e.to}' references '${e.from}', which is inside ${clauseById.get(repeating).kind} '${repeating}' and runs more than once`,
|
|
675
|
+
fix: `reference the clause's own output instead — $.${repeating}.values for the results in order, or $.${repeating} for the full branch record. "Whichever iteration happened to run last" is not a value anyone means`,
|
|
676
|
+
});
|
|
677
|
+
}
|
|
678
|
+
// ── A live row inside a repeating clause would be N live rows (01 §4, W1) ─
|
|
679
|
+
for (const n of doc.nodes) {
|
|
680
|
+
if (n.kind !== 'outlet' || desc(n.key)?.effects !== 'write' || !opensLive(n))
|
|
681
|
+
continue;
|
|
682
|
+
const repeating = repeats(n.clauseId);
|
|
683
|
+
if (!repeating)
|
|
684
|
+
continue;
|
|
685
|
+
f.push({
|
|
686
|
+
law: '01 §4',
|
|
687
|
+
severity: 'error',
|
|
688
|
+
nodeKey: n.key,
|
|
689
|
+
message: `live-row outlet '${n.key}' is inside ${clauseById.get(repeating).kind} '${repeating}' — one reply row per pass is N live rows`,
|
|
690
|
+
fix: 'open the reply row on the spine, before or after the repeat; writes that are not the live row may stay inside it',
|
|
691
|
+
});
|
|
692
|
+
}
|
|
693
|
+
// ── F8 — nodes cannot emit events ─────────────────────────────────────────
|
|
694
|
+
for (const n of doc.nodes) {
|
|
695
|
+
if ('emits' in n.config) {
|
|
696
|
+
f.push({
|
|
697
|
+
law: 'F8',
|
|
698
|
+
severity: 'error',
|
|
699
|
+
nodeKey: n.key,
|
|
700
|
+
message: `'${n.key}' declares emits`,
|
|
701
|
+
fix: 'no node emits: a write causes the event its outlet declares, and a package records its own declared event with record-event. A pipeline answers an event through its inlet lock' +
|
|
702
|
+
pluginRuleRef('events'),
|
|
703
|
+
});
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
// ── F8 / E1 — recording a declared event ──────────────────────────────────
|
|
707
|
+
// A write may cause an event its literal names (`causesEventFrom`). The
|
|
708
|
+
// event is a package's declaration, named as a literal so what a pipeline
|
|
709
|
+
// records is known before it runs, and the payload carries its shape.
|
|
710
|
+
// Scope — which pipelines may record it — is the package entry's to say,
|
|
711
|
+
// and is checked by the package pass and the host.
|
|
712
|
+
for (const n of doc.nodes) {
|
|
713
|
+
const d = desc(n.key);
|
|
714
|
+
const port = d?.causesEventFrom;
|
|
715
|
+
if (!port)
|
|
716
|
+
continue;
|
|
717
|
+
const literal = n.config[port];
|
|
718
|
+
const wired = doc.edges.some((e) => e.to === n.key && e.toPort.split('.')[0] === port) ||
|
|
719
|
+
(!!literal && typeof literal === 'object');
|
|
720
|
+
const refuse = (message, fix) => f.push({ law: 'F8', severity: 'error', nodeKey: n.key, message, fix });
|
|
721
|
+
if (wired) {
|
|
722
|
+
refuse(`'${n.key}' wires the event it records`, 'name the event as a literal — pass the declaration value — so what a pipeline records is known before it runs');
|
|
723
|
+
continue;
|
|
724
|
+
}
|
|
725
|
+
if (typeof literal !== 'string' || !literal) {
|
|
726
|
+
refuse(`'${n.key}' names no event to record`, 'pass the event you declared with defineSessionEvent()');
|
|
727
|
+
continue;
|
|
728
|
+
}
|
|
729
|
+
if (literal.startsWith('core:')) {
|
|
730
|
+
refuse(`'${n.key}' records '${literal}', a core event`, "core events are caused by core's own writes — declare your own event with defineSessionEvent()");
|
|
731
|
+
continue;
|
|
732
|
+
}
|
|
733
|
+
const event = packageEventById(literal);
|
|
734
|
+
if (!event) {
|
|
735
|
+
refuse(`'${n.key}' records '${literal}', which is not declared`, notADeclaredEvent(literal));
|
|
736
|
+
continue;
|
|
737
|
+
}
|
|
738
|
+
// The payload: present always; for any shape but json, wired whole
|
|
739
|
+
// from a port of that shape — an assembled or literal value has no
|
|
740
|
+
// shape the declaration could be held to.
|
|
741
|
+
const into = doc.edges.filter((e) => e.to === n.key && e.toPort.split('.')[0] === 'payload');
|
|
742
|
+
const whole = into.filter((e) => e.toPort === 'payload');
|
|
743
|
+
const literalPayload = n.config.payload !== undefined;
|
|
744
|
+
if (!into.length && !literalPayload) {
|
|
745
|
+
refuse(`'${n.key}' records '${literal}' with no payload`, `wire a value of shape '${event.payload}' into payload`);
|
|
746
|
+
continue;
|
|
747
|
+
}
|
|
748
|
+
if (event.payload === JSON_SHAPE)
|
|
749
|
+
continue;
|
|
750
|
+
if (whole.length !== 1 || into.length !== 1) {
|
|
751
|
+
refuse(`'${n.key}' records '${literal}' with an assembled or literal payload; the event carries '${event.payload}'`, `wire one port of shape '${event.payload}' into payload, whole`);
|
|
752
|
+
continue;
|
|
753
|
+
}
|
|
754
|
+
const outShape = desc(whole[0].from)?.ports.out?.[whole[0].fromPort];
|
|
755
|
+
if (outShape && !assignable(outShape, event.payload))
|
|
756
|
+
refuse(`'${n.key}' records '${literal}' with a '${outShape}' payload; the event carries '${event.payload}'`, `wire a value of shape '${event.payload}' into payload — the event's declaration says what a listener receives`);
|
|
757
|
+
}
|
|
758
|
+
// ── R57 — an annex write names only its owner's declared keys ────────────
|
|
759
|
+
// One annex declaration per owner is the single source of truth (owner
|
|
760
|
+
// ruling 2026-09-26): a `set-session-annex` step writes only the keys its
|
|
761
|
+
// owner declares with `annexField()`, and the audience stored is the
|
|
762
|
+
// declaration's. Judged here where the keys are literal and the owner's
|
|
763
|
+
// declaration is known in this process (core's; an installed package's on
|
|
764
|
+
// the host); a wired `value`, or an owner not known here, is the package
|
|
765
|
+
// pass's and the host's write to judge.
|
|
766
|
+
for (const hit of annexStepFindings(doc, annexDeclarationOf))
|
|
767
|
+
for (const refusal of hit.refusals)
|
|
768
|
+
f.push({
|
|
769
|
+
law: 'R57',
|
|
770
|
+
severity: 'error',
|
|
771
|
+
nodeKey: hit.nodeKey,
|
|
772
|
+
message: `'${hit.nodeKey}' writes the annex of '${hit.owner}': ${refusal}`,
|
|
773
|
+
fix: `write only keys '${hit.owner}' declares — add the key to its annexFields with its shape and who may see it`,
|
|
774
|
+
});
|
|
775
|
+
// ── R60 — the whole annex feeding a prompt is warned ──────────────────────
|
|
776
|
+
// The annex as a pipeline reads it carries every value, a secret included;
|
|
777
|
+
// a prompt should read the AI's view (`view: 'ai'`). Followed forward from
|
|
778
|
+
// its sources — `session-annex` without `view: 'ai'`, the settings
|
|
779
|
+
// document (`session-settings`, or an inlet's `session` port, whole or its
|
|
780
|
+
// `annex`) — through every node it reaches, to
|
|
781
|
+
// any node that builds a prompt (an `assembled-context` out-port). A
|
|
782
|
+
// warning, not a refusal: a pipeline may mean it.
|
|
783
|
+
{
|
|
784
|
+
const PROMPT = 'core:shape/assembled-context@1';
|
|
785
|
+
const buildsPrompt = (key) => Object.values(desc(key)?.ports.out ?? {}).some((shape) => shape === PROMPT);
|
|
786
|
+
const sources = [];
|
|
787
|
+
for (const n of doc.nodes) {
|
|
788
|
+
// A `view` wired rather than written is decided at run time; only a
|
|
789
|
+
// literal that is not `'ai'` is known to be the whole annex.
|
|
790
|
+
const viewWired = doc.edges.some((e) => e.to === n.key && e.toPort.split('.')[0] === 'view');
|
|
791
|
+
// `'template'` (typed templates P6) is not the whole annex either:
|
|
792
|
+
// declared keys only, and law T2 holds it to a template's port.
|
|
793
|
+
if (n.definitionId === 'core:query/session-annex' &&
|
|
794
|
+
n.config.view !== 'ai' &&
|
|
795
|
+
n.config.view !== 'template' &&
|
|
796
|
+
!viewWired)
|
|
797
|
+
sources.push(n.key);
|
|
798
|
+
// The settings document carries the whole annex too.
|
|
799
|
+
if (n.definitionId === 'core:query/session-settings')
|
|
800
|
+
sources.push(n.key);
|
|
801
|
+
}
|
|
802
|
+
const tainted = new Map();
|
|
803
|
+
for (const key of sources)
|
|
804
|
+
tainted.set(key, key);
|
|
805
|
+
const queue = [...sources];
|
|
806
|
+
for (const e of doc.edges) {
|
|
807
|
+
const from = doc.nodes.find((n) => n.key === e.from);
|
|
808
|
+
const path = e.fromPort.split('.');
|
|
809
|
+
// An inlet's settings document, whole or its `annex`.
|
|
810
|
+
const carries = path[0] === 'session' && (path.length === 1 || path[1] === 'annex');
|
|
811
|
+
if (from?.kind === 'inlet' && carries && !tainted.has(e.to)) {
|
|
812
|
+
tainted.set(e.to, e.from);
|
|
813
|
+
queue.push(e.to);
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
const warned = new Set();
|
|
817
|
+
while (queue.length) {
|
|
818
|
+
const key = queue.shift();
|
|
819
|
+
const origin = tainted.get(key);
|
|
820
|
+
if (buildsPrompt(key) && !warned.has(origin)) {
|
|
821
|
+
warned.add(origin);
|
|
822
|
+
f.push({
|
|
823
|
+
law: 'R60',
|
|
824
|
+
severity: 'warning',
|
|
825
|
+
nodeKey: origin,
|
|
826
|
+
message: `'${origin}' carries the whole session annex into a prompt ('${key}') — every value, secrets included`,
|
|
827
|
+
fix: "read the annex with view: 'ai' (and the speaker) so the prompt carries only what the model may see",
|
|
828
|
+
});
|
|
829
|
+
}
|
|
830
|
+
for (const e of doc.edges)
|
|
831
|
+
if (e.from === key && !tainted.has(e.to)) {
|
|
832
|
+
tainted.set(e.to, origin);
|
|
833
|
+
queue.push(e.to);
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
// ── R-7 P2 — one owner per setting per spec ───────────────────────────────
|
|
838
|
+
//
|
|
839
|
+
// Keyed on `FieldDecl.shared` (refined 2026-09-16, plans/30 U3b; was keyed
|
|
840
|
+
// on a same-named field under the same label, 2026-09-15). A definition
|
|
841
|
+
// says which of its `params` fields are the SAME setting wherever two of
|
|
842
|
+
// it run side by side — the lore lanes' scan depth, the embed pair's
|
|
843
|
+
// switch — by marking them `shared: true`; the executor resolves a marked
|
|
844
|
+
// field at the owner a `slot.params({ node })` names and an unmarked one at
|
|
845
|
+
// the node itself, and the panel renders them the same way. So the defect
|
|
846
|
+
// P2 names — the panel showing "Scan depth" three times, a person tuning
|
|
847
|
+
// one not tuning the others — is exactly two nodes that each OWN a params
|
|
848
|
+
// slot (neither references the other) and both declare a `shared` field
|
|
849
|
+
// under one name. A field left unmarked is the node's own by declaration:
|
|
850
|
+
// four `assemble` steps in one run each declaring `postHistoryDepth`, the
|
|
851
|
+
// three relationship reads each declaring `maxEntries`, are several
|
|
852
|
+
// settings that happen to share a spelling, and take no part. Nor does a
|
|
853
|
+
// node whose `params` is a reference — it is not an owner.
|
|
854
|
+
//
|
|
855
|
+
// ⚠ Shipped specs must trip this NOWHERE (the app pins that in
|
|
856
|
+
// `paramsSlotWiring.test.ts`), and there is no `distinct` escape any more:
|
|
857
|
+
// the declaration is where two same-named fields are told apart, and a
|
|
858
|
+
// `shared` field that is genuinely two settings on two nodes is a
|
|
859
|
+
// declaration error, not a spec annotation.
|
|
860
|
+
const sharedOwners = [];
|
|
861
|
+
for (const n of doc.nodes) {
|
|
862
|
+
const d = desc(n.key);
|
|
863
|
+
const paramsSlot = Object.entries((d?.slots ?? {})).find(([name, decl]) => name === 'params' && decl.kind === 'parameters');
|
|
864
|
+
if (!paramsSlot)
|
|
865
|
+
continue;
|
|
866
|
+
const wired = n.config['params'];
|
|
867
|
+
if (!isSlotRef(wired))
|
|
868
|
+
continue;
|
|
869
|
+
const ref = wired;
|
|
870
|
+
const target = n.resolvedRefs?.['params'] ?? ref.ofNode;
|
|
871
|
+
const schema = (paramsSlot[1].schema ?? {});
|
|
872
|
+
const shared = new Set(Object.entries(schema)
|
|
873
|
+
.filter(([, decl]) => decl?.shared === true)
|
|
874
|
+
.map(([name]) => name));
|
|
875
|
+
if (target && target !== n.key) {
|
|
876
|
+
// A reference whose own declaration shares nothing resolves every
|
|
877
|
+
// field at the node's own address — the reference reads as sharing
|
|
878
|
+
// and does not. Said at publish rather than discovered when the
|
|
879
|
+
// owner's tuned value fails to arrive.
|
|
880
|
+
if (!shared.size)
|
|
881
|
+
f.push({
|
|
882
|
+
law: '12 §2 P2',
|
|
883
|
+
severity: 'warning',
|
|
884
|
+
nodeKey: n.key,
|
|
885
|
+
message: `'${n.key}' references '${target}' for params, but its definition marks no field shared — every field resolves at '${n.key}' and the reference changes nothing`,
|
|
886
|
+
fix: `mark the fields the two nodes hold in common with shared: true on the definition, or wire params: slot.params()`,
|
|
887
|
+
});
|
|
888
|
+
continue; // a reference, not an owner
|
|
889
|
+
}
|
|
890
|
+
if (shared.size)
|
|
891
|
+
sharedOwners.push({ key: n.key, fields: shared });
|
|
892
|
+
}
|
|
893
|
+
for (let i = 0; i < sharedOwners.length; i++) {
|
|
894
|
+
for (let j = i + 1; j < sharedOwners.length; j++) {
|
|
895
|
+
const a = sharedOwners[i];
|
|
896
|
+
const b = sharedOwners[j];
|
|
897
|
+
const both = [...a.fields].filter((name) => b.fields.has(name));
|
|
898
|
+
if (!both.length)
|
|
899
|
+
continue;
|
|
900
|
+
f.push({
|
|
901
|
+
law: '12 §2 P2',
|
|
902
|
+
severity: 'warning',
|
|
903
|
+
nodeKey: b.key,
|
|
904
|
+
message: `'${a.key}' and '${b.key}' both own a params slot declaring the shared ${both
|
|
905
|
+
.map((name) => `'${name}'`)
|
|
906
|
+
.join(', ')} — two addresses for one setting`,
|
|
907
|
+
fix: `make one the owner and give the other params: slot.params({ node: '${a.key}' })`,
|
|
908
|
+
});
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
// ── F36 — every hook invocation is bounded ────────────────────────────────
|
|
912
|
+
for (const n of doc.nodes) {
|
|
913
|
+
if (n.kind === 'inlet')
|
|
914
|
+
continue;
|
|
915
|
+
const d = desc(n.key);
|
|
916
|
+
if (d && d.timeoutMs === undefined) {
|
|
917
|
+
f.push({
|
|
918
|
+
law: 'F36',
|
|
919
|
+
severity: 'warning',
|
|
920
|
+
nodeKey: n.key,
|
|
921
|
+
message: `type '${n.definitionId}@${n.definitionVersion}' declares no timeout`,
|
|
922
|
+
fix: 'declare timeoutMs on the descriptor; the pub ceiling applies regardless, but an explicit default is what stops a stuck hook running to the ceiling',
|
|
923
|
+
});
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
// ── Author presets (12 §3a) ───────────────────────────────────────────────
|
|
927
|
+
for (const p of doc.presets ?? []) {
|
|
928
|
+
for (const v of p.values) {
|
|
929
|
+
const node = byKey.get(v.nodeKey);
|
|
930
|
+
if (!node) {
|
|
931
|
+
f.push({
|
|
932
|
+
law: '12 §3a',
|
|
933
|
+
severity: 'error',
|
|
934
|
+
message: `preset '${p.slug}' sets '${v.slot}' on unknown node '${v.nodeKey}'`,
|
|
935
|
+
fix: `name a node this spec declares (${[...byKey.keys()].join(', ')}), or remove the entry — a preset row that matches no node is silently dead config`,
|
|
936
|
+
});
|
|
937
|
+
continue;
|
|
938
|
+
}
|
|
939
|
+
const d = desc(v.nodeKey);
|
|
940
|
+
// Slots are declared by the type, so a preset writing an undeclared slot is
|
|
941
|
+
// the same class of mistake as a typo'd node key: it resolves to nothing and
|
|
942
|
+
// the user sees the preset "not working" with no error anywhere. The
|
|
943
|
+
// substrate's `settings` counts as declared where the substrate declares
|
|
944
|
+
// it (R-9): on an optional or gated node, and nowhere else.
|
|
945
|
+
const declared = !!d?.slots?.[v.slot] || (v.slot === 'settings' && d && !!settingsSlotFor(d));
|
|
946
|
+
if (d && !declared && v.slot !== 'connection') {
|
|
947
|
+
f.push({
|
|
948
|
+
law: '12 §3a',
|
|
949
|
+
severity: 'error',
|
|
950
|
+
nodeKey: v.nodeKey,
|
|
951
|
+
message: `preset '${p.slug}' sets slot '${v.slot}' on '${v.nodeKey}', which declares ${Object.keys(d.slots ?? {}).join(', ') || 'no slots'}`,
|
|
952
|
+
fix: `set a slot the type declares, or add '${v.slot}' to the descriptor if the node should accept it`,
|
|
953
|
+
});
|
|
954
|
+
}
|
|
955
|
+
if (v.slot === 'connection') {
|
|
956
|
+
f.push({
|
|
957
|
+
law: '12 §4',
|
|
958
|
+
severity: 'error',
|
|
959
|
+
nodeKey: v.nodeKey,
|
|
960
|
+
message: `preset '${p.slug}' sets a connection`,
|
|
961
|
+
fix: 'an author preset may not pin compute or credentials — the admin cascade works because connection has no writable scope below the pub. Ship the behaviour (prompts, params, template) and let the admin choose the connection',
|
|
962
|
+
});
|
|
963
|
+
}
|
|
964
|
+
// A template value carries its own engine, so a bare string is ambiguous the
|
|
965
|
+
// moment more than one engine is registered (src/engines.ts).
|
|
966
|
+
if (v.slot === 'template' &&
|
|
967
|
+
(typeof v.value !== 'object' || !v.value?.engine)) {
|
|
968
|
+
f.push({
|
|
969
|
+
law: '12 §3a',
|
|
970
|
+
severity: 'error',
|
|
971
|
+
nodeKey: v.nodeKey,
|
|
972
|
+
message: `preset '${p.slug}' sets a template on '${v.nodeKey}' with no engine`,
|
|
973
|
+
fix: 'wrap it: jinja(source), text(source), or yourEngine(source) — the engine travels on the value so a slot can say what it is written in',
|
|
974
|
+
});
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
// ── Toggleable requires shape transparency ────────────────────────────────
|
|
979
|
+
for (const n of doc.nodes) {
|
|
980
|
+
const d = desc(n.key);
|
|
981
|
+
if (!d?.toggleable)
|
|
982
|
+
continue;
|
|
983
|
+
const outs = Object.values(d.ports.out ?? {});
|
|
984
|
+
const ins = Object.values(d.ports.in ?? {});
|
|
985
|
+
const transparent = outs.some((o) => ins.some((i) => assignable(o, i) || assignable(i, o)));
|
|
986
|
+
if (!transparent) {
|
|
987
|
+
f.push({
|
|
988
|
+
law: '01 §14',
|
|
989
|
+
severity: 'error',
|
|
990
|
+
nodeKey: n.key,
|
|
991
|
+
message: `'${n.key}' declares toggleable but its output is not assignable to its input`,
|
|
992
|
+
fix: 'only shape-transparent nodes may be switched off; otherwise turning it off breaks everything downstream',
|
|
993
|
+
});
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
// ── capability declarations ───────────────────────────────────────────────
|
|
997
|
+
//
|
|
998
|
+
// Checked HERE and not by `satisfies`, because at publish time there is no
|
|
999
|
+
// connection to satisfy — the document may be imported onto an instance whose
|
|
1000
|
+
// connections nobody has created yet. What is checkable statically is whether
|
|
1001
|
+
// the declaration itself is coherent, and every one of these is a mistake that
|
|
1002
|
+
// would otherwise surface as a slot that silently never matches anything.
|
|
1003
|
+
for (const n of doc.nodes) {
|
|
1004
|
+
const d = getDefinition(`${n.definitionId}@${n.definitionVersion}`);
|
|
1005
|
+
for (const [slotName, decl] of Object.entries(d?.slots ?? {})) {
|
|
1006
|
+
// The substrate's slot, authored (R-9). `register` refuses this at
|
|
1007
|
+
// declaration; the mirror here catches a descriptor that reached
|
|
1008
|
+
// the registry by another door — a row adopted from an install, a
|
|
1009
|
+
// declaration patched after registration — before a document is
|
|
1010
|
+
// published against it.
|
|
1011
|
+
if (slotName === 'settings' || decl.kind === 'settings') {
|
|
1012
|
+
f.push({
|
|
1013
|
+
law: 'R-9',
|
|
1014
|
+
severity: 'error',
|
|
1015
|
+
nodeKey: n.key,
|
|
1016
|
+
message: `'${n.key}' is bound to ${d.id}, which authors slot '${slotName}'${decl.kind === 'settings' ? " with kind 'settings'" : ''}`,
|
|
1017
|
+
fix: `'settings' is the substrate's slot — \`enabled\` on an optional node, \`review\` on a gated one — declared by the projection, never by an author; name the slot for what it holds ('parameters' for tunables)`,
|
|
1018
|
+
});
|
|
1019
|
+
continue;
|
|
1020
|
+
}
|
|
1021
|
+
const requires = decl.requires ?? [];
|
|
1022
|
+
const optional = decl.optional ?? [];
|
|
1023
|
+
if (!requires.length && !optional.length)
|
|
1024
|
+
continue;
|
|
1025
|
+
if (decl.kind !== 'connection') {
|
|
1026
|
+
f.push({
|
|
1027
|
+
law: 'capabilities',
|
|
1028
|
+
severity: 'error',
|
|
1029
|
+
nodeKey: n.key,
|
|
1030
|
+
message: `'${n.key}.${slotName}' declares capabilities but is a ${decl.kind} slot`,
|
|
1031
|
+
fix: 'capabilities describe a connection; declare them on the connection slot that resolves it',
|
|
1032
|
+
});
|
|
1033
|
+
continue;
|
|
1034
|
+
}
|
|
1035
|
+
for (const id of [...requires, ...optional]) {
|
|
1036
|
+
if (isKnownCapability(id))
|
|
1037
|
+
continue;
|
|
1038
|
+
// A transform built from known kinds but written in the wrong
|
|
1039
|
+
// ORDER is a different mistake from a typo, and telling them
|
|
1040
|
+
// apart is the difference between a one-word fix and a hunt.
|
|
1041
|
+
// `image+audio->video` and `audio+image->video` name one
|
|
1042
|
+
// capability, but only the canonical spelling is what
|
|
1043
|
+
// `transformId()` ever produces — so the other matches nothing,
|
|
1044
|
+
// forever, and the node's requirement is unsatisfiable by any
|
|
1045
|
+
// connection however capable.
|
|
1046
|
+
const canonical = isTransformId(id) ? canonicalise(id) : undefined;
|
|
1047
|
+
f.push({
|
|
1048
|
+
law: 'capabilities',
|
|
1049
|
+
severity: 'error',
|
|
1050
|
+
nodeKey: n.key,
|
|
1051
|
+
message: canonical
|
|
1052
|
+
? `'${n.key}.${slotName}' spells the capability '${id}' non-canonically`
|
|
1053
|
+
: `'${n.key}.${slotName}' names an unknown capability '${id}'`,
|
|
1054
|
+
fix: canonical
|
|
1055
|
+
? `write it as '${canonical}' — kinds are ordered by IO_KINDS (text, image, audio, video, document, embedding), and only that spelling is ever matched`
|
|
1056
|
+
: `use a declared transform (e.g. 'text->image') or feature (${FEATURES.join(', ')})`,
|
|
1057
|
+
});
|
|
1058
|
+
}
|
|
1059
|
+
// Both at once is not a stricter requirement, it is a contradiction:
|
|
1060
|
+
// `requires` guarantees presence, `optional` obliges the binding to
|
|
1061
|
+
// handle absence. One of the two branches would be unreachable.
|
|
1062
|
+
const both = requires.filter((r) => optional.includes(r));
|
|
1063
|
+
for (const id of both) {
|
|
1064
|
+
f.push({
|
|
1065
|
+
law: 'capabilities',
|
|
1066
|
+
severity: 'error',
|
|
1067
|
+
nodeKey: n.key,
|
|
1068
|
+
message: `'${n.key}.${slotName}' lists ${capabilityLabel(id)} as both required and optional`,
|
|
1069
|
+
fix: 'pick one — required means the run fails without it; optional means the binding handles its absence',
|
|
1070
|
+
});
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
// ── T1 — a template fits where it is rendered (typed templates P5) ─────────
|
|
1075
|
+
// Collisions and forbidden kinds in a template node's scope, a band with
|
|
1076
|
+
// no variable, and — given the checker — every template source the
|
|
1077
|
+
// document carries against the typed scope of the slot it fills.
|
|
1078
|
+
f.push(...templateLawFindings(doc, options.templates));
|
|
1079
|
+
// ── streaming step + step status (lair pass B3/B18, D6/D5, 2026-09-27) ──
|
|
1080
|
+
f.push(...streamingStepFindings(doc));
|
|
1081
|
+
return f;
|
|
1082
|
+
}
|
|
1083
|
+
/**
|
|
1084
|
+
* The streaming step and the step status, as declared on `expose` (lair
|
|
1085
|
+
* pass B3/B18; owner D6 and D5, 2026-09-27).
|
|
1086
|
+
*
|
|
1087
|
+
* Which oracle streams into the reply is **declared**, never inferred: the
|
|
1088
|
+
* inference it replaced skipped every oracle inside a clause and streamed the
|
|
1089
|
+
* Lair's planner JSON into the row. What a declaration can still get wrong is
|
|
1090
|
+
* refused here, each with the fix:
|
|
1091
|
+
*
|
|
1092
|
+
* · **a JSON step never streams** — a step whose `main` out-port is not a
|
|
1093
|
+
* streaming shape (`generate-json`, whose `main` is `core:shape/json@1`)
|
|
1094
|
+
* would write its document into the row a person is reading;
|
|
1095
|
+
* · **one per execution path** — a run has one live row, and two streams
|
|
1096
|
+
* interleave or concatenate into it. Two steps that can never run in the
|
|
1097
|
+
* same execution may each stream (W2, 2026-09-27): they sit in different
|
|
1098
|
+
* branches of one junction whose predicates are mutually exclusive — one
|
|
1099
|
+
* is the `otherwise`, or both are `equals` on the same path with different
|
|
1100
|
+
* literals. The runtime streams whichever one runs. Anything weaker (a
|
|
1101
|
+
* `truthy`, an `equalsPath`, two different paths) could fire both, so it
|
|
1102
|
+
* is refused, and so is a step on the spine beside one in a branch;
|
|
1103
|
+
* · **never in an each or a loop** — the step would stream once per pass
|
|
1104
|
+
* into the same row;
|
|
1105
|
+
* · **an oracle** — only an oracle has a model's tokens to stream.
|
|
1106
|
+
*
|
|
1107
|
+
* A step status, step label and step purpose are display text (R-20), and a
|
|
1108
|
+
* step purpose sits only on a model call — an oracle whose definition declares
|
|
1109
|
+
* a `connection` slot (`isModelCall`; law `step purpose`, 2026-09-30).
|
|
1110
|
+
* @internal
|
|
1111
|
+
*/
|
|
1112
|
+
export function streamingStepFindings(doc) {
|
|
1113
|
+
const f = [];
|
|
1114
|
+
const LAW = 'streaming step';
|
|
1115
|
+
const clauseById = new Map(doc.clauses.map((c) => [c.id, c]));
|
|
1116
|
+
const repeatingClause = (clauseId) => {
|
|
1117
|
+
const seen = new Set();
|
|
1118
|
+
for (let id = clauseId; id && !seen.has(id);) {
|
|
1119
|
+
seen.add(id);
|
|
1120
|
+
const c = clauseById.get(id);
|
|
1121
|
+
if (!c)
|
|
1122
|
+
return undefined;
|
|
1123
|
+
if (c.kind === 'each' || c.kind === 'loop')
|
|
1124
|
+
return c.id;
|
|
1125
|
+
id = c.clauseId;
|
|
1126
|
+
}
|
|
1127
|
+
return undefined;
|
|
1128
|
+
};
|
|
1129
|
+
const streaming = doc.nodes.filter((n) => n.expose?.stream === true);
|
|
1130
|
+
for (const n of streaming) {
|
|
1131
|
+
if (n.kind !== 'oracle') {
|
|
1132
|
+
f.push({
|
|
1133
|
+
law: LAW,
|
|
1134
|
+
severity: 'error',
|
|
1135
|
+
nodeKey: n.key,
|
|
1136
|
+
message: `'${n.key}' is declared the streaming step, but it is a ${n.kind} — only an oracle has a model's tokens to stream`,
|
|
1137
|
+
fix: 'move `expose: { stream: true }` to the oracle that writes the reply\'s prose',
|
|
1138
|
+
});
|
|
1139
|
+
continue;
|
|
1140
|
+
}
|
|
1141
|
+
const def = getDefinition(`${n.definitionId}@${n.definitionVersion}`);
|
|
1142
|
+
const out = def?.ports.out ?? {};
|
|
1143
|
+
// Judged on `main`, what the step IS: `generate-json` also publishes
|
|
1144
|
+
// the raw `text` it parsed as a text stream, for diagnosis, and that
|
|
1145
|
+
// port does not make its answer prose.
|
|
1146
|
+
const streams = out.main !== undefined && isStreaming(out.main);
|
|
1147
|
+
if (def && !streams) {
|
|
1148
|
+
const json = out.main === JSON_SHAPE;
|
|
1149
|
+
f.push({
|
|
1150
|
+
law: LAW,
|
|
1151
|
+
severity: 'error',
|
|
1152
|
+
nodeKey: n.key,
|
|
1153
|
+
message: json
|
|
1154
|
+
? `'${n.key}' (${n.definitionId}) is declared the streaming step, but it answers in JSON — a JSON step never streams into a row (D6)`
|
|
1155
|
+
: `'${n.key}' (${n.definitionId}) is declared the streaming step, but its main out-port does not stream`,
|
|
1156
|
+
fix: 'declare `expose: { stream: true }` on the step that writes the prose (a `core:oracle/generate-text` oracle), ' +
|
|
1157
|
+
'or on none — a spec that streams nothing shows its step status until the write lands',
|
|
1158
|
+
});
|
|
1159
|
+
}
|
|
1160
|
+
const repeat = repeatingClause(n.clauseId);
|
|
1161
|
+
if (repeat)
|
|
1162
|
+
f.push({
|
|
1163
|
+
law: LAW,
|
|
1164
|
+
severity: 'error',
|
|
1165
|
+
nodeKey: n.key,
|
|
1166
|
+
message: `'${n.key}' is declared the streaming step inside '${repeat}', which repeats — every pass would stream into the same row`,
|
|
1167
|
+
fix: 'stream a step outside the each or loop, or none; the repeated step\'s text reaches the row at the write',
|
|
1168
|
+
});
|
|
1169
|
+
}
|
|
1170
|
+
// Pairwise: every two streaming steps must be provably exclusive. A set
|
|
1171
|
+
// whose every pair is exclusive can never run two in one execution.
|
|
1172
|
+
const reported = new Set();
|
|
1173
|
+
for (let i = 0; i < streaming.length; i++)
|
|
1174
|
+
for (let j = i + 1; j < streaming.length; j++) {
|
|
1175
|
+
const a = streaming[i];
|
|
1176
|
+
const b = streaming[j];
|
|
1177
|
+
if (reported.has(b.key) || exclusiveSteps(clauseById, a, b))
|
|
1178
|
+
continue;
|
|
1179
|
+
reported.add(b.key);
|
|
1180
|
+
f.push({
|
|
1181
|
+
law: LAW,
|
|
1182
|
+
severity: 'error',
|
|
1183
|
+
nodeKey: b.key,
|
|
1184
|
+
message: `'${a.key}' and '${b.key}' are both declared the streaming step on the same execution path — a run has one live row, and at most one streaming step may run in any one execution`,
|
|
1185
|
+
fix: 'keep `expose: { stream: true }` on the step whose text is the reply, and give the others a `status` instead — ' +
|
|
1186
|
+
'two may each stream only from mutually exclusive branches of one junction (an `otherwise`, or `equals` on the same path with different values)',
|
|
1187
|
+
});
|
|
1188
|
+
}
|
|
1189
|
+
const FIX = {
|
|
1190
|
+
status: "write the step status a person reads while it runs — a string ('Planning the turn') or a locale map with 'en'",
|
|
1191
|
+
label: "write the step's name as the settings show it — a string ('Planner') or a locale map with 'en'",
|
|
1192
|
+
purpose: "write what this model call is for, in one or two plain sentences — a string or a locale map with 'en'",
|
|
1193
|
+
};
|
|
1194
|
+
for (const n of doc.nodes) {
|
|
1195
|
+
for (const field of ['status', 'label', 'purpose']) {
|
|
1196
|
+
const text = n.expose?.[field];
|
|
1197
|
+
if (text === undefined)
|
|
1198
|
+
continue;
|
|
1199
|
+
for (const message of i18nFindings(text, `'${n.key}' expose.${field}`))
|
|
1200
|
+
f.push({ law: 'R-20', severity: 'error', nodeKey: n.key, message, fix: FIX[field] });
|
|
1201
|
+
}
|
|
1202
|
+
if (n.expose?.purpose === undefined)
|
|
1203
|
+
continue;
|
|
1204
|
+
const def = getDefinition(`${n.definitionId}@${n.definitionVersion}`);
|
|
1205
|
+
if (def && !isModelCall(def))
|
|
1206
|
+
f.push({
|
|
1207
|
+
law: 'step purpose',
|
|
1208
|
+
severity: 'error',
|
|
1209
|
+
nodeKey: n.key,
|
|
1210
|
+
message: stepPurposeRefusal(n.key, def.id),
|
|
1211
|
+
fix: 'move `expose: { purpose }` to the oracle whose model this step feeds',
|
|
1212
|
+
});
|
|
1213
|
+
}
|
|
1214
|
+
return f;
|
|
1215
|
+
}
|
|
1216
|
+
/**
|
|
1217
|
+
* Whether `a` always runs after `b` has finished (F7's "after, not beside").
|
|
1218
|
+
*
|
|
1219
|
+
* A level — the spine, or one chain of one clause — runs its items one at a
|
|
1220
|
+
* time in position order; only a clause's chains may run side by side. So
|
|
1221
|
+
* `a` follows `b` exactly when, at the innermost level both sit in, the item
|
|
1222
|
+
* holding `a` is positioned after the item holding `b`. Two branches of one
|
|
1223
|
+
* clause meet at that clause's own position, and are never ordered.
|
|
1224
|
+
*/
|
|
1225
|
+
function runsStrictlyAfter(doc, a, b) {
|
|
1226
|
+
const clauseById = new Map(doc.clauses.map((c) => [c.id, c]));
|
|
1227
|
+
// Every level a node sits in, innermost first, with the position of the
|
|
1228
|
+
// item there that holds it.
|
|
1229
|
+
const levels = (n) => {
|
|
1230
|
+
const out = [];
|
|
1231
|
+
let at = n;
|
|
1232
|
+
const seen = new Set();
|
|
1233
|
+
while (at) {
|
|
1234
|
+
out.push({ level: `${at.clauseId ?? ''}\u0000${at.clauseChain ?? ''}`, position: at.position });
|
|
1235
|
+
if (!at.clauseId || seen.has(at.clauseId))
|
|
1236
|
+
break;
|
|
1237
|
+
seen.add(at.clauseId);
|
|
1238
|
+
at = clauseById.get(at.clauseId);
|
|
1239
|
+
}
|
|
1240
|
+
return out;
|
|
1241
|
+
};
|
|
1242
|
+
const bAt = new Map(levels(b).map((l) => [l.level, l.position]));
|
|
1243
|
+
for (const l of levels(a)) {
|
|
1244
|
+
const other = bAt.get(l.level);
|
|
1245
|
+
if (other !== undefined)
|
|
1246
|
+
return l.position > other;
|
|
1247
|
+
}
|
|
1248
|
+
return false;
|
|
1249
|
+
}
|
|
1250
|
+
/**
|
|
1251
|
+
* Whether two nodes can never run in the same execution (W2): they diverge
|
|
1252
|
+
* in two branches of one junction whose predicates cannot both fire.
|
|
1253
|
+
* Conservative — anything not provably exclusive is the same path.
|
|
1254
|
+
*/
|
|
1255
|
+
function exclusiveSteps(clauseById, a, b) {
|
|
1256
|
+
// Each node's ancestry, innermost first, as (clause, chain) pairs.
|
|
1257
|
+
const ancestry = (n) => {
|
|
1258
|
+
const out = [];
|
|
1259
|
+
const seen = new Set();
|
|
1260
|
+
for (let id = n.clauseId, chain = n.clauseChain; id && !seen.has(id);) {
|
|
1261
|
+
seen.add(id);
|
|
1262
|
+
out.push({ clause: id, chain });
|
|
1263
|
+
const c = clauseById.get(id);
|
|
1264
|
+
if (!c)
|
|
1265
|
+
break;
|
|
1266
|
+
id = c.clauseId;
|
|
1267
|
+
chain = c.clauseChain;
|
|
1268
|
+
}
|
|
1269
|
+
return out;
|
|
1270
|
+
};
|
|
1271
|
+
const bChains = new Map(ancestry(b).map((x) => [x.clause, x.chain]));
|
|
1272
|
+
// The innermost clause both sit in is where they diverge, if they do.
|
|
1273
|
+
for (const { clause, chain } of ancestry(a)) {
|
|
1274
|
+
if (!bChains.has(clause))
|
|
1275
|
+
continue;
|
|
1276
|
+
const other = bChains.get(clause);
|
|
1277
|
+
if (chain === other)
|
|
1278
|
+
return false;
|
|
1279
|
+
const c = clauseById.get(clause);
|
|
1280
|
+
if (!c || c.kind !== 'junction' || chain === undefined || other === undefined)
|
|
1281
|
+
return false;
|
|
1282
|
+
const p = c.branches?.[chain];
|
|
1283
|
+
const q = c.branches?.[other];
|
|
1284
|
+
return !!p && !!q && exclusivePredicates(p, q);
|
|
1285
|
+
}
|
|
1286
|
+
return false;
|
|
1287
|
+
}
|
|
1288
|
+
/** Two junction predicates that can never both fire. */
|
|
1289
|
+
function exclusivePredicates(p, q) {
|
|
1290
|
+
// `otherwise` fires exactly when nothing else did.
|
|
1291
|
+
if (p.default === true || q.default === true)
|
|
1292
|
+
return p.default !== q.default;
|
|
1293
|
+
const onlyEquals = (x) => 'equals' in x && x.equalsPath === undefined && x.truthy === undefined;
|
|
1294
|
+
if (!onlyEquals(p) || !onlyEquals(q))
|
|
1295
|
+
return false;
|
|
1296
|
+
if ((p.path ?? '') !== (q.path ?? ''))
|
|
1297
|
+
return false;
|
|
1298
|
+
return JSON.stringify(p.equals) !== JSON.stringify(q.equals);
|
|
1299
|
+
}
|
|
1300
|
+
/**
|
|
1301
|
+
* A capability id core or a plugin has actually declared.
|
|
1302
|
+
*
|
|
1303
|
+
* Transforms are checked structurally rather than against `TRANSFORMS`, because
|
|
1304
|
+
* that table names the ones core ships and a plugin may legitimately introduce
|
|
1305
|
+
* another — `image+audio->video` is not core's business but it is well-formed.
|
|
1306
|
+
* A feature, by contrast, is a closed set: it names a mechanism something has to
|
|
1307
|
+
* implement, so an unrecognised one is always a typo.
|
|
1308
|
+
*
|
|
1309
|
+
* ⚠ "Structurally" used to mean `!!lhs && !!rhs`, which passed `'text->tex'`,
|
|
1310
|
+
* `'txet->text'` and `'->'` — every typo this check exists to catch, since the
|
|
1311
|
+
* ones it did catch were already impossible to write. The real structure is
|
|
1312
|
+
* that both sides are non-empty lists of KNOWN kinds in CANONICAL order, which
|
|
1313
|
+
* is exactly "the id round-trips through `parseTransform` and back". That
|
|
1314
|
+
* rejects an unknown kind, a misspelled one, an empty side and `image+text->text`
|
|
1315
|
+
* (whose canonical spelling is `text+image->text`, so two ids would name one
|
|
1316
|
+
* capability and only one of them would ever match) — while still admitting
|
|
1317
|
+
* `image+audio->video`, because the plugin escape hatch above is the point.
|
|
1318
|
+
*
|
|
1319
|
+
* There is no registry of plugin-declared transforms to consult here: `validate`
|
|
1320
|
+
* reads a spec document, not an instance, so a set-membership test would have to
|
|
1321
|
+
* be `TRANSFORMS` alone and would close the door this docblock holds open. With
|
|
1322
|
+
* `tf()` emitting canonical spellings by construction, this is the runtime
|
|
1323
|
+
* backstop for hand-written strings rather than a check anything trips over.
|
|
1324
|
+
*/
|
|
1325
|
+
function isKnownCapability(id) {
|
|
1326
|
+
if (isTransformId(id))
|
|
1327
|
+
return canonicalise(id) === id;
|
|
1328
|
+
return FEATURES.includes(id);
|
|
1329
|
+
}
|
|
1330
|
+
/**
|
|
1331
|
+
* The canonical spelling of a transform id, or `undefined` if it is not one.
|
|
1332
|
+
*
|
|
1333
|
+
* `undefined` covers an empty side and any kind this build does not know —
|
|
1334
|
+
* neither of which has a canonical form to suggest, because there is nothing to
|
|
1335
|
+
* reorder. A mis-ORDERED id, by contrast, round-trips to a different string,
|
|
1336
|
+
* and that string is the fix.
|
|
1337
|
+
*/
|
|
1338
|
+
function canonicalise(id) {
|
|
1339
|
+
const t = parseTransform(id);
|
|
1340
|
+
if (!t.in.length || !t.out.length)
|
|
1341
|
+
return undefined;
|
|
1342
|
+
const known = (k) => IO_KINDS.includes(k);
|
|
1343
|
+
if (!t.in.every(known) || !t.out.every(known))
|
|
1344
|
+
return undefined;
|
|
1345
|
+
return transformId(t);
|
|
1346
|
+
}
|
|
1347
|
+
function reaches(doc, from, to, seen = new Set()) {
|
|
1348
|
+
if (from === to)
|
|
1349
|
+
return true;
|
|
1350
|
+
if (seen.has(from))
|
|
1351
|
+
return false;
|
|
1352
|
+
seen.add(from);
|
|
1353
|
+
return doc.edges.filter((e) => e.from === from).some((e) => reaches(doc, e.to, to, seen));
|
|
1354
|
+
}
|
|
1355
|
+
/** @experimental */
|
|
1356
|
+
export function assertValid(doc, options) {
|
|
1357
|
+
const errs = validate(doc, options).filter((x) => x.severity === 'error');
|
|
1358
|
+
if (errs.length) {
|
|
1359
|
+
throw new Error('spec validation failed:\n' +
|
|
1360
|
+
errs.map((e) => ` [${e.law}] ${e.message}\n → ${e.fix}`).join('\n'));
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
/**
|
|
1364
|
+
* The R-20 findings over one stored document: presets, and the genre
|
|
1365
|
+
* declaration a create pipeline carries. Read as `unknown` throughout — a
|
|
1366
|
+
* document may have come from anywhere — so a wrong shape is a sentence,
|
|
1367
|
+
* never a throw.
|
|
1368
|
+
* @experimental
|
|
1369
|
+
*/
|
|
1370
|
+
export function documentDisplayTextFindings(doc) {
|
|
1371
|
+
const out = [];
|
|
1372
|
+
const presets = doc.presets;
|
|
1373
|
+
if (Array.isArray(presets))
|
|
1374
|
+
presets.forEach((p, i) => {
|
|
1375
|
+
const preset = p;
|
|
1376
|
+
const at = `presets[${typeof preset?.slug === 'string' ? preset.slug : i}]`;
|
|
1377
|
+
out.push(...i18nFindings(preset?.label, `${at}.label`, { required: true }));
|
|
1378
|
+
out.push(...i18nFindings(preset?.description, `${at}.description`));
|
|
1379
|
+
});
|
|
1380
|
+
const genre = doc.genre ?? undefined;
|
|
1381
|
+
if (genre && typeof genre === 'object') {
|
|
1382
|
+
out.push(...i18nFindings(genre.name, 'genre.name', { required: true }));
|
|
1383
|
+
out.push(...i18nFindings(genre.description, 'genre.description'));
|
|
1384
|
+
const shape = genre.shape;
|
|
1385
|
+
if (shape && typeof shape === 'object') {
|
|
1386
|
+
out.push(...settingsSchemaFindings(shape.fields, 'genre.shape.fields'));
|
|
1387
|
+
out.push(...widgetDeclsFindings(shape.panels, 'genre.shape.panels'));
|
|
1388
|
+
}
|
|
1389
|
+
if (Array.isArray(genre.envoys))
|
|
1390
|
+
genre.envoys.forEach((e, i) => {
|
|
1391
|
+
const envoy = e;
|
|
1392
|
+
const at = `genre.envoys[${typeof envoy?.key === 'string' ? envoy.key : i}]`;
|
|
1393
|
+
out.push(...i18nFindings(envoy?.name, `${at}.name`, { required: true }));
|
|
1394
|
+
out.push(...i18nFindings(envoy?.description, `${at}.description`));
|
|
1395
|
+
});
|
|
1396
|
+
}
|
|
1397
|
+
return out;
|
|
1398
|
+
}
|
|
1399
|
+
//# sourceMappingURL=validate.js.map
|