@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,57 @@
|
|
|
1
|
+
import { type NodeId } from "../ids.js";
|
|
2
|
+
import type { JsonObject } from "../json.js";
|
|
3
|
+
import { type LoomTree } from "../tree/tree.js";
|
|
4
|
+
/**
|
|
5
|
+
* A small, deterministic tree used across tests and, later, by the renderer and
|
|
6
|
+
* portal for smoke fixtures. Ids come from a sequential factory so assertions
|
|
7
|
+
* can name them instead of digging them out of the structure.
|
|
8
|
+
*/
|
|
9
|
+
export type SampleTree = {
|
|
10
|
+
readonly tree: LoomTree;
|
|
11
|
+
readonly ids: {
|
|
12
|
+
readonly page: NodeId;
|
|
13
|
+
readonly header: NodeId;
|
|
14
|
+
readonly headline: NodeId;
|
|
15
|
+
readonly main: NodeId;
|
|
16
|
+
readonly card: NodeId;
|
|
17
|
+
readonly body: NodeId;
|
|
18
|
+
readonly footer: NodeId;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export declare const sampleTree: () => SampleTree;
|
|
22
|
+
export type FormTree = {
|
|
23
|
+
readonly tree: LoomTree;
|
|
24
|
+
readonly ids: {
|
|
25
|
+
readonly page: NodeId;
|
|
26
|
+
readonly form: NodeId;
|
|
27
|
+
/** A sibling that posts nowhere, so a test can move a destination onto one. */
|
|
28
|
+
readonly aside: NodeId;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* A page whose form already posts somewhere. Separate from `sampleTree` rather
|
|
33
|
+
* than a node added to it: every count in the stakes and analysis suites is
|
|
34
|
+
* asserted against that tree's exact size, and a fixture that grows is a fixture
|
|
35
|
+
* that makes unrelated tests wrong.
|
|
36
|
+
*/
|
|
37
|
+
export declare const formTree: (to?: string) => FormTree;
|
|
38
|
+
export type BoundTree = {
|
|
39
|
+
readonly tree: LoomTree;
|
|
40
|
+
readonly ids: {
|
|
41
|
+
readonly page: NodeId;
|
|
42
|
+
readonly bound: NodeId;
|
|
43
|
+
/** A sibling that asks nothing, so a test can put a binding onto one. */
|
|
44
|
+
readonly aside: NodeId;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* A page whose card already reads from somewhere. `formTree`'s twin at the other
|
|
49
|
+
* end of the pipe, separate from both for the reason that one gives: every count
|
|
50
|
+
* in the stakes and analysis suites is asserted against an exact tree size, and
|
|
51
|
+
* a fixture that grows makes unrelated tests wrong.
|
|
52
|
+
*
|
|
53
|
+
* Internal, unlike `formTree`. A published entry point is a promise (see
|
|
54
|
+
* `testing/index.ts`), and nothing outside this package has asked for this one.
|
|
55
|
+
*/
|
|
56
|
+
export declare const boundTree: (source?: string, params?: JsonObject) => BoundTree;
|
|
57
|
+
//# sourceMappingURL=fixtures.d.ts.map
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { sequentialIdFactory } from "../ids.js";
|
|
2
|
+
import { DATA_PROP_KEY, SUBMIT_PROP_KEY } from "../reserved-props.js";
|
|
3
|
+
import { buildElement, buildSlot, buildText } from "../tree/builders.js";
|
|
4
|
+
import { createTree } from "../tree/tree.js";
|
|
5
|
+
export const sampleTree = () => {
|
|
6
|
+
const idFactory = sequentialIdFactory();
|
|
7
|
+
const headline = buildText(idFactory, "Welcome");
|
|
8
|
+
const header = buildElement(idFactory, { type: "loom.header", children: [headline] });
|
|
9
|
+
const body = buildText(idFactory, "Body copy");
|
|
10
|
+
const card = buildElement(idFactory, {
|
|
11
|
+
type: "loom.card",
|
|
12
|
+
props: { variant: "outlined", elevation: 1 },
|
|
13
|
+
children: [body],
|
|
14
|
+
});
|
|
15
|
+
const main = buildSlot(idFactory, "main", [card]);
|
|
16
|
+
const footer = buildElement(idFactory, { type: "loom.footer" });
|
|
17
|
+
const page = buildElement(idFactory, {
|
|
18
|
+
type: "loom.page",
|
|
19
|
+
props: { title: "Home" },
|
|
20
|
+
children: [header, main, footer],
|
|
21
|
+
});
|
|
22
|
+
return {
|
|
23
|
+
tree: createTree(page, idFactory),
|
|
24
|
+
ids: {
|
|
25
|
+
page: page.id,
|
|
26
|
+
header: header.id,
|
|
27
|
+
headline: headline.id,
|
|
28
|
+
main: main.id,
|
|
29
|
+
card: card.id,
|
|
30
|
+
body: body.id,
|
|
31
|
+
footer: footer.id,
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* A page whose form already posts somewhere. Separate from `sampleTree` rather
|
|
37
|
+
* than a node added to it: every count in the stakes and analysis suites is
|
|
38
|
+
* asserted against that tree's exact size, and a fixture that grows is a fixture
|
|
39
|
+
* that makes unrelated tests wrong.
|
|
40
|
+
*/
|
|
41
|
+
export const formTree = (to = "newsletter.subscribe") => {
|
|
42
|
+
const idFactory = sequentialIdFactory("form");
|
|
43
|
+
const form = buildElement(idFactory, {
|
|
44
|
+
type: "loom.form",
|
|
45
|
+
props: { [SUBMIT_PROP_KEY]: { to } },
|
|
46
|
+
});
|
|
47
|
+
const aside = buildElement(idFactory, { type: "loom.form" });
|
|
48
|
+
const page = buildElement(idFactory, {
|
|
49
|
+
type: "loom.page",
|
|
50
|
+
props: { title: "Contact" },
|
|
51
|
+
children: [form, aside],
|
|
52
|
+
});
|
|
53
|
+
return {
|
|
54
|
+
tree: createTree(page, idFactory),
|
|
55
|
+
ids: { page: page.id, form: form.id, aside: aside.id },
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* A page whose card already reads from somewhere. `formTree`'s twin at the other
|
|
60
|
+
* end of the pipe, separate from both for the reason that one gives: every count
|
|
61
|
+
* in the stakes and analysis suites is asserted against an exact tree size, and
|
|
62
|
+
* a fixture that grows makes unrelated tests wrong.
|
|
63
|
+
*
|
|
64
|
+
* Internal, unlike `formTree`. A published entry point is a promise (see
|
|
65
|
+
* `testing/index.ts`), and nothing outside this package has asked for this one.
|
|
66
|
+
*/
|
|
67
|
+
export const boundTree = (source = "catalogue.services", params = {}) => {
|
|
68
|
+
const idFactory = sequentialIdFactory("bound");
|
|
69
|
+
const bound = buildElement(idFactory, {
|
|
70
|
+
type: "loom.card",
|
|
71
|
+
props: { [DATA_PROP_KEY]: { items: { source, params } } },
|
|
72
|
+
});
|
|
73
|
+
const aside = buildElement(idFactory, { type: "loom.card" });
|
|
74
|
+
const page = buildElement(idFactory, {
|
|
75
|
+
type: "loom.page",
|
|
76
|
+
props: { title: "Services" },
|
|
77
|
+
children: [bound, aside],
|
|
78
|
+
});
|
|
79
|
+
return {
|
|
80
|
+
tree: createTree(page, idFactory),
|
|
81
|
+
ids: { page: page.id, bound: bound.id, aside: aside.id },
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
//# sourceMappingURL=fixtures.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type TreeId } from "../ids.js";
|
|
2
|
+
import type { HeldProposal, HoldStore } from "../write/held.js";
|
|
3
|
+
/**
|
|
4
|
+
* A hold against a real tree.
|
|
5
|
+
*
|
|
6
|
+
* `sampleTree` mints the same ids every time, so a test that needs two holds to
|
|
7
|
+
* differ has to say how. Every optional field on the three stored shapes is left
|
|
8
|
+
* absent by default and set only by the test that is about them — absence is the
|
|
9
|
+
* case a JSON round-trip is most likely to get wrong, so it is the one the rest
|
|
10
|
+
* of the suite should be exercising.
|
|
11
|
+
*/
|
|
12
|
+
export declare const heldProposalFixture: (options?: {
|
|
13
|
+
readonly heldAt?: string;
|
|
14
|
+
readonly treeId?: TreeId;
|
|
15
|
+
readonly actor?: string;
|
|
16
|
+
readonly policyFingerprint?: string;
|
|
17
|
+
}) => HeldProposal;
|
|
18
|
+
export declare const describeHoldStoreContract: (name: string, makeStore: () => HoldStore | Promise<HoldStore>) => void;
|
|
19
|
+
//# sourceMappingURL=hold-contract.d.ts.map
|
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { sequentialIdFactory, treeIdSchema } from "../ids.js";
|
|
3
|
+
import { buildIntent, buildProposal, FIXED_INSTANT } from "./doubles.js";
|
|
4
|
+
import { sampleTree } from "./fixtures.js";
|
|
5
|
+
/**
|
|
6
|
+
* One suite, run against every `HoldStore`.
|
|
7
|
+
*
|
|
8
|
+
* `held.ts` calls `memoryHoldStore` the reference implementation, which is a
|
|
9
|
+
* promise rather than a fact until something checks a second one against it.
|
|
10
|
+
* This is that check, and it exists for a sharper reason than the tree store's
|
|
11
|
+
* did: the property that makes a hold safe — that `release` is a take rather
|
|
12
|
+
* than a read, so two reviewers confirming at once cannot both come away with
|
|
13
|
+
* the same change — is a *race*, and a race is exactly the kind of thing a
|
|
14
|
+
* single-threaded `Map` gets right for free and a database has to be made to
|
|
15
|
+
* get right on purpose.
|
|
16
|
+
*
|
|
17
|
+
* Only behaviour the contract promises belongs here. How an implementation
|
|
18
|
+
* reports a connection failure, and what it does with the row underneath, stays
|
|
19
|
+
* in that implementation's own test file.
|
|
20
|
+
*/
|
|
21
|
+
const ids = sequentialIdFactory("holdcontract");
|
|
22
|
+
/**
|
|
23
|
+
* A hold against a real tree.
|
|
24
|
+
*
|
|
25
|
+
* `sampleTree` mints the same ids every time, so a test that needs two holds to
|
|
26
|
+
* differ has to say how. Every optional field on the three stored shapes is left
|
|
27
|
+
* absent by default and set only by the test that is about them — absence is the
|
|
28
|
+
* case a JSON round-trip is most likely to get wrong, so it is the one the rest
|
|
29
|
+
* of the suite should be exercising.
|
|
30
|
+
*/
|
|
31
|
+
export const heldProposalFixture = (options) => {
|
|
32
|
+
const { tree, ids: nodes } = sampleTree();
|
|
33
|
+
const treeId = options?.treeId ?? tree.treeId;
|
|
34
|
+
/**
|
|
35
|
+
* A real operation rather than an empty list, because a delta with nothing in
|
|
36
|
+
* it is not a `TreeDelta`: `treeDeltaSchema` requires at least one. The
|
|
37
|
+
* in-memory store never noticed, since it stores what it is handed; a backing
|
|
38
|
+
* store that reads a hold back has to parse it, and would refuse this on the
|
|
39
|
+
* way out having accepted it on the way in.
|
|
40
|
+
*/
|
|
41
|
+
const delta = {
|
|
42
|
+
deltaId: ids.deltaId(),
|
|
43
|
+
treeId,
|
|
44
|
+
baseRevision: tree.revision,
|
|
45
|
+
operations: [{ op: "configure", nodeId: nodes.page, set: { title: "Held" }, unset: [] }],
|
|
46
|
+
};
|
|
47
|
+
const intent = buildIntent(ids, {
|
|
48
|
+
treeId,
|
|
49
|
+
baseRevision: tree.revision,
|
|
50
|
+
...(options?.actor === undefined ? {} : { actor: options.actor }),
|
|
51
|
+
});
|
|
52
|
+
const proposal = buildProposal(ids, { intentId: intent.intentId, delta });
|
|
53
|
+
return {
|
|
54
|
+
proposalId: proposal.proposalId,
|
|
55
|
+
treeId,
|
|
56
|
+
baseRevision: tree.revision,
|
|
57
|
+
intent,
|
|
58
|
+
proposal,
|
|
59
|
+
disposition: {
|
|
60
|
+
kind: "requires-confirmation",
|
|
61
|
+
reason: { code: "confidence-below-minimum", detail: "0.5 is under the floor" },
|
|
62
|
+
stakes: "medium",
|
|
63
|
+
reversible: true,
|
|
64
|
+
confidence: 0.5,
|
|
65
|
+
policyId: "default",
|
|
66
|
+
...(options?.policyFingerprint === undefined
|
|
67
|
+
? {}
|
|
68
|
+
: { policyFingerprint: options.policyFingerprint }),
|
|
69
|
+
},
|
|
70
|
+
heldAt: options?.heldAt ?? FIXED_INSTANT,
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
export const describeHoldStoreContract = (name, makeStore) => {
|
|
74
|
+
describe(`${name} — HoldStore contract`, () => {
|
|
75
|
+
it("gives back what it was given, whole", async () => {
|
|
76
|
+
const store = await makeStore();
|
|
77
|
+
const held = heldProposalFixture();
|
|
78
|
+
expect(await store.hold(held)).toEqual({ ok: true, value: held });
|
|
79
|
+
const found = await store.get(held.proposalId);
|
|
80
|
+
expect(found).toEqual({ ok: true, value: held });
|
|
81
|
+
});
|
|
82
|
+
/**
|
|
83
|
+
* The one a backing store is most likely to break. `actor` and
|
|
84
|
+
* `policyFingerprint` are absent on an ordinary hold, and a column-per-
|
|
85
|
+
* field store would read them back as `null` — which is a different value
|
|
86
|
+
* from an absent key and would make the two implementations disagree about
|
|
87
|
+
* a proposal neither of them refused.
|
|
88
|
+
*/
|
|
89
|
+
it("keeps an optional field that was set, and does not invent one that was not", async () => {
|
|
90
|
+
const store = await makeStore();
|
|
91
|
+
const bare = heldProposalFixture();
|
|
92
|
+
const full = heldProposalFixture({
|
|
93
|
+
treeId: treeIdSchema.parse("t_full"),
|
|
94
|
+
actor: "alex",
|
|
95
|
+
policyFingerprint: "sha256:abc",
|
|
96
|
+
});
|
|
97
|
+
await store.hold(bare);
|
|
98
|
+
await store.hold(full);
|
|
99
|
+
const readBare = await store.get(bare.proposalId);
|
|
100
|
+
const readFull = await store.get(full.proposalId);
|
|
101
|
+
if (!readBare.ok || !readFull.ok)
|
|
102
|
+
throw new Error("expected both holds");
|
|
103
|
+
expect("actor" in readBare.value.intent).toBe(false);
|
|
104
|
+
expect("policyFingerprint" in readBare.value.disposition).toBe(false);
|
|
105
|
+
expect(readFull.value.intent.actor).toBe("alex");
|
|
106
|
+
expect(readFull.value.disposition.policyFingerprint).toBe("sha256:abc");
|
|
107
|
+
});
|
|
108
|
+
it("reports an unknown id as not-held rather than as an empty answer", async () => {
|
|
109
|
+
const store = await makeStore();
|
|
110
|
+
expect(await store.get("p_missing")).toEqual({
|
|
111
|
+
ok: false,
|
|
112
|
+
error: { code: "not-held", proposalId: "p_missing" },
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
it("refuses to hold the same proposal twice", async () => {
|
|
116
|
+
const store = await makeStore();
|
|
117
|
+
const held = heldProposalFixture();
|
|
118
|
+
await store.hold(held);
|
|
119
|
+
expect(await store.hold(held)).toEqual({
|
|
120
|
+
ok: false,
|
|
121
|
+
error: { code: "already-held", proposalId: held.proposalId },
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
/** A refused second hold must not have overwritten the first. */
|
|
125
|
+
it("leaves the original in place when a second hold is refused", async () => {
|
|
126
|
+
const store = await makeStore();
|
|
127
|
+
const held = heldProposalFixture();
|
|
128
|
+
await store.hold(held);
|
|
129
|
+
await store.hold({ ...held, heldAt: "2026-07-31T00:00:00.000Z" });
|
|
130
|
+
const found = await store.get(held.proposalId);
|
|
131
|
+
if (!found.ok)
|
|
132
|
+
throw new Error("expected the first hold to survive");
|
|
133
|
+
expect(found.value.heldAt).toBe(held.heldAt);
|
|
134
|
+
});
|
|
135
|
+
/**
|
|
136
|
+
* The whole reason `release` is a take rather than a read: two reviewers
|
|
137
|
+
* pressing confirm cannot both come away holding the same change.
|
|
138
|
+
*/
|
|
139
|
+
it("releases a proposal exactly once", async () => {
|
|
140
|
+
const store = await makeStore();
|
|
141
|
+
const held = heldProposalFixture();
|
|
142
|
+
await store.hold(held);
|
|
143
|
+
const first = await store.release(held.proposalId);
|
|
144
|
+
const second = await store.release(held.proposalId);
|
|
145
|
+
expect(first).toEqual({ ok: true, value: held });
|
|
146
|
+
expect(second).toEqual({
|
|
147
|
+
ok: false,
|
|
148
|
+
error: { code: "not-held", proposalId: held.proposalId },
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
/**
|
|
152
|
+
* The same property under concurrency, which is where an implementation that
|
|
153
|
+
* reads and then deletes in two steps differs from one that takes in one.
|
|
154
|
+
* Sequential release cannot tell them apart; this can.
|
|
155
|
+
*/
|
|
156
|
+
it("releases exactly once when two callers race", async () => {
|
|
157
|
+
const store = await makeStore();
|
|
158
|
+
const held = heldProposalFixture();
|
|
159
|
+
await store.hold(held);
|
|
160
|
+
const outcomes = await Promise.all([
|
|
161
|
+
store.release(held.proposalId),
|
|
162
|
+
store.release(held.proposalId),
|
|
163
|
+
store.release(held.proposalId),
|
|
164
|
+
]);
|
|
165
|
+
expect(outcomes.filter((outcome) => outcome.ok)).toHaveLength(1);
|
|
166
|
+
});
|
|
167
|
+
it("cannot be read after it is released", async () => {
|
|
168
|
+
const store = await makeStore();
|
|
169
|
+
const held = heldProposalFixture();
|
|
170
|
+
await store.hold(held);
|
|
171
|
+
await store.release(held.proposalId);
|
|
172
|
+
expect((await store.get(held.proposalId)).ok).toBe(false);
|
|
173
|
+
});
|
|
174
|
+
/** Answering frees the id, because a repair may be held under a fresh one. */
|
|
175
|
+
it("can hold a proposal again once it has been released", async () => {
|
|
176
|
+
const store = await makeStore();
|
|
177
|
+
const held = heldProposalFixture();
|
|
178
|
+
await store.hold(held);
|
|
179
|
+
await store.release(held.proposalId);
|
|
180
|
+
expect((await store.hold(held)).ok).toBe(true);
|
|
181
|
+
});
|
|
182
|
+
it("lists only the proposals held against the tree asked about", async () => {
|
|
183
|
+
const store = await makeStore();
|
|
184
|
+
const mine = heldProposalFixture();
|
|
185
|
+
const theirs = heldProposalFixture({ treeId: treeIdSchema.parse("t_elsewhere") });
|
|
186
|
+
await store.hold(mine);
|
|
187
|
+
await store.hold(theirs);
|
|
188
|
+
const listed = await store.forTree(mine.treeId);
|
|
189
|
+
if (!listed.ok)
|
|
190
|
+
throw new Error("expected a listing");
|
|
191
|
+
expect(listed.value.held.map((entry) => entry.proposalId)).toEqual([mine.proposalId]);
|
|
192
|
+
});
|
|
193
|
+
/**
|
|
194
|
+
* The half of the listing every implementation has to answer even when it
|
|
195
|
+
* has nothing to say. A store that omitted the field — or left it
|
|
196
|
+
* `undefined` when all was well — would make every caller check whether it
|
|
197
|
+
* was handed a listing or an older one, which is the branch the shape
|
|
198
|
+
* exists to remove.
|
|
199
|
+
*/
|
|
200
|
+
it("reports nothing unreadable when every row parses, in both listings", async () => {
|
|
201
|
+
const store = await makeStore();
|
|
202
|
+
const held = heldProposalFixture();
|
|
203
|
+
await store.hold(held);
|
|
204
|
+
const listed = await store.forTree(held.treeId);
|
|
205
|
+
const page = await store.waiting();
|
|
206
|
+
if (!listed.ok || !page.ok)
|
|
207
|
+
throw new Error("expected both listings");
|
|
208
|
+
expect(listed.value.unreadable).toEqual([]);
|
|
209
|
+
expect(page.value.unreadable).toEqual([]);
|
|
210
|
+
});
|
|
211
|
+
it("lists a tree with nothing held as empty rather than as missing", async () => {
|
|
212
|
+
const store = await makeStore();
|
|
213
|
+
const { tree } = sampleTree();
|
|
214
|
+
expect(await store.forTree(tree.treeId)).toEqual({
|
|
215
|
+
ok: true,
|
|
216
|
+
value: { held: [], unreadable: [] },
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
/** Oldest first, because the oldest hold is the one closest to going stale. */
|
|
220
|
+
it("orders a listing by when each proposal was held", async () => {
|
|
221
|
+
const store = await makeStore();
|
|
222
|
+
const later = heldProposalFixture({ heldAt: "2026-07-30T12:00:00.000Z" });
|
|
223
|
+
const earlier = heldProposalFixture({ heldAt: "2026-07-30T09:00:00.000Z" });
|
|
224
|
+
await store.hold(later);
|
|
225
|
+
await store.hold(earlier);
|
|
226
|
+
const listed = await store.forTree(later.treeId);
|
|
227
|
+
if (!listed.ok)
|
|
228
|
+
throw new Error("expected a listing");
|
|
229
|
+
expect(listed.value.held.map((entry) => entry.heldAt)).toEqual([earlier.heldAt, later.heldAt]);
|
|
230
|
+
});
|
|
231
|
+
/**
|
|
232
|
+
* The tiebreak, and it is not an edge case: every fixture shares one instant
|
|
233
|
+
* unless a test says otherwise, which is exactly the shape a real request
|
|
234
|
+
* produces when the Gate holds two changes in one judgement. Without it the
|
|
235
|
+
* two implementations sort ties however their backend happens to, and a
|
|
236
|
+
* cursor taken from one of those pages means nothing.
|
|
237
|
+
*/
|
|
238
|
+
it("breaks a tie on the same instant by proposal id, in both listings", async () => {
|
|
239
|
+
const store = await makeStore();
|
|
240
|
+
const first = heldProposalFixture();
|
|
241
|
+
const second = heldProposalFixture();
|
|
242
|
+
const [earlier, later] = first.proposalId < second.proposalId ? [first, second] : [second, first];
|
|
243
|
+
await store.hold(later);
|
|
244
|
+
await store.hold(earlier);
|
|
245
|
+
const listed = await store.forTree(first.treeId);
|
|
246
|
+
const page = await store.waiting();
|
|
247
|
+
if (!listed.ok || !page.ok)
|
|
248
|
+
throw new Error("expected both listings");
|
|
249
|
+
expect(listed.value.held.map((entry) => entry.proposalId)).toEqual([
|
|
250
|
+
earlier.proposalId,
|
|
251
|
+
later.proposalId,
|
|
252
|
+
]);
|
|
253
|
+
expect(page.value.held.map((entry) => entry.proposalId)).toEqual([
|
|
254
|
+
earlier.proposalId,
|
|
255
|
+
later.proposalId,
|
|
256
|
+
]);
|
|
257
|
+
});
|
|
258
|
+
/**
|
|
259
|
+
* The read `forTree` cannot be assembled from: answering "does anything need
|
|
260
|
+
* me" by listing trees and asking each one is O(pages) queries over a listing
|
|
261
|
+
* that is itself bounded, so it is both slow and unable to be complete.
|
|
262
|
+
*/
|
|
263
|
+
it("lists what is held across every tree, oldest first", async () => {
|
|
264
|
+
const store = await makeStore();
|
|
265
|
+
const mine = heldProposalFixture({ heldAt: "2026-07-30T12:00:00.000Z" });
|
|
266
|
+
const theirs = heldProposalFixture({
|
|
267
|
+
treeId: treeIdSchema.parse("t_elsewhere"),
|
|
268
|
+
heldAt: "2026-07-30T09:00:00.000Z",
|
|
269
|
+
});
|
|
270
|
+
await store.hold(mine);
|
|
271
|
+
await store.hold(theirs);
|
|
272
|
+
const page = await store.waiting();
|
|
273
|
+
if (!page.ok)
|
|
274
|
+
throw new Error("expected a page");
|
|
275
|
+
expect(page.value.held.map((entry) => entry.proposalId)).toEqual([
|
|
276
|
+
theirs.proposalId,
|
|
277
|
+
mine.proposalId,
|
|
278
|
+
]);
|
|
279
|
+
expect(page.value.cursor).toBeNull();
|
|
280
|
+
});
|
|
281
|
+
it("reports an empty deployment as an empty page rather than as a failure", async () => {
|
|
282
|
+
const store = await makeStore();
|
|
283
|
+
expect(await store.waiting()).toEqual({
|
|
284
|
+
ok: true,
|
|
285
|
+
value: { held: [], unreadable: [], cursor: null },
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
/**
|
|
289
|
+
* The property that makes a cursor worth having: every hold appears exactly
|
|
290
|
+
* once across the pages, in order, and the last page says it is the last.
|
|
291
|
+
*/
|
|
292
|
+
it("pages through everything held without repeating or skipping one", async () => {
|
|
293
|
+
const store = await makeStore();
|
|
294
|
+
const holds = [0, 1, 2, 3, 4].map((minute) => heldProposalFixture({ heldAt: `2026-07-30T09:0${minute}:00.000Z` }));
|
|
295
|
+
for (const held of holds)
|
|
296
|
+
await store.hold(held);
|
|
297
|
+
const seen = [];
|
|
298
|
+
let cursor = null;
|
|
299
|
+
do {
|
|
300
|
+
const page = await store.waiting({
|
|
301
|
+
limit: 2,
|
|
302
|
+
...(cursor === null ? {} : { cursor }),
|
|
303
|
+
});
|
|
304
|
+
if (!page.ok)
|
|
305
|
+
throw new Error("expected a page");
|
|
306
|
+
seen.push(...page.value.held.map((entry) => entry.proposalId));
|
|
307
|
+
cursor = page.value.cursor;
|
|
308
|
+
} while (cursor !== null);
|
|
309
|
+
expect(seen).toEqual(holds.map((held) => held.proposalId));
|
|
310
|
+
});
|
|
311
|
+
/**
|
|
312
|
+
* A queue is paged through while people are emptying it, so the hold a
|
|
313
|
+
* cursor names is routinely gone by the time it is used. Resuming from the
|
|
314
|
+
* position rather than from the row is what makes that safe.
|
|
315
|
+
*/
|
|
316
|
+
it("resumes from a cursor whose hold has since been answered", async () => {
|
|
317
|
+
const store = await makeStore();
|
|
318
|
+
const answered = heldProposalFixture({ heldAt: "2026-07-30T09:00:00.000Z" });
|
|
319
|
+
const next = heldProposalFixture({ heldAt: "2026-07-30T09:01:00.000Z" });
|
|
320
|
+
const last = heldProposalFixture({ heldAt: "2026-07-30T09:02:00.000Z" });
|
|
321
|
+
for (const held of [answered, next, last])
|
|
322
|
+
await store.hold(held);
|
|
323
|
+
const first = await store.waiting({ limit: 1 });
|
|
324
|
+
if (!first.ok || first.value.cursor === null)
|
|
325
|
+
throw new Error("expected a first page");
|
|
326
|
+
await store.release(answered.proposalId);
|
|
327
|
+
const second = await store.waiting({ cursor: first.value.cursor });
|
|
328
|
+
if (!second.ok)
|
|
329
|
+
throw new Error("expected a second page");
|
|
330
|
+
expect(second.value.held.map((entry) => entry.proposalId)).toEqual([
|
|
331
|
+
next.proposalId,
|
|
332
|
+
last.proposalId,
|
|
333
|
+
]);
|
|
334
|
+
});
|
|
335
|
+
/**
|
|
336
|
+
* Unreadable means the same thing to every implementation — start at the
|
|
337
|
+
* beginning — rather than one refusing what another silently accepts. A
|
|
338
|
+
* cursor is a value that has been through a URL, so this is the case that
|
|
339
|
+
* actually arrives.
|
|
340
|
+
*/
|
|
341
|
+
it("starts at the beginning when handed a cursor it cannot read", async () => {
|
|
342
|
+
const store = await makeStore();
|
|
343
|
+
const held = heldProposalFixture();
|
|
344
|
+
await store.hold(held);
|
|
345
|
+
const page = await store.waiting({ cursor: "not a cursor" });
|
|
346
|
+
if (!page.ok)
|
|
347
|
+
throw new Error("expected a page");
|
|
348
|
+
expect(page.value.held.map((entry) => entry.proposalId)).toEqual([held.proposalId]);
|
|
349
|
+
});
|
|
350
|
+
it("drops a released proposal from the deployment-wide listing too", async () => {
|
|
351
|
+
const store = await makeStore();
|
|
352
|
+
const held = heldProposalFixture();
|
|
353
|
+
await store.hold(held);
|
|
354
|
+
await store.release(held.proposalId);
|
|
355
|
+
expect(await store.waiting()).toEqual({
|
|
356
|
+
ok: true,
|
|
357
|
+
value: { held: [], unreadable: [], cursor: null },
|
|
358
|
+
});
|
|
359
|
+
});
|
|
360
|
+
it("drops a released proposal from the listing", async () => {
|
|
361
|
+
const store = await makeStore();
|
|
362
|
+
const first = heldProposalFixture({ heldAt: "2026-07-30T09:00:00.000Z" });
|
|
363
|
+
const second = heldProposalFixture({ heldAt: "2026-07-30T12:00:00.000Z" });
|
|
364
|
+
await store.hold(first);
|
|
365
|
+
await store.hold(second);
|
|
366
|
+
await store.release(first.proposalId);
|
|
367
|
+
const listed = await store.forTree(first.treeId);
|
|
368
|
+
if (!listed.ok)
|
|
369
|
+
throw new Error("expected a listing");
|
|
370
|
+
expect(listed.value.held.map((entry) => entry.proposalId)).toEqual([second.proposalId]);
|
|
371
|
+
});
|
|
372
|
+
});
|
|
373
|
+
};
|
|
374
|
+
//# sourceMappingURL=hold-contract.js.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The fixtures and doubles a host can import, published as `@jam-overture/loom/testing`.
|
|
3
|
+
*
|
|
4
|
+
* Everything in this directory existed already and was reachable only from
|
|
5
|
+
* inside the repository: `src/testing/**` was excluded from the build, so
|
|
6
|
+
* `dist/testing/` did not exist and there was no entry point that could have
|
|
7
|
+
* named it. That was right while the only consumer was this package's own
|
|
8
|
+
* suite. It stopped being right when three consumers outside it appeared —
|
|
9
|
+
* the course, whose seventeen most-imported fences all start with
|
|
10
|
+
* `sampleTree()`; a host implementing a tree store, whose only way to know it
|
|
11
|
+
* is correct is the suite this package already runs against its own; and
|
|
12
|
+
* anybody writing a primitive, who wants a registry to register it in.
|
|
13
|
+
*
|
|
14
|
+
* The alternative each of them faces without this is to reimplement the
|
|
15
|
+
* fixture, which is the worst outcome available: a `sampleTree` that agrees
|
|
16
|
+
* with the lesson and disagrees with Loom. Publishing it is what makes the
|
|
17
|
+
* fixture *the* fixture rather than one of several.
|
|
18
|
+
*
|
|
19
|
+
* **What is here is a promise, and what is not here is not.** A published
|
|
20
|
+
* entry point is API: `sampleTree`'s shape is now something a host may depend
|
|
21
|
+
* on and this package may not silently change. So this file names its exports
|
|
22
|
+
* one module at a time rather than re-exporting the directory, and two modules
|
|
23
|
+
* are deliberately absent — `row-security.ts`, which asks a live Postgres about
|
|
24
|
+
* a table and belongs with the contract suites, and nothing else. A module
|
|
25
|
+
* added to this directory is internal until a line here says otherwise.
|
|
26
|
+
*
|
|
27
|
+
* **Nothing reachable from this file imports a test framework.** The contract
|
|
28
|
+
* suites do — they are `describe` blocks, that is what they are for — and they
|
|
29
|
+
* live at [`contracts.ts`](./contracts.ts) behind a second entry point for
|
|
30
|
+
* exactly that reason. This one is loadable anywhere the runtime is, including
|
|
31
|
+
* a browser, which is the property the course's in-page runner needs and the
|
|
32
|
+
* one `surface.test.ts` holds.
|
|
33
|
+
*/
|
|
34
|
+
export { cardDefinition, footerDefinition, headerDefinition, pageDefinition, registryOf, testDefinitions, testRegistry, } from "./definitions.js";
|
|
35
|
+
export { buildIntent, buildProposal, collectingEventSink, failingEventSink, fixedClock, FIXED_INSTANT, hangingModelClient, scriptedInterpreter, scriptedModelClient, scriptedRepairer, type CollectingEventSink, type HangingModelClient, type IntentDraft, type ProposalDraft, type RecordingInterpreter, type RecordingModelClient, type RecordingRepairer, } from "./doubles.js";
|
|
36
|
+
export { harnessWith, proposalScript, removalDelta, type EpisodeHarness, } from "./episode-harness.js";
|
|
37
|
+
export { memoryFileSystem, type MemoryFileSystem, type MemoryFileSystemOptions, } from "./filesystem.js";
|
|
38
|
+
export { formTree, sampleTree, type FormTree, type SampleTree } from "./fixtures.js";
|
|
39
|
+
export { CONFIGURE_CARD_REPLY, FOREIGN_ID_REPLY, INSERT_NOTE_REPLY, INSERT_SLOT_REPLY, NON_OBJECT_PROPS_REPLY, NOT_UNDERSTOOD_REPLY, NO_CHANGE_REPLY, OFF_SCHEMA_REPLY, TRUNCATED_REPLY, UNDECODABLE_PROP_REPLY, } from "./model-replies.js";
|
|
40
|
+
export { testPrimitiveResolver, testPrimitives, undecoratedPrimitive, } from "./primitives.js";
|
|
41
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The fixtures and doubles a host can import, published as `@jam-overture/loom/testing`.
|
|
3
|
+
*
|
|
4
|
+
* Everything in this directory existed already and was reachable only from
|
|
5
|
+
* inside the repository: `src/testing/**` was excluded from the build, so
|
|
6
|
+
* `dist/testing/` did not exist and there was no entry point that could have
|
|
7
|
+
* named it. That was right while the only consumer was this package's own
|
|
8
|
+
* suite. It stopped being right when three consumers outside it appeared —
|
|
9
|
+
* the course, whose seventeen most-imported fences all start with
|
|
10
|
+
* `sampleTree()`; a host implementing a tree store, whose only way to know it
|
|
11
|
+
* is correct is the suite this package already runs against its own; and
|
|
12
|
+
* anybody writing a primitive, who wants a registry to register it in.
|
|
13
|
+
*
|
|
14
|
+
* The alternative each of them faces without this is to reimplement the
|
|
15
|
+
* fixture, which is the worst outcome available: a `sampleTree` that agrees
|
|
16
|
+
* with the lesson and disagrees with Loom. Publishing it is what makes the
|
|
17
|
+
* fixture *the* fixture rather than one of several.
|
|
18
|
+
*
|
|
19
|
+
* **What is here is a promise, and what is not here is not.** A published
|
|
20
|
+
* entry point is API: `sampleTree`'s shape is now something a host may depend
|
|
21
|
+
* on and this package may not silently change. So this file names its exports
|
|
22
|
+
* one module at a time rather than re-exporting the directory, and two modules
|
|
23
|
+
* are deliberately absent — `row-security.ts`, which asks a live Postgres about
|
|
24
|
+
* a table and belongs with the contract suites, and nothing else. A module
|
|
25
|
+
* added to this directory is internal until a line here says otherwise.
|
|
26
|
+
*
|
|
27
|
+
* **Nothing reachable from this file imports a test framework.** The contract
|
|
28
|
+
* suites do — they are `describe` blocks, that is what they are for — and they
|
|
29
|
+
* live at [`contracts.ts`](./contracts.ts) behind a second entry point for
|
|
30
|
+
* exactly that reason. This one is loadable anywhere the runtime is, including
|
|
31
|
+
* a browser, which is the property the course's in-page runner needs and the
|
|
32
|
+
* one `surface.test.ts` holds.
|
|
33
|
+
*/
|
|
34
|
+
export { cardDefinition, footerDefinition, headerDefinition, pageDefinition, registryOf, testDefinitions, testRegistry, } from "./definitions.js";
|
|
35
|
+
export { buildIntent, buildProposal, collectingEventSink, failingEventSink, fixedClock, FIXED_INSTANT, hangingModelClient, scriptedInterpreter, scriptedModelClient, scriptedRepairer, } from "./doubles.js";
|
|
36
|
+
export { harnessWith, proposalScript, removalDelta, } from "./episode-harness.js";
|
|
37
|
+
export { memoryFileSystem, } from "./filesystem.js";
|
|
38
|
+
export { formTree, sampleTree } from "./fixtures.js";
|
|
39
|
+
export { CONFIGURE_CARD_REPLY, FOREIGN_ID_REPLY, INSERT_NOTE_REPLY, INSERT_SLOT_REPLY, NON_OBJECT_PROPS_REPLY, NOT_UNDERSTOOD_REPLY, NO_CHANGE_REPLY, OFF_SCHEMA_REPLY, TRUNCATED_REPLY, UNDECODABLE_PROP_REPLY, } from "./model-replies.js";
|
|
40
|
+
export { testPrimitiveResolver, testPrimitives, undecoratedPrimitive, } from "./primitives.js";
|
|
41
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type TelemetryJournal, type TelemetryRecord } from "../telemetry/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* One suite, run against every `TelemetryJournal`.
|
|
4
|
+
*
|
|
5
|
+
* The same argument as `store-contract.ts`: an interface is only tested once a
|
|
6
|
+
* second implementation exists, and a disagreement between the in-memory
|
|
7
|
+
* journal and Postgres should be a test failure rather than something noticed
|
|
8
|
+
* in an analysis six weeks later.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* A whole episode, narrated: an intent, the proposal it produced, the Gate
|
|
12
|
+
* accepting it, and the change landing. Built through `recordOf` rather than by
|
|
13
|
+
* hand so the suite exercises the narrowing every host will use.
|
|
14
|
+
*/
|
|
15
|
+
export declare const sampleEpisode: (namespace?: string) => readonly TelemetryRecord[];
|
|
16
|
+
export declare const describeTelemetryJournalContract: (name: string, makeJournal: () => Promise<TelemetryJournal> | TelemetryJournal) => void;
|
|
17
|
+
//# sourceMappingURL=journal-contract.d.ts.map
|