@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
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Verdicts — one function per rule, heard at every door (01 §13; plans/31 V4).
|
|
3
|
+
*
|
|
4
|
+
* *A rule has exactly one verdict function. Every door — construction,
|
|
5
|
+
* `validate()`, publish (`saveDocument`), the registry, the run, the fire,
|
|
6
|
+
* the write — calls it and quotes its sentence. A door that re-derives a rule
|
|
7
|
+
* is a defect.*
|
|
8
|
+
*
|
|
9
|
+
* ## The shape
|
|
10
|
+
*
|
|
11
|
+
* A **verdict** is a declaration: an id (`core:verdict/<slug>`), the law it
|
|
12
|
+
* comes from (the label a `Finding` carries — `R-20`, `F39`), the **doors**
|
|
13
|
+
* that hear it, a `judge` over one input, and a `failing()` input the
|
|
14
|
+
* conformance kit feeds through every declared door (C27) expecting the
|
|
15
|
+
* verdict's own sentence back. The judge answers `{ ok: true }` or
|
|
16
|
+
* `{ ok: false, sentence, fix? }` — the sentence is the refusal a person
|
|
17
|
+
* reads, the fix is what to do instead (the teaching-error pattern, 15
|
|
18
|
+
* §1.3), and both are display text (R-20). A door quotes them; it composes
|
|
19
|
+
* nothing. Where a door has one string to speak through — a throw, a halt
|
|
20
|
+
* reason, a receipt note — it says the sentence and then the fix; where it
|
|
21
|
+
* has a `Finding`, the two are its `message` and `fix`.
|
|
22
|
+
*
|
|
23
|
+
* ## A door is where a rule is heard
|
|
24
|
+
*
|
|
25
|
+
* `Door` is the closed list of places a rule can be heard, SDK and host
|
|
26
|
+
* alike. A verdict declares every door that exists in code today, including
|
|
27
|
+
* the ones only a host has (`fire`, `write`, `list`, `publish`) — the kit
|
|
28
|
+
* then holds each host to the doors it has and names the rest as unjudged.
|
|
29
|
+
*
|
|
30
|
+
* ## Where a verdict is declared
|
|
31
|
+
*
|
|
32
|
+
* This module is imported by every door in the SDK — the registry
|
|
33
|
+
* (`descriptors.ts`), the action model, `validate()`, the executor — so it
|
|
34
|
+
* must sit below all of them: it reads only the leaf vocabulary (`i18n`,
|
|
35
|
+
* `predicates`, `participants`, `settingsSlot`, `hash`) and nothing above.
|
|
36
|
+
* A verdict whose judge reads a primitive above this module is declared
|
|
37
|
+
* beside that primitive, with the same `defineVerdict`, and reaches the
|
|
38
|
+
* registry the same way: the effects line and form staleness are declared
|
|
39
|
+
* in `messageBlocks.ts`, because their judges call `worldBlockFunctions`
|
|
40
|
+
* and `isFormStale`. The SDK's own graph carries no import cycle and a
|
|
41
|
+
* registry that pulled the whole vocabulary into one file would start one
|
|
42
|
+
* (DECOMPOSITION.md records what a latent cycle cost once already).
|
|
43
|
+
*
|
|
44
|
+
* `defineVerdict` is idempotent on an identical redeclaration — the same
|
|
45
|
+
* content-keyed rule every registry here applies (`refuseUnlessIdentical`),
|
|
46
|
+
* so a dev server's hot reload re-running this module is a no-op and a
|
|
47
|
+
* *different* declaration under a registered id still throws.
|
|
48
|
+
*/
|
|
49
|
+
import { type I18n } from './i18n.js';
|
|
50
|
+
import { type EnabledWhen } from './predicates.js';
|
|
51
|
+
import { type ParticipantRef, type Portrayals } from './participants.js';
|
|
52
|
+
/**
|
|
53
|
+
* The closed list of places a rule is heard:
|
|
54
|
+
*
|
|
55
|
+
* - `construction` — an author building a document or a declaration: the
|
|
56
|
+
* builder, `.preset()`, `genre()`, `announce.build()`.
|
|
57
|
+
* - `registry` — a definition registered (`register()`, the `define*`
|
|
58
|
+
* doors), or a host reading its registry against what it can run.
|
|
59
|
+
* - `validate` — `validate()` over a stored document.
|
|
60
|
+
* - `publish` — a host's `saveDocument`, the CLI packager, an install.
|
|
61
|
+
* - `run` — the executor.
|
|
62
|
+
* - `fire` — a host's action fire (`fireAction`, the verb handlers).
|
|
63
|
+
* - `write` — a host's message write (the block gate at `create-message`).
|
|
64
|
+
* - `list` — a listing or an affordance: a host's action list, a client
|
|
65
|
+
* drawing a control grey or a form collapsed.
|
|
66
|
+
* @experimental
|
|
67
|
+
*/
|
|
68
|
+
export declare const DOORS: readonly ['construction', 'registry', 'validate', 'publish', 'run', 'fire', 'write', 'list'];
|
|
69
|
+
/** @experimental */
|
|
70
|
+
export type Door = (typeof DOORS)[number];
|
|
71
|
+
/**
|
|
72
|
+
* What a judge answers. A refusal carries the sentence a person reads and,
|
|
73
|
+
* where the rule has one, the fix — both display text. `code` is a stable
|
|
74
|
+
* word for a refusal a door routes on rather than reads (none of the core
|
|
75
|
+
* verdicts needs one today; a host's may).
|
|
76
|
+
* @experimental
|
|
77
|
+
*/
|
|
78
|
+
export type VerdictResult = {
|
|
79
|
+
ok: true;
|
|
80
|
+
} | {
|
|
81
|
+
ok: false;
|
|
82
|
+
sentence: I18n;
|
|
83
|
+
fix?: I18n;
|
|
84
|
+
code?: string;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* A verdict, declared — and, once `defineVerdict` has it, registered and
|
|
88
|
+
* frozen: the declaration is the registered thing, as a `FacetDecl` or a
|
|
89
|
+
* `ScriptKindDecl` is. (The name `Verdict` is taken: `capabilities.ts`
|
|
90
|
+
* spells the answer to "can this connection run this node" that way.)
|
|
91
|
+
*
|
|
92
|
+
* `judge` and `failing` are methods, not function-typed properties, so
|
|
93
|
+
* that a `VerdictDecl<AudienceInput>` is a `VerdictDecl<unknown>` — the
|
|
94
|
+
* shape `verdicts()` enumerates — under strict function types.
|
|
95
|
+
* @experimental
|
|
96
|
+
*/
|
|
97
|
+
export interface VerdictDecl<I> {
|
|
98
|
+
/** `core:verdict/<slug>` — a kebab slug: `core:verdict/i18n`, `core:verdict/effects-line`. */
|
|
99
|
+
id: string;
|
|
100
|
+
/** The law's label, as a `Finding` carries it: `R-20`, `F39`, `F41`, `R-2`, `U5e`, `U5f`, `R-15`. */
|
|
101
|
+
law: string;
|
|
102
|
+
/** Every door that hears this rule in code today — SDK and host alike. */
|
|
103
|
+
doors: readonly Door[];
|
|
104
|
+
/** The one judgement. Pure: the same input answers the same sentence at every door. */
|
|
105
|
+
judge(input: I): VerdictResult;
|
|
106
|
+
/**
|
|
107
|
+
* A failing input the conformance kit feeds through the named door (C27);
|
|
108
|
+
* `judge(failing(door))` must be `ok: false`. Named per door because a
|
|
109
|
+
* rule with several input kinds is heard through different ones at
|
|
110
|
+
* different doors — F39's `construction` hears a declared port, its
|
|
111
|
+
* `validate` hears an edge — and the kit needs the one that door hears.
|
|
112
|
+
*/
|
|
113
|
+
failing(door: Door): I;
|
|
114
|
+
}
|
|
115
|
+
/** `owner:verdict/slug` — the owner as every other id spells it, the slug in kebab case. @experimental */
|
|
116
|
+
export declare const VERDICT_ID: RegExp;
|
|
117
|
+
/**
|
|
118
|
+
* Register a verdict and get it back frozen. Refuses an id outside the
|
|
119
|
+
* grammar, a verdict with no law or no door, and an unknown door — each
|
|
120
|
+
* with the sentence that says what to write instead. An identical
|
|
121
|
+
* redeclaration is a no-op; a different one under a registered id throws.
|
|
122
|
+
* @experimental
|
|
123
|
+
*/
|
|
124
|
+
export declare function defineVerdict<I>(decl: VerdictDecl<I>): VerdictDecl<I>;
|
|
125
|
+
/** Every registered verdict, in registration order. @experimental */
|
|
126
|
+
export declare function verdicts(): readonly VerdictDecl<unknown>[];
|
|
127
|
+
/** @experimental */
|
|
128
|
+
export declare function verdictById(id: string): VerdictDecl<unknown> | undefined;
|
|
129
|
+
/**
|
|
130
|
+
* A door with one string to speak through — a throw, a halt reason, a note —
|
|
131
|
+
* says the sentence and then the fix, in `en` through the one resolver
|
|
132
|
+
* (`i18nText`). The refusal's shape at such a door is the verdict's, not the
|
|
133
|
+
* door's: nothing here rewords either half.
|
|
134
|
+
* @internal
|
|
135
|
+
*/
|
|
136
|
+
export declare function refusalText(r: Extract<VerdictResult, {
|
|
137
|
+
ok: false;
|
|
138
|
+
}>): string;
|
|
139
|
+
/** The sentence half alone, in `en` — for a door that has nowhere to put the fix. @internal */
|
|
140
|
+
export declare function sentenceText(r: Extract<VerdictResult, {
|
|
141
|
+
ok: false;
|
|
142
|
+
}>): string;
|
|
143
|
+
/** @experimental */
|
|
144
|
+
export interface DisplayTextInput {
|
|
145
|
+
/** The value the author wrote. */
|
|
146
|
+
value: unknown;
|
|
147
|
+
/** The field's address as the author sees it (`acme:task/roll@1 i18n.name`). */
|
|
148
|
+
where: string;
|
|
149
|
+
/** Absence is a finding when the field is required. */
|
|
150
|
+
required?: boolean;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Display text is a non-blank string or a locale map with a non-blank `en`
|
|
154
|
+
* (R-20; U5i, ruled 2026-09-17). `i18nFindings` is the one check and
|
|
155
|
+
* answers at most one sentence per value; this is that check as a verdict.
|
|
156
|
+
* Every publish door runs it: `register()`, the builder's presets, `genre()`,
|
|
157
|
+
* `announce.build()`, the attribute, sheet, script-kind and value
|
|
158
|
+
* declarations, `validate()`, the CLI packager, a host's `saveDocument`, and
|
|
159
|
+
* the executor for a status (a note; the status is dropped, never a halt).
|
|
160
|
+
* @experimental
|
|
161
|
+
*/
|
|
162
|
+
export declare const i18nVerdict: VerdictDecl<DisplayTextInput>;
|
|
163
|
+
/** @experimental */
|
|
164
|
+
export interface EnablementInput {
|
|
165
|
+
/** The predicate set in force for the action — a list, one, or none. */
|
|
166
|
+
preds: ReadonlyArray<EnabledWhen> | EnabledWhen | undefined | null;
|
|
167
|
+
/** The published-values document the predicates are read over. */
|
|
168
|
+
doc: unknown;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* An action is offered now when every enabled-when predicate holds over the
|
|
172
|
+
* session's published values (plans/29 R-15; U5e). The sentence is the
|
|
173
|
+
* author's own `reason` on the first predicate that fails — that is the
|
|
174
|
+
* design: the refusal a door quotes and the grey a listing shows are the
|
|
175
|
+
* author's words, in the person's language. `evaluateEnabledWhen` is the
|
|
176
|
+
* judge; the host's listing and its fire read it through here.
|
|
177
|
+
* @internal
|
|
178
|
+
*/
|
|
179
|
+
export declare const enablementVerdict: VerdictDecl<EnablementInput>;
|
|
180
|
+
/** @experimental */
|
|
181
|
+
export interface AudienceInput {
|
|
182
|
+
/** The action's name, for the sentence. */
|
|
183
|
+
name: string;
|
|
184
|
+
/** The references being judged — an action's `act`, or its `see`. */
|
|
185
|
+
refs: ReadonlyArray<ParticipantRef>;
|
|
186
|
+
/** Who portrays each reference, as the host's resolver answered. */
|
|
187
|
+
portrayals: Portrayals;
|
|
188
|
+
/** The person asking. */
|
|
189
|
+
viewer: {
|
|
190
|
+
userId: number | string;
|
|
191
|
+
};
|
|
192
|
+
/**
|
|
193
|
+
* The item rule's answer for the message the press is on, when the host
|
|
194
|
+
* has one. Absent at a listing, where `item` is a question for a message
|
|
195
|
+
* and holds for now (`itemGated`); `false` at a fire that names no row.
|
|
196
|
+
*/
|
|
197
|
+
item?: boolean;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* An action is a person's to use when they hold one of the references its
|
|
201
|
+
* audience names (plans/29 R-15 *audience*): a portrayal naming them, or
|
|
202
|
+
* the item rule on the message. `audienceHolds` is the judge, the same
|
|
203
|
+
* function the listing's `canAct` reads, so a grey chip and a refusal at
|
|
204
|
+
* the fire can never disagree.
|
|
205
|
+
* @internal
|
|
206
|
+
*/
|
|
207
|
+
export declare const audienceVerdict: VerdictDecl<AudienceInput>;
|
|
208
|
+
/**
|
|
209
|
+
* The three shapes a setting could travel in: a data edge drawn from a
|
|
210
|
+
* node's `settings` address, a config reference naming the substrate's
|
|
211
|
+
* slot, and a definition publishing an out-port of the name — which would
|
|
212
|
+
* put a port at the address the other two are refused for.
|
|
213
|
+
* @experimental
|
|
214
|
+
*/
|
|
215
|
+
export type SettingsTravelInput = {
|
|
216
|
+
kind: 'edge';
|
|
217
|
+
from: string;
|
|
218
|
+
fromPort: string;
|
|
219
|
+
to: string;
|
|
220
|
+
toPort: string;
|
|
221
|
+
} | {
|
|
222
|
+
kind: 'reference';
|
|
223
|
+
node: string;
|
|
224
|
+
key: string;
|
|
225
|
+
slot: unknown;
|
|
226
|
+
target: string;
|
|
227
|
+
} | {
|
|
228
|
+
kind: 'port';
|
|
229
|
+
definitionId: string;
|
|
230
|
+
port: string;
|
|
231
|
+
};
|
|
232
|
+
/**
|
|
233
|
+
* Settings never travel; only data does (12 §2 P3, 29 §5d; F39).
|
|
234
|
+
* `<nodeKey>.settings.*` — `enabled`, `review`, `mode` — is read by the
|
|
235
|
+
* executor at its owner and handed to nobody. It is not a port: a data edge
|
|
236
|
+
* drawn from it carries nothing, a reference naming it resolves to nothing,
|
|
237
|
+
* and a document that draws one has made a node depend on another node's
|
|
238
|
+
* switch, which is exactly the coupling that stops two configs from being
|
|
239
|
+
* independent. Heard at the registry (a declared port of the name), at
|
|
240
|
+
* `validate()` (an edge, a reference) and by the executor (a reference in a
|
|
241
|
+
* document that skipped validation).
|
|
242
|
+
* @experimental
|
|
243
|
+
*/
|
|
244
|
+
export declare const settingsTravelVerdict: VerdictDecl<SettingsTravelInput>;
|
|
245
|
+
/**
|
|
246
|
+
* The two directions of *declared, not bound*: a document placing a
|
|
247
|
+
* definition that carries the flag, and a publication — a registry row, a
|
|
248
|
+
* picker entry — with no handler behind it and no flag excusing it.
|
|
249
|
+
* @experimental
|
|
250
|
+
*/
|
|
251
|
+
export type ProvisionalInput = {
|
|
252
|
+
kind: 'placement';
|
|
253
|
+
nodeKey: string;
|
|
254
|
+
definitionId: string;
|
|
255
|
+
definitionVersion: number | string;
|
|
256
|
+
provisional: boolean;
|
|
257
|
+
} | {
|
|
258
|
+
kind: 'publication';
|
|
259
|
+
definitionId: string;
|
|
260
|
+
provisional: boolean;
|
|
261
|
+
bound: boolean;
|
|
262
|
+
};
|
|
263
|
+
/**
|
|
264
|
+
* A provisional definition is declared, not bound (plans/29 R-2): published
|
|
265
|
+
* because a plan owns it, run by no handler. A document placing one is
|
|
266
|
+
* refused where the author is — `validate()` — and again by the executor
|
|
267
|
+
* for a stored document older than the flag, so it halts on the law rather
|
|
268
|
+
* than on "no binding registered" pointing at the wrong file. The other
|
|
269
|
+
* direction is the host's boot gate: a core definition it publishes with no
|
|
270
|
+
* handler and no flag is a packaging error, said with the three things a
|
|
271
|
+
* person can do.
|
|
272
|
+
* @internal
|
|
273
|
+
*/
|
|
274
|
+
export declare const provisionalVerdict: VerdictDecl<ProvisionalInput>;
|
|
275
|
+
//# sourceMappingURL=verdicts.d.ts.map
|
package/dist/verdicts.js
ADDED
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Verdicts — one function per rule, heard at every door (01 §13; plans/31 V4).
|
|
3
|
+
*
|
|
4
|
+
* *A rule has exactly one verdict function. Every door — construction,
|
|
5
|
+
* `validate()`, publish (`saveDocument`), the registry, the run, the fire,
|
|
6
|
+
* the write — calls it and quotes its sentence. A door that re-derives a rule
|
|
7
|
+
* is a defect.*
|
|
8
|
+
*
|
|
9
|
+
* ## The shape
|
|
10
|
+
*
|
|
11
|
+
* A **verdict** is a declaration: an id (`core:verdict/<slug>`), the law it
|
|
12
|
+
* comes from (the label a `Finding` carries — `R-20`, `F39`), the **doors**
|
|
13
|
+
* that hear it, a `judge` over one input, and a `failing()` input the
|
|
14
|
+
* conformance kit feeds through every declared door (C27) expecting the
|
|
15
|
+
* verdict's own sentence back. The judge answers `{ ok: true }` or
|
|
16
|
+
* `{ ok: false, sentence, fix? }` — the sentence is the refusal a person
|
|
17
|
+
* reads, the fix is what to do instead (the teaching-error pattern, 15
|
|
18
|
+
* §1.3), and both are display text (R-20). A door quotes them; it composes
|
|
19
|
+
* nothing. Where a door has one string to speak through — a throw, a halt
|
|
20
|
+
* reason, a receipt note — it says the sentence and then the fix; where it
|
|
21
|
+
* has a `Finding`, the two are its `message` and `fix`.
|
|
22
|
+
*
|
|
23
|
+
* ## A door is where a rule is heard
|
|
24
|
+
*
|
|
25
|
+
* `Door` is the closed list of places a rule can be heard, SDK and host
|
|
26
|
+
* alike. A verdict declares every door that exists in code today, including
|
|
27
|
+
* the ones only a host has (`fire`, `write`, `list`, `publish`) — the kit
|
|
28
|
+
* then holds each host to the doors it has and names the rest as unjudged.
|
|
29
|
+
*
|
|
30
|
+
* ## Where a verdict is declared
|
|
31
|
+
*
|
|
32
|
+
* This module is imported by every door in the SDK — the registry
|
|
33
|
+
* (`descriptors.ts`), the action model, `validate()`, the executor — so it
|
|
34
|
+
* must sit below all of them: it reads only the leaf vocabulary (`i18n`,
|
|
35
|
+
* `predicates`, `participants`, `settingsSlot`, `hash`) and nothing above.
|
|
36
|
+
* A verdict whose judge reads a primitive above this module is declared
|
|
37
|
+
* beside that primitive, with the same `defineVerdict`, and reaches the
|
|
38
|
+
* registry the same way: the effects line and form staleness are declared
|
|
39
|
+
* in `messageBlocks.ts`, because their judges call `worldBlockFunctions`
|
|
40
|
+
* and `isFormStale`. The SDK's own graph carries no import cycle and a
|
|
41
|
+
* registry that pulled the whole vocabulary into one file would start one
|
|
42
|
+
* (DECOMPOSITION.md records what a latent cycle cost once already).
|
|
43
|
+
*
|
|
44
|
+
* `defineVerdict` is idempotent on an identical redeclaration — the same
|
|
45
|
+
* content-keyed rule every registry here applies (`refuseUnlessIdentical`),
|
|
46
|
+
* so a dev server's hot reload re-running this module is a no-op and a
|
|
47
|
+
* *different* declaration under a registered id still throws.
|
|
48
|
+
*/
|
|
49
|
+
import { refuseUnlessIdentical } from './hash.js';
|
|
50
|
+
import { i18nFindings, i18nText } from './i18n.js';
|
|
51
|
+
import { evaluateEnabledWhen } from './predicates.js';
|
|
52
|
+
import { audienceHolds } from './participants.js';
|
|
53
|
+
import { SETTINGS_SLOT } from './settingsSlot.js';
|
|
54
|
+
/**
|
|
55
|
+
* The closed list of places a rule is heard:
|
|
56
|
+
*
|
|
57
|
+
* - `construction` — an author building a document or a declaration: the
|
|
58
|
+
* builder, `.preset()`, `genre()`, `announce.build()`.
|
|
59
|
+
* - `registry` — a definition registered (`register()`, the `define*`
|
|
60
|
+
* doors), or a host reading its registry against what it can run.
|
|
61
|
+
* - `validate` — `validate()` over a stored document.
|
|
62
|
+
* - `publish` — a host's `saveDocument`, the CLI packager, an install.
|
|
63
|
+
* - `run` — the executor.
|
|
64
|
+
* - `fire` — a host's action fire (`fireAction`, the verb handlers).
|
|
65
|
+
* - `write` — a host's message write (the block gate at `create-message`).
|
|
66
|
+
* - `list` — a listing or an affordance: a host's action list, a client
|
|
67
|
+
* drawing a control grey or a form collapsed.
|
|
68
|
+
* @experimental
|
|
69
|
+
*/
|
|
70
|
+
export const DOORS = [
|
|
71
|
+
'construction',
|
|
72
|
+
'registry',
|
|
73
|
+
'validate',
|
|
74
|
+
'publish',
|
|
75
|
+
'run',
|
|
76
|
+
'fire',
|
|
77
|
+
'write',
|
|
78
|
+
'list',
|
|
79
|
+
];
|
|
80
|
+
/** `owner:verdict/slug` — the owner as every other id spells it, the slug in kebab case. @experimental */
|
|
81
|
+
export const VERDICT_ID = /^[a-z0-9]+(?:[.-][a-z0-9]+)*:verdict\/[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
82
|
+
const registry = new Map();
|
|
83
|
+
const doorSet = new Set(DOORS);
|
|
84
|
+
/**
|
|
85
|
+
* Register a verdict and get it back frozen. Refuses an id outside the
|
|
86
|
+
* grammar, a verdict with no law or no door, and an unknown door — each
|
|
87
|
+
* with the sentence that says what to write instead. An identical
|
|
88
|
+
* redeclaration is a no-op; a different one under a registered id throws.
|
|
89
|
+
* @experimental
|
|
90
|
+
*/
|
|
91
|
+
export function defineVerdict(decl) {
|
|
92
|
+
if (typeof decl.id !== 'string' || !VERDICT_ID.test(decl.id))
|
|
93
|
+
throw new Error(`'${String(decl.id)}' is not a verdict id — one is '<owner>:verdict/<slug>', the slug ` +
|
|
94
|
+
`lowercase letters, digits and hyphens: core:verdict/effects-line`);
|
|
95
|
+
if (typeof decl.law !== 'string' || !decl.law.trim())
|
|
96
|
+
throw new Error(`${decl.id} names no law — 'law' is the label a Finding carries for this rule ('F39', 'R-20')`);
|
|
97
|
+
if (!Array.isArray(decl.doors) || decl.doors.length === 0)
|
|
98
|
+
throw new Error(`${decl.id} declares no door — list every place the rule is heard, one of ${DOORS.join(', ')}`);
|
|
99
|
+
const unknown = decl.doors.find((d) => !doorSet.has(d));
|
|
100
|
+
if (unknown !== undefined)
|
|
101
|
+
throw new Error(`${decl.id} declares the door '${String(unknown)}', which is not one — a door is one of ` +
|
|
102
|
+
`${DOORS.join(', ')}`);
|
|
103
|
+
if (typeof decl.judge !== 'function' || typeof decl.failing !== 'function')
|
|
104
|
+
throw new Error(`${decl.id} declares no judge or no failing input — a verdict is { id, law, doors, judge, failing }`);
|
|
105
|
+
const existing = registry.get(decl.id);
|
|
106
|
+
if (existing)
|
|
107
|
+
refuseUnlessIdentical(existing, decl, `duplicate verdict id: ${decl.id}`);
|
|
108
|
+
const verdict = Object.freeze({ ...decl, doors: Object.freeze([...decl.doors]) });
|
|
109
|
+
registry.set(decl.id, verdict);
|
|
110
|
+
return verdict;
|
|
111
|
+
}
|
|
112
|
+
/** Every registered verdict, in registration order. @experimental */
|
|
113
|
+
export function verdicts() {
|
|
114
|
+
return [...registry.values()];
|
|
115
|
+
}
|
|
116
|
+
/** @experimental */
|
|
117
|
+
export function verdictById(id) {
|
|
118
|
+
return registry.get(id);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* A door with one string to speak through — a throw, a halt reason, a note —
|
|
122
|
+
* says the sentence and then the fix, in `en` through the one resolver
|
|
123
|
+
* (`i18nText`). The refusal's shape at such a door is the verdict's, not the
|
|
124
|
+
* door's: nothing here rewords either half.
|
|
125
|
+
* @internal
|
|
126
|
+
*/
|
|
127
|
+
export function refusalText(r) {
|
|
128
|
+
const sentence = i18nText(r.sentence) ?? '';
|
|
129
|
+
return r.fix === undefined ? sentence : `${sentence} — ${i18nText(r.fix) ?? ''}`;
|
|
130
|
+
}
|
|
131
|
+
/** The sentence half alone, in `en` — for a door that has nowhere to put the fix. @internal */
|
|
132
|
+
export function sentenceText(r) {
|
|
133
|
+
return i18nText(r.sentence) ?? '';
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Display text is a non-blank string or a locale map with a non-blank `en`
|
|
137
|
+
* (R-20; U5i, ruled 2026-09-17). `i18nFindings` is the one check and
|
|
138
|
+
* answers at most one sentence per value; this is that check as a verdict.
|
|
139
|
+
* Every publish door runs it: `register()`, the builder's presets, `genre()`,
|
|
140
|
+
* `announce.build()`, the attribute, sheet, script-kind and value
|
|
141
|
+
* declarations, `validate()`, the CLI packager, a host's `saveDocument`, and
|
|
142
|
+
* the executor for a status (a note; the status is dropped, never a halt).
|
|
143
|
+
* @experimental
|
|
144
|
+
*/
|
|
145
|
+
export const i18nVerdict = defineVerdict({
|
|
146
|
+
id: 'core:verdict/i18n',
|
|
147
|
+
law: 'R-20',
|
|
148
|
+
doors: ['construction', 'registry', 'validate', 'publish', 'run'],
|
|
149
|
+
judge({ value, where, required }) {
|
|
150
|
+
const [sentence] = i18nFindings(value, where, { required });
|
|
151
|
+
return sentence === undefined ? { ok: true } : { ok: false, sentence };
|
|
152
|
+
},
|
|
153
|
+
// The field each door is asked about — the sentence names it, so the
|
|
154
|
+
// door's own address has to be the one the kit expects to hear back: a
|
|
155
|
+
// definition's name at the registry, a preset's label where a document
|
|
156
|
+
// is built, validated or published, a status's text at the run.
|
|
157
|
+
failing: (door) => ({
|
|
158
|
+
value: { fr: 'Titre' },
|
|
159
|
+
where: door === 'registry' ? 'i18n.name' : door === 'run' ? 'status.i18n' : 'presets[lore].label',
|
|
160
|
+
required: true,
|
|
161
|
+
}),
|
|
162
|
+
});
|
|
163
|
+
/**
|
|
164
|
+
* An action is offered now when every enabled-when predicate holds over the
|
|
165
|
+
* session's published values (plans/29 R-15; U5e). The sentence is the
|
|
166
|
+
* author's own `reason` on the first predicate that fails — that is the
|
|
167
|
+
* design: the refusal a door quotes and the grey a listing shows are the
|
|
168
|
+
* author's words, in the person's language. `evaluateEnabledWhen` is the
|
|
169
|
+
* judge; the host's listing and its fire read it through here.
|
|
170
|
+
* @internal
|
|
171
|
+
*/
|
|
172
|
+
export const enablementVerdict = defineVerdict({
|
|
173
|
+
id: 'core:verdict/enablement',
|
|
174
|
+
law: 'U5e',
|
|
175
|
+
doors: ['list', 'fire'],
|
|
176
|
+
judge({ preds, doc }) {
|
|
177
|
+
const heard = evaluateEnabledWhen(preds, doc);
|
|
178
|
+
return heard.enabled ? { ok: true } : { ok: false, sentence: heard.reason };
|
|
179
|
+
},
|
|
180
|
+
failing: () => ({
|
|
181
|
+
preds: [
|
|
182
|
+
{
|
|
183
|
+
on: 'state.world.conformance',
|
|
184
|
+
truthy: true,
|
|
185
|
+
reason: { en: 'conformance: the enabled-when predicate refused this press' },
|
|
186
|
+
},
|
|
187
|
+
],
|
|
188
|
+
doc: { state: { world: { conformance: false } } },
|
|
189
|
+
}),
|
|
190
|
+
});
|
|
191
|
+
/**
|
|
192
|
+
* An action is a person's to use when they hold one of the references its
|
|
193
|
+
* audience names (plans/29 R-15 *audience*): a portrayal naming them, or
|
|
194
|
+
* the item rule on the message. `audienceHolds` is the judge, the same
|
|
195
|
+
* function the listing's `canAct` reads, so a grey chip and a refusal at
|
|
196
|
+
* the fire can never disagree.
|
|
197
|
+
* @internal
|
|
198
|
+
*/
|
|
199
|
+
export const audienceVerdict = defineVerdict({
|
|
200
|
+
id: 'core:verdict/audience',
|
|
201
|
+
law: 'R-15',
|
|
202
|
+
doors: ['list', 'fire'],
|
|
203
|
+
judge({ name, refs, portrayals, viewer, item }) {
|
|
204
|
+
if (audienceHolds(refs, portrayals, viewer, item))
|
|
205
|
+
return { ok: true };
|
|
206
|
+
return {
|
|
207
|
+
ok: false,
|
|
208
|
+
sentence: `'${name}' is not yours to use here — its audience is ${refs.length ? refs.join(', ') : 'nobody'}.`,
|
|
209
|
+
};
|
|
210
|
+
},
|
|
211
|
+
failing: () => ({
|
|
212
|
+
name: 'grant',
|
|
213
|
+
refs: ['owner'],
|
|
214
|
+
portrayals: { owner: { by: 'person', userId: '1' } },
|
|
215
|
+
viewer: { userId: 2 },
|
|
216
|
+
}),
|
|
217
|
+
});
|
|
218
|
+
/** Is this the substrate's `settings` address, or a path under it? */
|
|
219
|
+
const isSettingsAddress = (name) => typeof name === 'string' && (name === SETTINGS_SLOT || name.startsWith(`${SETTINGS_SLOT}.`));
|
|
220
|
+
/**
|
|
221
|
+
* Settings never travel; only data does (12 §2 P3, 29 §5d; F39).
|
|
222
|
+
* `<nodeKey>.settings.*` — `enabled`, `review`, `mode` — is read by the
|
|
223
|
+
* executor at its owner and handed to nobody. It is not a port: a data edge
|
|
224
|
+
* drawn from it carries nothing, a reference naming it resolves to nothing,
|
|
225
|
+
* and a document that draws one has made a node depend on another node's
|
|
226
|
+
* switch, which is exactly the coupling that stops two configs from being
|
|
227
|
+
* independent. Heard at the registry (a declared port of the name), at
|
|
228
|
+
* `validate()` (an edge, a reference) and by the executor (a reference in a
|
|
229
|
+
* document that skipped validation).
|
|
230
|
+
* @experimental
|
|
231
|
+
*/
|
|
232
|
+
export const settingsTravelVerdict = defineVerdict({
|
|
233
|
+
id: 'core:verdict/settings-travel',
|
|
234
|
+
law: 'F39',
|
|
235
|
+
doors: ['registry', 'validate', 'run'],
|
|
236
|
+
judge(input) {
|
|
237
|
+
switch (input.kind) {
|
|
238
|
+
case 'edge': {
|
|
239
|
+
if (!isSettingsAddress(input.fromPort))
|
|
240
|
+
return { ok: true };
|
|
241
|
+
const { from, fromPort, to, toPort } = input;
|
|
242
|
+
return {
|
|
243
|
+
ok: false,
|
|
244
|
+
sentence: `'${to}.${toPort}' reads '${from}.${fromPort}' — a setting, not a port; ` +
|
|
245
|
+
`settings never travel, only data does`,
|
|
246
|
+
fix: `wire a port '${from}' publishes (what it DID with the setting), or declare the ` +
|
|
247
|
+
`value '${to}' needs on its own params and share the owner's with ` +
|
|
248
|
+
`slot.params({ node: '${from}' }) — the substrate's switches (enabled, review, ` +
|
|
249
|
+
`mode) are read at their owner by the executor and are never a value`,
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
case 'reference': {
|
|
253
|
+
if (!isSettingsAddress(input.slot))
|
|
254
|
+
return { ok: true };
|
|
255
|
+
const { node, key, target } = input;
|
|
256
|
+
return {
|
|
257
|
+
ok: false,
|
|
258
|
+
sentence: `'${node}.${key}' references '${target}.${SETTINGS_SLOT}' — the substrate's switches, ` +
|
|
259
|
+
`read at their owner by the executor and never a value; settings never travel, ` +
|
|
260
|
+
`only data does`,
|
|
261
|
+
fix: `read a port '${target}' publishes, or declare the value '${node}' needs on its own ` +
|
|
262
|
+
`params and share the owner's with slot.params({ node: '${target}' }) — a switch ` +
|
|
263
|
+
`(enabled, review, mode) belongs to no reference`,
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
case 'port': {
|
|
267
|
+
if (!isSettingsAddress(input.port))
|
|
268
|
+
return { ok: true };
|
|
269
|
+
const { definitionId, port } = input;
|
|
270
|
+
return {
|
|
271
|
+
ok: false,
|
|
272
|
+
sentence: `${definitionId} declares an out-port named '${port}'. '<node>.${SETTINGS_SLOT}' (and ` +
|
|
273
|
+
`paths under it) is the address of the substrate's own switches — \`enabled\`, ` +
|
|
274
|
+
`\`review\`, \`mode\` — which the executor reads at the node and hands to nobody ` +
|
|
275
|
+
`(F39: settings never travel), so an edge from a port of that name would be ` +
|
|
276
|
+
`refused as a setting`,
|
|
277
|
+
fix: `name the port for what it publishes ('result', 'applied', 'chosen')`,
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
default:
|
|
281
|
+
return {
|
|
282
|
+
ok: false,
|
|
283
|
+
sentence: `'${String(input.kind)}' is not a shape this verdict judges — one of 'edge', 'reference', 'port'.`,
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
},
|
|
287
|
+
failing: (door) => door === 'registry'
|
|
288
|
+
? { kind: 'port', definitionId: 'conformance:task/claims-settings-port@1', port: 'settings.review' }
|
|
289
|
+
: door === 'run'
|
|
290
|
+
? { kind: 'reference', node: 'probe', key: 'main', slot: SETTINGS_SLOT, target: 'save' }
|
|
291
|
+
: { kind: 'edge', from: 'save', fromPort: `${SETTINGS_SLOT}.review`, to: 'probe', toPort: 'main' },
|
|
292
|
+
});
|
|
293
|
+
/**
|
|
294
|
+
* A provisional definition is declared, not bound (plans/29 R-2): published
|
|
295
|
+
* because a plan owns it, run by no handler. A document placing one is
|
|
296
|
+
* refused where the author is — `validate()` — and again by the executor
|
|
297
|
+
* for a stored document older than the flag, so it halts on the law rather
|
|
298
|
+
* than on "no binding registered" pointing at the wrong file. The other
|
|
299
|
+
* direction is the host's boot gate: a core definition it publishes with no
|
|
300
|
+
* handler and no flag is a packaging error, said with the three things a
|
|
301
|
+
* person can do.
|
|
302
|
+
* @internal
|
|
303
|
+
*/
|
|
304
|
+
export const provisionalVerdict = defineVerdict({
|
|
305
|
+
id: 'core:verdict/provisional',
|
|
306
|
+
law: 'R-2',
|
|
307
|
+
doors: ['validate', 'run', 'registry'],
|
|
308
|
+
judge(input) {
|
|
309
|
+
switch (input.kind) {
|
|
310
|
+
case 'placement': {
|
|
311
|
+
if (!input.provisional)
|
|
312
|
+
return { ok: true };
|
|
313
|
+
const { nodeKey, definitionId, definitionVersion } = input;
|
|
314
|
+
return {
|
|
315
|
+
ok: false,
|
|
316
|
+
sentence: `'${nodeKey}' places ${definitionId}@${definitionVersion}, which is provisional — ` +
|
|
317
|
+
`declared, not bound: no handler runs it in this release (R-2)`,
|
|
318
|
+
fix: 'bind it or remove the node',
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
case 'publication': {
|
|
322
|
+
if (input.provisional || input.bound)
|
|
323
|
+
return { ok: true };
|
|
324
|
+
return {
|
|
325
|
+
ok: false,
|
|
326
|
+
sentence: `${input.definitionId} is published with no handler behind it and no plan claiming it — ` +
|
|
327
|
+
`declared, not bound (R-2)`,
|
|
328
|
+
fix: 'bind it in bindings.ts, mark it `provisional: true` under the plan that owns it, or cull it',
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
default:
|
|
332
|
+
return {
|
|
333
|
+
ok: false,
|
|
334
|
+
sentence: `'${String(input.kind)}' is not a shape this verdict judges — one of 'placement', 'publication'.`,
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
},
|
|
338
|
+
failing: (door) => door === 'registry'
|
|
339
|
+
? { kind: 'publication', definitionId: 'core:task/stray-unbound@1', provisional: false, bound: false }
|
|
340
|
+
: {
|
|
341
|
+
kind: 'placement',
|
|
342
|
+
nodeKey: 'pending',
|
|
343
|
+
definitionId: 'conformance:oracle/pending',
|
|
344
|
+
definitionVersion: 1,
|
|
345
|
+
provisional: true,
|
|
346
|
+
},
|
|
347
|
+
});
|
|
348
|
+
//# sourceMappingURL=verdicts.js.map
|