@jam-overture/loom 0.1.0 → 0.2.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/README.md +3 -1
- package/dist/application/application.d.ts +109 -0
- package/dist/application/application.js +97 -0
- package/dist/application/memory.d.ts +20 -0
- package/dist/application/memory.js +79 -0
- package/dist/application/store.d.ts +101 -0
- package/dist/application/store.js +25 -0
- package/dist/audience/audience.d.ts +36 -0
- package/dist/audience/audience.js +41 -0
- package/dist/cli/templates.js +19 -0
- package/dist/data/plan.js +0 -0
- package/dist/data/resolution.d.ts +23 -1
- package/dist/data/resolve.d.ts +30 -3
- package/dist/data/resolve.js +11 -3
- package/dist/ids.d.ts +10 -0
- package/dist/ids.js +11 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/patch.d.ts +54 -0
- package/dist/patch.js +44 -0
- package/dist/project/closing.d.ts +51 -0
- package/dist/project/closing.js +53 -0
- package/dist/project/memory.d.ts +20 -0
- package/dist/project/memory.js +97 -0
- package/dist/project/project.d.ts +90 -0
- package/dist/project/project.js +91 -0
- package/dist/project/store.d.ts +135 -0
- package/dist/project/store.js +41 -0
- package/dist/registered.d.ts +64 -0
- package/dist/registered.js +118 -0
- package/dist/render/behaviour-adjust.d.ts +11 -19
- package/dist/render/behaviour-adjust.js +75 -21
- package/dist/render/behaviour-present.d.ts +8 -0
- package/dist/render/behaviour-present.js +57 -6
- package/dist/render/behaviour.d.ts +98 -17
- package/dist/render/behaviour.js +91 -26
- package/dist/render/control-name.d.ts +68 -0
- package/dist/render/control-name.js +37 -0
- package/dist/render/diagnostics.d.ts +72 -0
- package/dist/render/diagnostics.js +7 -0
- package/dist/render/index.d.ts +2 -0
- package/dist/render/index.js +2 -0
- package/dist/render/reads.d.ts +11 -0
- package/dist/render/reads.js +12 -1
- package/dist/render/render.js +102 -7
- package/dist/render/slots.d.ts +52 -0
- package/dist/render/slots.js +24 -0
- package/dist/render/theme.d.ts +54 -1
- package/dist/render/theme.js +23 -1
- package/dist/render/unshown.d.ts +152 -0
- package/dist/render/unshown.js +80 -0
- package/dist/runtime/analysis.d.ts +94 -9
- package/dist/runtime/analysis.js +54 -9
- package/dist/runtime/assessment.d.ts +36 -2
- package/dist/runtime/assessment.js +27 -2
- package/dist/runtime/checks.d.ts +148 -0
- package/dist/runtime/checks.js +112 -0
- package/dist/runtime/disposition.d.ts +96 -0
- package/dist/runtime/disposition.js +46 -0
- package/dist/runtime/gate.js +22 -0
- package/dist/runtime/index.d.ts +3 -0
- package/dist/runtime/index.js +3 -0
- package/dist/runtime/irreversibility.d.ts +64 -0
- package/dist/runtime/irreversibility.js +45 -0
- package/dist/runtime/pipeline.d.ts +43 -0
- package/dist/runtime/pipeline.js +10 -2
- package/dist/runtime/policy-change.d.ts +93 -0
- package/dist/runtime/policy-change.js +299 -0
- package/dist/runtime/policy-log.d.ts +406 -0
- package/dist/runtime/policy-log.js +285 -0
- package/dist/runtime/reversibility.d.ts +11 -9
- package/dist/runtime/stakes.d.ts +129 -1
- package/dist/runtime/stakes.js +240 -26
- package/dist/runtime/vocabulary.d.ts +164 -7
- package/dist/runtime/vocabulary.js +181 -8
- package/dist/sdk/audit.d.ts +174 -3
- package/dist/sdk/audit.js +176 -17
- package/dist/sdk/catalogue.d.ts +9 -1
- package/dist/sdk/conformance.d.ts +37 -3
- package/dist/sdk/conformance.js +25 -4
- package/dist/sdk/definition.d.ts +65 -0
- package/dist/sdk/definition.js +22 -0
- package/dist/sdk/registry.d.ts +29 -2
- package/dist/sdk/registry.js +63 -1
- package/dist/signals/action-change.d.ts +507 -0
- package/dist/signals/action-change.js +265 -0
- package/dist/signals/action.d.ts +331 -0
- package/dist/signals/action.js +182 -0
- package/dist/signals/applied-window.contract.d.ts +23 -0
- package/dist/signals/applied-window.contract.js +160 -0
- package/dist/signals/arriving.d.ts +210 -0
- package/dist/signals/arriving.js +133 -0
- package/dist/signals/audiences.d.ts +528 -0
- package/dist/signals/audiences.js +255 -0
- package/dist/signals/broadcast.d.ts +8 -2
- package/dist/signals/broadcast.js +58 -8
- package/dist/signals/change.d.ts +378 -0
- package/dist/signals/change.js +327 -0
- package/dist/signals/collect.d.ts +41 -0
- package/dist/signals/collect.js +88 -7
- package/dist/signals/copy-change.d.ts +553 -0
- package/dist/signals/copy-change.js +377 -0
- package/dist/signals/copy.d.ts +337 -0
- package/dist/signals/copy.js +211 -0
- package/dist/signals/counters.d.ts +46 -0
- package/dist/signals/counters.js +102 -0
- package/dist/signals/deliver.d.ts +23 -4
- package/dist/signals/deliver.js +34 -6
- package/dist/signals/deployment-change.d.ts +371 -0
- package/dist/signals/deployment-change.js +268 -0
- package/dist/signals/deployment.d.ts +265 -0
- package/dist/signals/deployment.js +152 -0
- package/dist/signals/door.d.ts +92 -0
- package/dist/signals/door.js +53 -0
- package/dist/signals/fold.d.ts +10 -0
- package/dist/signals/fold.js +5 -1
- package/dist/signals/form-action.d.ts +302 -0
- package/dist/signals/form-action.js +169 -0
- package/dist/signals/form-copy.d.ts +523 -0
- package/dist/signals/form-copy.js +346 -0
- package/dist/signals/forms.d.ts +247 -0
- package/dist/signals/forms.js +147 -0
- package/dist/signals/funnel-change.d.ts +548 -0
- package/dist/signals/funnel-change.js +361 -0
- package/dist/signals/funnel.d.ts +532 -0
- package/dist/signals/funnel.js +216 -0
- package/dist/signals/health.d.ts +497 -0
- package/dist/signals/health.js +361 -0
- package/dist/signals/index.d.ts +41 -0
- package/dist/signals/index.js +41 -0
- package/dist/signals/ingest.d.ts +56 -1
- package/dist/signals/ingest.js +91 -1
- package/dist/signals/journal.d.ts +11 -0
- package/dist/signals/kinds.d.ts +8 -6
- package/dist/signals/kinds.js +14 -6
- package/dist/signals/library-action.d.ts +430 -0
- package/dist/signals/library-action.js +336 -0
- package/dist/signals/library-change.d.ts +477 -0
- package/dist/signals/library-change.js +335 -0
- package/dist/signals/library-copy-change.d.ts +498 -0
- package/dist/signals/library-copy-change.js +476 -0
- package/dist/signals/library-pace.d.ts +319 -0
- package/dist/signals/library-pace.js +305 -0
- package/dist/signals/library-reach-change.d.ts +636 -0
- package/dist/signals/library-reach-change.js +534 -0
- package/dist/signals/library-reach.d.ts +377 -0
- package/dist/signals/library-reach.js +227 -0
- package/dist/signals/library-word-reach-change.d.ts +567 -0
- package/dist/signals/library-word-reach-change.js +568 -0
- package/dist/signals/library.d.ts +306 -0
- package/dist/signals/library.js +178 -0
- package/dist/signals/memory.d.ts +9 -0
- package/dist/signals/memory.js +105 -14
- package/dist/signals/migrate.d.ts +17 -2
- package/dist/signals/migrate.js +122 -5
- package/dist/signals/notice.d.ts +334 -0
- package/dist/signals/notice.js +228 -0
- package/dist/signals/pace-change.d.ts +501 -0
- package/dist/signals/pace-change.js +310 -0
- package/dist/signals/pace.d.ts +296 -0
- package/dist/signals/pace.js +291 -0
- package/dist/signals/page-views.d.ts +365 -0
- package/dist/signals/page-views.js +218 -0
- package/dist/signals/parts.d.ts +344 -0
- package/dist/signals/parts.js +273 -0
- package/dist/signals/postgres.d.ts +16 -2
- package/dist/signals/postgres.js +390 -87
- package/dist/signals/progress.d.ts +212 -0
- package/dist/signals/progress.js +150 -0
- package/dist/signals/ratios.d.ts +108 -0
- package/dist/signals/ratios.js +40 -0
- package/dist/signals/reach.d.ts +309 -0
- package/dist/signals/reach.js +93 -0
- package/dist/signals/readable.d.ts +34 -0
- package/dist/signals/readable.js +34 -0
- package/dist/signals/readership.d.ts +381 -0
- package/dist/signals/readership.js +308 -0
- package/dist/signals/region-pages.d.ts +173 -0
- package/dist/signals/region-pages.js +62 -0
- package/dist/signals/region.d.ts +287 -0
- package/dist/signals/region.js +198 -0
- package/dist/signals/retention.d.ts +141 -0
- package/dist/signals/retention.js +58 -0
- package/dist/signals/rollup.d.ts +67 -3
- package/dist/signals/rollup.js +0 -0
- package/dist/signals/schema.d.ts +432 -1
- package/dist/signals/schema.js +157 -3
- package/dist/signals/signal.d.ts +237 -11
- package/dist/signals/signal.js +70 -10
- package/dist/signals/silence-census.d.ts +205 -0
- package/dist/signals/silence-census.js +87 -0
- package/dist/signals/silences.d.ts +848 -0
- package/dist/signals/silences.js +753 -0
- package/dist/signals/tally.d.ts +140 -11
- package/dist/signals/window-figures.d.ts +148 -0
- package/dist/signals/window-figures.js +42 -0
- package/dist/signals/window.d.ts +866 -0
- package/dist/signals/window.js +693 -0
- package/dist/signals/words.d.ts +24 -0
- package/dist/signals/words.js +24 -0
- package/dist/store/index.d.ts +19 -0
- package/dist/store/index.js +19 -0
- package/dist/store/memory.d.ts +2 -1
- package/dist/store/memory.js +48 -12
- package/dist/store/migrate.d.ts +80 -0
- package/dist/store/migrate.js +259 -7
- package/dist/store/postgres-applications.d.ts +4 -0
- package/dist/store/postgres-applications.js +197 -0
- package/dist/store/postgres-holds.d.ts +10 -1
- package/dist/store/postgres-holds.js +116 -101
- package/dist/store/postgres-policy-log.d.ts +14 -0
- package/dist/store/postgres-policy-log.js +240 -0
- package/dist/store/postgres-projects.d.ts +4 -0
- package/dist/store/postgres-projects.js +217 -0
- package/dist/store/postgres.d.ts +16 -1
- package/dist/store/postgres.js +59 -9
- package/dist/store/replay.d.ts +102 -1
- package/dist/store/replay.js +190 -19
- package/dist/store/reseed.d.ts +238 -0
- package/dist/store/reseed.js +308 -0
- package/dist/store/schema.d.ts +450 -2
- package/dist/store/schema.js +141 -5
- package/dist/store/store.d.ts +29 -6
- package/dist/submit/resolve.js +2 -1
- package/dist/telemetry/calibration.d.ts +25 -0
- package/dist/telemetry/calibration.js +27 -1
- package/dist/telemetry/event.d.ts +391 -33
- package/dist/telemetry/event.js +84 -20
- package/dist/telemetry/index.d.ts +1 -0
- package/dist/telemetry/index.js +1 -0
- package/dist/telemetry/journal.d.ts +72 -3
- package/dist/telemetry/journal.js +9 -0
- package/dist/telemetry/lookup.d.ts +27 -0
- package/dist/telemetry/lookup.js +18 -0
- package/dist/telemetry/memory.js +23 -0
- package/dist/telemetry/migrate.js +22 -1
- package/dist/telemetry/postgres.d.ts +10 -1
- package/dist/telemetry/postgres.js +172 -90
- package/dist/telemetry/remeasure.d.ts +78 -0
- package/dist/telemetry/remeasure.js +83 -0
- package/dist/telemetry/retention.d.ts +2 -2
- package/dist/telemetry/schema.d.ts +17 -0
- package/dist/telemetry/schema.js +27 -1
- package/dist/telemetry/sink.d.ts +2 -2
- package/dist/testing/application-contract.d.ts +14 -0
- package/dist/testing/application-contract.js +270 -0
- package/dist/testing/contracts.d.ts +12 -7
- package/dist/testing/contracts.js +12 -7
- package/dist/testing/definitions.d.ts +78 -0
- package/dist/testing/definitions.js +134 -9
- package/dist/testing/doubles.d.ts +103 -0
- package/dist/testing/doubles.js +143 -0
- package/dist/testing/index.d.ts +2 -2
- package/dist/testing/index.js +2 -2
- package/dist/testing/journal-contract.js +140 -2
- package/dist/testing/model-contract.d.ts +110 -0
- package/dist/testing/model-contract.js +150 -0
- package/dist/testing/policy-log-contract.d.ts +26 -0
- package/dist/testing/policy-log-contract.js +344 -0
- package/dist/testing/project-contract.d.ts +14 -0
- package/dist/testing/project-contract.js +266 -0
- package/dist/testing/reader-signal-contract.d.ts +27 -2
- package/dist/testing/reader-signal-contract.js +475 -5
- package/dist/testing/store-contract.d.ts +7 -1
- package/dist/testing/store-contract.js +84 -3
- package/dist/theme/apply.d.ts +20 -1
- package/dist/theme/apply.js +5 -3
- package/dist/theme/derive.d.ts +22 -0
- package/dist/theme/derive.js +54 -1
- package/dist/theme/library.js +1 -1
- package/dist/theme/measure.d.ts +34 -0
- package/dist/theme/measure.js +30 -1
- package/dist/theme/palettes.js +7 -7
- package/dist/theme/ramp.d.ts +64 -0
- package/dist/theme/ramp.js +114 -0
- package/dist/theme/registry.d.ts +9 -0
- package/dist/theme/registry.js +11 -1
- package/dist/theme/separation.d.ts +97 -3
- package/dist/theme/separation.js +75 -0
- package/dist/tree/compare.d.ts +9 -0
- package/dist/tree/compare.js +18 -0
- package/dist/write/computed.d.ts +60 -0
- package/dist/write/computed.js +61 -0
- package/dist/write/held.d.ts +59 -0
- package/dist/write/index.d.ts +5 -2
- package/dist/write/index.js +5 -2
- package/dist/write/reseed.d.ts +151 -0
- package/dist/write/reseed.js +184 -0
- package/dist/write/revert.js +2 -16
- package/package.json +98 -19
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { DeltaId } from "../ids.js";
|
|
2
|
-
import type { PrimitiveType } from "../primitive-type.js";
|
|
3
2
|
import { type Result } from "../result.js";
|
|
4
3
|
import type { TreeDelta } from "../tree/delta.js";
|
|
5
4
|
import type { TreeError } from "../tree/errors.js";
|
|
6
5
|
import type { LoomTree } from "../tree/tree.js";
|
|
7
6
|
import type { ChangeAnalysis } from "./analysis.js";
|
|
7
|
+
import type { IrreversibilityReason } from "./irreversibility.js";
|
|
8
8
|
import type { GatePolicy } from "./policy.js";
|
|
9
9
|
/**
|
|
10
10
|
* Reversibility is computed, not guessed: the inverse delta is produced up
|
|
@@ -16,14 +16,16 @@ import type { GatePolicy } from "./policy.js";
|
|
|
16
16
|
* configuration reaches a payment flow or a sent message — or that the inverse
|
|
17
17
|
* would have to retain more content than the runtime is willing to hold.
|
|
18
18
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
/**
|
|
20
|
+
* The reason's shape is published from here, where it always was. Its schema and
|
|
21
|
+
* the narrowing helper beside it are not: both exist so that `disposition.ts`
|
|
22
|
+
* can validate a stored judgment and `telemetry/event.ts` can journal the types
|
|
23
|
+
* one reason blames, and neither is something a host composing a runtime has to
|
|
24
|
+
* reach for. A published door has to be documented on a page a reader can find,
|
|
25
|
+
* which is the right bar for a name a host needs and the wrong one for an
|
|
26
|
+
* internal seam between two modules of this package.
|
|
27
|
+
*/
|
|
28
|
+
export type { IrreversibilityReason } from "./irreversibility.js";
|
|
27
29
|
export type Reversibility = {
|
|
28
30
|
readonly reversible: boolean;
|
|
29
31
|
/** The tree-level undo. Present even when `reversible` is false. */
|
package/dist/runtime/stakes.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { PrimitiveType } from "../primitive-type.js";
|
|
1
3
|
import type { ChangeAnalysis } from "./analysis.js";
|
|
2
4
|
import type { GatePolicy } from "./policy.js";
|
|
3
5
|
import type { DiscardedWork } from "./proposal.js";
|
|
@@ -18,7 +20,34 @@ import { type StakeLevel } from "./stake-level.js";
|
|
|
18
20
|
* exception, `discards-later-work`, is a fact about the log the delta was
|
|
19
21
|
* computed from, which no amount of looking at the delta can recover (0035).
|
|
20
22
|
*/
|
|
21
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Which rule a factor is, as a closed vocabulary rather than a bare union.
|
|
25
|
+
*
|
|
26
|
+
* A schema because the codes leave the process. A telemetry record carries them
|
|
27
|
+
* so that a corpus can group refusals by the rule that caused one, and anything
|
|
28
|
+
* crossing that boundary has to be parsed on the way back in. This is the same
|
|
29
|
+
* bargain `stakeLevelSchema` and `dispositionReasonSchema` already make, and it
|
|
30
|
+
* is deliberately *not* the bargain `telemetryFailureSchema.code` makes: an
|
|
31
|
+
* error taxonomy is open because adding a code elsewhere in the codebase must
|
|
32
|
+
* not invalidate yesterday's records, whereas this list is the Gate's own
|
|
33
|
+
* vocabulary and a record naming a rule this version has never heard of is a
|
|
34
|
+
* record it genuinely cannot interpret.
|
|
35
|
+
*
|
|
36
|
+
* The order is the order `FACTORS` evaluates in, which is severity-ish and not
|
|
37
|
+
* arithmetic: nothing reads an index here, unlike `STAKE_ORDER` (0166).
|
|
38
|
+
*/
|
|
39
|
+
export declare const stakeFactorCodeSchema: z.ZodEnum<["protected-type-removed", "protected-type-touched", "protected-type-relocated", "protected-prop-configured", "large-removal", "broad-change", "shallow-structural-change", "discards-later-work", "nested-target", "unknown-primitive", "invalid-props", "unread-binding", "unplaced-slot", "redirected-submission", "repointed-binding"]>;
|
|
40
|
+
export type StakeFactorCode = z.infer<typeof stakeFactorCodeSchema>;
|
|
41
|
+
/**
|
|
42
|
+
* Every rule the Gate can raise, walkable.
|
|
43
|
+
*
|
|
44
|
+
* Derived rather than declared: the members come from a schema, so a second
|
|
45
|
+
* hand-written list would be the copy `closed-set.ts` exists to avoid. Two
|
|
46
|
+
* surfaces hold a plain-language table keyed by this union and both reached for
|
|
47
|
+
* `Object.keys(...) as StakeFactorCode[]` to walk it, which is a cast standing
|
|
48
|
+
* in for a list.
|
|
49
|
+
*/
|
|
50
|
+
export declare const STAKE_FACTOR_CODES: readonly StakeFactorCode[];
|
|
22
51
|
export type StakeFactor = {
|
|
23
52
|
readonly code: StakeFactorCode;
|
|
24
53
|
readonly level: StakeLevel;
|
|
@@ -41,7 +70,106 @@ export type StakeInput = {
|
|
|
41
70
|
/** Empty when the proposal declared nothing, which is not the same as nothing. */
|
|
42
71
|
readonly discards: readonly DiscardedWork[];
|
|
43
72
|
};
|
|
73
|
+
/**
|
|
74
|
+
* The rules whose level is fixed at the code, and the level each one is fixed
|
|
75
|
+
* at.
|
|
76
|
+
*
|
|
77
|
+
* Every rule in this file is one of two kinds, and the difference is which
|
|
78
|
+
* question it answers. Seven of them ask *how much of this deployment's page
|
|
79
|
+
* does this touch* — how many nodes went, how broad it was, how shallow, which
|
|
80
|
+
* of the types this host declared it cares about — so moving a field of the
|
|
81
|
+
* policy moves the answer. The other eight ask *is this change coherent at all*:
|
|
82
|
+
* a target nobody can reach, a type nothing is registered for, props the
|
|
83
|
+
* declaring primitive refuses, a question nothing reads, content put in a region
|
|
84
|
+
* nothing places, a form or a region pointed somewhere else, work written over.
|
|
85
|
+
* None of those consults a policy field. A host turns them off by declaring no
|
|
86
|
+
* vocabulary (0002) and cannot tune them, so their level is a property of the
|
|
87
|
+
* rule itself.
|
|
88
|
+
*
|
|
89
|
+
* Declared here rather than written into each factor because the level now has
|
|
90
|
+
* two readers. The Gate computes it while it holds the delta, and
|
|
91
|
+
* `remeasureStakes` has to state it months later holding only a record — and the
|
|
92
|
+
* second reader exists *because* these seven cannot be re-measured from a
|
|
93
|
+
* record: a code says a rule fired and the list of nodes it fired about does not
|
|
94
|
+
* cross the boundary (0023). What crosses is the code, and this is what turns a
|
|
95
|
+
* code back into a level without a second copy of these numbers in whatever
|
|
96
|
+
* reads the journal.
|
|
97
|
+
*/
|
|
98
|
+
declare const FIXED_LEVELS: {
|
|
99
|
+
readonly "discards-later-work": "high";
|
|
100
|
+
readonly "nested-target": "critical";
|
|
101
|
+
readonly "unknown-primitive": "critical";
|
|
102
|
+
readonly "invalid-props": "critical";
|
|
103
|
+
readonly "unread-binding": "critical";
|
|
104
|
+
readonly "unplaced-slot": "critical";
|
|
105
|
+
readonly "redirected-submission": "high";
|
|
106
|
+
readonly "repointed-binding": "high";
|
|
107
|
+
};
|
|
108
|
+
/** A rule no policy field can move, so its code alone gives its level. */
|
|
109
|
+
export type FixedStakeFactorCode = keyof typeof FIXED_LEVELS;
|
|
110
|
+
/**
|
|
111
|
+
* A rule a policy decides, so the same change under two policies is two
|
|
112
|
+
* answers. The complement of `FixedStakeFactorCode` by construction: a factor
|
|
113
|
+
* added to the vocabulary belongs to one set or the other and nothing has to
|
|
114
|
+
* remember to put it there.
|
|
115
|
+
*/
|
|
116
|
+
export type MeasuredStakeFactorCode = Exclude<StakeFactorCode, FixedStakeFactorCode>;
|
|
117
|
+
/** The level this rule is always raised at, which is the whole of what its code means. */
|
|
118
|
+
export declare const fixedStakeLevel: (code: FixedStakeFactorCode) => StakeLevel;
|
|
119
|
+
export declare const isFixedStakeFactor: (code: StakeFactorCode) => code is FixedStakeFactorCode;
|
|
120
|
+
/**
|
|
121
|
+
* The two halves of the vocabulary, walkable, in the order the Gate raises them.
|
|
122
|
+
*
|
|
123
|
+
* Filtered from `STAKE_FACTOR_CODES` rather than written out, so neither list can
|
|
124
|
+
* be the stale copy of a partition that lives in one place. A factor added to the
|
|
125
|
+
* schema joins one of them according to whether `FIXED_LEVELS` names it, and a
|
|
126
|
+
* reader walking either gets the new member without being told.
|
|
127
|
+
*/
|
|
128
|
+
export declare const FIXED_STAKE_FACTOR_CODES: readonly FixedStakeFactorCode[];
|
|
129
|
+
export declare const MEASURED_STAKE_FACTOR_CODES: readonly MeasuredStakeFactorCode[];
|
|
130
|
+
/**
|
|
131
|
+
* The facts the policy-dependent rules read, and nothing else.
|
|
132
|
+
*
|
|
133
|
+
* Narrower than `ChangeAnalysis` on purpose, and the narrowing is the contract.
|
|
134
|
+
* An analysis holds six lists of specifics — which targets are unreachable,
|
|
135
|
+
* which nodes carry refused props — that name parts of a particular page, so
|
|
136
|
+
* they belong to the moment the delta was weighed and go no further. What is
|
|
137
|
+
* here is nine numbers and four lists of type and prop names, which is exactly
|
|
138
|
+
* the part a telemetry record can carry and therefore the part a host can hold
|
|
139
|
+
* on to and measure again.
|
|
140
|
+
*
|
|
141
|
+
* So the seven rules below take this rather than the analysis, and the two
|
|
142
|
+
* producers — `stakeMeasurementOf` from a delta, `remeasureStakes` from a
|
|
143
|
+
* journalled record — put the same rules to the same numbers. A second
|
|
144
|
+
* implementation of *large removal* or *broad change* in whatever wants to
|
|
145
|
+
* re-run them would be a copy of the Gate that drifts from the Gate, which is
|
|
146
|
+
* the one failure a simulation of a policy must not have.
|
|
147
|
+
*/
|
|
148
|
+
export type StakeMeasurement = {
|
|
149
|
+
readonly insertedNodeCount: number;
|
|
150
|
+
readonly removedNodeCount: number;
|
|
151
|
+
readonly movedNodeCount: number;
|
|
152
|
+
/** `affectedNodeIds.length`. Breadth reads the count and never the ids. */
|
|
153
|
+
readonly affectedNodeCount: number;
|
|
154
|
+
readonly shallowestAffectedDepth: number;
|
|
155
|
+
readonly touchedPrimitiveTypes: readonly PrimitiveType[];
|
|
156
|
+
readonly removedPrimitiveTypes: readonly PrimitiveType[];
|
|
157
|
+
readonly relocatedPrimitiveTypes: readonly PrimitiveType[];
|
|
158
|
+
readonly configuredPropKeys: readonly string[];
|
|
159
|
+
};
|
|
160
|
+
/** The measurable half of an analysis, which is what the Gate's own path takes. */
|
|
161
|
+
export declare const stakeMeasurementOf: (analysis: ChangeAnalysis) => StakeMeasurement;
|
|
162
|
+
/**
|
|
163
|
+
* The policy-dependent half, against a measurement rather than a delta.
|
|
164
|
+
*
|
|
165
|
+
* Published because it is the half that can be run twice: once by the Gate on
|
|
166
|
+
* the change in front of it, and again by anything holding a record of that
|
|
167
|
+
* change and a policy it is considering. The other half cannot, which is why it
|
|
168
|
+
* is not here — see `fixedStakeLevel`.
|
|
169
|
+
*/
|
|
170
|
+
export declare const measureStakes: (measurement: StakeMeasurement, policy: GatePolicy) => readonly StakeFactor[];
|
|
44
171
|
export declare const assessStakes: (input: StakeInput, policy: GatePolicy) => StakeAssessment;
|
|
45
172
|
/** The factor with this code, for a caller that needs the reason and not the level. */
|
|
46
173
|
export declare const stakeFactor: (stakes: StakeAssessment, code: StakeFactorCode) => StakeFactor | undefined;
|
|
174
|
+
export {};
|
|
47
175
|
//# sourceMappingURL=stakes.d.ts.map
|
package/dist/runtime/stakes.js
CHANGED
|
@@ -1,12 +1,132 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
1
2
|
import { describeNestedTarget } from "./nesting.js";
|
|
2
3
|
import { describeRedirectedSubmission } from "./redirection.js";
|
|
3
4
|
import { describeRepointedBinding } from "./repointing.js";
|
|
4
|
-
import { describeInvalidProps, describeUnknownPrimitive } from "./vocabulary.js";
|
|
5
|
+
import { describeInvalidProps, describeUnknownPrimitive, describeUnplacedSlot, describeUnreadBinding, } from "./vocabulary.js";
|
|
5
6
|
import { highestStake } from "./stake-level.js";
|
|
7
|
+
/**
|
|
8
|
+
* Stakes assessment: facts plus policy in, a level plus its reasons out.
|
|
9
|
+
*
|
|
10
|
+
* Every factor is recorded rather than collapsed, so a disposition can explain
|
|
11
|
+
* itself. "High stakes" is not useful feedback; "this removes 14 nodes and
|
|
12
|
+
* touches commerce.checkout" is.
|
|
13
|
+
*
|
|
14
|
+
* Stakes measure damage only. Whether a change can be taken back is a separate
|
|
15
|
+
* axis assessed separately — a change can be devastating and trivially
|
|
16
|
+
* reversible, or tiny and permanent, and the Gate needs to see those two
|
|
17
|
+
* properties independently rather than pre-blended into one number.
|
|
18
|
+
*
|
|
19
|
+
* Every factor but one is a fact about the delta against the tree. The
|
|
20
|
+
* exception, `discards-later-work`, is a fact about the log the delta was
|
|
21
|
+
* computed from, which no amount of looking at the delta can recover (0035).
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Which rule a factor is, as a closed vocabulary rather than a bare union.
|
|
25
|
+
*
|
|
26
|
+
* A schema because the codes leave the process. A telemetry record carries them
|
|
27
|
+
* so that a corpus can group refusals by the rule that caused one, and anything
|
|
28
|
+
* crossing that boundary has to be parsed on the way back in. This is the same
|
|
29
|
+
* bargain `stakeLevelSchema` and `dispositionReasonSchema` already make, and it
|
|
30
|
+
* is deliberately *not* the bargain `telemetryFailureSchema.code` makes: an
|
|
31
|
+
* error taxonomy is open because adding a code elsewhere in the codebase must
|
|
32
|
+
* not invalidate yesterday's records, whereas this list is the Gate's own
|
|
33
|
+
* vocabulary and a record naming a rule this version has never heard of is a
|
|
34
|
+
* record it genuinely cannot interpret.
|
|
35
|
+
*
|
|
36
|
+
* The order is the order `FACTORS` evaluates in, which is severity-ish and not
|
|
37
|
+
* arithmetic: nothing reads an index here, unlike `STAKE_ORDER` (0166).
|
|
38
|
+
*/
|
|
39
|
+
export const stakeFactorCodeSchema = z.enum([
|
|
40
|
+
"protected-type-removed",
|
|
41
|
+
"protected-type-touched",
|
|
42
|
+
"protected-type-relocated",
|
|
43
|
+
"protected-prop-configured",
|
|
44
|
+
"large-removal",
|
|
45
|
+
"broad-change",
|
|
46
|
+
"shallow-structural-change",
|
|
47
|
+
"discards-later-work",
|
|
48
|
+
"nested-target",
|
|
49
|
+
"unknown-primitive",
|
|
50
|
+
"invalid-props",
|
|
51
|
+
"unread-binding",
|
|
52
|
+
"unplaced-slot",
|
|
53
|
+
"redirected-submission",
|
|
54
|
+
"repointed-binding",
|
|
55
|
+
]);
|
|
56
|
+
/**
|
|
57
|
+
* Every rule the Gate can raise, walkable.
|
|
58
|
+
*
|
|
59
|
+
* Derived rather than declared: the members come from a schema, so a second
|
|
60
|
+
* hand-written list would be the copy `closed-set.ts` exists to avoid. Two
|
|
61
|
+
* surfaces hold a plain-language table keyed by this union and both reached for
|
|
62
|
+
* `Object.keys(...) as StakeFactorCode[]` to walk it, which is a cast standing
|
|
63
|
+
* in for a list.
|
|
64
|
+
*/
|
|
65
|
+
export const STAKE_FACTOR_CODES = stakeFactorCodeSchema.options;
|
|
66
|
+
/**
|
|
67
|
+
* The rules whose level is fixed at the code, and the level each one is fixed
|
|
68
|
+
* at.
|
|
69
|
+
*
|
|
70
|
+
* Every rule in this file is one of two kinds, and the difference is which
|
|
71
|
+
* question it answers. Seven of them ask *how much of this deployment's page
|
|
72
|
+
* does this touch* — how many nodes went, how broad it was, how shallow, which
|
|
73
|
+
* of the types this host declared it cares about — so moving a field of the
|
|
74
|
+
* policy moves the answer. The other eight ask *is this change coherent at all*:
|
|
75
|
+
* a target nobody can reach, a type nothing is registered for, props the
|
|
76
|
+
* declaring primitive refuses, a question nothing reads, content put in a region
|
|
77
|
+
* nothing places, a form or a region pointed somewhere else, work written over.
|
|
78
|
+
* None of those consults a policy field. A host turns them off by declaring no
|
|
79
|
+
* vocabulary (0002) and cannot tune them, so their level is a property of the
|
|
80
|
+
* rule itself.
|
|
81
|
+
*
|
|
82
|
+
* Declared here rather than written into each factor because the level now has
|
|
83
|
+
* two readers. The Gate computes it while it holds the delta, and
|
|
84
|
+
* `remeasureStakes` has to state it months later holding only a record — and the
|
|
85
|
+
* second reader exists *because* these seven cannot be re-measured from a
|
|
86
|
+
* record: a code says a rule fired and the list of nodes it fired about does not
|
|
87
|
+
* cross the boundary (0023). What crosses is the code, and this is what turns a
|
|
88
|
+
* code back into a level without a second copy of these numbers in whatever
|
|
89
|
+
* reads the journal.
|
|
90
|
+
*/
|
|
91
|
+
const FIXED_LEVELS = {
|
|
92
|
+
"discards-later-work": "high",
|
|
93
|
+
"nested-target": "critical",
|
|
94
|
+
"unknown-primitive": "critical",
|
|
95
|
+
"invalid-props": "critical",
|
|
96
|
+
"unread-binding": "critical",
|
|
97
|
+
"unplaced-slot": "critical",
|
|
98
|
+
"redirected-submission": "high",
|
|
99
|
+
"repointed-binding": "high",
|
|
100
|
+
};
|
|
101
|
+
/** The level this rule is always raised at, which is the whole of what its code means. */
|
|
102
|
+
export const fixedStakeLevel = (code) => FIXED_LEVELS[code];
|
|
103
|
+
export const isFixedStakeFactor = (code) => code in FIXED_LEVELS;
|
|
104
|
+
/**
|
|
105
|
+
* The two halves of the vocabulary, walkable, in the order the Gate raises them.
|
|
106
|
+
*
|
|
107
|
+
* Filtered from `STAKE_FACTOR_CODES` rather than written out, so neither list can
|
|
108
|
+
* be the stale copy of a partition that lives in one place. A factor added to the
|
|
109
|
+
* schema joins one of them according to whether `FIXED_LEVELS` names it, and a
|
|
110
|
+
* reader walking either gets the new member without being told.
|
|
111
|
+
*/
|
|
112
|
+
export const FIXED_STAKE_FACTOR_CODES = STAKE_FACTOR_CODES.filter(isFixedStakeFactor);
|
|
113
|
+
export const MEASURED_STAKE_FACTOR_CODES = STAKE_FACTOR_CODES.filter((code) => !isFixedStakeFactor(code));
|
|
114
|
+
/** The measurable half of an analysis, which is what the Gate's own path takes. */
|
|
115
|
+
export const stakeMeasurementOf = (analysis) => ({
|
|
116
|
+
insertedNodeCount: analysis.insertedNodeCount,
|
|
117
|
+
removedNodeCount: analysis.removedNodeCount,
|
|
118
|
+
movedNodeCount: analysis.movedNodeCount,
|
|
119
|
+
affectedNodeCount: analysis.affectedNodeIds.length,
|
|
120
|
+
shallowestAffectedDepth: analysis.shallowestAffectedDepth,
|
|
121
|
+
touchedPrimitiveTypes: analysis.touchedPrimitiveTypes,
|
|
122
|
+
removedPrimitiveTypes: analysis.removedPrimitiveTypes,
|
|
123
|
+
relocatedPrimitiveTypes: analysis.relocatedPrimitiveTypes,
|
|
124
|
+
configuredPropKeys: analysis.configuredPropKeys,
|
|
125
|
+
});
|
|
6
126
|
const intersect = (candidates, declared) => candidates.filter((candidate) => declared.includes(candidate));
|
|
7
127
|
/** Destroying a protected primitive outranks merely reconfiguring one. */
|
|
8
|
-
const protectedTypeRemoved = (
|
|
9
|
-
const matches = intersect(
|
|
128
|
+
const protectedTypeRemoved = (measurement, policy) => {
|
|
129
|
+
const matches = intersect(measurement.removedPrimitiveTypes, policy.protectedPrimitiveTypes);
|
|
10
130
|
if (matches.length === 0)
|
|
11
131
|
return null;
|
|
12
132
|
return {
|
|
@@ -15,8 +135,8 @@ const protectedTypeRemoved = ({ analysis }, policy) => {
|
|
|
15
135
|
detail: `destroys protected ${matches.join(", ")}`,
|
|
16
136
|
};
|
|
17
137
|
};
|
|
18
|
-
const protectedTypeTouched = (
|
|
19
|
-
const matches = intersect(
|
|
138
|
+
const protectedTypeTouched = (measurement, policy) => {
|
|
139
|
+
const matches = intersect(measurement.touchedPrimitiveTypes, policy.protectedPrimitiveTypes);
|
|
20
140
|
if (matches.length === 0)
|
|
21
141
|
return null;
|
|
22
142
|
return {
|
|
@@ -32,8 +152,8 @@ const protectedTypeTouched = ({ analysis }, policy) => {
|
|
|
32
152
|
* because the two sentences a reviewer needs are different — one says the card
|
|
33
153
|
* was rewritten, the other says it is somewhere else now (0044).
|
|
34
154
|
*/
|
|
35
|
-
const protectedTypeRelocated = (
|
|
36
|
-
const matches = intersect(
|
|
155
|
+
const protectedTypeRelocated = (measurement, policy) => {
|
|
156
|
+
const matches = intersect(measurement.relocatedPrimitiveTypes, policy.protectedPrimitiveTypes);
|
|
37
157
|
if (matches.length === 0)
|
|
38
158
|
return null;
|
|
39
159
|
return {
|
|
@@ -42,8 +162,8 @@ const protectedTypeRelocated = ({ analysis }, policy) => {
|
|
|
42
162
|
detail: `relocates protected ${matches.join(", ")}`,
|
|
43
163
|
};
|
|
44
164
|
};
|
|
45
|
-
const protectedProp = (
|
|
46
|
-
const matches = intersect(
|
|
165
|
+
const protectedProp = (measurement, policy) => {
|
|
166
|
+
const matches = intersect(measurement.configuredPropKeys, policy.protectedPropKeys);
|
|
47
167
|
if (matches.length === 0)
|
|
48
168
|
return null;
|
|
49
169
|
return {
|
|
@@ -52,8 +172,8 @@ const protectedProp = ({ analysis }, policy) => {
|
|
|
52
172
|
detail: `configures protected ${matches.join(", ")}`,
|
|
53
173
|
};
|
|
54
174
|
};
|
|
55
|
-
const largeRemoval = (
|
|
56
|
-
const { removedNodeCount } =
|
|
175
|
+
const largeRemoval = (measurement, policy) => {
|
|
176
|
+
const { removedNodeCount } = measurement;
|
|
57
177
|
const { removalThresholds } = policy;
|
|
58
178
|
if (removedNodeCount >= removalThresholds.high) {
|
|
59
179
|
return {
|
|
@@ -71,22 +191,22 @@ const largeRemoval = ({ analysis }, policy) => {
|
|
|
71
191
|
}
|
|
72
192
|
return null;
|
|
73
193
|
};
|
|
74
|
-
const broadChange = (
|
|
75
|
-
const touched =
|
|
194
|
+
const broadChange = (measurement, policy) => {
|
|
195
|
+
const touched = measurement.affectedNodeCount;
|
|
76
196
|
if (touched < policy.breadthThreshold)
|
|
77
197
|
return null;
|
|
78
198
|
return { code: "broad-change", level: "medium", detail: `touches ${touched} nodes` };
|
|
79
199
|
};
|
|
80
|
-
const isStructural = (
|
|
81
|
-
const shallowStructuralChange = (
|
|
82
|
-
if (!isStructural(
|
|
200
|
+
const isStructural = (measurement) => measurement.insertedNodeCount + measurement.removedNodeCount + measurement.movedNodeCount > 0;
|
|
201
|
+
const shallowStructuralChange = (measurement, policy) => {
|
|
202
|
+
if (!isStructural(measurement))
|
|
83
203
|
return null;
|
|
84
|
-
if (
|
|
204
|
+
if (measurement.shallowestAffectedDepth > policy.shallowDepthThreshold)
|
|
85
205
|
return null;
|
|
86
206
|
return {
|
|
87
207
|
code: "shallow-structural-change",
|
|
88
208
|
level: "medium",
|
|
89
|
-
detail: `restructures at depth ${
|
|
209
|
+
detail: `restructures at depth ${measurement.shallowestAffectedDepth}`,
|
|
90
210
|
};
|
|
91
211
|
};
|
|
92
212
|
/**
|
|
@@ -108,7 +228,7 @@ const discardsLaterWork = ({ discards }) => {
|
|
|
108
228
|
const nodes = new Set(discards.flatMap((discarded) => discarded.nodeIds));
|
|
109
229
|
return {
|
|
110
230
|
code: "discards-later-work",
|
|
111
|
-
level: "
|
|
231
|
+
level: FIXED_LEVELS["discards-later-work"],
|
|
112
232
|
detail: `discards work from revision${revisions.length === 1 ? "" : "s"} ${revisions.join(", ")} at ${nodes.size} node${nodes.size === 1 ? "" : "s"}`,
|
|
113
233
|
};
|
|
114
234
|
};
|
|
@@ -148,7 +268,7 @@ const nestedTarget = ({ analysis }) => {
|
|
|
148
268
|
const one = nestedTargets.length === 1;
|
|
149
269
|
return {
|
|
150
270
|
code: "nested-target",
|
|
151
|
-
level: "
|
|
271
|
+
level: FIXED_LEVELS["nested-target"],
|
|
152
272
|
detail: `puts ${one ? "a target" : `${nestedTargets.length} targets`} where the reader cannot reach ${one ? "it" : "them"}: ${nestedTargets.map(describeNestedTarget).join("; ")}`,
|
|
153
273
|
};
|
|
154
274
|
};
|
|
@@ -188,7 +308,7 @@ const unknownPrimitive = ({ analysis }) => {
|
|
|
188
308
|
const one = unknownPrimitives.length === 1;
|
|
189
309
|
return {
|
|
190
310
|
code: "unknown-primitive",
|
|
191
|
-
level: "
|
|
311
|
+
level: FIXED_LEVELS["unknown-primitive"],
|
|
192
312
|
detail: `adds ${one ? "a node" : `${unknownPrimitives.length} nodes`} no primitive is registered for, so ${one ? "it draws" : "they draw"} nothing: ${unknownPrimitives.map(describeUnknownPrimitive).join("; ")}`,
|
|
193
313
|
};
|
|
194
314
|
};
|
|
@@ -218,10 +338,80 @@ const invalidProps = ({ analysis }) => {
|
|
|
218
338
|
const one = invalid.length === 1;
|
|
219
339
|
return {
|
|
220
340
|
code: "invalid-props",
|
|
221
|
-
level: "
|
|
341
|
+
level: FIXED_LEVELS["invalid-props"],
|
|
222
342
|
detail: `leaves ${one ? "a node" : `${invalid.length} nodes`} carrying props the declaring primitive refuses, so ${one ? "it draws" : "they draw"} nothing: ${invalid.map(describeInvalidProps).join("; ")}`,
|
|
223
343
|
};
|
|
224
344
|
};
|
|
345
|
+
/**
|
|
346
|
+
* A question nothing will read, as damage.
|
|
347
|
+
*
|
|
348
|
+
* `critical`, which ranks it with `unknown-primitive` and `invalid-props`, and
|
|
349
|
+
* the argument is **not** theirs. Those two are `critical` because the damage is
|
|
350
|
+
* identical — `renderElement` returns `null` and the page has a hole — and a
|
|
351
|
+
* level that separated them would be ranking the explanation rather than the
|
|
352
|
+
* harm. This harm is a different thing: the page draws, nothing is missing from
|
|
353
|
+
* the markup, and what is wrong is that the region shows its empty state while
|
|
354
|
+
* the host pays a round trip to its own source on every render to fill it.
|
|
355
|
+
*
|
|
356
|
+
* It is ranked with them because of the **available answer** rather than the
|
|
357
|
+
* damage, which is worth stating plainly rather than filed under a family
|
|
358
|
+
* resemblance. A refusal is the disposition a repairer is offered, and
|
|
359
|
+
* *`loom.feed` reads `entries`, and this node asked under `rows`* is close to
|
|
360
|
+
* the most actionable thing a model can be told: the declaration holds the
|
|
361
|
+
* correct name, so the repair is one string. Confirmation is the wrong rung for
|
|
362
|
+
* the same reason it is wrong for invalid props — it puts a change to a person
|
|
363
|
+
* whose only sensible answer is no, and the one thing it could not tell them is
|
|
364
|
+
* what to do instead.
|
|
365
|
+
*
|
|
366
|
+
* The one case it ranks too high is the node somebody meant to leave asking
|
|
367
|
+
* ahead of a primitive that will read it next week. That change is honestly
|
|
368
|
+
* refusable today: the round trip is real now and the reader nobody wrote is
|
|
369
|
+
* not, so a host that wants it declares no reader and this never fires — which
|
|
370
|
+
* is the default, and 0002's answer to every knob that was not built.
|
|
371
|
+
*/
|
|
372
|
+
const unreadBinding = ({ analysis }) => {
|
|
373
|
+
const { unreadBindings: unread } = analysis;
|
|
374
|
+
if (unread.length === 0)
|
|
375
|
+
return null;
|
|
376
|
+
const one = unread.length === 1;
|
|
377
|
+
return {
|
|
378
|
+
code: "unread-binding",
|
|
379
|
+
level: FIXED_LEVELS["unread-binding"],
|
|
380
|
+
detail: `asks ${one ? "a question" : `${unread.length} questions`} no primitive reads, so the ${one ? "answer is" : "answers are"} fetched and dropped: ${unread.map(describeUnreadBinding).join("; ")}`,
|
|
381
|
+
};
|
|
382
|
+
};
|
|
383
|
+
/**
|
|
384
|
+
* Content put where nothing will draw it, as damage.
|
|
385
|
+
*
|
|
386
|
+
* `critical`, which is `unread-binding`'s level and the argument for it applies
|
|
387
|
+
* here with one word changed. The repair is one string and the registry holds
|
|
388
|
+
* it: *`loom.dialog` places `header` and `footer`, and this node filled `body`*
|
|
389
|
+
* is something a repairer can act on without being told anything else, so a
|
|
390
|
+
* refusal is worth more to it than a confirmation a person can only answer no
|
|
391
|
+
* to.
|
|
392
|
+
*
|
|
393
|
+
* Where it is a stronger case than the binding is in what is lost. A question
|
|
394
|
+
* nothing reads costs a round trip and draws an empty state; a region nothing
|
|
395
|
+
* places drops the content **and everything under it**, so an author's
|
|
396
|
+
* paragraph is simply not on the page. 0249 gave the renderer a diagnostic for
|
|
397
|
+
* that and this is the half that keeps it from being written in the first
|
|
398
|
+
* place.
|
|
399
|
+
*
|
|
400
|
+
* It fires only where a host has handed a placer, which is 0002's answer again:
|
|
401
|
+
* a deployment resolving primitives from a plain map has never been able to say
|
|
402
|
+
* what a primitive places, and nothing here invents the knowledge.
|
|
403
|
+
*/
|
|
404
|
+
const unplacedSlot = ({ analysis }) => {
|
|
405
|
+
const { unplacedSlots: unplaced } = analysis;
|
|
406
|
+
if (unplaced.length === 0)
|
|
407
|
+
return null;
|
|
408
|
+
const one = unplaced.length === 1;
|
|
409
|
+
return {
|
|
410
|
+
code: "unplaced-slot",
|
|
411
|
+
level: FIXED_LEVELS["unplaced-slot"],
|
|
412
|
+
detail: `fills ${one ? "a region" : `${unplaced.length} regions`} no primitive places, so the ${one ? "content and everything under it is" : "contents and everything under them are"} dropped: ${unplaced.map(describeUnplacedSlot).join("; ")}`,
|
|
413
|
+
};
|
|
414
|
+
};
|
|
225
415
|
/**
|
|
226
416
|
* A form pointed somewhere else, as damage.
|
|
227
417
|
*
|
|
@@ -248,7 +438,7 @@ const redirectedSubmission = ({ analysis }) => {
|
|
|
248
438
|
return null;
|
|
249
439
|
return {
|
|
250
440
|
code: "redirected-submission",
|
|
251
|
-
level: "
|
|
441
|
+
level: FIXED_LEVELS["redirected-submission"],
|
|
252
442
|
detail: `redirects ${redirectedSubmissions.length === 1 ? "a submission" : `${redirectedSubmissions.length} submissions`}: ${redirectedSubmissions.map(describeRedirectedSubmission).join("; ")}`,
|
|
253
443
|
};
|
|
254
444
|
};
|
|
@@ -277,11 +467,18 @@ const repointedBinding = ({ analysis }) => {
|
|
|
277
467
|
return null;
|
|
278
468
|
return {
|
|
279
469
|
code: "repointed-binding",
|
|
280
|
-
level: "
|
|
470
|
+
level: FIXED_LEVELS["repointed-binding"],
|
|
281
471
|
detail: `repoints ${repointedBindings.length === 1 ? "a binding" : `${repointedBindings.length} bindings`}: ${repointedBindings.map(describeRepointedBinding).join("; ")}`,
|
|
282
472
|
};
|
|
283
473
|
};
|
|
284
|
-
|
|
474
|
+
/**
|
|
475
|
+
* The seven a policy decides, in the order the Gate raises them.
|
|
476
|
+
*
|
|
477
|
+
* Order is part of the record: `stakeFactorCodes` is written in the order the
|
|
478
|
+
* factors came out, so the two lists here are the one list this used to be, cut
|
|
479
|
+
* where the kinds change and not reordered.
|
|
480
|
+
*/
|
|
481
|
+
const MEASURED_FACTORS = [
|
|
285
482
|
protectedTypeRemoved,
|
|
286
483
|
protectedTypeTouched,
|
|
287
484
|
protectedTypeRelocated,
|
|
@@ -289,15 +486,32 @@ const FACTORS = [
|
|
|
289
486
|
largeRemoval,
|
|
290
487
|
broadChange,
|
|
291
488
|
shallowStructuralChange,
|
|
489
|
+
];
|
|
490
|
+
/** The eight fixed at their code, which read the specifics a record does not carry. */
|
|
491
|
+
const FIXED_FACTORS = [
|
|
292
492
|
discardsLaterWork,
|
|
293
493
|
nestedTarget,
|
|
294
494
|
unknownPrimitive,
|
|
295
495
|
invalidProps,
|
|
496
|
+
unreadBinding,
|
|
497
|
+
unplacedSlot,
|
|
296
498
|
redirectedSubmission,
|
|
297
499
|
repointedBinding,
|
|
298
500
|
];
|
|
501
|
+
/**
|
|
502
|
+
* The policy-dependent half, against a measurement rather than a delta.
|
|
503
|
+
*
|
|
504
|
+
* Published because it is the half that can be run twice: once by the Gate on
|
|
505
|
+
* the change in front of it, and again by anything holding a record of that
|
|
506
|
+
* change and a policy it is considering. The other half cannot, which is why it
|
|
507
|
+
* is not here — see `fixedStakeLevel`.
|
|
508
|
+
*/
|
|
509
|
+
export const measureStakes = (measurement, policy) => MEASURED_FACTORS.flatMap((factor) => factor(measurement, policy) ?? []);
|
|
299
510
|
export const assessStakes = (input, policy) => {
|
|
300
|
-
const factors =
|
|
511
|
+
const factors = [
|
|
512
|
+
...measureStakes(stakeMeasurementOf(input.analysis), policy),
|
|
513
|
+
...FIXED_FACTORS.flatMap((factor) => factor(input, policy) ?? []),
|
|
514
|
+
];
|
|
301
515
|
return { level: highestStake(factors.map((factor) => factor.level)), factors };
|
|
302
516
|
};
|
|
303
517
|
/** The factor with this code, for a caller that needs the reason and not the level. */
|