@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,149 @@
|
|
|
1
|
+
import type { NodeId } from "../ids.js";
|
|
2
|
+
import type { PrimitiveType } from "../primitive-type.js";
|
|
3
|
+
import { type Result } from "../result.js";
|
|
4
|
+
import type { TreeDelta } from "../tree/delta.js";
|
|
5
|
+
import type { TreeError } from "../tree/errors.js";
|
|
6
|
+
import type { LoomTree } from "../tree/tree.js";
|
|
7
|
+
import { type InteractivePredicate, type NestedTarget } from "./nesting.js";
|
|
8
|
+
import { type RedirectedSubmission } from "./redirection.js";
|
|
9
|
+
import { type RepointedBinding } from "./repointing.js";
|
|
10
|
+
import { type InvalidProps, type PrimitiveVocabulary, type PropsVocabulary, type UnknownPrimitive } from "./vocabulary.js";
|
|
11
|
+
/**
|
|
12
|
+
* Facts about what a delta does, extracted before anyone judges it.
|
|
13
|
+
*
|
|
14
|
+
* Analysis is deliberately separate from the Gate: this module knows what
|
|
15
|
+
* changed and nothing about whether that is acceptable. Policy and judgment
|
|
16
|
+
* live downstream, which means the Gate's rules can change without touching
|
|
17
|
+
* how a change is measured.
|
|
18
|
+
*
|
|
19
|
+
* Two facts need vocabulary to state, and that is not the same as needing
|
|
20
|
+
* judgment. "This node renders a target" and "this deployment has no primitive
|
|
21
|
+
* for that type" are both properties of the host's primitives that no amount of
|
|
22
|
+
* looking at the tree recovers, so they arrive as predicates; what either is
|
|
23
|
+
* worth is still decided downstream.
|
|
24
|
+
*/
|
|
25
|
+
export type ChangeAnalysis = {
|
|
26
|
+
readonly operationCount: number;
|
|
27
|
+
readonly insertedNodeCount: number;
|
|
28
|
+
readonly removedNodeCount: number;
|
|
29
|
+
/** Nodes a move operation named. The subtree each carried is counted separately. */
|
|
30
|
+
readonly movedNodeCount: number;
|
|
31
|
+
readonly configuredNodeCount: number;
|
|
32
|
+
/**
|
|
33
|
+
* Nodes a move carried, the node it named included. A move is the one
|
|
34
|
+
* operation whose reach is larger than the node it names, and measuring it
|
|
35
|
+
* that way is what makes the analysis independent of how the delta was
|
|
36
|
+
* phrased: relocating a slot and relocating the card inside it are the same
|
|
37
|
+
* physical change described two ways (0044).
|
|
38
|
+
*/
|
|
39
|
+
readonly relocatedNodeCount: number;
|
|
40
|
+
/** Nodes directly touched. A move counts the node, not the subtree riding along. */
|
|
41
|
+
readonly affectedNodeIds: readonly NodeId[];
|
|
42
|
+
/**
|
|
43
|
+
* Types this delta created, destroyed, or reconfigured. A move contributes
|
|
44
|
+
* nothing here whichever node it names — a relocated node is not rewritten,
|
|
45
|
+
* and `relocatedPrimitiveTypes` is where it is reported instead (0044).
|
|
46
|
+
*/
|
|
47
|
+
readonly touchedPrimitiveTypes: readonly PrimitiveType[];
|
|
48
|
+
/**
|
|
49
|
+
* Types carried by a move, in the whole subtree rather than at its root. A
|
|
50
|
+
* protected primitive travelling across the page is a fact the Gate has to
|
|
51
|
+
* see, and it is not the same fact as one being rewritten.
|
|
52
|
+
*/
|
|
53
|
+
readonly relocatedPrimitiveTypes: readonly PrimitiveType[];
|
|
54
|
+
/**
|
|
55
|
+
* Types destroyed outright, a subset of the touched types. Destroying a
|
|
56
|
+
* primitive is a strictly bigger deal than reconfiguring one, so stakes need
|
|
57
|
+
* to tell the two apart.
|
|
58
|
+
*/
|
|
59
|
+
readonly removedPrimitiveTypes: readonly PrimitiveType[];
|
|
60
|
+
readonly configuredPropKeys: readonly string[];
|
|
61
|
+
/**
|
|
62
|
+
* Targets this change leaves inside another target, which is a control the
|
|
63
|
+
* reader cannot use. Sometimes because the markup is invalid and a browser
|
|
64
|
+
* drops the inner link; sometimes because the enclosing node covers itself
|
|
65
|
+
* with an overlay and the click never arrives (0068). Same damage either way,
|
|
66
|
+
* and only the outer node's own declaration distinguishes it.
|
|
67
|
+
*
|
|
68
|
+
* Measured on the resulting tree rather than on the operations, because every
|
|
69
|
+
* operation kind can produce it and only one of them looks like it does:
|
|
70
|
+
* `insert` and `move` put a target somewhere, and `configure` breaks every
|
|
71
|
+
* link already inside a card by giving the card an `href`. Positions the tree
|
|
72
|
+
* already had are excluded, so a change is answerable for the breakage it
|
|
73
|
+
* introduces and not for the breakage it inherited.
|
|
74
|
+
*
|
|
75
|
+
* Empty for every host that declares no interactive vocabulary, which is the
|
|
76
|
+
* default.
|
|
77
|
+
*/
|
|
78
|
+
readonly nestedTargets: readonly NestedTarget[];
|
|
79
|
+
/**
|
|
80
|
+
* Nodes this change would add that the deployment has no primitive for, so
|
|
81
|
+
* the page it produces has a hole where each one is.
|
|
82
|
+
*
|
|
83
|
+
* Measured on the operations rather than on the resulting tree, unlike
|
|
84
|
+
* `nestedTargets`, and the difference is the point. A tree may already name a
|
|
85
|
+
* primitive a later deployment rolled back — that is exactly why the renderer
|
|
86
|
+
* reports instead of throwing (0050) — and a change is answerable for the
|
|
87
|
+
* holes it introduces, not for the ones it found. Only `insert` can introduce
|
|
88
|
+
* one: `move` carries nodes the tree already had, and `configure` cannot
|
|
89
|
+
* change a type.
|
|
90
|
+
*
|
|
91
|
+
* Empty for every host that declares no vocabulary, which is the default.
|
|
92
|
+
*/
|
|
93
|
+
readonly unknownPrimitives: readonly UnknownPrimitive[];
|
|
94
|
+
/**
|
|
95
|
+
* Nodes this change would leave carrying props the primitive declaring their
|
|
96
|
+
* type refuses, so the page it produces has a hole where each one is — the
|
|
97
|
+
* same hole `unknownPrimitives` describes, one question further down.
|
|
98
|
+
*
|
|
99
|
+
* Measured on both trees, like `nestedTargets`, and unlike `unknownPrimitives`:
|
|
100
|
+
* props are the one thing two operations in a delta can argue about, so only
|
|
101
|
+
* the tree at the end says what a reader will actually be served.
|
|
102
|
+
* `introducedInvalidProps` says why, and what a node already failing before
|
|
103
|
+
* the change counts as.
|
|
104
|
+
*
|
|
105
|
+
* Empty for every host that wires no props vocabulary, which is the default.
|
|
106
|
+
*/
|
|
107
|
+
readonly invalidProps: readonly InvalidProps[];
|
|
108
|
+
/**
|
|
109
|
+
* Forms this change points somewhere else — a node that posted to one
|
|
110
|
+
* registered endpoint before and posts to another after.
|
|
111
|
+
*
|
|
112
|
+
* Measured on both trees, like `nestedTargets`, and unlike it needs no host
|
|
113
|
+
* vocabulary: `loom:submit` is the runtime's own key. A node that gains or
|
|
114
|
+
* loses a destination is not here; `redirection.ts` says why.
|
|
115
|
+
*/
|
|
116
|
+
readonly redirectedSubmissions: readonly RedirectedSubmission[];
|
|
117
|
+
/**
|
|
118
|
+
* Bindings this change points somewhere else — a node that asked one question
|
|
119
|
+
* under a name before and asks a different one under that name after.
|
|
120
|
+
*
|
|
121
|
+
* The other end of the pipe from `redirectedSubmissions`, measured the same
|
|
122
|
+
* way and needing host vocabulary just as little: `loom:data` is the runtime's
|
|
123
|
+
* own key. A node that gains or loses a binding is not here; `repointing.ts`
|
|
124
|
+
* says why, and why a params change counts where a submission has no params
|
|
125
|
+
* to move.
|
|
126
|
+
*/
|
|
127
|
+
readonly repointedBindings: readonly RepointedBinding[];
|
|
128
|
+
/**
|
|
129
|
+
* Distance from the root of the shallowest touched position, where the root
|
|
130
|
+
* is 0. A change near the root restructures the page; a change deep in a leaf
|
|
131
|
+
* usually does not.
|
|
132
|
+
*/
|
|
133
|
+
readonly shallowestAffectedDepth: number;
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* Walks the delta forward so each operation is measured against the tree it
|
|
137
|
+
* actually observes — an operation may target a node an earlier operation in
|
|
138
|
+
* the same delta inserted.
|
|
139
|
+
*
|
|
140
|
+
* The three vocabularies are separate trailing parameters rather than one
|
|
141
|
+
* record, which is not the shape `StakeInput` argues for. This function is
|
|
142
|
+
* published and a lesson calls it by hand, so collecting them would be a
|
|
143
|
+
* breaking change to teach nothing, and a third one arriving is the second time
|
|
144
|
+
* that has been true; what keeps them from being forgotten is that
|
|
145
|
+
* `assessChange` is the only caller that assembles them, and it passes all
|
|
146
|
+
* three in one expression.
|
|
147
|
+
*/
|
|
148
|
+
export declare const analyzeDelta: (tree: LoomTree, delta: TreeDelta, isInteractive?: InteractivePredicate, isRegistered?: PrimitiveVocabulary, checkProps?: PropsVocabulary) => Result<ChangeAnalysis, TreeError>;
|
|
149
|
+
//# sourceMappingURL=analysis.d.ts.map
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { assertNever, err, ok } from "../result.js";
|
|
2
|
+
import { applyOperation } from "../tree/apply.js";
|
|
3
|
+
import { findNode, pathToNode, walkTree } from "../tree/navigation.js";
|
|
4
|
+
import { nestedTargetsIn, NOTHING_INTERACTIVE, } from "./nesting.js";
|
|
5
|
+
import { redirectedSubmissionsBetween } from "./redirection.js";
|
|
6
|
+
import { repointedBindingsBetween } from "./repointing.js";
|
|
7
|
+
import { EVERY_TYPE_REGISTERED, EVERY_TYPE_UNDECLARED, invalidPropsIn, unknownPrimitivesIn, } from "./vocabulary.js";
|
|
8
|
+
const elementTypesIn = (node) => Array.from(walkTree(node)).flatMap((current) => current.kind === "element" ? [current.type] : []);
|
|
9
|
+
const nodeCount = (node) => Array.from(walkTree(node)).length;
|
|
10
|
+
const depthOf = (root, nodeId) => {
|
|
11
|
+
const path = pathToNode(root, nodeId);
|
|
12
|
+
return path ? path.length - 1 : null;
|
|
13
|
+
};
|
|
14
|
+
const emptyTally = () => ({
|
|
15
|
+
inserted: 0,
|
|
16
|
+
removed: 0,
|
|
17
|
+
moved: 0,
|
|
18
|
+
relocated: 0,
|
|
19
|
+
configured: 0,
|
|
20
|
+
shallowest: Number.POSITIVE_INFINITY,
|
|
21
|
+
affected: new Set(),
|
|
22
|
+
types: new Set(),
|
|
23
|
+
removedTypes: new Set(),
|
|
24
|
+
relocatedTypes: new Set(),
|
|
25
|
+
propKeys: new Set(),
|
|
26
|
+
unknown: [],
|
|
27
|
+
});
|
|
28
|
+
const noteDepth = (tally, depth) => {
|
|
29
|
+
if (depth !== null)
|
|
30
|
+
tally.shallowest = Math.min(tally.shallowest, depth);
|
|
31
|
+
};
|
|
32
|
+
const noteSubtree = (tally, node) => {
|
|
33
|
+
for (const current of walkTree(node))
|
|
34
|
+
tally.affected.add(current.id);
|
|
35
|
+
for (const type of elementTypesIn(node))
|
|
36
|
+
tally.types.add(type);
|
|
37
|
+
};
|
|
38
|
+
const tallyOperation = (tally, root, operation, isRegistered) => {
|
|
39
|
+
switch (operation.op) {
|
|
40
|
+
case "insert": {
|
|
41
|
+
const parentDepth = depthOf(root, operation.parentId);
|
|
42
|
+
if (parentDepth === null)
|
|
43
|
+
return err({ code: "node-not-found", nodeId: operation.parentId });
|
|
44
|
+
tally.inserted += nodeCount(operation.node);
|
|
45
|
+
noteSubtree(tally, operation.node);
|
|
46
|
+
tally.unknown.push(...unknownPrimitivesIn(operation.node, isRegistered));
|
|
47
|
+
noteDepth(tally, parentDepth + 1);
|
|
48
|
+
return ok(tally);
|
|
49
|
+
}
|
|
50
|
+
case "remove": {
|
|
51
|
+
const target = findNode(root, operation.nodeId);
|
|
52
|
+
if (!target)
|
|
53
|
+
return err({ code: "node-not-found", nodeId: operation.nodeId });
|
|
54
|
+
tally.removed += nodeCount(target);
|
|
55
|
+
noteSubtree(tally, target);
|
|
56
|
+
for (const type of elementTypesIn(target))
|
|
57
|
+
tally.removedTypes.add(type);
|
|
58
|
+
noteDepth(tally, depthOf(root, operation.nodeId));
|
|
59
|
+
return ok(tally);
|
|
60
|
+
}
|
|
61
|
+
case "move": {
|
|
62
|
+
const target = findNode(root, operation.nodeId);
|
|
63
|
+
if (!target)
|
|
64
|
+
return err({ code: "node-not-found", nodeId: operation.nodeId });
|
|
65
|
+
const destinationDepth = depthOf(root, operation.parentId);
|
|
66
|
+
if (destinationDepth === null)
|
|
67
|
+
return err({ code: "node-not-found", nodeId: operation.parentId });
|
|
68
|
+
tally.moved += 1;
|
|
69
|
+
tally.relocated += nodeCount(target);
|
|
70
|
+
tally.affected.add(operation.nodeId);
|
|
71
|
+
for (const type of elementTypesIn(target))
|
|
72
|
+
tally.relocatedTypes.add(type);
|
|
73
|
+
noteDepth(tally, depthOf(root, operation.nodeId));
|
|
74
|
+
noteDepth(tally, destinationDepth + 1);
|
|
75
|
+
return ok(tally);
|
|
76
|
+
}
|
|
77
|
+
case "configure": {
|
|
78
|
+
const target = findNode(root, operation.nodeId);
|
|
79
|
+
if (!target)
|
|
80
|
+
return err({ code: "node-not-found", nodeId: operation.nodeId });
|
|
81
|
+
tally.configured += 1;
|
|
82
|
+
tally.affected.add(operation.nodeId);
|
|
83
|
+
if (target.kind === "element")
|
|
84
|
+
tally.types.add(target.type);
|
|
85
|
+
for (const key of [...Object.keys(operation.set), ...operation.unset]) {
|
|
86
|
+
tally.propKeys.add(key);
|
|
87
|
+
}
|
|
88
|
+
noteDepth(tally, depthOf(root, operation.nodeId));
|
|
89
|
+
return ok(tally);
|
|
90
|
+
}
|
|
91
|
+
default:
|
|
92
|
+
return assertNever(operation, "tallyOperation");
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
/** Two ids name the pair; nothing else about it can differ. */
|
|
96
|
+
const pairKey = (nested) => `${nested.ancestorId}>${nested.nodeId}`;
|
|
97
|
+
/**
|
|
98
|
+
* The nested targets this delta is answerable for: the ones in the tree it
|
|
99
|
+
* produces, less the ones already in the tree it started from.
|
|
100
|
+
*
|
|
101
|
+
* The before-walk is skipped when the result has none, which is the ordinary
|
|
102
|
+
* case — a page with no nesting cannot have inherited any.
|
|
103
|
+
*/
|
|
104
|
+
const introducedNestedTargets = (before, after, isInteractive) => {
|
|
105
|
+
const produced = nestedTargetsIn(after, isInteractive);
|
|
106
|
+
if (produced.length === 0)
|
|
107
|
+
return produced;
|
|
108
|
+
const inherited = new Set(nestedTargetsIn(before, isInteractive).map(pairKey));
|
|
109
|
+
return produced.filter((nested) => !inherited.has(pairKey(nested)));
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* The nodes this delta is answerable for leaving unrenderable: the ones whose
|
|
113
|
+
* props fail in the tree it produces, less the ones already failing in the tree
|
|
114
|
+
* it started from.
|
|
115
|
+
*
|
|
116
|
+
* Measured on the two trees rather than on the operations, unlike
|
|
117
|
+
* `unknownPrimitives`, and the difference is forced by what a prop is. A type
|
|
118
|
+
* is fixed when a node is inserted and nothing can change it, so an `insert` is
|
|
119
|
+
* the only operation that can introduce an unknown one. Props are not: a delta
|
|
120
|
+
* may insert a node and configure it, or configure a node another operation in
|
|
121
|
+
* the same delta put there, and only the tree at the end says what the page
|
|
122
|
+
* will actually carry. Measuring the operations would refuse a delta that broke
|
|
123
|
+
* a node and then fixed it in the next breath.
|
|
124
|
+
*
|
|
125
|
+
* Keyed by node id alone, so a node that was already failing and fails
|
|
126
|
+
* differently afterwards counts as inherited. That is deliberate: the page has
|
|
127
|
+
* a hole at that node either way, the change did not put it there, and counting
|
|
128
|
+
* it would refuse the half-repair that is the likeliest way anybody digs such a
|
|
129
|
+
* node back out.
|
|
130
|
+
*
|
|
131
|
+
* The before-walk is skipped when the result has none, which is the ordinary
|
|
132
|
+
* case and — with `EVERY_TYPE_UNDECLARED` — the only case on a deployment that
|
|
133
|
+
* has wired nothing.
|
|
134
|
+
*/
|
|
135
|
+
const introducedInvalidProps = (before, after, checkProps) => {
|
|
136
|
+
const produced = invalidPropsIn(after, checkProps);
|
|
137
|
+
if (produced.length === 0)
|
|
138
|
+
return produced;
|
|
139
|
+
const inherited = new Set(invalidPropsIn(before, checkProps).map((invalid) => invalid.nodeId));
|
|
140
|
+
return produced.filter((invalid) => !inherited.has(invalid.nodeId));
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* Walks the delta forward so each operation is measured against the tree it
|
|
144
|
+
* actually observes — an operation may target a node an earlier operation in
|
|
145
|
+
* the same delta inserted.
|
|
146
|
+
*
|
|
147
|
+
* The three vocabularies are separate trailing parameters rather than one
|
|
148
|
+
* record, which is not the shape `StakeInput` argues for. This function is
|
|
149
|
+
* published and a lesson calls it by hand, so collecting them would be a
|
|
150
|
+
* breaking change to teach nothing, and a third one arriving is the second time
|
|
151
|
+
* that has been true; what keeps them from being forgotten is that
|
|
152
|
+
* `assessChange` is the only caller that assembles them, and it passes all
|
|
153
|
+
* three in one expression.
|
|
154
|
+
*/
|
|
155
|
+
export const analyzeDelta = (tree, delta, isInteractive = NOTHING_INTERACTIVE, isRegistered = EVERY_TYPE_REGISTERED, checkProps = EVERY_TYPE_UNDECLARED) => {
|
|
156
|
+
const tally = emptyTally();
|
|
157
|
+
let state = tree.root;
|
|
158
|
+
for (const operation of delta.operations) {
|
|
159
|
+
const tallied = tallyOperation(tally, state, operation, isRegistered);
|
|
160
|
+
if (!tallied.ok)
|
|
161
|
+
return tallied;
|
|
162
|
+
const advanced = applyOperation(state, operation);
|
|
163
|
+
if (!advanced.ok)
|
|
164
|
+
return advanced;
|
|
165
|
+
state = advanced.value;
|
|
166
|
+
}
|
|
167
|
+
return ok({
|
|
168
|
+
operationCount: delta.operations.length,
|
|
169
|
+
insertedNodeCount: tally.inserted,
|
|
170
|
+
removedNodeCount: tally.removed,
|
|
171
|
+
movedNodeCount: tally.moved,
|
|
172
|
+
configuredNodeCount: tally.configured,
|
|
173
|
+
relocatedNodeCount: tally.relocated,
|
|
174
|
+
affectedNodeIds: Array.from(tally.affected),
|
|
175
|
+
touchedPrimitiveTypes: Array.from(tally.types),
|
|
176
|
+
removedPrimitiveTypes: Array.from(tally.removedTypes),
|
|
177
|
+
relocatedPrimitiveTypes: Array.from(tally.relocatedTypes),
|
|
178
|
+
configuredPropKeys: Array.from(tally.propKeys),
|
|
179
|
+
nestedTargets: introducedNestedTargets(tree.root, state, isInteractive),
|
|
180
|
+
unknownPrimitives: tally.unknown,
|
|
181
|
+
invalidProps: introducedInvalidProps(tree.root, state, checkProps),
|
|
182
|
+
redirectedSubmissions: redirectedSubmissionsBetween(tree.root, state),
|
|
183
|
+
repointedBindings: repointedBindingsBetween(tree.root, state),
|
|
184
|
+
shallowestAffectedDepth: Number.isFinite(tally.shallowest) ? tally.shallowest : 0,
|
|
185
|
+
});
|
|
186
|
+
};
|
|
187
|
+
//# sourceMappingURL=analysis.js.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { DeltaId } from "../ids.js";
|
|
2
|
+
import { type Result } from "../result.js";
|
|
3
|
+
import type { TreeError } from "../tree/errors.js";
|
|
4
|
+
import type { LoomTree } from "../tree/tree.js";
|
|
5
|
+
import { type ChangeAnalysis } from "./analysis.js";
|
|
6
|
+
import type { GatePolicy } from "./policy.js";
|
|
7
|
+
import type { ProposedChange } from "./proposal.js";
|
|
8
|
+
import { type Reversibility } from "./reversibility.js";
|
|
9
|
+
import { type StakeAssessment } from "./stakes.js";
|
|
10
|
+
import { type PropsVocabulary } from "./vocabulary.js";
|
|
11
|
+
/**
|
|
12
|
+
* Everything the Gate is allowed to look at, gathered in one pass. Assembling
|
|
13
|
+
* this is the last step that touches the tree; the Gate itself sees only this
|
|
14
|
+
* record and the policy, which is what keeps it a pure function of its inputs.
|
|
15
|
+
*
|
|
16
|
+
* A failure here means the delta does not apply at all — a malformed proposal
|
|
17
|
+
* rather than a rejected one. That distinction matters downstream: an
|
|
18
|
+
* inapplicable proposal is an interpreter bug, not a policy decision.
|
|
19
|
+
*
|
|
20
|
+
* This is also where a proposal's own declaration about what it writes over is
|
|
21
|
+
* folded into the damage estimate (0035), so the Gate keeps seeing two axes and
|
|
22
|
+
* a policy rather than growing a third input. The policy's vocabulary — which
|
|
23
|
+
* primitives are targets, and which exist at all — reaches the analysis the
|
|
24
|
+
* same way and for the same reason (0064, 0173): the facts need a host's
|
|
25
|
+
* primitives to state, and one seam should hold everything the Gate's inputs
|
|
26
|
+
* are assembled from.
|
|
27
|
+
*/
|
|
28
|
+
export type ChangeAssessment = {
|
|
29
|
+
readonly proposal: ProposedChange;
|
|
30
|
+
readonly analysis: ChangeAnalysis;
|
|
31
|
+
readonly stakes: StakeAssessment;
|
|
32
|
+
readonly reversibility: Reversibility;
|
|
33
|
+
};
|
|
34
|
+
export declare const assessChange: (tree: LoomTree, proposal: ProposedChange, policy: GatePolicy, inverseDeltaId: DeltaId, checkProps?: PropsVocabulary) => Result<ChangeAssessment, TreeError>;
|
|
35
|
+
//# sourceMappingURL=assessment.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { flatMapResult, mapResult } from "../result.js";
|
|
2
|
+
import { analyzeDelta } from "./analysis.js";
|
|
3
|
+
import { interactivePredicateFor } from "./nesting.js";
|
|
4
|
+
import { assessReversibility } from "./reversibility.js";
|
|
5
|
+
import { assessStakes } from "./stakes.js";
|
|
6
|
+
import { EVERY_TYPE_UNDECLARED, primitiveVocabularyFor } from "./vocabulary.js";
|
|
7
|
+
export const assessChange = (tree, proposal, policy, inverseDeltaId, checkProps = EVERY_TYPE_UNDECLARED) => flatMapResult(analyzeDelta(tree, proposal.delta, interactivePredicateFor(policy.interactiveTypes), primitiveVocabularyFor(policy.registeredPrimitiveTypes), checkProps), (analysis) => mapResult(assessReversibility(tree, proposal.delta, analysis, policy, inverseDeltaId), (reversibility) => ({
|
|
8
|
+
proposal,
|
|
9
|
+
analysis,
|
|
10
|
+
stakes: assessStakes({ analysis, discards: proposal.discards ?? [] }, policy),
|
|
11
|
+
reversibility,
|
|
12
|
+
})));
|
|
13
|
+
//# sourceMappingURL=assessment.js.map
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { type StakeLevel } from "./stake-level.js";
|
|
3
|
+
/**
|
|
4
|
+
* What the Gate decided, and why. The rationale is structured rather than
|
|
5
|
+
* prose so that a host can render it, a test can assert on it, and telemetry
|
|
6
|
+
* can aggregate it — the same decision has to serve all three.
|
|
7
|
+
*/
|
|
8
|
+
export declare const dispositionKindSchema: z.ZodEnum<["accepted", "requires-confirmation", "rejected"]>;
|
|
9
|
+
export type DispositionKind = z.infer<typeof dispositionKindSchema>;
|
|
10
|
+
export declare const dispositionReasonCodeSchema: z.ZodEnum<["confidence-below-floor", "stakes-at-refusal-floor", "irreversible", "discards-later-work", "redirected-submission", "repointed-binding", "stakes-above-ceiling", "confidence-below-minimum", "within-policy"]>;
|
|
11
|
+
export type DispositionReasonCode = z.infer<typeof dispositionReasonCodeSchema>;
|
|
12
|
+
export declare const dispositionReasonSchema: z.ZodObject<{
|
|
13
|
+
code: z.ZodEnum<["confidence-below-floor", "stakes-at-refusal-floor", "irreversible", "discards-later-work", "redirected-submission", "repointed-binding", "stakes-above-ceiling", "confidence-below-minimum", "within-policy"]>;
|
|
14
|
+
detail: z.ZodString;
|
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
code: "discards-later-work" | "redirected-submission" | "repointed-binding" | "confidence-below-floor" | "stakes-at-refusal-floor" | "irreversible" | "stakes-above-ceiling" | "confidence-below-minimum" | "within-policy";
|
|
17
|
+
detail: string;
|
|
18
|
+
}, {
|
|
19
|
+
code: "discards-later-work" | "redirected-submission" | "repointed-binding" | "confidence-below-floor" | "stakes-at-refusal-floor" | "irreversible" | "stakes-above-ceiling" | "confidence-below-minimum" | "within-policy";
|
|
20
|
+
detail: string;
|
|
21
|
+
}>;
|
|
22
|
+
export type DispositionReason = {
|
|
23
|
+
readonly code: DispositionReasonCode;
|
|
24
|
+
readonly detail: string;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* What a disposition says when it was decided before the Gate recorded which
|
|
28
|
+
* policy decided it. Not the default policy's name: those judgments were made
|
|
29
|
+
* under a policy nobody wrote down, and claiming they were made under this
|
|
30
|
+
* host's current one would be a guess presented as a record.
|
|
31
|
+
*/
|
|
32
|
+
export declare const UNATTRIBUTED_POLICY_ID = "unattributed";
|
|
33
|
+
/**
|
|
34
|
+
* The schema exists because a disposition outlives the process that decided it:
|
|
35
|
+
* §6 stores one and reads it back later, and a judgment restored from storage is
|
|
36
|
+
* validated at that boundary like anything else that crossed a wire or a year.
|
|
37
|
+
*/
|
|
38
|
+
export declare const dispositionSchema: z.ZodObject<{
|
|
39
|
+
kind: z.ZodEnum<["accepted", "requires-confirmation", "rejected"]>;
|
|
40
|
+
reason: z.ZodObject<{
|
|
41
|
+
code: z.ZodEnum<["confidence-below-floor", "stakes-at-refusal-floor", "irreversible", "discards-later-work", "redirected-submission", "repointed-binding", "stakes-above-ceiling", "confidence-below-minimum", "within-policy"]>;
|
|
42
|
+
detail: z.ZodString;
|
|
43
|
+
}, "strip", z.ZodTypeAny, {
|
|
44
|
+
code: "discards-later-work" | "redirected-submission" | "repointed-binding" | "confidence-below-floor" | "stakes-at-refusal-floor" | "irreversible" | "stakes-above-ceiling" | "confidence-below-minimum" | "within-policy";
|
|
45
|
+
detail: string;
|
|
46
|
+
}, {
|
|
47
|
+
code: "discards-later-work" | "redirected-submission" | "repointed-binding" | "confidence-below-floor" | "stakes-at-refusal-floor" | "irreversible" | "stakes-above-ceiling" | "confidence-below-minimum" | "within-policy";
|
|
48
|
+
detail: string;
|
|
49
|
+
}>;
|
|
50
|
+
stakes: z.ZodEnum<["low", "medium", "high", "critical"]>;
|
|
51
|
+
reversible: z.ZodBoolean;
|
|
52
|
+
confidence: z.ZodNumber;
|
|
53
|
+
/**
|
|
54
|
+
* Which policy judged this. Required on the type so every construction site
|
|
55
|
+
* has to say; defaulted on the schema so a record written before the field
|
|
56
|
+
* existed still parses, and reads as the unknown it is.
|
|
57
|
+
*/
|
|
58
|
+
policyId: z.ZodDefault<z.ZodString>;
|
|
59
|
+
/**
|
|
60
|
+
* What that policy *contained* when it judged this, beside what it was called.
|
|
61
|
+
*
|
|
62
|
+
* Optional and never defaulted, unlike `policyId`. A name has an honest
|
|
63
|
+
* stand-in for the unknown — `unattributed` says "nobody wrote this down" — and
|
|
64
|
+
* a digest has none: any string here is a claim about the contents of a
|
|
65
|
+
* policy, and inventing one would be inventing the very fact the field exists
|
|
66
|
+
* to check.
|
|
67
|
+
*/
|
|
68
|
+
policyFingerprint: z.ZodOptional<z.ZodString>;
|
|
69
|
+
}, "strip", z.ZodTypeAny, {
|
|
70
|
+
kind: "rejected" | "accepted" | "requires-confirmation";
|
|
71
|
+
confidence: number;
|
|
72
|
+
policyId: string;
|
|
73
|
+
reason: {
|
|
74
|
+
code: "discards-later-work" | "redirected-submission" | "repointed-binding" | "confidence-below-floor" | "stakes-at-refusal-floor" | "irreversible" | "stakes-above-ceiling" | "confidence-below-minimum" | "within-policy";
|
|
75
|
+
detail: string;
|
|
76
|
+
};
|
|
77
|
+
stakes: "low" | "medium" | "high" | "critical";
|
|
78
|
+
reversible: boolean;
|
|
79
|
+
policyFingerprint?: string | undefined;
|
|
80
|
+
}, {
|
|
81
|
+
kind: "rejected" | "accepted" | "requires-confirmation";
|
|
82
|
+
confidence: number;
|
|
83
|
+
reason: {
|
|
84
|
+
code: "discards-later-work" | "redirected-submission" | "repointed-binding" | "confidence-below-floor" | "stakes-at-refusal-floor" | "irreversible" | "stakes-above-ceiling" | "confidence-below-minimum" | "within-policy";
|
|
85
|
+
detail: string;
|
|
86
|
+
};
|
|
87
|
+
stakes: "low" | "medium" | "high" | "critical";
|
|
88
|
+
reversible: boolean;
|
|
89
|
+
policyId?: string | undefined;
|
|
90
|
+
policyFingerprint?: string | undefined;
|
|
91
|
+
}>;
|
|
92
|
+
export type Disposition = {
|
|
93
|
+
readonly kind: DispositionKind;
|
|
94
|
+
readonly reason: DispositionReason;
|
|
95
|
+
readonly stakes: StakeLevel;
|
|
96
|
+
readonly reversible: boolean;
|
|
97
|
+
readonly confidence: number;
|
|
98
|
+
readonly policyId: string;
|
|
99
|
+
/** Absent on a judgment recorded before the Gate fingerprinted policies. */
|
|
100
|
+
readonly policyFingerprint?: string;
|
|
101
|
+
};
|
|
102
|
+
//# sourceMappingURL=disposition.d.ts.map
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { stakeLevelSchema } from "./stake-level.js";
|
|
3
|
+
/**
|
|
4
|
+
* What the Gate decided, and why. The rationale is structured rather than
|
|
5
|
+
* prose so that a host can render it, a test can assert on it, and telemetry
|
|
6
|
+
* can aggregate it — the same decision has to serve all three.
|
|
7
|
+
*/
|
|
8
|
+
export const dispositionKindSchema = z.enum(["accepted", "requires-confirmation", "rejected"]);
|
|
9
|
+
export const dispositionReasonCodeSchema = z.enum([
|
|
10
|
+
"confidence-below-floor",
|
|
11
|
+
"stakes-at-refusal-floor",
|
|
12
|
+
"irreversible",
|
|
13
|
+
"discards-later-work",
|
|
14
|
+
"redirected-submission",
|
|
15
|
+
"repointed-binding",
|
|
16
|
+
"stakes-above-ceiling",
|
|
17
|
+
"confidence-below-minimum",
|
|
18
|
+
"within-policy",
|
|
19
|
+
]);
|
|
20
|
+
export const dispositionReasonSchema = z.object({
|
|
21
|
+
code: dispositionReasonCodeSchema,
|
|
22
|
+
detail: z.string().min(1),
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* What a disposition says when it was decided before the Gate recorded which
|
|
26
|
+
* policy decided it. Not the default policy's name: those judgments were made
|
|
27
|
+
* under a policy nobody wrote down, and claiming they were made under this
|
|
28
|
+
* host's current one would be a guess presented as a record.
|
|
29
|
+
*/
|
|
30
|
+
export const UNATTRIBUTED_POLICY_ID = "unattributed";
|
|
31
|
+
/**
|
|
32
|
+
* The schema exists because a disposition outlives the process that decided it:
|
|
33
|
+
* §6 stores one and reads it back later, and a judgment restored from storage is
|
|
34
|
+
* validated at that boundary like anything else that crossed a wire or a year.
|
|
35
|
+
*/
|
|
36
|
+
export const dispositionSchema = z.object({
|
|
37
|
+
kind: dispositionKindSchema,
|
|
38
|
+
reason: dispositionReasonSchema,
|
|
39
|
+
stakes: stakeLevelSchema,
|
|
40
|
+
reversible: z.boolean(),
|
|
41
|
+
confidence: z.number().min(0).max(1),
|
|
42
|
+
/**
|
|
43
|
+
* Which policy judged this. Required on the type so every construction site
|
|
44
|
+
* has to say; defaulted on the schema so a record written before the field
|
|
45
|
+
* existed still parses, and reads as the unknown it is.
|
|
46
|
+
*/
|
|
47
|
+
policyId: z.string().min(1).default(UNATTRIBUTED_POLICY_ID),
|
|
48
|
+
/**
|
|
49
|
+
* What that policy *contained* when it judged this, beside what it was called.
|
|
50
|
+
*
|
|
51
|
+
* Optional and never defaulted, unlike `policyId`. A name has an honest
|
|
52
|
+
* stand-in for the unknown — `unattributed` says "nobody wrote this down" — and
|
|
53
|
+
* a digest has none: any string here is a claim about the contents of a
|
|
54
|
+
* policy, and inventing one would be inventing the very fact the field exists
|
|
55
|
+
* to check.
|
|
56
|
+
*/
|
|
57
|
+
policyFingerprint: z.string().min(1).optional(),
|
|
58
|
+
});
|
|
59
|
+
//# sourceMappingURL=disposition.js.map
|