@jam-overture/loom 0.1.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/LICENSE +21 -0
- package/README.md +743 -0
- package/dist/catalogue.d.ts +70 -0
- package/dist/catalogue.js +88 -0
- package/dist/cli/args.d.ts +17 -0
- package/dist/cli/args.js +83 -0
- package/dist/cli/filesystem.d.ts +15 -0
- package/dist/cli/filesystem.js +31 -0
- package/dist/cli/index.d.ts +12 -0
- package/dist/cli/index.js +12 -0
- package/dist/cli/main.d.ts +3 -0
- package/dist/cli/main.js +30 -0
- package/dist/cli/namespace.d.ts +40 -0
- package/dist/cli/namespace.js +40 -0
- package/dist/cli/plan.d.ts +84 -0
- package/dist/cli/plan.js +113 -0
- package/dist/cli/run.d.ts +17 -0
- package/dist/cli/run.js +75 -0
- package/dist/cli/templates.d.ts +43 -0
- package/dist/cli/templates.js +134 -0
- package/dist/closed-set.d.ts +34 -0
- package/dist/closed-set.js +34 -0
- package/dist/data/adapter.d.ts +123 -0
- package/dist/data/adapter.js +91 -0
- package/dist/data/binding.d.ts +48 -0
- package/dist/data/binding.js +39 -0
- package/dist/data/catalogue.d.ts +26 -0
- package/dist/data/catalogue.js +6 -0
- package/dist/data/index.d.ts +14 -0
- package/dist/data/index.js +14 -0
- package/dist/data/plan.d.ts +58 -0
- package/dist/data/plan.js +0 -0
- package/dist/data/resolution.d.ts +91 -0
- package/dist/data/resolution.js +96 -0
- package/dist/data/resolve.d.ts +46 -0
- package/dist/data/resolve.js +37 -0
- package/dist/data/source.d.ts +40 -0
- package/dist/data/source.js +45 -0
- package/dist/deadline.d.ts +57 -0
- package/dist/deadline.js +78 -0
- package/dist/frame/catalogue.d.ts +24 -0
- package/dist/frame/catalogue.js +5 -0
- package/dist/frame/index.d.ts +12 -0
- package/dist/frame/index.js +12 -0
- package/dist/frame/origin.d.ts +87 -0
- package/dist/frame/origin.js +114 -0
- package/dist/frame/resolution.d.ts +85 -0
- package/dist/frame/resolution.js +79 -0
- package/dist/grammar.d.ts +26 -0
- package/dist/grammar.js +28 -0
- package/dist/ids.d.ts +57 -0
- package/dist/ids.js +104 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +26 -0
- package/dist/interactivity.d.ts +50 -0
- package/dist/interactivity.js +22 -0
- package/dist/interpretation/anthropic.d.ts +22 -0
- package/dist/interpretation/anthropic.js +76 -0
- package/dist/interpretation/client.d.ts +83 -0
- package/dist/interpretation/client.js +2 -0
- package/dist/interpretation/draft.d.ts +234 -0
- package/dist/interpretation/draft.js +84 -0
- package/dist/interpretation/index.d.ts +15 -0
- package/dist/interpretation/index.js +15 -0
- package/dist/interpretation/interpreter.d.ts +62 -0
- package/dist/interpretation/interpreter.js +151 -0
- package/dist/interpretation/materialize.d.ts +42 -0
- package/dist/interpretation/materialize.js +107 -0
- package/dist/interpretation/prompt.d.ts +229 -0
- package/dist/interpretation/prompt.js +285 -0
- package/dist/interpretation/render.d.ts +76 -0
- package/dist/interpretation/render.js +272 -0
- package/dist/interpretation/schema.d.ts +49 -0
- package/dist/interpretation/schema.js +131 -0
- package/dist/json.d.ts +35 -0
- package/dist/json.js +11 -0
- package/dist/paging.d.ts +60 -0
- package/dist/paging.js +49 -0
- package/dist/primitive-type.d.ts +32 -0
- package/dist/primitive-type.js +39 -0
- package/dist/render/addressing.d.ts +59 -0
- package/dist/render/addressing.js +60 -0
- package/dist/render/anchor.d.ts +105 -0
- package/dist/render/anchor.js +84 -0
- package/dist/render/behaviour-adjust.d.ts +62 -0
- package/dist/render/behaviour-adjust.js +78 -0
- package/dist/render/behaviour-copy.d.ts +53 -0
- package/dist/render/behaviour-copy.js +75 -0
- package/dist/render/behaviour-disclose.d.ts +74 -0
- package/dist/render/behaviour-disclose.js +77 -0
- package/dist/render/behaviour-present.d.ts +123 -0
- package/dist/render/behaviour-present.js +173 -0
- package/dist/render/behaviour.d.ts +243 -0
- package/dist/render/behaviour.js +284 -0
- package/dist/render/control.d.ts +81 -0
- package/dist/render/control.js +80 -0
- package/dist/render/decorative.d.ts +62 -0
- package/dist/render/decorative.js +2 -0
- package/dist/render/diagnostics.d.ts +260 -0
- package/dist/render/diagnostics.js +61 -0
- package/dist/render/disclosed.d.ts +37 -0
- package/dist/render/disclosed.js +37 -0
- package/dist/render/editable.d.ts +34 -0
- package/dist/render/editable.js +35 -0
- package/dist/render/frame.d.ts +42 -0
- package/dist/render/frame.js +31 -0
- package/dist/render/index.d.ts +35 -0
- package/dist/render/index.js +35 -0
- package/dist/render/inline-variables.d.ts +77 -0
- package/dist/render/inline-variables.js +220 -0
- package/dist/render/presented.d.ts +82 -0
- package/dist/render/presented.js +82 -0
- package/dist/render/primitive.d.ts +228 -0
- package/dist/render/primitive.js +36 -0
- package/dist/render/props.d.ts +48 -0
- package/dist/render/props.js +2 -0
- package/dist/render/reads.d.ts +73 -0
- package/dist/render/reads.js +45 -0
- package/dist/render/render.d.ts +164 -0
- package/dist/render/render.js +571 -0
- package/dist/render/request.d.ts +111 -0
- package/dist/render/request.js +60 -0
- package/dist/render/text.d.ts +91 -0
- package/dist/render/text.js +44 -0
- package/dist/render/theme.d.ts +61 -0
- package/dist/render/theme.js +52 -0
- package/dist/reserved-props.d.ts +35 -0
- package/dist/reserved-props.js +45 -0
- package/dist/result.d.ts +27 -0
- package/dist/result.js +30 -0
- package/dist/role.d.ts +71 -0
- package/dist/role.js +22 -0
- package/dist/runtime/analysis.d.ts +149 -0
- package/dist/runtime/analysis.js +187 -0
- package/dist/runtime/assessment.d.ts +35 -0
- package/dist/runtime/assessment.js +13 -0
- package/dist/runtime/disposition.d.ts +102 -0
- package/dist/runtime/disposition.js +59 -0
- package/dist/runtime/events.d.ts +187 -0
- package/dist/runtime/events.js +7 -0
- package/dist/runtime/gate.d.ts +43 -0
- package/dist/runtime/gate.js +169 -0
- package/dist/runtime/index.d.ts +27 -0
- package/dist/runtime/index.js +27 -0
- package/dist/runtime/intent.d.ts +60 -0
- package/dist/runtime/intent.js +36 -0
- package/dist/runtime/interpreter.d.ts +117 -0
- package/dist/runtime/interpreter.js +46 -0
- package/dist/runtime/inverse-interpreter.d.ts +90 -0
- package/dist/runtime/inverse-interpreter.js +56 -0
- package/dist/runtime/inverse.d.ts +87 -0
- package/dist/runtime/inverse.js +48 -0
- package/dist/runtime/narration.d.ts +24 -0
- package/dist/runtime/narration.js +36 -0
- package/dist/runtime/nesting.d.ts +31 -0
- package/dist/runtime/nesting.js +46 -0
- package/dist/runtime/pipeline.d.ts +124 -0
- package/dist/runtime/pipeline.js +178 -0
- package/dist/runtime/policy-fingerprint.d.ts +29 -0
- package/dist/runtime/policy-fingerprint.js +119 -0
- package/dist/runtime/policy-source.d.ts +42 -0
- package/dist/runtime/policy-source.js +8 -0
- package/dist/runtime/policy.d.ts +156 -0
- package/dist/runtime/policy.js +107 -0
- package/dist/runtime/proposal.d.ts +423 -0
- package/dist/runtime/proposal.js +109 -0
- package/dist/runtime/redirection.d.ts +53 -0
- package/dist/runtime/redirection.js +38 -0
- package/dist/runtime/repointing.d.ts +71 -0
- package/dist/runtime/repointing.js +0 -0
- package/dist/runtime/reversibility.d.ts +36 -0
- package/dist/runtime/reversibility.js +39 -0
- package/dist/runtime/stake-level.d.ts +33 -0
- package/dist/runtime/stake-level.js +58 -0
- package/dist/runtime/stakes.d.ts +47 -0
- package/dist/runtime/stakes.js +305 -0
- package/dist/runtime/vocabulary.d.ts +122 -0
- package/dist/runtime/vocabulary.js +87 -0
- package/dist/sdk/audit.d.ts +195 -0
- package/dist/sdk/audit.js +128 -0
- package/dist/sdk/catalogue.d.ts +37 -0
- package/dist/sdk/catalogue.js +16 -0
- package/dist/sdk/conformance.d.ts +342 -0
- package/dist/sdk/conformance.js +494 -0
- package/dist/sdk/copy.d.ts +105 -0
- package/dist/sdk/copy.js +90 -0
- package/dist/sdk/definition.d.ts +242 -0
- package/dist/sdk/definition.js +64 -0
- package/dist/sdk/index.d.ts +19 -0
- package/dist/sdk/index.js +19 -0
- package/dist/sdk/interactivity.d.ts +29 -0
- package/dist/sdk/interactivity.js +34 -0
- package/dist/sdk/pairings.d.ts +124 -0
- package/dist/sdk/pairings.js +81 -0
- package/dist/sdk/registry.d.ts +162 -0
- package/dist/sdk/registry.js +329 -0
- package/dist/sdk/selection.d.ts +46 -0
- package/dist/sdk/selection.js +24 -0
- package/dist/sdk/text.d.ts +100 -0
- package/dist/sdk/text.js +105 -0
- package/dist/sdk/vocabulary.d.ts +39 -0
- package/dist/sdk/vocabulary.js +36 -0
- package/dist/signals/broadcast.d.ts +134 -0
- package/dist/signals/broadcast.js +451 -0
- package/dist/signals/collect.d.ts +184 -0
- package/dist/signals/collect.js +196 -0
- package/dist/signals/deliver.d.ts +64 -0
- package/dist/signals/deliver.js +85 -0
- package/dist/signals/fold.d.ts +112 -0
- package/dist/signals/fold.js +76 -0
- package/dist/signals/index.d.ts +31 -0
- package/dist/signals/index.js +31 -0
- package/dist/signals/ingest.d.ts +51 -0
- package/dist/signals/ingest.js +70 -0
- package/dist/signals/intake.d.ts +149 -0
- package/dist/signals/intake.js +154 -0
- package/dist/signals/journal.d.ts +94 -0
- package/dist/signals/journal.js +11 -0
- package/dist/signals/kinds.d.ts +22 -0
- package/dist/signals/kinds.js +22 -0
- package/dist/signals/ledger.d.ts +46 -0
- package/dist/signals/ledger.js +81 -0
- package/dist/signals/memory.d.ts +17 -0
- package/dist/signals/memory.js +99 -0
- package/dist/signals/migrate.d.ts +27 -0
- package/dist/signals/migrate.js +78 -0
- package/dist/signals/postgres.d.ts +7 -0
- package/dist/signals/postgres.js +295 -0
- package/dist/signals/rollup.d.ts +142 -0
- package/dist/signals/rollup.js +0 -0
- package/dist/signals/schema.d.ts +534 -0
- package/dist/signals/schema.js +92 -0
- package/dist/signals/signal.d.ts +381 -0
- package/dist/signals/signal.js +150 -0
- package/dist/signals/tally.d.ts +70 -0
- package/dist/signals/tally.js +2 -0
- package/dist/signals/view.d.ts +51 -0
- package/dist/signals/view.js +54 -0
- package/dist/store/attribution.d.ts +125 -0
- package/dist/store/attribution.js +116 -0
- package/dist/store/database.d.ts +14 -0
- package/dist/store/database.js +2 -0
- package/dist/store/driver.d.ts +29 -0
- package/dist/store/driver.js +39 -0
- package/dist/store/errors.d.ts +56 -0
- package/dist/store/errors.js +37 -0
- package/dist/store/index.d.ts +16 -0
- package/dist/store/index.js +16 -0
- package/dist/store/memory.d.ts +3 -0
- package/dist/store/memory.js +115 -0
- package/dist/store/migrate.d.ts +54 -0
- package/dist/store/migrate.js +122 -0
- package/dist/store/postgres-holds.d.ts +4 -0
- package/dist/store/postgres-holds.js +192 -0
- package/dist/store/postgres.d.ts +8 -0
- package/dist/store/postgres.js +262 -0
- package/dist/store/replay.d.ts +94 -0
- package/dist/store/replay.js +82 -0
- package/dist/store/revert.d.ts +116 -0
- package/dist/store/revert.js +243 -0
- package/dist/store/schema.d.ts +371 -0
- package/dist/store/schema.js +78 -0
- package/dist/store/source.d.ts +23 -0
- package/dist/store/source.js +37 -0
- package/dist/store/store.d.ts +231 -0
- package/dist/store/store.js +52 -0
- package/dist/store/undone.d.ts +18 -0
- package/dist/store/undone.js +89 -0
- package/dist/submit/catalogue.d.ts +20 -0
- package/dist/submit/catalogue.js +5 -0
- package/dist/submit/declaration.d.ts +39 -0
- package/dist/submit/declaration.js +30 -0
- package/dist/submit/endpoint.d.ts +131 -0
- package/dist/submit/endpoint.js +160 -0
- package/dist/submit/index.d.ts +13 -0
- package/dist/submit/index.js +13 -0
- package/dist/submit/plan.d.ts +49 -0
- package/dist/submit/plan.js +47 -0
- package/dist/submit/resolution.d.ts +61 -0
- package/dist/submit/resolution.js +64 -0
- package/dist/submit/resolve.d.ts +45 -0
- package/dist/submit/resolve.js +36 -0
- package/dist/telemetry/calibration.d.ts +132 -0
- package/dist/telemetry/calibration.js +151 -0
- package/dist/telemetry/episode.d.ts +140 -0
- package/dist/telemetry/episode.js +272 -0
- package/dist/telemetry/event.d.ts +2310 -0
- package/dist/telemetry/event.js +405 -0
- package/dist/telemetry/index.d.ts +15 -0
- package/dist/telemetry/index.js +15 -0
- package/dist/telemetry/journal.d.ts +116 -0
- package/dist/telemetry/journal.js +11 -0
- package/dist/telemetry/memory.d.ts +24 -0
- package/dist/telemetry/memory.js +75 -0
- package/dist/telemetry/migrate.d.ts +26 -0
- package/dist/telemetry/migrate.js +40 -0
- package/dist/telemetry/postgres.d.ts +6 -0
- package/dist/telemetry/postgres.js +139 -0
- package/dist/telemetry/retention.d.ts +131 -0
- package/dist/telemetry/retention.js +217 -0
- package/dist/telemetry/schema.d.ts +113 -0
- package/dist/telemetry/schema.js +33 -0
- package/dist/telemetry/sink.d.ts +42 -0
- package/dist/telemetry/sink.js +61 -0
- package/dist/testing/contracts.d.ts +34 -0
- package/dist/testing/contracts.js +34 -0
- package/dist/testing/definitions.d.ts +15 -0
- package/dist/testing/definitions.js +48 -0
- package/dist/testing/doubles.d.ts +94 -0
- package/dist/testing/doubles.js +141 -0
- package/dist/testing/episode-harness.d.ts +49 -0
- package/dist/testing/episode-harness.js +65 -0
- package/dist/testing/filesystem.d.ts +17 -0
- package/dist/testing/filesystem.js +17 -0
- package/dist/testing/fixtures.d.ts +57 -0
- package/dist/testing/fixtures.js +84 -0
- package/dist/testing/hold-contract.d.ts +19 -0
- package/dist/testing/hold-contract.js +374 -0
- package/dist/testing/index.d.ts +41 -0
- package/dist/testing/index.js +41 -0
- package/dist/testing/journal-contract.d.ts +17 -0
- package/dist/testing/journal-contract.js +353 -0
- package/dist/testing/model-replies.d.ts +34 -0
- package/dist/testing/model-replies.js +101 -0
- package/dist/testing/primitives.d.ts +7 -0
- package/dist/testing/primitives.js +29 -0
- package/dist/testing/reader-signal-contract.d.ts +38 -0
- package/dist/testing/reader-signal-contract.js +318 -0
- package/dist/testing/row-security.d.ts +17 -0
- package/dist/testing/row-security.js +21 -0
- package/dist/testing/store-contract.d.ts +25 -0
- package/dist/testing/store-contract.js +500 -0
- package/dist/theme/apply.d.ts +17 -0
- package/dist/theme/apply.js +60 -0
- package/dist/theme/contrast.d.ts +197 -0
- package/dist/theme/contrast.js +259 -0
- package/dist/theme/derive.d.ts +77 -0
- package/dist/theme/derive.js +167 -0
- package/dist/theme/faces.d.ts +73 -0
- package/dist/theme/faces.js +119 -0
- package/dist/theme/font-packs.d.ts +25 -0
- package/dist/theme/font-packs.js +257 -0
- package/dist/theme/index.d.ts +20 -0
- package/dist/theme/index.js +20 -0
- package/dist/theme/lab.d.ts +30 -0
- package/dist/theme/lab.js +46 -0
- package/dist/theme/library.d.ts +114 -0
- package/dist/theme/library.js +300 -0
- package/dist/theme/measure.d.ts +144 -0
- package/dist/theme/measure.js +145 -0
- package/dist/theme/palettes.d.ts +64 -0
- package/dist/theme/palettes.js +497 -0
- package/dist/theme/registry.d.ts +59 -0
- package/dist/theme/registry.js +60 -0
- package/dist/theme/separation.d.ts +177 -0
- package/dist/theme/separation.js +203 -0
- package/dist/theme/style-presets.d.ts +60 -0
- package/dist/theme/style-presets.js +124 -0
- package/dist/theme/theme.d.ts +253 -0
- package/dist/theme/theme.js +171 -0
- package/dist/tree/apply.d.ts +16 -0
- package/dist/tree/apply.js +104 -0
- package/dist/tree/builders.d.ts +19 -0
- package/dist/tree/builders.js +20 -0
- package/dist/tree/compare.d.ts +68 -0
- package/dist/tree/compare.js +75 -0
- package/dist/tree/configuration.d.ts +25 -0
- package/dist/tree/configuration.js +108 -0
- package/dist/tree/delta.d.ts +288 -0
- package/dist/tree/delta.js +88 -0
- package/dist/tree/errors.d.ts +69 -0
- package/dist/tree/errors.js +34 -0
- package/dist/tree/identity.d.ts +117 -0
- package/dist/tree/identity.js +145 -0
- package/dist/tree/index.d.ts +21 -0
- package/dist/tree/index.js +21 -0
- package/dist/tree/inverse.d.ts +24 -0
- package/dist/tree/inverse.js +112 -0
- package/dist/tree/mutation.d.ts +18 -0
- package/dist/tree/mutation.js +49 -0
- package/dist/tree/naming.d.ts +4 -0
- package/dist/tree/naming.js +35 -0
- package/dist/tree/navigation.d.ts +38 -0
- package/dist/tree/navigation.js +83 -0
- package/dist/tree/node.d.ts +103 -0
- package/dist/tree/node.js +46 -0
- package/dist/tree/outline.d.ts +28 -0
- package/dist/tree/outline.js +10 -0
- package/dist/tree/tree.d.ts +83 -0
- package/dist/tree/tree.js +62 -0
- package/dist/write/commit.d.ts +124 -0
- package/dist/write/commit.js +234 -0
- package/dist/write/held.d.ts +674 -0
- package/dist/write/held.js +185 -0
- package/dist/write/index.d.ts +11 -0
- package/dist/write/index.js +11 -0
- package/dist/write/liveness.d.ts +132 -0
- package/dist/write/liveness.js +91 -0
- package/dist/write/revert.d.ts +79 -0
- package/dist/write/revert.js +134 -0
- package/package.json +160 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { assertNever } from "../result.js";
|
|
2
|
+
export const interpretationFault = (error) => {
|
|
3
|
+
switch (error.code) {
|
|
4
|
+
case "not-understood":
|
|
5
|
+
case "no-change-needed":
|
|
6
|
+
return "asker";
|
|
7
|
+
case "refused":
|
|
8
|
+
case "malformed-proposal":
|
|
9
|
+
return "model";
|
|
10
|
+
case "interpreter-unavailable":
|
|
11
|
+
return "provider";
|
|
12
|
+
case "interpreter-misconfigured":
|
|
13
|
+
return "deployment";
|
|
14
|
+
case "interpreter-request-rejected":
|
|
15
|
+
return "runtime";
|
|
16
|
+
default:
|
|
17
|
+
return assertNever(error, "interpretationFault");
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* One sentence a reader who is not holding this union in their head can act on.
|
|
22
|
+
*
|
|
23
|
+
* Every sentence says what happens if nothing changes, because that is the part
|
|
24
|
+
* a code alone never carried: two of these clear on their own and three do not.
|
|
25
|
+
*/
|
|
26
|
+
export const describeInterpretationError = (error) => {
|
|
27
|
+
switch (error.code) {
|
|
28
|
+
case "not-understood":
|
|
29
|
+
return `the request was not understood: ${error.detail}`;
|
|
30
|
+
case "no-change-needed":
|
|
31
|
+
return `nothing needed to change: ${error.detail}`;
|
|
32
|
+
case "interpreter-unavailable":
|
|
33
|
+
return `the model could not be reached, and may answer later: ${error.detail}`;
|
|
34
|
+
case "interpreter-misconfigured":
|
|
35
|
+
return `this deployment cannot reach a model until an operator changes that: ${error.detail}`;
|
|
36
|
+
case "interpreter-request-rejected":
|
|
37
|
+
return `the model service rejected the request, and would reject it again unchanged: ${error.detail}`;
|
|
38
|
+
case "refused":
|
|
39
|
+
return `the model declined to answer: ${error.detail}`;
|
|
40
|
+
case "malformed-proposal":
|
|
41
|
+
return `the model's answer could not be used: ${error.detail}`;
|
|
42
|
+
default:
|
|
43
|
+
return assertNever(error, "describeInterpretationError");
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=interpreter.js.map
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { IdFactory } from "../ids.js";
|
|
2
|
+
import type { TreeOperation } from "../tree/delta.js";
|
|
3
|
+
import type { Clock } from "./events.js";
|
|
4
|
+
import type { ChangeInterpreter } from "./interpreter.js";
|
|
5
|
+
import type { DiscardedWork } from "./proposal.js";
|
|
6
|
+
/**
|
|
7
|
+
* Proposing an inverse that is already in hand.
|
|
8
|
+
*
|
|
9
|
+
* The runtime computes the inverse of every change at assessment time
|
|
10
|
+
* (`assessReversibility`), and until now the only way to *offer* one back was
|
|
11
|
+
* `revertRevision`, which plans an undo by replaying a store. That is the right
|
|
12
|
+
* path when the undo is being recovered from a log — it has to read one to know
|
|
13
|
+
* what has been built on top since (0035).
|
|
14
|
+
*
|
|
15
|
+
* It is the wrong path, and an unreachable one, when the inverse never left the
|
|
16
|
+
* process. A surface that composed a change and still holds the `Reversibility`
|
|
17
|
+
* it produced has no log to replay and nothing to contest: the whole of what it
|
|
18
|
+
* needs is the short piece between *here is an inverse* and *here is a proposal
|
|
19
|
+
* the Gate can weigh*. `Loom marketing` wrote that piece by hand on 5 September
|
|
20
|
+
* to make the front door's *Put it back* do what it says, and filed it, because
|
|
21
|
+
* the alternative is every stateless surface rebuilding the same thirty lines
|
|
22
|
+
* with its own idea of what an undo's provenance says.
|
|
23
|
+
*
|
|
24
|
+
* So this is the assembled version, and `revertInterpreter` is now it plus the
|
|
25
|
+
* two things only a log can supply: a rationale naming the revision, and the
|
|
26
|
+
* declaration of what applying it writes over.
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* The inverse, as little of it as proposing one needs.
|
|
30
|
+
*
|
|
31
|
+
* A `TreeDelta` satisfies this, which is the common case — it is what
|
|
32
|
+
* `Reversibility.inverse` hands back. A caller holding operations and the
|
|
33
|
+
* revision they were computed against, and no delta yet, satisfies it too: the
|
|
34
|
+
* delta id and tree id belong to the delta this proposes, not to the inverse it
|
|
35
|
+
* proposes from.
|
|
36
|
+
*/
|
|
37
|
+
export type ProposableInverse = {
|
|
38
|
+
/** The revision the operations were computed against. */
|
|
39
|
+
readonly baseRevision: number;
|
|
40
|
+
readonly operations: readonly TreeOperation[];
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* What the interpreter cannot compute, because it depends on where the inverse
|
|
44
|
+
* came from.
|
|
45
|
+
*
|
|
46
|
+
* Both are required rather than defaulted. A default interpreter id would put
|
|
47
|
+
* one stamp on undos planned by unrelated callers, and reading that stamp back
|
|
48
|
+
* is how a surface tells an undo from a change — `(demo)` does exactly that
|
|
49
|
+
* against `REVERT_INTERPRETER`. A default rationale would be the runtime
|
|
50
|
+
* writing a sentence about a provenance it does not know, on the one field the
|
|
51
|
+
* person answering a hold actually reads (0019).
|
|
52
|
+
*/
|
|
53
|
+
export type InverseTerms = {
|
|
54
|
+
/** What produced the delta, for `Provenance.interpreter`. Not a model. */
|
|
55
|
+
readonly interpreter: string;
|
|
56
|
+
/** Why, in the words the person answering a hold is shown. */
|
|
57
|
+
readonly rationale: string;
|
|
58
|
+
/**
|
|
59
|
+
* Work applying this inverse would write over. Only a caller holding a log
|
|
60
|
+
* can know of any, and absence keeps meaning "nobody looked at a log" rather
|
|
61
|
+
* than "a log was checked and was clean" (0035).
|
|
62
|
+
*/
|
|
63
|
+
readonly discards?: readonly DiscardedWork[];
|
|
64
|
+
/**
|
|
65
|
+
* The revision this puts back, recorded on the provenance the log keeps.
|
|
66
|
+
*
|
|
67
|
+
* Optional because not every inverse has one to name. A stateless surface
|
|
68
|
+
* undoing a change it made in the same session has no revision — nothing was
|
|
69
|
+
* ever appended — and stamping a number it does not have would be worse than
|
|
70
|
+
* the absence. A caller that planned the undo off a log always does.
|
|
71
|
+
*/
|
|
72
|
+
readonly undoes?: number;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* An interpreter that has nothing to interpret.
|
|
76
|
+
*
|
|
77
|
+
* The seam exists because interpretation is the non-deterministic step (0005),
|
|
78
|
+
* not because it is always a model — and an undo is the case that proves the
|
|
79
|
+
* seam was drawn in the right place. Everything downstream of it cannot tell
|
|
80
|
+
* that no model was involved, which is exactly what makes an undo gateable on
|
|
81
|
+
* the same terms as an AI-authored change.
|
|
82
|
+
*
|
|
83
|
+
* `confidence` is 1 because the inverse is computed, not guessed. That is the
|
|
84
|
+
* honest self-grade (0007), and it is also why `authoredBy` is `runtime`: a 1
|
|
85
|
+
* nobody graded is not a claim, and calibration (0031) segments these out of its
|
|
86
|
+
* score rather than letting every undo walk the top band toward a perfect record
|
|
87
|
+
* the model never earned.
|
|
88
|
+
*/
|
|
89
|
+
export declare const inverseInterpreter: (inverse: ProposableInverse, terms: InverseTerms, idFactory: IdFactory, clock: Clock) => ChangeInterpreter;
|
|
90
|
+
//# sourceMappingURL=inverse-interpreter.d.ts.map
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { err, ok } from "../result.js";
|
|
2
|
+
/**
|
|
3
|
+
* An interpreter that has nothing to interpret.
|
|
4
|
+
*
|
|
5
|
+
* The seam exists because interpretation is the non-deterministic step (0005),
|
|
6
|
+
* not because it is always a model — and an undo is the case that proves the
|
|
7
|
+
* seam was drawn in the right place. Everything downstream of it cannot tell
|
|
8
|
+
* that no model was involved, which is exactly what makes an undo gateable on
|
|
9
|
+
* the same terms as an AI-authored change.
|
|
10
|
+
*
|
|
11
|
+
* `confidence` is 1 because the inverse is computed, not guessed. That is the
|
|
12
|
+
* honest self-grade (0007), and it is also why `authoredBy` is `runtime`: a 1
|
|
13
|
+
* nobody graded is not a claim, and calibration (0031) segments these out of its
|
|
14
|
+
* score rather than letting every undo walk the top band toward a perfect record
|
|
15
|
+
* the model never earned.
|
|
16
|
+
*/
|
|
17
|
+
export const inverseInterpreter = (inverse, terms, idFactory, clock) => ({
|
|
18
|
+
interpret: (intent, tree) => Promise.resolve(
|
|
19
|
+
/**
|
|
20
|
+
* An inverse is computed against one arrangement of a tree. Offering it
|
|
21
|
+
* against another would be proposing something whose reasoning has
|
|
22
|
+
* expired, so it declines rather than proposing. The write path refuses a
|
|
23
|
+
* moved head before reaching here; this is what keeps the interpreter safe
|
|
24
|
+
* to wire into a runtime directly, which a stateless caller does.
|
|
25
|
+
*/
|
|
26
|
+
tree.revision === inverse.baseRevision
|
|
27
|
+
? ok({
|
|
28
|
+
proposalId: idFactory.proposalId(),
|
|
29
|
+
intentId: intent.intentId,
|
|
30
|
+
delta: {
|
|
31
|
+
deltaId: idFactory.deltaId(),
|
|
32
|
+
treeId: tree.treeId,
|
|
33
|
+
baseRevision: tree.revision,
|
|
34
|
+
operations: inverse.operations,
|
|
35
|
+
},
|
|
36
|
+
rationale: terms.rationale,
|
|
37
|
+
...(terms.discards === undefined || terms.discards.length === 0
|
|
38
|
+
? {}
|
|
39
|
+
: { discards: terms.discards }),
|
|
40
|
+
provenance: {
|
|
41
|
+
origin: intent.origin,
|
|
42
|
+
...(intent.actor === undefined ? {} : { actor: intent.actor }),
|
|
43
|
+
interpreter: terms.interpreter,
|
|
44
|
+
/** Computed, not inferred — so calibration leaves it out (0031). */
|
|
45
|
+
authoredBy: "runtime",
|
|
46
|
+
...(terms.undoes === undefined ? {} : { undoes: terms.undoes }),
|
|
47
|
+
confidence: 1,
|
|
48
|
+
interpretedAt: clock.now(),
|
|
49
|
+
},
|
|
50
|
+
})
|
|
51
|
+
: err({
|
|
52
|
+
code: "refused",
|
|
53
|
+
detail: `the inverse was computed against revision ${inverse.baseRevision}, and this tree is at ${tree.revision}`,
|
|
54
|
+
})),
|
|
55
|
+
});
|
|
56
|
+
//# sourceMappingURL=inverse-interpreter.js.map
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { IdFactory } from "../ids.js";
|
|
2
|
+
import type { TreeOperation } from "../tree/delta.js";
|
|
3
|
+
import type { Clock } from "./events.js";
|
|
4
|
+
import type { ChangeInterpreter } from "./interpreter.js";
|
|
5
|
+
import type { DiscardedWork } from "./proposal.js";
|
|
6
|
+
/**
|
|
7
|
+
* An undo that is already computed, offered as a change like any other.
|
|
8
|
+
*
|
|
9
|
+
* The runtime writes an inverse every time a change applies, so a surface that
|
|
10
|
+
* ran the change is holding the undo before anybody asks for it. What it is not
|
|
11
|
+
* holding is a *proposal*: the short piece between "here are the operations that
|
|
12
|
+
* put it back" and "here is something the Gate can weigh" — a proposal id, the
|
|
13
|
+
* delta stated against the tree in hand, a rationale, and provenance that says
|
|
14
|
+
* the runtime computed this rather than a model guessing it.
|
|
15
|
+
*
|
|
16
|
+
* `revertInterpreter` has assembled that piece since undo landed, and only ever
|
|
17
|
+
* for a caller with a store: it takes a `RevertablePlan`, which is a reading of
|
|
18
|
+
* a log. A surface with no store — the front door, a preview, anything that
|
|
19
|
+
* demonstrates on one request and keeps nothing (0081) — could compute an undo
|
|
20
|
+
* and could not assemble one, so it wrote this by hand. The marketing lane did,
|
|
21
|
+
* in about thirty lines, and filed the fact as the finding.
|
|
22
|
+
*
|
|
23
|
+
* So the store-shaped half comes out. What is left is the whole of what a
|
|
24
|
+
* stateless caller needs and exactly what `revertInterpreter` is built from,
|
|
25
|
+
* which is the property that keeps the two honest: a surface offering an undo
|
|
26
|
+
* gets the portal's behaviour rather than its own reading of it.
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* The operations that put something back, and what to say about them.
|
|
30
|
+
*
|
|
31
|
+
* `interpreter` has no default on purpose. It is the stamp a reader uses to
|
|
32
|
+
* decide whether a record is an undo the runtime planned — `REVERT_INTERPRETER`
|
|
33
|
+
* means "this came off a log", and a caller inheriting that for a delta planned
|
|
34
|
+
* somewhere else would be lying in its own provenance. Naming it is one line and
|
|
35
|
+
* it is the line that stays true.
|
|
36
|
+
*/
|
|
37
|
+
export type ComputedInverse = {
|
|
38
|
+
/** The undo, as operations. The delta's id and base belong to the proposal. */
|
|
39
|
+
readonly operations: readonly TreeOperation[];
|
|
40
|
+
/**
|
|
41
|
+
* The revision the operations were computed against.
|
|
42
|
+
*
|
|
43
|
+
* An inverse is only an inverse of one arrangement. Offered against another it
|
|
44
|
+
* would be proposing something whose reasoning has expired, so the interpreter
|
|
45
|
+
* declines rather than proposing it — which is what makes this safe to wire
|
|
46
|
+
* into a runtime directly, with no write path in front of it.
|
|
47
|
+
*/
|
|
48
|
+
readonly headRevision: number;
|
|
49
|
+
/** What produced the delta, for `Provenance.interpreter`. Not a model. */
|
|
50
|
+
readonly interpreter: string;
|
|
51
|
+
/** Why, in the words the person answering a hold reads (0019). */
|
|
52
|
+
readonly rationale: string;
|
|
53
|
+
/**
|
|
54
|
+
* Work this undo writes over, when the caller knows of some.
|
|
55
|
+
*
|
|
56
|
+
* Only a caller that read a log can know, so it is absent by default and
|
|
57
|
+
* absence keeps meaning "nobody looked" rather than "a log was checked and was
|
|
58
|
+
* clean" (0035).
|
|
59
|
+
*/
|
|
60
|
+
readonly discards?: readonly DiscardedWork[];
|
|
61
|
+
/**
|
|
62
|
+
* The revision this puts back, recorded on the provenance the log keeps.
|
|
63
|
+
*
|
|
64
|
+
* Optional because not every inverse has one to name. A stateless surface
|
|
65
|
+
* undoing a change it made in the same session has no revision — nothing was
|
|
66
|
+
* ever appended — and stamping a number it does not have would be worse than
|
|
67
|
+
* the absence. A caller that planned the undo off a log always does (0111).
|
|
68
|
+
*/
|
|
69
|
+
readonly undoes?: number;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* An interpreter that has nothing to interpret.
|
|
73
|
+
*
|
|
74
|
+
* The seam exists because interpretation is the non-deterministic step (0005),
|
|
75
|
+
* not because it is always a model — and an undo is the case that proves the
|
|
76
|
+
* seam was drawn in the right place. Everything downstream of it cannot tell
|
|
77
|
+
* that no model was involved, which is exactly what makes an undo gateable on
|
|
78
|
+
* the same terms as an AI-authored change.
|
|
79
|
+
*
|
|
80
|
+
* `confidence` is 1 because the inverse is computed, not guessed. That is the
|
|
81
|
+
* honest self-grade (0007), and it is also why `authoredBy` is `runtime`: a 1
|
|
82
|
+
* nobody graded is not a claim, and calibration (0031) segments these out of its
|
|
83
|
+
* score rather than letting every undo walk the top band toward a perfect record
|
|
84
|
+
* the model never earned.
|
|
85
|
+
*/
|
|
86
|
+
export declare const inverseInterpreter: (inverse: ComputedInverse, idFactory: IdFactory, clock: Clock) => ChangeInterpreter;
|
|
87
|
+
//# sourceMappingURL=inverse.d.ts.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { err, ok } from "../result.js";
|
|
2
|
+
/**
|
|
3
|
+
* An interpreter that has nothing to interpret.
|
|
4
|
+
*
|
|
5
|
+
* The seam exists because interpretation is the non-deterministic step (0005),
|
|
6
|
+
* not because it is always a model — and an undo is the case that proves the
|
|
7
|
+
* seam was drawn in the right place. Everything downstream of it cannot tell
|
|
8
|
+
* that no model was involved, which is exactly what makes an undo gateable on
|
|
9
|
+
* the same terms as an AI-authored change.
|
|
10
|
+
*
|
|
11
|
+
* `confidence` is 1 because the inverse is computed, not guessed. That is the
|
|
12
|
+
* honest self-grade (0007), and it is also why `authoredBy` is `runtime`: a 1
|
|
13
|
+
* nobody graded is not a claim, and calibration (0031) segments these out of its
|
|
14
|
+
* score rather than letting every undo walk the top band toward a perfect record
|
|
15
|
+
* the model never earned.
|
|
16
|
+
*/
|
|
17
|
+
export const inverseInterpreter = (inverse, idFactory, clock) => ({
|
|
18
|
+
interpret: (intent, tree) => Promise.resolve(tree.revision === inverse.headRevision
|
|
19
|
+
? ok({
|
|
20
|
+
proposalId: idFactory.proposalId(),
|
|
21
|
+
intentId: intent.intentId,
|
|
22
|
+
delta: {
|
|
23
|
+
deltaId: idFactory.deltaId(),
|
|
24
|
+
treeId: tree.treeId,
|
|
25
|
+
baseRevision: tree.revision,
|
|
26
|
+
operations: inverse.operations,
|
|
27
|
+
},
|
|
28
|
+
rationale: inverse.rationale,
|
|
29
|
+
...(inverse.discards === undefined || inverse.discards.length === 0
|
|
30
|
+
? {}
|
|
31
|
+
: { discards: inverse.discards }),
|
|
32
|
+
provenance: {
|
|
33
|
+
origin: intent.origin,
|
|
34
|
+
...(intent.actor === undefined ? {} : { actor: intent.actor }),
|
|
35
|
+
interpreter: inverse.interpreter,
|
|
36
|
+
...(inverse.undoes === undefined ? {} : { undoes: inverse.undoes }),
|
|
37
|
+
/** Computed, not inferred — so calibration leaves it out (0031). */
|
|
38
|
+
authoredBy: "runtime",
|
|
39
|
+
confidence: 1,
|
|
40
|
+
interpretedAt: clock.now(),
|
|
41
|
+
},
|
|
42
|
+
})
|
|
43
|
+
: err({
|
|
44
|
+
code: "refused",
|
|
45
|
+
detail: `the undo was computed against revision ${inverse.headRevision}, and this tree is at ${tree.revision}`,
|
|
46
|
+
})),
|
|
47
|
+
});
|
|
48
|
+
//# sourceMappingURL=inverse.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { TreeId } from "../ids.js";
|
|
2
|
+
import type { Clock, EventSink, RuntimeEvent } from "./events.js";
|
|
3
|
+
/**
|
|
4
|
+
* The one door a runtime event leaves through.
|
|
5
|
+
*
|
|
6
|
+
* `EventSink` has promised since §2 that a sink cannot fail a change the Gate
|
|
7
|
+
* already accepted. Until now that was an obligation on whoever implemented the
|
|
8
|
+
* interface: the pipeline and the write path both called `emit` bare, so a sink
|
|
9
|
+
* that threw took the change down with it — including, at `change-committed`,
|
|
10
|
+
* a change already durable in the log, reported to the caller as an error.
|
|
11
|
+
*
|
|
12
|
+
* So the promise is kept here instead, once, where every event passes. A sink
|
|
13
|
+
* is free to be a bad citizen; what it cannot be is load-bearing.
|
|
14
|
+
*/
|
|
15
|
+
export type Narrator = (event: RuntimeEvent) => void;
|
|
16
|
+
/**
|
|
17
|
+
* The clock is deliberately outside the containment. A sink that fails is a
|
|
18
|
+
* broken observer and the change is still true; a clock that fails means the
|
|
19
|
+
* runtime cannot say when anything happened, and it stamps `appliedAt` on the
|
|
20
|
+
* commit itself, so pretending otherwise would put a wrong time in the log
|
|
21
|
+
* rather than lose an event.
|
|
22
|
+
*/
|
|
23
|
+
export declare const narrator: (events: EventSink, clock: Clock, treeId: TreeId) => Narrator;
|
|
24
|
+
//# sourceMappingURL=narration.d.ts.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const ignore = () => undefined;
|
|
2
|
+
/**
|
|
3
|
+
* `emit` is declared to return `void`, which does not stop a host from writing
|
|
4
|
+
* an `async` one — TypeScript assigns `() => Promise<void>` to `() => void`
|
|
5
|
+
* without complaint. Such a sink rejects instead of throwing, and an unhandled
|
|
6
|
+
* rejection is a process-level failure on exactly the serverless hosts this
|
|
7
|
+
* containment was written for (0024). It has to cover both shapes or it covers
|
|
8
|
+
* neither.
|
|
9
|
+
*/
|
|
10
|
+
const isThenable = (value) => typeof value === "object" &&
|
|
11
|
+
value !== null &&
|
|
12
|
+
typeof value.then === "function";
|
|
13
|
+
/**
|
|
14
|
+
* Emits without letting the sink refuse. Nothing is reported when containment
|
|
15
|
+
* fires, because the only channel for reporting it is the thing that just
|
|
16
|
+
* failed, which is accepted rather than worked around (see 0042).
|
|
17
|
+
*/
|
|
18
|
+
const contain = (events, envelope) => {
|
|
19
|
+
try {
|
|
20
|
+
const returned = events.emit(envelope);
|
|
21
|
+
if (isThenable(returned))
|
|
22
|
+
returned.then(ignore, ignore);
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
/** Contained on purpose. A sink observes; it does not get a vote. */
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* The clock is deliberately outside the containment. A sink that fails is a
|
|
30
|
+
* broken observer and the change is still true; a clock that fails means the
|
|
31
|
+
* runtime cannot say when anything happened, and it stamps `appliedAt` on the
|
|
32
|
+
* commit itself, so pretending otherwise would put a wrong time in the log
|
|
33
|
+
* rather than lose an event.
|
|
34
|
+
*/
|
|
35
|
+
export const narrator = (events, clock, treeId) => (event) => contain(events, { treeId, occurredAt: clock.now(), event });
|
|
36
|
+
//# sourceMappingURL=narration.js.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { NodeId } from "../ids.js";
|
|
2
|
+
import { type InteractiveTypes } from "../interactivity.js";
|
|
3
|
+
import type { PrimitiveType } from "../primitive-type.js";
|
|
4
|
+
import { type ElementNode, type LoomNode } from "../tree/node.js";
|
|
5
|
+
/**
|
|
6
|
+
* Where a tree puts one target inside another.
|
|
7
|
+
*
|
|
8
|
+
* Nothing built so far can catch this.
|
|
9
|
+
* [0008](../../decisions/0008-the-renderer-is-a-total-pure-projection.md)
|
|
10
|
+
* forbids the renderer from enforcing parentage, `auditRegistry` probes a
|
|
11
|
+
* primitive in isolation, and a props schema sees one node and never its
|
|
12
|
+
* descendants. The constraint is real, cheap to check, and until now
|
|
13
|
+
* expressible nowhere (0064).
|
|
14
|
+
*/
|
|
15
|
+
/** Whether this element renders a target — its type and its own props, never its position. */
|
|
16
|
+
export type InteractivePredicate = (node: ElementNode) => boolean;
|
|
17
|
+
/** What a host that declares no interactive vocabulary gets, which is today's behaviour. */
|
|
18
|
+
export declare const NOTHING_INTERACTIVE: InteractivePredicate;
|
|
19
|
+
export declare const interactivePredicateFor: (types: InteractiveTypes) => InteractivePredicate;
|
|
20
|
+
/** One target sitting inside another, named by the node the reader cannot reach. */
|
|
21
|
+
export type NestedTarget = {
|
|
22
|
+
readonly nodeId: NodeId;
|
|
23
|
+
readonly type: PrimitiveType;
|
|
24
|
+
/** The nearest target above it, which is the one that swallows it. */
|
|
25
|
+
readonly ancestorId: NodeId;
|
|
26
|
+
readonly ancestorType: PrimitiveType;
|
|
27
|
+
};
|
|
28
|
+
/** Every target this tree puts inside another, in document order. */
|
|
29
|
+
export declare const nestedTargetsIn: (root: LoomNode, isInteractive: InteractivePredicate) => readonly NestedTarget[];
|
|
30
|
+
export declare const describeNestedTarget: (nested: NestedTarget) => string;
|
|
31
|
+
//# sourceMappingURL=nesting.d.ts.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { isInteractiveWith } from "../interactivity.js";
|
|
2
|
+
import { childrenOf } from "../tree/node.js";
|
|
3
|
+
/** What a host that declares no interactive vocabulary gets, which is today's behaviour. */
|
|
4
|
+
export const NOTHING_INTERACTIVE = () => false;
|
|
5
|
+
export const interactivePredicateFor = (types) => {
|
|
6
|
+
/**
|
|
7
|
+
* A `Map` rather than an index, for the reason `staticPrimitiveResolver`
|
|
8
|
+
* gives: `constructor` and `toString` are valid primitive types, and an
|
|
9
|
+
* ordinary object would answer for them out of `Object.prototype`.
|
|
10
|
+
*/
|
|
11
|
+
const byType = new Map(Object.entries(types).flatMap(([type, when]) => (when ? [[type, when]] : [])));
|
|
12
|
+
return (node) => {
|
|
13
|
+
const when = byType.get(node.type);
|
|
14
|
+
return when !== undefined && isInteractiveWith(when, node.props);
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
const collect = (node, enclosing, isInteractive, found) => {
|
|
18
|
+
const target = node.kind === "element" && isInteractive(node) ? node : null;
|
|
19
|
+
if (target && enclosing) {
|
|
20
|
+
found.push({
|
|
21
|
+
nodeId: target.id,
|
|
22
|
+
type: target.type,
|
|
23
|
+
ancestorId: enclosing.id,
|
|
24
|
+
ancestorType: enclosing.type,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The *nearest* enclosing target, not the outermost. Three deep is two faults
|
|
29
|
+
* rather than one, and a reviewer told about each pair that touches can read
|
|
30
|
+
* the chain off the tree; told only about the ends, they cannot.
|
|
31
|
+
*
|
|
32
|
+
* Slot nodes are descended without being targets themselves — a region
|
|
33
|
+
* projected into a linked card sits inside it exactly as a child does.
|
|
34
|
+
*/
|
|
35
|
+
const below = target ? { id: target.id, type: target.type } : enclosing;
|
|
36
|
+
for (const child of childrenOf(node))
|
|
37
|
+
collect(child, below, isInteractive, found);
|
|
38
|
+
};
|
|
39
|
+
/** Every target this tree puts inside another, in document order. */
|
|
40
|
+
export const nestedTargetsIn = (root, isInteractive) => {
|
|
41
|
+
const found = [];
|
|
42
|
+
collect(root, null, isInteractive, found);
|
|
43
|
+
return found;
|
|
44
|
+
};
|
|
45
|
+
export const describeNestedTarget = (nested) => `${nested.type} ${nested.nodeId} inside ${nested.ancestorType} ${nested.ancestorId}`;
|
|
46
|
+
//# sourceMappingURL=nesting.js.map
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import type { IdFactory } from "../ids.js";
|
|
2
|
+
import type { TreeDelta } from "../tree/delta.js";
|
|
3
|
+
import type { TreeError } from "../tree/errors.js";
|
|
4
|
+
import type { LoomTree } from "../tree/tree.js";
|
|
5
|
+
import { type ChangeAssessment } from "./assessment.js";
|
|
6
|
+
import type { Disposition } from "./disposition.js";
|
|
7
|
+
import type { Clock, EventSink } from "./events.js";
|
|
8
|
+
import type { EditIntent } from "./intent.js";
|
|
9
|
+
import type { ChangeInterpreter, ChangeRepairer, InterpretationError } from "./interpreter.js";
|
|
10
|
+
import type { PolicySource } from "./policy-source.js";
|
|
11
|
+
import type { ProposedChange } from "./proposal.js";
|
|
12
|
+
import type { PropsVocabulary } from "./vocabulary.js";
|
|
13
|
+
/**
|
|
14
|
+
* The composition runtime: EditIntent → ProposedChange → Gate → Disposition →
|
|
15
|
+
* Apply, narrating each stage as it goes.
|
|
16
|
+
*
|
|
17
|
+
* The orchestrator coordinates and does nothing else. Interpretation belongs to
|
|
18
|
+
* the interpreter, judgment to the Gate, structural change to `applyDelta`;
|
|
19
|
+
* this module's only jobs are sequencing them, emitting events, and turning the
|
|
20
|
+
* result into an outcome a caller can act on.
|
|
21
|
+
*/
|
|
22
|
+
export type CompositionRuntime = {
|
|
23
|
+
readonly interpreter: ChangeInterpreter;
|
|
24
|
+
/**
|
|
25
|
+
* Which policy judges a given change. A source rather than a policy, because
|
|
26
|
+
* one runtime may serve trees that do not deserve the same latitude; a host
|
|
27
|
+
* with one policy says so with `fixedPolicy`.
|
|
28
|
+
*/
|
|
29
|
+
readonly policySource: PolicySource;
|
|
30
|
+
readonly events: EventSink;
|
|
31
|
+
readonly clock: Clock;
|
|
32
|
+
readonly idFactory: IdFactory;
|
|
33
|
+
/**
|
|
34
|
+
* Optional, and absent by default. With no repairer, a refusal is terminal.
|
|
35
|
+
* With one, a refused proposal gets exactly one more attempt — see
|
|
36
|
+
* `attemptRepair`, where the "exactly one" is structural rather than a
|
|
37
|
+
* counter that could drift.
|
|
38
|
+
*/
|
|
39
|
+
readonly repairer?: ChangeRepairer;
|
|
40
|
+
/**
|
|
41
|
+
* What this deployment's primitives accept, checked before a delta is judged.
|
|
42
|
+
* Optional, and absent by default: a runtime handed none cannot check props,
|
|
43
|
+
* so "this deployment refuses AI-authored props its own schemas reject" is a
|
|
44
|
+
* visible choice at the composition root rather than a property of whichever
|
|
45
|
+
* interpreter happened to be wired in (0179).
|
|
46
|
+
*
|
|
47
|
+
* Deliberately the same shape as the renderer's `PropsValidator`, so a host
|
|
48
|
+
* with a registry hands the same object to both seams and the two cannot
|
|
49
|
+
* disagree about what is drawable. `propsVocabularyFor(registry)` in the SDK
|
|
50
|
+
* is how one is obtained without hand-keeping it.
|
|
51
|
+
*/
|
|
52
|
+
readonly propsVocabulary?: PropsVocabulary;
|
|
53
|
+
};
|
|
54
|
+
export type CompositionOutcome = {
|
|
55
|
+
readonly kind: "applied";
|
|
56
|
+
readonly tree: LoomTree;
|
|
57
|
+
readonly assessment: ChangeAssessment;
|
|
58
|
+
readonly disposition: Disposition;
|
|
59
|
+
readonly inverse: TreeDelta;
|
|
60
|
+
} | {
|
|
61
|
+
readonly kind: "awaiting-confirmation";
|
|
62
|
+
readonly assessment: ChangeAssessment;
|
|
63
|
+
readonly disposition: Disposition;
|
|
64
|
+
} | {
|
|
65
|
+
readonly kind: "rejected";
|
|
66
|
+
readonly assessment: ChangeAssessment;
|
|
67
|
+
readonly disposition: Disposition;
|
|
68
|
+
/**
|
|
69
|
+
* Why no smaller change was offered instead — present only when a repairer
|
|
70
|
+
* was asked for one and could not produce it.
|
|
71
|
+
*
|
|
72
|
+
* The three ways a refusal can end are told apart by this field and
|
|
73
|
+
* `assessment.proposal.repairOf` together: `repairOf` set means a repair
|
|
74
|
+
* was made and refused in its turn; this field set means the repairer
|
|
75
|
+
* declined; neither means no repairer was wired, so nothing was asked.
|
|
76
|
+
* Without it the second and third read identically, and a host that wanted
|
|
77
|
+
* to say "we asked for something smaller and could not get one" had to
|
|
78
|
+
* recover the fact from the event stream (0040).
|
|
79
|
+
*/
|
|
80
|
+
readonly repairFailure?: InterpretationError;
|
|
81
|
+
} | {
|
|
82
|
+
readonly kind: "not-interpreted";
|
|
83
|
+
readonly error: InterpretationError;
|
|
84
|
+
} | {
|
|
85
|
+
readonly kind: "not-applicable";
|
|
86
|
+
readonly proposal: ProposedChange;
|
|
87
|
+
readonly error: TreeError;
|
|
88
|
+
};
|
|
89
|
+
export type CompositionOutcomeKind = CompositionOutcome["kind"];
|
|
90
|
+
/**
|
|
91
|
+
* The five ways an ask can end, in the order a host meets them.
|
|
92
|
+
*
|
|
93
|
+
* The same addition `WRITE_OUTCOME_KINDS` is for the write path, one level up:
|
|
94
|
+
* a `switch` is exhaustive at compile time and enumeration has no answer, so
|
|
95
|
+
* anything that wants to *walk* the endings — a surface explaining what a host
|
|
96
|
+
* must handle, a dashboard seeding a bucket per ending before the first request,
|
|
97
|
+
* a runbook — keeps its own copy and nothing fails when a sixth lands.
|
|
98
|
+
*
|
|
99
|
+
* Ordered applied, awaiting-confirmation, rejected, not-interpreted,
|
|
100
|
+
* not-applicable: the three the Gate decides first, then the two that never
|
|
101
|
+
* reached it. A reader taking them in this order learns the shape of the
|
|
102
|
+
* pipeline; alphabetical order would put `applied` beside `awaiting-confirmation`
|
|
103
|
+
* for no reason a reader could use.
|
|
104
|
+
*/
|
|
105
|
+
export declare const COMPOSITION_OUTCOME_KINDS: readonly CompositionOutcomeKind[];
|
|
106
|
+
export declare const composeChange: (runtime: CompositionRuntime, tree: LoomTree, intent: EditIntent) => Promise<CompositionOutcome>;
|
|
107
|
+
/**
|
|
108
|
+
* What confirming can produce. Narrower than `CompositionOutcome` because
|
|
109
|
+
* confirmation starts from a proposal that already exists: there is nothing left
|
|
110
|
+
* to interpret, and a change the Gate holds a second time is not offered a third
|
|
111
|
+
* — it applies or it does not.
|
|
112
|
+
*/
|
|
113
|
+
export type ConfirmationOutcome = Extract<CompositionOutcome, {
|
|
114
|
+
readonly kind: "applied" | "rejected" | "not-applicable";
|
|
115
|
+
}>;
|
|
116
|
+
/**
|
|
117
|
+
* Completes a change the Gate held back. The assessment is recomputed against
|
|
118
|
+
* the tree as it stands now rather than trusting the one captured at proposal
|
|
119
|
+
* time, so a confirmation cannot smuggle in a decision made about a different
|
|
120
|
+
* tree. A change the Gate now refuses outright stays refused, even with a
|
|
121
|
+
* human saying yes.
|
|
122
|
+
*/
|
|
123
|
+
export declare const confirmChange: (runtime: CompositionRuntime, tree: LoomTree, proposal: ProposedChange, intent: EditIntent) => ConfirmationOutcome;
|
|
124
|
+
//# sourceMappingURL=pipeline.d.ts.map
|