@homepages/concrete 4.0.0 → 6.0.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/CHANGELOG.md +359 -0
- package/README.md +28 -17
- package/codemods/fill-is-a-source.mjs +533 -0
- package/codemods/manifest.json +18 -0
- package/codemods/reads-replace-reconcile.mjs +285 -0
- package/dist/artifact/playground/client/assets/{index-D1fwOGVK.js → index-u3T7DiSN.js} +96 -96
- package/dist/artifact/playground/client/index.html +1 -1
- package/dist/artifact/playground/host.mjs +23 -23
- package/dist/base.css +3 -8
- package/dist/browser/site-config.js +1 -16
- package/dist/browser/submit-lead.js +0 -31
- package/dist/cli/build/artifact.js +16 -23
- package/dist/cli/build/captures.js +0 -6
- package/dist/cli/build/esbuild.js +0 -17
- package/dist/cli/build/fixtures.js +15 -30
- package/dist/cli/build/icons.js +0 -3
- package/dist/cli/build/index.js +1 -1
- package/dist/cli/build/playground.js +4 -8
- package/dist/cli/build/sections.js +9 -30
- package/dist/cli/build/source.js +52 -27
- package/dist/cli/build/static.js +4 -25
- package/dist/cli/capture/bundle.js +0 -9
- package/dist/cli/capture/capture-browser.js +0 -14
- package/dist/cli/capture/capture.js +1 -8
- package/dist/cli/check/analyze.js +2 -5
- package/dist/cli/check/index.js +1 -1
- package/dist/cli/check/line-endings.js +52 -0
- package/dist/cli/check/load-workspace.js +3 -8
- package/dist/cli/check/portable-names.js +48 -0
- package/dist/cli/check/render/class-conflicts.js +0 -5
- package/dist/cli/check/render/html.js +0 -1
- package/dist/cli/check/render/invariants.js +0 -5
- package/dist/cli/check/render/island-frames.js +0 -25
- package/dist/cli/check/render/marker-coverage.js +0 -20
- package/dist/cli/check/render/nav.js +0 -33
- package/dist/cli/check/report.js +0 -3
- package/dist/cli/check/stages/bundles.js +1 -9
- package/dist/cli/check/stages/composition.js +3 -2
- package/dist/cli/check/stages/dependencies.js +7 -38
- package/dist/cli/check/stages/fixtures.js +3 -31
- package/dist/cli/check/stages/lint.js +2 -2
- package/dist/cli/check/stages/logic.js +3 -34
- package/dist/cli/check/stages/relations.js +46 -0
- package/dist/cli/check/stages/render.js +0 -1
- package/dist/cli/check/stages/sections.js +3 -3
- package/dist/cli/check/stages/stylesheet.js +1 -1
- package/dist/cli/check/stages/typecheck.js +5 -11
- package/dist/cli/check/stages/workspace.js +36 -14
- package/dist/cli/commands.js +9 -56
- package/dist/cli/currency/cache.js +4 -17
- package/dist/cli/currency/decide.js +0 -14
- package/dist/cli/currency/opt-out.js +0 -7
- package/dist/cli/currency/preamble.js +3 -24
- package/dist/cli/currency/prompt.js +0 -1
- package/dist/cli/currency/refresh.js +5 -12
- package/dist/cli/currency/resolve-latest.js +3 -64
- package/dist/cli/currency/version-order.js +0 -12
- package/dist/cli/dev/crop.js +0 -2
- package/dist/cli/dev/http.js +0 -13
- package/dist/cli/dev/index.js +3 -4
- package/dist/cli/dev/islands.js +25 -70
- package/dist/cli/dev/listen.js +26 -0
- package/dist/cli/dev/load-template.js +0 -1
- package/dist/cli/dev/request-error.js +0 -4
- package/dist/cli/dev/server.js +46 -52
- package/dist/cli/dev/tsconfig-paths.js +0 -13
- package/dist/cli/dev/vite.js +9 -38
- package/dist/cli/dev/workspace-reader.js +4 -34
- package/dist/cli/media/cache.js +4 -51
- package/dist/cli/media/derive.js +2 -94
- package/dist/cli/media/deriver-plugin.js +0 -2
- package/dist/cli/media/frame-rung-floor.js +0 -6
- package/dist/cli/property/index.js +0 -4
- package/dist/cli/property/library.js +6 -24
- package/dist/cli/publish/client.js +0 -1
- package/dist/cli/publish/freshness.js +0 -2
- package/dist/cli/publish/git.js +2 -8
- package/dist/cli/publish/index.js +8 -15
- package/dist/cli/publish/pack.js +5 -6
- package/dist/cli/publish/report.js +0 -6
- package/dist/cli/publish/target.js +16 -13
- package/dist/cli/publish/wire.js +0 -6
- package/dist/cli/tar.js +2 -9
- package/dist/cli/upgrade/codemod.js +0 -8
- package/dist/cli/upgrade/index.js +0 -24
- package/dist/cli/upgrade/manifest.js +0 -12
- package/dist/cli/upgrade/plan.js +0 -17
- package/dist/cli/upgrade/stage.js +12 -15
- package/dist/cli/version.js +0 -8
- package/dist/cli/workspace.js +2 -34
- package/dist/cli.js +4 -21
- package/dist/css/compile.js +25 -28
- package/dist/css/graph.js +3 -10
- package/dist/css/inline.js +3 -13
- package/dist/css/rules.js +6 -43
- package/dist/design-system/format-variants.js +0 -22
- package/dist/eslint/authoring.js +0 -2
- package/dist/eslint/correctness.js +0 -7
- package/dist/eslint/rules/editor-reason.js +0 -11
- package/dist/eslint/rules/island-ids.js +0 -1
- package/dist/eslint/rules/jsx-visitor.js +0 -13
- package/dist/eslint/rules/no-editor-globals.js +0 -2
- package/dist/eslint/rules/no-raw-values.js +0 -1
- package/dist/fixtures/brand.js +0 -1
- package/dist/fixtures/bundle-rule.js +4 -9
- package/dist/fixtures/canonical.d.ts +20 -0
- package/dist/fixtures/image-dimensions.js +0 -1
- package/dist/fixtures/load.js +8 -17
- package/dist/fixtures/media-plugin.js +4 -31
- package/dist/fixtures/media.js +0 -21
- package/dist/fixtures/package-stylesheets.js +0 -6
- package/dist/fixtures/property.js +16 -15
- package/dist/fixtures/resolve.js +102 -29
- package/dist/fixtures/rows.js +12 -11
- package/dist/fixtures/synthesize-empties.js +0 -4
- package/dist/fixtures.d.ts +19 -4
- package/dist/fixtures.js +0 -18
- package/dist/index.d.ts +8 -9
- package/dist/index.js +2 -11
- package/dist/islands/client-module.js +0 -11
- package/dist/islands/marker.js +0 -33
- package/dist/node_modules/.pnpm/fflate@0.8.3/node_modules/fflate/esm/browser.js +0 -20
- package/dist/packages/external/concrete/package.js +1 -1
- package/dist/packages/internal/fill-bake/dist/bake-property-ref.js +22 -36
- package/dist/packages/internal/fill-bake/dist/compute-reads.js +4 -0
- package/dist/packages/internal/fill-bake/dist/derive-source.js +40 -0
- package/dist/packages/internal/fill-bake/dist/display.js +0 -1
- package/dist/packages/internal/fill-bake/dist/index.js +4 -4
- package/dist/packages/internal/fill-vocabulary/dist/origination.js +106 -0
- package/dist/packages/internal/fill-vocabulary/dist/row-planners.js +1 -49
- package/dist/packages/internal/format-geometry/dist/capture.js +10 -240
- package/dist/packages/internal/format-geometry/dist/geometry.js +0 -6
- package/dist/packages/internal/image-ladder/dist/crop.js +0 -12
- package/dist/packages/internal/image-ladder/dist/policy.js +0 -14
- package/dist/packages/internal/island-runtime/dist/capture-holds.js +0 -13
- package/dist/packages/internal/island-runtime/dist/contract.js +0 -34
- package/dist/packages/internal/island-runtime/dist/editor-instance-context.js +0 -1
- package/dist/packages/internal/island-runtime/dist/index.js +0 -34
- package/dist/packages/internal/island-runtime/dist/island-id-context.js +0 -1
- package/dist/packages/internal/island-runtime/dist/use-capture-ready.js +0 -15
- package/dist/packages/internal/island-runtime/dist/use-editor.js +0 -10
- package/dist/packages/internal/island-runtime/dist/use-island-id.js +0 -32
- package/dist/packages/internal/property-facts/dist/derive-facts-view.js +2 -17
- package/dist/packages/internal/property-facts/dist/index.js +1 -1
- package/dist/packages/internal/property-facts/dist/{property-facts-CSdkSuD7.js → property-facts-5pxZnlkh.js} +13 -2
- package/dist/packages/internal/section-contracts/dist/cap-contract.js +1 -18
- package/dist/packages/internal/section-contracts/dist/catalog.js +16 -8
- package/dist/packages/internal/section-contracts/dist/choose-select-contract.js +12 -16
- package/dist/packages/internal/section-contracts/dist/count-bounds-contract.js +5 -11
- package/dist/packages/internal/section-contracts/dist/display-contract.js +2 -0
- package/dist/packages/internal/section-contracts/dist/display-evidence-contract.js +2 -8
- package/dist/packages/internal/section-contracts/dist/fill-spec-view.js +13 -0
- package/dist/packages/internal/section-contracts/dist/index.js +2 -1
- package/dist/packages/internal/section-contracts/dist/interpolation-contract.js +16 -42
- package/dist/packages/internal/section-contracts/dist/list-fill-contract.js +24 -43
- package/dist/packages/internal/section-contracts/dist/name-title-contract.js +11 -18
- package/dist/packages/internal/section-contracts/dist/poi-curation-contract.js +10 -12
- package/dist/packages/internal/section-contracts/dist/pooling-field-contract.js +3 -13
- package/dist/packages/internal/section-contracts/dist/row-fill-contract.js +6 -18
- package/dist/packages/internal/section-contracts/dist/runners.js +21 -13
- package/dist/packages/internal/section-contracts/dist/source-contract.js +13 -2
- package/dist/packages/internal/section-contracts/dist/writer-reads-fact-contract.js +31 -0
- package/dist/packages/internal/source-resolution/dist/index.js +5 -30
- package/dist/packages/internal/template-artifact/dist/hash.js +0 -8
- package/dist/packages/internal/template-artifact/dist/index.js +1 -1
- package/dist/packages/internal/template-artifact/dist/layout.js +0 -39
- package/dist/packages/internal/template-artifact/dist/manifest.js +1 -9
- package/dist/packages/internal/template-artifact/dist/sha256.js +0 -1
- package/dist/packages/internal/template-artifact/dist/verify.js +2 -4
- package/dist/packages/internal/template-contracts/dist/collection-editing.js +0 -16
- package/dist/packages/internal/template-contracts/dist/content-categories.js +0 -4
- package/dist/packages/internal/template-contracts/dist/facts-view.d.ts +16 -10
- package/dist/packages/internal/template-contracts/dist/facts-view.js +15 -28
- package/dist/packages/internal/template-contracts/dist/layout.js +0 -7
- package/dist/packages/internal/template-contracts/dist/markers.js +0 -29
- package/dist/packages/internal/template-contracts/dist/select-key.js +0 -6
- package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +56 -34
- package/dist/packages/internal/template-contracts/dist/slot-catalog.js +22 -389
- package/dist/platform/file-url.js +8 -0
- package/dist/platform/fs.js +73 -0
- package/dist/platform/names.js +63 -0
- package/dist/platform/order.js +7 -0
- package/dist/platform/paths.js +62 -0
- package/dist/platform/process.js +97 -0
- package/dist/playground/host/page-state.js +0 -2
- package/dist/playground/host/paths.js +0 -1
- package/dist/playground/layout.js +0 -7
- package/dist/playground/wire.js +0 -8
- package/dist/primitives/FrameShell.js +0 -18
- package/dist/primitives/Image.d.ts +5 -1
- package/dist/primitives/Image.js +2 -68
- package/dist/primitives/Section.js +0 -13
- package/dist/primitives/Tour.js +0 -26
- package/dist/primitives/Video.js +0 -32
- package/dist/primitives/embed-playback.js +0 -1
- package/dist/primitives/marker-attrs.js +0 -17
- package/dist/primitives/picture-sources.js +6 -1
- package/dist/primitives/probe-context.js +0 -7
- package/dist/primitives/slot-bindings.d.ts +3 -2
- package/dist/primitives/slot-bindings.js +0 -46
- package/dist/primitives/slot-document.js +0 -11
- package/dist/primitives/slot-group.js +0 -9
- package/dist/primitives/slot-media.js +0 -27
- package/dist/primitives/slot-scalar.js +0 -4
- package/dist/primitives/slot.js +0 -6
- package/dist/rules/registry.js +42 -24
- package/dist/schema/compute.d.ts +46 -8
- package/dist/schema/compute.js +21 -15
- package/dist/schema/define-schema.d.ts +1 -1
- package/dist/schema/define-schema.js +37 -17
- package/dist/schema/extract-fill-spec.js +93 -180
- package/dist/schema/extract-used-facts.js +16 -158
- package/dist/schema/fact.d.ts +33 -18
- package/dist/schema/fact.js +7 -11
- package/dist/schema/fill-builders.d.ts +91 -366
- package/dist/schema/fill-builders.js +21 -259
- package/dist/schema/fill-declaration.d.ts +7 -69
- package/dist/schema/fill-declaration.js +5 -34
- package/dist/schema/fill-spec.js +59 -148
- package/dist/schema/format-presets.js +0 -12
- package/dist/schema/format.js +0 -7
- package/dist/schema/layout.js +0 -10
- package/dist/schema/manifest.js +0 -39
- package/dist/schema/property-facts.d.ts +20 -0
- package/dist/schema/runtime-values.d.ts +6 -18
- package/dist/schema/section-nav.js +0 -15
- package/dist/schema/section-props.d.ts +7 -9
- package/dist/schema/section-schema.d.ts +0 -1
- package/dist/schema/section-schema.js +4 -20
- package/dist/schema/slot-builders.d.ts +128 -117
- package/dist/schema/slot-builders.js +18 -201
- package/dist/schema/slot-ref.d.ts +63 -0
- package/dist/schema/slot-ref.js +33 -0
- package/dist/schema/slot-types.d.ts +3 -2
- package/dist/schema/slot-types.js +11 -20
- package/dist/section/declare.d.ts +14 -10
- package/dist/section/declare.js +13 -2
- package/dist/section/discovery.js +6 -21
- package/dist/section/groups.js +0 -6
- package/dist/section/materialize.js +0 -5
- package/dist/section/placements.js +0 -4
- package/dist/section/section.d.ts +8 -5
- package/dist/section/section.js +7 -29
- package/dist/styles.css +5 -0
- package/dist/template/define-template.d.ts +0 -4
- package/dist/template/define-template.js +1 -15
- package/dist/template/logic-build.js +8 -35
- package/dist/template/logic-shim.d.ts +4 -5
- package/dist/template/logic-shim.js +2 -6
- package/dist/template/logic-transform.js +0 -6
- package/dist/template/materialize.js +52 -43
- package/dist/template/mirror-types.js +43 -0
- package/dist/template/running-copy.js +5 -20
- package/dist/template/section-reads.js +83 -0
- package/guide/reference/cli/INDEX.md +12 -6
- package/guide/reference/cli/build.md +1 -1
- package/guide/reference/cli/check.md +1 -1
- package/guide/reference/cli/dev.md +3 -3
- package/guide/reference/cli/property-add.md +1 -1
- package/guide/reference/cli/property-list.md +1 -1
- package/guide/reference/cli/publish.md +4 -2
- package/guide/reference/cli/upgrade.md +1 -1
- package/guide/reference/rules/INDEX.md +26 -13
- package/package.json +4 -2
- package/dist/packages/internal/fact-interpolation/dist/index.js +0 -22
- package/dist/packages/internal/fill-bake/dist/reconcile-cross-section.js +0 -170
- package/dist/packages/internal/fill-vocabulary/dist/facts.d.ts +0 -32
- package/dist/packages/internal/fill-vocabulary/dist/facts.js +0 -131
- package/dist/packages/internal/template-contracts/dist/slot-overrides.js +0 -11
- package/dist/schema/fill-spec.d.ts +0 -18
- package/dist/template/reconcile.d.ts +0 -67
- package/dist/template/reconcile.js +0 -25
|
@@ -3,39 +3,7 @@ import { createContext, useContext } from "react";
|
|
|
3
3
|
|
|
4
4
|
//#region ../../internal/island-runtime/dist/use-island-id.js
|
|
5
5
|
const IslandIdContext = islandIdContext({ createContext });
|
|
6
|
-
/**
|
|
7
|
-
* What the hook returns where nothing opened the channel. The tooling venues that
|
|
8
|
-
* render a section's module graph directly — `concrete check`'s group and placement
|
|
9
|
-
* probes, its per-fixture render stage — reach an island as a plain component, with
|
|
10
|
-
* no marker around it, and each reads the markup for its slot markers and discards
|
|
11
|
-
* it. None of them hydrates, so no id in them is ever compared with anything.
|
|
12
|
-
*
|
|
13
|
-
* A fixed value rather than a throw, because those venues are normal and there is no
|
|
14
|
-
* end of them; what a throw was really guarding — a SECTION minting an island id, and
|
|
15
|
-
* so the same constant for every instance of itself on a page — is a question about
|
|
16
|
-
* source, which `concrete/islands/island-ids` answers before any of this runs.
|
|
17
|
-
*/
|
|
18
6
|
const NO_ISLAND_ID = "tr-no-island";
|
|
19
|
-
/**
|
|
20
|
-
* The enclosing island's id: one string, identical in the server's render and in the
|
|
21
|
-
* client's hydration of the same island, and unique among the islands of a document.
|
|
22
|
-
* Compose an id from it rather than calling React's `useId`, which mints a different
|
|
23
|
-
* value in each of those two renders and hydrates into an attribute mismatch on
|
|
24
|
-
* whatever markup carries it (see {@link islandIdContext}):
|
|
25
|
-
*
|
|
26
|
-
* ```tsx
|
|
27
|
-
* const bodyId = `${useIslandId()}-body`;
|
|
28
|
-
* <button aria-controls={bodyId} /><div id={bodyId} />
|
|
29
|
-
* ```
|
|
30
|
-
*
|
|
31
|
-
* It is one value per island, not per call — the discriminator after it is the
|
|
32
|
-
* author's, and two call sites in one island that compose the same suffix collide
|
|
33
|
-
* deterministically, in both renders, where a test or a browser will say so.
|
|
34
|
-
*
|
|
35
|
-
* Outside an island it is {@link NO_ISLAND_ID}. Only a client module may call it
|
|
36
|
-
* (`concrete/islands/island-ids`); a section renders once and hydrates never, so it
|
|
37
|
-
* has no id to hand out and gives one to the island as a prop instead.
|
|
38
|
-
*/
|
|
39
7
|
function useIslandId() {
|
|
40
8
|
return useContext(IslandIdContext) ?? "tr-no-island";
|
|
41
9
|
}
|
|
@@ -2,24 +2,9 @@ import { projectFactsView } from "../../template-contracts/dist/facts-view.js";
|
|
|
2
2
|
import "../../source-resolution/dist/index.js";
|
|
3
3
|
|
|
4
4
|
//#region ../../internal/property-facts/dist/derive-facts-view.js
|
|
5
|
-
function currentYear() {
|
|
6
|
-
const fixed = process.env.TR_FIXED_YEAR;
|
|
7
|
-
if (fixed) {
|
|
8
|
-
const n = Number(fixed);
|
|
9
|
-
if (!Number.isInteger(n)) throw new Error(`TR_FIXED_YEAR not an integer: ${fixed}`);
|
|
10
|
-
return n;
|
|
11
|
-
}
|
|
12
|
-
return (/* @__PURE__ */ new Date()).getUTCFullYear();
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Projects the loaded PropertyFacts into the derive-time `Facts` view an
|
|
16
|
-
* authored `compute()` handle receives. The projector takes the canonical
|
|
17
|
-
* bundle as a loose record and normalizes member-by-member against the fact
|
|
18
|
-
* graph registry, so the Zod-inferred type passes straight in.
|
|
19
|
-
*/
|
|
20
5
|
function buildDeriveFactsView(facts) {
|
|
21
|
-
return projectFactsView(facts
|
|
6
|
+
return projectFactsView(facts);
|
|
22
7
|
}
|
|
23
8
|
|
|
24
9
|
//#endregion
|
|
25
|
-
export { buildDeriveFactsView
|
|
10
|
+
export { buildDeriveFactsView };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { C as VideoSchema, S as UnitSchema, _ as PropertyFactsSchema, a as ComparableSchema, b as TourLinkSchema, c as DocumentSchema, f as ListingIntentSchema, h as PlannerUnitSchema, i as ComparablePricePeriodSchema, l as FloorPlanSchema, m as PhotoSchema, n as COMPARABLE_PRICE_PERIODS, o as ComparableStatusSchema, p as NarrativeSchema, r as COMPARABLE_STATUSES, s as ContactCardSchema, t as AddressSchema, u as FloorPlanUnitAssignmentSchema, v as PropertyTypeSchema, x as UnitFloorPlanRefSchema } from "./property-facts-
|
|
1
|
+
import { C as VideoSchema, S as UnitSchema, _ as PropertyFactsSchema, a as ComparableSchema, b as TourLinkSchema, c as DocumentSchema, f as ListingIntentSchema, h as PlannerUnitSchema, i as ComparablePricePeriodSchema, l as FloorPlanSchema, m as PhotoSchema, n as COMPARABLE_PRICE_PERIODS, o as ComparableStatusSchema, p as NarrativeSchema, r as COMPARABLE_STATUSES, s as ContactCardSchema, t as AddressSchema, u as FloorPlanUnitAssignmentSchema, v as PropertyTypeSchema, x as UnitFloorPlanRefSchema } from "./property-facts-5pxZnlkh.js";
|
|
2
2
|
|
|
3
3
|
export { PropertyFactsSchema };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
|
|
3
|
-
//#region ../../internal/property-facts/dist/property-facts-
|
|
3
|
+
//#region ../../internal/property-facts/dist/property-facts-5pxZnlkh.js
|
|
4
4
|
const AddressSchema = z.object({
|
|
5
5
|
display: z.string(),
|
|
6
6
|
street: z.string(),
|
|
@@ -128,7 +128,18 @@ const ComparableSchema = z.object({
|
|
|
128
128
|
sqft: z.number().int().nullable(),
|
|
129
129
|
photo_url: z.string().nullable(),
|
|
130
130
|
source_url: z.string().nullable(),
|
|
131
|
-
source_name: z.string().nullable()
|
|
131
|
+
source_name: z.string().nullable(),
|
|
132
|
+
year_built: z.number().int().nullable(),
|
|
133
|
+
lot_sqft: z.number().int().nullable(),
|
|
134
|
+
stories: z.number().nullable(),
|
|
135
|
+
units: z.number().int().nullable(),
|
|
136
|
+
hoa_monthly: z.number().int().nullable(),
|
|
137
|
+
days_on_market: z.number().int().nullable(),
|
|
138
|
+
list_price: z.number().int().nullable(),
|
|
139
|
+
listed_date: z.string().nullable(),
|
|
140
|
+
mls_number: z.string().nullable(),
|
|
141
|
+
description: z.string().nullable(),
|
|
142
|
+
property_type: PropertyTypeSchema.nullable()
|
|
132
143
|
});
|
|
133
144
|
const PropertyFactsSchema = z.object({
|
|
134
145
|
address: AddressSchema,
|
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
import { plannerForField } from "../../fill-vocabulary/dist/row-planners.js";
|
|
2
2
|
|
|
3
3
|
//#region ../../internal/section-contracts/dist/cap-contract.js
|
|
4
|
-
function generatesText(node) {
|
|
5
|
-
if (node.type === "list-fill") return node.mode === "extract" || node.mode === void 0;
|
|
6
|
-
return node.type === "text-block";
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Where the character budget for the value filling this slot is declared, and
|
|
10
|
-
* what to call it in a message. A `text` slot declares its own; a scalar `list`
|
|
11
|
-
* writes ITEMS, so the element that holds an item declares it. Everything else —
|
|
12
|
-
* a select vocabulary, a record list, media, a POI — fills a value with no
|
|
13
|
-
* character budget at all, which is what makes this rule a no-op for it.
|
|
14
|
-
*/
|
|
15
4
|
function capHolder(slot) {
|
|
16
5
|
if (slot.fields !== void 0) return null;
|
|
17
6
|
const planner = plannerForField(slot);
|
|
@@ -26,7 +15,7 @@ function capHolder(slot) {
|
|
|
26
15
|
return null;
|
|
27
16
|
}
|
|
28
17
|
function checkAgainstSlot(node, slot, where, decisionId, sectionKey) {
|
|
29
|
-
if (slot === void 0
|
|
18
|
+
if (slot === void 0) return;
|
|
30
19
|
const resolved = capHolder(slot);
|
|
31
20
|
if (resolved === null) return;
|
|
32
21
|
const label = `${where}${resolved.suffix}`;
|
|
@@ -44,12 +33,6 @@ function checkNode(node, slot, slotId, field, decisionId, sectionKey) {
|
|
|
44
33
|
checkNode(plan, rowField, slotId, planned, decisionId, sectionKey);
|
|
45
34
|
}
|
|
46
35
|
}
|
|
47
|
-
/**
|
|
48
|
-
* Rejects a fill-side character cap that is not strictly lower than the slot's,
|
|
49
|
-
* and a filled text slot or list element that declares no cap at all. Throws on
|
|
50
|
-
* the first violation; mirrors assertCountBoundsContract in signature and
|
|
51
|
-
* error-message style.
|
|
52
|
-
*/
|
|
53
36
|
function assertCapContract(schema, decision, sectionKey) {
|
|
54
37
|
const node = decision;
|
|
55
38
|
for (const slotId of decision.produces) checkNode(node, schema.slots[slotId], slotId, void 0, decision.id, sectionKey);
|
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
const SECTION_CONTRACT_CATALOG = [
|
|
3
3
|
{
|
|
4
4
|
id: "reads-readable",
|
|
5
|
-
summary: "Every fact
|
|
5
|
+
summary: "Every fact a section reads is one the fact registry declares."
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
id: "decision-kind",
|
|
9
|
+
summary: "Every fill decision names a kind the platform runs: text, pick, list or display."
|
|
6
10
|
},
|
|
7
11
|
{
|
|
8
12
|
id: "produces-known-slot",
|
|
@@ -14,23 +18,23 @@ const SECTION_CONTRACT_CATALOG = [
|
|
|
14
18
|
},
|
|
15
19
|
{
|
|
16
20
|
id: "list-fill",
|
|
17
|
-
summary: "A list fill declares what
|
|
21
|
+
summary: "A list fill declares what the slot's own origination needs: a brief where the model originates rows, a bound where it writes them, nothing on a fact-bound list."
|
|
18
22
|
},
|
|
19
23
|
{
|
|
20
24
|
id: "choose-select",
|
|
21
|
-
summary: "A
|
|
25
|
+
summary: "A record list the model originates is keyed by its title field, else by exactly one select field with declared values."
|
|
22
26
|
},
|
|
23
27
|
{
|
|
24
28
|
id: "name-title",
|
|
25
|
-
summary: "A
|
|
29
|
+
summary: "A list keyed by a written name needs that field to be capped text that carries no fill of its own."
|
|
26
30
|
},
|
|
27
31
|
{
|
|
28
32
|
id: "pooling-field",
|
|
29
|
-
summary: "A list fill's item declares at most one unbound pooled asset field
|
|
33
|
+
summary: "A list fill's record item declares at most one unbound pooled asset field."
|
|
30
34
|
},
|
|
31
35
|
{
|
|
32
36
|
id: "row-fill",
|
|
33
|
-
summary: "A list fill plans only unbound fields its record item declares, each
|
|
37
|
+
summary: "A list fill plans only unbound fields its record item declares, each of a type a row can be filled with."
|
|
34
38
|
},
|
|
35
39
|
{
|
|
36
40
|
id: "count-bounds",
|
|
@@ -40,13 +44,17 @@ const SECTION_CONTRACT_CATALOG = [
|
|
|
40
44
|
id: "cap",
|
|
41
45
|
summary: "Every generated text value has one character budget, declared on its slot, and a fill cap may only be lower."
|
|
42
46
|
},
|
|
47
|
+
{
|
|
48
|
+
id: "writer-reads-fact",
|
|
49
|
+
summary: "A fill that writes text, its row fields included, reads at least one fact to ground what it writes."
|
|
50
|
+
},
|
|
43
51
|
{
|
|
44
52
|
id: "display",
|
|
45
53
|
summary: "Display entries declare one origin and legal cases, and every slot variant gate names a declared case."
|
|
46
54
|
},
|
|
47
55
|
{
|
|
48
56
|
id: "display-evidence",
|
|
49
|
-
summary: "A filled display entry
|
|
57
|
+
summary: "A filled display entry has a declared fact read to judge its case from."
|
|
50
58
|
},
|
|
51
59
|
{
|
|
52
60
|
id: "source",
|
|
@@ -86,7 +94,7 @@ const SECTION_CONTRACT_CATALOG = [
|
|
|
86
94
|
},
|
|
87
95
|
{
|
|
88
96
|
id: "interpolation",
|
|
89
|
-
summary: "
|
|
97
|
+
summary: "A fill brief refers to its facts through reads and never interpolates one."
|
|
90
98
|
},
|
|
91
99
|
{
|
|
92
100
|
id: "group",
|
|
@@ -1,24 +1,20 @@
|
|
|
1
|
+
import { originationFor } from "../../fill-vocabulary/dist/origination.js";
|
|
2
|
+
import { isListFill } from "./fill-spec-view.js";
|
|
3
|
+
|
|
1
4
|
//#region ../../internal/section-contracts/dist/choose-select-contract.js
|
|
2
|
-
/**
|
|
3
|
-
* A `choose` list fill producing a record list needs exactly one `select`
|
|
4
|
-
* field declaring `values` on the row — the vocabulary the rows are picked from
|
|
5
|
-
* and the key the batched call is keyed on. A value item (the element IS the
|
|
6
|
-
* vocabulary) and every other mode pass untouched. Throws on the first violation.
|
|
7
|
-
*/
|
|
8
5
|
function assertChooseSelectContract(schema, decision, sectionKey) {
|
|
9
|
-
|
|
10
|
-
if (fill.type !== "list-fill" || fill.mode !== "choose") return;
|
|
6
|
+
if (!isListFill(decision)) return;
|
|
11
7
|
for (const slotId of decision.produces) {
|
|
12
|
-
const
|
|
13
|
-
if (
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
const slot = schema.slots[slotId];
|
|
9
|
+
if (slot === void 0) continue;
|
|
10
|
+
const origination = originationFor(slot);
|
|
11
|
+
if (origination?.kind !== "unkeyed-rows") continue;
|
|
12
|
+
const where = `Section "${sectionKey}": list fill "${decision.id}" originates rows of "${slotId}"`;
|
|
13
|
+
const declared = Object.keys(slot.fields ?? {});
|
|
14
|
+
if (origination.title !== void 0) throw new Error(`${where}, keyed by \`title: "${origination.title}"\` — ${origination.titleType === void 0 ? "which is not one of its declared fields" : `a \`${origination.titleType}\` field${origination.titleType === "select" ? " with no declared `values`" : ""}`}. Rows are keyed on a \`text\` field the model writes or a \`select.of([...])\` field it picks from, so point \`title:\` at one of those.`);
|
|
15
|
+
throw new Error(`${where}, but declares neither a \`title:\` to key them by nor exactly one \`select\` field with \`values\` to fall back to (found ${origination.selects.length}; declared: ${declared.length > 0 ? declared.join(", ") : "none"}). Title the list by the field that names a row, give the row exactly one \`select.of([...])\` field, or originate the rows another way.`);
|
|
17
16
|
}
|
|
18
17
|
}
|
|
19
|
-
function isSelectVocabulary(field) {
|
|
20
|
-
return field.type === "select" && Array.isArray(field.values);
|
|
21
|
-
}
|
|
22
18
|
|
|
23
19
|
//#endregion
|
|
24
20
|
export { assertChooseSelectContract };
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
//#region ../../internal/section-contracts/dist/count-bounds-contract.js
|
|
2
|
-
/**
|
|
3
|
-
* The requested range a `count:` value states, in the two shapes the grammar
|
|
4
|
-
* spells it: a literal generation target (`count: 4`) or a range
|
|
5
|
-
* (`count: { min, max }`, either end optional). Anything else declares no count.
|
|
6
|
-
*/
|
|
7
2
|
function requestedCount(raw) {
|
|
8
|
-
if (typeof raw === "number") return {
|
|
3
|
+
if (typeof raw === "number") return {
|
|
4
|
+
ceiling: raw,
|
|
5
|
+
floor: raw
|
|
6
|
+
};
|
|
9
7
|
if (typeof raw !== "object" || raw === null) return void 0;
|
|
10
8
|
const { min, max } = raw;
|
|
11
9
|
const requested = {};
|
|
@@ -14,6 +12,7 @@ function requestedCount(raw) {
|
|
|
14
12
|
return requested.ceiling === void 0 && requested.floor === void 0 ? void 0 : requested;
|
|
15
13
|
}
|
|
16
14
|
function checkAgainstBounds(requested, bounds, where, decisionId, sectionKey) {
|
|
15
|
+
if (requested.floor !== void 0 && requested.ceiling !== void 0 && requested.floor > requested.ceiling) throw new Error(`Section "${sectionKey}": decision "${decisionId}" requests at least ${requested.floor} items but at most ${requested.ceiling} for ${where}.`);
|
|
17
16
|
if (bounds.max !== void 0) {
|
|
18
17
|
if (requested.ceiling !== void 0 && requested.ceiling > bounds.max) throw new Error(`Section "${sectionKey}": decision "${decisionId}" requests up to ${requested.ceiling} items but ${where} holds at most ${bounds.max}.`);
|
|
19
18
|
if (requested.floor !== void 0 && requested.floor > bounds.max) throw new Error(`Section "${sectionKey}": decision "${decisionId}" requests at least ${requested.floor} items but ${where} holds at most ${bounds.max}.`);
|
|
@@ -30,11 +29,6 @@ function checkNode(node, holder, slotId, field, decisionId, sectionKey) {
|
|
|
30
29
|
checkNode(plan, bounds, slotId, planned, decisionId, sectionKey);
|
|
31
30
|
}
|
|
32
31
|
}
|
|
33
|
-
/**
|
|
34
|
-
* Every count a decision declares, at every level, against the bounds of
|
|
35
|
-
* whatever holds those items. Throws on the first violation; mirrors
|
|
36
|
-
* assertPoiCurationContract in signature and error-message style.
|
|
37
|
-
*/
|
|
38
32
|
function assertCountBoundsContract(schema, decision, sectionKey) {
|
|
39
33
|
const node = decision;
|
|
40
34
|
for (const slotId of decision.produces) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DISPLAY_ENTRIES, VISIBILITY_CASES } from "../../template-contracts/dist/slot-catalog.js";
|
|
2
|
+
import { assertDeclaredRefs } from "./source-contract.js";
|
|
2
3
|
|
|
3
4
|
//#region ../../internal/section-contracts/dist/display-contract.js
|
|
4
5
|
function assertDisplayContract(schema, sectionKey) {
|
|
@@ -7,6 +8,7 @@ function assertDisplayContract(schema, sectionKey) {
|
|
|
7
8
|
const entry = display[entryKey];
|
|
8
9
|
if (entry === void 0) continue;
|
|
9
10
|
if (new Set(entry.cases).size !== entry.cases.length) throw new Error(`Section "${sectionKey}": display ${entryKey} declares a duplicate case.`);
|
|
11
|
+
assertDeclaredRefs(`Section "${sectionKey}": display ${entryKey}`, entry.source?.reads);
|
|
10
12
|
const origins = [entry.source, entry.fill].filter((o) => o !== void 0).length;
|
|
11
13
|
if (origins !== 1) throw new Error(`Section "${sectionKey}": display ${entryKey} declares ${origins === 0 ? "no origin" : "two origins"} — exactly one of \`source:\` or \`fill:\` decides it.`);
|
|
12
14
|
}
|
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
import { extractPaths } from "../../fact-interpolation/dist/index.js";
|
|
2
|
-
import { assertFactPath } from "./interpolation-contract.js";
|
|
3
|
-
|
|
4
1
|
//#region ../../internal/section-contracts/dist/display-evidence-contract.js
|
|
5
2
|
function assertDisplayEvidenceContract(schema, fillSpec, sectionKey) {
|
|
3
|
+
if ((fillSpec.reads ?? []).length > 0) return;
|
|
6
4
|
for (const [entryKey, entry] of Object.entries(schema.display ?? {})) {
|
|
7
5
|
if (entry?.fill === void 0) continue;
|
|
8
|
-
|
|
9
|
-
const paths = extractPaths(entry.fill.pick);
|
|
10
|
-
for (const path of paths) assertFactPath(path, sectionKey, subject);
|
|
11
|
-
if (paths.length > 0 || (fillSpec.reads ?? []).length > 0) continue;
|
|
12
|
-
throw new Error(`Section "${sectionKey}": ${subject} names no evidence — the section declares no \`reads\` and the prose interpolates no \`\${facts.*}\`, so the model decides it from the always-on slice alone. Declare the fact bucket it judges (\`reads: ["photos"]\`) or interpolate the fact itself (\`\${facts.primary_contact_website_url}\`). A display decision is handed no other decision's output, however late it runs.`);
|
|
6
|
+
throw new Error(`Section "${sectionKey}": display ${entryKey}'s \`pick\` names no evidence — its fill reads nothing, and a fill is shown exactly its \`reads\`. Declare the fact it judges (\`reads: [fact.contact.website]\`).`);
|
|
13
7
|
}
|
|
14
8
|
}
|
|
15
9
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region ../../internal/section-contracts/dist/fill-spec-view.js
|
|
2
|
+
const DECISION_KINDS = [
|
|
3
|
+
"text",
|
|
4
|
+
"pick",
|
|
5
|
+
"list",
|
|
6
|
+
"display"
|
|
7
|
+
];
|
|
8
|
+
function isListFill(decision) {
|
|
9
|
+
return decision.kind === "list";
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { DECISION_KINDS, isListFill };
|
|
@@ -4,6 +4,7 @@ import { assertChooseSelectContract } from "./choose-select-contract.js";
|
|
|
4
4
|
import { assertCountBoundsContract } from "./count-bounds-contract.js";
|
|
5
5
|
import { assertGroupContract } from "./group-contract.js";
|
|
6
6
|
import { assertInterpolationContract } from "./interpolation-contract.js";
|
|
7
|
+
import { assertWriterReadsFactContract } from "./writer-reads-fact-contract.js";
|
|
7
8
|
import { assertListFillContract } from "./list-fill-contract.js";
|
|
8
9
|
import { assertListScalarContract } from "./list-scalar-contract.js";
|
|
9
10
|
import { assertNameTitleContract } from "./name-title-contract.js";
|
|
@@ -14,10 +15,10 @@ import { assertPoiCurationContract } from "./poi-curation-contract.js";
|
|
|
14
15
|
import { assertPoolingFieldContract } from "./pooling-field-contract.js";
|
|
15
16
|
import { assertRowContract } from "./row-contract.js";
|
|
16
17
|
import { assertRowFillContract } from "./row-fill-contract.js";
|
|
18
|
+
import { assertSourceContract } from "./source-contract.js";
|
|
17
19
|
import { assertDisplayContract } from "./display-contract.js";
|
|
18
20
|
import { assertDisplayEvidenceContract } from "./display-evidence-contract.js";
|
|
19
21
|
import { assertSelectContract } from "./select-contract.js";
|
|
20
|
-
import { assertSourceContract } from "./source-contract.js";
|
|
21
22
|
import { assertSourceFilterContract } from "./source-filter-contract.js";
|
|
22
23
|
import { assertSourcesContract } from "./sources-contract.js";
|
|
23
24
|
import { assertUrlContract } from "./url-contract.js";
|
|
@@ -1,48 +1,22 @@
|
|
|
1
|
-
import { NAMESPACE, extractPaths } from "../../fact-interpolation/dist/index.js";
|
|
2
|
-
import { FACTS_INTERPOLABLE_ROOTS } from "../../fill-vocabulary/dist/facts.js";
|
|
3
|
-
|
|
4
1
|
//#region ../../internal/section-contracts/dist/interpolation-contract.js
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
* Assert one extracted `${facts.*}` reference resolves, naming `subject` (e.g.
|
|
15
|
-
* `fill-spec decision "hero"`) as what wrote it.
|
|
16
|
-
*
|
|
17
|
-
* Exported because a fill-spec decision is not the only place a `${facts.*}`
|
|
18
|
-
* reference is authored and expanded: a `fill:` display entry's `pick` prose
|
|
19
|
-
* lives on the SCHEMA's display entry, never on the decision that names the
|
|
20
|
-
* entry, so the walk above never reaches it (`display-evidence-contract.ts`
|
|
21
|
-
* runs it there).
|
|
22
|
-
*/
|
|
23
|
-
function assertFactPath(path, sectionKey, subject) {
|
|
24
|
-
const where = `${subject} interpolates \${${path}}`;
|
|
25
|
-
const [namespace, root, ...rest] = path.split(".");
|
|
26
|
-
if (namespace !== "facts") throw new Error(`Section "${sectionKey}": ${where}, but "${NAMESPACE}" is the only namespace a prompt may reference.`);
|
|
27
|
-
if (root === void 0) throw new Error(`Section "${sectionKey}": ${where}, which names no fact — write \${${NAMESPACE}.<fact>}.`);
|
|
28
|
-
let shape = Object.hasOwn(FACTS_INTERPOLABLE_ROOTS, root) ? FACTS_INTERPOLABLE_ROOTS[root] : void 0;
|
|
29
|
-
if (shape === void 0) throw new Error(`Section "${sectionKey}": ${where}, but "${root}" is not a fact the relevance slice carries (allowed: ${Object.keys(FACTS_INTERPOLABLE_ROOTS).join(", ")}). It would expand to nothing.`);
|
|
30
|
-
let walked = `${NAMESPACE}.${root}`;
|
|
31
|
-
for (const [index, segment] of rest.entries()) {
|
|
32
|
-
const remainder = rest.slice(index).join(".");
|
|
33
|
-
if (shape.kind === "scalar") throw new Error(`Section "${sectionKey}": ${where}, but "${walked}" is a scalar fact and has no "${remainder}" beneath it. It would expand to nothing.`);
|
|
34
|
-
if (shape.kind === "array") {
|
|
35
|
-
if (!IS_INDEX.test(segment)) throw new Error(`Section "${sectionKey}": ${where}, but "${walked}" is a list — a reference names it whole (it expands to JSON) or indexes it (\${${walked}.0.…}), and "${segment}" is neither. It would expand to nothing.`);
|
|
36
|
-
shape = shape.element;
|
|
37
|
-
} else {
|
|
38
|
-
const next = Object.hasOwn(shape.fields, segment) ? shape.fields[segment] : void 0;
|
|
39
|
-
if (next === void 0) throw new Error(`Section "${sectionKey}": ${where}, but "${walked}" has no "${segment}" beneath it (allowed: ${Object.keys(shape.fields).join(", ")}). It would expand to nothing.`);
|
|
40
|
-
shape = next;
|
|
2
|
+
const INTERPOLATION = "${facts.";
|
|
3
|
+
function assertInterpolationContract(fillSpec, sectionKey, schema) {
|
|
4
|
+
for (const decision of fillSpec.decisions) {
|
|
5
|
+
assertNoInterpolation(decision, sectionKey, `fill "${decision.id}"`);
|
|
6
|
+
const fields = decision.fields ?? {};
|
|
7
|
+
for (const [field, fill] of Object.entries(fields)) assertNoInterpolation(fill, sectionKey, `fill "${decision.id}" row field "${field}"`);
|
|
8
|
+
if (decision.kind === "display") for (const [entryKey, entry] of Object.entries(schema?.display ?? {})) {
|
|
9
|
+
const pick = entry?.fill?.pick;
|
|
10
|
+
if (typeof pick === "string" && pick.includes(INTERPOLATION)) throw new Error(interpolationMessage(sectionKey, `display ${entryKey}'s fill`, "brief"));
|
|
41
11
|
}
|
|
42
|
-
walked = `${walked}.${segment}`;
|
|
43
12
|
}
|
|
44
13
|
}
|
|
45
|
-
|
|
14
|
+
function assertNoInterpolation(fill, sectionKey, subject) {
|
|
15
|
+
if (typeof fill.brief === "string" && fill.brief.includes(INTERPOLATION)) throw new Error(interpolationMessage(sectionKey, subject, "brief"));
|
|
16
|
+
}
|
|
17
|
+
function interpolationMessage(sectionKey, subject, key) {
|
|
18
|
+
return `Section "${sectionKey}": ${subject}'s \`${key}\` interpolates \`\${facts.…}\`, which nothing expands — a fill is shown exactly its \`reads\`. Declare the fact in \`reads\` (\`reads: [fact.property.address]\`) and refer to it by name in the prose.`;
|
|
19
|
+
}
|
|
46
20
|
|
|
47
21
|
//#endregion
|
|
48
|
-
export {
|
|
22
|
+
export { assertInterpolationContract };
|
|
@@ -1,52 +1,33 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { originationFor } from "../../fill-vocabulary/dist/origination.js";
|
|
2
|
+
import { isListFill } from "./fill-spec-view.js";
|
|
2
3
|
|
|
3
4
|
//#region ../../internal/section-contracts/dist/list-fill-contract.js
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Whether each origination mode carries what it needs: `choose` a `{ min, max }`
|
|
8
|
-
* range, `extract` a `count` — a literal target or a band — and no `iterate`, `facts` an iterable
|
|
9
|
-
* property-facts array to walk, and `pool`/`curate` the prose brief that is
|
|
10
|
-
* their whole steer — and, for the two that originate without model discretion,
|
|
11
|
-
* that they declare no `none`. Throws on the first violation.
|
|
12
|
-
*/
|
|
13
|
-
function assertListFillContract(decision, sectionKey) {
|
|
5
|
+
const NO_ABSTENTION = ["bound-rows", "curate"];
|
|
6
|
+
function assertListFillContract(schema, decision, sectionKey) {
|
|
14
7
|
const fill = decision;
|
|
15
|
-
if (
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (
|
|
8
|
+
if (!isListFill(decision)) return;
|
|
9
|
+
for (const slotId of decision.produces) {
|
|
10
|
+
const slot = schema.slots[slotId];
|
|
11
|
+
if (slot === void 0) continue;
|
|
12
|
+
const origination = originationFor(slot);
|
|
13
|
+
if (origination === void 0 || origination.kind === "unkeyed-rows") continue;
|
|
14
|
+
assertOrigination(fill, origination, slot, `Section "${sectionKey}": list fill "${decision.id}"`);
|
|
21
15
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
if (fill.mode === "extract") {
|
|
34
|
-
if (fill.iterate !== void 0) throw new Error(`${where} generates rows against the facts slice, so it takes no \`iterate\` — declare a \`count\`, or \`mode: "facts"\` for one row per fact entry.`);
|
|
35
|
-
if (typeof fill.count === "number") return;
|
|
36
|
-
const band = fill.count;
|
|
37
|
-
if (typeof band?.min !== "number" || typeof band.max !== "number") throw new Error(`${where} generates rows but declares no \`count\` — a literal target, or \`{ min, max }\`.`);
|
|
38
|
-
if (band.min > band.max) throw new Error(`${where} declares count.min ${band.min} above count.max ${band.max} — a band the model can never answer inside.`);
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
if (fill.mode === "pool" || fill.mode === "curate") {
|
|
42
|
-
if (typeof fill.pick !== "string" || fill.pick.length === 0) throw new Error(`${where} originates rows by ${fill.mode} but declares no \`pick\` brief.`);
|
|
16
|
+
}
|
|
17
|
+
function assertOrigination(fill, origination, slot, where) {
|
|
18
|
+
if (fill.none !== void 0 && NO_ABSTENTION.includes(origination.kind)) throw new Error(`${where} declares \`none\`, but ${origination.kind === "curate" ? "a curated list" : "a fact-bound list"} has no discretion to abstain — its rows come from the platform's place search or from the facts. Drop \`none\`, or give a row field its own.`);
|
|
19
|
+
if (origination.kind === "bound-rows") {
|
|
20
|
+
for (const option of [
|
|
21
|
+
"brief",
|
|
22
|
+
"count",
|
|
23
|
+
"none"
|
|
24
|
+
]) if (fill[option] !== void 0) throw new Error(`${where} declares \`${option}\`, but its rows are the facts' it is bound to — only its row fields are filled. Drop it, or declare it on a row field.`);
|
|
43
25
|
return;
|
|
44
26
|
}
|
|
45
|
-
if (typeof fill.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (!isIterableFactsField(iterate)) throw new Error(`${where} iterate="${iterate}" is not an iterable facts array (allowed: ${FACTS_ARRAY_FIELDS.join(", ")}).`);
|
|
27
|
+
if (typeof fill.brief !== "string" || fill.brief.length === 0) throw new Error(`${where} originates rows but declares no \`brief\` — the brief is the whole instruction.`);
|
|
28
|
+
if ((origination.kind === "write-items" || origination.kind === "keyed-rows" && origination.keys === "written") && fill.count === void 0 && slot.max === void 0) throw new Error(`${where} writes its ${origination.kind === "write-items" ? "items" : "rows"} but neither it nor the slot says how many — declare a \`count\`, or give the slot a \`max\`.`);
|
|
29
|
+
const band = fill.count;
|
|
30
|
+
if (typeof band?.min === "number" && typeof band.max === "number" && band.min > band.max) throw new Error(`${where} declares count.min ${String(band.min)} above count.max ${String(band.max)} — a band the model can never answer inside.`);
|
|
50
31
|
}
|
|
51
32
|
|
|
52
33
|
//#endregion
|
|
@@ -1,25 +1,18 @@
|
|
|
1
|
+
import { originationFor } from "../../fill-vocabulary/dist/origination.js";
|
|
2
|
+
import { isListFill } from "./fill-spec-view.js";
|
|
3
|
+
|
|
1
4
|
//#region ../../internal/section-contracts/dist/name-title-contract.js
|
|
2
|
-
/**
|
|
3
|
-
* A `name` list fill producing a record list needs the slot's `title:` to name a
|
|
4
|
-
* `text` row field carrying a `cap` — the field the written name lands in, and
|
|
5
|
-
* the budget it is written to. Every other mode passes untouched. Throws on the
|
|
6
|
-
* first violation.
|
|
7
|
-
*/
|
|
8
5
|
function assertNameTitleContract(schema, decision, sectionKey) {
|
|
9
|
-
|
|
10
|
-
if (fill.type !== "list-fill" || fill.mode !== "name") return;
|
|
6
|
+
if (!isListFill(decision)) return;
|
|
11
7
|
for (const slotId of decision.produces) {
|
|
12
8
|
const slot = schema.slots[slotId];
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (
|
|
20
|
-
if (field.type !== "text") throw new Error(`${where} by "${title}", which is a \`${String(field.type)}\` field — a written name needs a \`text\` field.`);
|
|
21
|
-
if (typeof field.cap !== "number") throw new Error(`${where} by "${title}", which declares no \`cap\` — a written name needs its character budget.`);
|
|
22
|
-
if (decision.fields?.[title] !== void 0) throw new Error(`${where} by "${title}", which also carries its own fill — the written name is that field's value, so it takes none.`);
|
|
9
|
+
if (slot === void 0) continue;
|
|
10
|
+
const origination = originationFor(slot);
|
|
11
|
+
if (origination?.kind !== "keyed-rows" || origination.keys !== "written") continue;
|
|
12
|
+
const key = origination.keyField;
|
|
13
|
+
const where = `Section "${sectionKey}": list fill "${decision.id}" writes each row of "${slotId}" into "${key}"`;
|
|
14
|
+
if (typeof (slot.fields?.[key])?.cap !== "number") throw new Error(`${where}, which declares no \`cap\` — a written name needs its character budget.`);
|
|
15
|
+
if (decision.fields?.[key] !== void 0) throw new Error(`${where}, which also carries its own fill — the written name is that field's value, so it takes none.`);
|
|
23
16
|
}
|
|
24
17
|
}
|
|
25
18
|
|
|
@@ -1,17 +1,15 @@
|
|
|
1
|
+
import { originationFor } from "../../fill-vocabulary/dist/origination.js";
|
|
2
|
+
import { isListFill } from "./fill-spec-view.js";
|
|
3
|
+
|
|
1
4
|
//#region ../../internal/section-contracts/dist/poi-curation-contract.js
|
|
2
|
-
function curates(decision) {
|
|
3
|
-
return decision.type === "list-fill" && decision.mode === "curate";
|
|
4
|
-
}
|
|
5
|
-
/** Whether this slot's items are POIs, at either spelling of a POI list. */
|
|
6
|
-
function holdsPois(slot) {
|
|
7
|
-
return slot.type === "list" && slot.element?.type === "poi";
|
|
8
|
-
}
|
|
9
5
|
function assertPoiCurationContract(schema, decision, sectionKey) {
|
|
10
|
-
if (!
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
if (!isListFill(decision) || decision.produces.length <= 1) return;
|
|
7
|
+
const curated = decision.produces.find((slotId) => {
|
|
8
|
+
const slot = schema.slots[slotId];
|
|
9
|
+
return slot !== void 0 && originationFor(slot)?.kind === "curate";
|
|
10
|
+
});
|
|
11
|
+
if (curated === void 0) return;
|
|
12
|
+
throw new Error(`Section "${sectionKey}": POI curation decision "${decision.id}" must produce exactly one slot (got [${decision.produces.join(", ")}]) — "${curated}" is curated by one place search, which answers one list.`);
|
|
15
13
|
}
|
|
16
14
|
|
|
17
15
|
//#endregion
|
|
@@ -1,28 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { poolingPrimitiveOf } from "../../fill-vocabulary/dist/row-planners.js";
|
|
2
|
+
import { isListFill } from "./fill-spec-view.js";
|
|
2
3
|
|
|
3
4
|
//#region ../../internal/section-contracts/dist/pooling-field-contract.js
|
|
4
|
-
/**
|
|
5
|
-
* The unbound pooled-asset declarations one item carries, named as an author
|
|
6
|
-
* would find them: a record's field names, or `element` for a single-item list.
|
|
7
|
-
*/
|
|
8
5
|
function poolingDeclarationsOf(slot) {
|
|
9
6
|
if (slot.fields !== void 0) return Object.entries(slot.fields).filter(([, field]) => field.source === void 0 && poolingPrimitiveOf(field) !== void 0).map(([name]) => name);
|
|
10
7
|
return poolingPrimitiveOf(slot.element ?? {}) !== void 0 ? ["element"] : [];
|
|
11
8
|
}
|
|
12
|
-
/**
|
|
13
|
-
* Rejects a record item declaring more than one pooling field, and pool
|
|
14
|
-
* origination over an item that declares no pooled asset at all. Throws on the
|
|
15
|
-
* first violation.
|
|
16
|
-
*/
|
|
17
9
|
function assertPoolingFieldContract(schema, decision, sectionKey) {
|
|
18
|
-
if (decision
|
|
19
|
-
const { mode } = decision;
|
|
10
|
+
if (!isListFill(decision)) return;
|
|
20
11
|
for (const slotId of decision.produces) {
|
|
21
12
|
const slot = schema.slots[slotId];
|
|
22
13
|
if (!slot) continue;
|
|
23
14
|
const pooling = poolingDeclarationsOf(slot);
|
|
24
15
|
if (pooling.length > 1) throw new Error(`Section "${sectionKey}": list fill "${decision.id}" produces "${slotId}", whose item declares ${pooling.length} pooled fields (${pooling.join(", ")}) — a record item carries at most one, since the pool it draws from IS where its rows come from. Bind all but one to a fact with \`source:\`, or split the list.`);
|
|
25
|
-
if (mode === "pool" && pooling.length === 0) throw new Error(`Section "${sectionKey}": list fill "${decision.id}" originates rows from an asset pool, but "${slotId}" declares no ${POOLING_PRIMITIVES.join(" / ")} item.`);
|
|
26
16
|
}
|
|
27
17
|
}
|
|
28
18
|
|