@pipelex/mthds-form 0.33.0 → 0.34.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/dist/brand/index.js +2 -2
- package/dist/{chunk-UKTYADY3.js → chunk-5RV3ASMO.js} +141 -69
- package/dist/chunk-5RV3ASMO.js.map +1 -0
- package/dist/{chunk-VH5CDQDR.js → chunk-AURDKAIC.js} +3 -3
- package/dist/{chunk-VH5CDQDR.js.map → chunk-AURDKAIC.js.map} +1 -1
- package/dist/{chunk-ZX52CQJ4.js → chunk-CFBK7NO7.js} +3 -3
- package/dist/{chunk-ZX52CQJ4.js.map → chunk-CFBK7NO7.js.map} +1 -1
- package/dist/{chunk-3GO65HWP.js → chunk-PNNWNRPG.js} +11 -7
- package/dist/chunk-PNNWNRPG.js.map +1 -0
- package/dist/{chunk-XO5OENNF.js → chunk-TF4RTKLH.js} +32 -5
- package/dist/chunk-TF4RTKLH.js.map +1 -0
- package/dist/{chunk-IBBAJXIO.js → chunk-XIWBKV7T.js} +3 -3
- package/dist/{chunk-IBBAJXIO.js.map → chunk-XIWBKV7T.js.map} +1 -1
- package/dist/{chunk-4SRSGZWM.js → chunk-XYS5KCXB.js} +158 -31
- package/dist/chunk-XYS5KCXB.js.map +1 -0
- package/dist/core/gate.js +2 -2
- package/dist/core/index.js +4 -4
- package/dist/core/readiness.d.ts +34 -1
- package/dist/core/readiness.js +1 -1
- package/dist/core/seed.js +2 -2
- package/dist/core/values.js +2 -2
- package/dist/generative/headless/index.d.ts +15 -9
- package/dist/generative/headless/index.js +3 -2
- package/dist/generative/index.d.ts +27 -4
- package/dist/generative/index.js +628 -240
- package/dist/generative/index.js.map +1 -1
- package/dist/react/index.d.ts +30 -3
- package/dist/react/index.js +4 -4
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/dist/chunk-3GO65HWP.js.map +0 -1
- package/dist/chunk-4SRSGZWM.js.map +0 -1
- package/dist/chunk-UKTYADY3.js.map +0 -1
- package/dist/chunk-XO5OENNF.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/generative/schema.ts","../src/generative/shadcn-definitions.ts","../src/generative/components.ts","../src/generative/frame-definitions.ts","../src/generative/catalog.ts","../src/generative/props-signature.ts","../src/generative/designer-catalog.ts","../src/generative/prompt-hash.ts","../src/generative/expressions.ts","../src/generative/share-amount.ts","../src/generative/spec-shape.ts","../src/generative/zod-definition.ts","../src/generative/paths.ts","../src/generative/layout-fits.ts","../src/generative/validate.ts","../src/generative/designer-run.ts","../src/generative/brief.ts","../src/generative/stream.ts","../src/generative/state.ts","../src/generative/fixture.ts"],"names":["z","defineCatalog","components","definitionOf","shown","fieldAt","resolves","catalog","descend","declared","describe","isRecord"],"mappings":";;;;;;;AAqBO,IAAM,gBAAA,GAAmB,YAAA;AAAA,EAC9B,CAAC,CAAA,MAAO;AAAA,IACN,IAAA,EAAM,EAAE,MAAA,CAAO;AAAA,MACb,IAAA,EAAM,EAAE,MAAA,EAAO;AAAA,MACf,UAAU,CAAA,CAAE,MAAA;AAAA,QACV,EAAE,MAAA,CAAO;AAAA,UACP,IAAA,EAAM,CAAA,CAAE,GAAA,CAAI,oBAAoB,CAAA;AAAA,UAChC,KAAA,EAAO,CAAA,CAAE,OAAA,CAAQ,oBAAoB,CAAA;AAAA,UACrC,QAAA,EAAU,CAAA,CAAE,KAAA,CAAM,CAAA,CAAE,QAAQ,CAAA;AAAA,UAC5B,KAAA,EAAO,EAAE,GAAG,CAAA,CAAE,OAAO,CAAA,CAAE,KAAA,CAAM,CAAA,CAAE,MAAA,EAAQ,CAAC,CAAA,EAAG,GAAG,CAAA,CAAE,UAAS,EAAE;AAAA,UAC3D,OAAA,EAAS,EAAE,GAAG,CAAA,CAAE,KAAI,EAAG,GAAG,CAAA,CAAE,QAAA,EAAS,EAAE;AAAA,UACvC,MAAA,EAAQ,EAAE,GAAG,CAAA,CAAE,KAAI,EAAG,GAAG,CAAA,CAAE,QA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n * Our own json-render schema: the React schema's SHAPE and built-in actions,\n * verbatim, and nothing about prompting.\n *\n * Why not `@json-render/react`'s `schema`: it carries a prompt written for a\n * model that INVENTS data - an \"INITIAL STATE\" section demanding `/state`\n * patches for every bound path, and default rules asking three times for\n * realistic sample data. This layer's posture is the opposite: every value is\n * bound to a path the HOST loads. So the schema here declares no rules and no\n * prompt template at all. The prompt is the designer method's own\n * (`methods/layout-design.mthds`), which receives the catalog as data\n * (`designerCatalog()`) and lays it out in its own prose; `catalog.prompt()`\n * on a catalog over this schema renders json-render's stock text and is not\n * what any model is handed.\n *\n * The spec shape is unchanged because the renderer, the stream compiler and the\n * validator read it, and because a spec written against it renders through any\n * json-render registry.\n */\nexport const generativeSchema = defineSchema(\n (s) => ({\n spec: s.object({\n root: s.string(),\n elements: s.record(\n s.object({\n type: s.ref('catalog.components'),\n props: s.propsOf('catalog.components'),\n children: s.array(s.string()),\n slots: { ...s.record(s.array(s.string())), ...s.optional() },\n visible: { ...s.any(), ...s.optional() },\n repeat: { ...s.any(), ...s.optional() },\n }),\n ),\n }),\n catalog: s.object({\n components: s.map({\n props: s.zod(),\n slots: s.array(s.string()),\n description: s.string(),\n example: s.any(),\n }),\n actions: s.map({\n params: s.zod(),\n description: s.string(),\n }),\n }),\n }),\n {\n // The runtime handles these four without a registry handler; the names and\n // the wording are the React schema's, so a model that has seen json-render\n // before recognises them. The validator reads them to know which actions\n // need no handler, and `designerCatalog()` lists them first, marked\n // built-in, so the method's prompt names them beside the catalog's own.\n builtInActions: [\n {\n name: 'setState',\n description:\n 'Update a value in the state model at the given statePath. Params: { statePath: string, value: any }',\n },\n {\n name: 'pushState',\n description:\n 'Append an item to an array in state. Params: { statePath: string, value: any, clearStatePath?: string }.',\n },\n {\n name: 'removeState',\n description:\n 'Remove an item from an array in state by index. Params: { statePath: string, index: number }',\n },\n {\n name: 'validateForm',\n description:\n 'Validate all registered form fields and write the result to state. Params: { statePath?: string }. Defaults to /formValidation.',\n },\n ],\n },\n);\n","import { z } from 'zod';\n\n/**\n * The component DEFINITIONS the catalog picks from shadcn/ui, vendored.\n *\n * They are json-render's shadcn catalog entries, copied verbatim from\n * `@json-render/shadcn` at `0.20.0` for the subset `components.ts` picks and\n * nothing else. Vendoring them is what keeps the package off that dependency:\n * the definitions are zod and prose, the renderers are React over radix, and a\n * consumer of this entry should install neither. The controls vendor their\n * primitives for the same reason; see `docs/dependency-budget.md`.\n *\n * These strings ARE the prompt: `designerCatalog()` hands them to the designer\n * method as data, and the prompt hash is computed over the result.\n * `docs/generative-ui.md` states the pin, and `__tests__/prompt.test.ts` fails\n * the moment a character here moves - which is also what proves this copy\n * faithful to the definitions the captured layouts were produced against.\n */\n\nconst validationCheckSchema = z\n .array(\n z.object({\n type: z.string(),\n message: z.string(),\n args: z.record(z.string(), z.unknown()).optional(),\n }),\n )\n .nullable();\n\nconst validateOnSchema = z.enum(['change', 'blur', 'submit']).nullable();\n\nexport const shadcnComponentDefinitions = {\n // ── Layout ────────────────────────────────────────────────────────────────\n Card: {\n props: z.object({\n title: z.string().nullable(),\n description: z.string().nullable(),\n maxWidth: z.enum(['sm', 'md', 'lg', 'full']).nullable(),\n centered: z.boolean().nullable(),\n className: z.string().nullable().describe('Additional CSS classes'),\n }),\n slots: ['default'],\n description:\n 'Container card for content sections. Use for forms/content boxes, NOT for page headers.',\n example: { title: 'Overview', description: 'Your account summary' },\n },\n Stack: {\n props: z.object({\n direction: z.enum(['horizontal', 'vertical']).nullable(),\n gap: z.enum(['none', 'sm', 'md', 'lg', 'xl']).nullable(),\n align: z.enum(['start', 'center', 'end', 'stretch']).nullable(),\n justify: z.enum(['start', 'center', 'end', 'between', 'around']).nullable(),\n className: z.string().nullable().describe('Additional CSS classes'),\n }),\n slots: ['default'],\n description: 'Flex container for layouts',\n example: { direction: 'vertical', gap: 'md' },\n },\n Grid: {\n props: z.object({\n columns: z.number().nullable(),\n gap: z.enum(['sm', 'md', 'lg', 'xl']).nullable(),\n className: z.string().nullable().describe('Additional CSS classes'),\n }),\n slots: ['default'],\n description: 'Grid layout (1-6 columns)',\n example: { columns: 3, gap: 'md' },\n },\n Separator: {\n props: z.object({\n orientation: z.enum(['horizontal', 'vertical']).nullable(),\n }),\n description: 'Visual separator line',\n },\n Collapsible: {\n props: z.object({\n title: z.string(),\n defaultOpen: z.boolean().nullable(),\n }),\n slots: ['default'],\n description: 'Collapsible section with trigger. Children render inside.',\n },\n // ── Content ───────────────────────────────────────────────────────────────\n Heading: {\n props: z.object({\n text: z.string(),\n level: z.enum(['h1', 'h2', 'h3', 'h4']).nullable(),\n }),\n description: 'Heading text (h1-h4)',\n example: { text: 'Welcome', level: 'h1' },\n },\n Text: {\n props: z.object({\n text: z.string(),\n variant: z.enum(['body', 'caption', 'muted', 'lead', 'code']).nullable(),\n }),\n description: 'Paragraph text',\n example: { text: 'Hello, world!' },\n },\n Avatar: {\n props: z.object({\n src: z.string().nullable(),\n name: z.string(),\n size: z.enum(['sm', 'md', 'lg']).nullable(),\n }),\n description: 'User avatar with fallback initials',\n example: { name: 'Jane Doe', size: 'md' },\n },\n Badge: {\n props: z.object({\n text: z.string(),\n variant: z.enum(['default', 'secondary', 'destructive', 'outline']).nullable(),\n }),\n description: 'Status badge',\n example: { text: 'Active', variant: 'default' },\n },\n Alert: {\n props: z.object({\n title: z.string(),\n message: z.string().nullable(),\n type: z.enum(['info', 'success', 'warning', 'error']).nullable(),\n }),\n description: 'Alert banner',\n example: {\n title: 'Note',\n message: 'Your changes have been saved.',\n type: 'success',\n },\n },\n Progress: {\n props: z.object({\n value: z.number(),\n max: z.number().nullable(),\n label: z.string().nullable(),\n }),\n description: 'Progress bar (value 0-100)',\n example: { value: 65, max: 100, label: 'Upload progress' },\n },\n // ── Inputs ────────────────────────────────────────────────────────────────\n Input: {\n props: z.object({\n label: z.string(),\n name: z.string(),\n type: z.enum(['text', 'email', 'password', 'number']).nullable(),\n placeholder: z.string().nullable(),\n value: z.string().nullable(),\n checks: validationCheckSchema,\n validateOn: validateOnSchema,\n }),\n events: ['submit', 'focus', 'blur'],\n description:\n 'Text input field. Use { $bindState } on value for two-way binding. Use checks for validation (e.g. required, email, minLength). validateOn controls timing (default: blur).',\n example: {\n label: 'Email',\n name: 'email',\n type: 'email',\n placeholder: 'you@example.com',\n },\n },\n Textarea: {\n props: z.object({\n label: z.string(),\n name: z.string(),\n placeholder: z.string().nullable(),\n rows: z.number().nullable(),\n value: z.string().nullable(),\n checks: validationCheckSchema,\n validateOn: validateOnSchema,\n }),\n description:\n 'Multi-line text input. Use { $bindState } on value for binding. Use checks for validation. validateOn controls timing (default: blur).',\n },\n Select: {\n props: z.object({\n label: z.string(),\n name: z.string(),\n options: z.array(z.string().min(1)),\n placeholder: z.string().nullable(),\n value: z.string().nullable(),\n checks: validationCheckSchema,\n validateOn: validateOnSchema,\n }),\n events: ['change'],\n description:\n 'Dropdown select input. Use { $bindState } on value for binding. Use checks for validation. validateOn controls timing (default: change).',\n },\n Radio: {\n props: z.object({\n label: z.string(),\n name: z.string(),\n options: z.array(z.string().min(1)),\n value: z.string().nullable(),\n checks: validationCheckSchema,\n validateOn: validateOnSchema,\n }),\n events: ['change'],\n description:\n 'Radio button group. Use { $bindState } on value for binding. Use checks for validation. validateOn controls timing (default: change).',\n },\n Checkbox: {\n props: z.object({\n label: z.string(),\n name: z.string(),\n checked: z.boolean().nullable(),\n checks: validationCheckSchema,\n validateOn: validateOnSchema,\n }),\n events: ['change'],\n description:\n 'Checkbox input. Use { $bindState } on checked for binding. Use checks for validation. validateOn controls timing (default: change).',\n },\n Switch: {\n props: z.object({\n label: z.string(),\n name: z.string(),\n checked: z.boolean().nullable(),\n checks: validationCheckSchema,\n validateOn: validateOnSchema,\n }),\n events: ['change'],\n description:\n 'Toggle switch. Use { $bindState } on checked for binding. Use checks for validation. validateOn controls timing (default: change).',\n },\n // ── Actions ───────────────────────────────────────────────────────────────\n Button: {\n props: z.object({\n label: z.string(),\n variant: z.enum(['primary', 'secondary', 'danger']).nullable(),\n disabled: z.boolean().nullable(),\n }),\n events: ['press'],\n description: 'Clickable button. Bind on.press for handler.',\n example: { label: 'Submit', variant: 'primary' },\n },\n};\n","import { defineCatalog } from '@json-render/core';\nimport { z } from 'zod';\nimport { generativeSchema } from './schema';\nimport { shadcnComponentDefinitions } from './shadcn-definitions';\n\n/**\n * The base vocabulary: what a spec may be made of, before the product page's\n * own components are added on top of it in `catalog.ts`.\n *\n * Two layers. From shadcn/ui's catalog, the subset a page needs and nothing\n * that cannot bind: not its `Tabs` (its panels do not follow the active tab),\n * not `Accordion` (its items are strings and cannot hold a subtree), not\n * `Table` (rows as inline strings), not `Slider` (a slider needs bounds, and\n * the standard states none on a number - a range a model invents narrows the\n * input). Then the layer's own: the two escape hatches, the bound equivalents\n * of what a model most wants to inline (`DataTable`, `Metric`), and the\n * vocabulary of an APP rather than a form - `Tabs` whose panels follow the\n * active tab, `Steps` for a journey, `Split` for a rail beside the work,\n * `Segmented` for a choice as pills, `NumberInput` that writes a number, and\n * `Icon` to give a section a face.\n *\n * `className` is omitted from every picked definition: an arbitrary utility a\n * model invents is one the Storybook build never compiled, and a colour it\n * invents is one that ignores the theme.\n *\n * Zod only, importable from node with no DOM: `designerCatalog()` renders\n * these definitions into the data the designer method takes, and the prompt\n * hash is computed over the result, so what is written here is part of the\n * pinned prompt. Erasable syntax only (no enums, no namespaces, no parameter\n * properties), because node strips the types itself.\n */\n\nconst shadcn = shadcnComponentDefinitions;\n\n/** The shadcn subset, by name. The order is the order the prompt lists them. */\nexport const PICKED_SHADCN = [\n 'Card',\n 'Stack',\n 'Grid',\n 'Separator',\n 'Heading',\n 'Text',\n 'Badge',\n 'Alert',\n 'Collapsible',\n 'Progress',\n 'Avatar',\n 'Input',\n 'Textarea',\n 'Select',\n 'Radio',\n 'Checkbox',\n 'Switch',\n 'Button',\n] as const;\n\nexport type PickedShadcnName = (typeof PICKED_SHADCN)[number];\n\n/** Our own, by name. */\nexport const CUSTOM_COMPONENTS = [\n 'Split',\n 'Tabs',\n 'Steps',\n 'Icon',\n 'Segmented',\n 'NumberInput',\n 'MthdsField',\n 'MthdsResult',\n 'DataTable',\n 'Metric',\n] as const;\n\nexport type CustomComponentName = (typeof CUSTOM_COMPONENTS)[number];\n\n/**\n * The value formats a `Metric` can apply. A model picks one; the registry\n * formats with `Intl.NumberFormat`.\n */\nexport const METRIC_FORMATS = ['plain', 'integer', 'decimal', 'compact'] as const;\n\n/**\n * The icons a spec may name: lucide's, a closed list so a misspelt name fails\n * validation rather than rendering nothing. Chosen for what pages about\n * methods talk about - people, places, money, time, files, standing.\n */\nexport const ICON_NAMES = [\n 'Sparkles',\n 'Rocket',\n 'Compass',\n 'Map',\n 'MapPin',\n 'Route',\n 'Plane',\n 'Train',\n 'Car',\n 'Ship',\n 'Hotel',\n 'Home',\n 'Building2',\n 'Landmark',\n 'Globe',\n 'Mountain',\n 'Leaf',\n 'Sun',\n 'Moon',\n 'Calendar',\n 'Clock',\n 'Hourglass',\n 'Users',\n 'User',\n 'Baby',\n 'Accessibility',\n 'Heart',\n 'Star',\n 'Utensils',\n 'Coffee',\n 'Music',\n 'Camera',\n 'Image',\n 'Ticket',\n 'Gift',\n 'Wallet',\n 'Banknote',\n 'Coins',\n 'Receipt',\n 'Percent',\n 'Hash',\n 'TrendingUp',\n 'BarChart3',\n 'FileText',\n 'Upload',\n 'Paperclip',\n 'Mail',\n 'Phone',\n 'Tag',\n 'Layers',\n 'ListChecks',\n 'CheckCircle2',\n 'AlertCircle',\n 'Info',\n 'Shield',\n 'Flag',\n 'Bookmark',\n 'Briefcase',\n 'Package',\n 'Truck',\n 'Lightbulb',\n 'Zap',\n 'Pencil',\n 'Send',\n] as const;\n\nexport type IconName = (typeof ICON_NAMES)[number];\n\nconst components = {\n // ── Layout (shadcn) ────────────────────────────────────────────────────\n Card: {\n ...shadcn.Card,\n props: shadcn.Card.props.omit({ className: true, maxWidth: true, centered: true }),\n description:\n 'Container card for content sections. Use for forms/content boxes, NOT for page headers. Its optional \"title\" renders as an h3, so a titled Card sits under an h2.',\n },\n Stack: { ...shadcn.Stack, props: shadcn.Stack.props.omit({ className: true }) },\n Grid: { ...shadcn.Grid, props: shadcn.Grid.props.omit({ className: true }) },\n Separator: shadcn.Separator,\n Collapsible: shadcn.Collapsible,\n // ── Content (shadcn) ───────────────────────────────────────────────────\n Heading: shadcn.Heading,\n Text: shadcn.Text,\n Badge: shadcn.Badge,\n Alert: shadcn.Alert,\n Progress: shadcn.Progress,\n Avatar: {\n ...shadcn.Avatar,\n description:\n 'A round avatar showing the initials of \"name\" - bind it to a person\\'s name in the state ({ \"$state\" } or { \"$item\" }); never set \"src\".',\n },\n // ── Inputs (shadcn) ────────────────────────────────────────────────────\n Input: shadcn.Input,\n Textarea: shadcn.Textarea,\n Select: shadcn.Select,\n Radio: shadcn.Radio,\n Checkbox: shadcn.Checkbox,\n Switch: shadcn.Switch,\n Button: shadcn.Button,\n // ── Layout (ours) ──────────────────────────────────────────────────────\n Split: {\n props: z.object({\n ratio: z.enum(['1:1', '1:2', '2:1']).nullable(),\n gap: z.enum(['md', 'lg', 'xl']).nullable(),\n }),\n slots: ['default'],\n description:\n 'Two columns side by side, from exactly two children: the first is the left column. \"1:2\" puts a narrow rail (a summary, the essentials, the run) beside the work; \"2:1\" the reverse; \"1:1\" two halves. Columns stack on a narrow screen.',\n example: { ratio: '1:2', gap: 'lg' },\n },\n Tabs: {\n props: z.object({\n tabs: z.array(z.object({ label: z.string(), value: z.string() })).min(2),\n }),\n slots: ['default'],\n description:\n \"Concerns of equal weight, one visible at a time. Exactly one child per tab, in the same order - each child is that tab's panel (usually a Stack). The first tab opens. The active tab is the component's own state, never /state.\",\n example: {\n tabs: [\n { label: 'The trip', value: 'trip' },\n { label: 'Who is going', value: 'people' },\n ],\n },\n },\n Steps: {\n props: z.object({\n steps: z.array(z.string()).min(2),\n nextLabel: z.string().nullable(),\n backLabel: z.string().nullable(),\n }),\n slots: ['default'],\n description:\n \"A journey with a natural order: a numbered indicator, one panel at a time, and its own Back and Next. Exactly one child per step, in order - each child is that step's panel. Put the Button that runs inside the LAST panel; Next disappears there. The current step is the component's own state, never /state.\",\n example: { steps: ['Where', 'Who', 'How'], nextLabel: 'Continue' },\n },\n Icon: {\n props: z.object({\n name: z.enum(ICON_NAMES),\n size: z.enum(['sm', 'md', 'lg']).nullable(),\n }),\n slots: [],\n description:\n 'A decorative icon, one of the listed lucide names, to give a section or a figure a face: put it in a horizontal Stack beside a Heading or a Metric. It carries no meaning on its own and no text.',\n example: { name: 'Plane', size: 'md' },\n },\n // ── Inputs (ours) ──────────────────────────────────────────────────────\n Segmented: {\n props: z.object({\n label: z.string(),\n name: z.string(),\n options: z.array(z.string().min(1)).min(2).max(6),\n value: z.string().nullable(),\n }),\n slots: [],\n description:\n 'A choice of two to six options as a row of pills, one selected - the app\\'s answer to a short Select. \"options\" are EXACTLY the brief\\'s choices, spelled exactly; bind \"value\" with { \"$bindState\": \"/inputs/...\" }.',\n example: {\n label: 'Pace',\n name: 'pace',\n options: ['slow', 'balanced', 'packed'],\n value: { $bindState: '/inputs/request/pace' },\n },\n },\n NumberInput: {\n props: z.object({\n label: z.string(),\n name: z.string(),\n value: z.number().nullable(),\n placeholder: z.string().nullable(),\n unit: z.string().nullable(),\n min: z.number().nullable(),\n max: z.number().nullable(),\n step: z.number().nullable(),\n }),\n slots: [],\n description:\n 'A figure the person types: writes a NUMBER to the bound path, which Input type \"number\" does not (it writes text). Bind \"value\" with { \"$bindState\": \"/inputs/...\" }. \"unit\" is a short suffix ONLY when the brief states one; \"min\", \"max\" and \"step\" only when the brief states them.',\n example: {\n label: 'Budget',\n name: 'budget',\n value: { $bindState: '/inputs/request/budget' },\n placeholder: '2500',\n },\n },\n // ── The escape hatches and the bound equivalents (ours) ────────────────\n MthdsField: {\n props: z.object({\n path: z.string(),\n // The page words the label and the line under it, as it words every other control.\n label: z.string().nullable(),\n hint: z.string().nullable(),\n }),\n slots: [],\n description:\n 'The kernel\\'s own control for ONE input, bound two-way at \"path\" (a /inputs path from the brief). Use it for every path the brief marks as delegated - a file, a date, a list, a structure you would rather not lay out - and for any scalar you would rather not style. It renders the descriptor\\'s label and description unless the page words them: \"label\" replaces the label, \"hint\" the line under it. Inside a repeat, \"path\" is the item\\'s field name relative to the item (\"lines\"), never an $item expression.',\n example: { path: '/inputs/source' },\n },\n MthdsResult: {\n props: z.object({\n path: z.string(),\n hideLabel: z.boolean().nullable(),\n }),\n slots: [],\n description:\n 'The kernel\\'s own read-only rendering of ONE result subtree at \"path\" (a /result path from the brief). Use it for every path the brief marks as delegated - a file, a date, a document, prose, markup - and for any structure you choose not to lay out. It renders its own label unless hideLabel is true. Inside a repeat, \"path\" is the item\\'s field name relative to the item (\"teams\"), never an $item expression - the way to delegate one subtree of every item.',\n example: { path: '/result/issued_on' },\n },\n DataTable: {\n props: z.object({\n rows: z.any(),\n // A column says how its cells read, from the kind the brief states.\n columns: z.array(\n z.object({\n path: z.string(),\n label: z.string(),\n format: z.enum(['text', 'date', 'number']).nullable().optional(),\n }),\n ),\n caption: z.string().nullable(),\n }),\n slots: [],\n description:\n 'A table over a list of structures. \"rows\" MUST be { \"$state\": \"/path/to/the/list\" } (never inline rows); each column names a field of one item by its relative path (\"label\", \"unit_price\"), the header to show for it, and how its cells read: \"date\" for a date path (written \"9 Mar 2025\"), \"number\" for a number path (digits grouped), \"text\" otherwise.',\n example: {\n rows: { $state: '/result/lines' },\n columns: [\n { path: 'label', label: 'Item' },\n { path: 'quantity', label: 'Qty' },\n ],\n },\n },\n Metric: {\n props: z.object({\n label: z.string(),\n value: z.any(),\n unit: z.string().nullable(),\n format: z.enum(METRIC_FORMATS).nullable(),\n }),\n slots: [],\n description:\n 'A labelled figure - the one number a reader looks for first. \"value\" is bound with { \"$state\": \"/path\" } (never inline); \"unit\" is a short suffix and ONLY one the brief states (a currency the structure carries, \"%\" for a rate, \"M\" when the brief says \"in millions\") - never invent a currency the state does not carry; \"format\" is plain, integer, decimal (two places) or compact.',\n example: { label: 'Total', value: { $state: '/result/total' }, unit: 'EUR', format: 'decimal' },\n },\n};\n\nconst actions = {\n run: {\n params: z.object({}),\n description:\n 'Start the run with the current /inputs. The host handles it; an input page binds it to its one Button after validateForm.',\n },\n};\n\n/**\n * The base catalog, for the renderers in `registry.tsx` to be typed against.\n * It renders no prompt: the catalog a model is handed is `catalog.ts`'s, which\n * extends this vocabulary with the product page's own.\n */\nexport const baseCatalog = defineCatalog(generativeSchema, { components, actions });\n\n/**\n * The two maps, for the catalog that EXTENDS this vocabulary. Exporting them\n * changes nothing about the prompt or its hash.\n */\nexport const generativeComponents = components;\nexport const generativeActions = actions;\n","import { z } from 'zod';\n\n/**\n * The frames a layout is written for, and the vocabulary each adds.\n *\n * `page` is a whole product page of its own, the frame every layout had\n * before a host drew one around it. `composer` and `result` are the two\n * moments of a host's compose-then-result app: the inputs before a run, in a\n * centred column whose host draws the band above it and the action row's\n * mechanics, and the result after one, under the host's bar restating the\n * request. The two moments carry their own components, found by measuring the\n * designer against hand-drawn screens of several methods: the composer's frame\n * (`Composer`, with the page's h1, the panel and the host's action row) and a\n * group of inputs inside it, and a result's header, a proportion bar, colour\n * swatches, a picture, a fact, a labelled detail, a date in words and a list\n * of short texts. A date range, chips for a list of texts and compact rows\n * for a list of structures were found too, and went to the kernel's own\n * controls instead, since they improve the plain form as much as a designed\n * one: a composer delegates those inputs to `MthdsField`.\n *\n * Zod only, importable from node: `designerCatalog()` renders these into the\n * data the designer method takes. Each description says what the component IS\n * and how it renders, never where a page must put it.\n */\n\n/** The frame a layout is written for: a whole product page, or one of the two moments of a host's compose-then-result app. */\nexport const FRAMES = ['page', 'composer', 'result'] as const;\nexport type Frame = (typeof FRAMES)[number];\n\n/** The components the composer frame adds to the catalog. */\nexport const COMPOSER_COMPONENTS = ['Composer', 'FieldGroup'] as const;\n/** The components the result frame adds to the catalog. */\nexport const RESULT_COMPONENTS = [\n 'ResultHeader',\n 'ProportionBar',\n 'Swatches',\n 'Picture',\n 'Fact',\n 'Detail',\n 'DateText',\n 'TextList',\n] as const;\n/** Every component a frame adds, which the `page` frame's vocabulary leaves out. */\nexport const FRAME_COMPONENTS = [...COMPOSER_COMPONENTS, ...RESULT_COMPONENTS] as const;\n\nexport const frameComponents = {\n Composer: {\n props: z.object({\n headline: z.string(),\n lede: z.string().nullable(),\n runLabel: z.string(),\n columns: z.enum(['1', '2']).nullable(),\n notes: z.array(z.string()).nullable(),\n }),\n slots: ['default'],\n events: ['press'],\n description:\n 'The composer: the page\\'s headline (rendered as the h1) and one muted line under it, then a single raised panel holding its children - the inputs - in one column, or two columns side by side when \"columns\" is \"2\", and at the panel\\'s foot the host\\'s action row: how long a run takes, as the host knows it, and the one button that runs the method, worded by \"runLabel\". The action row stays on screen while a long panel scrolls. It is the control that runs the method: bind on.press to validateForm then run. \"notes\" are a few short lines set under the panel, each after a check mark, in two columns: what one run gives back, in a person\\'s words.',\n example: {\n headline: 'A day-by-day plan for your trip',\n lede: 'Tell us who is going, where and when.',\n runLabel: 'Plan my trip',\n columns: '2',\n },\n },\n FieldGroup: {\n props: z.object({ title: z.string().nullable() }),\n slots: ['default'],\n description:\n 'A quiet group of inputs inside a panel: an optional small h2 title, then its children stacked with even spacing. No box, no rule: the panel around it is the surface.',\n example: { title: 'Where and when' },\n },\n ResultHeader: {\n props: z.object({\n eyebrow: z.string().nullable(),\n title: z.string(),\n subtitle: z.string().nullable(),\n }),\n slots: [],\n description:\n 'The result\\'s heading: a small eyebrow in the accent colour, the title (rendered as the h1) and one muted line under it, with the host\\'s actions on the result (download, share) at the right. Text props may be read from the state with { \"$state\" } or { \"$template\" }.',\n example: {\n eyebrow: 'Your plan',\n title: { $state: '/result/title' },\n subtitle: { $template: '${/result/currency} ${/result/estimated_total} estimated' },\n },\n },\n ProportionBar: {\n props: z.object({\n label: z.string(),\n total: z.number().nullable(),\n of: z.number().nullable(),\n unit: z.string().nullable(),\n items: z.array(z.any()).nullable(),\n labelKey: z.string(),\n valueKey: z.string(),\n }),\n slots: [],\n description:\n 'A labelled total over its parts, in a raised panel: the label and the total in large figures (\"of\" a ceiling when there is one), then one bar split in proportion to each part, and a legend naming each part with its amount. \"items\" is { \"$state\": ... } on a list of structures; \"labelKey\" and \"valueKey\" name the member of one item that labels it and the number that sizes it. \"unit\" is a currency or unit the state carries, read with { \"$state\" }.',\n example: {\n label: 'Estimated cost',\n total: { $state: '/result/estimated_total' },\n unit: { $state: '/result/currency' },\n items: { $state: '/result/costs' },\n labelKey: 'category',\n valueKey: 'amount',\n },\n },\n Swatches: {\n props: z.object({ colors: z.array(z.string()) }),\n slots: [],\n description:\n 'A row of colour swatches, each a small tile filled with the colour and its value written under it in mono. \"colors\" is a list of colour values, each read from a text path ({ \"$state\" }, or { \"$item\" } inside a repeat).',\n example: { colors: [{ $item: 'colors/primary' }, { $item: 'colors/accent' }] },\n },\n Picture: {\n props: z.object({\n path: z.string(),\n alt: z.string().nullable(),\n aspect: z.enum(['16:9', '4:3', '1:1', 'auto']).nullable(),\n }),\n slots: [],\n description:\n 'A picture the run produced, shown whole and edge to edge in its column with a hairline border, cropped to \"aspect\" when one is set. \"path\" is an image path of the brief, literally (\"/result/cover\"), or relative to the item inside a repeat (\"\" for the item itself, when the repeat is over a list of images).',\n example: { path: '/result/cover', alt: 'The cover', aspect: '16:9' },\n },\n Fact: {\n props: z.object({\n label: z.string(),\n value: z.any(),\n detail: z.string().nullable(),\n }),\n slots: [],\n description:\n 'One fact as a small boxed tile: a muted label, the value under it, and an optional muted detail. Several in a Grid make a band of facts. \"value\" is a scalar read with { \"$state\" } or { \"$template\" }.',\n example: { label: 'Order number', value: { $state: '/result/number' } },\n },\n DateText: {\n props: z.object({\n value: z.string().nullable(),\n style: z.enum(['long', 'short', 'weekday']).nullable(),\n tone: z.enum(['default', 'muted', 'accent']).nullable(),\n }),\n slots: [],\n description:\n 'A date written in words: \"long\" is \"Wednesday 14 April 2027\", \"short\" is \"14 Apr 2027\", \"weekday\" is \"Wed 14 April\". \"value\" is a date path read with { \"$state\" } or { \"$item\" }; \"tone\" colours it muted or in the accent colour, as an eyebrow over a title.',\n example: { value: { $item: 'day' }, style: 'weekday', tone: 'accent' },\n },\n TextList: {\n props: z.object({\n items: z.array(z.string()).nullable(),\n marker: z.enum(['bullet', 'number', 'check']).nullable(),\n }),\n slots: [],\n description:\n 'A list of short texts as one list, each entry a line with a small marker before it: a dot, its number or a check. \"items\" reads a list of text path with { \"$state\" }, or { \"$item\" } inside a repeat - the whole list at once, so it needs no repeat of its own.',\n example: { items: { $state: '/result/notes' }, marker: 'bullet' },\n },\n Detail: {\n props: z.object({\n label: z.string(),\n value: z.any(),\n }),\n slots: [],\n description:\n 'A labelled line of text: the label muted in a narrow column at the left, the value wrapping beside it, a hairline under the line. Several in a column read as a list of details. \"value\" is a scalar read with { \"$state\" }, { \"$item\" } or { \"$template\" }; the line hides itself while the value is empty.',\n example: { label: 'Morning', value: { $item: 'morning' } },\n },\n};\n","import { defineCatalog } from '@json-render/core';\nimport { z } from 'zod';\nimport {\n CUSTOM_COMPONENTS,\n PICKED_SHADCN,\n generativeActions,\n generativeComponents,\n} from './components';\nimport { generativeSchema } from './schema';\nimport {\n COMPOSER_COMPONENTS,\n FRAME_COMPONENTS,\n RESULT_COMPONENTS,\n frameComponents,\n type Frame,\n} from './frame-definitions';\nimport type { ComponentRendering, ValidationCatalog } from './validate';\n\n/**\n * The catalog: everything the base vocabulary has, plus the chrome of a\n * product page - a bar with the logo, a hero, a workspace that puts a panel\n * beside the work, a section, a raised rail, the summary rows a rail can be\n * made of, a call to action, a footer line. They are vocabulary, not a\n * template: the designer method prescribes no composition, and a layout uses\n * whichever of them serve it. Each description says what the component IS and\n * how it renders - a heading level, a landmark, a fixed child count - and never\n * where it must go or whether a page must have it, because the descriptions\n * travel to the model as data and would otherwise be the mandate the method\n * gave up. The vocabulary names no brand: the logo is whichever the manifest\n * carries and the accent is whichever the host's theme tokens set.\n *\n * Rule 1 holds here as it does everywhere in this entry: a component takes\n * copy and bound values, never a schema, and the fields the kernel owns are\n * still `MthdsField` elements naming a path.\n */\n\nexport const PRODUCT_COMPONENTS = [\n 'AppBar',\n 'Hero',\n 'Workspace',\n 'Section',\n 'Rail',\n 'SummaryRow',\n 'Cta',\n 'Footer',\n] as const;\n\nexport type ProductComponentName = (typeof PRODUCT_COMPONENTS)[number];\n\nconst product = {\n AppBar: {\n props: z.object({\n app: z.string(),\n links: z.array(z.string()).nullable(),\n tag: z.string().nullable(),\n }),\n slots: [],\n description:\n \"A bar across the top of the page: the brand's logo, the name of this app beside it, a few muted links, and a small mono tag at the right (the method behind the page). It renders as the page's banner, so at most one.\",\n example: { app: 'Trip planner', links: ['Methods', 'Runs'], tag: 'plan_trip' },\n },\n Hero: {\n props: z.object({\n headline: z.string(),\n lede: z.string().nullable(),\n eyebrow: z.string().nullable(),\n }),\n slots: [],\n description:\n 'An opening: one bold headline that says what happens here, one muted line under it at most, and an optional small eyebrow in the accent colour above. The headline renders as an h1, so at most one on a page.',\n example: { headline: 'Plan a trip worth taking.', lede: 'Tell us where and who is coming.' },\n },\n Workspace: {\n props: z.object({ rail: z.enum(['right', 'left']).nullable() }),\n slots: ['default'],\n description:\n 'Two children side by side on a wide screen and stacked on a narrow one: the work, and beside it a narrower panel that stays sticky while the work scrolls. Exactly two children; \"rail\" says which side the panel takes, right by default.',\n example: { rail: 'right' },\n },\n Section: {\n props: z.object({\n number: z.string().nullable(),\n title: z.string(),\n lede: z.string().nullable(),\n }),\n slots: ['default'],\n description:\n 'A titled stage of the work: an optional small mono number in the accent colour, an h2 title, an optional muted line, then its children - flat, spaced, separated from the next Section by a hairline, never boxed.',\n example: { number: '01', title: 'Where and when' },\n },\n Rail: {\n props: z.object({ title: z.string() }),\n slots: ['default'],\n description:\n 'A raised, boxed panel: a small uppercase h2 title, then its children in a column. Made to stand beside the work as the panel of a Workspace, and the one boxed surface in this vocabulary.',\n example: { title: 'Your trip' },\n },\n SummaryRow: {\n props: z.object({\n label: z.string(),\n value: z.any().nullable(),\n detail: z.any().nullable(),\n separator: z.string().nullable(),\n placeholder: z.string().nullable(),\n }),\n slots: [],\n description:\n 'A line that restates a value: a muted label at the left, a bound value at the right. \"value\" and the optional \"detail\" are read with { \"$state\": \"/inputs/...\" } and joined by \"separator\" (a space by default); each is a scalar path - text, number, boolean, date or choice - never a structure, a list or a file. While both are empty the row shows \"placeholder\", or a dash.',\n example: {\n label: 'Budget',\n value: { $state: '/inputs/request/budget' },\n detail: { $state: '/inputs/request/currency' },\n },\n },\n Cta: {\n props: z.object({ label: z.string(), hint: z.string().nullable() }),\n slots: [],\n events: ['press'],\n description:\n 'A call to action: a full-width button in the accent colour that runs the method, with an optional one-line hint under it. Bind on.press to validateForm then run.',\n example: { label: 'Plan my trip', hint: 'Nothing runs until the request is complete.' },\n },\n Footer: {\n props: z.object({ text: z.string(), tag: z.string().nullable() }),\n slots: [],\n description:\n \"A closing line, muted, with an optional mono tag at the right. It renders as the page's contentinfo, so at most one.\",\n example: { text: 'Runs on Pipelex.', tag: 'MTHDS' },\n },\n};\n\n/**\n * What this entry's components render beyond their schemas - the heading a\n * title is, the landmark a bar or a footer renders as, the two children a\n * split lays out, the panel per tab or step - declared once here, where the\n * descriptions above say the same in prose for the model, and carried on the\n * catalog so the validator reads it off whichever catalog it is handed. A\n * host validating against a vocabulary of its own declares what its\n * renderers do, or nothing.\n */\nexport const COMPONENT_RENDERINGS: Readonly<Record<string, ComponentRendering>> = {\n Hero: { heading: { level: 1 } },\n Section: { heading: { level: 2 } },\n Rail: { heading: { level: 2 } },\n Card: { heading: { level: 3, when: 'title' } },\n AppBar: { once: \"the page's banner\" },\n Footer: { once: \"the page's contentinfo\" },\n Split: { children: { count: 2, roles: 'left, right' } },\n Workspace: { children: { count: 2, roles: 'work, rail' } },\n Tabs: { panels: { prop: 'tabs', noun: 'tab' } },\n Steps: { panels: { prop: 'steps', noun: 'step' } },\n Composer: { heading: { level: 1 }, once: 'the composer' },\n ResultHeader: { heading: { level: 1 }, once: \"the result's header\" },\n FieldGroup: { heading: { level: 2, when: 'title' } },\n};\n\nexport const catalog = Object.assign(\n defineCatalog(generativeSchema, {\n components: { ...generativeComponents, ...product, ...frameComponents },\n actions: generativeActions,\n }),\n { renders: COMPONENT_RENDERINGS },\n);\n\n/** The spec type a layout is written against. */\nexport type GenerativeSpec = typeof catalog._specType;\n\n/**\n * Every component name the catalog knows, the shadcn subset first. This is\n * the order the designer method lists them in, since `designerCatalog()`\n * walks it; the rules and the direction that name them are the method's own\n * prose, in `methods/layout-design.mthds`.\n */\nexport const COMPONENT_NAMES: readonly string[] = [\n ...PICKED_SHADCN,\n ...CUSTOM_COMPONENTS,\n ...PRODUCT_COMPONENTS,\n];\n\n/**\n * The vocabulary of each frame, in the order the designer method lists it.\n * `page` is the product page: the base vocabulary and the product chrome, with\n * none of the frames' own components, so a component added to either joins it.\n * `composer` and `result` are the two moments of a host's compose-then-result\n * app, and each is an allow-list, so a component added to the catalog joins\n * neither until it is named here: their host draws the band, the action row's\n * mechanics, the request bar and the result's actions, so they leave out the\n * product chrome and the side panel (`AppBar`, `Footer`, `Workspace`,\n * `Rail`), the stand-alone run controls (`Cta`, `Button`) and the hero the\n * composer already carries, and each leaves out the other moment's\n * components: a composer reads no result, a result page enters no input. A\n * composer may still list short texts (`TextList`), such as what a run gives\n * back.\n */\nconst FRAME_VOCABULARIES: Record<Exclude<Frame, 'page'>, readonly string[]> = {\n composer: Object.freeze([\n 'Card',\n 'Stack',\n 'Grid',\n 'Separator',\n 'Heading',\n 'Text',\n 'Badge',\n 'Alert',\n 'Collapsible',\n 'Avatar',\n 'Input',\n 'Textarea',\n 'Select',\n 'Radio',\n 'Checkbox',\n 'Switch',\n 'Split',\n 'Tabs',\n 'Steps',\n 'Icon',\n 'Segmented',\n 'NumberInput',\n 'MthdsField',\n 'Section',\n ...COMPOSER_COMPONENTS,\n 'TextList',\n ]),\n result: Object.freeze([\n 'Card',\n 'Stack',\n 'Grid',\n 'Separator',\n 'Heading',\n 'Text',\n 'Badge',\n 'Alert',\n 'Collapsible',\n 'Progress',\n 'Avatar',\n 'Split',\n 'Tabs',\n 'Icon',\n 'MthdsResult',\n 'DataTable',\n 'Metric',\n 'Section',\n 'SummaryRow',\n ...RESULT_COMPONENTS,\n ]),\n};\n\n/** A whole page's vocabulary: every component but the frames' own. */\nconst PAGE_VOCABULARY: readonly string[] = Object.freeze(\n COMPONENT_NAMES.filter((name) => !(FRAME_COMPONENTS as readonly string[]).includes(name)),\n);\n\n/**\n * The component names a layout written for `frame` may use, in the order the\n * designer method lists them. Frozen, like the catalog `frameCatalog` builds\n * over them: both are shared by every check, so a caller that edited one\n * would change what every later check accepts.\n */\nexport function componentNamesFor(frame: Frame): readonly string[] {\n return frame === 'page' ? PAGE_VOCABULARY : FRAME_VOCABULARIES[frame];\n}\n\nconst frameCatalogs = new Map<Frame, ValidationCatalog>();\n\n/**\n * The catalog a layout written for `frame` is validated against: the same\n * definitions and renderings as `catalog`, held to the frame's vocabulary.\n * Built once per frame and shared, so it is frozen with its vocabulary. A\n * composer that names an `AppBar` is refused here as an unknown component,\n * though the entry's registry could render one, because the host's frame\n * already draws what it stands for.\n */\nexport function frameCatalog(frame: Frame): ValidationCatalog {\n // Built once per frame: every check of a layout asks for one.\n const built = frameCatalogs.get(frame);\n if (built) return built;\n const made: ValidationCatalog = Object.freeze({\n componentNames: componentNamesFor(frame),\n actionNames: catalog.actionNames,\n data: catalog.data,\n schema: catalog.schema,\n renders: COMPONENT_RENDERINGS,\n });\n frameCatalogs.set(frame, made);\n return made;\n}\n","import type { z } from 'zod';\n\n/**\n * A component's props, as the one-line signature the designer method lists it\n * under: `{ text: string, tag?: string }` for a `Footer`, whose `tag` is\n * declared `.nullable()`, or `{ label: string, value: unknown, unit?: string,\n * format?: \"plain\" | \"integer\" | \"decimal\" | \"compact\" }` for a `Metric`.\n *\n * It renders the SAME text json-render's own prompt renders for a zod schema,\n * case for case - a prop wrapped in `nullable` or `optional` gets a `?` and\n * never a `| null`, an enum lists its values, `z.any()` prints as `unknown` -\n * so a model that has\n * seen json-render's prompt reads a familiar shape. json-render does not export\n * its formatter (it hands it to a prompt template as a context member), and\n * the catalog travels to the method as data rather than as a rendered prompt,\n * so the formatter lives here; `__tests__/prompt.test.ts` holds it to the\n * package's own output over every component in the catalog.\n *\n * Reads zod v4's `_zod.def`, the definition every schema class carries: `type`\n * names the kind, and the members read below are the ones that kind holds.\n */\n\ninterface ZodDefinition {\n type: string;\n innerType?: z.ZodType;\n element?: z.ZodType;\n shape?: Record<string, z.ZodType>;\n entries?: Record<string, unknown>;\n values?: readonly unknown[];\n options?: readonly z.ZodType[];\n keyType?: z.ZodType;\n valueType?: z.ZodType;\n}\n\nfunction definitionOf(schema: z.ZodType): ZodDefinition {\n return (schema as unknown as { _zod: { def: ZodDefinition } })._zod.def;\n}\n\nexport function propsSignature(schema: z.ZodType): string {\n const def = definitionOf(schema);\n switch (def.type) {\n case 'string':\n return 'string';\n case 'number':\n return 'number';\n case 'boolean':\n return 'boolean';\n case 'literal':\n return JSON.stringify(def.values?.[0]);\n case 'enum':\n return Object.values(def.entries ?? {})\n .map((value) => `\"${String(value)}\"`)\n .join(' | ');\n case 'array':\n return `Array<${def.element ? propsSignature(def.element) : 'unknown'}>`;\n case 'object': {\n const props = Object.entries(def.shape ?? {}).map(([key, value]) => {\n const inner = definitionOf(value).type;\n const optional = inner === 'optional' || inner === 'nullable';\n return `${key}${optional ? '?' : ''}: ${propsSignature(value)}`;\n });\n return `{ ${props.join(', ')} }`;\n }\n case 'optional':\n case 'nullable':\n case 'default':\n return def.innerType ? propsSignature(def.innerType) : 'unknown';\n case 'union':\n return def.options\n ? def.options.map((option) => propsSignature(option)).join(' | ')\n : 'unknown';\n case 'record': {\n const key = def.keyType ? propsSignature(def.keyType) : 'string';\n const value = def.valueType ? propsSignature(def.valueType) : 'unknown';\n return `Record<${key}, ${value}>`;\n }\n default:\n return 'unknown';\n }\n}\n","import type { z } from 'zod';\nimport type { Action, Catalog, Component } from '../generated/layout-design/types';\nimport { catalog, componentNamesFor } from './catalog';\nimport type { Frame } from './frame-definitions';\nimport { propsSignature } from './props-signature';\nimport { generativeSchema } from './schema';\n\n/**\n * The catalog as the designer method's `catalog` input: the vocabulary as\n * DATA, which the method's own prompt lays out.\n *\n * The prompt a model reads is the method - `methods/layout-design.mthds`\n * carries every paragraph of it as prose and loops over these two lists for\n * the component and action sections. What this package contributes is what\n * only code can state: each component's props signature, rendered from its\n * zod schema, beside the description and the slots its definition declares.\n * One function so the fixture pass, the briefs and the tests hand over one\n * value, and the hash stamped on a captured layout covers what was actually\n * sent.\n *\n * The shapes are the method's own: codegen projects the `Catalog`,\n * `Component` and `Action` structures the bundle declares into\n * `src/generated/layout-design/`, and the aliases below are those types. So a\n * field renamed in the bundle fails the type check on the literals here\n * rather than a run, and the value goes over as the content of a structured\n * input, verbatim. The import is type-only: the generated zod schemas stay\n * out of the entry, which ships no validator for this value.\n */\n\n/** The `Catalog` structure of `methods/layout-design.mthds`, as codegen projects it. */\nexport type DesignerCatalog = Catalog;\n/** One component of the catalog: its name, its props signature, what it is for, what it accepts. */\nexport type DesignerComponent = Component;\n/** One action a page may bind to an event. */\nexport type DesignerAction = Action;\n\n/** The concept a run request names for the `catalog` input: the method's own, domain-qualified. */\nexport const DESIGNER_CATALOG_CONCEPT = 'generative.Catalog';\n\ninterface ComponentDefinition {\n props: z.ZodType;\n slots?: readonly string[];\n events?: readonly string[];\n description?: string;\n}\n\n/** What a catalog is built for. */\nexport interface DesignerCatalogOptions {\n /**\n * The frame the layout is written for: `page` (the default), a whole\n * product page; `composer` or `result`, a moment of a host's\n * compose-then-result app, whose vocabulary leaves out what that host draws\n * and adds the frame's own components (`componentNamesFor`).\n */\n frame?: Frame;\n}\n\n/**\n * The catalog as the designer method's `catalog` input, for one frame. The\n * same frame's `frameCatalog` is what the layout it produces is validated\n * against, so the vocabulary a model was shown and the one it is held to are\n * one list.\n */\nexport function designerCatalog({ frame = 'page' }: DesignerCatalogOptions = {}): DesignerCatalog {\n const definitions = catalog.data.components as Record<string, ComponentDefinition>;\n const components = componentNamesFor(frame).map((name): DesignerComponent => {\n const definition = definitions[name];\n if (!definition) throw new Error(`the catalog defines no component named '${name}'`);\n const slots = definition.slots ?? [];\n return {\n name,\n props: propsSignature(definition.props),\n description: definition.description,\n accepts_children: slots.includes('default'),\n slots: slots.filter((slot) => slot !== 'default'),\n events: [...(definition.events ?? [])],\n };\n });\n\n const builtIn = (generativeSchema.builtInActions ?? []).map((action): DesignerAction => ({\n name: action.name,\n description: action.description,\n built_in: true,\n }));\n const own = Object.entries(catalog.data.actions as Record<string, { description: string }>).map(\n ([name, action]): DesignerAction => ({\n name,\n description: action.description,\n built_in: false,\n }),\n );\n\n return { components, actions: [...builtIn, ...own] };\n}\n","import { designerCatalog } from './designer-catalog';\nimport { FRAMES } from './frame-definitions';\n\n/**\n * The hash that pairs a captured layout with the prompt it was produced\n * against: the first twelve hex digits of the SHA-256 of `promptHashSubject`,\n * which is the designer method's text and the catalog of every frame.\n *\n * The prompt is no longer one string this package renders: it is the method\n * (`methods/layout-design.mthds`, every paragraph as prose) applied to\n * the catalog as data (`designerCatalog({ frame })`). Both are what a run was\n * actually given, so both are hashed - a reworded rule and a renamed prop each\n * move the pin, exactly as they did when the prompt was rendered here. A run\n * is given the catalog of one frame, and the hash covers the method's text\n * first and then every frame's catalog, in a fixed order: one pin a host\n * compares every stored layout with, whichever frame it was written for, and\n * which a reworded rule or any frame's vocabulary moving moves. The frame a\n * layout was written for is its own provenance, beside the hash. The brief is\n * not hashed: it is the per-method half, recorded with each layout. The model\n * pin in the method file moves it too, since the file is hashed whole; a\n * fixture records its model on its own, so that costs a regeneration, never a\n * misread.\n *\n * It is a PIN rather than a computation, so that this entry stays importable\n * from a browser (hashing would mean `node:crypto` or an async Web Crypto\n * call, and a host compares this value synchronously while deciding whether a\n * stored layout still stands - and the entry must not read the method file).\n * `__tests__/prompt.test.ts` recomputes it from the file and the catalog and\n * fails on any drift, so the pin cannot go stale quietly: a catalog, rule or\n * direction change is a failing test, which is exactly what it was for.\n *\n * A stored layout whose hash is not this one is not rendered - the host falls\n * back to the kernel's own form - because the vocabulary it was written in is\n * no longer the vocabulary this entry renders.\n */\nexport const PROMPT_HASH = '30cf9bc059f6';\n\n/**\n * What the hash is computed over: the method's text as shipped, then the\n * catalog of each frame as a run request carries it, in `FRAMES` order. The\n * one recipe the test, the fixture pass and a host's producer share, so the\n * pin they check and the stamp they write agree: a producer that runs the\n * method off a checkout hashes this string (SHA-256, the first twelve hex\n * digits) and compares it with `PROMPT_HASH` before it spends anything. It is\n * a string rather than the hash so the entry stays free of a hashing\n * dependency and importable from a browser.\n */\nexport function promptHashSubject(method: string): string {\n const catalogs = FRAMES.map((frame) => designerCatalog({ frame }));\n return `${method}\\n${JSON.stringify(catalogs)}`;\n}\n","/**\n * Whether a value is a json-render expression - `{ \"$state\": ... }` and its\n * kin - rather than a literal. Both checks read a value as an expression by\n * this and by nothing else, so neither calls an object a literal that the\n * other calls an expression - a `{ \"$label\": ... }` a model wrote is a literal\n * to json-render, and to both.\n *\n * A key alone does not make one, and the test is json-render's own, member by\n * member: it resolves `$state`, `$item`, `$bindState`, `$bindItem`,\n * `$computed` and `$template` only when they hold a text, `$index` only when\n * it is `true`, and `$cond` only beside both `$then` and `$else`. Anything\n * else under those keys is a literal object, which it resolves member by\n * member and hands the renderer as an object. So `{ \"$state\": 7 }` is read\n * here as the literal it renders as, and the literal check holds it to the\n * prop's schema rather than waving it through as a binding nothing resolves.\n */\nexport function isExpression(value: unknown): boolean {\n return expressionForm(value) !== undefined;\n}\n\n/** The form json-render resolves an expression as, named by its key. */\nexport type ExpressionForm =\n '$state' | '$item' | '$index' | '$bindState' | '$bindItem' | '$cond' | '$computed' | '$template';\n\n/**\n * The form json-render resolves `value` as, or nothing for a literal: its\n * forms tried in json-render's own order, so an object carrying two keys is\n * the first. The one place that order is written; every reader of an\n * expression asks this.\n */\nexport function expressionForm(value: unknown): ExpressionForm | undefined {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) return undefined;\n const record = value as Record<string, unknown>;\n if (typeof record.$state === 'string') return '$state';\n if (typeof record.$item === 'string') return '$item';\n if (record.$index === true) return '$index';\n if (typeof record.$bindState === 'string') return '$bindState';\n if (typeof record.$bindItem === 'string') return '$bindItem';\n if ('$cond' in record && '$then' in record && '$else' in record) return '$cond';\n if (typeof record.$computed === 'string') return '$computed';\n if (typeof record.$template === 'string') return '$template';\n return undefined;\n}\n\n/**\n * The two values a `$cond` resolves to - each resolved again in its turn -\n * when json-render reads `value` as one, or nothing.\n */\nexport function condBranches(value: unknown): readonly [unknown, unknown] | undefined {\n if (expressionForm(value) !== '$cond') return undefined;\n const record = value as Record<string, unknown>;\n return [record.$then, record.$else];\n}\n","/**\n * A decimal written out: a sign, digits with or without a fraction, and an\n * exponent. `Number` reads more than that - \"0x1A\" as 26, \"0b11\" as 3 - and a\n * code that happens to look like one is no amount.\n */\nconst DECIMAL = /^[-+]?(\\d+(\\.\\d*)?|\\.\\d+)(e[-+]?\\d+)?$/i;\n\n/**\n * The amount a `ProportionBar` part draws, read as its renderer reads it and\n * as the fit check holds a part written out inline to, and the number a\n * `DataTable` number column writes: a number, or a text that writes one out\n * in decimal, as a payload's decimal may arrive. Nothing else is one - a\n * structure (on which `Number` throws when it carries its own `toString`\n * member), a list, a boolean, an empty text, a hexadecimal code - and reads\n * as `NaN`, which draws no share.\n */\nexport function shareAmount(raw: unknown): number {\n if (typeof raw === 'number') return raw;\n if (typeof raw === 'string' && DECIMAL.test(raw.trim())) return Number(raw);\n return Number.NaN;\n}\n","/**\n * Whether a layout is shaped like a spec at all, and what the checks answer\n * when they fail on one that is.\n *\n * The checks answer with problems, never an exception, because a host calls\n * them to decide whether a page renders and a throw leaves it with no verdict.\n * They used to keep that promise with a catch around each walk that called any\n * throw \"the layout is not a well-formed spec\" - a bug in the checks included,\n * which a producer then handed to the method's repair pass, paying for passes\n * no layout could satisfy. So the shape the walks assume is checked first,\n * here, and stated as what it is; a throw on a spec that has it is the checks'\n * own failure, answered by a line of its own, and flagged as such by\n * `layoutCheck` - never by the line's words, which a layout can write into an\n * element key - so a producer stops rather than repairs.\n */\n\n/** A value that is no spec, in words for the line that says so; never throws. */\nfunction shown(value: unknown): string {\n if (Array.isArray(value)) return 'a list';\n if (typeof value === 'bigint') return String(value);\n if (typeof value === 'symbol' || typeof value === 'function') return `a ${typeof value}`;\n try {\n return String(JSON.stringify(value ?? null));\n } catch {\n return 'a value that cannot be written out';\n }\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n/**\n * What makes `spec` no spec the checks can walk, in words, or nothing when it\n * has the shape they assume: a `root` named by a text, an `elements` map of\n * structures, each naming its component `type` as a text, with structured\n * `props`, a list of `children` and slots of lists that name elements by\n * their keys, and a `repeat` naming its `statePath`. A key is a text because\n * every walk looks an element up by it, and a structure carrying its own\n * `toString` member throws as it is turned into one, which the checks would\n * answer as their own failure and a producer would skip the repair pass for.\n * Whether the root is there at all, whether a key names an element, whether a\n * type is known, whether `on` and `watch` are the maps the runtime reads:\n * those are problems the checks themselves report, in their own words, not\n * reasons they cannot run.\n */\nexport function specMalformation(spec: unknown): string | undefined {\n if (!isRecord(spec)) return `it is ${shown(spec)}, not a structure`;\n if (spec.root !== undefined && typeof spec.root !== 'string') {\n return `its \"root\" is ${shown(spec.root)}, not an element's key`;\n }\n if (!isRecord(spec.elements)) return 'it has no \"elements\" map';\n for (const [key, element] of Object.entries(spec.elements)) {\n const at = JSON.stringify(key);\n if (!isRecord(element)) return `the element ${at} is not a structure`;\n const { type, props, children, slots, repeat } = element;\n if (typeof type !== 'string') return `the element ${at} names no component \"type\"`;\n if (props != null && !isRecord(props))\n return `the element ${at} has \"props\" that are not a structure`;\n if (children != null && !Array.isArray(children))\n return `the element ${at} has \"children\" that are not a list`;\n const child = Array.isArray(children) ? firstNotAKey(children) : undefined;\n if (child)\n return `the element ${at} has a child that is ${shown(child.entry)}, not an element's key`;\n if (slots != null && (!isRecord(slots) || !Object.values(slots).every(Array.isArray))) {\n return `the element ${at} has \"slots\" that are not lists`;\n }\n const slotted = isRecord(slots)\n ? firstNotAKey(Object.values(slots).flatMap((entries) => entries as unknown[]))\n : undefined;\n if (slotted) {\n return `the element ${at} has a slot entry that is ${shown(slotted.entry)}, not an element's key`;\n }\n if (repeat !== undefined && !repeatsOver(repeat)) {\n return `the element ${at} has a \"repeat\" that names no \"statePath\"`;\n }\n }\n return undefined;\n}\n\n/**\n * The first entry of `children` or of a slot that is not an element's key,\n * boxed, so an entry written as `undefined` is found as well.\n */\nfunction firstNotAKey(entries: readonly unknown[]): { entry: unknown } | undefined {\n for (const entry of entries) if (typeof entry !== 'string') return { entry };\n return undefined;\n}\n\n/**\n * Whether a `repeat` names the list it lays out as json-render reads one: a\n * path, or `{ \"$item\": … }`, a path relative to the item of the repeat\n * around it, which json-render joins as a text.\n */\nfunction repeatsOver(repeat: unknown): boolean {\n if (!isRecord(repeat)) return false;\n const { statePath } = repeat;\n return (\n typeof statePath === 'string' || (isRecord(statePath) && typeof statePath.$item === 'string')\n );\n}\n\n/** The line a malformed spec is answered with. */\nexport function malformedLine(what: string): string {\n return `the layout is not a well-formed spec: ${what}`;\n}\n\n/** The line the checks answer with when they throw on a layout of the right shape. */\nexport function checksFailedLine(error: unknown): string {\n let said: string;\n try {\n said = String(error);\n } catch {\n said = 'an error that cannot be written out';\n }\n return `the checks failed on this layout (${said}): a defect in the checks, which no repair of the layout can fix`;\n}\n","import type { z } from 'zod';\n\n/**\n * How the generative layer reads a prop's zod schema, in one place: the\n * renderers' prop conformance (`declared-props.ts`), the fit check's list\n * props (`layout-fits.ts`) and the catalog check's closed vocabularies\n * (`validate.ts`) each look under the same wrappers for the same facts, and\n * used to do it three ways - one through `nullable`, `optional` and `default`\n * alone, the others through anything with an inner type - so a prop declared\n * `.readonly()` was a list to one and not to another.\n *\n * Reads zod v4's `_zod.def`, the definition every schema class carries: `type`\n * names the kind, and the members below are the ones the readers need.\n */\nexport interface ZodDefinition {\n type: string;\n /** What a wrapper - `optional`, `nullable`, `default`, `readonly`, `catch` and their kin - wraps. */\n innerType?: z.ZodType;\n /** An array's item schema. */\n element?: z.ZodType;\n /** An object's member schemas. */\n shape?: Record<string, z.ZodType>;\n /**\n * The refinements on a schema - `.min(2)`, a pattern, a `.refine` on a\n * wrapper too - absent when there are none.\n */\n checks?: readonly unknown[];\n /** A string or number format - `email`, `url`, `safeint` - which zod keeps here rather than in `checks`. */\n format?: string;\n}\n\n/** A schema's definition, or nothing for a value that is not a zod schema. */\nexport function definitionOf(schema: unknown): ZodDefinition | undefined {\n if (typeof schema !== 'object' || schema === null) return undefined;\n return (schema as { _zod?: { def?: ZodDefinition } })._zod?.def;\n}\n\n/**\n * Every definition from the schema's own down through each wrapper it\n * carries - `.nullable()`, `.optional()`, `.default()` and any other schema\n * that only wraps an inner one - to the one they wrap, or none when the chain\n * is broken or longer than a prop's. Bounded, since a definition is data a\n * host's catalog supplies.\n */\nexport function definitionChain(schema: unknown): readonly ZodDefinition[] {\n const chain: ZodDefinition[] = [];\n let def = definitionOf(schema);\n for (let depth = 0; depth < 8 && def; depth += 1) {\n chain.push(def);\n if (def.innerType === undefined) return chain;\n def = definitionOf(def.innerType);\n }\n return [];\n}\n\n/** The definition under every wrapper a prop carries: the last of its chain. */\nexport function unwrapped(schema: unknown): ZodDefinition | undefined {\n const chain = definitionChain(schema);\n return chain[chain.length - 1];\n}\n","import type { Spec } from '@json-render/core';\nimport type { RunField } from '../core';\n\n/**\n * The two state trees, and how a path into either maps back onto the\n * descriptor.\n *\n * An input page binds at `/inputs/<name>`, recursing into structures as the\n * descriptor does; a result page binds at `/result/<path>`. Both are JSON\n * Pointers (RFC 6901), because that is what json-render's state store reads.\n * Nothing here knows a value - a path is resolved against the DESCRIPTOR, which\n * is how the two escape hatches find the `RunField` to hand the kernel.\n */\n\nexport const INPUTS_ROOT = '/inputs';\nexport const RESULT_ROOT = '/result';\n\n/** `/inputs` + `invoice` + `billed_to` → `/inputs/invoice/billed_to`. */\nexport function joinPath(root: string, ...segments: readonly string[]): string {\n return segments.reduce<string>((path, segment) => `${path}/${escapeSegment(segment)}`, root);\n}\n\n/**\n * RFC 6901: `~` is `~0`, `/` is `~1`. Field names are identifiers, so this\n * rarely fires. Exported for the stream module, which writes an element key\n * into a patch path: the escaping is spelled once, because the second spelling\n * was a copy and a copy drifts.\n */\nexport function escapeSegment(segment: string): string {\n return segment.replace(/~/g, '~0').replace(/\\//g, '~1');\n}\n\n/**\n * The inverse, in the order the RFC requires - `~1` first, then `~0`, so `~01`\n * reads back as `~1` and not as `/`. The stream's prototype guard unescapes a\n * patch path through this same function before it compares segments, so the\n * order that guard relies on is decided here and nowhere else.\n */\nexport function unescapeSegment(segment: string): string {\n return segment.replace(/~1/g, '/').replace(/~0/g, '~');\n}\n\n/** The segments of a pointer, root excluded: `/inputs/a/b` under `/inputs` → `['a', 'b']`. */\nexport function segmentsUnder(root: string, path: string): string[] | undefined {\n if (path === root) return [];\n if (!path.startsWith(`${root}/`)) return undefined;\n return path\n .slice(root.length + 1)\n .split('/')\n .map(unescapeSegment);\n}\n\n/**\n * The descriptor node a path names, or `undefined` when the path leaves the\n * tree. An object's children are found by name; a list's are found by index,\n * and every index resolves to the same item descriptor.\n */\nexport function fieldAtSegments(\n fields: readonly RunField[],\n segments: readonly string[],\n): RunField | undefined {\n const [head, ...rest] = segments;\n if (head === undefined) return undefined;\n const field = fields.find((candidate) => candidate.name === head);\n if (!field) return undefined;\n return rest.length === 0 ? field : descend(field, rest);\n}\n\nfunction descend(field: RunField, segments: readonly string[]): RunField | undefined {\n const [head, ...rest] = segments;\n if (head === undefined) return field;\n if (field.kind === 'object') return fieldAtSegments(field.fields, segments);\n if (field.kind === 'list' && /^\\d+$/.test(head)) return descend(field.item, rest);\n return undefined;\n}\n\n/** `/inputs/<...>` resolved against a form's top-level fields. */\nexport function inputFieldAtPath(fields: readonly RunField[], path: string): RunField | undefined {\n const segments = segmentsUnder(INPUTS_ROOT, path);\n return segments && segments.length > 0 ? fieldAtSegments(fields, segments) : undefined;\n}\n\n/** `/result/<...>` resolved against a result descriptor; `/result` itself is the root. */\nexport function resultFieldAtPath(field: RunField, path: string): RunField | undefined {\n const segments = segmentsUnder(RESULT_ROOT, path);\n if (!segments) return undefined;\n return segments.length === 0 ? field : descend(field, segments);\n}\n\n/**\n * The child-to-parent map of a spec's element tree.\n *\n * Built once and passed down rather than rebuilt per lookup: `layoutProblems`\n * resolves one relative hatch path per element that carries one, and each\n * resolution walks the chain of parents above it. Rebuilding the map inside\n * that walk made the whole pass quadratic in element count.\n */\nexport function parentMapOf(spec: Spec): Map<string, string> {\n const parents = new Map<string, string>();\n for (const [parentKey, element] of Object.entries(spec.elements)) {\n for (const child of element.children ?? []) parents.set(child, parentKey);\n }\n return parents;\n}\n\n/**\n * The base path a relative hatch path resolves against, statically: the chain\n * of `repeat`s from the root down to `key`, each contributing its list path\n * and a first index. `undefined` outside any repeat. Mirrors what\n * `useRepeatScope` gives the hatch at render time, for a test that never\n * renders.\n *\n * The walk up the parent chain STOPS on a key it has already seen. A layout is\n * model-produced, and an element that is its own ancestor - `children: [\"self\"]`\n * at its simplest - is a shape json-render's `validateSpec` accepts without a\n * word, so without the guard this loop never terminates. Since a host calls\n * this through `layoutFits` precisely to decide whether an untrusted layout is\n * safe to render, the gate hanging is worse than the layout it was asked about.\n */\nexport function repeatBasePathOf(\n spec: Spec,\n key: string,\n parents: Map<string, string> = parentMapOf(spec),\n): string | undefined {\n const chain: string[] = [];\n const seen = new Set<string>();\n let current: string | undefined = key;\n while (current !== undefined && !seen.has(current)) {\n seen.add(current);\n chain.unshift(current);\n current = parents.get(current);\n }\n let base: string | undefined;\n for (const elementKey of chain) {\n const repeat = spec.elements[elementKey]?.repeat;\n if (!repeat) continue;\n const statePath = repeat.statePath;\n if (typeof statePath === 'string') {\n base = `${statePath}/0`;\n continue;\n }\n // A relative `repeat` names the item's field, and only a string is one. A\n // layout is model-produced, so `statePath` can be null or an object here -\n // and reading `.$item` off either produced a throw or a path with\n // \"[object Object]\" in it, reported later as an ordinary staleness problem\n // that named the wrong cause.\n const item = (statePath as { $item?: unknown } | null)?.$item;\n if (base === undefined || typeof item !== 'string') return undefined;\n base = `${joinPath(base, item)}/0`;\n }\n return base;\n}\n\n/** A hatch's path as the layer resolves it: absolute as written, or relative to the repeat it sits in. */\nexport function absoluteHatchPath(\n spec: Spec,\n key: string,\n path: string,\n parents?: Map<string, string>,\n): string | undefined {\n if (path.startsWith('/')) return path;\n const base = repeatBasePathOf(spec, key, parents);\n // Raw, not `joinPath`: a relative hatch path is written by the producer and\n // may name several segments (`billed_to/city`), so its `/` are separators\n // already and escaping them would name one segment that does not exist.\n return base ? `${base}/${path}` : undefined;\n}\n\n/**\n * The list a `repeat` lays out, as an absolute path: its `statePath` when that\n * is written absolute, or, for a relative `{ $item }` one, the item's field\n * under the repeat above it - the same chain `repeatBasePathOf` walks, stopped\n * one level short. `undefined` when there is nothing to be relative to, or\n * when `statePath` is neither form. It is the path a repeat READS, which is\n * how the fit gate asks whether the descriptor still has the list.\n */\nexport function repeatListPathOf(\n spec: Spec,\n key: string,\n parents: Map<string, string> = parentMapOf(spec),\n): string | undefined {\n const statePath = spec.elements[key]?.repeat?.statePath;\n if (typeof statePath === 'string') return statePath;\n const item = (statePath as { $item?: unknown } | null | undefined)?.$item;\n const parent = parents.get(key);\n const outer = parent === undefined ? undefined : repeatBasePathOf(spec, parent, parents);\n return outer !== undefined && typeof item === 'string' ? joinPath(outer, item) : undefined;\n}\n","import type { Spec } from '@json-render/core';\nimport type { RunField, RunFieldKind } from '../core';\nimport { hasOwnProp } from '../core/own-property';\nimport { isFilled } from '../core/readiness';\nimport { catalog } from './catalog';\nimport { condBranches, expressionForm, isExpression } from './expressions';\nimport { shareAmount } from './share-amount';\nimport { checksFailedLine, malformedLine, specMalformation } from './spec-shape';\nimport { unwrapped } from './zod-definition';\nimport {\n INPUTS_ROOT,\n RESULT_ROOT,\n absoluteHatchPath,\n inputFieldAtPath,\n joinPath,\n parentMapOf,\n repeatBasePathOf,\n repeatListPathOf,\n resultFieldAtPath,\n} from './paths';\n\n/**\n * How many `$cond`s deep a ProportionBar part is followed into its branches;\n * one nested deeper is read as an expression that reads nothing.\n */\nconst MAX_COND_DEPTH = 8;\n\n/**\n * Whether a stored layout still fits the descriptor it will be rendered over.\n *\n * A layout is produced once per method version and stored; a descriptor is\n * derived from the method every time it is read. Those two can part company -\n * a method's input is renamed, a structure loses a member - and when they do,\n * a delegated path resolves to nothing and a bound path writes into a corner of\n * the state the run never reads. Neither fails loudly on its own, so the host\n * asks this before it renders and falls back to the kernel's own form when the\n * answer is no.\n *\n * Two directions, and the second is the one a corpus cannot notice. The first\n * is staleness: every path the layout MENTIONS is a path the descriptor still\n * has, which is the corpus test's check lifted out of the test and into the\n * product. The second is coverage: every path the descriptor REQUIRES is one\n * the layout offers somewhere. A layout that simply omits an input is not\n * stale and validates perfectly - it renders a page with no field for a\n * required input, the run gate then refuses the run for that input, and the\n * person has nowhere to type it. A page you cannot complete is worse than the\n * plain form, which is what the fallback is for.\n *\n * It answers with problems, not exceptions, and that is a promise rather than\n * a habit: a host calls this to decide whether it is safe to render, so a\n * throw leaves it with no verdict at the one moment it needs one. A layout is\n * model-produced and may be malformed in ways the walk below trips on\n * (`children: 5`, a null element, no `elements` map at all), and the other\n * gate, which refuses those shapes outright, is exported separately - so\n * neither may assume the other ran first.\n *\n * A third check sits between the two and is about KIND rather than presence:\n * a path a layout shows as a value must be a scalar, and a path it reads into\n * a prop that takes a list must be a list. A `SummaryRow` whose `value` reads\n * `/inputs/document`, a structure of a url and a filename, is not stale - the\n * path exists - and it validates perfectly; it renders `[object Object]`,\n * because the renderer stringifies what it is handed and nothing anywhere said\n * the path was not a value. An `AppBar` whose `links` read that same structure\n * is the mirror image: its renderer maps over what it is handed, renders\n * nothing for a structure and throws for a text. Only the descriptor knows\n * what kind a path is, so this is where that is said.\n *\n * What is NOT checked here is whether the layout validates against the catalog\n * - that is `validateAgainstCatalog`, and a host runs both.\n */\n\nexport interface LayoutDescriptor {\n /** The input page's top-level fields, for `/inputs/...` paths. */\n inputs?: readonly RunField[];\n /** The result page's descriptor, for `/result/...` paths. */\n result?: RunField;\n}\n\n/** Whether `path` is `root` itself or lies under it. */\nfunction isUnder(root: string, path: string): boolean {\n return path === root || path.startsWith(`${root}/`);\n}\n\n/**\n * Every state path the layout mentions, sorted by what it does with it.\n *\n * `bound` is what it WRITES: `{ \"$bindState\": \"/path\" }`, and inside a repeat\n * `{ \"$bindItem\": \"field\" }`, which binds a member of the current item. `read`\n * is the rest. A binding is not the only way a layout names a path: the prompt\n * teaches `{ \"$state\": \"/path\" }` for a read-only value, `$cond` for a\n * condition (whose own condition object is a `$state`, so the same walk finds\n * it), `{ \"$template\": \"Total ${/result/amount}\" }` for an interpolation, a\n * top-level `visible` condition on the ELEMENT rather than in its props - which\n * is why `element.visible` is walked here beside `element.props` - and, inside\n * a repeat, `{ \"$item\": \"field\" }` for a member of the current item.\n *\n * Missing any of these was not cosmetic. A read that has gone stale renders a\n * placeholder where a value belongs; a stale `visible` condition compares\n * against nothing, never holds, and hides its element for good - so a section\n * carrying a required input silently never appears, while the coverage half\n * below still counts that input as offered because the binding is right there\n * in the props of an element nobody can see.\n *\n * The two item forms are RELATIVE, and json-render resolves them against the\n * item of the nearest repeat above the element: `$item: \"name\"` inside a\n * repeat over `/result/lines` reads `/result/lines/<i>/name`. They are resolved\n * here the way a relative hatch path is - through `repeatBasePathOf`, at the\n * first index, since every index resolves to the same descriptor node - so a\n * renamed member of a repeated item is the same stale path as a renamed input,\n * and a `$bindItem` under `/result` is the same forbidden write as a\n * `$bindState` there. One outside any repeat resolves to nothing at all; the\n * runtime warns and renders nothing, and `adrift` names the element so the\n * gate can say so.\n *\n * A `repeat` is a read too, and it is resolved separately (`staleRepeats`)\n * because a relative one names its list through the repeat above it.\n */\ninterface Mentioned {\n bound: string[];\n read: string[];\n /** The elements that read or bind the current item with no repeat above them. */\n adrift: string[];\n}\n\n/**\n * The absolute path an item-relative field of one element resolves to, or\n * nothing outside any repeat. Resolved lazily: most elements sit in no repeat\n * and mention no item.\n */\nfunction itemPathResolver(\n spec: Spec,\n key: string,\n parents: Map<string, string>,\n): (field: string) => string | undefined {\n let base: string | undefined;\n let resolvedBase = false;\n return (field) => {\n if (!resolvedBase) {\n base = repeatBasePathOf(spec, key, parents);\n resolvedBase = true;\n }\n if (base === undefined) return undefined;\n // The runtime joins the field under the item's own path, and reads\n // `\"\"` (or `\"/\"`) as the item itself.\n const under = field.startsWith('/') ? field.slice(1) : field;\n return under === '' ? base : `${base}/${under}`;\n };\n}\n\n/**\n * The paths a template interpolates, resolved the way json-render resolves\n * them: `${/result/amount}` is absolute and read as written; a bare\n * `${amount}` is read off the item of the nearest repeat above the element,\n * and outside any repeat off the root of the state, as `/amount`. Inside a\n * repeat the runtime falls back to the root when the item has no such member,\n * but a layout that writes `${name}` in a repeat means the item's `name`, so\n * it is read as one here and a member the item has lost is stale rather than\n * quietly a root path. The pattern is json-render's own - one or more\n * characters - so an empty `${}` is the literal text it renders as, not an\n * interpolation of nothing.\n */\nfunction interpolatedPaths(\n template: string,\n itemPath: (field: string) => string | undefined,\n): string[] {\n return [...template.matchAll(/\\$\\{([^}]+)\\}/g)].flatMap((match) => {\n const raw = match[1];\n if (raw === undefined) return [];\n if (raw.startsWith('/')) return [raw];\n return [itemPath(raw) ?? `/${raw}`];\n });\n}\n\nfunction mentionedPaths(spec: Spec, parents: Map<string, string>): Mentioned {\n const found: Mentioned = { bound: [], read: [], adrift: [] };\n for (const [key, element] of Object.entries(spec.elements)) {\n const itemPath = itemPathResolver(spec, key, parents);\n const walk = (value: unknown): void => {\n if (Array.isArray(value)) {\n value.forEach(walk);\n return;\n }\n if (typeof value !== 'object' || value === null) return;\n const record = value as Record<string, unknown>;\n if (typeof record.$bindState === 'string') found.bound.push(record.$bindState);\n if (typeof record.$state === 'string') found.read.push(record.$state);\n if (typeof record.$template === 'string') {\n found.read.push(...interpolatedPaths(record.$template, itemPath));\n }\n if (typeof record.$bindItem === 'string') {\n const path = itemPath(record.$bindItem);\n if (path === undefined) found.adrift.push(key);\n else found.bound.push(path);\n }\n if (typeof record.$item === 'string') {\n const path = itemPath(record.$item);\n if (path === undefined) found.adrift.push(key);\n else found.read.push(path);\n }\n Object.values(record).forEach(walk);\n };\n walk(element.props);\n walk(element.visible);\n }\n return found;\n}\n\n/**\n * The read paths this descriptor answers for, deduplicated.\n *\n * Only paths under the root in question: a layout may hold scratch state of its\n * own (a `$state` an element writes and reads back), and that is its business,\n * not the descriptor's. What the descriptor owns is `/inputs` on an input page\n * and `/result` on a result one, and a path under either that no longer\n * resolves is the staleness this predicate exists to catch. One line per path,\n * however many elements mention it.\n */\nfunction staleReads(\n read: readonly string[],\n root: string,\n resolves: (path: string) => boolean,\n): string[] {\n const under = read.filter((path) => isUnder(root, path));\n return [...new Set(under)].filter((path) => !resolves(path));\n}\n\n/**\n * The repeats whose list the descriptor no longer has, or never had as a list.\n *\n * A repeat over a list the method has renamed renders nothing at all, and\n * nothing else notices: on a result page there is no coverage to miss it, and\n * on an input page an optional list is asked for by nobody. A required one was\n * caught, by the coverage half and for the wrong reason. The list is resolved\n * the way a hatch inside the repeat resolves its own path - through the chain\n * of repeats above it - and, as with every read, only under the root the\n * descriptor owns: a repeat over the layout's own scratch state is its\n * business.\n *\n * A repeat over a path that holds something other than a list is refused as\n * well. json-render maps over what the path holds, so a text there throws in\n * the render of the element above and drops the whole subtree, and a structure\n * renders nothing. A path the descriptor cannot speak for (`unknown`) is left\n * alone.\n */\nfunction staleRepeats(\n spec: Spec,\n parents: Map<string, string>,\n root: string,\n fieldAt: (path: string) => RunField | undefined,\n side: 'input' | 'result',\n): string[] {\n const problems: string[] = [];\n for (const [key, element] of Object.entries(spec.elements)) {\n if (!element.repeat) continue;\n const listPath = repeatListPathOf(spec, key, parents);\n if (listPath === undefined || !isUnder(root, listPath)) continue;\n const field = fieldAt(listPath);\n if (!field) {\n problems.push(`${key}: repeats over ${listPath}, which no ${side} has`);\n } else if (field.kind !== 'list' && field.kind !== 'unknown') {\n problems.push(\n `${key}: repeats over ${listPath}, which holds ${kindWords(field.kind)}, not a list`,\n );\n }\n }\n return problems;\n}\n\n/** A word with its indefinite article: `a \"category\"`, `an \"amount\"`, `an image value`. */\nfunction withArticle(word: string): string {\n return `${/^[\"']?[aeiou]/i.test(word) ? 'an' : 'a'} ${word}`;\n}\n\n/** A member name as a refusal writes it, with its article: `a \"category\"`, `an \"amount\"`. */\nfunction memberWords(name: string): string {\n return withArticle(JSON.stringify(name));\n}\n\n/**\n * What a path of `kind` holds, in the words of a refusal: what `NOT_A_VALUE`\n * calls the kinds a value cannot be - \"a structure\", \"a file\", \"a list\" - and\n * \"a text value\", \"a number value\" for the rest.\n */\nfunction kindWords(kind: RunFieldKind): string {\n const wrong = hasOwnProp(NOT_A_VALUE, kind) ? NOT_A_VALUE[kind] : undefined;\n return wrong ? wrong.what : withArticle(`${kind} value`);\n}\n\n/**\n * What a path of each kind is, in the words of the refusal, for the kinds a\n * value cannot be. A scalar - text, prose, a date, a number, a boolean, a\n * choice - is left out, and so is `unknown`, which the descriptor cannot\n * speak for.\n */\nconst NOT_A_VALUE: Partial<Record<RunFieldKind, { what: string; instead: string }>> = {\n object: { what: 'a structure', instead: 'a structure is shown through its members' },\n list: { what: 'a list', instead: 'a list is laid out as a repeat or a DataTable' },\n document: { what: 'a file', instead: \"a file is delegated to the kernel's own control\" },\n image: { what: 'a file', instead: \"a file is delegated to the kernel's own control\" },\n};\n\n/**\n * What the items of a list-taking prop may be: values alone, for a prop\n * declared as an array of strings or numbers (an `AppBar`'s links), or\n * anything, for one declared over structures or left open (a `DataTable`'s\n * rows). What a list of the wrong item kind is, in the words of the refusal,\n * is `NOT_VALUES`: a `Steps` handed a list of structures for its step names\n * renders `[object Object]` per step, and a renderer that maps a structure\n * into a React child throws.\n */\ntype ListItems = 'values' | 'anything';\nconst NOT_VALUES: Partial<Record<RunFieldKind, string>> = {\n object: 'structures',\n list: 'lists',\n document: 'files',\n image: 'files',\n};\n\n/**\n * The props that take a list rather than a value, by component, and what their\n * items may be: every prop the catalog declares as an array, read from the\n * schemas so a new one is never a missing entry here, plus the rows a\n * `DataTable` lays out, declared `any` because their shape is the\n * descriptor's. A `$state` read into one of these must be the list it wants;\n * into any other prop it is shown as a value.\n */\nlet listPropsCache: Map<string, Map<string, ListItems>> | undefined;\nfunction listProps(): Map<string, Map<string, ListItems>> {\n if (listPropsCache) return listPropsCache;\n const found = new Map<string, Map<string, ListItems>>([\n ['DataTable', new Map([['rows', 'anything']])],\n ]);\n const components = catalog.data.components as Record<string, { props?: unknown }>;\n for (const [type, definition] of Object.entries(components)) {\n const shape = (definition.props as { shape?: Record<string, unknown> } | undefined)?.shape;\n for (const [prop, schema] of Object.entries(shape ?? {})) {\n const items = listItemsOf(schema);\n if (items === undefined) continue;\n if (!found.has(type)) found.set(type, new Map());\n found.get(type)!.set(prop, items);\n }\n }\n listPropsCache = found;\n return found;\n}\n\n/** The zod schemas whose values a list-taking prop can render as they are. */\nconst VALUE_SCHEMAS = new Set(['string', 'number', 'boolean', 'enum', 'literal']);\n\n/** What a prop declared as an array takes as its items, or nothing for a prop that is not one. */\nfunction listItemsOf(schema: unknown): ListItems | undefined {\n const def = unwrapped(schema);\n if (def?.type !== 'array') return undefined;\n const element = unwrapped(def.element);\n return element?.type !== undefined && VALUE_SCHEMAS.has(element.type) ? 'values' : 'anything';\n}\n\n/**\n * The reads that show a path of the wrong kind as a value, or read one of the\n * wrong kind into a prop that takes a list.\n *\n * A read sits in one of two places. In a CONDITION - the object under a\n * `$cond`, or the element's own `visible` - it asks whether a value is set,\n * and any path may be asked; the `visible` field is not walked here at all.\n * Anywhere else in a prop it is shown: the renderer receives what the path\n * holds and stringifies it, and for a structure, a list or a file that is\n * `[object Object]`, a comma-joined list or a url where a name belongs. Every\n * form that shows a value is held to it - `$state`, the item-relative `$item`\n * resolved through the repeat above it, and every interpolation of a\n * `$template`, which stringifies what it interpolates, resolved the same way.\n *\n * A prop that takes a list is held the other way round. Written as one\n * expression, it reads a whole list, and the path must be one: a renderer\n * maps over what it is handed, so a structure or a file there renders nothing\n * and a text throws, and a list of structures where the prop takes values is\n * `[object Object]` per item or a throw, both past every gate. Written as an\n * array literal, each entry is a value and is walked as one. A path the\n * descriptor does not have is not repeated here: the staleness check names it.\n */\nfunction nonScalarReads(\n spec: Spec,\n parents: Map<string, string>,\n root: string,\n fieldAt: (path: string) => RunField | undefined,\n): string[] {\n const problems: string[] = [];\n const lists = listProps();\n for (const [key, element] of Object.entries(spec.elements)) {\n const itemPath = itemPathResolver(spec, key, parents);\n const listy = lists.get(element.type);\n const check = (prop: string, path: string): void => {\n if (!isUnder(root, path)) return;\n const field = fieldAt(path);\n if (!field) return;\n const wrong = hasOwnProp(NOT_A_VALUE, field.kind) ? NOT_A_VALUE[field.kind] : undefined;\n if (!wrong) return;\n problems.push(\n `${key}: ${prop} shows ${path}, which is ${wrong.what} and not a value; a prop that shows a value takes a scalar path, and ${wrong.instead}`,\n );\n };\n const checkList = (prop: string, path: string, items: ListItems): void => {\n if (!isUnder(root, path)) return;\n const field = fieldAt(path);\n if (!field || field.kind === 'unknown') return;\n if (field.kind !== 'list') {\n const what = hasOwnProp(NOT_A_VALUE, field.kind)\n ? NOT_A_VALUE[field.kind]!.what\n : 'a value';\n problems.push(\n `${key}: ${prop} takes a list, and ${path} is ${what}; a prop that takes a list reads a list path`,\n );\n return;\n }\n if (items !== 'values') return;\n const of = hasOwnProp(NOT_VALUES, field.item.kind) ? NOT_VALUES[field.item.kind] : undefined;\n if (!of) return;\n problems.push(\n `${key}: ${prop} takes a list of values, and ${path} is a list of ${of}; a list of ${of} is laid out as a repeat or a DataTable`,\n );\n };\n // A share's parts are read by member name, so a list of scalars or a\n // misspelt key would draw an empty bar with nothing to say why; it is\n // refused here instead, and the page falls back.\n const checkShares = (path: string): void => {\n if (element.type !== 'ProportionBar' || !isUnder(root, path)) return;\n const field = fieldAt(path);\n if (field?.kind !== 'list') return;\n if (field.item.kind !== 'object') {\n problems.push(\n `${key}: ProportionBar reads ${path}, a list of ${field.item.kind} values; its parts are structures, each with a label member and a number member`,\n );\n return;\n }\n const members = field.item.fields;\n const { labelKey, valueKey } = (element.props ?? {}) as Record<string, unknown>;\n const member = (name: unknown) =>\n typeof name === 'string' ? members.find((m) => m.name === name) : undefined;\n if (!member(labelKey)) {\n problems.push(\n `${key}: ProportionBar's labelKey ${JSON.stringify(labelKey)} is no member of ${path}'s items`,\n );\n }\n const value = member(valueKey);\n if (!value) {\n problems.push(\n `${key}: ProportionBar's valueKey ${JSON.stringify(valueKey)} is no member of ${path}'s items`,\n );\n } else if (value.kind !== 'number') {\n problems.push(\n `${key}: ProportionBar's valueKey ${JSON.stringify(valueKey)} holds a ${value.kind}, not a number`,\n );\n }\n };\n // The path an expression reads, resolved: `$state` and `$bindState` name\n // it, `$item` and `$bindItem` name it relative to the repeat's item, and\n // all four resolve to the value there. Nothing for any other value.\n const readPath = (value: unknown): string | undefined => {\n const form = expressionForm(value);\n const record = value as Record<string, string>;\n if (form === '$state' || form === '$bindState') return record[form];\n if (form === '$item' || form === '$bindItem') return itemPath(record[form]!);\n return undefined;\n };\n // Whether json-render resolves `value` to the repeat's index, a number.\n const readsIndex = (value: unknown): boolean => expressionForm(value) === '$index';\n // Every value `value` can resolve to, a `$cond` being either of its\n // branches, each resolved again; the value itself for anything else.\n const outcomes = (value: unknown, depth = 0): unknown[] => {\n const branches = depth < MAX_COND_DEPTH ? condBranches(value) : undefined;\n return branches ? branches.flatMap((branch) => outcomes(branch, depth + 1)) : [value];\n };\n // Why an amount draws nothing, or nothing when it draws: what the\n // renderer draws from is a number, or a text that writes one out\n // (`shareAmount`), so a literal must be one and a read must name a path\n // that holds one. A `$template` writes a text that may carry anything\n // around the number, so it reads none.\n const amountPathRefusal = (path: string): string | undefined => {\n const field = isUnder(root, path) ? fieldAt(path) : undefined;\n if (field && field.kind !== 'number' && field.kind !== 'unknown') {\n return `reads ${path}, which holds ${kindWords(field.kind)}, not a number`;\n }\n return undefined;\n };\n const amountRefusal = (amount: unknown): string | undefined => {\n if (Number.isFinite(shareAmount(amount)) || readsIndex(amount)) return undefined;\n const path = readPath(amount);\n if (path === undefined) {\n const shown = isExpression(amount)\n ? 'an expression that reads no number'\n : String(JSON.stringify(amount ?? null));\n return `is ${shown}, not a number`;\n }\n return amountPathRefusal(path);\n };\n // A share's total and its ceiling, held to what the renderer draws as\n // either: a number, or a read of one. The renderer shows no figure for\n // anything else rather than the parts' sum, so a total a model wrote as\n // a `$template` around a currency would be a bar with no figure; it is\n // refused here instead, in each branch of a `$cond`, and the page falls\n // back. Writing none (`null`) is the parts' sum, and no ceiling. The\n // repeat's index, which a part's amount may read, is never a total, and\n // outside a repeat it resolves to nothing, which the renderer would take\n // for no total and draw the parts' sum in its place.\n if (element.type === 'ProportionBar') {\n const props = (element.props ?? {}) as Record<string, unknown>;\n for (const prop of ['total', 'of'] as const) {\n const refusals = outcomes(props[prop])\n .filter((outcome) => outcome !== null && outcome !== undefined)\n .map((outcome) =>\n readsIndex(outcome) ? \"is the repeat's index, not an amount\" : amountRefusal(outcome),\n )\n .filter((refusal): refusal is string => refusal !== undefined);\n for (const refusal of new Set(refusals)) {\n problems.push(\n `${key}: ProportionBar's ${prop} ${refusal}; a total or a ceiling is a number, or reads a path that holds one with { \"$state\" }`,\n );\n }\n }\n }\n // Parts written out inline. The catalog takes a share's items as a list\n // of anything, and the renderer reads each by member name and its value\n // member as a number, so every entry must be a structure naming both\n // members whose value member is a number - written as one, or read from\n // a path that holds one - or a read of a structure that has both members,\n // its value member a number. A part or an amount under a `$cond` is held\n // to that in each branch, since either may be the one drawn. A part that\n // is neither draws no share, silently. The label member may be any\n // expression, which `walk` holds to a value. A path under no root the\n // descriptor owns is the layout's own scratch state and left alone, and\n // one the descriptor does not have is the staleness check's to name.\n // What comes back is the entries left to walk: a refused one is named\n // once, here, and a read part has nothing in it to walk.\n const inlineShares = (entries: readonly unknown[]): readonly unknown[] => {\n if (element.type !== 'ProportionBar') return entries;\n const { labelKey, valueKey } = (element.props ?? {}) as Record<string, unknown>;\n if (typeof labelKey !== 'string' || typeof valueKey !== 'string') return entries;\n const how = `each part is written as a structure with ${memberWords(labelKey)} member and ${memberWords(valueKey)} member holding a number, or the whole list is read with { \"$state\" }`;\n // What a template amount writes out: a template whose text is one\n // interpolation and nothing else, whitespace aside, writes out the\n // value at the path it reads, so it is read as that path - the renderer\n // draws the text a number writes out as that number. One with words or\n // a second interpolation beside it writes a number only by accident,\n // and one with none writes its own text.\n const templateAmount = (\n amount: unknown,\n ): { path: string } | { text: string } | 'more' | undefined => {\n if (expressionForm(amount) !== '$template') return undefined;\n const text = (amount as { $template: string }).$template;\n const sole = /^\\s*(\\$\\{[^}]+\\})\\s*$/.exec(text)?.[1];\n if (sole !== undefined) {\n const [path] = interpolatedPaths(sole, itemPath);\n return path === undefined ? 'more' : { path };\n }\n return interpolatedPaths(text, itemPath).length > 0 ? 'more' : { text };\n };\n // An inline amount may also be a template that writes one out; a page\n // hands json-render no functions, so a `$computed` resolves to nothing\n // there, which draws no share. Everything else is any amount's refusal.\n const inlineAmountRefusal = (amount: unknown): string | undefined => {\n if (expressionForm(amount) === '$computed') {\n return 'is a $computed, which a page has no function to resolve, not a number';\n }\n const written = templateAmount(amount);\n if (written === undefined) return amountRefusal(amount);\n if (written === 'more') {\n return 'is a template that writes text beside its value, not a number';\n }\n if ('path' in written) return amountPathRefusal(written.path);\n return Number.isFinite(shareAmount(written.text))\n ? undefined\n : `is a template that writes ${JSON.stringify(written.text)} out, not a number`;\n };\n // Whether an amount draws no share, naming why when it does not.\n const amountRefused = (part: string, amount: unknown): boolean => {\n const refusal = inlineAmountRefusal(amount);\n if (refusal === undefined) return false;\n problems.push(`${part}'s ${JSON.stringify(valueKey)} ${refusal}; ${how}`);\n return true;\n };\n // One value a part can resolve to, held to the rule above.\n const sharePart = (part: string, entry: unknown): unknown[] => {\n if (typeof entry !== 'object' || entry === null || Array.isArray(entry)) {\n const shown = Array.isArray(entry) ? 'a list' : String(JSON.stringify(entry ?? null));\n problems.push(`${part} is ${shown}, not a structure; ${how}`);\n return [];\n }\n if (isExpression(entry)) {\n const path = readPath(entry);\n if (path === undefined) {\n problems.push(`${part} is an expression that reads no structure; ${how}`);\n return [];\n }\n const field = isUnder(root, path) ? fieldAt(path) : undefined;\n if (!field || field.kind === 'unknown') return [];\n if (field.kind !== 'object') {\n problems.push(`${part} reads ${path}, which holds ${kindWords(field.kind)}; ${how}`);\n return [];\n }\n for (const name of [labelKey, valueKey]) {\n const member = field.fields.find((m) => m.name === name);\n if (!member) {\n problems.push(\n `${part} reads ${path}, which has no ${JSON.stringify(name)} member; ${how}`,\n );\n } else if (name === valueKey && member.kind !== 'number' && member.kind !== 'unknown') {\n problems.push(\n `${part} reads ${path}, whose ${JSON.stringify(name)} member holds ${kindWords(member.kind)}, not a number; ${how}`,\n );\n }\n }\n return [];\n }\n const missing = [labelKey, valueKey].find((name) => !hasOwnProp(entry, name));\n if (missing !== undefined) {\n problems.push(`${part} has no ${JSON.stringify(missing)} member; ${how}`);\n return [entry];\n }\n // A refused amount is named here, and the rest of the part is walked.\n const { [valueKey]: amount, ...rest } = entry as Record<string, unknown>;\n const refused = outcomes(amount)\n .map((outcome) => amountRefused(part, outcome))\n .some(Boolean);\n return refused ? [rest] : [entry];\n };\n return entries.flatMap((entry, index) => {\n const part = `${key}: ProportionBar's part ${index + 1}`;\n return outcomes(entry).flatMap((outcome) => sharePart(part, outcome));\n });\n };\n const walk = (prop: string, value: unknown): void => {\n if (Array.isArray(value)) {\n value.forEach((entry) => walk(prop, entry));\n return;\n }\n if (typeof value !== 'object' || value === null) return;\n const record = value as Record<string, unknown>;\n if (typeof record.$state === 'string') check(prop, record.$state);\n if (typeof record.$item === 'string') {\n const path = itemPath(record.$item);\n if (path !== undefined) check(prop, path);\n }\n if (typeof record.$template === 'string') {\n for (const path of interpolatedPaths(record.$template, itemPath)) check(prop, path);\n }\n for (const [name, entry] of Object.entries(record)) {\n if (name !== '$cond') walk(prop, entry);\n }\n };\n for (const [prop, value] of Object.entries(element.props ?? {})) {\n // A share's total and ceiling were held to a number above, which says\n // more than that they are no value.\n if (element.type === 'ProportionBar' && (prop === 'total' || prop === 'of')) continue;\n const items = listy?.get(prop);\n if (items === undefined || Array.isArray(value)) {\n walk(prop, prop === 'items' && Array.isArray(value) ? inlineShares(value) : value);\n continue;\n }\n if (typeof value !== 'object' || value === null) continue;\n const record = value as Record<string, unknown>;\n // A template writes a text, which is never the list the prop takes.\n if (typeof record.$template === 'string') {\n problems.push(\n `${key}: ${prop} takes a list, and a $template writes a text; a prop that takes a list reads a list path`,\n );\n continue;\n }\n // A binding reads the path it names as well as writing it, so it is\n // held to the path's kind exactly as a read is.\n const absolute = typeof record.$state === 'string' ? record.$state : record.$bindState;\n const relative = typeof record.$item === 'string' ? record.$item : record.$bindItem;\n const listPath =\n typeof absolute === 'string'\n ? absolute\n : typeof relative === 'string'\n ? itemPath(relative)\n : undefined;\n if (listPath !== undefined) {\n checkList(prop, listPath, items);\n if (prop === 'items') checkShares(listPath);\n }\n }\n }\n return problems;\n}\n\n/**\n * The bound paths a layout may not write, under one rule for both pages - the\n * rule the read side above and the validator's `setState` check already apply.\n * `/inputs` is the person's: on an input page a binding there must name an\n * input the descriptor has, and a result page, which writes nothing, may not\n * bind there at all. `/result` is the run's, and no page may bind into it.\n * Anything else is the layout's own scratch state - a `Switch` bound to\n * `/ui/showDetails` is the natural way to drive a `visible` condition - and it\n * is left alone, as a read of it is.\n */\nfunction boundProblems(\n bound: readonly string[],\n inputs: readonly RunField[] | undefined,\n): string[] {\n const problems: string[] = [];\n const underInputs = bound.filter((path) => isUnder(INPUTS_ROOT, path));\n if (!inputs) {\n if (underInputs.length > 0) {\n problems.push(`a result page binds ${underInputs.join(', ')}; a result page writes nothing`);\n }\n } else {\n for (const path of underInputs) {\n if (!inputFieldAtPath(inputs, path)) {\n problems.push(`${path} is bound, and no input has it`);\n }\n }\n }\n for (const path of bound) {\n if (isUnder(RESULT_ROOT, path)) {\n problems.push(\n `${path} is bound; a layout may not write into ${RESULT_ROOT}, which the run fills`,\n );\n }\n }\n return problems;\n}\n\n/** The list path of every `repeat` in the spec: how a layout lays a list out. */\nfunction repeatPaths(spec: Spec): string[] {\n const found: string[] = [];\n for (const element of Object.values(spec.elements)) {\n const statePath = element.repeat?.statePath;\n if (typeof statePath === 'string') found.push(statePath);\n }\n return found;\n}\n\n/**\n * Where a person can enter this path: bound to a control, laid out as a\n * repeat, or delegated to the kernel's own control at this path or at any\n * ancestor of it - an `MthdsField` on a structure renders the whole subtree.\n */\nfunction isOffered(path: string, offered: Offered): boolean {\n if (offered.bound.has(path) || offered.repeated.has(path)) return true;\n return offered.delegated.some((at) => path === at || path.startsWith(`${at}/`));\n}\n\ninterface Offered {\n bound: Set<string>;\n repeated: Set<string>;\n delegated: string[];\n}\n\n/**\n * The required paths under `field` that the layout offers nowhere.\n *\n * A structure is covered by covering what it requires, so a layout may leave\n * out an optional member and still fit; a list is covered whole, by a repeat\n * or by delegation, because its items are the layout's business and not this\n * predicate's. A structure that requires no member still has to hold\n * something before the run takes it (`fieldFilled`), so it is covered by\n * covering any one member, or by a member whose default the seed writes into\n * it, and is itself the uncovered path otherwise: answering nothing there let\n * a page through that no person could complete.\n *\n * `seeded` says that `seedInputs` walks `field`: true of every top-level\n * input, and of a member only down a chain of required structures with no\n * default of their own. The seed leaves an optional structure absent and\n * writes a structure's own default whole, so a member's default anywhere else\n * never arrives, however required the structures between are.\n */\nfunction uncoveredUnder(\n field: RunField,\n path: string,\n offered: Offered,\n seeded: boolean,\n): string[] {\n if (isOffered(path, offered)) return [];\n if (field.kind === 'object') {\n const seededBelow = seeded && field.required && field.defaultValue === undefined;\n const under = (child: RunField) =>\n uncoveredUnder(child, joinPath(path, child.name), offered, seededBelow);\n const required = field.fields.filter((child) => child.required);\n if (required.length > 0) return required.flatMap(under);\n // A blank default fills nothing, whatever the seed does with it.\n return field.fields.some(\n (child) => (seededBelow && isFilled(child.defaultValue)) || under(child).length === 0,\n )\n ? []\n : [path];\n }\n return [path];\n}\n\n/**\n * Every way this layout no longer fits, in the words a host can count by:\n * one line per element or path, empty when it fits.\n *\n * The checks live in `collectLayoutProblems`; this is the boundary that keeps\n * the promise in the header around them. A malformed spec is one line, naming\n * what the walk tripped on, which is a verdict the fallback can act on where a\n * throw was not.\n */\nexport function layoutProblems(descriptor: LayoutDescriptor, spec: Spec): string[] {\n const misshapen = descriptorMalformation(descriptor);\n if (misshapen !== undefined) return [misshapen];\n const malformed = specMalformation(spec);\n if (malformed !== undefined) return [malformedLine(malformed)];\n return fitCheck(descriptor, spec).problems;\n}\n\n/**\n * What makes `descriptor` no descriptor the fit check can read, in words, or\n * nothing. A descriptor is the host's, derived from the method; one of the\n * wrong shape is answered as such, in words saying what is wrong with it,\n * and `layoutCheck` flags it as no repair of the layout can mend. An\n * absent half - `null` written for it included, which is how JSON carries one\n * - is a descriptor with nothing on that side. Every field is held to the\n * shape the walks read, at every depth: a structure naming its `kind` and its\n * `name` as texts, a structure's members a list of fields and a list's item a\n * field, with no field inside itself, none nested deeper than\n * `MAX_FIELD_DEPTH` and no more than `MAX_DESCRIPTOR_FIELDS` in all. Reading\n * one never throws: a descriptor whose own reading\n * throws is answered as one that cannot be read.\n */\nexport function descriptorMalformation(descriptor: unknown): string | undefined {\n if (typeof descriptor !== 'object' || descriptor === null) {\n return 'the layout has no descriptor to be checked against';\n }\n try {\n const budget = { fields: 0 };\n const { inputs, result } = descriptor as { inputs?: unknown; result?: unknown };\n if (inputs != null && !Array.isArray(inputs)) {\n return 'the descriptor\\'s \"inputs\" is not a list of fields';\n }\n for (const [index, input] of (inputs ?? []).entries()) {\n const problem = fieldMalformation(input, `input ${index + 1}`, new Set(), budget);\n if (problem !== undefined) return `the descriptor's ${problem}`;\n }\n if (result != null) {\n if (!isField(result)) return 'the descriptor\\'s \"result\" is not a field';\n const problem = fieldMalformation(result, '\"result\"', new Set(), budget);\n if (problem !== undefined) return `the descriptor's ${problem}`;\n }\n return undefined;\n } catch (error) {\n let said: string;\n try {\n said = String(error);\n } catch {\n said = 'an error that cannot be written out';\n }\n return `the descriptor cannot be read (${said})`;\n }\n}\n\n/** How many fields deep a descriptor is read before it is refused as too deep. */\nconst MAX_FIELD_DEPTH = 64;\n\n/**\n * How many fields a descriptor holds, counted at each place one is held,\n * before it is refused as too large. A field held at two places is two fields\n * the form draws and the fit check walks, so a descriptor built in memory that\n * shares a structure level under level doubles at every level within the\n * depth cap; no method declares anywhere near this many.\n */\nconst MAX_DESCRIPTOR_FIELDS = 10_000;\n\n/** Whether `value` names its `kind` and its `name` as texts, as a field does. */\nfunction isField(value: unknown): value is { kind: string; name: string } {\n return (\n typeof value === 'object' &&\n value !== null &&\n !Array.isArray(value) &&\n typeof (value as { kind?: unknown }).kind === 'string' &&\n typeof (value as { name?: unknown }).name === 'string'\n );\n}\n\n/**\n * What makes `value`, which the descriptor holds as `subject`, no field the\n * walks can read, or nothing. `ancestors` holds the fields it sits inside,\n * so a field held twice - two members sharing one definition - is read at\n * each place, and only one inside itself is refused.\n */\nfunction fieldMalformation(\n value: unknown,\n subject: string,\n ancestors: Set<object>,\n budget: { fields: number },\n): string | undefined {\n if (++budget.fields > MAX_DESCRIPTOR_FIELDS) {\n return `fields number more than ${MAX_DESCRIPTOR_FIELDS}, counted at each place one is held`;\n }\n if (!isField(value)) return `${subject} is not a field`;\n const named = `${subject} (${JSON.stringify(value.name)})`;\n if (ancestors.has(value)) return `${named} contains itself`;\n if (ancestors.size >= MAX_FIELD_DEPTH) {\n return `${named} is nested more than ${MAX_FIELD_DEPTH} fields deep`;\n }\n ancestors.add(value);\n try {\n if (value.kind === 'object') {\n const { fields } = value as { fields?: unknown };\n if (!Array.isArray(fields)) return `${named} has no list of member \"fields\"`;\n for (const [index, member] of fields.entries()) {\n const problem = fieldMalformation(\n member,\n `${named} member ${index + 1}`,\n ancestors,\n budget,\n );\n if (problem !== undefined) return problem;\n }\n }\n if (value.kind === 'list') {\n const problem = fieldMalformation(\n (value as { item?: unknown }).item,\n `${named} item`,\n ancestors,\n budget,\n );\n if (problem !== undefined) return problem;\n }\n return undefined;\n } finally {\n ancestors.delete(value);\n }\n}\n\n/**\n * The fit check on a descriptor and a spec already known to have the shapes\n * it reads, and whether the check itself failed on them - said beside the\n * problems, so no reader has to recognise the failure by its words.\n */\nexport function fitCheck(\n descriptor: LayoutDescriptor,\n spec: Spec,\n): { problems: string[]; checksFailed: boolean } {\n try {\n return { problems: collectLayoutProblems(descriptor, spec), checksFailed: false };\n } catch (error) {\n return { problems: [checksFailedLine(error)], checksFailed: true };\n }\n}\n\n/**\n * A value a layout wrote, as text for a problem line: a text as it is,\n * anything else as its JSON. Never throws, for a value whose own `toString`\n * would.\n */\nfunction shownAs(value: unknown): string {\n if (typeof value === 'string') return value;\n try {\n return String(JSON.stringify(value ?? null));\n } catch {\n return 'a value that cannot be written out';\n }\n}\n\nfunction collectLayoutProblems(descriptor: LayoutDescriptor, spec: Spec): string[] {\n const problems: string[] = [];\n const delegated: string[] = [];\n const parents = parentMapOf(spec);\n\n for (const [key, element] of Object.entries(spec.elements)) {\n const written = (element.props as { path?: unknown } | undefined)?.path;\n const path =\n typeof written === 'string' ? absoluteHatchPath(spec, key, written, parents) : undefined;\n if (element.type === 'MthdsField') {\n if (!path || !inputFieldAtPath(descriptor.inputs ?? [], path)) {\n problems.push(`${key}: MthdsField delegates ${shownAs(written)}, which no input has`);\n } else {\n delegated.push(path);\n }\n }\n if (element.type === 'MthdsResult') {\n if (!path || !descriptor.result || !resultFieldAtPath(descriptor.result, path)) {\n problems.push(`${key}: MthdsResult delegates ${shownAs(written)}, which no result has`);\n }\n }\n // A repeat renders its element ONCE and that element's children once per\n // item, so a Grid whose only child carries the repeat is a grid of one\n // cell holding every item in a column: three directions in a third of\n // the page, the rest empty. The repeat belongs on the Grid.\n const [onlyKey] = element.children?.length === 1 ? element.children : [];\n const only = onlyKey === undefined ? undefined : spec.elements[onlyKey];\n if (element.type === 'Grid' && element.repeat === undefined && only?.repeat !== undefined) {\n problems.push(\n `${key}: Grid's only child ${onlyKey} carries the repeat, so every item lands in one cell; put the repeat on ${key} itself, with the item's element as its child`,\n );\n }\n // A picture names its path literally, as a hatch does, because an image is\n // a file the kind check refuses to read into a prop; so it is held here to\n // what a hatch is held to, and to the one kind it can show. Inside a repeat\n // over a list of images, \"\" is the item itself.\n if (element.type === 'Picture') {\n const shown = written === '' ? repeatBasePathOf(spec, key, parents) : (path ?? undefined);\n const field =\n shown && descriptor.result ? resultFieldAtPath(descriptor.result, shown) : undefined;\n if (!field) {\n problems.push(`${key}: Picture shows ${JSON.stringify(written)}, which no result has`);\n } else if (field.kind !== 'image') {\n problems.push(`${key}: Picture shows ${shown}, which holds a ${field.kind}, not an image`);\n }\n }\n }\n\n const { bound, read, adrift } = mentionedPaths(spec, parents);\n for (const key of new Set(adrift)) {\n problems.push(`${key}: reads the current item, and no repeat above it has one`);\n }\n problems.push(...boundProblems(bound, descriptor.inputs));\n\n if (!descriptor.inputs) {\n const result = descriptor.result;\n const fieldAt = (path: string): RunField | undefined =>\n result ? resultFieldAtPath(result, path) : undefined;\n const resolves = (path: string): boolean => fieldAt(path) !== undefined;\n problems.push(...staleRepeats(spec, parents, RESULT_ROOT, fieldAt, 'result'));\n for (const path of staleReads(read, RESULT_ROOT, resolves)) {\n problems.push(`${path} is read, and no result has it`);\n }\n problems.push(...nonScalarReads(spec, parents, RESULT_ROOT, fieldAt));\n return problems;\n }\n\n const inputs = descriptor.inputs;\n const fieldAt = (path: string): RunField | undefined => inputFieldAtPath(inputs, path);\n const resolves = (path: string): boolean => fieldAt(path) !== undefined;\n problems.push(...staleRepeats(spec, parents, INPUTS_ROOT, fieldAt, 'input'));\n for (const path of staleReads(read, INPUTS_ROOT, resolves)) {\n problems.push(`${path} is read, and no input has it`);\n }\n problems.push(...nonScalarReads(spec, parents, INPUTS_ROOT, fieldAt));\n\n const offered: Offered = {\n bound: new Set(bound),\n repeated: new Set(repeatPaths(spec)),\n delegated,\n };\n for (const field of inputs) {\n if (!field.required) continue;\n for (const path of uncoveredUnder(field, joinPath(INPUTS_ROOT, field.name), offered, true)) {\n problems.push(`${path} is required, and the layout offers nowhere to enter it`);\n }\n }\n\n return problems;\n}\n\n/** The predicate: `layoutProblems` is empty. */\nexport function layoutFits(descriptor: LayoutDescriptor, spec: Spec): boolean {\n return layoutProblems(descriptor, spec).length === 0;\n}\n","import type { Spec } from '@json-render/core';\nimport { validateSpec } from '@json-render/core';\nimport type { z } from 'zod';\nimport { frameCatalog } from './catalog';\nimport { isExpression } from './expressions';\nimport { INPUTS_ROOT, RESULT_ROOT } from './paths';\nimport { checksFailedLine, malformedLine, specMalformation } from './spec-shape';\nimport { unwrapped } from './zod-definition';\nimport { hasOwnProp } from '../core/own-property';\n\n/**\n * Whether a spec is one this catalog can render - the check every source\n * passes, whoever wrote it.\n *\n * Three layers, because json-render's own `catalog.validate()` covers only the\n * first two once a catalog has more than one component: it checks the element\n * TYPE against the component names, but `propsOf` degrades to \"any record\"\n * when several definitions could apply, so a misspelt or invented prop passes.\n * The per-component prop check is therefore this module's, and it has to be\n * expression-aware: a bound prop's raw value is `{ \"$state\": \"/path\" }`, which\n * the component's own zod schema (`z.string()`) would reject, so a dynamic\n * expression is accepted wherever the prop EXISTS and a literal is parsed\n * against the prop's schema.\n *\n * The checks are the same whichever catalog a spec was written against; the\n * catalog is a parameter, this entry's own by default, so a host that defines\n * a vocabulary of its own is validated by the same code and not by a copy of\n * it.\n *\n * What a component renders beyond its schema - the heading its title is, the\n * landmark it renders as, the fixed number of children it lays out, the panel\n * per entry of one of its props - is a fact about its renderer that no schema\n * states, so the catalog carries it as `renders`, declared beside the\n * definitions, and the validator reads it off the catalog it is handed rather\n * than assuming it from a component's name, which a host's vocabulary may\n * reuse for something that renders nothing of the kind. This entry's catalog\n * declares its own; a host's declares what its renderers do, or nothing, and\n * is then held only to what its schemas and its `Heading` elements say.\n */\n\n/**\n * What one component renders beyond what its props schema says, and what the\n * validator holds a layout to on that account. Every member is optional: a\n * component with none is held to its schema alone.\n */\nexport interface ComponentRendering {\n /**\n * The heading its renderer emits, at this level - a `Hero`'s headline is\n * the h1 - and, when it emits one only if a prop is set, the prop: a `Card`\n * renders its `title` as an h3 and nothing when it has none.\n */\n heading?: { level: 1 | 2 | 3 | 4; when?: string };\n /** What it renders as that a page has one of - a landmark, in the words a refusal uses: \"the page's banner\". */\n once?: string;\n /** The number of children its renderer lays out, dropping the rest in silence, and what they are. */\n children?: { count: number; roles: string };\n /** A panelled container: the prop that lists its panels, one child per entry, and what one is called. */\n panels?: { prop: string; noun: string };\n}\n\n/** What the validator reads off a catalog: its names, its definitions, and what its components render. */\nexport interface ValidationCatalog {\n componentNames: readonly string[];\n /** The catalog's own action names. A `defineCatalog` result carries this already. */\n actionNames?: readonly string[];\n data: unknown;\n /** The schema the catalog was defined against, for the actions its runtime handles without a handler. */\n schema?: { builtInActions?: readonly { name: string }[] };\n /** What each component renders beyond its schema, by component name. Absent, no component renders a heading, a landmark or a fixed set of children. */\n renders?: Readonly<Record<string, ComponentRendering>>;\n}\n\nexport interface SpecProblem {\n elementKey?: string;\n message: string;\n}\n\nexport interface SpecVerdict {\n ok: boolean;\n problems: SpecProblem[];\n}\n\n/**\n * The components whose `path` the layer resolves as written - the two escape\n * hatches, and the `Picture`, which shows a file the kind check will not read\n * into a prop - so it is never an expression. The fit check resolves each\n * through the repeat above it; an expression there resolved at render time to\n * whatever it held, past this check.\n */\nconst LITERAL_PATHS = new Set(['MthdsField', 'MthdsResult', 'Picture']);\n\n/** The action a generative page hands to the host's `onRun`: the one that starts a billed run. */\nconst RUN_ACTION = 'run';\n\n/**\n * The events a run may start from: a press of a button, and Enter in a field,\n * which is how a plain form submits. Every other event a control emits fires\n * as the person edits or moves through the page.\n */\nconst DELIBERATE_EVENTS: readonly string[] = ['press', 'submit'];\n\n/** The value a zod issue path points at inside a prop's raw value. */\nfunction valueAt(value: unknown, path: readonly PropertyKey[]): unknown {\n let at: unknown = value;\n for (const step of path) {\n if (typeof at !== 'object' || at === null) return undefined;\n at = (at as Record<PropertyKey, unknown>)[step];\n }\n return at;\n}\n\n/**\n * The closed vocabularies a prop can be declared with, unwrapped through the\n * `.optional()` / `.nullable()` most of them carry.\n *\n * An expression-valued prop skips the literal check below, which is right for a\n * value the host supplies at render - but not for a prop whose whole meaning is\n * that it is one of a fixed set. A `{ \"$template\": \"script\" }` carries no\n * interpolation, so json-render resolves it to the literal string `script`,\n * and a renderer that trusted the prop's declared union turned that into a DOM\n * tag name. A closed vocabulary has no dynamic form: if the value is not one of\n * the names, no expression can make it one.\n */\nfunction isClosedVocabulary(schema: z.ZodType): boolean {\n const type = unwrapped(schema)?.type;\n return type === 'enum' || type === 'literal';\n}\n\n/**\n * Where inside a prop's value an expression stands for one of a fixed set of\n * names, as the issue path of the member it stands for: a `DataTable`\n * column's `format` written as `{ \"$state\": ... }` is refused as a top-level\n * closed prop is, rather than passed because it sits one level down. The\n * value is walked beside its schema, through lists and structures; the whole\n * prop is the caller's to judge.\n */\nfunction closedExpressionPaths(\n schema: z.ZodType | undefined,\n value: unknown,\n path: readonly PropertyKey[] = [],\n): PropertyKey[][] {\n if (schema === undefined || typeof value !== 'object' || value === null) return [];\n if (path.length > 0 && isExpression(value)) return isClosedVocabulary(schema) ? [[...path]] : [];\n const def = unwrapped(schema);\n if (Array.isArray(value)) {\n return def?.type === 'array'\n ? value.flatMap((entry, index) => closedExpressionPaths(def.element, entry, [...path, index]))\n : [];\n }\n if (def?.type !== 'object' || !def.shape) return [];\n const shape = def.shape;\n return Object.entries(value as Record<string, unknown>).flatMap(([name, member]) =>\n hasOwnProp(shape, name) ? closedExpressionPaths(shape[name], member, [...path, name]) : [],\n );\n}\n\n/** The catalog's definition of one component, or nothing for a type it does not have. */\nfunction definitionOf(\n catalog: ValidationCatalog,\n type: string,\n): { props?: unknown; events?: unknown; slots?: unknown } | undefined {\n const components = (catalog.data as { components: Record<string, { props?: unknown }> })\n .components;\n // `hasOwnProp`, because the type is model-written and a prototype key would\n // find a function where a definition belongs.\n return hasOwnProp(components, type) ? components[type] : undefined;\n}\n\n/** The zod object each component's props are declared with, by component name. */\nfunction propsSchemaOf(catalog: ValidationCatalog, type: string): z.ZodObject | undefined {\n const props = definitionOf(catalog, type)?.props;\n return props && typeof props === 'object' && 'shape' in props\n ? (props as z.ZodObject)\n : undefined;\n}\n\n/**\n * The events a component's renderer emits, as its definition declares them -\n * an empty list for a component that emits nothing. `undefined` only for a\n * type the catalog does not have, which section 2 reports on its own.\n */\nfunction eventsOf(catalog: ValidationCatalog, type: string): readonly string[] | undefined {\n const definition = definitionOf(catalog, type);\n if (!definition) return undefined;\n return Array.isArray(definition.events)\n ? definition.events.filter((event): event is string => typeof event === 'string')\n : [];\n}\n\n/**\n * The deepest element chain this entry judges.\n *\n * Every walk below recurses, json-render's `validateSpec` included, so a deep\n * enough chain overflows the stack inside the gate: a chain of a thousand\n * elements validates in about no time, six thousand throws. The stack limit is\n * a property of the engine and not of the layout, so without a cap the same\n * stored bytes can pass under node and fail in a browser - and a stored artifact\n * deserves one verdict wherever it is checked. The number is far past any page\n * a person reads and far short of where any engine's stack gives out.\n */\nconst MAX_ELEMENT_DEPTH = 512;\n\nfunction childKeysOf(spec: Spec, key: string): string[] {\n const element = spec.elements[key] as { children?: unknown; slots?: unknown } | null | undefined;\n if (!element) return [];\n const children = Array.isArray(element.children) ? (element.children as string[]) : [];\n const slots =\n typeof element.slots === 'object' && element.slots !== null\n ? Object.values(element.slots as Record<string, unknown>).flatMap((slot) =>\n Array.isArray(slot) ? (slot as string[]) : [],\n )\n : [];\n return [...children, ...slots].filter((child) => typeof child === 'string');\n}\n\n/**\n * The longest chain of elements in the spec, measured without recursing.\n *\n * Iterative on purpose: a check whose whole job is to catch a walk that\n * overflows must not be able to overflow itself. Post-order with a memo, so it\n * is linear in the tree rather than in its paths, and a back edge is ignored\n * for depth - a cycle is section 1b's to report, not this one's.\n */\nfunction deepestChain(spec: Spec): number {\n const below = new Map<string, number>();\n const onPath = new Set<string>();\n let deepest = 0;\n for (const start of Object.keys(spec.elements)) {\n if (below.has(start)) continue;\n const stack: string[] = [start];\n while (stack.length > 0) {\n const key = stack[stack.length - 1] as string;\n if (below.has(key)) {\n onPath.delete(key);\n stack.pop();\n continue;\n }\n const children = childKeysOf(spec, key).filter((child) => !onPath.has(child));\n const pending = children.filter((child) => !below.has(child));\n if (pending.length > 0) {\n onPath.add(key);\n stack.push(...pending);\n continue;\n }\n below.set(\n key,\n children.reduce((tallest, child) => Math.max(tallest, below.get(child) ?? 0), 0) + 1,\n );\n onPath.delete(key);\n stack.pop();\n }\n deepest = Math.max(deepest, below.get(start) ?? 0);\n }\n return deepest;\n}\n\n/**\n * Whether a spec is one this catalog can render.\n *\n * The checks live in `checkAgainstCatalog`; this is the boundary that keeps the\n * documented promise around them - it answers with problems, not exceptions.\n * That promise was not kept: `validateSpec` throws on `repeat: null`, on\n * `children: 5`, on `props: 5`, on a null element and on a missing `elements`\n * map, all of which a model can emit. A host calls this to decide whether it is\n * safe to render, so a throw leaves it with no verdict at the one moment it\n * needs one, and the fallback to the plain form never fires.\n */\nexport function validateAgainstCatalog(\n spec: Spec,\n // A whole page's vocabulary unless the caller names a frame's: the exported\n // `catalog` also defines the frames' own components, which a whole page\n // must not hold.\n catalog: ValidationCatalog = frameCatalog('page'),\n): SpecVerdict {\n const malformed = specMalformation(spec);\n if (malformed !== undefined) {\n return { ok: false, problems: [{ message: malformedLine(malformed) }] };\n }\n return catalogCheck(spec, catalog).verdict;\n}\n\n/**\n * The catalog's verdict on a spec already known to have the shape the checks\n * walk, and whether the checks themselves failed on it - said beside the\n * verdict, so no reader has to recognise the failure by its words.\n */\nexport function catalogCheck(\n spec: Spec,\n catalog: ValidationCatalog,\n): { verdict: SpecVerdict; checksFailed: boolean } {\n try {\n return { verdict: checkAgainstCatalog(spec, catalog), checksFailed: false };\n } catch (error) {\n return {\n verdict: { ok: false, problems: [{ message: checksFailedLine(error) }] },\n checksFailed: true,\n };\n }\n}\n\nfunction checkAgainstCatalog(spec: Spec, catalog: ValidationCatalog): SpecVerdict {\n const problems: SpecProblem[] = [];\n\n // 0. Depth, before anything that recurses - including json-render's own walk.\n const depth = deepestChain(spec);\n if (depth > MAX_ELEMENT_DEPTH) {\n return {\n ok: false,\n problems: [\n {\n message: `the element tree is ${depth} deep; this entry renders at most ${MAX_ELEMENT_DEPTH}.`,\n },\n ],\n };\n }\n\n // 1. Structure: root, children, misplaced fields, and the elements the root\n // never reaches. json-render reports an orphan at `warning` severity, so\n // forwarding errors alone made `checkOrphans` a flag with no effect on the\n // verdict - while `stream.ts` deliberately keeps an unreachable element in\n // the JSONL \"so a validator can report it\". An orphan is a branch of the\n // page the model wrote and never attached: it renders as nothing at all,\n // which is exactly the silent half-page the fallback exists for.\n const structure = validateSpec(spec, { checkOrphans: true });\n for (const issue of structure.issues) {\n if (issue.severity === 'error' || issue.code === 'orphaned_element') {\n problems.push({ elementKey: issue.elementKey, message: issue.message });\n }\n }\n\n // 1b. No element is its own ancestor.\n //\n // json-render's `validateSpec` guards its OWN walks against a cycle but\n // reports nothing about one, so `children: [\"self\"]` passes it in silence.\n // What follows is not silent: the renderer walks children to paint the\n // page and recurses until the stack goes. Catching it here is what makes\n // the fallback fire instead, and it is the reason `repeatBasePathOf` also\n // carries a `seen` guard of its own - the two predicates are exported\n // separately, so neither may assume the other ran first.\n const cyclic = new Set<string>();\n const state = new Map<string, 'open' | 'done'>();\n const descend = (key: string): void => {\n const mark = state.get(key);\n if (mark === 'done') return;\n if (mark === 'open') {\n cyclic.add(key);\n return;\n }\n state.set(key, 'open');\n const element = spec.elements[key];\n for (const child of element?.children ?? []) descend(child);\n for (const slot of Object.values(element?.slots ?? {}))\n for (const child of slot) descend(child);\n state.set(key, 'done');\n };\n for (const key of Object.keys(spec.elements)) descend(key);\n for (const key of cyclic) {\n problems.push({\n elementKey: key,\n message: `\"${key}\" is its own descendant: an element tree may not contain a cycle.`,\n });\n }\n\n // 2. Every type is in the catalog.\n const known = new Set(catalog.componentNames);\n for (const [key, element] of Object.entries(spec.elements)) {\n if (!known.has(element.type)) {\n problems.push({ elementKey: key, message: `unknown component type \"${element.type}\"` });\n }\n }\n\n // 2b. Every named slot is one its component declares. An element's\n // children in a slot its renderer does not have render nothing at all,\n // and json-render says so only in a development warning, which it\n // looks up by the registry object `defineRegistry` returned - and the\n // page renders through a registry of its own, every renderer wrapped in\n // a reporting boundary, so that warning never fires. `default` is\n // never a slot's name: a component's default content is its `children`.\n for (const [key, element] of Object.entries(spec.elements)) {\n const slots = element.slots;\n if (typeof slots !== 'object' || slots === null) continue;\n const definition = definitionOf(catalog, element.type);\n if (!definition) continue;\n const declared = Array.isArray(definition.slots) ? definition.slots : [];\n for (const name of Object.keys(slots)) {\n if (name !== 'default' && declared.includes(name)) continue;\n problems.push({\n elementKey: key,\n message:\n name === 'default'\n ? `\"${key}\" puts children in a slot named \"default\"; a component's own content goes in \"children\".`\n : `\"${key}\" puts children in slot \"${name}\", which ${element.type} does not have; its content goes in \"children\".`,\n });\n }\n }\n\n // 3. Every prop exists on its component, and every literal parses.\n for (const [key, element] of Object.entries(spec.elements)) {\n const schema = propsSchemaOf(catalog, element.type);\n if (!schema) continue;\n const shape = schema.shape as Record<string, z.ZodType>;\n const props = (element.props ?? {}) as Record<string, unknown>;\n for (const [name, value] of Object.entries(props)) {\n const propSchema = shape[name];\n if (!propSchema) {\n problems.push({\n elementKey: key,\n message: `${element.type} has no prop \"${name}\" (known: ${Object.keys(shape).join(', ')})`,\n });\n continue;\n }\n if (isExpression(value)) {\n if (LITERAL_PATHS.has(element.type) && name === 'path') {\n problems.push({\n elementKey: key,\n message: `${element.type}.path must be a literal string - absolute, or the item's field name inside a repeat - never an expression.`,\n });\n } else if (isClosedVocabulary(propSchema)) {\n problems.push({\n elementKey: key,\n message: `${element.type}.${name} is one of a fixed set of names, so it must be written as a literal, never as an expression.`,\n });\n }\n continue;\n }\n for (const at of closedExpressionPaths(propSchema, value)) {\n problems.push({\n elementKey: key,\n message: `${element.type}.${name}.${at.map(String).join('.')} is one of a fixed set of names, so it must be written as a literal, never as an expression.`,\n });\n }\n const parsed = propSchema.safeParse(value);\n // json-render resolves an expression wherever it sits in a prop, inside\n // an array or an object included, so an issue raised at a nested\n // expression, or under one (an expression standing for an object draws\n // issues at the object's members), is the literal check misreading it.\n const issues = parsed.success\n ? []\n : parsed.error.issues.filter(\n (issue) =>\n !issue.path.some((_, n) => isExpression(valueAt(value, issue.path.slice(0, n + 1)))),\n );\n if (issues.length > 0) {\n problems.push({\n elementKey: key,\n message: `${element.type}.${name}: ${issues.map((issue) => issue.message).join('; ')}`,\n });\n }\n }\n // A required prop that is absent. Optional ones are `.nullable()` in the\n // shadcn definitions, so \"required\" here means neither optional nor nullable.\n for (const [name, propSchema] of Object.entries(shape)) {\n if (name in props) continue;\n if (propSchema.safeParse(undefined).success || propSchema.safeParse(null).success) continue;\n problems.push({\n elementKey: key,\n message: `${element.type} is missing required prop \"${name}\"`,\n });\n }\n }\n\n // What each component renders beyond its schema, read off the catalog under\n // validation. `hasOwnProp`, because the type is model-written and a\n // prototype key would find a function where a rendering belongs.\n const renders = catalog.renders ?? {};\n const renderingOf = (type: string): ComponentRendering | undefined =>\n hasOwnProp(renders, type) ? renders[type] : undefined;\n\n // 4. A panelled container has one child per panel, in order. The renderer\n // would silently show fewer panels than tabs, or a step with nothing in\n // it; the validator says so instead.\n for (const [key, element] of Object.entries(spec.elements)) {\n const panelled = renderingOf(element.type)?.panels;\n if (!panelled) continue;\n const props = (element.props ?? {}) as Record<string, unknown>;\n const listed = props[panelled.prop];\n if (!Array.isArray(listed)) continue;\n const panels = listed.length;\n const children = element.children?.length ?? 0;\n if (children !== panels) {\n problems.push({\n elementKey: key,\n message: `${element.type} declares ${panels} panel${panels === 1 ? '' : 's'} but has ${children} child${children === 1 ? '' : 'ren'}: exactly one child per ${panelled.noun}, in order.`,\n });\n }\n const runs = (element.children ?? []).filter(\n (child) => spec.elements[child]?.type === 'Button',\n );\n if (runs.length > 0) {\n problems.push({\n elementKey: key,\n message: `${element.type} has a Button as a direct child; a panel is a container (a Stack), and the Button belongs inside the last one.`,\n });\n }\n }\n // 5. Exactly one h1, and heading levels that increase by one, in render\n // order. The Storybook a11y gate runs axe's `heading-order` at error, and\n // a page that jumps from h1 to h3 fails it; saying so here makes it a\n // rejected spec with a re-run rather than a failing story with a fixture\n // nobody may edit. A `Heading` is not the only element that renders one:\n // a component renders its title as a heading too, at the level its\n // rendering declares - which is what its description states to the\n // model - and the walk counts it where it renders, before its children,\n // since a title comes first. Counting `Heading` elements alone let a page\n // with no h1 through, and one with a Hero over a Section over a titled\n // Card was three headings the check never saw.\n // A Card renders its title as a heading only when it has one; a bound title\n // counts, since it renders whenever the value is set.\n const present = (value: unknown) => value !== undefined && value !== null && value !== '';\n const levels: { key: string; type: string; level: number }[] = [];\n // The elements of each component a page has at most one of, in render order.\n const onlyOnce = new Map<string, { reason: string; keys: string[] }>();\n const seen = new Set<string>();\n const walk = (key: string) => {\n if (seen.has(key)) return;\n seen.add(key);\n const element = spec.elements[key];\n if (!element) return;\n const props = (element.props ?? {}) as Record<string, unknown>;\n const rendering = renderingOf(element.type);\n if (element.type === 'Heading') {\n const level = String(props.level ?? 'h2');\n const match = /^h([1-4])$/.exec(level);\n if (match) levels.push({ key, type: 'Heading', level: Number(match[1]) });\n } else if (rendering?.heading) {\n const rendered = rendering.heading;\n const has = rendered.when === undefined || present(props[rendered.when]);\n if (has) levels.push({ key, type: element.type, level: rendered.level });\n }\n if (rendering?.once !== undefined) {\n const entry = onlyOnce.get(element.type) ?? { reason: rendering.once, keys: [] };\n entry.keys.push(key);\n onlyOnce.set(element.type, entry);\n }\n for (const child of element.children ?? []) walk(child);\n for (const slot of Object.values(element.slots ?? {})) for (const child of slot) walk(child);\n };\n if (spec.root) walk(spec.root);\n const describe = (heading: { type: string; level: number }) =>\n heading.type === 'Heading' ? `h${heading.level}` : `${heading.type}'s h${heading.level}`;\n // Every heading after the first may go deeper than the one before it by\n // one at most, as axe reads it.\n let previous: { type: string; level: number } | undefined;\n for (const heading of levels) {\n if (previous !== undefined && heading.level > previous.level + 1) {\n problems.push({\n elementKey: heading.key,\n message: `${describe(heading)} jumps after ${describe(previous)}: heading levels increase by one, never by more.`,\n });\n }\n previous = heading;\n }\n // One h1, which is the page's title: a page without one has no name for a\n // screen reader to announce, and a page with two has two. A page is asked\n // for one only where its catalog can express one - a `Heading` at level\n // h1, or a component whose rendering declares one - since a vocabulary\n // with neither could never satisfy the rule.\n const firsts = levels.filter((heading) => heading.level === 1);\n const h1Ways = [\n ...(known.has('Heading') ? ['as a Heading at level h1'] : []),\n ...Object.entries(renders)\n .filter(([, rendering]) => rendering.heading?.level === 1)\n .map(([type]) => `as the heading a ${type} renders`),\n ];\n if (firsts.length === 0 && spec.root && h1Ways.length > 0) {\n problems.push({\n elementKey: spec.root,\n message: `the page has no h1: exactly one, ${h1Ways.join(' or ')}.`,\n });\n }\n for (const extra of firsts.slice(1)) {\n problems.push({\n elementKey: extra.key,\n message: `a second h1 (${describe(extra)}, after ${describe(firsts[0]!)} at [${firsts[0]!.key}]): exactly one on a page.`,\n });\n }\n // A component that renders as one of the page's landmarks - its banner, its\n // contentinfo - is one a page has at most one of. axe says so of the DOM\n // (`landmark-no-duplicate-banner`), but the stories switch that rule off\n // because their pair view renders every page twice, so this is the one\n // place a second bar or footer is refused.\n for (const [type, { reason, keys }] of onlyOnce) {\n for (const extra of keys.slice(1)) {\n problems.push({\n elementKey: extra,\n message: `a second ${type} (after [${keys[0]}]): at most one on a page, since it renders as ${reason}.`,\n });\n }\n }\n\n // 6. A container that takes a fixed number of children, and would drop the\n // rest in silence: its renderer destructures the ones it lays out and\n // paints nothing for a third. The product rules state the count for a\n // Workspace, and this is where a layout is held to it.\n for (const [key, element] of Object.entries(spec.elements)) {\n const rule = renderingOf(element.type)?.children;\n if (!rule) continue;\n const children = element.children?.length ?? 0;\n if (children !== rule.count) {\n problems.push({\n elementKey: key,\n message: `${element.type} takes exactly ${rule.count} children (${rule.roles}); this one has ${children}.`,\n });\n }\n }\n\n // 7. The `on` field, which nothing looked at before.\n //\n // `props` was checked exhaustively while the other half of what a layout\n // can say went unread, and the failures that hid there are ends of the\n // same gap. An action name the catalog does not have is accepted, so a\n // `Cta` bound to a misspelt `run` renders a page that validates, fits,\n // and whose only button does nothing - with no fallback, because both\n // checks said yes. An EVENT name the component never emits is the same\n // dead button by the other door: a `Cta` emits `press` and nothing else,\n // so `on.click` bound to a perfectly good `run` fires never, and the\n // action check alone waved it through. And json-render's runtime applies\n // `setState` to whatever `statePath` it is handed, so a layout could write\n // a value the person never saw into `/inputs` and have it leave in the run\n // payload. That is rule 1 inverted: a layout names a path, and the two\n // trees the descriptor owns are the host's to fill - `/inputs` from the\n // person through the controls and `seedInputs`, `/result` from the run.\n // Scratch state of the layout's own, at any other path, stays its business.\n //\n // The write ban covers EVERY destination an action writes, not the one\n // parameter that happens to be named `statePath` on the obvious three:\n // `validateForm` writes its verdict at its own `statePath`, and\n // `pushState` clears a second path, `clearStatePath`, after it appends.\n // Both went unread, and either put a value into `/inputs` through an\n // action the ban never looked at. And the runtime's pointer parser treats\n // `inputs/city` exactly as `/inputs/city` - a missing leading slash is\n // supplied, never refused - so a destination is judged with the slash the\n // runtime will give it, not the one the model wrote.\n //\n // The name check needs a catalog that declares its actions. Both fields are\n // optional on `ValidationCatalog` and a `defineCatalog` result carries\n // both, so this entry's catalog is always checked - but a host that hands\n // in a vocabulary of its own without them gets the write ban and no\n // unknown-action verdict, rather than every action refused for want of a\n // list to check against.\n //\n // And a binding does not only sit under `on`. A `watch` fires its\n // bindings when the state at its key changes, with no event and no\n // person in between; and any binding may carry an `onSuccess` and an\n // `onError`, which the runtime applies after the handler returns or\n // throws: a `set` there writes each key straight into the state with\n // no handler between, and an `action` there is a binding of its own,\n // run through the same executor. Every one of those is a door into\n // `/inputs` that the walk over `on` never saw, so a binding is checked\n // wherever it sits, and a chain is followed as far as it goes.\n //\n // And a run is billed, so it starts from a deliberate gesture and from\n // nothing else (`DELIBERATE_EVENTS`). Bound under `change`, `focus` or\n // `blur` it started a run at every edit, and under a `watch` at every\n // change of the state, with no gesture at all. A run in a chain is never\n // deliberate either: json-render applies a chain after a handler alone, so\n // one after `validateForm` or a state action never fires, and one after a\n // run starts a second billed run as the first settles.\n /** Where a binding sits, which decides whether a run may start from it. */\n type Trigger = { kind: 'event'; event: string } | { kind: 'watch' } | { kind: 'chain' };\n const deliberately = `a run is billed, so it starts only from a deliberate gesture: bind it under ${DELIBERATE_EVENTS.map((event) => `\"${event}\"`).join(' or ')}.`;\n const misplacedRun = (trigger: Trigger): string | undefined => {\n if (trigger.kind === 'event') {\n return DELIBERATE_EVENTS.includes(trigger.event)\n ? undefined\n : `runs the method on \"${trigger.event}\", which fires as the person edits or moves through the page; ${deliberately}`;\n }\n if (trigger.kind === 'watch') {\n return `runs the method when the state changes, with no gesture at all; ${deliberately}`;\n }\n return `chains a run after another action, which either never fires or starts a second billed run as the first settles; bind run directly under ${DELIBERATE_EVENTS.map((event) => `\"${event}\"`).join(' or ')}.`;\n };\n const declared = [\n ...(catalog.actionNames ?? []),\n ...(catalog.schema?.builtInActions ?? []).map((action) => action.name),\n ];\n const knownActions = declared.length > 0 ? new Set(declared) : undefined;\n // Every parameter each state-writing action writes to. A destination the\n // runtime falls back on when the parameter is absent (`validateForm` writes\n // `/formValidation`; `pushState` clears nothing) is not the layout's to name,\n // so those are `optional`; the others are refused when they are not a literal.\n const STATE_WRITES: Record<string, readonly { param: string; optional?: boolean }[]> = {\n setState: [{ param: 'statePath' }],\n pushState: [{ param: 'statePath' }, { param: 'clearStatePath', optional: true }],\n removeState: [{ param: 'statePath' }],\n validateForm: [{ param: 'statePath', optional: true }],\n };\n const OWNED_ROOTS = [INPUTS_ROOT, RESULT_ROOT];\n /** The owned root a destination lands in, judged with the leading slash the runtime supplies. */\n const ownedRootOf = (written: string): string | undefined => {\n const statePath = written.startsWith('/') ? written : `/${written}`;\n return OWNED_ROOTS.find((root) => statePath === root || statePath.startsWith(`${root}/`));\n };\n const bindingsOf = (binding: unknown): unknown[] =>\n Array.isArray(binding) ? binding : [binding];\n const refusal = (owned: string, statePath: string): string =>\n `a layout may not write into ${owned}, which the host fills. Bind the value with { \"$bindState\": \"${statePath}\" } or delegate it with MthdsField instead.`;\n\n /**\n * One binding, wherever it sits - under `on.<event>`, under `watch.<path>`,\n * or as the `onSuccess` or `onError` of another - held to the name check,\n * the write ban, where a run may start, and then to its own callbacks.\n * `site` is the spelling a problem names the binding by, and `trigger` what\n * fires it.\n */\n const checkBinding = (key: string, site: string, entry: unknown, trigger: Trigger): void => {\n const action = (entry as { action?: unknown } | null)?.action;\n if (typeof action !== 'string') {\n problems.push({ elementKey: key, message: `${site} has an entry with no \"action\" name.` });\n return;\n }\n if (knownActions && !knownActions.has(action)) {\n problems.push({\n elementKey: key,\n message: `${site} names the unknown action \"${action}\" (known: ${[...knownActions].join(', ')}); nothing would handle it.`,\n });\n return;\n }\n if (action === RUN_ACTION) {\n const misplaced = misplacedRun(trigger);\n if (misplaced) problems.push({ elementKey: key, message: `${site} ${misplaced}` });\n }\n // `hasOwnProp`: the action is model-written, and `constructor` would\n // find a function where a list of destinations belongs.\n const writes = hasOwnProp(STATE_WRITES, action) ? STATE_WRITES[action] : undefined;\n if (writes) {\n const params = (entry as { params?: unknown }).params;\n for (const { param, optional } of writes) {\n const written =\n typeof params === 'object' && params !== null\n ? (params as Record<string, unknown>)[param]\n : undefined;\n if (written === undefined || written === null) {\n if (!optional) {\n problems.push({\n elementKey: key,\n message: `${site} calls ${action} without a literal \"${param}\".`,\n });\n }\n continue;\n }\n if (typeof written !== 'string') {\n problems.push({\n elementKey: key,\n message: `${site} calls ${action} with a \"${param}\" that is not a literal string; where an action writes must be named, never computed.`,\n });\n continue;\n }\n const owned = ownedRootOf(written);\n if (owned) {\n const where = param === 'statePath' ? `on \"${written}\"` : `with ${param} \"${written}\"`;\n problems.push({\n elementKey: key,\n message: `${site} calls ${action} ${where}: ${refusal(owned, written.startsWith('/') ? written : `/${written}`)}`,\n });\n }\n }\n }\n // What the runtime does once the handler has returned or thrown. A `set`\n // writes each of its keys straight into the state, with no handler in\n // between; an `action` is a binding of its own, run through the same\n // executor, so it is checked as one - callbacks included.\n for (const hook of ['onSuccess', 'onError'] as const) {\n const follow = (entry as Record<string, unknown>)[hook];\n if (follow === undefined || follow === null) continue;\n const hookSite = `${site}.${hook}`;\n if (typeof follow !== 'object' || Array.isArray(follow)) {\n problems.push({\n elementKey: key,\n message: `${hookSite} must be an object: a { \"set\" } of state paths to values, or an { \"action\" } binding.`,\n });\n continue;\n }\n const record = follow as Record<string, unknown>;\n if (record.set !== undefined && record.set !== null) {\n if (typeof record.set !== 'object' || Array.isArray(record.set)) {\n problems.push({\n elementKey: key,\n message: `${hookSite}.set must be an object mapping a state path to its value.`,\n });\n } else {\n for (const written of Object.keys(record.set as Record<string, unknown>)) {\n const owned = ownedRootOf(written);\n if (owned) {\n problems.push({\n elementKey: key,\n message: `${hookSite} sets \"${written}\": ${refusal(owned, written.startsWith('/') ? written : `/${written}`)}`,\n });\n }\n }\n }\n }\n if (record.action !== undefined) checkBinding(key, hookSite, record, { kind: 'chain' });\n }\n };\n\n for (const [key, element] of Object.entries(spec.elements)) {\n const on = (element as { on?: unknown }).on;\n if (on !== undefined && on !== null) {\n if (typeof on !== 'object' || Array.isArray(on)) {\n problems.push({\n elementKey: key,\n message: '\"on\" must be an object mapping an event name to its actions.',\n });\n } else {\n const emitted = eventsOf(catalog, element.type);\n for (const [event, binding] of Object.entries(on as Record<string, unknown>)) {\n if (emitted && !emitted.includes(event)) {\n problems.push({\n elementKey: key,\n message:\n emitted.length > 0\n ? `on.${event}: ${element.type} never emits \"${event}\" (it emits: ${emitted.join(', ')}), so nothing bound there would ever fire.`\n : `on.${event}: ${element.type} emits no events, so nothing bound there would ever fire.`,\n });\n }\n for (const entry of bindingsOf(binding)) {\n checkBinding(key, `on.${event}`, entry, { kind: 'event', event });\n }\n }\n }\n }\n // A watch has no event to check against a definition: its key is the\n // state path whose change fires it. Its bindings are held to everything\n // else.\n const watch = (element as { watch?: unknown }).watch;\n if (watch !== undefined && watch !== null) {\n if (typeof watch !== 'object' || Array.isArray(watch)) {\n problems.push({\n elementKey: key,\n message:\n '\"watch\" must be an object mapping a state path to the actions its change fires.',\n });\n } else {\n for (const [path, binding] of Object.entries(watch as Record<string, unknown>)) {\n for (const entry of bindingsOf(binding)) {\n checkBinding(key, `watch.${path}`, entry, { kind: 'watch' });\n }\n }\n }\n }\n }\n\n return { ok: problems.length === 0, problems };\n}\n\n/** The problems as one block, for a failing test or a repair prompt. */\nexport function formatProblems(problems: readonly SpecProblem[]): string {\n return problems\n .map((problem) =>\n problem.elementKey ? `[${problem.elementKey}] ${problem.message}` : problem.message,\n )\n .join('\\n');\n}\n","import type { Spec } from '@json-render/core';\nimport { frameCatalog } from './catalog';\nimport { FRAMES, type Frame } from './frame-definitions';\nimport { descriptorMalformation, fitCheck, type LayoutDescriptor } from './layout-fits';\nimport { checksFailedLine, malformedLine, specMalformation } from './spec-shape';\nimport { catalogCheck, formatProblems } from './validate';\n\n/**\n * What a producer of layouts needs beside the method, the catalog and the\n * brief: the line a creative seed travels as, the checks a produced layout is\n * held to, and how many times a refused one goes back to the method's repair\n * pass. Nothing here calls a model; the producer is the host's, on the far\n * side of this seam (docs/generative-ui.md, \"Producing a layout\").\n */\n\n/**\n * The one line a creative seed reaches the designer method as, under its\n * `seed` input. The planner's seed procedure was written against this line,\n * so a host that hands the method a seed sends it, rather than restating it.\n */\nexport function seedLine(seed: string): string {\n return `CREATIVE SEED (derive your direction from it; never reveal it): ${seed}`;\n}\n\n/**\n * How many times a producer hands a refused layout to the method's\n * `repair_layout` pass before it gives up and the host keeps the plain form.\n * The refusals the designer makes are slips of one prop or one heading, which\n * one pass told what it broke fixes; a second covers a fix that broke a rule\n * of its own, and a third would be paying for a page that is not converging.\n */\nexport const REPAIR_ATTEMPTS = 2;\n\n/** What a layout is checked against: the frame it was written for and the descriptor it binds. */\nexport interface LayoutCheck {\n frame: Frame;\n descriptor: LayoutDescriptor;\n}\n\n/**\n * The checks' answer on a layout: every problem they found, one a line, and\n * whether they themselves failed on it.\n */\nexport interface LayoutVerdict {\n /** Every problem, one a line, in the words the repair pass reads; empty means the layout may render. */\n problems: string[];\n /**\n * Whether no repair of the layout can help: a check threw on a layout of\n * the right shape, a defect in the checks, or the frame or the descriptor\n * the layout is checked against is not one, a defect in what the host\n * handed over. Each\n * is stated among the problems in a line of its own. The layout is refused\n * all the same - the host keeps the plain form - but a producer stops here\n * instead of handing the lines to the repair pass, which can change the\n * layout and neither the checks nor the descriptor.\n */\n checksFailed: boolean;\n}\n\n/**\n * Everything the host's two checks find wrong with a layout written for\n * `frame`, and whether the checks themselves failed on it: first the\n * catalog's verdict against the frame's own vocabulary (`frameCatalog`), then\n * whether it fits the descriptor (`layoutProblems`). Empty problems mean the\n * layout may render. A producer feeds the lines, joined, to `repair_layout`\n * as its `problems`, unless `checksFailed` says no repair can help; a host\n * deciding whether a stored layout renders needs only whether the list is\n * empty, which `layoutCheckProblems` answers alone.\n *\n * It never throws. Its subject is whatever a model wrote, or a layout and a\n * frame a host stored and read back, and a throw is the one answer a host\n * cannot act on: it arrives instead of the problem that would have sent the\n * page to its fallback. So a frame this package does not draw, a missing or\n * misshapen descriptor, and anything not shaped like a spec are each a\n * problem line, and a throw left in a walk below on a layout of the right\n * shape is the checks' own failure, a line saying so. The frame and the\n * descriptor are the host's, and a throw is the checks', so each of those\n * sets `checksFailed` too: no repair of the layout can mend it.\n * The shape is checked once, before either check walks the layout.\n */\nexport function layoutCheck(spec: Spec, { frame, descriptor }: LayoutCheck): LayoutVerdict {\n const refused = (line: string): LayoutVerdict => ({ problems: [line], checksFailed: false });\n if (!(FRAMES as readonly unknown[]).includes(frame)) {\n // The frame is the host's argument, not the layout's: no repair can mend it.\n return {\n problems: [\n `the layout is checked against the frame ${JSON.stringify(frame)}, which is none of ${FRAMES.join(', ')}`,\n ],\n checksFailed: true,\n };\n }\n // The descriptor is the host's, not the layout's: no repair can mend it.\n const misshapen = descriptorMalformation(descriptor);\n if (misshapen !== undefined) return { problems: [misshapen], checksFailed: true };\n const malformed = specMalformation(spec);\n if (malformed !== undefined) return refused(malformedLine(malformed));\n try {\n const catalogs = catalogCheck(spec, frameCatalog(frame));\n const invalid = catalogs.verdict.ok\n ? []\n : formatProblems(catalogs.verdict.problems).split('\\n');\n // A page that takes inputs is there to start a run, and nothing else in it\n // can: a layout with no button bound to `run` renders a dead page, which\n // the host must refuse rather than show.\n const runless =\n frame !== 'result' && descriptor.inputs && !pressRuns(spec)\n ? [\n \"the layout has no control that runs the method: bind `run` under a control's `on.press`\",\n ]\n : [];\n const fit = fitCheck(descriptor, spec);\n return {\n problems: [...invalid, ...runless, ...fit.problems],\n checksFailed: catalogs.checksFailed || fit.checksFailed,\n };\n } catch (error) {\n return { problems: [checksFailedLine(error)], checksFailed: true };\n }\n}\n\n/**\n * Everything the host's two checks find wrong with a layout written for\n * `frame`, one problem a line: `layoutCheck`'s problems alone, for a host\n * that needs only whether a stored layout renders. Never throws.\n */\nexport function layoutCheckProblems(spec: Spec, check: LayoutCheck): string[] {\n return layoutCheck(spec, check).problems;\n}\n\n/**\n * Whether any element binds the `run` action directly under `on.press`, as\n * the binding itself or as one entry of a list of them, which json-render runs\n * in order: a page needs a button that runs it. A run under a field's\n * `submit` is a deliberate gesture the catalog check accepts, but Enter in a\n * field is no control a person can see, so it does not count here; nor does a\n * run reached through an `onSuccess` or `onError` chain, which the catalog\n * check refuses. In the composer frame the one control that emits `press` is\n * the `Composer`'s run button, so this asks for that button to run. The walk\n * is total over whatever a model wrote, since a malformed element is the\n * catalog check's to report, never a reason for this one to throw.\n */\nfunction pressRuns(spec: Spec): boolean {\n const isRun = (binding: unknown): boolean =>\n typeof binding === 'object' &&\n binding !== null &&\n (binding as Record<string, unknown>).action === 'run';\n if (typeof spec !== 'object' || spec === null) return false;\n const elements: unknown = spec.elements;\n if (typeof elements !== 'object' || elements === null) return false;\n return Object.values(elements).some((element) => {\n if (typeof element !== 'object' || element === null) return false;\n const on: unknown = (element as Record<string, unknown>).on;\n if (typeof on !== 'object' || on === null) return false;\n const press: unknown = (on as Record<string, unknown>).press;\n return Array.isArray(press) ? press.some(isRun) : isRun(press);\n });\n}\n","import type { RunField } from '../core';\nimport {\n isNativeCompositeNode,\n isNativeDateNode,\n isNativeHtmlNode,\n isNativeValueNode,\n} from '../core/native-content';\nimport { APP_STYLES, type AppStyleId } from '../brand/styles';\nimport type { Brief, PathEntry, Style } from '../generated/layout-design/types';\nimport type { Frame } from './frame-definitions';\nimport { INPUTS_ROOT, RESULT_ROOT, joinPath } from './paths';\n\n/**\n * The brief: the model's view of the descriptor, as DATA.\n *\n * Rule 1, restated for a model. The model's input is the DESCRIPTOR, never JSON\n * Schema: it receives the kinds, the labels, the descriptions, the choices, the\n * presence and what gates the run - projected from `RunField[]` here, and from\n * nowhere else, into the `Brief` structure the designer method declares. On the\n * result side it also receives one real run's loaded state, so it can judge\n * magnitudes, but it never sees the wire: the state it reads is what\n * `payloadToState` produced, with the envelopes already gone.\n *\n * Nothing here is prose. The sentences a model reads - the headings, how a\n * path line is worded, what \"delegated\" says - are the method's own, in the\n * `render_brief` stage of `methods/layout-design.mthds`: a Jinja2 template\n * over this value, and the one place the brief's wording is edited. What this\n * module contributes is what only code can state: every path, flattened in\n * reading order with its depth, its kind in words, its constraints in words,\n * and which of them the kernel keeps. The shape is the method's own: codegen\n * projects its `Brief` and `PathEntry` structures into\n * `src/generated/layout-design/`, and the aliases below are those types,\n * imported type-only so the generated schemas stay out of the entry. A field\n * renamed in the bundle fails the type check on the literals here rather than\n * a run.\n *\n * Pure, no React, and the only place the descriptor is projected for a model.\n * What a path is marked as (delegated or not) is decided here too, so the\n * projection, the brief and the validator agree on which paths the kernel\n * renders.\n */\n\n/** The `Brief` structure of `methods/layout-design.mthds`, as codegen projects it. */\nexport type DesignerBrief = Brief;\n/** One path of the brief: where it is, what it holds, what constrains it, whether the kernel keeps it. */\nexport type DesignerPathEntry = PathEntry;\n/** The style a brief carries: its name and its direction, as `APP_STYLES` states them. */\nexport type DesignerStyle = Style;\n\n/** The concept a run request names for the `brief` input: the method's own, domain-qualified. */\nexport const DESIGNER_BRIEF_CONCEPT = 'generative.Brief';\n\n/**\n * The component that runs the page, handed over as the brief's `run_control`\n * so the brief and the catalog agree on which one it is - and so the method's\n * own prose can go on naming none of the catalog's chrome. A rename in the\n * catalog does not have to be caught here: a brief asking for a component the\n * catalog no longer has produces a layout the validator refuses, loudly, on\n * the pass that made it.\n */\nconst RUN_COMPONENT = 'Cta';\n/** In a host's composer frame the composer itself runs the method: its foot is the host's action row. */\nconst COMPOSER_RUN_COMPONENT = 'Composer';\n\nexport interface BriefSubject {\n /** `results.nested_result`. */\n pipeRef: string;\n /** The pipe's description, when the wire carries one. */\n description?: string;\n /**\n * The method's name as a host lists it - an authored method's, since a host\n * has one for every method it lists; absent on a synthesized carrier, which\n * no host lists. The brief hands it to the layout as the one product name\n * the page may carry, because the brand catalog's AppBar asks for a name\n * and a brief that gives none gets one invented.\n */\n name?: string;\n}\n\n/**\n * On the input side, the kinds the catalog's inputs cannot enter - and one\n * shape of a kind they otherwise can. The standard puts no floor on a choice,\n * so an enum may carry `\"\"`; the catalog's own choices may not, because no\n * dropdown row or pill can offer nothing, and the validator refuses an empty\n * option. A model told to list the brief's choices exactly would copy the\n * empty one into a layout the validator then refuses, so the brief hands the\n * input back to the kernel's own control instead.\n */\nexport function isDelegatedInput(field: RunField): boolean {\n return (\n field.kind === 'document' ||\n field.kind === 'image' ||\n field.kind === 'date' ||\n field.kind === 'list' ||\n field.kind === 'unknown' ||\n (field.kind === 'enum' && field.options.includes(''))\n );\n}\n\n/**\n * On the result side, the kinds and concepts the catalog cannot show.\n *\n * A native value is one of them, and so is a list of one: the native\n * predicates refuse a `list` node, because a list of dates is a list and not a\n * date, but no catalog component reads a date's `{date, time}` either, so the\n * kernel renders the list whole - one value per line, as the result view does.\n *\n * The result frame's vocabulary shows two of them itself: a picture\n * (`Picture`) and a date in words (`DateText`), so on a result page written\n * for that frame neither is delegated. A date with a time stays delegated:\n * `DateText` writes the day alone, and the kernel's result shows the time.\n */\nexport function isDelegatedResult(field: RunField, frame: Frame = 'page'): boolean {\n if (isNativeValueNode(field)) return true;\n if (frame === 'result' && (field.kind === 'image' || (field.kind === 'date' && !field.datetime)))\n return false;\n if (field.kind === 'list' && isNativeValueNode(field.item)) return true;\n return (\n field.kind === 'document' ||\n field.kind === 'image' ||\n field.kind === 'date' ||\n field.kind === 'prose' ||\n field.kind === 'unknown'\n );\n}\n\n/** What a path holds, in words - the one rendering of a kind the brief carries. */\nfunction kindLabel(field: RunField): string {\n if (isNativeHtmlNode(field)) return 'markup (native.Html)';\n if (isNativeDateNode(field)) return 'date (native.Date)';\n if (isNativeCompositeNode(field)) return 'composite (native.Composite)';\n switch (field.kind) {\n case 'text':\n return 'text';\n case 'prose':\n return 'prose (markdown)';\n case 'number':\n return field.integer ? 'integer' : 'number';\n case 'boolean':\n return 'boolean';\n case 'enum':\n return `choice of ${field.options.map((option) => JSON.stringify(option)).join(' | ')}`;\n case 'date':\n return field.datetime ? 'date with time' : 'date';\n case 'document':\n return 'document (a file)';\n case 'image':\n return 'image (a file)';\n case 'object':\n return `structure${field.conceptRef ? ` ${field.conceptRef}` : ''}`;\n case 'list':\n return `list of ${kindLabel(field.item)}`;\n case 'unknown':\n return 'unknown';\n default:\n return field satisfies never;\n }\n}\n\n/** The constraints and hints of a field, each one fact in words. */\nfunction constraints(field: RunField): string[] {\n const notes: string[] = [];\n if (field.kind === 'number') {\n if (field.min !== undefined) notes.push(`min ${field.min}`);\n if (field.max !== undefined) notes.push(`max ${field.max}`);\n }\n if (field.kind === 'text' || field.kind === 'prose') {\n if (field.minLength !== undefined) notes.push(`at least ${field.minLength} characters`);\n if (field.maxLength !== undefined) notes.push(`at most ${field.maxLength} characters`);\n if (field.format) notes.push(`format ${field.format}`);\n }\n if (field.kind === 'list') {\n if (field.itemCount !== undefined) notes.push(`at least ${field.itemCount} items`);\n if (field.maxItemCount !== undefined) notes.push(`at most ${field.maxItemCount} items`);\n }\n if (field.defaultValue !== undefined) notes.push(`default ${JSON.stringify(field.defaultValue)}`);\n if (field.examples && field.examples.length > 0) {\n notes.push(`examples ${field.examples.map((example) => JSON.stringify(example)).join(', ')}`);\n }\n if (field.hints && Object.keys(field.hints).length > 0) {\n notes.push(\n `hints ${Object.entries(field.hints)\n .map(([key, value]) => `${key}=${value}`)\n .join(', ')}`,\n );\n }\n return notes;\n}\n\ntype Side = 'input' | 'result';\n\n/**\n * One path as the brief carries it. Presence is an input-page fact, so it is\n * stated on that side only; `relative` marks a path spelled from one item of\n * the list above, which is how a DataTable column or `$item` reads it.\n * `seeded` says an ancestor already carries a default: the seed is the\n * OUTERMOST default, exactly as `seedInputs` seeds it, so a member beneath a\n * defaulted structure lists none of its own - two `/state` patches on one\n * subtree would make the seed depend on the order a model emits them in -\n * while its notes still state it, as a fact about the field rather than an\n * instruction. An optional structure with no default of its own seeds nothing\n * beneath it, for the same reason `seedInputs` leaves it absent.\n */\nfunction entryOf(\n field: RunField,\n path: string,\n depth: number,\n side: Side,\n relative: boolean,\n seeded: boolean,\n frame: Frame = 'page',\n): DesignerPathEntry {\n const notes = constraints(field);\n return {\n depth,\n path,\n kind: kindLabel(field),\n name: field.name,\n title: field.title && field.title !== field.name ? field.title : undefined,\n description: field.description,\n required: side === 'input' ? field.required : undefined,\n gating: side === 'input' && field.gating ? true : undefined,\n notes: notes.length > 0 ? notes : undefined,\n default:\n seeded || field.defaultValue === undefined ? undefined : JSON.stringify(field.defaultValue),\n delegated: side === 'input' ? isDelegatedInput(field) : isDelegatedResult(field, frame),\n relative: relative ? true : undefined,\n };\n}\n\n/**\n * A path and, beneath it, what the page can lay out: a structure's members at\n * their own paths, and - on a result page - a list's item, whose members\n * follow spelled relative to one item. A delegated path ends the walk: the\n * kernel renders it whole, so its members are nobody else's to bind.\n */\nfunction describe(\n field: RunField,\n path: string,\n depth: number,\n side: Side,\n entries: DesignerPathEntry[],\n seeded = false,\n frame: Frame = 'page',\n): void {\n const entry = entryOf(field, path, depth, side, false, seeded, frame);\n entries.push(entry);\n if (entry.delegated) return;\n if (field.kind === 'object') {\n // Beneath an optional structure with no default of its own nothing is\n // seeded either: whether it is there at all is the person's choice, made\n // with its disclosure, and `seedInputs` leaves it absent. Listing its\n // members' defaults as seeds would have a layout open it.\n const seededBelow =\n seeded || field.defaultValue !== undefined || (side === 'input' && !field.required);\n for (const child of field.fields) {\n describe(child, joinPath(path, child.name), depth + 1, side, entries, seededBelow, frame);\n }\n }\n if (field.kind === 'list' && side === 'result') {\n const item = field.item;\n entry.item_kind = kindLabel(item);\n entry.item_description = item.description;\n if (item.kind === 'object' && !isDelegatedResult(item, frame)) {\n entry.item_laid_out = true;\n for (const child of item.fields) {\n describeRelative(child, child.name, depth + 2, entries, side, frame);\n }\n }\n }\n}\n\n/** A member of a list's item, spelled relative to that item; a nested list's members go through `<i>`. */\nfunction describeRelative(\n field: RunField,\n relativePath: string,\n depth: number,\n entries: DesignerPathEntry[],\n side: Side = 'result',\n frame: Frame = 'page',\n): void {\n const entry = entryOf(field, relativePath, depth, side, true, false, frame);\n entries.push(entry);\n if (entry.delegated) return;\n if (field.kind === 'object') {\n for (const child of field.fields) {\n describeRelative(child, joinPath(relativePath, child.name), depth + 1, entries, side, frame);\n }\n }\n if (field.kind === 'list' && side === 'result') {\n const item = field.item;\n entry.item_kind = kindLabel(item);\n entry.item_description = item.description;\n if (item.kind === 'object' && !isDelegatedResult(item, frame)) {\n entry.item_laid_out = true;\n for (const child of item.fields) {\n describeRelative(\n child,\n joinPath(relativePath, '<i>', child.name),\n depth + 2,\n entries,\n side,\n frame,\n );\n }\n }\n }\n}\n\n/**\n * What one run gives back, one line per member of the result (of one item,\n * for a list), from the result's own titles and descriptions - so a composer\n * can say what comes back before the run.\n */\nfunction returnsOf(result: RunField): string[] {\n const shape = result.kind === 'list' ? result.item : result;\n const members = shape.kind === 'object' ? shape.fields : [shape];\n return members.map((member) => {\n const title = member.title ?? member.name.replace(/_/g, ' ');\n return member.description && member.description !== title\n ? `${title}: ${member.description}`\n : title;\n });\n}\n\n/** The style a brief carries, read off `APP_STYLES`: its name and its direction, as data. */\nfunction styleOf(style: AppStyleId | undefined): DesignerStyle | undefined {\n if (!style) return undefined;\n const { name, direction } = APP_STYLES[style];\n return { name, direction };\n}\n\n/** How an input page's brief is built: the frame it is written for, the team's style, and what a run returns. */\nexport interface InputBriefOptions {\n /** `page` (the default), a whole product page; `composer`, the inputs of a host's compose-then-result app. */\n frame?: Extract<Frame, 'page' | 'composer'>;\n /**\n * The style the team's apps wear. The brief carries its name and its\n * direction, which the composition follows; its faces, radii and panels are\n * the components' to draw and never reach the brief. Absent, the brief\n * names no style.\n */\n style?: AppStyleId;\n /** The result's descriptor, from which a composer's brief says what one run gives back. */\n result?: RunField;\n}\n\n/** How a result page's brief is built: the frame it is written for and the team's style. */\nexport interface ResultBriefOptions {\n /** `page` (the default), a whole product page; `result`, the result page of a host's compose-then-result app. */\n frame?: Extract<Frame, 'page' | 'result'>;\n /** The style the team's apps wear (see `InputBriefOptions.style`). */\n style?: AppStyleId;\n}\n\n/** The brief for an INPUT page: the form a run is started from. */\nexport function inputBrief(\n subject: BriefSubject,\n fields: readonly RunField[],\n { frame = 'page', style, result }: InputBriefOptions = {},\n): DesignerBrief {\n const paths: DesignerPathEntry[] = [];\n for (const field of fields) {\n describe(field, joinPath(INPUTS_ROOT, field.name), 0, 'input', paths, false, frame);\n }\n return {\n side: 'input',\n frame,\n pipe_ref: subject.pipeRef,\n description: subject.description,\n name: subject.name,\n paths,\n run_control: frame === 'composer' ? COMPOSER_RUN_COMPONENT : RUN_COMPONENT,\n ...(frame === 'composer' && result ? { returns: returnsOf(result) } : {}),\n ...(style ? { style: styleOf(style) } : {}),\n };\n}\n\n/** The brief for a RESULT page: what one run produced, laid out. */\nexport function resultBrief(\n subject: BriefSubject,\n field: RunField,\n state: unknown,\n { frame = 'page', style }: ResultBriefOptions = {},\n): DesignerBrief {\n const paths: DesignerPathEntry[] = [];\n if (field.kind === 'object' && !isDelegatedResult(field, frame)) {\n // The result itself is the root, and its line names no member: it IS the\n // structure, whose members then follow one level down.\n paths.push({\n depth: 0,\n path: RESULT_ROOT,\n kind: kindLabel(field),\n description: field.description,\n delegated: false,\n });\n for (const child of field.fields) {\n describe(child, joinPath(RESULT_ROOT, child.name), 1, 'result', paths, false, frame);\n }\n } else {\n describe(field, RESULT_ROOT, 0, 'result', paths, false, frame);\n }\n return {\n side: 'result',\n frame,\n pipe_ref: subject.pipeRef,\n description: subject.description,\n paths,\n ...(style ? { style: styleOf(style) } : {}),\n sample_state: JSON.stringify(state, null, 2),\n };\n}\n","import type { Spec } from '@json-render/core';\nimport { compileSpecStream } from '@json-render/core';\nimport { escapeSegment, unescapeSegment } from './paths';\n\n/**\n * A spec as JSONL patches, and back.\n *\n * json-render's wire format is RFC 6902 patches, one per line, root first and\n * parents before children, so a renderer can paint a partial tree at every\n * line. A model emits that format; a projected or authored spec is a finished\n * object. This is the bridge: any of the three sources can be replayed through\n * `specToJsonl`, and what a model emitted is compiled through `specFromJsonl`\n * before it is validated.\n */\n\n/**\n * The patch lines for a spec: `/root`, then every element reachable from the\n * root in breadth-first order (a parent always precedes its children), then\n * any element the root does not reach (kept, so a validator can report it),\n * then one patch per top-level `state` key.\n */\nexport function specToJsonl(spec: Spec): string {\n const lines: string[] = [];\n const push = (op: 'add', path: string, value: unknown) =>\n lines.push(JSON.stringify({ op, path, value }));\n\n push('add', '/root', spec.root);\n\n const emitted = new Set<string>();\n const queue = [spec.root];\n while (queue.length > 0) {\n const key = queue.shift()!;\n if (emitted.has(key)) continue;\n const element = spec.elements[key];\n if (!element) continue;\n emitted.add(key);\n push('add', `/elements/${escapeSegment(key)}`, element);\n for (const child of element.children ?? []) queue.push(child);\n for (const slotChildren of Object.values(element.slots ?? {})) queue.push(...slotChildren);\n }\n for (const key of Object.keys(spec.elements)) {\n if (!emitted.has(key)) push('add', `/elements/${escapeSegment(key)}`, spec.elements[key]);\n }\n for (const [key, value] of Object.entries(spec.state ?? {})) {\n push('add', `/state/${escapeSegment(key)}`, value);\n }\n return `${lines.join('\\n')}\\n`;\n}\n\n/**\n * The segments a patch path may not contain.\n *\n * json-render's patch applier walks a pointer with `if (!(segment in current)\n * || typeof current[segment] !== 'object') current[segment] = {}` and then\n * steps into it. `'__proto__' in {}` is true and its value is an object, so a\n * line naming `/__proto__/<key>` walks onto `Object.prototype` and assigns\n * there - polluting every object in the realm.\n *\n * This is the only place that can stop it. Compiling happens BEFORE\n * `validateAgainstCatalog` and before `layoutFits`, so by the time either gate\n * has a spec to judge, the damage is done and no verdict and no fallback can\n * undo it. A produced layout is untrusted text, and this is where it first\n * becomes objects.\n *\n * A `copy` or a `move` names a SECOND pointer, `from`, and the applier reads\n * it with the same walk: `getByPath(spec, '/__proto__')` answers\n * `Object.prototype` itself, and a `copy` of it to `/scratch` parks a\n * reference to the prototype inside the spec - not a clone - so the next\n * `add` at `/scratch/<key>` lands on every object in the realm through a path\n * that names no forbidden segment at all. Both pointers are checked, for the\n * same reason `path` is.\n */\nconst FORBIDDEN_SEGMENTS = new Set(['__proto__', 'constructor', 'prototype']);\n\n/** Whether a pointer would walk onto a prototype. */\nfunction pointerReachesPrototype(pointer: unknown): boolean {\n return (\n typeof pointer === 'string' &&\n pointer.split('/').some((segment) => FORBIDDEN_SEGMENTS.has(unescapeSegment(segment)))\n );\n}\n\n/** Whether a patch line names a pointer - its `path`, or a copy's or move's `from` - that would walk onto a prototype. */\nfunction reachesPrototype(line: string): boolean {\n let parsed: unknown;\n try {\n parsed = JSON.parse(line);\n } catch {\n return false; // Not JSON: the compiler skips it, and so do we.\n }\n const patch = parsed as { path?: unknown; from?: unknown } | null;\n return pointerReachesPrototype(patch?.path) || pointerReachesPrototype(patch?.from);\n}\n\n/**\n * The spec a JSONL stream compiles to. Blank lines and non-JSON lines are\n * skipped by the compiler; a line whose `path` or `from` would reach a\n * prototype is dropped here, before the compiler sees it; and a line the\n * compiler refuses is dropped too, which is why the stream is applied one line\n * at a time.\n *\n * A batch compile made a single bad line fatal to the whole layout. Two of them\n * are reachable from produced text: a `test` op whose value does not match\n * throws `Test operation failed`, and a non-string `path` throws\n * `path.startsWith is not a function`. A host follows the documented flow -\n * compile, then ask the two gates - so a throw here arrives before there is any\n * verdict to act on, and the fallback that exists for exactly this case never\n * fires. Skipping the line degrades instead: what survives is a partial spec,\n * which the gates then judge on its merits and reject if it is not renderable.\n */\nexport function specFromJsonl(jsonl: string): Spec {\n let spec: Record<string, unknown> = { root: '', elements: {} };\n for (const line of jsonl.split('\\n')) {\n if (reachesPrototype(line)) continue;\n try {\n spec = compileSpecStream<Record<string, unknown>>(line, spec) as Record<string, unknown>;\n } catch {\n continue; // A patch that will not apply is skipped, as a non-JSON line is.\n }\n }\n return spec as unknown as Spec;\n}\n\n/** The individual patch lines of a stream, for a replay that feeds them one at a time. */\nexport function jsonlLines(jsonl: string): string[] {\n return jsonl.split('\\n').filter((line) => line.trim().length > 0);\n}\n","import type { RunField } from '../core';\nimport { hasOwnProp } from '../core/own-property';\nimport { formatDateContent, isNativeValueNode, readDateContent } from '../core/native-content';\n\n/**\n * The two state loaders - what fills the trees a spec binds to.\n *\n * It is the LOADER, not the model, that knows the wire. A result payload\n * arrives with the runtime's serialization quirks - a date inside a structure\n * in a typed envelope, a plural result under `items` - and a model laying out\n * an invoice must not have to know either. This walks the result descriptor BY\n * STATED KIND, through the kernel's own readers, and hands the spec a tree it\n * can bind to naively. Working out what a value is by looking at it stays\n * forbidden on this side of the seam too: every branch below is keyed by what\n * the descriptor says, never by the shape of the payload.\n */\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n/**\n * A payload, as the result tree a spec binds to at `/result`.\n *\n * - a `date` becomes the ISO string (`2026-03-14`, or `2026-03-14 15:40:00`\n * when a time rides along), whatever envelope it arrived in;\n * - a `list` becomes an array whether the wire sent one or the plural\n * envelope `{items: [...]}`, each item loaded by the item descriptor;\n * - an `object` is loaded member by member, keeping any member the descriptor\n * does not name as it came;\n * - a `document` or `image` passes through verbatim: the pinned content model\n * is what `ResultField` reads, and its member names (`url`, `filename`) are\n * the ones a model would bind to anyway;\n * - the three native concepts the kind vocabulary cannot name (`native.Html`,\n * `native.Date`, `native.Composite`) pass through whole, for the escape\n * hatch to render - and a list of one is still a list, an array of whole\n * values, which is what the kernel renders when the brief delegates it;\n * - a scalar passes through.\n *\n * A top-level scalar's `contentKey` wrapper is NOT unwrapped: `ResultField`\n * unwraps it itself, and the brief names the wrapped path (`/result/text`), so\n * the model and the escape hatch read the same tree.\n */\nexport function payloadToState(field: RunField, payload: unknown): unknown {\n if (payload === undefined || payload === null) return payload;\n if (isNativeValueNode(field)) return payload;\n switch (field.kind) {\n case 'date': {\n const content = readDateContent(payload);\n return content ? formatDateContent(content) : payload;\n }\n case 'list': {\n const items = Array.isArray(payload)\n ? payload\n : isRecord(payload) && Array.isArray(payload.items)\n ? payload.items\n : undefined;\n if (!items) return payload;\n return items.map((item) => payloadToState(field.item, item));\n }\n case 'object': {\n if (!isRecord(payload)) return payload;\n const out: Record<string, unknown> = { ...payload };\n for (const child of field.fields) {\n if (hasOwnProp(payload, child.name)) {\n out[child.name] = payloadToState(child, payload[child.name]);\n }\n }\n return out;\n }\n case 'document':\n case 'image':\n case 'text':\n case 'prose':\n case 'number':\n case 'boolean':\n case 'enum':\n case 'unknown':\n return payload;\n default:\n return field satisfies never;\n }\n}\n","import type { Spec } from '@json-render/core';\nimport type { AppStyleId } from '../brand/styles';\nimport type { PagePlan } from '../generated/layout-design/types';\nimport type { Frame } from './frame-definitions';\n\n/**\n * A spec with its provenance - the shape every fixture takes, whoever produced\n * it, so a story renders any of them without knowing which it holds.\n *\n * A spec is a payload's twin: the one artifact no projection can produce. So\n * it follows the payload's rules - produced by a pass, committed with its\n * provenance - plus what a spec needs and a payload does not: WHO produced it,\n * on WHICH model, under WHAT prompt (its hash), and, when the run was given\n * one, the creative seed and the critic loop. The stories and the comparison\n * viewer are titled from this record and from nothing else, so a page is\n * never labelled with a role (\"authored\", \"generated\") but with what actually\n * made it.\n */\n\n/** How a spec came to be. */\nexport type Producer =\n /** The designer method, `methods/layout-design.mthds`, run on the hosted API. */\n | 'pipelex-method'\n /** A Claude Code subagent in a fresh context, given the method, the catalog data and the brief and nothing else. */\n | 'claude-code-subagent'\n /** The Claude Code session working in this repo, writing the spec by hand in TypeScript. */\n | 'claude-code-session';\n\nexport interface CriticLoop {\n /** The model that judged the screenshots. */\n model: string;\n /** How many critique-and-revise rounds ran. */\n rounds: number;\n}\n\nexport interface SpecFixture {\n /** `results.nested_result`. */\n pipeRef: string;\n producer: Producer;\n /** The model id: the one the method ran with, or the Claude Code model behind the agent. */\n model: string;\n /** The creative seed handed over with the brief, verbatim, when one was. */\n seed?: string;\n /** The critic loop the producer ran, when one did. */\n critic?: CriticLoop;\n /** The frame it was written for, when not a whole product page: `composer` or `result`. */\n frame?: Exclude<Frame, 'page'>;\n /** The style the brief carried, when it carried one. */\n style?: AppStyleId;\n /**\n * How many times the method's repair pass re-emitted it before it passed\n * the checks, when it needed any: the page as stored is the last pass's.\n */\n repairs?: number;\n /** The first twelve hex digits of the SHA-256 of the catalog prompt at the time. */\n promptHash: string;\n /** The day it was produced, `YYYY-MM-DD`. */\n date: string;\n /** The brief it was produced from, repo-relative. */\n brief: string;\n /** The JSONL patch lines, exactly as emitted, or as `specToJsonl` renders a hand-written spec. */\n jsonl: string;\n /** The compiled spec. */\n spec: Spec;\n /**\n * The planner's plan, when the producer was the designer method: the\n * intermediate the builder was handed, read from the run's working memory.\n * It is what a person reads to see why a page has the shape it has, and it\n * is the one stage a comparison between two runs can be made at. Absent for\n * a producer that plans nowhere the harness can read.\n */\n plan?: PagePlan;\n}\n\ntype Provenance = Pick<SpecFixture, 'producer' | 'model' | 'seed' | 'critic' | 'frame' | 'style'>;\n\n/**\n * The id a story and a screenshot are keyed by: producer, model, the frame and\n * the style it was written for, and the two procedures that change what a run\n * is. `pipelex-method--gpt-5.5--seeded`,\n * `pipelex-method--gpt-6.1-sol--composer--soft--seeded`.\n */\nexport function fixtureId(fixture: Provenance) {\n return [\n fixture.producer,\n fixture.model,\n fixture.frame ?? null,\n fixture.style ?? null,\n fixture.seed ? 'seeded' : null,\n fixture.critic ? 'critic' : null,\n ]\n .filter((part): part is string => part !== null)\n .join('--');\n}\n\nconst PRODUCER_LABEL: Record<Producer, string> = {\n 'pipelex-method': 'Pipelex method',\n 'claude-code-subagent': 'Claude Code subagent',\n 'claude-code-session': 'Claude Code session, by hand',\n};\n\n/**\n * The honest title: what made the page. `Pipelex method · gpt-5.5 · with a\n * seed`, never a role (\"authored\", \"generated\").\n */\nexport function fixtureLabel(fixture: Provenance & Pick<SpecFixture, 'repairs'>): string {\n const parts = [PRODUCER_LABEL[fixture.producer], fixture.model];\n if (fixture.frame) parts.push(`${fixture.frame} frame`);\n if (fixture.style) parts.push(`${fixture.style} style`);\n if (fixture.seed) parts.push('with a seed');\n if (fixture.repairs) parts.push(`repaired × ${fixture.repairs}`);\n if (fixture.critic) {\n parts.push(\n `${fixture.critic.model} critic × ${fixture.critic.rounds} round${fixture.critic.rounds === 1 ? '' : 's'}`,\n );\n }\n return parts.join(' · ');\n}\n\n/** The fixture a story asks for, or a loud failure: a story must never render a page it did not name. */\nexport function findFixture(fixtures: readonly SpecFixture[], pipeRef: string, id: string) {\n const found = fixtures.find(\n (fixture) => fixture.pipeRef === pipeRef && fixtureId(fixture) === id,\n );\n if (!found) {\n const known = fixtures\n .filter((fixture) => fixture.pipeRef === pipeRef)\n .map(fixtureId)\n .join(', ');\n throw new Error(`No spec fixture ${id} for ${pipeRef}. Known: ${known || 'none'}.`);\n }\n return found;\n}\n"]}
|