@jam-overture/loom 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/application/application.d.ts +109 -0
- package/dist/application/application.js +97 -0
- package/dist/application/memory.d.ts +20 -0
- package/dist/application/memory.js +79 -0
- package/dist/application/store.d.ts +101 -0
- package/dist/application/store.js +25 -0
- package/dist/audience/audience.d.ts +36 -0
- package/dist/audience/audience.js +41 -0
- package/dist/audience/compose.d.ts +112 -0
- package/dist/audience/compose.js +134 -0
- package/dist/audience/memory.d.ts +14 -0
- package/dist/audience/memory.js +71 -0
- package/dist/audience/overlay-store.d.ts +343 -0
- package/dist/audience/overlay-store.js +217 -0
- package/dist/audience/rule.d.ts +121 -0
- package/dist/audience/rule.js +78 -0
- package/dist/cli/index.d.ts +3 -4
- package/dist/cli/index.js +3 -4
- package/dist/cli/templates.js +19 -0
- package/dist/data/adapter.d.ts +9 -1
- package/dist/data/adapter.js +2 -0
- package/dist/data/plan.js +0 -0
- package/dist/data/resolution.d.ts +23 -1
- package/dist/data/resolve.d.ts +31 -4
- package/dist/data/resolve.js +11 -3
- package/dist/ids.d.ts +10 -0
- package/dist/ids.js +11 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/interpretation/anthropic.d.ts +1 -1
- package/dist/interpretation/anthropic.js +2 -22
- package/dist/interpretation/client.d.ts +1 -1
- package/dist/interpretation/materialize.js +67 -22
- package/dist/interpretation/openai-compatible.d.ts +36 -0
- package/dist/interpretation/openai-compatible.js +79 -0
- package/dist/interpretation/status.d.ts +19 -0
- package/dist/interpretation/status.js +26 -0
- package/dist/live/index.d.ts +73 -0
- package/dist/live/index.js +73 -0
- package/dist/live/pages.d.ts +187 -0
- package/dist/live/pages.js +161 -0
- package/dist/live/pull.d.ts +147 -0
- package/dist/live/pull.js +398 -0
- package/dist/live/pulling.d.ts +79 -0
- package/dist/live/pulling.js +117 -0
- package/dist/live/window.d.ts +129 -0
- package/dist/live/window.js +132 -0
- package/dist/patch.d.ts +54 -0
- package/dist/patch.js +44 -0
- package/dist/project/closing.d.ts +51 -0
- package/dist/project/closing.js +53 -0
- package/dist/project/memory.d.ts +20 -0
- package/dist/project/memory.js +97 -0
- package/dist/project/project.d.ts +90 -0
- package/dist/project/project.js +91 -0
- package/dist/project/store.d.ts +135 -0
- package/dist/project/store.js +41 -0
- package/dist/registered.d.ts +64 -0
- package/dist/registered.js +118 -0
- package/dist/render/addressed.d.ts +35 -0
- package/dist/render/addressed.js +79 -0
- package/dist/render/behaviour-adjust.d.ts +11 -19
- package/dist/render/behaviour-adjust.js +75 -21
- package/dist/render/behaviour-present.d.ts +8 -0
- package/dist/render/behaviour-present.js +57 -6
- package/dist/render/behaviour.d.ts +98 -17
- package/dist/render/behaviour.js +91 -26
- package/dist/render/control-name.d.ts +68 -0
- package/dist/render/control-name.js +37 -0
- package/dist/render/diagnostics.d.ts +72 -0
- package/dist/render/diagnostics.js +7 -0
- package/dist/render/document-theme.d.ts +70 -0
- package/dist/render/document-theme.js +139 -0
- package/dist/render/editable.d.ts +15 -1
- package/dist/render/editable.js +13 -1
- package/dist/render/expected.d.ts +98 -0
- package/dist/render/expected.js +88 -0
- package/dist/render/index.d.ts +4 -0
- package/dist/render/index.js +4 -0
- package/dist/render/reads.d.ts +11 -0
- package/dist/render/reads.js +12 -1
- package/dist/render/render.d.ts +11 -0
- package/dist/render/render.js +294 -53
- package/dist/render/request.d.ts +8 -1
- package/dist/render/request.js +1 -0
- package/dist/render/slots.d.ts +52 -0
- package/dist/render/slots.js +24 -0
- package/dist/render/theme.d.ts +54 -1
- package/dist/render/theme.js +23 -1
- package/dist/render/unshown.d.ts +152 -0
- package/dist/render/unshown.js +80 -0
- package/dist/runtime/analysis.d.ts +94 -9
- package/dist/runtime/analysis.js +54 -9
- package/dist/runtime/assessment.d.ts +36 -2
- package/dist/runtime/assessment.js +27 -2
- package/dist/runtime/auto-apply-ceiling.d.ts +54 -0
- package/dist/runtime/auto-apply-ceiling.js +66 -0
- package/dist/runtime/checks.d.ts +148 -0
- package/dist/runtime/checks.js +112 -0
- package/dist/runtime/disposition.d.ts +96 -0
- package/dist/runtime/disposition.js +46 -0
- package/dist/runtime/gate.js +91 -10
- package/dist/runtime/index.d.ts +4 -0
- package/dist/runtime/index.js +4 -0
- package/dist/runtime/irreversibility.d.ts +64 -0
- package/dist/runtime/irreversibility.js +45 -0
- package/dist/runtime/nesting.d.ts +13 -1
- package/dist/runtime/nesting.js +41 -24
- package/dist/runtime/pipeline.d.ts +43 -0
- package/dist/runtime/pipeline.js +10 -2
- package/dist/runtime/policy-change.d.ts +93 -0
- package/dist/runtime/policy-change.js +305 -0
- package/dist/runtime/policy-log.d.ts +406 -0
- package/dist/runtime/policy-log.js +285 -0
- package/dist/runtime/policy.d.ts +8 -6
- package/dist/runtime/policy.js +5 -2
- package/dist/runtime/repointing.js +0 -0
- package/dist/runtime/reversibility.d.ts +11 -9
- package/dist/runtime/stakes.d.ts +129 -1
- package/dist/runtime/stakes.js +240 -26
- package/dist/runtime/vocabulary.d.ts +164 -7
- package/dist/runtime/vocabulary.js +181 -8
- package/dist/sdk/audit.d.ts +174 -3
- package/dist/sdk/audit.js +176 -17
- package/dist/sdk/catalogue.d.ts +9 -1
- package/dist/sdk/conformance.d.ts +37 -3
- package/dist/sdk/conformance.js +25 -4
- package/dist/sdk/definition.d.ts +129 -5
- package/dist/sdk/definition.js +66 -0
- package/dist/sdk/registry.d.ts +45 -2
- package/dist/sdk/registry.js +102 -1
- package/dist/signals/acted.contract.d.ts +21 -0
- package/dist/signals/acted.contract.js +236 -0
- package/dist/signals/acted.d.ts +359 -0
- package/dist/signals/acted.js +135 -0
- package/dist/signals/action-change.d.ts +507 -0
- package/dist/signals/action-change.js +265 -0
- package/dist/signals/action.d.ts +331 -0
- package/dist/signals/action.js +182 -0
- package/dist/signals/agenda.d.ts +585 -0
- package/dist/signals/agenda.js +295 -0
- package/dist/signals/applied-window.contract.d.ts +23 -0
- package/dist/signals/applied-window.contract.js +160 -0
- package/dist/signals/arrivals.contract.d.ts +21 -0
- package/dist/signals/arrivals.contract.js +180 -0
- package/dist/signals/arrivals.d.ts +375 -0
- package/dist/signals/arrivals.js +254 -0
- package/dist/signals/arriving.d.ts +210 -0
- package/dist/signals/arriving.js +133 -0
- package/dist/signals/audiences.d.ts +528 -0
- package/dist/signals/audiences.js +255 -0
- package/dist/signals/broadcast.d.ts +33 -17
- package/dist/signals/broadcast.js +255 -32
- package/dist/signals/change.d.ts +378 -0
- package/dist/signals/change.js +327 -0
- package/dist/signals/collect.d.ts +169 -34
- package/dist/signals/collect.js +186 -38
- package/dist/signals/conversion.d.ts +348 -0
- package/dist/signals/conversion.js +235 -0
- package/dist/signals/copy-change.d.ts +553 -0
- package/dist/signals/copy-change.js +377 -0
- package/dist/signals/copy.d.ts +337 -0
- package/dist/signals/copy.js +211 -0
- package/dist/signals/correlated.contract.d.ts +24 -0
- package/dist/signals/correlated.contract.js +94 -0
- package/dist/signals/counters.d.ts +97 -0
- package/dist/signals/counters.js +160 -0
- package/dist/signals/deliver.d.ts +23 -4
- package/dist/signals/deliver.js +34 -6
- package/dist/signals/deployment-change.d.ts +395 -0
- package/dist/signals/deployment-change.js +309 -0
- package/dist/signals/deployment.d.ts +278 -0
- package/dist/signals/deployment.js +178 -0
- package/dist/signals/door.d.ts +114 -0
- package/dist/signals/door.js +77 -0
- package/dist/signals/expire.d.ts +192 -0
- package/dist/signals/expire.js +213 -0
- package/dist/signals/fold.d.ts +10 -0
- package/dist/signals/fold.js +5 -1
- package/dist/signals/form-action.d.ts +302 -0
- package/dist/signals/form-action.js +169 -0
- package/dist/signals/form-copy.d.ts +523 -0
- package/dist/signals/form-copy.js +346 -0
- package/dist/signals/forms.d.ts +247 -0
- package/dist/signals/forms.js +147 -0
- package/dist/signals/frontier.d.ts +268 -0
- package/dist/signals/frontier.js +145 -0
- package/dist/signals/funnel-change.d.ts +548 -0
- package/dist/signals/funnel-change.js +361 -0
- package/dist/signals/funnel-hours.contract.d.ts +21 -0
- package/dist/signals/funnel-hours.contract.js +221 -0
- package/dist/signals/funnel-hours.d.ts +293 -0
- package/dist/signals/funnel-hours.js +99 -0
- package/dist/signals/funnel.d.ts +592 -0
- package/dist/signals/funnel.js +231 -0
- package/dist/signals/health.d.ts +694 -0
- package/dist/signals/health.js +573 -0
- package/dist/signals/index.d.ts +60 -0
- package/dist/signals/index.js +60 -0
- package/dist/signals/ingest.d.ts +56 -1
- package/dist/signals/ingest.js +91 -1
- package/dist/signals/inside.d.ts +190 -0
- package/dist/signals/inside.js +263 -0
- package/dist/signals/join.d.ts +56 -0
- package/dist/signals/join.js +60 -0
- package/dist/signals/journal.d.ts +123 -9
- package/dist/signals/kept.contract.d.ts +22 -0
- package/dist/signals/kept.contract.js +111 -0
- package/dist/signals/kinds.d.ts +8 -6
- package/dist/signals/kinds.js +14 -6
- package/dist/signals/library-action.d.ts +430 -0
- package/dist/signals/library-action.js +336 -0
- package/dist/signals/library-agenda-change.d.ts +324 -0
- package/dist/signals/library-agenda-change.js +199 -0
- package/dist/signals/library-agenda.d.ts +258 -0
- package/dist/signals/library-agenda.js +167 -0
- package/dist/signals/library-change.d.ts +477 -0
- package/dist/signals/library-change.js +335 -0
- package/dist/signals/library-copy-change.d.ts +498 -0
- package/dist/signals/library-copy-change.js +476 -0
- package/dist/signals/library-pace.d.ts +319 -0
- package/dist/signals/library-pace.js +305 -0
- package/dist/signals/library-reach-change.d.ts +646 -0
- package/dist/signals/library-reach-change.js +542 -0
- package/dist/signals/library-reach.d.ts +377 -0
- package/dist/signals/library-reach.js +227 -0
- package/dist/signals/library-senders-change.d.ts +457 -0
- package/dist/signals/library-senders-change.js +367 -0
- package/dist/signals/library-senders-reach-change.d.ts +486 -0
- package/dist/signals/library-senders-reach-change.js +538 -0
- package/dist/signals/library-senders-reach.d.ts +340 -0
- package/dist/signals/library-senders-reach.js +252 -0
- package/dist/signals/library-senders.d.ts +271 -0
- package/dist/signals/library-senders.js +180 -0
- package/dist/signals/library-word-reach-change.d.ts +567 -0
- package/dist/signals/library-word-reach-change.js +564 -0
- package/dist/signals/library.d.ts +306 -0
- package/dist/signals/library.js +178 -0
- package/dist/signals/memory.d.ts +9 -0
- package/dist/signals/memory.js +246 -14
- package/dist/signals/migrate.d.ts +20 -4
- package/dist/signals/migrate.js +269 -8
- package/dist/signals/notice.d.ts +389 -0
- package/dist/signals/notice.js +250 -0
- package/dist/signals/pace-change.d.ts +501 -0
- package/dist/signals/pace-change.js +310 -0
- package/dist/signals/pace.d.ts +296 -0
- package/dist/signals/pace.js +291 -0
- package/dist/signals/page-views.d.ts +365 -0
- package/dist/signals/page-views.js +218 -0
- package/dist/signals/part-pace.d.ts +378 -0
- package/dist/signals/part-pace.js +333 -0
- package/dist/signals/parts.d.ts +354 -0
- package/dist/signals/parts.js +232 -0
- package/dist/signals/postgres.d.ts +16 -2
- package/dist/signals/postgres.js +753 -76
- package/dist/signals/progress.d.ts +212 -0
- package/dist/signals/progress.js +150 -0
- package/dist/signals/ratios.d.ts +108 -0
- package/dist/signals/ratios.js +40 -0
- package/dist/signals/reach.d.ts +309 -0
- package/dist/signals/reach.js +93 -0
- package/dist/signals/readable.d.ts +34 -0
- package/dist/signals/readable.js +34 -0
- package/dist/signals/readership.d.ts +381 -0
- package/dist/signals/readership.js +308 -0
- package/dist/signals/region-pages.d.ts +173 -0
- package/dist/signals/region-pages.js +62 -0
- package/dist/signals/region.d.ts +287 -0
- package/dist/signals/region.js +198 -0
- package/dist/signals/retention.d.ts +163 -0
- package/dist/signals/retention.js +75 -0
- package/dist/signals/rhythm.d.ts +302 -0
- package/dist/signals/rhythm.js +262 -0
- package/dist/signals/rollup.d.ts +194 -4
- package/dist/signals/rollup.js +0 -0
- package/dist/signals/schema.d.ts +1069 -1
- package/dist/signals/schema.js +393 -3
- package/dist/signals/signal.d.ts +237 -11
- package/dist/signals/signal.js +70 -10
- package/dist/signals/silence-census.d.ts +205 -0
- package/dist/signals/silence-census.js +87 -0
- package/dist/signals/silences.d.ts +1147 -0
- package/dist/signals/silences.js +996 -0
- package/dist/signals/subtrees.d.ts +123 -0
- package/dist/signals/subtrees.js +102 -0
- package/dist/signals/tally.d.ts +262 -12
- package/dist/signals/unread.d.ts +292 -0
- package/dist/signals/unread.js +137 -0
- package/dist/signals/window-agenda.d.ts +276 -0
- package/dist/signals/window-agenda.js +83 -0
- package/dist/signals/window-figures.d.ts +148 -0
- package/dist/signals/window-figures.js +42 -0
- package/dist/signals/window-funnels.d.ts +88 -0
- package/dist/signals/window-funnels.js +47 -0
- package/dist/signals/window.d.ts +866 -0
- package/dist/signals/window.js +693 -0
- package/dist/signals/words.d.ts +24 -0
- package/dist/signals/words.js +24 -0
- package/dist/store/cache.d.ts +101 -0
- package/dist/store/cache.js +149 -0
- package/dist/store/history.d.ts +82 -0
- package/dist/store/history.js +36 -0
- package/dist/store/index.d.ts +30 -0
- package/dist/store/index.js +30 -0
- package/dist/store/memory.d.ts +2 -1
- package/dist/store/memory.js +48 -12
- package/dist/store/migrate.d.ts +106 -0
- package/dist/store/migrate.js +323 -7
- package/dist/store/postgres-applications.d.ts +4 -0
- package/dist/store/postgres-applications.js +197 -0
- package/dist/store/postgres-audience.d.ts +14 -0
- package/dist/store/postgres-audience.js +272 -0
- package/dist/store/postgres-holds.d.ts +10 -1
- package/dist/store/postgres-holds.js +116 -101
- package/dist/store/postgres-policy-log.d.ts +14 -0
- package/dist/store/postgres-policy-log.js +240 -0
- package/dist/store/postgres-projects.d.ts +4 -0
- package/dist/store/postgres-projects.js +217 -0
- package/dist/store/postgres.d.ts +17 -1
- package/dist/store/postgres.js +60 -9
- package/dist/store/replay.d.ts +102 -1
- package/dist/store/replay.js +190 -19
- package/dist/store/reseed.d.ts +238 -0
- package/dist/store/reseed.js +308 -0
- package/dist/store/schema.d.ts +762 -2
- package/dist/store/schema.js +218 -5
- package/dist/store/source.d.ts +57 -1
- package/dist/store/source.js +65 -1
- package/dist/store/store.d.ts +29 -6
- package/dist/submit/resolve.d.ts +1 -1
- package/dist/submit/resolve.js +2 -1
- package/dist/telemetry/calibration.d.ts +25 -0
- package/dist/telemetry/calibration.js +27 -1
- package/dist/telemetry/event.d.ts +391 -33
- package/dist/telemetry/event.js +84 -20
- package/dist/telemetry/index.d.ts +2 -0
- package/dist/telemetry/index.js +2 -0
- package/dist/telemetry/journal.d.ts +104 -3
- package/dist/telemetry/journal.js +9 -0
- package/dist/telemetry/lookup.d.ts +27 -0
- package/dist/telemetry/lookup.js +18 -0
- package/dist/telemetry/memory.js +33 -1
- package/dist/telemetry/migrate.js +22 -1
- package/dist/telemetry/postgres.d.ts +10 -1
- package/dist/telemetry/postgres.js +188 -90
- package/dist/telemetry/remeasure.d.ts +78 -0
- package/dist/telemetry/remeasure.js +83 -0
- package/dist/telemetry/retention.d.ts +2 -2
- package/dist/telemetry/schema.d.ts +17 -0
- package/dist/telemetry/schema.js +27 -1
- package/dist/telemetry/sink.d.ts +2 -2
- package/dist/telemetry/window.d.ts +135 -0
- package/dist/telemetry/window.js +101 -0
- package/dist/testing/application-contract.d.ts +14 -0
- package/dist/testing/application-contract.js +270 -0
- package/dist/testing/audience-overlay-contract.d.ts +31 -0
- package/dist/testing/audience-overlay-contract.js +354 -0
- package/dist/testing/contracts.d.ts +13 -7
- package/dist/testing/contracts.js +13 -7
- package/dist/testing/definitions.d.ts +78 -0
- package/dist/testing/definitions.js +134 -9
- package/dist/testing/doubles.d.ts +103 -0
- package/dist/testing/doubles.js +143 -0
- package/dist/testing/index.d.ts +2 -2
- package/dist/testing/index.js +2 -2
- package/dist/testing/journal-contract.js +297 -6
- package/dist/testing/model-contract.d.ts +110 -0
- package/dist/testing/model-contract.js +150 -0
- package/dist/testing/policy-log-contract.d.ts +26 -0
- package/dist/testing/policy-log-contract.js +344 -0
- package/dist/testing/project-contract.d.ts +14 -0
- package/dist/testing/project-contract.js +266 -0
- package/dist/testing/reader-signal-contract.d.ts +27 -2
- package/dist/testing/reader-signal-contract.js +475 -5
- package/dist/testing/store-contract.d.ts +7 -1
- package/dist/testing/store-contract.js +84 -3
- package/dist/theme/apply.d.ts +20 -1
- package/dist/theme/apply.js +5 -3
- package/dist/theme/contrast.d.ts +19 -14
- package/dist/theme/contrast.js +181 -17
- package/dist/theme/derive.d.ts +22 -0
- package/dist/theme/derive.js +54 -1
- package/dist/theme/library.js +1 -1
- package/dist/theme/measure.d.ts +34 -0
- package/dist/theme/measure.js +30 -1
- package/dist/theme/palettes.js +7 -7
- package/dist/theme/ramp.d.ts +64 -0
- package/dist/theme/ramp.js +114 -0
- package/dist/theme/registry.d.ts +9 -0
- package/dist/theme/registry.js +11 -1
- package/dist/theme/separation.d.ts +97 -3
- package/dist/theme/separation.js +75 -0
- package/dist/tree/apply.js +13 -0
- package/dist/tree/compare.d.ts +9 -0
- package/dist/tree/compare.js +18 -0
- package/dist/tree/mutation.d.ts +18 -0
- package/dist/tree/mutation.js +24 -12
- package/dist/tree/navigation.d.ts +5 -0
- package/dist/tree/navigation.js +32 -10
- package/dist/tree/outline.d.ts +7 -0
- package/dist/tree/outline.js +9 -5
- package/dist/write/computed.d.ts +60 -0
- package/dist/write/computed.js +61 -0
- package/dist/write/held.d.ts +59 -0
- package/dist/write/index.d.ts +5 -2
- package/dist/write/index.js +5 -2
- package/dist/write/reseed.d.ts +151 -0
- package/dist/write/reseed.js +184 -0
- package/dist/write/revert.js +2 -16
- package/package.json +25 -3
- package/dist/runtime/inverse-interpreter.d.ts +0 -90
- package/dist/runtime/inverse-interpreter.js +0 -56
package/dist/store/schema.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { sql } from "drizzle-orm";
|
|
2
|
-
import { integer, jsonb, pgTable, primaryKey, text, timestamp } from "drizzle-orm/pg-core";
|
|
2
|
+
import { index, integer, jsonb, pgTable, primaryKey, text, timestamp } from "drizzle-orm/pg-core";
|
|
3
3
|
/**
|
|
4
4
|
* Two tables: the log, and the snapshot it produces.
|
|
5
5
|
*
|
|
@@ -14,13 +14,24 @@ import { integer, jsonb, pgTable, primaryKey, text, timestamp } from "drizzle-or
|
|
|
14
14
|
* that shredded it would have to be migrated every time §1 changes the AST.
|
|
15
15
|
*/
|
|
16
16
|
export const loomTrees = pgTable("loom_trees", {
|
|
17
|
-
|
|
17
|
+
/**
|
|
18
|
+
* The project the tree belongs to (0260). First in the key rather than
|
|
19
|
+
* beside it: every read this store performs is already inside one project,
|
|
20
|
+
* so a composite key led by the project is the index those reads want, and
|
|
21
|
+
* a tree id only has to be unique within its own project.
|
|
22
|
+
*
|
|
23
|
+
* Defaulted so a database written before projects existed keeps answering.
|
|
24
|
+
* `DEFAULT_APPLICATION_ID` is the value, spelled out here because DDL cannot
|
|
25
|
+
* import it — `project.test.ts` holds the two together.
|
|
26
|
+
*/
|
|
27
|
+
applicationId: text("application_id").notNull().default("app_default"),
|
|
28
|
+
treeId: text("tree_id").notNull(),
|
|
18
29
|
revision: integer("revision").notNull(),
|
|
19
30
|
document: jsonb("document").notNull(),
|
|
20
31
|
updatedAt: timestamp("updated_at", { withTimezone: true })
|
|
21
32
|
.notNull()
|
|
22
33
|
.default(sql `now()`),
|
|
23
|
-
});
|
|
34
|
+
}, (table) => [primaryKey({ columns: [table.applicationId, table.treeId] })]);
|
|
24
35
|
/**
|
|
25
36
|
* The log. The composite primary key is load-bearing rather than incidental: it
|
|
26
37
|
* makes the *database* enforce the revision sequence, so two writers racing at
|
|
@@ -32,6 +43,8 @@ export const loomTrees = pgTable("loom_trees", {
|
|
|
32
43
|
* by §1 and §2. Columns would duplicate those definitions and drift from them.
|
|
33
44
|
*/
|
|
34
45
|
export const loomRevisions = pgTable("loom_revisions", {
|
|
46
|
+
/** See `loomTrees.applicationId`. */
|
|
47
|
+
applicationId: text("application_id").notNull().default("app_default"),
|
|
35
48
|
treeId: text("tree_id").notNull(),
|
|
36
49
|
revision: integer("revision").notNull(),
|
|
37
50
|
proposalId: text("proposal_id").notNull(),
|
|
@@ -45,7 +58,7 @@ export const loomRevisions = pgTable("loom_revisions", {
|
|
|
45
58
|
* nobody observed stays unrecorded rather than being invented.
|
|
46
59
|
*/
|
|
47
60
|
answeredBy: text("answered_by"),
|
|
48
|
-
}, (table) => [primaryKey({ columns: [table.treeId, table.revision] })]);
|
|
61
|
+
}, (table) => [primaryKey({ columns: [table.applicationId, table.treeId, table.revision] })]);
|
|
49
62
|
/**
|
|
50
63
|
* The custody of what the Gate held back.
|
|
51
64
|
*
|
|
@@ -67,12 +80,212 @@ export const loomRevisions = pgTable("loom_revisions", {
|
|
|
67
80
|
* than by two that happen to agree.
|
|
68
81
|
*/
|
|
69
82
|
export const loomHolds = pgTable("loom_holds", {
|
|
70
|
-
|
|
83
|
+
/**
|
|
84
|
+
* The project the hold belongs to (0260). First in the key, as it is on
|
|
85
|
+
* the two tables above, because every read of this table is already inside
|
|
86
|
+
* one project.
|
|
87
|
+
*
|
|
88
|
+
* Widening the key does not weaken what it was doing. The note on `hold`
|
|
89
|
+
* in `postgres-holds.ts` is that the key is what makes *already held* a
|
|
90
|
+
* fact the database establishes rather than a check the code races
|
|
91
|
+
* against; within a project that is unchanged, and across projects two
|
|
92
|
+
* proposals that happen to share an id were never the same proposal.
|
|
93
|
+
*/
|
|
94
|
+
applicationId: text("application_id").notNull().default("app_default"),
|
|
95
|
+
proposalId: text("proposal_id").notNull(),
|
|
71
96
|
treeId: text("tree_id").notNull(),
|
|
72
97
|
baseRevision: integer("base_revision").notNull(),
|
|
73
98
|
intent: jsonb("intent").notNull(),
|
|
74
99
|
proposal: jsonb("proposal").notNull(),
|
|
75
100
|
disposition: jsonb("disposition").notNull(),
|
|
76
101
|
heldAt: text("held_at").notNull(),
|
|
102
|
+
}, (table) => [primaryKey({ columns: [table.applicationId, table.proposalId] })]);
|
|
103
|
+
/**
|
|
104
|
+
* The policy's own log.
|
|
105
|
+
*
|
|
106
|
+
* A fourth table rather than a column anywhere, because a policy revision is not
|
|
107
|
+
* a tree revision: it is not keyed by a tree, it does not advance one, and the
|
|
108
|
+
* same revision of one policy judges changes to every tree a deployment holds.
|
|
109
|
+
* `policy-log.ts` says the same thing from the other side.
|
|
110
|
+
*
|
|
111
|
+
* `policy` is the whole `GatePolicy` as JSON, for the reason
|
|
112
|
+
* `loom_revisions.delta` is: it is a Zod-validated shape owned by §2, and
|
|
113
|
+
* columns would duplicate that definition and drift from it. A knob added to the
|
|
114
|
+
* policy would otherwise be a migration away from a log that quietly stops
|
|
115
|
+
* recording it.
|
|
116
|
+
*
|
|
117
|
+
* `fingerprint` is the one denormalised value in this schema, and it is a column
|
|
118
|
+
* rather than a JSON path because of the query it exists for: a `Disposition`
|
|
119
|
+
* carries a fingerprint, and finding the revision it names has to be a seek. The
|
|
120
|
+
* runtime computes it from the policy beside it on the way in and never accepts
|
|
121
|
+
* one from a caller, so the two cannot disagree.
|
|
122
|
+
*
|
|
123
|
+
* The composite primary key is load-bearing exactly as `loom_revisions`' is: it
|
|
124
|
+
* makes the database enforce the revision sequence, so two writers racing at the
|
|
125
|
+
* same head cannot both commit even if both read the head before either wrote.
|
|
126
|
+
*
|
|
127
|
+
* `recorded_at` is text rather than a timestamp to match
|
|
128
|
+
* `loom_revisions.applied_at` and `loom_holds.held_at` — an ISO-8601 UTC instant
|
|
129
|
+
* orders lexicographically exactly as it orders in time, and what the runtime
|
|
130
|
+
* holds above this boundary is a string.
|
|
131
|
+
*/
|
|
132
|
+
export const loomPolicyRevisions = pgTable("loom_policy_revisions", {
|
|
133
|
+
/** The project whose policy this is (0260). See `loomTrees.applicationId`. */
|
|
134
|
+
applicationId: text("application_id").notNull().default("app_default"),
|
|
135
|
+
policyId: text("policy_id").notNull(),
|
|
136
|
+
revision: integer("revision").notNull(),
|
|
137
|
+
fingerprint: text("fingerprint").notNull(),
|
|
138
|
+
policy: jsonb("policy").notNull(),
|
|
139
|
+
/**
|
|
140
|
+
* Who made this the policy (0200). Never null: a revision nobody can be named
|
|
141
|
+
* for is not a record of a decision.
|
|
142
|
+
*/
|
|
143
|
+
actor: text("actor").notNull(),
|
|
144
|
+
recordedAt: text("recorded_at").notNull(),
|
|
145
|
+
note: text("note"),
|
|
146
|
+
}, (table) => [
|
|
147
|
+
primaryKey({ columns: [table.applicationId, table.policyId, table.revision] }),
|
|
148
|
+
/**
|
|
149
|
+
* The join `judgedUnder` is. Without it, resolving the fingerprint on a
|
|
150
|
+
* disposition is a scan of every policy revision the deployment has ever
|
|
151
|
+
* recorded — which is small today and is on the path of a screen that reads
|
|
152
|
+
* it once per record on the page.
|
|
153
|
+
*/
|
|
154
|
+
index("loom_policy_revisions_fingerprint_idx").on(table.applicationId, table.policyId, table.fingerprint),
|
|
155
|
+
]);
|
|
156
|
+
/**
|
|
157
|
+
* The applications a deployment governs.
|
|
158
|
+
*
|
|
159
|
+
* The unit everything else is stored under: five tables carry `application_id`
|
|
160
|
+
* and none of them could say what that id named until this existed — the column
|
|
161
|
+
* was a foreign key to nothing.
|
|
162
|
+
*
|
|
163
|
+
* It carried the name *project* until 12 October, when the maintainer settled
|
|
164
|
+
* the hierarchy as **account > project > application** and the thing with the
|
|
165
|
+
* pages turned out to be the third of those rather than the second.
|
|
166
|
+
*
|
|
167
|
+
* `created_at` is text rather than `timestamptz` to match `applicationSchema`,
|
|
168
|
+
* which takes an ISO string — the same choice `loom_revisions.applied_at`
|
|
169
|
+
* makes, and for the same reason: what the row holds is what the type holds,
|
|
170
|
+
* so nothing has to agree about how a driver renders a timestamp.
|
|
171
|
+
*/
|
|
172
|
+
export const loomApplications = pgTable("loom_applications", {
|
|
173
|
+
applicationId: text("application_id").primaryKey(),
|
|
174
|
+
/**
|
|
175
|
+
* The project it is grouped under. Not null and not defaulted in the type,
|
|
176
|
+
* but defaulted in the DDL so a database written before projects existed
|
|
177
|
+
* keeps answering — the same device every scoped column here uses.
|
|
178
|
+
*/
|
|
179
|
+
projectId: text("project_id").notNull().default("prj_default"),
|
|
180
|
+
name: text("name").notNull(),
|
|
181
|
+
createdAt: text("created_at").notNull(),
|
|
182
|
+
/** Absent until the application says where it lives. */
|
|
183
|
+
host: text("host"),
|
|
184
|
+
/** When it was closed, absent while it is open (0289). See `loomProjects.closedAt`. */
|
|
185
|
+
closedAt: text("closed_at"),
|
|
77
186
|
});
|
|
187
|
+
/**
|
|
188
|
+
* The projects a deployment has, which group the applications above.
|
|
189
|
+
*
|
|
190
|
+
* Three columns, because the grouping is organisational and owns nothing yet.
|
|
191
|
+
* No row anywhere is scoped by a project: the five scoped tables name their
|
|
192
|
+
* application and the application names its project, so there is one place a
|
|
193
|
+
* thing's project is recorded and nothing to disagree with.
|
|
194
|
+
*/
|
|
195
|
+
export const loomProjects = pgTable("loom_projects", {
|
|
196
|
+
projectId: text("project_id").primaryKey(),
|
|
197
|
+
name: text("name").notNull(),
|
|
198
|
+
createdAt: text("created_at").notNull(),
|
|
199
|
+
/**
|
|
200
|
+
* The repository this project's pages live in, absent while it has none
|
|
201
|
+
* (0292). Unique where present, because a repository belongs to at most one
|
|
202
|
+
* project and two claiming it is a race rather than a typo.
|
|
203
|
+
*/
|
|
204
|
+
repository: text("repository"),
|
|
205
|
+
/**
|
|
206
|
+
* When it was closed, absent while it is open (0289).
|
|
207
|
+
*
|
|
208
|
+
* This store has no delete and this is what it has instead. Nullable and
|
|
209
|
+
* undefaulted, which is the honest value for every row written before closing
|
|
210
|
+
* existed: they were open, and they still are.
|
|
211
|
+
*/
|
|
212
|
+
closedAt: text("closed_at"),
|
|
213
|
+
});
|
|
214
|
+
/**
|
|
215
|
+
* A page's audience rules, as an append-only log of the whole ordered list.
|
|
216
|
+
*
|
|
217
|
+
* The composite primary key is load-bearing exactly as `loom_revisions`' and
|
|
218
|
+
* `loom_policy_revisions`' are: it makes the *database* enforce the sequence, so
|
|
219
|
+
* two people editing one page's rules cannot both commit even if both read the
|
|
220
|
+
* head before either wrote. `overlay-store.ts` says the same from the other
|
|
221
|
+
* side.
|
|
222
|
+
*
|
|
223
|
+
* `rules` is the whole ordered list as JSON rather than a row per rule, and that
|
|
224
|
+
* is the decision this table exists to carry. 0359 clause 3 makes the order the
|
|
225
|
+
* precedence — the last matching rule wins a contested node — and an order
|
|
226
|
+
* expressed as a `position` column is an order a reorder half-applies: several
|
|
227
|
+
* row updates, with a reader arriving between two of them served a precedence
|
|
228
|
+
* nobody authored. One value, written once, is the only shape that cannot do
|
|
229
|
+
* that. It is also the reason `loom_trees.document` is one column.
|
|
230
|
+
*
|
|
231
|
+
* `recorded_at` is text rather than a timestamp to match
|
|
232
|
+
* `loom_revisions.applied_at` and `loom_policy_revisions.recorded_at` — an
|
|
233
|
+
* ISO-8601 UTC instant orders lexicographically exactly as it orders in time, and
|
|
234
|
+
* what the runtime holds above this boundary is a string.
|
|
235
|
+
*/
|
|
236
|
+
export const loomAudienceRules = pgTable("loom_audience_rules", {
|
|
237
|
+
/** See `loomTrees.applicationId`. */
|
|
238
|
+
applicationId: text("application_id").notNull().default("app_default"),
|
|
239
|
+
treeId: text("tree_id").notNull(),
|
|
240
|
+
revision: integer("revision").notNull(),
|
|
241
|
+
rules: jsonb("rules").notNull(),
|
|
242
|
+
/** Who made these the rules (0200). Never null, for the reason `loom_policy_revisions.actor` is not. */
|
|
243
|
+
actor: text("actor").notNull(),
|
|
244
|
+
recordedAt: text("recorded_at").notNull(),
|
|
245
|
+
}, (table) => [primaryKey({ columns: [table.applicationId, table.treeId, table.revision] })]);
|
|
246
|
+
/**
|
|
247
|
+
* The delta each audience earns, one row per audience per page.
|
|
248
|
+
*
|
|
249
|
+
* Rows rather than a second log, and the asymmetry with the table above is
|
|
250
|
+
* deliberate: a rule decides *who sees which form* and is therefore a decision
|
|
251
|
+
* to be attributed, where a form is a document being worked on and rebased onto
|
|
252
|
+
* a base that has moved. A log of every edit of a form would be a record of
|
|
253
|
+
* drafting rather than of deciding, and the record of how a form came to say
|
|
254
|
+
* what it says is the proposal that produced it.
|
|
255
|
+
*
|
|
256
|
+
* One row per audience rather than one row per page holding every form: two
|
|
257
|
+
* audiences' forms are then independent writes, which is what a deployment with
|
|
258
|
+
* four audiences and two editors needs.
|
|
259
|
+
*
|
|
260
|
+
* `base_revision` is the one denormalised value here, and it is a column for the
|
|
261
|
+
* query it exists for — the same argument `loom_policy_revisions.fingerprint` is
|
|
262
|
+
* a column on. A screen listing a page's audiences asks *which of these forms is
|
|
263
|
+
* behind the page*, and answering it from `delta` means loading every delta to
|
|
264
|
+
* read one integer off each. The write takes it from the delta beside it and
|
|
265
|
+
* never from a caller, so the two cannot disagree.
|
|
266
|
+
*/
|
|
267
|
+
export const loomAudienceForms = pgTable("loom_audience_forms", {
|
|
268
|
+
/** See `loomTrees.applicationId`. */
|
|
269
|
+
applicationId: text("application_id").notNull().default("app_default"),
|
|
270
|
+
treeId: text("tree_id").notNull(),
|
|
271
|
+
audienceId: text("audience_id").notNull(),
|
|
272
|
+
delta: jsonb("delta").notNull(),
|
|
273
|
+
baseRevision: integer("base_revision").notNull(),
|
|
274
|
+
actor: text("actor").notNull(),
|
|
275
|
+
authoredAt: text("authored_at").notNull(),
|
|
276
|
+
/**
|
|
277
|
+
* Who took this form out of service and when, both `NULL` while it is the
|
|
278
|
+
* form its audience is served (0403).
|
|
279
|
+
*
|
|
280
|
+
* **Two nullable columns and not a delete**, which is what keeps the
|
|
281
|
+
* no-delete rule (0376): the row stays, carrying the delta it held, so the
|
|
282
|
+
* day the change is wanted again the work is there and `setForm` is the one
|
|
283
|
+
* call that puts it back. They are set and cleared together — `withdrawnAt`
|
|
284
|
+
* without `withdrawnBy` is a state no write here produces.
|
|
285
|
+
*/
|
|
286
|
+
withdrawnBy: text("withdrawn_by"),
|
|
287
|
+
withdrawnAt: text("withdrawn_at"),
|
|
288
|
+
}, (table) => [
|
|
289
|
+
primaryKey({ columns: [table.applicationId, table.treeId, table.audienceId] }),
|
|
290
|
+
]);
|
|
78
291
|
//# sourceMappingURL=schema.js.map
|
package/dist/store/source.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type AudienceOverlay } from "../audience/compose.js";
|
|
2
|
+
import { type AudienceOverlayReader } from "../audience/overlay-store.js";
|
|
3
|
+
import type { TreeId } from "../ids.js";
|
|
4
|
+
import { type Result } from "../result.js";
|
|
5
|
+
import type { TreeSource, TreeSourceError } from "../render/request.js";
|
|
2
6
|
import type { TreeReader } from "./store.js";
|
|
3
7
|
/**
|
|
4
8
|
* The adapter that lets the renderer read from the store.
|
|
@@ -20,4 +24,56 @@ import type { TreeReader } from "./store.js";
|
|
|
20
24
|
* this passes the snapshot through the same boundary any other source would.
|
|
21
25
|
*/
|
|
22
26
|
export declare const treeSourceFromStore: (store: TreeReader) => TreeSource;
|
|
27
|
+
/**
|
|
28
|
+
* Where a deployment's audience rules and audience-scoped deltas come from.
|
|
29
|
+
*
|
|
30
|
+
* A seam rather than a table, and deliberately: 0263's store dimension is a
|
|
31
|
+
* schema change on top of 0260's, and the composition above it needs none of
|
|
32
|
+
* that to be built or tested. A deployment holding its forms in a module
|
|
33
|
+
* satisfies this; so will the store, once the dimension lands.
|
|
34
|
+
*
|
|
35
|
+
* Keyed by tree because that is what a request names, and answered whole
|
|
36
|
+
* because both halves are cacheable beside the base (0263 clause 3).
|
|
37
|
+
*/
|
|
38
|
+
export interface AudienceOverlaySource {
|
|
39
|
+
readonly load: (treeId: TreeId) => Promise<Result<AudienceOverlay, TreeSourceError>>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The composing sibling of `treeSourceFromStore` — one tree per id stays the
|
|
43
|
+
* right answer for a deployment that wants it, so this is a second function
|
|
44
|
+
* rather than an option on the first (0263).
|
|
45
|
+
*
|
|
46
|
+
* Two reads and a pure composition: the base from the store, the overlay from
|
|
47
|
+
* wherever a deployment keeps it, and `composeTreeForContext` over the
|
|
48
|
+
* request's own context. Nothing about the reader leaves the process (0262).
|
|
49
|
+
*
|
|
50
|
+
* **A composition that cannot be served reads as `unavailable`**, with the
|
|
51
|
+
* reason in `detail`. The code is not widened to say *stale form* because
|
|
52
|
+
* `TreeSourceError` is published and exhaustively switched on by hosts, and
|
|
53
|
+
* what a caller does about it is what it does about any other page it cannot
|
|
54
|
+
* have — the sentence that says which audience and which revision is the part
|
|
55
|
+
* somebody acts on, and that is in `detail`.
|
|
56
|
+
*/
|
|
57
|
+
export declare const composingTreeSourceFromStore: (store: TreeReader, overlays: AudienceOverlaySource) => TreeSource;
|
|
58
|
+
/**
|
|
59
|
+
* The store, as the composition's `AudienceOverlaySource`.
|
|
60
|
+
*
|
|
61
|
+
* The seam 0359 clause 6 declared instead of a table now has the table under
|
|
62
|
+
* it, and this is the one function that joins them. It is the audience
|
|
63
|
+
* dimension's `treeSourceFromStore`: two reads above it, a pure composition
|
|
64
|
+
* beside it, and nothing about the reader leaving the process (0262).
|
|
65
|
+
*
|
|
66
|
+
* **A page with no rules is an empty overlay and not a failure**, which is what
|
|
67
|
+
* the store answers and what `composeTreeForContext` serves the base for. So
|
|
68
|
+
* wiring the composing source into a deployment that has never defined an
|
|
69
|
+
* audience changes nothing about what it serves — the property 0359 promised
|
|
70
|
+
* and the one this adapter must not quietly break.
|
|
71
|
+
*
|
|
72
|
+
* `unreadable` and `out-of-date` both read as `unavailable` here for the reason
|
|
73
|
+
* the composition's own errors do: `TreeSourceError` is published and
|
|
74
|
+
* exhaustively switched on by hosts, what a caller does about a page it cannot
|
|
75
|
+
* have does not change with the reason, and the sentence somebody acts on is in
|
|
76
|
+
* `detail`.
|
|
77
|
+
*/
|
|
78
|
+
export declare const audienceOverlaySourceFromStore: (overlays: AudienceOverlayReader) => AudienceOverlaySource;
|
|
23
79
|
//# sourceMappingURL=source.d.ts.map
|
package/dist/store/source.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { composeTreeForContext, describeComposeError, } from "../audience/compose.js";
|
|
2
|
+
import { describeAudienceOverlayError, } from "../audience/overlay-store.js";
|
|
3
|
+
import { err, ok } from "../result.js";
|
|
2
4
|
import { describeStoreError } from "./errors.js";
|
|
3
5
|
/**
|
|
4
6
|
* The adapter that lets the renderer read from the store.
|
|
@@ -34,4 +36,66 @@ export const treeSourceFromStore = (store) => ({
|
|
|
34
36
|
return ok(head.value);
|
|
35
37
|
},
|
|
36
38
|
});
|
|
39
|
+
/**
|
|
40
|
+
* The composing sibling of `treeSourceFromStore` — one tree per id stays the
|
|
41
|
+
* right answer for a deployment that wants it, so this is a second function
|
|
42
|
+
* rather than an option on the first (0263).
|
|
43
|
+
*
|
|
44
|
+
* Two reads and a pure composition: the base from the store, the overlay from
|
|
45
|
+
* wherever a deployment keeps it, and `composeTreeForContext` over the
|
|
46
|
+
* request's own context. Nothing about the reader leaves the process (0262).
|
|
47
|
+
*
|
|
48
|
+
* **A composition that cannot be served reads as `unavailable`**, with the
|
|
49
|
+
* reason in `detail`. The code is not widened to say *stale form* because
|
|
50
|
+
* `TreeSourceError` is published and exhaustively switched on by hosts, and
|
|
51
|
+
* what a caller does about it is what it does about any other page it cannot
|
|
52
|
+
* have — the sentence that says which audience and which revision is the part
|
|
53
|
+
* somebody acts on, and that is in `detail`.
|
|
54
|
+
*/
|
|
55
|
+
export const composingTreeSourceFromStore = (store, overlays) => ({
|
|
56
|
+
load: async (request) => {
|
|
57
|
+
const base = await store.head(request.treeId);
|
|
58
|
+
if (!base.ok) {
|
|
59
|
+
return err({
|
|
60
|
+
code: base.error.code === "not-found" ? "not-found" : "unavailable",
|
|
61
|
+
detail: describeStoreError(base.error),
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
const overlay = await overlays.load(request.treeId);
|
|
65
|
+
if (!overlay.ok)
|
|
66
|
+
return overlay;
|
|
67
|
+
const composed = composeTreeForContext(base.value, overlay.value, request.context);
|
|
68
|
+
return composed.ok
|
|
69
|
+
? ok(composed.value.tree)
|
|
70
|
+
: err({ code: "unavailable", detail: describeComposeError(composed.error) });
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
/**
|
|
74
|
+
* The store, as the composition's `AudienceOverlaySource`.
|
|
75
|
+
*
|
|
76
|
+
* The seam 0359 clause 6 declared instead of a table now has the table under
|
|
77
|
+
* it, and this is the one function that joins them. It is the audience
|
|
78
|
+
* dimension's `treeSourceFromStore`: two reads above it, a pure composition
|
|
79
|
+
* beside it, and nothing about the reader leaving the process (0262).
|
|
80
|
+
*
|
|
81
|
+
* **A page with no rules is an empty overlay and not a failure**, which is what
|
|
82
|
+
* the store answers and what `composeTreeForContext` serves the base for. So
|
|
83
|
+
* wiring the composing source into a deployment that has never defined an
|
|
84
|
+
* audience changes nothing about what it serves — the property 0359 promised
|
|
85
|
+
* and the one this adapter must not quietly break.
|
|
86
|
+
*
|
|
87
|
+
* `unreadable` and `out-of-date` both read as `unavailable` here for the reason
|
|
88
|
+
* the composition's own errors do: `TreeSourceError` is published and
|
|
89
|
+
* exhaustively switched on by hosts, what a caller does about a page it cannot
|
|
90
|
+
* have does not change with the reason, and the sentence somebody acts on is in
|
|
91
|
+
* `detail`.
|
|
92
|
+
*/
|
|
93
|
+
export const audienceOverlaySourceFromStore = (overlays) => ({
|
|
94
|
+
load: async (treeId) => {
|
|
95
|
+
const overlay = await overlays.overlay(treeId);
|
|
96
|
+
return overlay.ok
|
|
97
|
+
? overlay
|
|
98
|
+
: err({ code: "unavailable", detail: describeAudienceOverlayError(overlay.error) });
|
|
99
|
+
},
|
|
100
|
+
});
|
|
37
101
|
//# sourceMappingURL=source.js.map
|
package/dist/store/store.d.ts
CHANGED
|
@@ -58,15 +58,31 @@ export type AppendRequest = {
|
|
|
58
58
|
/**
|
|
59
59
|
* What a listing says about a tree without loading it.
|
|
60
60
|
*
|
|
61
|
-
* `revision`
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
61
|
+
* `revision` starts at 0 and increments once per accepted delta, so it is also
|
|
62
|
+
* the number of entries in the log.
|
|
63
|
+
*
|
|
64
|
+
* `changedAt` is the stamped field 0020 named as the way out of its own
|
|
65
|
+
* ordering decision, and it is not invented here: it is the `appliedAt` of the
|
|
66
|
+
* newest entry in that tree's log, which is the same clock `StoredRevision`
|
|
67
|
+
* already publishes and the same value a caller reading `revisions` would see.
|
|
68
|
+
* A `LoomTree` still carries no time of its own — §1 kept time out of the
|
|
69
|
+
* document, and this is the store's fact about the tree rather than the
|
|
70
|
+
* document's fact about itself, which is why it can be told honestly here and
|
|
71
|
+
* could not be told there.
|
|
72
|
+
*
|
|
73
|
+
* **Absent means the tree has never been appended to**, which is exactly
|
|
74
|
+
* `revision === 0`: a tree is created without a log entry, and a store that
|
|
75
|
+
* filled this with the creation time would be answering a question nobody
|
|
76
|
+
* asked — *when did this appear* is not *when did this change*, and 0020 is
|
|
77
|
+
* explicit that `create` takes no stamp the way `append` takes an `appliedAt`.
|
|
78
|
+
* A reader may rely on the two agreeing: `changedAt` is present if and only if
|
|
79
|
+
* `revision` is greater than 0.
|
|
66
80
|
*/
|
|
67
81
|
export type TreeListing = {
|
|
68
82
|
readonly treeId: TreeId;
|
|
69
83
|
readonly revision: number;
|
|
84
|
+
/** The newest log entry's `appliedAt`; absent when `revision` is 0. */
|
|
85
|
+
readonly changedAt?: string;
|
|
70
86
|
};
|
|
71
87
|
export type ListRequest = {
|
|
72
88
|
/**
|
|
@@ -210,7 +226,14 @@ export declare const clampListingLimit: (limit: number | undefined) => number;
|
|
|
210
226
|
* **Pages are ordered by `treeId`, ascending.** Not by recency, however much a
|
|
211
227
|
* portal would prefer it: ordering has to be total and stable for a cursor to
|
|
212
228
|
* mean anything, and `treeId` is the only key every implementation is guaranteed
|
|
213
|
-
* to have.
|
|
229
|
+
* to have.
|
|
230
|
+
*
|
|
231
|
+
* Recency is no longer a view over data the store does not hold — every listing
|
|
232
|
+
* carries `changedAt` (0277) — but the *order* is still by id, and that half of
|
|
233
|
+
* 0020 stands until somebody decides the second one. A caller sorting a page it
|
|
234
|
+
* holds is sorting that page and not the store: beyond one page, the newest
|
|
235
|
+
* tree overall may sit on a page this caller never asked for. Ordering by
|
|
236
|
+
* recency is proposed separately and is not implemented.
|
|
214
237
|
*/
|
|
215
238
|
export interface TreeStore {
|
|
216
239
|
readonly create: (tree: LoomTree) => Promise<Result<LoomTree, StoreError>>;
|
package/dist/submit/resolve.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ import { type SubmissionResolution } from "./resolution.js";
|
|
|
22
22
|
export type ResolveSubmissionsOptions = {
|
|
23
23
|
readonly registry: EndpointRegistry;
|
|
24
24
|
/** Passed through to every endpoint — the render request's host context. */
|
|
25
|
-
readonly context?: JsonObject;
|
|
25
|
+
readonly context?: JsonObject | undefined;
|
|
26
26
|
/**
|
|
27
27
|
* How long any one endpoint is given, each independently of the others.
|
|
28
28
|
* Defaults to `DEFAULT_ENDPOINT_CEILING_MS`; there is no way to wait forever
|
package/dist/submit/resolve.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ceilingOf, describeCeiling, withCeiling } from "../deadline.js";
|
|
2
|
+
import { describeRegistered } from "../registered.js";
|
|
2
3
|
import { err } from "../result.js";
|
|
3
4
|
import { planTreeSubmissions, submissionPlanIsEmpty } from "./plan.js";
|
|
4
5
|
import { buildSubmissionResolution, EMPTY_SUBMISSION_RESOLUTION, } from "./resolution.js";
|
|
@@ -16,7 +17,7 @@ const askOne = async (to, options) => {
|
|
|
16
17
|
if (!registered) {
|
|
17
18
|
return err({
|
|
18
19
|
reason: "no-such-endpoint",
|
|
19
|
-
detail: `registered: ${options.registry.endpoints.map((entry) => entry.id)
|
|
20
|
+
detail: `registered: ${describeRegistered(to, options.registry.endpoints.map((entry) => entry.id))}`,
|
|
20
21
|
});
|
|
21
22
|
}
|
|
22
23
|
const ceiling = ceilingOf(options.ceilingMs, DEFAULT_ENDPOINT_CEILING_MS);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type WriteCheck } from "../runtime/checks.js";
|
|
1
2
|
import type { EpisodeFold, ProposalEpisode } from "./episode.js";
|
|
2
3
|
/**
|
|
3
4
|
* Confidence is self-graded and trusted on purpose, on one condition: that it
|
|
@@ -97,6 +98,30 @@ export type PolicyCalibration = {
|
|
|
97
98
|
* of length one would say it was.
|
|
98
99
|
*/
|
|
99
100
|
readonly unfingerprinted: number;
|
|
101
|
+
/**
|
|
102
|
+
* The distinct sets of optional write-path checks the judgments in this
|
|
103
|
+
* segment were made under, each in canonical order.
|
|
104
|
+
*
|
|
105
|
+
* The fingerprint above proves which *rules* judged these claims and cannot
|
|
106
|
+
* reach the two seams a composition root hands over separately, either of
|
|
107
|
+
* which can turn an `accepted` into a `rejected` (0179, 0208). So a segment
|
|
108
|
+
* whose `fingerprints` has one member is a segment that was judged under one
|
|
109
|
+
* set of rules, and this is the rest of the sentence: whether it was judged by
|
|
110
|
+
* one write path. More than one member here and a survival rate that moved is
|
|
111
|
+
* explained by the wiring rather than by the model.
|
|
112
|
+
*
|
|
113
|
+
* Sets rather than a verdict, for the reason `fingerprints` is a list rather
|
|
114
|
+
* than a `RulesetContinuity`: `checksContinuityOf` reads this, and the lists
|
|
115
|
+
* themselves are what a host matches against its own composition root.
|
|
116
|
+
*/
|
|
117
|
+
readonly checkSets: readonly (readonly WriteCheck[])[];
|
|
118
|
+
/**
|
|
119
|
+
* Judged claims in this segment whose disposition named no check list. Kept
|
|
120
|
+
* beside the sets for the reason `unfingerprinted` is kept beside the
|
|
121
|
+
* fingerprints: one set plus twelve judgments that recorded none is not a
|
|
122
|
+
* segment shown to have been judged by one write path.
|
|
123
|
+
*/
|
|
124
|
+
readonly unrecordedChecks: number;
|
|
100
125
|
};
|
|
101
126
|
export type CalibrationReport = {
|
|
102
127
|
readonly overall: CalibrationScore;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { everyMemberOf } from "../closed-set.js";
|
|
2
|
+
import { canonicalChecksOf } from "../runtime/checks.js";
|
|
2
3
|
/**
|
|
3
4
|
* The buckets a fold has to open before the first proposal arrives, so a reason
|
|
4
5
|
* nobody hit still reads as zero rather than as missing.
|
|
@@ -106,7 +107,13 @@ export const calibrationOf = (fold) => {
|
|
|
106
107
|
const existing = byPolicy.get(policyId);
|
|
107
108
|
if (existing)
|
|
108
109
|
return existing;
|
|
109
|
-
const fresh = {
|
|
110
|
+
const fresh = {
|
|
111
|
+
bands: emptyBands(),
|
|
112
|
+
fingerprints: new Set(),
|
|
113
|
+
unfingerprinted: 0,
|
|
114
|
+
checkSets: new Map(),
|
|
115
|
+
unrecordedChecks: 0,
|
|
116
|
+
};
|
|
110
117
|
byPolicy.set(policyId, fresh);
|
|
111
118
|
return fresh;
|
|
112
119
|
};
|
|
@@ -131,6 +138,13 @@ export const calibrationOf = (fold) => {
|
|
|
131
138
|
segment.unfingerprinted += 1;
|
|
132
139
|
else
|
|
133
140
|
segment.fingerprints.add(fingerprint);
|
|
141
|
+
const wired = proposal.disposition?.wiredChecks;
|
|
142
|
+
if (wired === undefined)
|
|
143
|
+
segment.unrecordedChecks += 1;
|
|
144
|
+
else {
|
|
145
|
+
const canonical = canonicalChecksOf(wired);
|
|
146
|
+
segment.checkSets.set(canonical.join(","), canonical);
|
|
147
|
+
}
|
|
134
148
|
}
|
|
135
149
|
}
|
|
136
150
|
return {
|
|
@@ -142,6 +156,18 @@ export const calibrationOf = (fold) => {
|
|
|
142
156
|
buckets: bucketsOf(segment.bands),
|
|
143
157
|
fingerprints: Array.from(segment.fingerprints).sort(),
|
|
144
158
|
unfingerprinted: segment.unfingerprinted,
|
|
159
|
+
/**
|
|
160
|
+
* Looked back up by key rather than carried out of the map's values, so
|
|
161
|
+
* the order is the canonical key's and a `flatMap` over arrays cannot
|
|
162
|
+
* quietly flatten the sets into one list.
|
|
163
|
+
*/
|
|
164
|
+
checkSets: Array.from(segment.checkSets.keys())
|
|
165
|
+
.sort()
|
|
166
|
+
.flatMap((key) => {
|
|
167
|
+
const set = segment.checkSets.get(key);
|
|
168
|
+
return set === undefined ? [] : [set];
|
|
169
|
+
}),
|
|
170
|
+
unrecordedChecks: segment.unrecordedChecks,
|
|
145
171
|
})).sort(byPolicyName),
|
|
146
172
|
unjudged,
|
|
147
173
|
unattributed: fold.unattributed.length,
|