@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,187 @@
|
|
|
1
|
+
import type { IntentId, ProposalId, TreeId } from "../ids.js";
|
|
2
|
+
import type { StoreError } from "../store/errors.js";
|
|
3
|
+
import type { TreeDelta } from "../tree/delta.js";
|
|
4
|
+
import type { TreeError } from "../tree/errors.js";
|
|
5
|
+
import type { ChangeAssessment } from "./assessment.js";
|
|
6
|
+
import type { Disposition, DispositionReason } from "./disposition.js";
|
|
7
|
+
import type { EditIntent } from "./intent.js";
|
|
8
|
+
import type { InterpretationError } from "./interpreter.js";
|
|
9
|
+
import type { GatePolicy } from "./policy.js";
|
|
10
|
+
import type { ProposedChange } from "./proposal.js";
|
|
11
|
+
/**
|
|
12
|
+
* The runtime narrates itself.
|
|
13
|
+
*
|
|
14
|
+
* Every stage emits, including the ones that fail, because the telemetry
|
|
15
|
+
* pipeline needs the rejected and unconfirmed changes as much as the applied
|
|
16
|
+
* ones — a Gate that refuses the right things is only demonstrable if refusals
|
|
17
|
+
* are recorded.
|
|
18
|
+
*
|
|
19
|
+
* These events are the runtime talking to itself within one request, so they
|
|
20
|
+
* carry whole assessments and whole inverse deltas. What survives the request is
|
|
21
|
+
* a narrowing of them (0023), which `src/telemetry` owns.
|
|
22
|
+
*/
|
|
23
|
+
export type RuntimeEvent = {
|
|
24
|
+
readonly type: "intent-received";
|
|
25
|
+
readonly intent: EditIntent;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Which policy this intent will be judged under, settled before anything is
|
|
29
|
+
* interpreted. Emitted even for an intent that never reaches a disposition,
|
|
30
|
+
* because "which policy was in force" is a question about the ask rather than
|
|
31
|
+
* about the answer — and an interpretation failure under a strict policy and
|
|
32
|
+
* one under a lax policy are not the same event.
|
|
33
|
+
*
|
|
34
|
+
* It carries the whole policy: within a request the next stage needs the
|
|
35
|
+
* values, not the name. What survives is narrower (0023).
|
|
36
|
+
*/
|
|
37
|
+
| {
|
|
38
|
+
readonly type: "policy-resolved";
|
|
39
|
+
readonly intentId: IntentId;
|
|
40
|
+
readonly policy: GatePolicy;
|
|
41
|
+
} | {
|
|
42
|
+
readonly type: "interpretation-failed";
|
|
43
|
+
readonly intent: EditIntent;
|
|
44
|
+
readonly error: InterpretationError;
|
|
45
|
+
} | {
|
|
46
|
+
readonly type: "change-proposed";
|
|
47
|
+
readonly proposal: ProposedChange;
|
|
48
|
+
} | {
|
|
49
|
+
readonly type: "assessment-failed";
|
|
50
|
+
readonly proposal: ProposedChange;
|
|
51
|
+
readonly error: TreeError;
|
|
52
|
+
} | {
|
|
53
|
+
readonly type: "change-assessed";
|
|
54
|
+
readonly assessment: ChangeAssessment;
|
|
55
|
+
} | {
|
|
56
|
+
readonly type: "disposition-decided";
|
|
57
|
+
readonly proposalId: ProposalId;
|
|
58
|
+
readonly disposition: Disposition;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* A refusal was handed back for one more attempt. Emitted *after* the
|
|
62
|
+
* refusal's own `disposition-decided`, never instead of it: a change that was
|
|
63
|
+
* refused and then repaired into something acceptable must leave both halves
|
|
64
|
+
* of that story in the record, or the pattern becomes invisible.
|
|
65
|
+
*/
|
|
66
|
+
| {
|
|
67
|
+
readonly type: "repair-requested";
|
|
68
|
+
readonly refusedProposalId: ProposalId;
|
|
69
|
+
readonly reason: DispositionReason;
|
|
70
|
+
} | {
|
|
71
|
+
readonly type: "repair-failed";
|
|
72
|
+
readonly refusedProposalId: ProposalId;
|
|
73
|
+
readonly error: InterpretationError;
|
|
74
|
+
} | {
|
|
75
|
+
readonly type: "change-applied";
|
|
76
|
+
readonly proposalId: ProposalId;
|
|
77
|
+
readonly revision: number;
|
|
78
|
+
readonly inverse: TreeDelta;
|
|
79
|
+
} | {
|
|
80
|
+
readonly type: "application-failed";
|
|
81
|
+
readonly proposalId: ProposalId;
|
|
82
|
+
readonly error: TreeError;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* An intent that never reached interpretation, because the tree it named had
|
|
86
|
+
* already moved on. Narrated rather than silently returned: a rising rate of
|
|
87
|
+
* this is contention, and it is the one failure a client is expected to
|
|
88
|
+
* recover from on its own (0017).
|
|
89
|
+
*/
|
|
90
|
+
| {
|
|
91
|
+
readonly type: "intent-not-writable";
|
|
92
|
+
readonly intent: EditIntent;
|
|
93
|
+
readonly error: StoreError;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* The Gate held a change back and custody of it succeeded, so there is
|
|
97
|
+
* something for a human to answer. Distinct from the `disposition-decided`
|
|
98
|
+
* that preceded it: one is a judgment, the other is a proposal that still
|
|
99
|
+
* exists to be confirmed.
|
|
100
|
+
*/
|
|
101
|
+
| {
|
|
102
|
+
readonly type: "proposal-held";
|
|
103
|
+
readonly proposalId: ProposalId;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Custody failed, so a change the Gate was willing to offer is simply gone.
|
|
107
|
+
* Emitted because the alternative is a change that disappears between two
|
|
108
|
+
* events that both say things went well.
|
|
109
|
+
*/
|
|
110
|
+
| {
|
|
111
|
+
readonly type: "hold-failed";
|
|
112
|
+
readonly proposalId: ProposalId;
|
|
113
|
+
readonly detail: string;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* A human answered a held proposal. The disposition that follows is the Gate's
|
|
117
|
+
* second look.
|
|
118
|
+
*
|
|
119
|
+
* `actor` is who answered, which is not who asked: a hold exists precisely
|
|
120
|
+
* because the Gate wanted a second person, and provenance records only the
|
|
121
|
+
* first. This event is the only place the approval is attributed (0027), so a
|
|
122
|
+
* host that drops it keeps the change and loses who allowed it.
|
|
123
|
+
*/
|
|
124
|
+
| {
|
|
125
|
+
readonly type: "hold-confirmed";
|
|
126
|
+
readonly proposalId: ProposalId;
|
|
127
|
+
readonly actor?: string;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* A human answered no. The most valuable event in this list for §6: it is the
|
|
131
|
+
* only one that says a change the Gate was prepared to allow was not wanted,
|
|
132
|
+
* which is what calibration (0007) has to learn from — and a refusal is only
|
|
133
|
+
* evidence about a reviewer if it says which one.
|
|
134
|
+
*/
|
|
135
|
+
| {
|
|
136
|
+
readonly type: "hold-discarded";
|
|
137
|
+
readonly proposalId: ProposalId;
|
|
138
|
+
readonly actor?: string;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* The delta reached the log. `change-applied` says a tree in memory accepted
|
|
142
|
+
* it; this says the truth (0016) moved.
|
|
143
|
+
*/
|
|
144
|
+
| {
|
|
145
|
+
readonly type: "change-committed";
|
|
146
|
+
readonly proposalId: ProposalId;
|
|
147
|
+
readonly revision: number;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Accepted, applied in memory, and then not persisted. The gap between
|
|
151
|
+
* `change-applied` and this is the one place the event stream could lie about
|
|
152
|
+
* what a tree contains, so it is narrated rather than returned only to the
|
|
153
|
+
* caller.
|
|
154
|
+
*/
|
|
155
|
+
| {
|
|
156
|
+
readonly type: "commit-failed";
|
|
157
|
+
readonly proposalId: ProposalId;
|
|
158
|
+
readonly error: StoreError;
|
|
159
|
+
};
|
|
160
|
+
export type RuntimeEventEnvelope = {
|
|
161
|
+
readonly treeId: TreeId;
|
|
162
|
+
readonly occurredAt: string;
|
|
163
|
+
readonly event: RuntimeEvent;
|
|
164
|
+
};
|
|
165
|
+
/**
|
|
166
|
+
* Emission is fire-and-forget: a sink that throws cannot fail a change the Gate
|
|
167
|
+
* already accepted.
|
|
168
|
+
*
|
|
169
|
+
* That is a guarantee the runtime provides, not an obligation this interface
|
|
170
|
+
* places on whoever implements it. Every event leaves through `narrator`, which
|
|
171
|
+
* contains whatever `emit` throws or rejects with (0042) — so a sink may be a
|
|
172
|
+
* bad citizen, but it cannot be load-bearing. The cost is that a throw is
|
|
173
|
+
* invisible: the event is lost and nothing says so.
|
|
174
|
+
*
|
|
175
|
+
* Hosts that need durability buffer behind this interface and flush once
|
|
176
|
+
* (0024), which is also how they keep count of what they lost.
|
|
177
|
+
*/
|
|
178
|
+
export interface EventSink {
|
|
179
|
+
readonly emit: (envelope: RuntimeEventEnvelope) => void;
|
|
180
|
+
}
|
|
181
|
+
/** Reading the clock is a side effect, so it enters through a seam like ids do. */
|
|
182
|
+
export interface Clock {
|
|
183
|
+
readonly now: () => string;
|
|
184
|
+
}
|
|
185
|
+
export declare const systemClock: Clock;
|
|
186
|
+
export declare const noopEventSink: EventSink;
|
|
187
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ChangeAssessment } from "./assessment.js";
|
|
2
|
+
import type { Disposition, DispositionReasonCode } from "./disposition.js";
|
|
3
|
+
import { type GatePolicy } from "./policy.js";
|
|
4
|
+
/**
|
|
5
|
+
* The Gate.
|
|
6
|
+
*
|
|
7
|
+
* A pure function from an assessment and a policy to a disposition. It performs
|
|
8
|
+
* no IO, reads no clock, touches no tree, and holds no state — the same inputs
|
|
9
|
+
* always produce the same decision, which is what makes the runtime's behaviour
|
|
10
|
+
* auditable after the fact and testable before it.
|
|
11
|
+
*
|
|
12
|
+
* The decision is a short ordered list of rules; the first one that fires wins.
|
|
13
|
+
* Order encodes precedence: a refusal outranks a request for confirmation, and
|
|
14
|
+
* an irreversible change is escalated before the ordinary stakes ceiling gets a
|
|
15
|
+
* say, so "small but permanent" is never silently auto-applied. A change that
|
|
16
|
+
* discards work already in the log is escalated there too, and for the same
|
|
17
|
+
* reason: the ceiling is per origin, and neither of those two properties should
|
|
18
|
+
* depend on who asked (0035).
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* The code a rung stamps when it fires. Every reason code but the acceptance.
|
|
22
|
+
*
|
|
23
|
+
* Excluded by type rather than by care: `within-policy` is what the Gate says
|
|
24
|
+
* when nothing objected, and a rung that stamped it would be a rung reporting
|
|
25
|
+
* that it did not fire.
|
|
26
|
+
*/
|
|
27
|
+
export type EscalationCode = Exclude<DispositionReasonCode, "within-policy">;
|
|
28
|
+
/**
|
|
29
|
+
* The ladder, in the order it is consulted, read off the rules themselves.
|
|
30
|
+
*
|
|
31
|
+
* Published because the number of rungs and their precedence are the thing this
|
|
32
|
+
* repository describes most often and in the most places — a record, a lesson,
|
|
33
|
+
* a documentation page, a portal that shows a reader which rung fired. Every one
|
|
34
|
+
* of those otherwise counts the rules by reading the source and writing the
|
|
35
|
+
* number down, which is a copy, and a copy of a list is wrong from the first
|
|
36
|
+
* time the list changes.
|
|
37
|
+
*
|
|
38
|
+
* It is derived rather than declared, so it cannot disagree with the rules it
|
|
39
|
+
* describes: inserting a rung changes this list in the same edit.
|
|
40
|
+
*/
|
|
41
|
+
export declare const ESCALATION_LADDER: readonly EscalationCode[];
|
|
42
|
+
export declare const gate: (assessment: ChangeAssessment, policy: GatePolicy) => Disposition;
|
|
43
|
+
//# sourceMappingURL=gate.d.ts.map
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { policyFingerprintOf } from "./policy-fingerprint.js";
|
|
2
|
+
import { ceilingFor } from "./policy.js";
|
|
3
|
+
import { isAbove, isAtLeast } from "./stake-level.js";
|
|
4
|
+
import { stakeFactor } from "./stakes.js";
|
|
5
|
+
const decide = (assessment, policy, kind, reason) => ({
|
|
6
|
+
kind,
|
|
7
|
+
reason,
|
|
8
|
+
stakes: assessment.stakes.level,
|
|
9
|
+
reversible: assessment.reversibility.reversible,
|
|
10
|
+
confidence: assessment.proposal.provenance.confidence,
|
|
11
|
+
/**
|
|
12
|
+
* The one place a judgment is attributed to the policy that made it. Stamped
|
|
13
|
+
* here rather than by the caller because the caller could stamp a different
|
|
14
|
+
* one than the rules consulted, and a disposition naming a policy it was not
|
|
15
|
+
* decided under is worse than one naming none.
|
|
16
|
+
*/
|
|
17
|
+
policyId: policy.policyId,
|
|
18
|
+
/**
|
|
19
|
+
* And what that policy contained, for the same reason and in the same place. A
|
|
20
|
+
* name is what a host can look up; a fingerprint is what proves the name still
|
|
21
|
+
* means what it meant. Neither is trustworthy from the caller.
|
|
22
|
+
*/
|
|
23
|
+
policyFingerprint: policyFingerprintOf(policy),
|
|
24
|
+
});
|
|
25
|
+
/** Too unsure to act on at all — asking the user to confirm a guess is noise. */
|
|
26
|
+
const rejectBelowConfidenceFloor = {
|
|
27
|
+
code: "confidence-below-floor",
|
|
28
|
+
kind: "rejected",
|
|
29
|
+
fires: (assessment, policy) => {
|
|
30
|
+
const { confidence } = assessment.proposal.provenance;
|
|
31
|
+
if (confidence >= policy.confidenceFloor)
|
|
32
|
+
return null;
|
|
33
|
+
return `interpreter confidence ${confidence} is below the floor of ${policy.confidenceFloor}`;
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
/** Some changes are not offered to the user at all, however they were asked for. */
|
|
37
|
+
const rejectAtRefusalFloor = {
|
|
38
|
+
code: "stakes-at-refusal-floor",
|
|
39
|
+
kind: "rejected",
|
|
40
|
+
fires: (assessment, policy) => {
|
|
41
|
+
if (!isAtLeast(assessment.stakes.level, policy.refusalFloor))
|
|
42
|
+
return null;
|
|
43
|
+
const detail = assessment.stakes.factors.map((factor) => factor.detail).join("; ");
|
|
44
|
+
return detail || `stakes reached ${policy.refusalFloor}`;
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
/** Undo would not undo reality, so a human decides — regardless of how small it looks. */
|
|
48
|
+
const confirmIrreversible = {
|
|
49
|
+
code: "irreversible",
|
|
50
|
+
kind: "requires-confirmation",
|
|
51
|
+
fires: (assessment) => {
|
|
52
|
+
if (assessment.reversibility.reversible)
|
|
53
|
+
return null;
|
|
54
|
+
const detail = assessment.reversibility.reasons.map((reason) => reason.code).join("; ");
|
|
55
|
+
return `cannot be undone cleanly: ${detail}`;
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* A change that writes over work already in the log is never applied without a
|
|
60
|
+
* person, whatever latitude its origin has.
|
|
61
|
+
*
|
|
62
|
+
* This is a rule rather than a level, because a level cannot say "never
|
|
63
|
+
* auto-apply": the ceilings are per origin (0002), so a `high` factor is a hold
|
|
64
|
+
* for one origin and an auto-apply for another. The thing that must not happen —
|
|
65
|
+
* work discarded with nobody in the loop — does not depend on who asked.
|
|
66
|
+
*
|
|
67
|
+
* It sits below the refusal floor deliberately. A host that has declared this
|
|
68
|
+
* much damage refusable gets a refusal; the floor stays sovereign over the
|
|
69
|
+
* escalations.
|
|
70
|
+
*/
|
|
71
|
+
const confirmDiscardsLaterWork = {
|
|
72
|
+
code: "discards-later-work",
|
|
73
|
+
kind: "requires-confirmation",
|
|
74
|
+
fires: (assessment) => stakeFactor(assessment.stakes, "discards-later-work")?.detail ?? null,
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* A change that moves where a form posts is never applied without a person,
|
|
78
|
+
* whatever latitude its origin has.
|
|
79
|
+
*
|
|
80
|
+
* The same argument as the rule above, about the same kind of thing: a level
|
|
81
|
+
* cannot say "never auto-apply" while ceilings are per origin, and the fact that
|
|
82
|
+
* must not pass unnoticed — the next visitor's message arriving somewhere else —
|
|
83
|
+
* does not depend on who asked for it.
|
|
84
|
+
*
|
|
85
|
+
* Below the refusal floor for the same reason, so a host that has declared this
|
|
86
|
+
* much damage refusable still gets a refusal.
|
|
87
|
+
*/
|
|
88
|
+
const confirmRedirectedSubmission = {
|
|
89
|
+
code: "redirected-submission",
|
|
90
|
+
kind: "requires-confirmation",
|
|
91
|
+
fires: (assessment) => stakeFactor(assessment.stakes, "redirected-submission")?.detail ?? null,
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* A change that points a region at different data is never applied without a
|
|
95
|
+
* person, whatever latitude its origin has.
|
|
96
|
+
*
|
|
97
|
+
* The same argument as the rule above, at the other end of the same pipe. That
|
|
98
|
+
* one keeps the next visitor's message from arriving somewhere else unnoticed;
|
|
99
|
+
* this one keeps something the host never meant to publish from appearing on a
|
|
100
|
+
* public page unnoticed. Neither fact depends on who asked.
|
|
101
|
+
*
|
|
102
|
+
* Below the refusal floor for the same reason, so a host that has declared this
|
|
103
|
+
* much damage refusable still gets a refusal.
|
|
104
|
+
*/
|
|
105
|
+
const confirmRepointedBinding = {
|
|
106
|
+
code: "repointed-binding",
|
|
107
|
+
kind: "requires-confirmation",
|
|
108
|
+
fires: (assessment) => stakeFactor(assessment.stakes, "repointed-binding")?.detail ?? null,
|
|
109
|
+
};
|
|
110
|
+
const confirmAboveCeiling = {
|
|
111
|
+
code: "stakes-above-ceiling",
|
|
112
|
+
kind: "requires-confirmation",
|
|
113
|
+
fires: (assessment, policy) => {
|
|
114
|
+
const ceiling = ceilingFor(policy, assessment.proposal.provenance.origin);
|
|
115
|
+
if (!isAbove(assessment.stakes.level, ceiling))
|
|
116
|
+
return null;
|
|
117
|
+
const detail = assessment.stakes.factors.map((factor) => factor.detail).join("; ");
|
|
118
|
+
return (detail ||
|
|
119
|
+
`${assessment.stakes.level} stakes exceed the ${ceiling} ceiling for ${assessment.proposal.provenance.origin}`);
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
const confirmBelowMinimumConfidence = {
|
|
123
|
+
code: "confidence-below-minimum",
|
|
124
|
+
kind: "requires-confirmation",
|
|
125
|
+
fires: (assessment, policy) => {
|
|
126
|
+
const { confidence } = assessment.proposal.provenance;
|
|
127
|
+
if (confidence >= policy.minimumConfidence)
|
|
128
|
+
return null;
|
|
129
|
+
return `interpreter confidence ${confidence} is below ${policy.minimumConfidence}`;
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
/** Nothing objected, so the change goes through. */
|
|
133
|
+
const accept = (assessment, policy) => decide(assessment, policy, "accepted", {
|
|
134
|
+
code: "within-policy",
|
|
135
|
+
detail: "reversible, within the stakes ceiling, and confidently interpreted",
|
|
136
|
+
});
|
|
137
|
+
const ESCALATION_RULES = [
|
|
138
|
+
rejectBelowConfidenceFloor,
|
|
139
|
+
rejectAtRefusalFloor,
|
|
140
|
+
confirmIrreversible,
|
|
141
|
+
confirmDiscardsLaterWork,
|
|
142
|
+
confirmRedirectedSubmission,
|
|
143
|
+
confirmRepointedBinding,
|
|
144
|
+
confirmAboveCeiling,
|
|
145
|
+
confirmBelowMinimumConfidence,
|
|
146
|
+
];
|
|
147
|
+
/**
|
|
148
|
+
* The ladder, in the order it is consulted, read off the rules themselves.
|
|
149
|
+
*
|
|
150
|
+
* Published because the number of rungs and their precedence are the thing this
|
|
151
|
+
* repository describes most often and in the most places — a record, a lesson,
|
|
152
|
+
* a documentation page, a portal that shows a reader which rung fired. Every one
|
|
153
|
+
* of those otherwise counts the rules by reading the source and writing the
|
|
154
|
+
* number down, which is a copy, and a copy of a list is wrong from the first
|
|
155
|
+
* time the list changes.
|
|
156
|
+
*
|
|
157
|
+
* It is derived rather than declared, so it cannot disagree with the rules it
|
|
158
|
+
* describes: inserting a rung changes this list in the same edit.
|
|
159
|
+
*/
|
|
160
|
+
export const ESCALATION_LADDER = ESCALATION_RULES.map((rule) => rule.code);
|
|
161
|
+
export const gate = (assessment, policy) => {
|
|
162
|
+
for (const rule of ESCALATION_RULES) {
|
|
163
|
+
const detail = rule.fires(assessment, policy);
|
|
164
|
+
if (detail !== null)
|
|
165
|
+
return decide(assessment, policy, rule.kind, { code: rule.code, detail });
|
|
166
|
+
}
|
|
167
|
+
return accept(assessment, policy);
|
|
168
|
+
};
|
|
169
|
+
//# sourceMappingURL=gate.js.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The part of Loom that decides whether a change may happen.
|
|
3
|
+
*
|
|
4
|
+
* An intent becomes a proposal, the proposal is analysed for what it puts at
|
|
5
|
+
* stake, and a policy turns that into one of three answers: apply it, ask a human
|
|
6
|
+
* first, or refuse. What it decided, and why, is narrated as it goes.
|
|
7
|
+
*/
|
|
8
|
+
export * from "./analysis.js";
|
|
9
|
+
export * from "./assessment.js";
|
|
10
|
+
export * from "./disposition.js";
|
|
11
|
+
export * from "./events.js";
|
|
12
|
+
export * from "./gate.js";
|
|
13
|
+
export * from "./intent.js";
|
|
14
|
+
export * from "./interpreter.js";
|
|
15
|
+
export * from "./inverse.js";
|
|
16
|
+
export * from "./nesting.js";
|
|
17
|
+
export * from "./pipeline.js";
|
|
18
|
+
export * from "./policy-fingerprint.js";
|
|
19
|
+
export * from "./policy-source.js";
|
|
20
|
+
export * from "./policy.js";
|
|
21
|
+
export * from "./proposal.js";
|
|
22
|
+
export * from "./redirection.js";
|
|
23
|
+
export * from "./reversibility.js";
|
|
24
|
+
export * from "./stake-level.js";
|
|
25
|
+
export * from "./stakes.js";
|
|
26
|
+
export * from "./vocabulary.js";
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The part of Loom that decides whether a change may happen.
|
|
3
|
+
*
|
|
4
|
+
* An intent becomes a proposal, the proposal is analysed for what it puts at
|
|
5
|
+
* stake, and a policy turns that into one of three answers: apply it, ask a human
|
|
6
|
+
* first, or refuse. What it decided, and why, is narrated as it goes.
|
|
7
|
+
*/
|
|
8
|
+
export * from "./analysis.js";
|
|
9
|
+
export * from "./assessment.js";
|
|
10
|
+
export * from "./disposition.js";
|
|
11
|
+
export * from "./events.js";
|
|
12
|
+
export * from "./gate.js";
|
|
13
|
+
export * from "./intent.js";
|
|
14
|
+
export * from "./interpreter.js";
|
|
15
|
+
export * from "./inverse.js";
|
|
16
|
+
export * from "./nesting.js";
|
|
17
|
+
export * from "./pipeline.js";
|
|
18
|
+
export * from "./policy-fingerprint.js";
|
|
19
|
+
export * from "./policy-source.js";
|
|
20
|
+
export * from "./policy.js";
|
|
21
|
+
export * from "./proposal.js";
|
|
22
|
+
export * from "./redirection.js";
|
|
23
|
+
export * from "./reversibility.js";
|
|
24
|
+
export * from "./stake-level.js";
|
|
25
|
+
export * from "./stakes.js";
|
|
26
|
+
export * from "./vocabulary.js";
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { type IntentId, type NodeId, type TreeId } from "../ids.js";
|
|
3
|
+
/**
|
|
4
|
+
* An EditIntent is what someone — or something — wants, before any
|
|
5
|
+
* interpretation. It is deliberately unstructured: a sentence, plus enough
|
|
6
|
+
* context to interpret it against a specific tree at a specific revision.
|
|
7
|
+
*
|
|
8
|
+
* Origin is carried from here all the way to the Gate, because who asked is a
|
|
9
|
+
* real input to how much latitude a change gets. An explicit human instruction
|
|
10
|
+
* earns more than an inference nobody requested.
|
|
11
|
+
*
|
|
12
|
+
* `actor` is the identity behind the origin, and it travels the same route:
|
|
13
|
+
* whatever raises an intent states who is behind it, and the interpreter copies
|
|
14
|
+
* it into provenance rather than inventing it (0027). It is optional here
|
|
15
|
+
* because a `system-signal` or a `scheduled-adaptation` has no one to name — not
|
|
16
|
+
* because a host may skip it for a human ask.
|
|
17
|
+
*/
|
|
18
|
+
export declare const intentOriginSchema: z.ZodEnum<["user-instruction", "system-signal", "scheduled-adaptation", "developer"]>;
|
|
19
|
+
export type IntentOrigin = z.infer<typeof intentOriginSchema>;
|
|
20
|
+
export declare const editIntentSchema: z.ZodObject<{
|
|
21
|
+
intentId: z.ZodBranded<z.ZodString, "IntentId">;
|
|
22
|
+
treeId: z.ZodBranded<z.ZodString, "TreeId">;
|
|
23
|
+
baseRevision: z.ZodNumber;
|
|
24
|
+
origin: z.ZodEnum<["user-instruction", "system-signal", "scheduled-adaptation", "developer"]>;
|
|
25
|
+
/** Who is behind the origin, named by whoever raised the intent. */
|
|
26
|
+
actor: z.ZodOptional<z.ZodString>;
|
|
27
|
+
utterance: z.ZodString;
|
|
28
|
+
/** Narrows interpretation to a subtree — "make *this card* quieter". */
|
|
29
|
+
scopeNodeId: z.ZodOptional<z.ZodBranded<z.ZodString, "NodeId">>;
|
|
30
|
+
observedAt: z.ZodString;
|
|
31
|
+
}, "strip", z.ZodTypeAny, {
|
|
32
|
+
treeId: string & z.BRAND<"TreeId">;
|
|
33
|
+
origin: "user-instruction" | "system-signal" | "scheduled-adaptation" | "developer";
|
|
34
|
+
baseRevision: number;
|
|
35
|
+
intentId: string & z.BRAND<"IntentId">;
|
|
36
|
+
utterance: string;
|
|
37
|
+
observedAt: string;
|
|
38
|
+
actor?: string | undefined;
|
|
39
|
+
scopeNodeId?: (string & z.BRAND<"NodeId">) | undefined;
|
|
40
|
+
}, {
|
|
41
|
+
treeId: string;
|
|
42
|
+
origin: "user-instruction" | "system-signal" | "scheduled-adaptation" | "developer";
|
|
43
|
+
baseRevision: number;
|
|
44
|
+
intentId: string;
|
|
45
|
+
utterance: string;
|
|
46
|
+
observedAt: string;
|
|
47
|
+
actor?: string | undefined;
|
|
48
|
+
scopeNodeId?: string | undefined;
|
|
49
|
+
}>;
|
|
50
|
+
export type EditIntent = {
|
|
51
|
+
readonly intentId: IntentId;
|
|
52
|
+
readonly treeId: TreeId;
|
|
53
|
+
readonly baseRevision: number;
|
|
54
|
+
readonly origin: IntentOrigin;
|
|
55
|
+
readonly actor?: string;
|
|
56
|
+
readonly utterance: string;
|
|
57
|
+
readonly scopeNodeId?: NodeId;
|
|
58
|
+
readonly observedAt: string;
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=intent.d.ts.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { intentIdSchema, nodeIdSchema, treeIdSchema } from "../ids.js";
|
|
3
|
+
/**
|
|
4
|
+
* An EditIntent is what someone — or something — wants, before any
|
|
5
|
+
* interpretation. It is deliberately unstructured: a sentence, plus enough
|
|
6
|
+
* context to interpret it against a specific tree at a specific revision.
|
|
7
|
+
*
|
|
8
|
+
* Origin is carried from here all the way to the Gate, because who asked is a
|
|
9
|
+
* real input to how much latitude a change gets. An explicit human instruction
|
|
10
|
+
* earns more than an inference nobody requested.
|
|
11
|
+
*
|
|
12
|
+
* `actor` is the identity behind the origin, and it travels the same route:
|
|
13
|
+
* whatever raises an intent states who is behind it, and the interpreter copies
|
|
14
|
+
* it into provenance rather than inventing it (0027). It is optional here
|
|
15
|
+
* because a `system-signal` or a `scheduled-adaptation` has no one to name — not
|
|
16
|
+
* because a host may skip it for a human ask.
|
|
17
|
+
*/
|
|
18
|
+
export const intentOriginSchema = z.enum([
|
|
19
|
+
"user-instruction",
|
|
20
|
+
"system-signal",
|
|
21
|
+
"scheduled-adaptation",
|
|
22
|
+
"developer",
|
|
23
|
+
]);
|
|
24
|
+
export const editIntentSchema = z.object({
|
|
25
|
+
intentId: intentIdSchema,
|
|
26
|
+
treeId: treeIdSchema,
|
|
27
|
+
baseRevision: z.number().int().nonnegative(),
|
|
28
|
+
origin: intentOriginSchema,
|
|
29
|
+
/** Who is behind the origin, named by whoever raised the intent. */
|
|
30
|
+
actor: z.string().min(1).optional(),
|
|
31
|
+
utterance: z.string().min(1),
|
|
32
|
+
/** Narrows interpretation to a subtree — "make *this card* quieter". */
|
|
33
|
+
scopeNodeId: nodeIdSchema.optional(),
|
|
34
|
+
observedAt: z.string().datetime(),
|
|
35
|
+
});
|
|
36
|
+
//# sourceMappingURL=intent.js.map
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { type Result } from "../result.js";
|
|
2
|
+
import type { LoomTree } from "../tree/tree.js";
|
|
3
|
+
import type { Disposition } from "./disposition.js";
|
|
4
|
+
import type { EditIntent } from "./intent.js";
|
|
5
|
+
import type { ProposedChange } from "./proposal.js";
|
|
6
|
+
/**
|
|
7
|
+
* The AI seam.
|
|
8
|
+
*
|
|
9
|
+
* Interpretation is the one genuinely non-deterministic step in the pipeline,
|
|
10
|
+
* so it sits behind an interface the rest of the runtime depends on but never
|
|
11
|
+
* implements. Everything downstream — assessment, the Gate, application — is
|
|
12
|
+
* pure and can be tested without a model in the loop.
|
|
13
|
+
*
|
|
14
|
+
* An interpreter may fail to produce a delta at all. That is a distinct outcome
|
|
15
|
+
* from producing one the Gate rejects, and the two must not be conflated: the
|
|
16
|
+
* first is "I did not understand", the second is "you may not do that".
|
|
17
|
+
*/
|
|
18
|
+
export type InterpretationError = {
|
|
19
|
+
readonly code: "not-understood";
|
|
20
|
+
readonly detail: string;
|
|
21
|
+
} | {
|
|
22
|
+
readonly code: "no-change-needed";
|
|
23
|
+
readonly detail: string;
|
|
24
|
+
}
|
|
25
|
+
/** The service could not answer now. The same request may succeed later. */
|
|
26
|
+
| {
|
|
27
|
+
readonly code: "interpreter-unavailable";
|
|
28
|
+
readonly detail: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* This deployment cannot reach a model at all — no credential, no entitlement,
|
|
32
|
+
* no billing. Kept apart from `interpreter-unavailable` because waiting never
|
|
33
|
+
* fixes it: an operator does.
|
|
34
|
+
*/
|
|
35
|
+
| {
|
|
36
|
+
readonly code: "interpreter-misconfigured";
|
|
37
|
+
readonly detail: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The service rejected the request Loom assembled, and would reject the same
|
|
41
|
+
* request again. This one is Loom's own fault, and it is the only failure here
|
|
42
|
+
* that a deployment can neither wait out nor configure away.
|
|
43
|
+
*/
|
|
44
|
+
| {
|
|
45
|
+
readonly code: "interpreter-request-rejected";
|
|
46
|
+
readonly detail: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The interpreter itself declined — a safety classifier, a content policy, a
|
|
50
|
+
* guardrail of its own. Kept apart from `interpreter-unavailable` because one
|
|
51
|
+
* is a statement about the request and the other is a statement about the
|
|
52
|
+
* service: a rising rate of the first is a content signal, a rising rate of
|
|
53
|
+
* the second is an outage.
|
|
54
|
+
*/
|
|
55
|
+
| {
|
|
56
|
+
readonly code: "refused";
|
|
57
|
+
readonly detail: string;
|
|
58
|
+
} | {
|
|
59
|
+
readonly code: "malformed-proposal";
|
|
60
|
+
readonly detail: string;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Who would have to do something for the next attempt to go differently.
|
|
64
|
+
*
|
|
65
|
+
* Seven codes, five actors. A reader that switches on codes has to know all
|
|
66
|
+
* seven and re-derive the grouping; a reader that switches on this cannot get
|
|
67
|
+
* the grouping wrong, and gains nothing to update when an eighth code lands.
|
|
68
|
+
*
|
|
69
|
+
* Deliberately not a `retryable` boolean. Retrying is a policy — a host may
|
|
70
|
+
* resample a `malformed-proposal` and reasonably refuse to resample anything
|
|
71
|
+
* else — and a seam that answered "should you retry" would be deciding that
|
|
72
|
+
* policy on the host's behalf while knowing less than the host does.
|
|
73
|
+
*/
|
|
74
|
+
export type InterpretationFault =
|
|
75
|
+
/** The intent: nothing failed except the asking. */
|
|
76
|
+
"asker"
|
|
77
|
+
/** The answer that came back. */
|
|
78
|
+
| "model"
|
|
79
|
+
/** The service, this time. */
|
|
80
|
+
| "provider"
|
|
81
|
+
/** The deployment, until someone changes it. */
|
|
82
|
+
| "deployment"
|
|
83
|
+
/** Loom, for what it sent. */
|
|
84
|
+
| "runtime";
|
|
85
|
+
export declare const interpretationFault: (error: InterpretationError) => InterpretationFault;
|
|
86
|
+
/**
|
|
87
|
+
* One sentence a reader who is not holding this union in their head can act on.
|
|
88
|
+
*
|
|
89
|
+
* Every sentence says what happens if nothing changes, because that is the part
|
|
90
|
+
* a code alone never carried: two of these clear on their own and three do not.
|
|
91
|
+
*/
|
|
92
|
+
export declare const describeInterpretationError: (error: InterpretationError) => string;
|
|
93
|
+
export interface ChangeInterpreter {
|
|
94
|
+
readonly interpret: (intent: EditIntent, tree: LoomTree) => Promise<Result<ProposedChange, InterpretationError>>;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* What a repairer is told: the intent that was raised, the proposal the Gate
|
|
98
|
+
* refused, and the disposition that refused it. Deliberately the whole
|
|
99
|
+
* disposition rather than a summary — a repairer that cannot see which rule
|
|
100
|
+
* fired can only guess at what would be acceptable.
|
|
101
|
+
*/
|
|
102
|
+
export type RepairRequest = {
|
|
103
|
+
readonly intent: EditIntent;
|
|
104
|
+
readonly refused: ProposedChange;
|
|
105
|
+
readonly disposition: Disposition;
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Revising a refused proposal is a different job from interpreting an
|
|
109
|
+
* utterance, so it is a different interface. A runtime that is handed no
|
|
110
|
+
* repairer cannot repair, which makes "this deployment lets AI have a second
|
|
111
|
+
* go" a visible choice at the composition root rather than a property of
|
|
112
|
+
* whichever interpreter happened to be wired in.
|
|
113
|
+
*/
|
|
114
|
+
export interface ChangeRepairer {
|
|
115
|
+
readonly repair: (request: RepairRequest, tree: LoomTree) => Promise<Result<ProposedChange, InterpretationError>>;
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=interpreter.d.ts.map
|