@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,353 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { sequentialIdFactory, treeIdSchema } from "../ids.js";
|
|
3
|
+
import { recordOf } from "../telemetry/index.js";
|
|
4
|
+
import { buildElement } from "../tree/builders.js";
|
|
5
|
+
import { createTree } from "../tree/tree.js";
|
|
6
|
+
import { buildIntent, buildProposal, FIXED_INSTANT } from "./doubles.js";
|
|
7
|
+
/**
|
|
8
|
+
* One suite, run against every `TelemetryJournal`.
|
|
9
|
+
*
|
|
10
|
+
* The same argument as `store-contract.ts`: an interface is only tested once a
|
|
11
|
+
* second implementation exists, and a disagreement between the in-memory
|
|
12
|
+
* journal and Postgres should be a test failure rather than something noticed
|
|
13
|
+
* in an analysis six weeks later.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* A whole episode, narrated: an intent, the proposal it produced, the Gate
|
|
17
|
+
* accepting it, and the change landing. Built through `recordOf` rather than by
|
|
18
|
+
* hand so the suite exercises the narrowing every host will use.
|
|
19
|
+
*/
|
|
20
|
+
export const sampleEpisode = (namespace = "j") => {
|
|
21
|
+
const ids = sequentialIdFactory(namespace);
|
|
22
|
+
const tree = createTree(buildElement(ids, { type: "loom.page" }), ids);
|
|
23
|
+
const intent = buildIntent(ids, { treeId: tree.treeId, baseRevision: 0 });
|
|
24
|
+
const proposal = buildProposal(ids, {
|
|
25
|
+
intentId: intent.intentId,
|
|
26
|
+
delta: {
|
|
27
|
+
deltaId: ids.deltaId(),
|
|
28
|
+
treeId: tree.treeId,
|
|
29
|
+
baseRevision: 0,
|
|
30
|
+
operations: [
|
|
31
|
+
{ op: "insert", parentId: tree.root.id, index: 0, node: buildElement(ids, { type: "loom.card" }) },
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
const envelope = (event) => recordOf({ treeId: tree.treeId, occurredAt: FIXED_INSTANT, event });
|
|
36
|
+
return [
|
|
37
|
+
envelope({ type: "intent-received", intent }),
|
|
38
|
+
envelope({ type: "change-proposed", proposal }),
|
|
39
|
+
envelope({
|
|
40
|
+
type: "disposition-decided",
|
|
41
|
+
proposalId: proposal.proposalId,
|
|
42
|
+
disposition: {
|
|
43
|
+
kind: "accepted",
|
|
44
|
+
reason: { code: "within-policy", detail: "low stakes, reversible" },
|
|
45
|
+
stakes: "low",
|
|
46
|
+
reversible: true,
|
|
47
|
+
confidence: 0.9,
|
|
48
|
+
policyId: "default",
|
|
49
|
+
},
|
|
50
|
+
}),
|
|
51
|
+
envelope({ type: "change-committed", proposalId: proposal.proposalId, revision: 1 }),
|
|
52
|
+
];
|
|
53
|
+
};
|
|
54
|
+
const recordsFor = (treeId, count) => Array.from({ length: count }, (_, index) => ({
|
|
55
|
+
treeId,
|
|
56
|
+
occurredAt: FIXED_INSTANT,
|
|
57
|
+
event: {
|
|
58
|
+
type: "hold-confirmed",
|
|
59
|
+
proposalId: sequentialIdFactory(`p${index}`).proposalId(),
|
|
60
|
+
},
|
|
61
|
+
}));
|
|
62
|
+
const typesOf = (records) => records.map((record) => record.event.type);
|
|
63
|
+
export const describeTelemetryJournalContract = (name, makeJournal) => {
|
|
64
|
+
const freshJournal = async () => await makeJournal();
|
|
65
|
+
describe(`${name} — TelemetryJournal contract`, () => {
|
|
66
|
+
it("reads back a batch in the order it arrived", async () => {
|
|
67
|
+
const journal = await freshJournal();
|
|
68
|
+
const episode = sampleEpisode();
|
|
69
|
+
expect(await journal.record(episode)).toEqual({ ok: true, value: undefined });
|
|
70
|
+
const page = await journal.read();
|
|
71
|
+
expect(page.ok && typesOf(page.value.records)).toEqual(typesOf(episode));
|
|
72
|
+
expect(page.ok && page.value.older).toBeNull();
|
|
73
|
+
expect(page.ok && page.value.newer).toBeNull();
|
|
74
|
+
});
|
|
75
|
+
/** A journal makes no claim that a tree exists, so nothing here is `not-found`. */
|
|
76
|
+
it("reads a tree it has never heard of as an empty page", async () => {
|
|
77
|
+
const journal = await freshJournal();
|
|
78
|
+
expect(await journal.read({ treeId: treeIdSchema.parse("t_absent") })).toEqual({
|
|
79
|
+
ok: true,
|
|
80
|
+
value: { records: [], older: null, newer: null },
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
it("accepts an empty batch", async () => {
|
|
84
|
+
const journal = await freshJournal();
|
|
85
|
+
expect(await journal.record([])).toEqual({ ok: true, value: undefined });
|
|
86
|
+
expect(await journal.read()).toEqual({
|
|
87
|
+
ok: true,
|
|
88
|
+
value: { records: [], older: null, newer: null },
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
it("survives the round trip with the proposal intact", async () => {
|
|
92
|
+
const journal = await freshJournal();
|
|
93
|
+
const episode = sampleEpisode();
|
|
94
|
+
await journal.record(episode);
|
|
95
|
+
const page = await journal.read();
|
|
96
|
+
const proposed = page.ok
|
|
97
|
+
? page.value.records.find((record) => record.event.type === "change-proposed")
|
|
98
|
+
: undefined;
|
|
99
|
+
expect(proposed?.event).toEqual(episode[1]?.event);
|
|
100
|
+
});
|
|
101
|
+
it("keeps trees apart", async () => {
|
|
102
|
+
const journal = await freshJournal();
|
|
103
|
+
const mine = treeIdSchema.parse("t_mine");
|
|
104
|
+
const yours = treeIdSchema.parse("t_yours");
|
|
105
|
+
await journal.record([...recordsFor(mine, 2), ...recordsFor(yours, 3)]);
|
|
106
|
+
const page = await journal.read({ treeId: yours });
|
|
107
|
+
expect(page.ok && page.value.records).toHaveLength(3);
|
|
108
|
+
expect(page.ok && page.value.records.every((record) => record.treeId === yours)).toBe(true);
|
|
109
|
+
});
|
|
110
|
+
/**
|
|
111
|
+
* Retention measures age against this, so an implementation that left it to
|
|
112
|
+
* the writer would let a writer decide how long its own records live.
|
|
113
|
+
*/
|
|
114
|
+
it("stamps an arrival instant the writer never supplied", async () => {
|
|
115
|
+
const journal = await freshJournal();
|
|
116
|
+
const before = new Date().toISOString();
|
|
117
|
+
await journal.record(sampleEpisode());
|
|
118
|
+
const page = await journal.read();
|
|
119
|
+
const stamps = page.ok ? page.value.records.map((record) => record.recordedAt) : [];
|
|
120
|
+
expect(stamps).toHaveLength(4);
|
|
121
|
+
expect(stamps.every((stamp) => stamp >= before)).toBe(true);
|
|
122
|
+
expect(stamps.every((stamp) => Number.isFinite(Date.parse(stamp)))).toBe(true);
|
|
123
|
+
/** `occurredAt` is the host's fixture instant, years apart from arrival. */
|
|
124
|
+
expect(stamps.every((stamp) => stamp !== FIXED_INSTANT)).toBe(true);
|
|
125
|
+
});
|
|
126
|
+
it("increases seq across separate batches", async () => {
|
|
127
|
+
const journal = await freshJournal();
|
|
128
|
+
const treeId = treeIdSchema.parse("t_seq");
|
|
129
|
+
await journal.record(recordsFor(treeId, 2));
|
|
130
|
+
await journal.record(recordsFor(treeId, 2));
|
|
131
|
+
const page = await journal.read();
|
|
132
|
+
const seqs = page.ok ? page.value.records.map((record) => record.seq) : [];
|
|
133
|
+
expect(seqs).toHaveLength(4);
|
|
134
|
+
expect(seqs.every((seq, index) => index === 0 || seq > (seqs[index - 1] ?? 0))).toBe(true);
|
|
135
|
+
});
|
|
136
|
+
describe("paging", () => {
|
|
137
|
+
it("hands back a cursor and resumes after it", async () => {
|
|
138
|
+
const journal = await freshJournal();
|
|
139
|
+
const treeId = treeIdSchema.parse("t_paged");
|
|
140
|
+
await journal.record(recordsFor(treeId, 5));
|
|
141
|
+
const first = await journal.read({ limit: 2 });
|
|
142
|
+
expect(first.ok && first.value.records).toHaveLength(2);
|
|
143
|
+
expect(first.ok && first.value.newer).not.toBeNull();
|
|
144
|
+
const second = await journal.read({
|
|
145
|
+
limit: 2,
|
|
146
|
+
...(first.ok && first.value.newer ? { cursor: first.value.newer } : {}),
|
|
147
|
+
});
|
|
148
|
+
expect(second.ok && second.value.records).toHaveLength(2);
|
|
149
|
+
expect(first.ok && second.ok && first.value.records[0]?.seq !== second.value.records[0]?.seq).toBe(true);
|
|
150
|
+
});
|
|
151
|
+
it("reports no cursor on the last page", async () => {
|
|
152
|
+
const journal = await freshJournal();
|
|
153
|
+
const treeId = treeIdSchema.parse("t_last");
|
|
154
|
+
await journal.record(recordsFor(treeId, 2));
|
|
155
|
+
const page = await journal.read({ limit: 2 });
|
|
156
|
+
expect(page.ok && page.value.records).toHaveLength(2);
|
|
157
|
+
expect(page.ok && page.value.newer).toBeNull();
|
|
158
|
+
});
|
|
159
|
+
it("clamps a limit rather than honouring it", async () => {
|
|
160
|
+
const journal = await freshJournal();
|
|
161
|
+
const treeId = treeIdSchema.parse("t_clamped");
|
|
162
|
+
await journal.record(recordsFor(treeId, 3));
|
|
163
|
+
const page = await journal.read({ limit: 0 });
|
|
164
|
+
expect(page.ok && page.value.records).toHaveLength(1);
|
|
165
|
+
});
|
|
166
|
+
/** A cursor is opaque, so an unreadable one means the same to every implementation. */
|
|
167
|
+
it("starts from the beginning when the cursor cannot be read", async () => {
|
|
168
|
+
const journal = await freshJournal();
|
|
169
|
+
const treeId = treeIdSchema.parse("t_bad");
|
|
170
|
+
await journal.record(recordsFor(treeId, 3));
|
|
171
|
+
const page = await journal.read({ cursor: "not-a-position" });
|
|
172
|
+
expect(page.ok && page.value.records).toHaveLength(3);
|
|
173
|
+
});
|
|
174
|
+
it("reads an empty page past the end", async () => {
|
|
175
|
+
const journal = await freshJournal();
|
|
176
|
+
const treeId = treeIdSchema.parse("t_end");
|
|
177
|
+
await journal.record(recordsFor(treeId, 2));
|
|
178
|
+
const all = await journal.read();
|
|
179
|
+
const last = all.ok ? all.value.records.at(-1) : undefined;
|
|
180
|
+
const past = await journal.read({ cursor: String(last?.seq ?? 0) });
|
|
181
|
+
expect(past).toEqual({ ok: true, value: { records: [], older: null, newer: null } });
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
/**
|
|
185
|
+
* The destructive half. Every rule about *what* may go lives in
|
|
186
|
+
* `retention.ts`; what a journal owes is that a position means the same
|
|
187
|
+
* thing to both implementations, and that a prune never reshuffles what
|
|
188
|
+
* survives it.
|
|
189
|
+
*/
|
|
190
|
+
describe("forgetting", () => {
|
|
191
|
+
const seqsAfter = async (journal) => {
|
|
192
|
+
const page = await journal.read();
|
|
193
|
+
return page.ok ? page.value.records.map((record) => record.seq) : [];
|
|
194
|
+
};
|
|
195
|
+
it("drops the records below a position and keeps the rest", async () => {
|
|
196
|
+
const journal = await freshJournal();
|
|
197
|
+
const treeId = treeIdSchema.parse("t_forget");
|
|
198
|
+
await journal.record(recordsFor(treeId, 4));
|
|
199
|
+
const all = await seqsAfter(journal);
|
|
200
|
+
const cut = all[2] ?? 0;
|
|
201
|
+
expect(await journal.forget({ before: cut })).toEqual({
|
|
202
|
+
ok: true,
|
|
203
|
+
value: { removed: 2 },
|
|
204
|
+
});
|
|
205
|
+
expect(await seqsAfter(journal)).toEqual(all.slice(2));
|
|
206
|
+
});
|
|
207
|
+
it("forgets nothing when the position is at or below the oldest record", async () => {
|
|
208
|
+
const journal = await freshJournal();
|
|
209
|
+
const treeId = treeIdSchema.parse("t_nofor");
|
|
210
|
+
await journal.record(recordsFor(treeId, 3));
|
|
211
|
+
const all = await seqsAfter(journal);
|
|
212
|
+
expect(await journal.forget({ before: all[0] ?? 0 })).toEqual({
|
|
213
|
+
ok: true,
|
|
214
|
+
value: { removed: 0 },
|
|
215
|
+
});
|
|
216
|
+
expect(await seqsAfter(journal)).toEqual(all);
|
|
217
|
+
});
|
|
218
|
+
it("forgets across every tree it holds, because a position is journal-wide", async () => {
|
|
219
|
+
const journal = await freshJournal();
|
|
220
|
+
const mine = treeIdSchema.parse("t_fmine");
|
|
221
|
+
const yours = treeIdSchema.parse("t_fyours");
|
|
222
|
+
await journal.record([...recordsFor(mine, 2), ...recordsFor(yours, 2)]);
|
|
223
|
+
const all = await seqsAfter(journal);
|
|
224
|
+
const forgotten = await journal.forget({ before: all[3] ?? 0 });
|
|
225
|
+
expect(forgotten).toEqual({ ok: true, value: { removed: 3 } });
|
|
226
|
+
expect(await journal.read({ treeId: mine })).toMatchObject({
|
|
227
|
+
ok: true,
|
|
228
|
+
value: { records: [] },
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
/** Idempotent, so a retention run that repeats after a timeout is harmless. */
|
|
232
|
+
it("is a no-op the second time", async () => {
|
|
233
|
+
const journal = await freshJournal();
|
|
234
|
+
const treeId = treeIdSchema.parse("t_twice");
|
|
235
|
+
await journal.record(recordsFor(treeId, 3));
|
|
236
|
+
const all = await seqsAfter(journal);
|
|
237
|
+
await journal.forget({ before: all[1] ?? 0 });
|
|
238
|
+
expect(await journal.forget({ before: all[1] ?? 0 })).toEqual({
|
|
239
|
+
ok: true,
|
|
240
|
+
value: { removed: 0 },
|
|
241
|
+
});
|
|
242
|
+
expect(await seqsAfter(journal)).toEqual(all.slice(1));
|
|
243
|
+
});
|
|
244
|
+
/**
|
|
245
|
+
* A forgotten position is never handed out again. A reader holding a
|
|
246
|
+
* cursor across a prune would otherwise resume inside records it has
|
|
247
|
+
* already read, and think the journal had gone backwards.
|
|
248
|
+
*/
|
|
249
|
+
it("does not reuse the positions it forgot", async () => {
|
|
250
|
+
const journal = await freshJournal();
|
|
251
|
+
const treeId = treeIdSchema.parse("t_reuse");
|
|
252
|
+
await journal.record(recordsFor(treeId, 3));
|
|
253
|
+
const all = await seqsAfter(journal);
|
|
254
|
+
await journal.forget({ before: (all.at(-1) ?? 0) + 1 });
|
|
255
|
+
await journal.record(recordsFor(treeId, 1));
|
|
256
|
+
const after = await seqsAfter(journal);
|
|
257
|
+
expect(after).toHaveLength(1);
|
|
258
|
+
expect(after[0]).toBeGreaterThan(all.at(-1) ?? 0);
|
|
259
|
+
});
|
|
260
|
+
it("empties a journal asked to forget everything", async () => {
|
|
261
|
+
const journal = await freshJournal();
|
|
262
|
+
const treeId = treeIdSchema.parse("t_empty");
|
|
263
|
+
await journal.record(recordsFor(treeId, 3));
|
|
264
|
+
const all = await seqsAfter(journal);
|
|
265
|
+
expect(await journal.forget({ before: (all.at(-1) ?? 0) + 1 })).toEqual({
|
|
266
|
+
ok: true,
|
|
267
|
+
value: { removed: 3 },
|
|
268
|
+
});
|
|
269
|
+
expect(await journal.read()).toEqual({
|
|
270
|
+
ok: true,
|
|
271
|
+
value: { records: [], older: null, newer: null },
|
|
272
|
+
});
|
|
273
|
+
});
|
|
274
|
+
it("accepts a position an empty journal has nothing below", async () => {
|
|
275
|
+
const journal = await freshJournal();
|
|
276
|
+
expect(await journal.forget({ before: 1 })).toEqual({ ok: true, value: { removed: 0 } });
|
|
277
|
+
});
|
|
278
|
+
});
|
|
279
|
+
/**
|
|
280
|
+
* The direction a page is taken from, which is the difference between "what
|
|
281
|
+
* happened recently" costing one read and costing every read.
|
|
282
|
+
*/
|
|
283
|
+
describe("paging backwards", () => {
|
|
284
|
+
const seqsOf = (page) => page.ok ? page.value.records.map((record) => record.seq) : [];
|
|
285
|
+
it("reads the newest page when asked for older with no cursor", async () => {
|
|
286
|
+
const journal = await freshJournal();
|
|
287
|
+
const treeId = treeIdSchema.parse("t_newest");
|
|
288
|
+
await journal.record(recordsFor(treeId, 5));
|
|
289
|
+
const all = await journal.read();
|
|
290
|
+
const newest = await journal.read({ direction: "older", limit: 2 });
|
|
291
|
+
expect(seqsOf(newest)).toEqual(seqsOf(all).slice(-2));
|
|
292
|
+
});
|
|
293
|
+
/** Ascending whichever end it came from, so a fold never has to ask which. */
|
|
294
|
+
it("returns a backwards page in arrival order", async () => {
|
|
295
|
+
const journal = await freshJournal();
|
|
296
|
+
const treeId = treeIdSchema.parse("t_order");
|
|
297
|
+
await journal.record(recordsFor(treeId, 4));
|
|
298
|
+
const page = await journal.read({ direction: "older", limit: 3 });
|
|
299
|
+
const seqs = seqsOf(page);
|
|
300
|
+
expect(seqs).toHaveLength(3);
|
|
301
|
+
expect(seqs.every((seq, index) => index === 0 || seq > (seqs[index - 1] ?? 0))).toBe(true);
|
|
302
|
+
});
|
|
303
|
+
it("walks back through the whole journal one page at a time", async () => {
|
|
304
|
+
const journal = await freshJournal();
|
|
305
|
+
const treeId = treeIdSchema.parse("t_walk");
|
|
306
|
+
await journal.record(recordsFor(treeId, 5));
|
|
307
|
+
const seen = [];
|
|
308
|
+
let cursor;
|
|
309
|
+
for (let read = 0; read < 4; read += 1) {
|
|
310
|
+
const page = await journal.read({
|
|
311
|
+
direction: "older",
|
|
312
|
+
limit: 2,
|
|
313
|
+
...(cursor ? { cursor } : {}),
|
|
314
|
+
});
|
|
315
|
+
seen.unshift(...seqsOf(page));
|
|
316
|
+
cursor = page.ok ? page.value.older : null;
|
|
317
|
+
if (cursor === null)
|
|
318
|
+
break;
|
|
319
|
+
}
|
|
320
|
+
expect(seen).toEqual(seqsOf(await journal.read()));
|
|
321
|
+
expect(cursor).toBeNull();
|
|
322
|
+
});
|
|
323
|
+
it("names the newer end once a backwards page has resumed", async () => {
|
|
324
|
+
const journal = await freshJournal();
|
|
325
|
+
const treeId = treeIdSchema.parse("t_both");
|
|
326
|
+
await journal.record(recordsFor(treeId, 5));
|
|
327
|
+
const newest = await journal.read({ direction: "older", limit: 2 });
|
|
328
|
+
expect(newest.ok && newest.value.newer).toBeNull();
|
|
329
|
+
const older = await journal.read({
|
|
330
|
+
direction: "older",
|
|
331
|
+
limit: 2,
|
|
332
|
+
...(newest.ok && newest.value.older ? { cursor: newest.value.older } : {}),
|
|
333
|
+
});
|
|
334
|
+
expect(older.ok && older.value.newer).not.toBeNull();
|
|
335
|
+
const back = await journal.read({
|
|
336
|
+
limit: 2,
|
|
337
|
+
...(older.ok && older.value.newer ? { cursor: older.value.newer } : {}),
|
|
338
|
+
});
|
|
339
|
+
expect(seqsOf(back)).toEqual(seqsOf(newest));
|
|
340
|
+
});
|
|
341
|
+
it("keeps trees apart when reading backwards", async () => {
|
|
342
|
+
const journal = await freshJournal();
|
|
343
|
+
const mine = treeIdSchema.parse("t_mineback");
|
|
344
|
+
const yours = treeIdSchema.parse("t_yoursback");
|
|
345
|
+
await journal.record([...recordsFor(mine, 3), ...recordsFor(yours, 2)]);
|
|
346
|
+
const page = await journal.read({ treeId: mine, direction: "older", limit: 2 });
|
|
347
|
+
expect(page.ok && page.value.records.every((record) => record.treeId === mine)).toBe(true);
|
|
348
|
+
expect(page.ok && page.value.records).toHaveLength(2);
|
|
349
|
+
});
|
|
350
|
+
});
|
|
351
|
+
});
|
|
352
|
+
};
|
|
353
|
+
//# sourceMappingURL=journal-contract.js.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reply bodies of the shape a model produces under the interpreter's output
|
|
3
|
+
* schema, kept as raw strings so tests exercise the parse step rather than
|
|
4
|
+
* starting from an already-decoded object. Node ids refer to `sampleTree`.
|
|
5
|
+
*
|
|
6
|
+
* These stand in for recorded responses: hand-written so the suite is
|
|
7
|
+
* deterministic, offline, and runnable without a key.
|
|
8
|
+
*
|
|
9
|
+
* Props are JSON-encoded objects, per 0014 — a string inside the reply, which is
|
|
10
|
+
* why they read as escaped JSON here.
|
|
11
|
+
*/
|
|
12
|
+
export declare const INSERT_NOTE_REPLY: string;
|
|
13
|
+
export declare const CONFIGURE_CARD_REPLY: string;
|
|
14
|
+
export declare const NO_CHANGE_REPLY: string;
|
|
15
|
+
export declare const NOT_UNDERSTOOD_REPLY: string;
|
|
16
|
+
/** Well-formed JSON, but not a shape the reply schema allows. */
|
|
17
|
+
export declare const OFF_SCHEMA_REPLY: string;
|
|
18
|
+
/** An operation that names a node id the id scheme does not permit. */
|
|
19
|
+
export declare const FOREIGN_ID_REPLY: string;
|
|
20
|
+
/**
|
|
21
|
+
* Passes the schema, because the schema only says "a string", and fails the
|
|
22
|
+
* parse. This is the failure mode accepted in exchange for the grammar budget
|
|
23
|
+
* (0014), so it is a fixture rather than an impossibility.
|
|
24
|
+
*/
|
|
25
|
+
export declare const UNDECODABLE_PROP_REPLY: string;
|
|
26
|
+
/** Parseable JSON, but not an object, so it cannot be a prop bag. */
|
|
27
|
+
export declare const NON_OBJECT_PROPS_REPLY: string;
|
|
28
|
+
/**
|
|
29
|
+
* Passes the schema and the parse, and proposes a slot — which the reply schema
|
|
30
|
+
* no longer offers as an insertable kind, so the draft schema must refuse it.
|
|
31
|
+
*/
|
|
32
|
+
export declare const INSERT_SLOT_REPLY: string;
|
|
33
|
+
export declare const TRUNCATED_REPLY = "{\"outcome\":\"change\",\"rationale\":\"Adds a not";
|
|
34
|
+
//# sourceMappingURL=model-replies.d.ts.map
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reply bodies of the shape a model produces under the interpreter's output
|
|
3
|
+
* schema, kept as raw strings so tests exercise the parse step rather than
|
|
4
|
+
* starting from an already-decoded object. Node ids refer to `sampleTree`.
|
|
5
|
+
*
|
|
6
|
+
* These stand in for recorded responses: hand-written so the suite is
|
|
7
|
+
* deterministic, offline, and runnable without a key.
|
|
8
|
+
*
|
|
9
|
+
* Props are JSON-encoded objects, per 0014 — a string inside the reply, which is
|
|
10
|
+
* why they read as escaped JSON here.
|
|
11
|
+
*/
|
|
12
|
+
export const INSERT_NOTE_REPLY = JSON.stringify({
|
|
13
|
+
outcome: "change",
|
|
14
|
+
rationale: "The footer is empty, so the note goes there as its own element.",
|
|
15
|
+
confidence: 0.86,
|
|
16
|
+
operations: [
|
|
17
|
+
{
|
|
18
|
+
op: "insert",
|
|
19
|
+
parentId: "n_6",
|
|
20
|
+
index: 0,
|
|
21
|
+
node: {
|
|
22
|
+
kind: "element",
|
|
23
|
+
type: "loom.note",
|
|
24
|
+
props: '{"tone":"quiet","dismissible":false}',
|
|
25
|
+
children: [{ kind: "text", value: "Thanks for visiting" }],
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
});
|
|
30
|
+
export const CONFIGURE_CARD_REPLY = JSON.stringify({
|
|
31
|
+
outcome: "change",
|
|
32
|
+
rationale: "Dropping elevation and clearing the variant makes the card quieter.",
|
|
33
|
+
confidence: 0.71,
|
|
34
|
+
operations: [
|
|
35
|
+
{
|
|
36
|
+
op: "configure",
|
|
37
|
+
nodeId: "n_4",
|
|
38
|
+
set: '{"elevation":0,"padding":{"x":2,"y":1}}',
|
|
39
|
+
unset: ["variant"],
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
});
|
|
43
|
+
export const NO_CHANGE_REPLY = JSON.stringify({
|
|
44
|
+
outcome: "no-change",
|
|
45
|
+
rationale: "The page already has a header containing a headline.",
|
|
46
|
+
});
|
|
47
|
+
export const NOT_UNDERSTOOD_REPLY = JSON.stringify({
|
|
48
|
+
outcome: "not-understood",
|
|
49
|
+
rationale: "«make it pop» does not name a node or a prop to change.",
|
|
50
|
+
});
|
|
51
|
+
/** Well-formed JSON, but not a shape the reply schema allows. */
|
|
52
|
+
export const OFF_SCHEMA_REPLY = JSON.stringify({
|
|
53
|
+
outcome: "change",
|
|
54
|
+
rationale: "Adds a note.",
|
|
55
|
+
confidence: 1.4,
|
|
56
|
+
operations: [{ op: "insert", parentId: "n_6", index: 0, node: { kind: "text", value: "hi" } }],
|
|
57
|
+
});
|
|
58
|
+
/** An operation that names a node id the id scheme does not permit. */
|
|
59
|
+
export const FOREIGN_ID_REPLY = JSON.stringify({
|
|
60
|
+
outcome: "change",
|
|
61
|
+
rationale: "Removes the footer.",
|
|
62
|
+
confidence: 0.9,
|
|
63
|
+
operations: [{ op: "remove", nodeId: "footer" }],
|
|
64
|
+
});
|
|
65
|
+
/**
|
|
66
|
+
* Passes the schema, because the schema only says "a string", and fails the
|
|
67
|
+
* parse. This is the failure mode accepted in exchange for the grammar budget
|
|
68
|
+
* (0014), so it is a fixture rather than an impossibility.
|
|
69
|
+
*/
|
|
70
|
+
export const UNDECODABLE_PROP_REPLY = JSON.stringify({
|
|
71
|
+
outcome: "change",
|
|
72
|
+
rationale: "Sets a padding object on the card.",
|
|
73
|
+
confidence: 0.8,
|
|
74
|
+
operations: [{ op: "configure", nodeId: "n_4", set: "{x: 2}", unset: [] }],
|
|
75
|
+
});
|
|
76
|
+
/** Parseable JSON, but not an object, so it cannot be a prop bag. */
|
|
77
|
+
export const NON_OBJECT_PROPS_REPLY = JSON.stringify({
|
|
78
|
+
outcome: "change",
|
|
79
|
+
rationale: "Sets the variant.",
|
|
80
|
+
confidence: 0.8,
|
|
81
|
+
operations: [{ op: "configure", nodeId: "n_4", set: '["filled"]', unset: [] }],
|
|
82
|
+
});
|
|
83
|
+
/**
|
|
84
|
+
* Passes the schema and the parse, and proposes a slot — which the reply schema
|
|
85
|
+
* no longer offers as an insertable kind, so the draft schema must refuse it.
|
|
86
|
+
*/
|
|
87
|
+
export const INSERT_SLOT_REPLY = JSON.stringify({
|
|
88
|
+
outcome: "change",
|
|
89
|
+
rationale: "Adds a region for the sidebar.",
|
|
90
|
+
confidence: 0.7,
|
|
91
|
+
operations: [
|
|
92
|
+
{
|
|
93
|
+
op: "insert",
|
|
94
|
+
parentId: "n_7",
|
|
95
|
+
index: 1,
|
|
96
|
+
node: { kind: "slot", name: "aside", children: [] },
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
});
|
|
100
|
+
export const TRUNCATED_REPLY = '{"outcome":"change","rationale":"Adds a not';
|
|
101
|
+
//# sourceMappingURL=model-replies.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { LoomPrimitive } from "../render/primitive.js";
|
|
2
|
+
import { type PrimitiveResolver } from "../render/primitive.js";
|
|
3
|
+
/** A primitive that ignores `loom.editable` — the failure mode §4 has to catch. */
|
|
4
|
+
export declare const undecoratedPrimitive: LoomPrimitive;
|
|
5
|
+
export declare const testPrimitives: Readonly<Record<string, LoomPrimitive>>;
|
|
6
|
+
export declare const testPrimitiveResolver: PrimitiveResolver;
|
|
7
|
+
//# sourceMappingURL=primitives.d.ts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createElement } from "react";
|
|
2
|
+
import { staticPrimitiveResolver } from "../render/primitive.js";
|
|
3
|
+
/**
|
|
4
|
+
* A host primitive set covering `sampleTree`, so renderer tests assert against
|
|
5
|
+
* real markup rather than a mock's call log.
|
|
6
|
+
*
|
|
7
|
+
* Each one does what a well-behaved primitive does: reads the props it declares
|
|
8
|
+
* out of the bag, spreads `loom.editable` onto its own root element, applies
|
|
9
|
+
* `loom.theme` as its style, places every region it was handed, and adds no
|
|
10
|
+
* element of its own to carry any of it.
|
|
11
|
+
*
|
|
12
|
+
* A real primitive names the regions it places; these are generic over any tag,
|
|
13
|
+
* so they place whatever arrived, in tree order.
|
|
14
|
+
*/
|
|
15
|
+
const hostPrimitive = (tag) => {
|
|
16
|
+
const Primitive = ({ loom, props, children }) => createElement(tag, { ...loom.editable, style: loom.theme, "data-props": JSON.stringify(props) }, children, Object.keys(loom.slots).map((name) => loom.slots[name]));
|
|
17
|
+
Primitive.displayName = `host(${tag})`;
|
|
18
|
+
return Primitive;
|
|
19
|
+
};
|
|
20
|
+
/** A primitive that ignores `loom.editable` — the failure mode §4 has to catch. */
|
|
21
|
+
export const undecoratedPrimitive = ({ children }) => createElement("div", null, children);
|
|
22
|
+
export const testPrimitives = {
|
|
23
|
+
"loom.page": hostPrimitive("main"),
|
|
24
|
+
"loom.header": hostPrimitive("header"),
|
|
25
|
+
"loom.card": hostPrimitive("article"),
|
|
26
|
+
"loom.footer": hostPrimitive("footer"),
|
|
27
|
+
};
|
|
28
|
+
export const testPrimitiveResolver = staticPrimitiveResolver(testPrimitives);
|
|
29
|
+
//# sourceMappingURL=primitives.js.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type NodeId, type TreeId } from "../ids.js";
|
|
2
|
+
import { type PrimitiveType } from "../primitive-type.js";
|
|
3
|
+
import type { ReaderSignalJournal } from "../signals/journal.js";
|
|
4
|
+
import type { ReaderSignal, ReaderSignalBatch, ViewKey } from "../signals/signal.js";
|
|
5
|
+
import type { ReaderTallyStore } from "../signals/tally.js";
|
|
6
|
+
/**
|
|
7
|
+
* Two suites, run against every implementation of the buffer and of the
|
|
8
|
+
* counters.
|
|
9
|
+
*
|
|
10
|
+
* The same argument as `store-contract.ts` and `journal-contract.ts`: an
|
|
11
|
+
* interface is only tested once a second implementation exists, and a
|
|
12
|
+
* disagreement between what runs under `pnpm dev` and what runs in production
|
|
13
|
+
* should be a failing test rather than a number somebody queries six weeks
|
|
14
|
+
* later and cannot explain.
|
|
15
|
+
*/
|
|
16
|
+
export declare const TREE: TreeId;
|
|
17
|
+
export declare const OTHER_TREE: TreeId;
|
|
18
|
+
export declare const nodeId: (name: string) => NodeId;
|
|
19
|
+
export declare const primitiveType: (name: string) => PrimitiveType;
|
|
20
|
+
/** A key of the right shape, spelled so a failing assertion says which view it was. */
|
|
21
|
+
export declare const viewKey: (nth: number) => ViewKey;
|
|
22
|
+
export declare const batchOf: (signals: readonly ReaderSignal[], overrides?: Partial<Omit<ReaderSignalBatch, "signals">>) => ReaderSignalBatch;
|
|
23
|
+
export declare const viewed: (name: string) => ReaderSignal;
|
|
24
|
+
export declare const activated: (name: string) => ReaderSignal;
|
|
25
|
+
/**
|
|
26
|
+
* A press, and the regions it happened inside — nearest first, which is the
|
|
27
|
+
* order a broadcaster walks in.
|
|
28
|
+
*
|
|
29
|
+
* Spelled out rather than spread onto `activated`, because the ancestry is the
|
|
30
|
+
* thing under test and a helper that hid it would let a test pass while the
|
|
31
|
+
* field was absent.
|
|
32
|
+
*/
|
|
33
|
+
export declare const activatedIn: (name: string, ...regions: readonly string[]) => ReaderSignal;
|
|
34
|
+
export declare const disclosedIn: (name: string, open: boolean, ...regions: readonly string[]) => ReaderSignal;
|
|
35
|
+
export declare const dwelled: (name: string, ms: number) => ReaderSignal;
|
|
36
|
+
export declare const describeReaderSignalJournalContract: (name: string, make: () => ReaderSignalJournal | Promise<ReaderSignalJournal>) => void;
|
|
37
|
+
export declare const describeReaderTallyStoreContract: (name: string, make: () => ReaderTallyStore | Promise<ReaderTallyStore>) => void;
|
|
38
|
+
//# sourceMappingURL=reader-signal-contract.d.ts.map
|