@serene-pub/sdk 0.6.0-pr-2 → 0.6.0-pr-5
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/README.md +24 -20
- package/dist/actions.d.ts +150 -68
- package/dist/actions.js +90 -36
- package/dist/annexFields.d.ts +8 -4
- package/dist/annexFields.js +5 -2
- package/dist/announce.d.ts +78 -28
- package/dist/announce.js +14 -5
- package/dist/attributes.d.ts +9 -6
- package/dist/attributes.js +9 -5
- package/dist/bands.d.ts +41 -6
- package/dist/bands.js +83 -33
- package/dist/builder.d.ts +161 -58
- package/dist/builder.js +128 -22
- package/dist/candidates.d.ts +5 -3
- package/dist/candidates.js +3 -2
- package/dist/clauses.d.ts +2 -1
- package/dist/clauses.js +2 -1
- package/dist/component.d.ts +24 -7
- package/dist/component.js +16 -6
- package/dist/componentBuild.d.ts +16 -5
- package/dist/componentBuild.js +14 -5
- package/dist/componentClient.d.ts +61 -30
- package/dist/componentClient.js +11 -1
- package/dist/componentImports.d.ts +8 -5
- package/dist/componentImports.js +23 -4
- package/dist/componentModule.js +2 -1
- package/dist/componentWire.d.ts +2 -1
- package/dist/componentWire.js +34 -2
- package/dist/config.d.ts +28 -14
- package/dist/config.js +20 -10
- package/dist/connections.d.ts +9 -4
- package/dist/connections.js +7 -4
- package/dist/declarations.d.ts +46 -17
- package/dist/declarations.js +46 -15
- package/dist/descriptors.d.ts +242 -97
- package/dist/descriptors.js +145 -41
- package/dist/dev.d.ts +6 -5
- package/dist/dev.js +6 -5
- package/dist/document.d.ts +74 -25
- package/dist/document.js +32 -11
- package/dist/dowry.d.ts +241 -0
- package/dist/dowry.js +315 -0
- package/dist/engines.d.ts +16 -7
- package/dist/engines.js +6 -4
- package/dist/eventMapLaws.d.ts +19 -8
- package/dist/eventMapLaws.js +9 -6
- package/dist/events.d.ts +101 -39
- package/dist/events.js +106 -33
- package/dist/executor.d.ts +122 -41
- package/dist/executor.js +195 -96
- package/dist/extension.d.ts +99 -35
- package/dist/extension.js +43 -9
- package/dist/facets.d.ts +2 -1
- package/dist/facets.js +4 -2
- package/dist/foldedSections.d.ts +4 -2
- package/dist/foldedSections.js +2 -1
- package/dist/genres.d.ts +123 -41
- package/dist/genres.js +127 -22
- package/dist/guardedConnection.d.ts +4 -3
- package/dist/guardedConnection.js +4 -3
- package/dist/handlebarsReach.d.ts +1 -1
- package/dist/handlebarsReach.js +1 -1
- package/dist/hash.d.ts +16 -5
- package/dist/hash.js +14 -4
- package/dist/hookGrants.d.ts +3 -2
- package/dist/hookGrants.js +6 -4
- package/dist/hooks.d.ts +21 -16
- package/dist/hooks.js +12 -10
- package/dist/hostElements.d.ts +41 -17
- package/dist/hostElements.js +49 -17
- package/dist/i18n.d.ts +5 -3
- package/dist/i18n.js +5 -3
- package/dist/identity.d.ts +5 -4
- package/dist/identity.js +5 -4
- package/dist/index.d.ts +5 -0
- package/dist/index.js +15 -0
- package/dist/layout.d.ts +36 -15
- package/dist/layout.js +2 -2
- package/dist/loadouts.d.ts +97 -0
- package/dist/loadouts.js +81 -0
- package/dist/media.d.ts +26 -4
- package/dist/media.js +2 -1
- package/dist/messageBlocks.d.ts +44 -32
- package/dist/messageBlocks.js +23 -18
- package/dist/migration.d.ts +16 -8
- package/dist/migration.js +14 -8
- package/dist/names.d.ts +2 -1
- package/dist/names.js +2 -1
- package/dist/nodeInput.d.ts +2 -1
- package/dist/nodeInput.js +2 -1
- package/dist/participants.d.ts +22 -15
- package/dist/participants.js +14 -12
- package/dist/personGate.d.ts +2 -1
- package/dist/personGate.js +2 -1
- package/dist/pluginHarness.d.ts +8 -3
- package/dist/pluginHarness.js +4 -2
- package/dist/pluginPermissions.d.ts +2 -1
- package/dist/pluginPermissions.js +12 -1
- package/dist/pluginRuleRef.d.ts +2 -2
- package/dist/pluginRuleRef.js +1 -1
- package/dist/predicates.d.ts +16 -11
- package/dist/predicates.js +7 -6
- package/dist/preview.d.ts +8 -3
- package/dist/preview.js +2 -1
- package/dist/promptBlocks.d.ts +5 -3
- package/dist/promptBlocks.js +5 -3
- package/dist/rankingDecisions.d.ts +2 -1
- package/dist/rankingDecisions.js +2 -1
- package/dist/receipt.d.ts +65 -29
- package/dist/receipt.js +9 -4
- package/dist/receiverRules.js +3 -2
- package/dist/refs.d.ts +34 -9
- package/dist/refs.js +33 -13
- package/dist/registry.d.ts +42 -23
- package/dist/registry.js +7 -5
- package/dist/review.d.ts +16 -5
- package/dist/review.js +11 -4
- package/dist/sampling.d.ts +54 -0
- package/dist/sampling.js +95 -3
- package/dist/sceneSettings.d.ts +312 -0
- package/dist/sceneSettings.js +425 -0
- package/dist/scope.d.ts +6 -4
- package/dist/scope.js +4 -3
- package/dist/scripts.d.ts +81 -14
- package/dist/scripts.js +90 -11
- package/dist/sessionDossier.d.ts +521 -0
- package/dist/sessionDossier.js +33 -0
- package/dist/sessionLayout.d.ts +303 -19
- package/dist/sessionLayout.js +354 -40
- package/dist/sessionSettings.d.ts +8 -5
- package/dist/settings.d.ts +45 -20
- package/dist/settings.js +19 -12
- package/dist/settingsSlot.d.ts +11 -8
- package/dist/settingsSlot.js +11 -8
- package/dist/shapes.d.ts +103 -41
- package/dist/shapes.js +105 -40
- package/dist/sheets.d.ts +4 -2
- package/dist/sheets.js +6 -3
- package/dist/statShapes.d.ts +2 -1
- package/dist/statShapes.js +2 -1
- package/dist/status.d.ts +13 -9
- package/dist/status.js +8 -6
- package/dist/storage.d.ts +2 -1
- package/dist/storage.js +2 -1
- package/dist/storyTime.d.ts +13 -7
- package/dist/storyTime.js +11 -6
- package/dist/strokes.d.ts +176 -0
- package/dist/strokes.js +281 -0
- package/dist/surfaces.d.ts +54 -25
- package/dist/surfaces.js +3 -3
- package/dist/template.d.ts +9 -5
- package/dist/template.js +5 -3
- package/dist/templateCheck.d.ts +2 -2
- package/dist/templateCheck.js +2 -2
- package/dist/templateFit.d.ts +37 -8
- package/dist/templateFit.js +92 -8
- package/dist/templateIds.d.ts +3 -3
- package/dist/templateIds.js +3 -3
- package/dist/templateScopeAt.d.ts +21 -11
- package/dist/templateScopeAt.js +21 -11
- package/dist/testing.d.ts +11 -4
- package/dist/testing.js +13 -5
- package/dist/tokenizers.d.ts +2 -2
- package/dist/tokenizers.js +2 -2
- package/dist/turnLock.d.ts +4 -2
- package/dist/turnLock.js +2 -1
- package/dist/turnOrder.d.ts +17 -11
- package/dist/turnOrder.js +9 -5
- package/dist/validate.d.ts +11 -8
- package/dist/validate.js +81 -10
- package/dist/values.d.ts +17 -8
- package/dist/values.js +11 -6
- package/dist/variables.d.ts +46 -7
- package/dist/variables.js +87 -6
- package/dist/verdicts.d.ts +20 -13
- package/dist/verdicts.js +17 -11
- package/dist/widgetDecls.d.ts +8 -4
- package/dist/widgetDecls.js +4 -2
- package/dist/widgets.d.ts +987 -94
- package/dist/widgets.js +93 -18
- package/dist/wire.d.ts +13 -6
- package/dist/wire.js +3 -3
- package/dist/worldinfo.d.ts +11 -6
- package/dist/worldinfo.js +8 -4
- package/host-elements.d.ts +13 -0
- package/package.json +1 -1
package/dist/executor.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* but never waiting, consumption budgets, per-kind injection, and core-emitted events.
|
|
7
7
|
*/
|
|
8
8
|
import { JUNCTION_CLAUSE_PORTS, envoyConfigKeysOf } from './document.js';
|
|
9
|
-
import { AMBIENT_SCRIPT_EXTRAS, getDefinition, opensLiveRow,
|
|
9
|
+
import { AMBIENT_SCRIPT_EXTRAS, getDefinition, opensLiveRow, seamsOf } from './descriptors.js';
|
|
10
10
|
import { packageEventById } from './events.js';
|
|
11
11
|
import { collectDataRefs, isSlotRef } from './refs.js';
|
|
12
12
|
import { resolveConfigSources, slotConnectionId, slotConnectionModelId, SLOT_VALUE, } from './config.js';
|
|
@@ -169,6 +169,21 @@ export function seededRandom(seed) {
|
|
|
169
169
|
const withAmbientExtras = (own = []) => [
|
|
170
170
|
...new Set([...own, ...AMBIENT_SCRIPT_EXTRAS]),
|
|
171
171
|
];
|
|
172
|
+
/**
|
|
173
|
+
* Thrown out of `ctx.scripts.apply` when the applier asks the node to halt
|
|
174
|
+
* (`ScriptChainOutcome.halt`), so a binding mid-work stops at the point. The
|
|
175
|
+
* executor turns the node's result into `halt` whatever the binding does with
|
|
176
|
+
* it.
|
|
177
|
+
* @experimental
|
|
178
|
+
*/
|
|
179
|
+
export class ScriptSeamHalt extends Error {
|
|
180
|
+
reason;
|
|
181
|
+
constructor(reason) {
|
|
182
|
+
super(reason);
|
|
183
|
+
this.reason = reason;
|
|
184
|
+
this.name = 'ScriptSeamHalt';
|
|
185
|
+
}
|
|
186
|
+
}
|
|
172
187
|
const EMPTY_WORLD = {
|
|
173
188
|
overrides: [],
|
|
174
189
|
samplingConfigs: [],
|
|
@@ -291,10 +306,11 @@ export async function run(doc, opts) {
|
|
|
291
306
|
/** Set the moment any node with declared effects is invoked — gates compaction. */
|
|
292
307
|
let effectfulNodeRan = false;
|
|
293
308
|
/**
|
|
294
|
-
* The status the run is showing right now
|
|
309
|
+
* The status the run is showing right now: the last one any node
|
|
295
310
|
* set. Ephemeral — it reaches the host through `onStatus` and lands on
|
|
296
311
|
* the receipt only as `lastStatus`, and only when the run did not end
|
|
297
|
-
* `ok
|
|
312
|
+
* `ok`. Never on a node row.
|
|
313
|
+
* @ruling R-19, R-21, F34
|
|
298
314
|
*/
|
|
299
315
|
let lastStatus;
|
|
300
316
|
const previewAt = opts.preview
|
|
@@ -466,7 +482,13 @@ export async function run(doc, opts) {
|
|
|
466
482
|
const d = getDefinition(`${node.definitionId}@${node.definitionVersion}`);
|
|
467
483
|
const targetNode = doc.nodes.find((n) => n.key === targetKey) ?? node;
|
|
468
484
|
const td = getDefinition(`${targetNode.definitionId}@${targetNode.definitionVersion}`);
|
|
469
|
-
|
|
485
|
+
// The type's shape, then the slot's own: a Task has no shape of its
|
|
486
|
+
// own, and its connection slot states the kind it takes
|
|
487
|
+
// (`SlotDecl.shape`, which `requiredConnections` already reads) —
|
|
488
|
+
// `core:task/query-windows@1`'s embedding slot, since `embed-text`
|
|
489
|
+
// stopped declaring one to reference (2026-10-05). Every oracle
|
|
490
|
+
// declares the same shape on both, so nothing else moves.
|
|
491
|
+
const kind = td?.shape ?? td?.slots?.connection?.shape ?? d?.shape ?? d?.slots?.connection?.shape;
|
|
470
492
|
const stored = config[targetKey]?.['connection']?.[SLOT_VALUE];
|
|
471
493
|
/**
|
|
472
494
|
* The pick, then the instance default — but the default answers only
|
|
@@ -600,7 +622,7 @@ export async function run(doc, opts) {
|
|
|
600
622
|
if (targetKey === node.key)
|
|
601
623
|
return resolveAt(node, ownSchema, () => true);
|
|
602
624
|
/**
|
|
603
|
-
* A reference, and two addresses (
|
|
625
|
+
* A reference, and two addresses (see
|
|
604
626
|
* `FieldDecl.shared`). The referencing node's OWN declaration says
|
|
605
627
|
* which of its fields it holds in common with the owner: those
|
|
606
628
|
* resolve at the owner — the owner's declared default under the
|
|
@@ -618,6 +640,7 @@ export async function run(doc, opts) {
|
|
|
618
640
|
* referencing node's default, so a reference to an owner of a
|
|
619
641
|
* different definition degrades to "own everywhere" rather than to
|
|
620
642
|
* `undefined`.
|
|
643
|
+
* @ruling R-7 P2 (2026-09-16)
|
|
621
644
|
*/
|
|
622
645
|
const targetNode = doc.nodes.find((n) => n.key === targetKey) ?? node;
|
|
623
646
|
const ownerSchema = paramsSchemaOf(targetNode);
|
|
@@ -685,38 +708,63 @@ export async function run(doc, opts) {
|
|
|
685
708
|
// does, and a host with no engine (`applyScripts` absent) runs every
|
|
686
709
|
// spec exactly as before. Declared above the input branch because an
|
|
687
710
|
// input node has a hook of its own — see there.
|
|
688
|
-
|
|
711
|
+
// Every seam this definition declares, in run order (`seamsOf`, D1).
|
|
712
|
+
// `portSeams` is "has any port seam" for the three gates below.
|
|
713
|
+
const seams = seamsOf(d);
|
|
714
|
+
const portSeams = seams.filter((sm) => sm.kind !== 'point');
|
|
715
|
+
/**
|
|
716
|
+
* The one read path: resolve the chain at
|
|
717
|
+
* the seam's storage address, build the site, invoke the applier and
|
|
718
|
+
* record what it says. Storage is unchanged — a slot's chain at
|
|
719
|
+
* `config[node][slot]['']`, a point's at `config[node].scripts[point]`.
|
|
720
|
+
* Per-origin behaviour (engine-failure absorption, alias propagation,
|
|
721
|
+
* the undeclared-point throw) stays with the callers, unchanged.
|
|
722
|
+
*
|
|
723
|
+
* An empty or absent chain still reaches the applier: the host may
|
|
724
|
+
* carry seam-level sources of its own — a connection's stop guards
|
|
725
|
+
* apply whether or not the pipeline configured a chain, and
|
|
726
|
+
* the applier is the side that knows.
|
|
727
|
+
* @ruling PLAN-script-placement D2, 18 §4b
|
|
728
|
+
*/
|
|
729
|
+
const applyAtSeam = async (seam, value, origin) => {
|
|
730
|
+
const point = seam.kind === 'point';
|
|
731
|
+
const site = {
|
|
732
|
+
nodeKey: node.key,
|
|
733
|
+
definitionId: nr.definitionId,
|
|
734
|
+
at: seam.at,
|
|
735
|
+
slot: point ? 'scripts' : seam.slot,
|
|
736
|
+
phase: seam.kind === 'out' ? 'after' : 'before',
|
|
737
|
+
port: point ? seam.at : seam.port,
|
|
738
|
+
accepts: [...seam.accepts],
|
|
739
|
+
// A slot's own extras, then the ambient set; a point declares
|
|
740
|
+
// none of its own, so it is handed the ambient set (R32).
|
|
741
|
+
extras: withAmbientExtras(seam.extras),
|
|
742
|
+
...(origin === 'binding' ? { origin } : {}),
|
|
743
|
+
};
|
|
744
|
+
const chain = point
|
|
745
|
+
? config[node.key]?.['scripts']?.[seam.at]
|
|
746
|
+
: config[node.key]?.[seam.slot]?.[''];
|
|
747
|
+
const outcome = await opts.applyScripts(site, chain, value);
|
|
748
|
+
if (outcome.applications.length)
|
|
749
|
+
nr.scripts = [...(nr.scripts ?? []), ...outcome.applications];
|
|
750
|
+
if (outcome.notes?.length)
|
|
751
|
+
nr.notes.push(...outcome.notes);
|
|
752
|
+
return outcome;
|
|
753
|
+
};
|
|
754
|
+
/** The port path: every `in:` or `out:` seam, in order, over a bag. */
|
|
689
755
|
const applyChainsAt = async (phase, bag) => {
|
|
690
756
|
if (!opts.applyScripts)
|
|
691
|
-
return bag;
|
|
757
|
+
return { bag };
|
|
692
758
|
let out = bag;
|
|
693
|
-
for (const
|
|
694
|
-
|
|
695
|
-
if ((sd.phase ?? 'before') !== phase)
|
|
759
|
+
for (const seam of portSeams) {
|
|
760
|
+
if ((seam.kind === 'out' ? 'after' : 'before') !== phase)
|
|
696
761
|
continue;
|
|
697
|
-
|
|
698
|
-
// may carry hook-level sources of its own — a connection's stop
|
|
699
|
-
// guards (18 §4b) apply whether or not the pipeline configured a
|
|
700
|
-
// chain, and the applier is the side that knows.
|
|
701
|
-
const chain = config[node.key]?.[slotName]?.[''];
|
|
702
|
-
const port = sd.port ?? 'main';
|
|
762
|
+
const port = seam.port;
|
|
703
763
|
if (!(port in out))
|
|
704
764
|
continue;
|
|
705
765
|
const before = out[port];
|
|
706
766
|
try {
|
|
707
|
-
const outcome = await
|
|
708
|
-
nodeKey: node.key,
|
|
709
|
-
definitionId: nr.definitionId,
|
|
710
|
-
slot: slotName,
|
|
711
|
-
phase,
|
|
712
|
-
port,
|
|
713
|
-
accepts: sd.accepts ?? [],
|
|
714
|
-
extras: withAmbientExtras(sd.extras),
|
|
715
|
-
}, chain, before);
|
|
716
|
-
if (outcome.applications.length)
|
|
717
|
-
nr.scripts = [...(nr.scripts ?? []), ...outcome.applications];
|
|
718
|
-
if (outcome.notes?.length)
|
|
719
|
-
nr.notes.push(...outcome.notes);
|
|
767
|
+
const outcome = await applyAtSeam(seam, before, 'substrate');
|
|
720
768
|
// Alias-preserving: a task publishing {main, messages} as one
|
|
721
769
|
// value keeps agreeing with itself after the rewrite — a
|
|
722
770
|
// downstream edge may pull either name.
|
|
@@ -724,6 +772,9 @@ export async function run(doc, opts) {
|
|
|
724
772
|
for (const [k, v] of Object.entries(out))
|
|
725
773
|
if (k !== port && v === before)
|
|
726
774
|
out[k] = outcome.value;
|
|
775
|
+
// The applier asked the node to halt (D4): no further seam runs.
|
|
776
|
+
if (outcome.halt)
|
|
777
|
+
return { bag: out, halt: outcome.halt.reason };
|
|
727
778
|
}
|
|
728
779
|
catch (e) {
|
|
729
780
|
// Engine failure, absorbed like an optional node's failure
|
|
@@ -746,7 +797,19 @@ export async function run(doc, opts) {
|
|
|
746
797
|
];
|
|
747
798
|
}
|
|
748
799
|
}
|
|
749
|
-
return out;
|
|
800
|
+
return { bag: out };
|
|
801
|
+
};
|
|
802
|
+
/**
|
|
803
|
+
* A node halted by a seam: settle the record, return the halt.
|
|
804
|
+
* @ruling D4
|
|
805
|
+
*/
|
|
806
|
+
const haltAtSeam = (reason) => {
|
|
807
|
+
nr.endedAt = now();
|
|
808
|
+
nr.elapsedMs = nr.endedAt - nr.startedAt;
|
|
809
|
+
nr.result = 'halt';
|
|
810
|
+
nr.reason = reason;
|
|
811
|
+
receipt.nodes.push(nr);
|
|
812
|
+
return halt(reason);
|
|
750
813
|
};
|
|
751
814
|
if (node.kind === 'inlet') {
|
|
752
815
|
// An input has no invocation to wrap, but it can still declare a
|
|
@@ -754,11 +817,15 @@ export async function run(doc, opts) {
|
|
|
754
817
|
// retrieval and the prompt see. The stored user message, written
|
|
755
818
|
// before the turn began, stays untouched by construction.
|
|
756
819
|
let published = opts.input;
|
|
757
|
-
if (
|
|
820
|
+
if (portSeams.length &&
|
|
758
821
|
published &&
|
|
759
822
|
typeof published === 'object' &&
|
|
760
|
-
!Array.isArray(published))
|
|
761
|
-
|
|
823
|
+
!Array.isArray(published)) {
|
|
824
|
+
const r = await applyChainsAt('after', published);
|
|
825
|
+
published = r.bag;
|
|
826
|
+
if (r.halt !== undefined)
|
|
827
|
+
return haltAtSeam(r.halt);
|
|
828
|
+
}
|
|
762
829
|
scope.set(node.key, published);
|
|
763
830
|
nr.output = published;
|
|
764
831
|
nr.endedAt = now();
|
|
@@ -795,8 +862,12 @@ export async function run(doc, opts) {
|
|
|
795
862
|
receipt.nodes.push(nr);
|
|
796
863
|
return ok({});
|
|
797
864
|
}
|
|
798
|
-
if (
|
|
799
|
-
|
|
865
|
+
if (portSeams.length) {
|
|
866
|
+
const r = await applyChainsAt('before', input);
|
|
867
|
+
input = r.bag;
|
|
868
|
+
if (r.halt !== undefined)
|
|
869
|
+
return haltAtSeam(r.halt);
|
|
870
|
+
}
|
|
800
871
|
// ── The review gate (01 §7) ───────────────────────────────────────────
|
|
801
872
|
// Substrate placement: after the input resolves, before the binding is invoked.
|
|
802
873
|
// Keys on declared effects, not on kind, so an effectful oracle gates too.
|
|
@@ -994,33 +1065,26 @@ export async function run(doc, opts) {
|
|
|
994
1065
|
// user attached there (slot `scripts`, path = the point key) is what
|
|
995
1066
|
// runs; applications land in the receipt marked `appliedBy: 'binding'`,
|
|
996
1067
|
// so an interior letting user policy in stays visible from outside.
|
|
1068
|
+
// Set when an interior point's applier asked the node to halt (D4); read
|
|
1069
|
+
// after the binding settles, so the node halts even if the binding
|
|
1070
|
+
// caught the `ScriptSeamHalt` and carried on.
|
|
1071
|
+
let interiorHalt;
|
|
997
1072
|
if (opts.applyScripts && d.scriptPoints?.length) {
|
|
998
|
-
const applyScripts = opts.applyScripts;
|
|
999
1073
|
// The full shape, deprecated spellings folded — so `accepts` is
|
|
1000
1074
|
// always the point's own (R-11), never a literal written here.
|
|
1001
|
-
const declared =
|
|
1075
|
+
const declared = seams.filter((sm) => sm.kind === 'point');
|
|
1002
1076
|
const apply = async (point, value) => {
|
|
1003
|
-
const known = declared.find((sp) => sp.
|
|
1077
|
+
const known = declared.find((sp) => sp.at === point);
|
|
1004
1078
|
if (!known)
|
|
1005
1079
|
throw new Error(`'${point}' is not a script point '${nr.definitionId}' declares. ` +
|
|
1006
|
-
`Declared: ${declared.map((sp) => sp.
|
|
1080
|
+
`Declared: ${declared.map((sp) => sp.at).join(', ')}. ` +
|
|
1007
1081
|
`Points are part of the hashed contract — declare it on the descriptor.`);
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
accepts: [...known.accepts],
|
|
1015
|
-
// Interior points declare no extras of their own; what
|
|
1016
|
-
// every point is handed is the ambient set (R32).
|
|
1017
|
-
extras: withAmbientExtras(),
|
|
1018
|
-
origin: 'binding',
|
|
1019
|
-
}, config[node.key]?.['scripts']?.[point], value);
|
|
1020
|
-
if (outcome.applications.length)
|
|
1021
|
-
nr.scripts = [...(nr.scripts ?? []), ...outcome.applications];
|
|
1022
|
-
if (outcome.notes?.length)
|
|
1023
|
-
nr.notes.push(...outcome.notes);
|
|
1082
|
+
// No try/catch: an applier throw reaches the binding that asked.
|
|
1083
|
+
const outcome = await applyAtSeam(known, value, 'binding');
|
|
1084
|
+
if (outcome.halt) {
|
|
1085
|
+
interiorHalt ??= outcome.halt.reason;
|
|
1086
|
+
throw new ScriptSeamHalt(outcome.halt.reason);
|
|
1087
|
+
}
|
|
1024
1088
|
return outcome.value;
|
|
1025
1089
|
};
|
|
1026
1090
|
base.scripts = {
|
|
@@ -1168,6 +1232,10 @@ export async function run(doc, opts) {
|
|
|
1168
1232
|
res = err(e.message);
|
|
1169
1233
|
}
|
|
1170
1234
|
}
|
|
1235
|
+
// An interior point asked the node to halt (D4) — whatever the binding
|
|
1236
|
+
// returned or threw after it.
|
|
1237
|
+
if (interiorHalt !== undefined)
|
|
1238
|
+
res = halt(interiorHalt);
|
|
1171
1239
|
nr.endedAt = now();
|
|
1172
1240
|
nr.elapsedMs = nr.endedAt - nr.startedAt;
|
|
1173
1241
|
nr.result = res.kind;
|
|
@@ -1188,41 +1256,55 @@ export async function run(doc, opts) {
|
|
|
1188
1256
|
let published = res.value;
|
|
1189
1257
|
// ── Script chains, after phase (18 §4a) — over what the binding
|
|
1190
1258
|
// published, before it reaches the scope any downstream edge reads.
|
|
1191
|
-
|
|
1259
|
+
let afterHalt;
|
|
1260
|
+
if (portSeams.length &&
|
|
1192
1261
|
published &&
|
|
1193
1262
|
typeof published === 'object' &&
|
|
1194
|
-
!Array.isArray(published))
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
//
|
|
1201
|
-
//
|
|
1202
|
-
//
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1263
|
+
!Array.isArray(published)) {
|
|
1264
|
+
const r = await applyChainsAt('after', published);
|
|
1265
|
+
published = r.bag;
|
|
1266
|
+
afterHalt = r.halt;
|
|
1267
|
+
}
|
|
1268
|
+
if (afterHalt !== undefined) {
|
|
1269
|
+
// Halted at an `out:` seam (D4): nothing reaches the scope. An
|
|
1270
|
+
// outlet's write has already happened — the halt stops the run,
|
|
1271
|
+
// it cannot unwrite.
|
|
1272
|
+
nr.result = 'halt';
|
|
1273
|
+
nr.reason = afterHalt;
|
|
1274
|
+
res = halt(afterHalt);
|
|
1275
|
+
}
|
|
1276
|
+
else {
|
|
1277
|
+
if (node.kind === 'outlet' && isGated(d.effects)) {
|
|
1278
|
+
// Wrap only if it is not already discriminated — but publish
|
|
1279
|
+
// either way. This used to skip publishing entirely when a
|
|
1280
|
+
// binding returned a `WriteResult` itself, so the binding doing
|
|
1281
|
+
// the *right* thing got the worse wiring: no `main`, and no
|
|
1282
|
+
// port typed `write-result@1` populated. Nothing caught it
|
|
1283
|
+
// because the only in-tree producer of `pending` was the
|
|
1284
|
+
// executor's own async-review branch, which called
|
|
1285
|
+
// `publishWriteResult` on its own; retiring that branch is what
|
|
1286
|
+
// surfaced this.
|
|
1287
|
+
const w = isWriteResult(published)
|
|
1288
|
+
? published
|
|
1289
|
+
: {
|
|
1290
|
+
status: 'committed',
|
|
1291
|
+
ids: (published ?? {}),
|
|
1292
|
+
};
|
|
1293
|
+
published = publishWriteResult(w, d.ports.out);
|
|
1294
|
+
}
|
|
1295
|
+
// The run's live row (R-21 (2)): the row this outlet committed,
|
|
1296
|
+
// when the declaration says its row is the one a stream goes to.
|
|
1297
|
+
// A dry run's synthetic id counts — a downstream oracle in a dry
|
|
1298
|
+
// run still streams to nothing, and the host is told so by `dry`
|
|
1299
|
+
// rather than by the row's absence. Judged on the node's inputs,
|
|
1300
|
+
// not on what its binding chose to commit: a complete message from
|
|
1301
|
+
// the same outlet is an ordinary write, not the live row (F7, W1).
|
|
1302
|
+
if (d.liveRow && opensLiveRow(input) && committedRow !== undefined)
|
|
1303
|
+
liveRow = committedRow;
|
|
1304
|
+
scope.set(node.key, published);
|
|
1305
|
+
res = ok(published);
|
|
1306
|
+
nr.output = redact(published);
|
|
1213
1307
|
}
|
|
1214
|
-
// The run's live row (R-21 (2)): the row this outlet committed,
|
|
1215
|
-
// when the declaration says its row is the one a stream goes to.
|
|
1216
|
-
// A dry run's synthetic id counts — a downstream oracle in a dry
|
|
1217
|
-
// run still streams to nothing, and the host is told so by `dry`
|
|
1218
|
-
// rather than by the row's absence. Judged on the node's inputs,
|
|
1219
|
-
// not on what its binding chose to commit: a complete message from
|
|
1220
|
-
// the same outlet is an ordinary write, not the live row (F7, W1).
|
|
1221
|
-
if (d.liveRow && opensLiveRow(input) && committedRow !== undefined)
|
|
1222
|
-
liveRow = committedRow;
|
|
1223
|
-
scope.set(node.key, published);
|
|
1224
|
-
res = ok(published);
|
|
1225
|
-
nr.output = redact(published);
|
|
1226
1308
|
}
|
|
1227
1309
|
else if (res.kind === 'halt' || res.kind === 'err' || res.kind === 'cancelled') {
|
|
1228
1310
|
nr.reason = res.reason;
|
|
@@ -1249,8 +1331,9 @@ export async function run(doc, opts) {
|
|
|
1249
1331
|
};
|
|
1250
1332
|
/**
|
|
1251
1333
|
* The invocation, observed. `onNode` fires at start and settle with node
|
|
1252
|
-
* identity and never a payload
|
|
1334
|
+
* identity and never a payload — an observer that throws is the
|
|
1253
1335
|
* observer's problem, not the run's.
|
|
1336
|
+
* @ruling F34
|
|
1254
1337
|
*/
|
|
1255
1338
|
const invoke = async (node, scope, blockMode, iteration, iterationCount) => {
|
|
1256
1339
|
const ev = (phase, result) => {
|
|
@@ -1275,7 +1358,10 @@ export async function run(doc, opts) {
|
|
|
1275
1358
|
ev('end', res.kind);
|
|
1276
1359
|
return res;
|
|
1277
1360
|
};
|
|
1278
|
-
/**
|
|
1361
|
+
/**
|
|
1362
|
+
* Admin kill — `cancelled`, not `err`, with the actor recorded.
|
|
1363
|
+
* @ruling 13 §3
|
|
1364
|
+
*/
|
|
1279
1365
|
const checkCancel = () => {
|
|
1280
1366
|
const c = opts.cancelSignal?.();
|
|
1281
1367
|
if (!c)
|
|
@@ -1509,11 +1595,12 @@ export async function run(doc, opts) {
|
|
|
1509
1595
|
*
|
|
1510
1596
|
* A tool loop is only a loop if the next prompt can see the last
|
|
1511
1597
|
* result, and the body cannot reference a node declared after it —
|
|
1512
|
-
* `makeScope` makes a back-edge unwritable
|
|
1598
|
+
* `makeScope` makes a back-edge unwritable. What *is* declared
|
|
1513
1599
|
* before the body is the clause itself, so `$.tools.values` reads the
|
|
1514
1600
|
* iterations that have already finished. Each iteration still runs in
|
|
1515
1601
|
* a child of this, so an iteration's node values stay private to it
|
|
1516
|
-
* and a loop remains the same construct as a parallel map
|
|
1602
|
+
* and a loop remains the same construct as a parallel map.
|
|
1603
|
+
* @ruling F9, F26
|
|
1517
1604
|
*/
|
|
1518
1605
|
const carry = scope.child();
|
|
1519
1606
|
publish(carry);
|
|
@@ -1645,7 +1732,8 @@ export async function run(doc, opts) {
|
|
|
1645
1732
|
/**
|
|
1646
1733
|
* Every out port a gate-eligible outlet declares as `write-result@1` resolves to the
|
|
1647
1734
|
* *same* discriminated value. A port named `messageId` therefore hands downstream the
|
|
1648
|
-
* result, not an id — which is the point: there may not be an id yet
|
|
1735
|
+
* result, not an id — which is the point: there may not be an id yet.
|
|
1736
|
+
* @ruling 13 §7j-b
|
|
1649
1737
|
*/
|
|
1650
1738
|
function publishWriteResult(w, out) {
|
|
1651
1739
|
const published = { ...w, main: w };
|
|
@@ -1702,11 +1790,14 @@ async function sequential(items, fn) {
|
|
|
1702
1790
|
out.push(await fn(i));
|
|
1703
1791
|
return out;
|
|
1704
1792
|
}
|
|
1705
|
-
/**
|
|
1793
|
+
/**
|
|
1794
|
+
* A node's own clock ran out; the message is the receipt's reason.
|
|
1795
|
+
* @ruling F36
|
|
1796
|
+
*/
|
|
1706
1797
|
class NodeTimeout extends Error {
|
|
1707
1798
|
}
|
|
1708
1799
|
/**
|
|
1709
|
-
* One invocation's clock
|
|
1800
|
+
* One invocation's clock, by the definition's `timeoutKind`.
|
|
1710
1801
|
*
|
|
1711
1802
|
* - `wall` — `ms` from the start of the invocation to its end, whatever the
|
|
1712
1803
|
* node does in between. `pulse` does nothing.
|
|
@@ -1722,6 +1813,7 @@ class NodeTimeout extends Error {
|
|
|
1722
1813
|
* what a host's in-flight request listens to (`CallHandles.signal`): a timeout
|
|
1723
1814
|
* that let the request run on would leave a model server generating into
|
|
1724
1815
|
* nothing, with the next request queued behind it.
|
|
1816
|
+
* @ruling F36
|
|
1725
1817
|
*/
|
|
1726
1818
|
function nodeClock(limit, controller) {
|
|
1727
1819
|
const { ms, kind, ceilingMs } = limit;
|
|
@@ -1785,7 +1877,10 @@ function setPath(obj, path, value) {
|
|
|
1785
1877
|
}
|
|
1786
1878
|
cur[path[path.length - 1]] = value;
|
|
1787
1879
|
}
|
|
1788
|
-
/**
|
|
1880
|
+
/**
|
|
1881
|
+
* Vectors, material and secrets never enter a receipt.
|
|
1882
|
+
* @ruling 16 §1a, 01 §10, 13 §6
|
|
1883
|
+
*/
|
|
1789
1884
|
function redact(v) {
|
|
1790
1885
|
if (Array.isArray(v) && v.length > 8 && v.every((x) => typeof x === 'number')) {
|
|
1791
1886
|
return { $vector: true, dims: v.length };
|
|
@@ -1810,7 +1905,11 @@ function redact(v) {
|
|
|
1810
1905
|
}
|
|
1811
1906
|
return v;
|
|
1812
1907
|
}
|
|
1813
|
-
/**
|
|
1908
|
+
/**
|
|
1909
|
+
* replay(receipt) — deterministic, never re-infers.
|
|
1910
|
+
* @experimental
|
|
1911
|
+
* @ruling F16
|
|
1912
|
+
*/
|
|
1814
1913
|
export async function replay(doc, receipt, bindings) {
|
|
1815
1914
|
const recorded = new Map(receipt.nodes.map((n) => [n.nodeKey, n.output]));
|
|
1816
1915
|
const replayBindings = { ...bindings };
|