@jam-overture/loom 0.2.0 → 0.3.0
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/dist/audience/compose.d.ts +112 -0
- package/dist/audience/compose.js +134 -0
- package/dist/audience/memory.d.ts +14 -0
- package/dist/audience/memory.js +71 -0
- package/dist/audience/overlay-store.d.ts +343 -0
- package/dist/audience/overlay-store.js +217 -0
- package/dist/audience/rule.d.ts +121 -0
- package/dist/audience/rule.js +78 -0
- package/dist/cli/index.d.ts +3 -4
- package/dist/cli/index.js +3 -4
- package/dist/data/adapter.d.ts +9 -1
- package/dist/data/adapter.js +2 -0
- package/dist/data/resolve.d.ts +1 -1
- package/dist/interpretation/anthropic.d.ts +1 -1
- package/dist/interpretation/anthropic.js +2 -22
- package/dist/interpretation/client.d.ts +1 -1
- package/dist/interpretation/materialize.js +67 -22
- package/dist/interpretation/openai-compatible.d.ts +36 -0
- package/dist/interpretation/openai-compatible.js +79 -0
- package/dist/interpretation/status.d.ts +19 -0
- package/dist/interpretation/status.js +26 -0
- package/dist/live/index.d.ts +73 -0
- package/dist/live/index.js +73 -0
- package/dist/live/pages.d.ts +187 -0
- package/dist/live/pages.js +161 -0
- package/dist/live/pull.d.ts +147 -0
- package/dist/live/pull.js +398 -0
- package/dist/live/pulling.d.ts +79 -0
- package/dist/live/pulling.js +117 -0
- package/dist/live/window.d.ts +129 -0
- package/dist/live/window.js +132 -0
- package/dist/render/addressed.d.ts +35 -0
- package/dist/render/addressed.js +79 -0
- package/dist/render/document-theme.d.ts +70 -0
- package/dist/render/document-theme.js +139 -0
- package/dist/render/editable.d.ts +15 -1
- package/dist/render/editable.js +13 -1
- package/dist/render/expected.d.ts +98 -0
- package/dist/render/expected.js +88 -0
- package/dist/render/index.d.ts +2 -0
- package/dist/render/index.js +2 -0
- package/dist/render/render.d.ts +11 -0
- package/dist/render/render.js +192 -46
- package/dist/render/request.d.ts +8 -1
- package/dist/render/request.js +1 -0
- package/dist/runtime/auto-apply-ceiling.d.ts +54 -0
- package/dist/runtime/auto-apply-ceiling.js +66 -0
- package/dist/runtime/gate.js +69 -10
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.js +1 -0
- package/dist/runtime/nesting.d.ts +13 -1
- package/dist/runtime/nesting.js +41 -24
- package/dist/runtime/policy-change.js +8 -2
- package/dist/runtime/policy-log.d.ts +5 -5
- package/dist/runtime/policy.d.ts +8 -6
- package/dist/runtime/policy.js +5 -2
- package/dist/runtime/repointing.js +0 -0
- package/dist/sdk/definition.d.ts +65 -6
- package/dist/sdk/definition.js +44 -0
- package/dist/sdk/registry.d.ts +17 -1
- package/dist/sdk/registry.js +39 -0
- package/dist/signals/acted.contract.d.ts +21 -0
- package/dist/signals/acted.contract.js +236 -0
- package/dist/signals/acted.d.ts +359 -0
- package/dist/signals/acted.js +135 -0
- package/dist/signals/agenda.d.ts +585 -0
- package/dist/signals/agenda.js +295 -0
- package/dist/signals/arrivals.contract.d.ts +21 -0
- package/dist/signals/arrivals.contract.js +180 -0
- package/dist/signals/arrivals.d.ts +375 -0
- package/dist/signals/arrivals.js +254 -0
- package/dist/signals/broadcast.d.ts +25 -15
- package/dist/signals/broadcast.js +209 -36
- package/dist/signals/collect.d.ts +137 -43
- package/dist/signals/collect.js +103 -36
- package/dist/signals/conversion.d.ts +348 -0
- package/dist/signals/conversion.js +235 -0
- package/dist/signals/correlated.contract.d.ts +24 -0
- package/dist/signals/correlated.contract.js +94 -0
- package/dist/signals/counters.d.ts +51 -0
- package/dist/signals/counters.js +58 -0
- package/dist/signals/deployment-change.d.ts +28 -4
- package/dist/signals/deployment-change.js +57 -16
- package/dist/signals/deployment.d.ts +18 -5
- package/dist/signals/deployment.js +37 -11
- package/dist/signals/door.d.ts +34 -12
- package/dist/signals/door.js +37 -13
- package/dist/signals/expire.d.ts +192 -0
- package/dist/signals/expire.js +213 -0
- package/dist/signals/frontier.d.ts +268 -0
- package/dist/signals/frontier.js +145 -0
- package/dist/signals/funnel-hours.contract.d.ts +21 -0
- package/dist/signals/funnel-hours.contract.js +221 -0
- package/dist/signals/funnel-hours.d.ts +293 -0
- package/dist/signals/funnel-hours.js +99 -0
- package/dist/signals/funnel.d.ts +60 -0
- package/dist/signals/funnel.js +35 -20
- package/dist/signals/health.d.ts +201 -4
- package/dist/signals/health.js +214 -2
- package/dist/signals/index.d.ts +19 -0
- package/dist/signals/index.js +19 -0
- package/dist/signals/inside.d.ts +190 -0
- package/dist/signals/inside.js +263 -0
- package/dist/signals/join.d.ts +56 -0
- package/dist/signals/join.js +60 -0
- package/dist/signals/journal.d.ts +112 -9
- package/dist/signals/kept.contract.d.ts +22 -0
- package/dist/signals/kept.contract.js +111 -0
- package/dist/signals/library-agenda-change.d.ts +324 -0
- package/dist/signals/library-agenda-change.js +199 -0
- package/dist/signals/library-agenda.d.ts +258 -0
- package/dist/signals/library-agenda.js +167 -0
- package/dist/signals/library-reach-change.d.ts +10 -0
- package/dist/signals/library-reach-change.js +11 -3
- package/dist/signals/library-senders-change.d.ts +457 -0
- package/dist/signals/library-senders-change.js +367 -0
- package/dist/signals/library-senders-reach-change.d.ts +486 -0
- package/dist/signals/library-senders-reach-change.js +538 -0
- package/dist/signals/library-senders-reach.d.ts +340 -0
- package/dist/signals/library-senders-reach.js +252 -0
- package/dist/signals/library-senders.d.ts +271 -0
- package/dist/signals/library-senders.js +180 -0
- package/dist/signals/library-word-reach-change.js +2 -6
- package/dist/signals/memory.js +142 -1
- package/dist/signals/migrate.d.ts +6 -5
- package/dist/signals/migrate.js +150 -6
- package/dist/signals/notice.d.ts +88 -33
- package/dist/signals/notice.js +38 -16
- package/dist/signals/part-pace.d.ts +378 -0
- package/dist/signals/part-pace.js +333 -0
- package/dist/signals/parts.d.ts +25 -15
- package/dist/signals/parts.js +32 -73
- package/dist/signals/postgres.js +400 -26
- package/dist/signals/region.d.ts +1 -1
- package/dist/signals/retention.d.ts +43 -21
- package/dist/signals/retention.js +25 -8
- package/dist/signals/rhythm.d.ts +302 -0
- package/dist/signals/rhythm.js +262 -0
- package/dist/signals/rollup.d.ts +127 -1
- package/dist/signals/rollup.js +211 -24
- package/dist/signals/schema.d.ts +640 -3
- package/dist/signals/schema.js +239 -3
- package/dist/signals/silences.d.ts +310 -11
- package/dist/signals/silences.js +243 -0
- package/dist/signals/subtrees.d.ts +123 -0
- package/dist/signals/subtrees.js +102 -0
- package/dist/signals/tally.d.ts +125 -4
- package/dist/signals/unread.d.ts +292 -0
- package/dist/signals/unread.js +137 -0
- package/dist/signals/window-agenda.d.ts +276 -0
- package/dist/signals/window-agenda.js +83 -0
- package/dist/signals/window-funnels.d.ts +88 -0
- package/dist/signals/window-funnels.js +47 -0
- package/dist/store/cache.d.ts +101 -0
- package/dist/store/cache.js +149 -0
- package/dist/store/history.d.ts +82 -0
- package/dist/store/history.js +36 -0
- package/dist/store/index.d.ts +11 -0
- package/dist/store/index.js +11 -0
- package/dist/store/migrate.d.ts +26 -0
- package/dist/store/migrate.js +64 -0
- package/dist/store/postgres-audience.d.ts +14 -0
- package/dist/store/postgres-audience.js +272 -0
- package/dist/store/postgres.d.ts +1 -0
- package/dist/store/postgres.js +1 -0
- package/dist/store/schema.d.ts +312 -0
- package/dist/store/schema.js +77 -0
- package/dist/store/source.d.ts +57 -1
- package/dist/store/source.js +65 -1
- package/dist/submit/resolve.d.ts +1 -1
- package/dist/telemetry/index.d.ts +1 -0
- package/dist/telemetry/index.js +1 -0
- package/dist/telemetry/journal.d.ts +32 -0
- package/dist/telemetry/memory.js +10 -1
- package/dist/telemetry/postgres.js +18 -2
- package/dist/telemetry/window.d.ts +135 -0
- package/dist/telemetry/window.js +101 -0
- package/dist/testing/audience-overlay-contract.d.ts +31 -0
- package/dist/testing/audience-overlay-contract.js +354 -0
- package/dist/testing/contracts.d.ts +1 -0
- package/dist/testing/contracts.js +1 -0
- package/dist/testing/journal-contract.js +158 -5
- package/dist/theme/contrast.d.ts +19 -14
- package/dist/theme/contrast.js +181 -17
- package/dist/tree/apply.js +13 -0
- package/dist/tree/mutation.d.ts +18 -0
- package/dist/tree/mutation.js +24 -12
- package/dist/tree/navigation.d.ts +5 -0
- package/dist/tree/navigation.js +32 -10
- package/dist/tree/outline.d.ts +7 -0
- package/dist/tree/outline.js +9 -5
- package/package.json +39 -96
- package/dist/runtime/inverse-interpreter.d.ts +0 -90
- package/dist/runtime/inverse-interpreter.js +0 -56
package/dist/render/render.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { createElement, Fragment } from "react";
|
|
2
|
+
import { DEFAULT_AUDIENCE_ID } from "../audience/audience.js";
|
|
3
|
+
import { parseBindings } from "../data/binding.js";
|
|
2
4
|
import { NO_DATA } from "../data/resolution.js";
|
|
3
5
|
import { NO_FRAMES } from "../frame/resolution.js";
|
|
4
6
|
import { ANCHOR_PROP_KEY, DATA_PROP_KEY, SUBMIT_PROP_KEY } from "../reserved-props.js";
|
|
@@ -9,9 +11,10 @@ import { createAnchorLedger, resolveAnchor, } from "./anchor.js";
|
|
|
9
11
|
import { isBehaviourResolver, NO_RESOLVED_BEHAVIOURS, NO_CONTROL_NAME_PROPS, resolveBehaviours, resolveControlNames, } from "./behaviour.js";
|
|
10
12
|
import { literalThemeElement } from "./inline-variables.js";
|
|
11
13
|
import { editableAttributes } from "./editable.js";
|
|
14
|
+
import { checkAnswers, isAnswerReader, } from "./expected.js";
|
|
12
15
|
import { isFrameResolver, resolveNodeFrames } from "./frame.js";
|
|
13
16
|
import { NO_SLOTS, } from "./primitive.js";
|
|
14
|
-
import { isBindingReader, unreadBindings } from "./reads.js";
|
|
17
|
+
import { isBindingReader, unreadBindings, } from "./reads.js";
|
|
15
18
|
import { isSlotPlacer, unplacedSlots } from "./slots.js";
|
|
16
19
|
import { isUnshownReader, readUnshown, unshownRows, } from "./unshown.js";
|
|
17
20
|
import { isTextResolver, NO_TEXT, overlayText, } from "./text.js";
|
|
@@ -25,23 +28,41 @@ import { partitionReservedProps, resolveTheme, themeStyle, THEME_PROP_KEY } from
|
|
|
25
28
|
* with the values substituted beneath them (0283).
|
|
26
29
|
*/
|
|
27
30
|
const rampFor = (options) => options.themeValues === "literals" ? "fixed" : "fluid";
|
|
28
|
-
|
|
31
|
+
/**
|
|
32
|
+
* A list of nodes, each walked from its own root.
|
|
33
|
+
*
|
|
34
|
+
* The `.map` is one level and spends no frame per level; each `renderSubtree`
|
|
35
|
+
* carries its own stack. Only a decorative copy starts a list this way now — a
|
|
36
|
+
* node's own children are rendered by the walk that reached it.
|
|
37
|
+
*/
|
|
38
|
+
const renderNodeList = (children, context) => children.length === 0 ? null : children.map((child) => renderSubtree(child, context));
|
|
29
39
|
const isRootNode = (node, context) => node.id === context.tree.root.id;
|
|
30
|
-
|
|
40
|
+
/**
|
|
41
|
+
* The children this element receives, split the way its primitive takes them.
|
|
42
|
+
*
|
|
43
|
+
* It renders nothing. The walk has already rendered every child by the time
|
|
44
|
+
* this runs (0380), and what is left is the routing — which is why the slot
|
|
45
|
+
* rules above are a statement about `from.kind` rather than about recursion.
|
|
46
|
+
*/
|
|
47
|
+
const elementBodyFrom = (node, rendered) => {
|
|
31
48
|
if (!node.children.some((child) => child.kind === "slot")) {
|
|
32
|
-
return {
|
|
49
|
+
return {
|
|
50
|
+
children: rendered.length === 0 ? null : rendered.map((child) => child.element),
|
|
51
|
+
slots: NO_SLOTS,
|
|
52
|
+
};
|
|
33
53
|
}
|
|
34
54
|
const slots = Object.create(null);
|
|
35
55
|
const rest = [];
|
|
36
|
-
for (const child of
|
|
37
|
-
if (child.kind !== "slot") {
|
|
38
|
-
rest.push(
|
|
56
|
+
for (const child of rendered) {
|
|
57
|
+
if (child.from.kind !== "slot") {
|
|
58
|
+
rest.push(child.element);
|
|
39
59
|
continue;
|
|
40
60
|
}
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
61
|
+
const existing = slots[child.from.name];
|
|
62
|
+
slots[child.from.name] =
|
|
63
|
+
existing === undefined
|
|
64
|
+
? child.element
|
|
65
|
+
: [...(Array.isArray(existing) ? existing : [existing]), child.element];
|
|
45
66
|
}
|
|
46
67
|
return { children: rest.length === 0 ? null : rest, slots: Object.freeze(slots) };
|
|
47
68
|
};
|
|
@@ -67,7 +88,7 @@ const decorativeChildrenFor = (node, context) => {
|
|
|
67
88
|
let rendered = false;
|
|
68
89
|
return () => {
|
|
69
90
|
if (!rendered) {
|
|
70
|
-
copy =
|
|
91
|
+
copy = renderNodeList(node.children, {
|
|
71
92
|
...context,
|
|
72
93
|
editMode: false,
|
|
73
94
|
addressed: false,
|
|
@@ -94,7 +115,11 @@ const renderContextFor = (node, slots, data, submit, frames, anchor, text, behav
|
|
|
94
115
|
...(submit ? { submit } : {}),
|
|
95
116
|
...(anchor ? { anchor } : {}),
|
|
96
117
|
...(context.editMode || context.addressed
|
|
97
|
-
? {
|
|
118
|
+
? {
|
|
119
|
+
editable: isRoot
|
|
120
|
+
? editableAttributes(node, context.tree, context.audience)
|
|
121
|
+
: editableAttributes(node),
|
|
122
|
+
}
|
|
98
123
|
: {}),
|
|
99
124
|
...(theme ? { theme } : {}),
|
|
100
125
|
};
|
|
@@ -122,7 +147,11 @@ const nodeDataFor = (node, declared, context) => {
|
|
|
122
147
|
unavailable: problem.unavailable,
|
|
123
148
|
});
|
|
124
149
|
}
|
|
125
|
-
const
|
|
150
|
+
const given = context.data.lookup(node.id);
|
|
151
|
+
const declaredReads = context.reads?.bindingsReadBy(node.type);
|
|
152
|
+
const { data, refused } = checkAnswers(given, declaredReads, context.expects?.answersExpectedBy(node.type), node.props);
|
|
153
|
+
if (refused.length > 0)
|
|
154
|
+
reportRefusedAnswers(node, declared, refused, context);
|
|
126
155
|
/**
|
|
127
156
|
* A resolution that answered nothing for a node that asked for something has
|
|
128
157
|
* never heard of the node: `buildDataResolution` gives every planned binding an
|
|
@@ -137,7 +166,7 @@ const nodeDataFor = (node, declared, context) => {
|
|
|
137
166
|
if (reported === 0 && !hasAnswers(data) && asksForSomething(declared)) {
|
|
138
167
|
context.collect({ code: "data-unresolved", nodeId: node.id, resolution: "unrelated" });
|
|
139
168
|
}
|
|
140
|
-
reportUnreadBindings(node, data, context);
|
|
169
|
+
reportUnreadBindings(node, data, declaredReads, context);
|
|
141
170
|
reportUnshownRows(node, data, context);
|
|
142
171
|
return data;
|
|
143
172
|
};
|
|
@@ -168,6 +197,45 @@ const reportUnplacedSlots = (node, context) => {
|
|
|
168
197
|
context.collect({ code: "slot-unplaced", nodeId: node.id, type: node.type, name });
|
|
169
198
|
}
|
|
170
199
|
};
|
|
200
|
+
/**
|
|
201
|
+
* A diagnostic for every answer this node was given that its primitive declared
|
|
202
|
+
* it cannot read.
|
|
203
|
+
*
|
|
204
|
+
* Reported as `data-unavailable`, which is the code it is: the binding has no
|
|
205
|
+
* value, and the reason it carries says whose schema refused it — the source's
|
|
206
|
+
* own, or the primitive reading it (0357). A code of its own would have said the
|
|
207
|
+
* same thing one word differently and split anything counting bindings that went
|
|
208
|
+
* unanswered across two codes.
|
|
209
|
+
*
|
|
210
|
+
* The source id comes from the node's own `loom:data`, re-parsed here rather
|
|
211
|
+
* than carried down from the plan. It costs a parse on the one path where an
|
|
212
|
+
* answer was refused and nothing at all on every other node, which is the
|
|
213
|
+
* trade worth making: the plan's own copy would have to travel through the
|
|
214
|
+
* resolution to reach here, and a resolution is asked about a node id and
|
|
215
|
+
* deliberately knows nothing about what the node declared.
|
|
216
|
+
*
|
|
217
|
+
* A refusal whose name is not in that map cannot happen on a rendered node — a
|
|
218
|
+
* ready answer under a name is there because the plan read that name off this
|
|
219
|
+
* node — and is passed over rather than reported against a source nobody named.
|
|
220
|
+
* `nameRead` guards the same impossibility for the same reason.
|
|
221
|
+
*/
|
|
222
|
+
const reportRefusedAnswers = (node, declared, refused, context) => {
|
|
223
|
+
const bindings = parseBindings(declared);
|
|
224
|
+
if (!bindings.ok)
|
|
225
|
+
return;
|
|
226
|
+
for (const [name, bound] of bindings.value) {
|
|
227
|
+
const refusal = refused.find((candidate) => candidate.name === name);
|
|
228
|
+
if (!refusal)
|
|
229
|
+
continue;
|
|
230
|
+
context.collect({
|
|
231
|
+
code: "data-unavailable",
|
|
232
|
+
nodeId: node.id,
|
|
233
|
+
name,
|
|
234
|
+
source: bound.source,
|
|
235
|
+
unavailable: { reason: "unreadable-answer", detail: refusal.detail },
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
};
|
|
171
239
|
/**
|
|
172
240
|
* A diagnostic for every name this node was answered under that its primitive
|
|
173
241
|
* says it does not read.
|
|
@@ -188,8 +256,7 @@ const reportUnplacedSlots = (node, context) => {
|
|
|
188
256
|
* declaration may name the prop that names the binding rather than the binding
|
|
189
257
|
* (0184), and this walk is the only place holding both.
|
|
190
258
|
*/
|
|
191
|
-
const reportUnreadBindings = (node, data, context) => {
|
|
192
|
-
const declared = context.reads?.bindingsReadBy(node.type);
|
|
259
|
+
const reportUnreadBindings = (node, data, declared, context) => {
|
|
193
260
|
if (declared === undefined)
|
|
194
261
|
return;
|
|
195
262
|
const asked = [];
|
|
@@ -419,7 +486,17 @@ const reportUnreadReservedProps = (node, reserved, isRoot, context) => {
|
|
|
419
486
|
context.collect({ code: "reserved-prop-unrecognised", nodeId: node.id, key });
|
|
420
487
|
}
|
|
421
488
|
};
|
|
422
|
-
|
|
489
|
+
/**
|
|
490
|
+
* Everything about an element that is settled before its children are walked,
|
|
491
|
+
* returned as the assembly that finishes it — or `null` where the node is
|
|
492
|
+
* omitted and its subtree is never walked at all.
|
|
493
|
+
*
|
|
494
|
+
* The split is at the seam `renderElementBody` used to sit on (0380). It is
|
|
495
|
+
* what lets the walk be a loop: the order props are validated in and anchors
|
|
496
|
+
* are claimed in is document order, which this preserves by running on the way
|
|
497
|
+
* down, and the element itself is built on the way up.
|
|
498
|
+
*/
|
|
499
|
+
const prepareElement = (node, context) => {
|
|
423
500
|
const primitive = context.resolver.resolve(node.type);
|
|
424
501
|
/**
|
|
425
502
|
* An unknown primitive omits its whole subtree rather than promoting the
|
|
@@ -473,39 +550,106 @@ const renderElement = (node, context) => {
|
|
|
473
550
|
const text = context.text?.textFor(node.type) ?? NO_TEXT;
|
|
474
551
|
const behaviours = nodeBehavioursFor(node, props, text, context);
|
|
475
552
|
reportUnplacedSlots(node, context);
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
553
|
+
return (body) => {
|
|
554
|
+
const rendered = {
|
|
555
|
+
loom: renderContextFor(node, body.slots, data, submit, frames, anchor, text, behaviours, context),
|
|
556
|
+
props,
|
|
557
|
+
children: body.children,
|
|
558
|
+
};
|
|
559
|
+
return context.literals
|
|
560
|
+
? literalThemeElement(primitive, context.literals, node.id, rendered)
|
|
561
|
+
: createElement(primitive, { key: node.id, ...rendered });
|
|
481
562
|
};
|
|
482
|
-
return context.literals
|
|
483
|
-
? literalThemeElement(primitive, context.literals, node.id, rendered)
|
|
484
|
-
: createElement(primitive, { key: node.id, ...rendered });
|
|
485
563
|
};
|
|
486
564
|
/**
|
|
487
|
-
* A slot is a projection point, not a box
|
|
488
|
-
*
|
|
489
|
-
*
|
|
565
|
+
* A slot is a projection point, not a box: it adds no element of its own
|
|
566
|
+
* whether it carries what the host projected or its own children as the
|
|
567
|
+
* fallback. Which of the two it carries is decided in the walk, because only
|
|
568
|
+
* the fallback has children to render first.
|
|
490
569
|
*/
|
|
491
|
-
const
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
570
|
+
const slotFragment = (node, projected) => createElement(Fragment, { key: node.id }, projected);
|
|
571
|
+
const readChildren = (work, children) => {
|
|
572
|
+
/** Reversed, so the pop order is the document order the recursion gave. */
|
|
573
|
+
for (let index = children.length - 1; index >= 0; index -= 1) {
|
|
574
|
+
const child = children[index];
|
|
575
|
+
if (child)
|
|
576
|
+
work.push({ step: "read", node: child });
|
|
577
|
+
}
|
|
497
578
|
};
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
579
|
+
/**
|
|
580
|
+
* One subtree, rendered with an **explicit stack** and no call frame per level
|
|
581
|
+
* (0380).
|
|
582
|
+
*
|
|
583
|
+
* Until this was a loop, a page of a thousand elements threw
|
|
584
|
+
* `RangeError: Maximum call stack size exceeded` — on **every** render, and at
|
|
585
|
+
* the shallowest depth anything in the framework stopped at. React is not the
|
|
586
|
+
* reason that bound existed: its own server renderer walks fifty thousand
|
|
587
|
+
* levels in 135 ms, so what stopped a deep page was this function.
|
|
588
|
+
*
|
|
589
|
+
* Nothing about the output moves. Elements are prepared on the way down, in
|
|
590
|
+
* document order, which is what the anchor ledger and the diagnostic order
|
|
591
|
+
* depend on; they are built on the way up, around children that are already
|
|
592
|
+
* `ReactNode`s. A node the renderer omits is pushed as `null` and its subtree
|
|
593
|
+
* is never read, which is how a subtree under an unknown primitive stays silent
|
|
594
|
+
* rather than raising a diagnostic per node.
|
|
595
|
+
*/
|
|
596
|
+
const renderSubtree = (root, context) => {
|
|
597
|
+
const work = [{ step: "read", node: root }];
|
|
598
|
+
const finished = [];
|
|
599
|
+
/** The last `count` children, taken off the stack in document order. */
|
|
600
|
+
const take = (count) => finished.splice(finished.length - count, count);
|
|
601
|
+
for (let next = work.pop(); next !== undefined; next = work.pop()) {
|
|
602
|
+
switch (next.step) {
|
|
603
|
+
case "build":
|
|
604
|
+
finished.push({
|
|
605
|
+
from: next.node,
|
|
606
|
+
element: next.assemble(elementBodyFrom(next.node, take(next.children))),
|
|
607
|
+
});
|
|
608
|
+
continue;
|
|
609
|
+
case "fill": {
|
|
610
|
+
const fallback = take(next.children);
|
|
611
|
+
finished.push({
|
|
612
|
+
from: next.node,
|
|
613
|
+
element: slotFragment(next.node, fallback.length === 0 ? null : fallback.map((child) => child.element)),
|
|
614
|
+
});
|
|
615
|
+
continue;
|
|
616
|
+
}
|
|
617
|
+
case "read":
|
|
618
|
+
break;
|
|
619
|
+
default:
|
|
620
|
+
return assertNever(next, "renderSubtree");
|
|
621
|
+
}
|
|
622
|
+
const node = next.node;
|
|
623
|
+
switch (node.kind) {
|
|
624
|
+
case "text":
|
|
625
|
+
finished.push({ from: node, element: node.value });
|
|
626
|
+
break;
|
|
627
|
+
case "slot":
|
|
628
|
+
/** Own-property only, for the reason given in `staticPrimitiveResolver`. */
|
|
629
|
+
if (Object.hasOwn(context.slots, node.name)) {
|
|
630
|
+
finished.push({ from: node, element: slotFragment(node, context.slots[node.name]) });
|
|
631
|
+
break;
|
|
632
|
+
}
|
|
633
|
+
work.push({ step: "fill", node, children: node.children.length });
|
|
634
|
+
readChildren(work, node.children);
|
|
635
|
+
break;
|
|
636
|
+
case "element": {
|
|
637
|
+
const assemble = prepareElement(node, context);
|
|
638
|
+
if (!assemble) {
|
|
639
|
+
finished.push({ from: node, element: null });
|
|
640
|
+
break;
|
|
641
|
+
}
|
|
642
|
+
work.push({ step: "build", node, assemble, children: node.children.length });
|
|
643
|
+
readChildren(work, node.children);
|
|
644
|
+
break;
|
|
645
|
+
}
|
|
646
|
+
default:
|
|
647
|
+
return assertNever(node, "renderSubtree");
|
|
648
|
+
}
|
|
508
649
|
}
|
|
650
|
+
const rendered = finished[0];
|
|
651
|
+
/** Unreachable: one node in, one element out, and every branch pushes one. */
|
|
652
|
+
return rendered ? rendered.element : null;
|
|
509
653
|
};
|
|
510
654
|
/**
|
|
511
655
|
* The theme is resolved once, from the root, before the walk begins — a tree
|
|
@@ -583,11 +727,12 @@ const renderFrom = (tree, from, options, collect) => {
|
|
|
583
727
|
if (options.themeValues === "literals" && !theme) {
|
|
584
728
|
collect({ code: "theme-values-unmounted", nodeId: tree.root.id });
|
|
585
729
|
}
|
|
586
|
-
const element =
|
|
730
|
+
const element = renderSubtree(from, {
|
|
587
731
|
resolver: options.resolver,
|
|
588
732
|
validator: options.validator,
|
|
589
733
|
editMode: options.editMode ?? false,
|
|
590
734
|
addressed: options.addressed ?? false,
|
|
735
|
+
audience: options.audience === DEFAULT_AUDIENCE_ID ? undefined : options.audience,
|
|
591
736
|
slots: options.slots ?? {},
|
|
592
737
|
tree,
|
|
593
738
|
theme: theme ? themeStyle(theme, rampFor(options)) : undefined,
|
|
@@ -596,6 +741,7 @@ const renderFrom = (tree, from, options, collect) => {
|
|
|
596
741
|
origins: options.origins,
|
|
597
742
|
frames: isFrameResolver(options.resolver) ? options.resolver : undefined,
|
|
598
743
|
reads: isBindingReader(options.resolver) ? options.resolver : undefined,
|
|
744
|
+
expects: isAnswerReader(options.resolver) ? options.resolver : undefined,
|
|
599
745
|
unshown: isUnshownReader(options.resolver) ? options.resolver : undefined,
|
|
600
746
|
placer: isSlotPlacer(options.resolver) ? options.resolver : undefined,
|
|
601
747
|
text: composeText(options.resolver, options.text),
|
package/dist/render/request.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AudienceId } from "../audience/audience.js";
|
|
1
2
|
import type { DataRegistry } from "../data/adapter.js";
|
|
2
3
|
import type { FrameOriginRegistry } from "../frame/origin.js";
|
|
3
4
|
import type { TreeId } from "../ids.js";
|
|
@@ -33,8 +34,14 @@ export type RenderRequest = {
|
|
|
33
34
|
* they are about. Off when absent (0136).
|
|
34
35
|
*/
|
|
35
36
|
readonly addressed?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* The segment the site's server sorted this reader into, written on an
|
|
39
|
+
* addressed page's root so its signals are filed under it. See
|
|
40
|
+
* `RenderOptions.audience`.
|
|
41
|
+
*/
|
|
42
|
+
readonly audience?: AudienceId | undefined;
|
|
36
43
|
/** Opaque host context — audience, locale, flags — passed through to the source. */
|
|
37
|
-
readonly context?: JsonObject;
|
|
44
|
+
readonly context?: JsonObject | undefined;
|
|
38
45
|
};
|
|
39
46
|
export type TreeSourceError = {
|
|
40
47
|
readonly code: "not-found" | "unavailable";
|
package/dist/render/request.js
CHANGED
|
@@ -46,6 +46,7 @@ export const renderRequest = async (request, dependencies) => {
|
|
|
46
46
|
resolver: dependencies.resolver,
|
|
47
47
|
editMode: request.editMode,
|
|
48
48
|
...(request.addressed ? { addressed: true } : {}),
|
|
49
|
+
audience: request.audience,
|
|
49
50
|
...(dependencies.validator ? { validator: dependencies.validator } : {}),
|
|
50
51
|
...(dependencies.themes ? { themes: dependencies.themes } : {}),
|
|
51
52
|
...(data ? { data } : {}),
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { type StakeLevel } from "./stake-level.js";
|
|
3
|
+
/**
|
|
4
|
+
* How much a policy lets an origin apply unattended, including none of it.
|
|
5
|
+
*
|
|
6
|
+
* A ceiling used to be a stake level, which made the strictest thing a
|
|
7
|
+
* deployment could say about an origin *low-stakes changes go live*. There is
|
|
8
|
+
* no level beneath `low`, so *nothing goes live, every change waits for a
|
|
9
|
+
* person* was not expressible at all — not by a lower ceiling, which does not
|
|
10
|
+
* exist, and not by `refusalFloor`, which throws the change away instead of
|
|
11
|
+
* holding it for somebody to look at.
|
|
12
|
+
*
|
|
13
|
+
* So the ceiling is its own scale: the four stake levels with one more rung
|
|
14
|
+
* below them. It lives beside the levels rather than among them because
|
|
15
|
+
* `nothing` is not a measure of damage — nothing is ever assessed at `nothing`
|
|
16
|
+
* stakes — and putting it in `STAKE_ORDER` would offer it to every reader of a
|
|
17
|
+
* level, `refusalFloor` and a role's acceptance ceiling included (0285).
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* The rung below `low`: this origin applies nothing on its own.
|
|
21
|
+
*
|
|
22
|
+
* Spelled as a word rather than as an absent entry, because an absent entry
|
|
23
|
+
* already means something — `ceilingFor` reads it as `low` — and a policy
|
|
24
|
+
* cannot say *I thought about this origin and decided none of it* by leaving it
|
|
25
|
+
* out.
|
|
26
|
+
*/
|
|
27
|
+
export declare const NOTHING_AUTO_APPLIES = "nothing";
|
|
28
|
+
export declare const autoApplyCeilingSchema: z.ZodUnion<[z.ZodLiteral<"nothing">, z.ZodEnum<["low", "medium", "high", "critical"]>]>;
|
|
29
|
+
/** A stake level, or the rung below all of them. */
|
|
30
|
+
export type AutoApplyCeiling = z.infer<typeof autoApplyCeilingSchema>;
|
|
31
|
+
/**
|
|
32
|
+
* The ceiling scale in order, which like `STAKE_ORDER` is the order and not
|
|
33
|
+
* merely the set.
|
|
34
|
+
*
|
|
35
|
+
* Built from the stake order rather than written out again, so a level added to
|
|
36
|
+
* the scale the Gate weighs on arrives here in the same edit and cannot be
|
|
37
|
+
* ranked by accident.
|
|
38
|
+
*/
|
|
39
|
+
export declare const CEILING_ORDER: readonly AutoApplyCeiling[];
|
|
40
|
+
/**
|
|
41
|
+
* Two ceilings compared. Only the sign is meaningful: negative is stricter,
|
|
42
|
+
* positive is looser, zero is the same latitude.
|
|
43
|
+
*/
|
|
44
|
+
export declare const compareCeilings: (left: AutoApplyCeiling, right: AutoApplyCeiling) => number;
|
|
45
|
+
/**
|
|
46
|
+
* Whether a change assessed at this level is above what the origin may apply
|
|
47
|
+
* unattended — which, at `nothing`, every change is.
|
|
48
|
+
*
|
|
49
|
+
* A stake level is a ceiling, so this is one comparison on one scale rather
|
|
50
|
+
* than a branch on the sentinel. `low` stakes against a `low` ceiling is *at*
|
|
51
|
+
* it and applies; `low` stakes against `nothing` is above it and waits.
|
|
52
|
+
*/
|
|
53
|
+
export declare const isAboveCeiling: (level: StakeLevel, ceiling: AutoApplyCeiling) => boolean;
|
|
54
|
+
//# sourceMappingURL=auto-apply-ceiling.d.ts.map
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { everyMemberOf } from "../closed-set.js";
|
|
3
|
+
import { STAKE_ORDER, stakeLevelSchema } from "./stake-level.js";
|
|
4
|
+
/**
|
|
5
|
+
* How much a policy lets an origin apply unattended, including none of it.
|
|
6
|
+
*
|
|
7
|
+
* A ceiling used to be a stake level, which made the strictest thing a
|
|
8
|
+
* deployment could say about an origin *low-stakes changes go live*. There is
|
|
9
|
+
* no level beneath `low`, so *nothing goes live, every change waits for a
|
|
10
|
+
* person* was not expressible at all — not by a lower ceiling, which does not
|
|
11
|
+
* exist, and not by `refusalFloor`, which throws the change away instead of
|
|
12
|
+
* holding it for somebody to look at.
|
|
13
|
+
*
|
|
14
|
+
* So the ceiling is its own scale: the four stake levels with one more rung
|
|
15
|
+
* below them. It lives beside the levels rather than among them because
|
|
16
|
+
* `nothing` is not a measure of damage — nothing is ever assessed at `nothing`
|
|
17
|
+
* stakes — and putting it in `STAKE_ORDER` would offer it to every reader of a
|
|
18
|
+
* level, `refusalFloor` and a role's acceptance ceiling included (0285).
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* The rung below `low`: this origin applies nothing on its own.
|
|
22
|
+
*
|
|
23
|
+
* Spelled as a word rather than as an absent entry, because an absent entry
|
|
24
|
+
* already means something — `ceilingFor` reads it as `low` — and a policy
|
|
25
|
+
* cannot say *I thought about this origin and decided none of it* by leaving it
|
|
26
|
+
* out.
|
|
27
|
+
*/
|
|
28
|
+
export const NOTHING_AUTO_APPLIES = "nothing";
|
|
29
|
+
export const autoApplyCeilingSchema = z.union([z.literal(NOTHING_AUTO_APPLIES), stakeLevelSchema]);
|
|
30
|
+
/**
|
|
31
|
+
* The ceiling scale in order, which like `STAKE_ORDER` is the order and not
|
|
32
|
+
* merely the set.
|
|
33
|
+
*
|
|
34
|
+
* Built from the stake order rather than written out again, so a level added to
|
|
35
|
+
* the scale the Gate weighs on arrives here in the same edit and cannot be
|
|
36
|
+
* ranked by accident.
|
|
37
|
+
*/
|
|
38
|
+
export const CEILING_ORDER = everyMemberOf()([
|
|
39
|
+
NOTHING_AUTO_APPLIES,
|
|
40
|
+
...STAKE_ORDER,
|
|
41
|
+
]);
|
|
42
|
+
/**
|
|
43
|
+
* Where a ceiling sits on that scale.
|
|
44
|
+
*
|
|
45
|
+
* `indexOf` answers `-1` for a value this list does not name, which ranks it
|
|
46
|
+
* beneath `nothing` and so waves the change through — the same reassuring
|
|
47
|
+
* failure `rankOf` in `stake-level.ts` documents, reached the same way and
|
|
48
|
+
* filed in the same entry. The list is complete at compile time, so the route
|
|
49
|
+
* left is a value that never passed through the types.
|
|
50
|
+
*/
|
|
51
|
+
const rankOf = (ceiling) => CEILING_ORDER.indexOf(ceiling);
|
|
52
|
+
/**
|
|
53
|
+
* Two ceilings compared. Only the sign is meaningful: negative is stricter,
|
|
54
|
+
* positive is looser, zero is the same latitude.
|
|
55
|
+
*/
|
|
56
|
+
export const compareCeilings = (left, right) => rankOf(left) - rankOf(right);
|
|
57
|
+
/**
|
|
58
|
+
* Whether a change assessed at this level is above what the origin may apply
|
|
59
|
+
* unattended — which, at `nothing`, every change is.
|
|
60
|
+
*
|
|
61
|
+
* A stake level is a ceiling, so this is one comparison on one scale rather
|
|
62
|
+
* than a branch on the sentinel. `low` stakes against a `low` ceiling is *at*
|
|
63
|
+
* it and applies; `low` stakes against `nothing` is above it and waits.
|
|
64
|
+
*/
|
|
65
|
+
export const isAboveCeiling = (level, ceiling) => compareCeilings(level, ceiling) > 0;
|
|
66
|
+
//# sourceMappingURL=auto-apply-ceiling.js.map
|
package/dist/runtime/gate.js
CHANGED
|
@@ -1,7 +1,24 @@
|
|
|
1
|
+
import { isAboveCeiling, NOTHING_AUTO_APPLIES, } from "./auto-apply-ceiling.js";
|
|
1
2
|
import { policyFingerprintOf } from "./policy-fingerprint.js";
|
|
2
3
|
import { ceilingFor } from "./policy.js";
|
|
3
|
-
import {
|
|
4
|
+
import { isAtLeast } from "./stake-level.js";
|
|
4
5
|
import { stakeFactor } from "./stakes.js";
|
|
6
|
+
/**
|
|
7
|
+
* The clause the four rungs below the refusal floor share, because they share
|
|
8
|
+
* one argument: a level cannot say "never auto-apply" while ceilings are per
|
|
9
|
+
* origin (0002), so these facts are held for a person regardless of who asked.
|
|
10
|
+
*/
|
|
11
|
+
const HELD_WHATEVER_THE_ORIGIN = "this deployment holds for a person whatever its origin may apply";
|
|
12
|
+
/**
|
|
13
|
+
* A reason's sentence: what the change does, then what the policy did about it.
|
|
14
|
+
*
|
|
15
|
+
* Both halves, because either alone has been mistaken for the whole. The damage
|
|
16
|
+
* on its own is identical for a change that is held and the same change refused
|
|
17
|
+
* — the damage really is the same, and a reviewer shown only that cannot tell
|
|
18
|
+
* *this needs you* from *this will never be offered*. The consequence on its own
|
|
19
|
+
* would describe a policy and never the change in front of the reader.
|
|
20
|
+
*/
|
|
21
|
+
const sentence = (damage, consequence) => damage.length > 0 ? `${damage}, which ${consequence}` : consequence;
|
|
5
22
|
const decide = (assessment, policy, kind, reason) => ({
|
|
6
23
|
kind,
|
|
7
24
|
reason,
|
|
@@ -54,6 +71,7 @@ const rejectBelowConfidenceFloor = {
|
|
|
54
71
|
return null;
|
|
55
72
|
return `interpreter confidence ${confidence} is below the floor of ${policy.confidenceFloor}`;
|
|
56
73
|
},
|
|
74
|
+
consequence: () => "this deployment refuses outright",
|
|
57
75
|
};
|
|
58
76
|
/** Some changes are not offered to the user at all, however they were asked for. */
|
|
59
77
|
const rejectAtRefusalFloor = {
|
|
@@ -62,9 +80,9 @@ const rejectAtRefusalFloor = {
|
|
|
62
80
|
fires: (assessment, policy) => {
|
|
63
81
|
if (!isAtLeast(assessment.stakes.level, policy.refusalFloor))
|
|
64
82
|
return null;
|
|
65
|
-
|
|
66
|
-
return detail || `stakes reached ${policy.refusalFloor}`;
|
|
83
|
+
return assessment.stakes.factors.map((factor) => factor.detail).join("; ");
|
|
67
84
|
},
|
|
85
|
+
consequence: (_assessment, policy) => `this deployment refuses outright at ${policy.refusalFloor} stakes`,
|
|
68
86
|
};
|
|
69
87
|
/** Undo would not undo reality, so a human decides — regardless of how small it looks. */
|
|
70
88
|
const confirmIrreversible = {
|
|
@@ -76,6 +94,7 @@ const confirmIrreversible = {
|
|
|
76
94
|
const detail = assessment.reversibility.reasons.map((reason) => reason.code).join("; ");
|
|
77
95
|
return `cannot be undone cleanly: ${detail}`;
|
|
78
96
|
},
|
|
97
|
+
consequence: () => HELD_WHATEVER_THE_ORIGIN,
|
|
79
98
|
};
|
|
80
99
|
/**
|
|
81
100
|
* A change that writes over work already in the log is never applied without a
|
|
@@ -94,6 +113,7 @@ const confirmDiscardsLaterWork = {
|
|
|
94
113
|
code: "discards-later-work",
|
|
95
114
|
kind: "requires-confirmation",
|
|
96
115
|
fires: (assessment) => stakeFactor(assessment.stakes, "discards-later-work")?.detail ?? null,
|
|
116
|
+
consequence: () => HELD_WHATEVER_THE_ORIGIN,
|
|
97
117
|
};
|
|
98
118
|
/**
|
|
99
119
|
* A change that moves where a form posts is never applied without a person,
|
|
@@ -111,6 +131,7 @@ const confirmRedirectedSubmission = {
|
|
|
111
131
|
code: "redirected-submission",
|
|
112
132
|
kind: "requires-confirmation",
|
|
113
133
|
fires: (assessment) => stakeFactor(assessment.stakes, "redirected-submission")?.detail ?? null,
|
|
134
|
+
consequence: () => HELD_WHATEVER_THE_ORIGIN,
|
|
114
135
|
};
|
|
115
136
|
/**
|
|
116
137
|
* A change that points a region at different data is never applied without a
|
|
@@ -128,18 +149,51 @@ const confirmRepointedBinding = {
|
|
|
128
149
|
code: "repointed-binding",
|
|
129
150
|
kind: "requires-confirmation",
|
|
130
151
|
fires: (assessment) => stakeFactor(assessment.stakes, "repointed-binding")?.detail ?? null,
|
|
152
|
+
consequence: () => HELD_WHATEVER_THE_ORIGIN,
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* What the ceiling rung says the change does, and why at `nothing` it says
|
|
156
|
+
* nothing at all.
|
|
157
|
+
*
|
|
158
|
+
* Everywhere else the factors are the better damage line: they say what about
|
|
159
|
+
* *this* change took it over the line, which is what somebody deciding whether
|
|
160
|
+
* to allow it wants. At `nothing` there is no line this change crossed — the
|
|
161
|
+
* deployment decided in advance that this origin applies none of its changes
|
|
162
|
+
* (0405) — so naming a factor would offer a reason that is not the reason, and
|
|
163
|
+
* invite a person to think a smaller change would have gone through.
|
|
164
|
+
*
|
|
165
|
+
* It is therefore the one rung whose damage half is empty *by policy* rather
|
|
166
|
+
* than for want of a factor to name, and the consequence below is the whole
|
|
167
|
+
* sentence. That is the single exception to the two-half shape, and it is an
|
|
168
|
+
* exception in the half that is said rather than in the half that is left out:
|
|
169
|
+
* the sentence still names the verdict and still names what decided it.
|
|
170
|
+
*/
|
|
171
|
+
const ceilingDamage = (assessment, ceiling) => ceiling === NOTHING_AUTO_APPLIES
|
|
172
|
+
? ""
|
|
173
|
+
: assessment.stakes.factors.map((factor) => factor.detail).join("; ");
|
|
174
|
+
/**
|
|
175
|
+
* What this deployment did about it, and on which of its thresholds.
|
|
176
|
+
*
|
|
177
|
+
* At `nothing` the threshold is the origin itself rather than a level on the
|
|
178
|
+
* scale, so the clause names the origin and what it is configured to apply —
|
|
179
|
+
* which is both what the policy did and the fact that a person is required.
|
|
180
|
+
*/
|
|
181
|
+
const ceilingConsequence = (assessment, ceiling) => {
|
|
182
|
+
const { origin } = assessment.proposal.provenance;
|
|
183
|
+
if (ceiling === NOTHING_AUTO_APPLIES)
|
|
184
|
+
return `${origin} applies nothing without a person`;
|
|
185
|
+
return `this deployment holds for a person above ${origin}'s ${ceiling} ceiling`;
|
|
131
186
|
};
|
|
132
187
|
const confirmAboveCeiling = {
|
|
133
188
|
code: "stakes-above-ceiling",
|
|
134
189
|
kind: "requires-confirmation",
|
|
135
190
|
fires: (assessment, policy) => {
|
|
136
191
|
const ceiling = ceilingFor(policy, assessment.proposal.provenance.origin);
|
|
137
|
-
if (!
|
|
192
|
+
if (!isAboveCeiling(assessment.stakes.level, ceiling))
|
|
138
193
|
return null;
|
|
139
|
-
|
|
140
|
-
return (detail ||
|
|
141
|
-
`${assessment.stakes.level} stakes exceed the ${ceiling} ceiling for ${assessment.proposal.provenance.origin}`);
|
|
194
|
+
return ceilingDamage(assessment, ceiling);
|
|
142
195
|
},
|
|
196
|
+
consequence: (assessment, policy) => ceilingConsequence(assessment, ceilingFor(policy, assessment.proposal.provenance.origin)),
|
|
143
197
|
};
|
|
144
198
|
const confirmBelowMinimumConfidence = {
|
|
145
199
|
code: "confidence-below-minimum",
|
|
@@ -150,6 +204,7 @@ const confirmBelowMinimumConfidence = {
|
|
|
150
204
|
return null;
|
|
151
205
|
return `interpreter confidence ${confidence} is below ${policy.minimumConfidence}`;
|
|
152
206
|
},
|
|
207
|
+
consequence: () => "this deployment holds for a person",
|
|
153
208
|
};
|
|
154
209
|
/** Nothing objected, so the change goes through. */
|
|
155
210
|
const accept = (assessment, policy) => decide(assessment, policy, "accepted", {
|
|
@@ -182,9 +237,13 @@ const ESCALATION_RULES = [
|
|
|
182
237
|
export const ESCALATION_LADDER = ESCALATION_RULES.map((rule) => rule.code);
|
|
183
238
|
export const gate = (assessment, policy) => {
|
|
184
239
|
for (const rule of ESCALATION_RULES) {
|
|
185
|
-
const
|
|
186
|
-
if (
|
|
187
|
-
|
|
240
|
+
const damage = rule.fires(assessment, policy);
|
|
241
|
+
if (damage === null)
|
|
242
|
+
continue;
|
|
243
|
+
return decide(assessment, policy, rule.kind, {
|
|
244
|
+
code: rule.code,
|
|
245
|
+
detail: sentence(damage, rule.consequence(assessment, policy)),
|
|
246
|
+
});
|
|
188
247
|
}
|
|
189
248
|
return accept(assessment, policy);
|
|
190
249
|
};
|
package/dist/runtime/index.d.ts
CHANGED