@ai-matrx/content-ir-react 0.16.1 → 0.17.1

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.
Files changed (43) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +1 -1
  3. package/dist/{component-resolution.types-DLO2w-0n.d.cts → component-resolution.types-DY4pGymy.d.cts} +1 -1
  4. package/dist/{component-resolution.types-DLO2w-0n.d.ts → component-resolution.types-DY4pGymy.d.ts} +1 -1
  5. package/dist/{component-resolution.types-C1MzCf2s.d.cts → component-resolution.types-DwKSF64x.d.cts} +1 -1
  6. package/dist/{component-resolution.types-C1MzCf2s.d.ts → component-resolution.types-DwKSF64x.d.ts} +1 -1
  7. package/dist/db-component.d.cts +1 -1
  8. package/dist/db-component.d.ts +1 -1
  9. package/dist/{directive-host-C4TcPpxX.d.cts → directive-host-BOML4BQ7.d.cts} +27 -1
  10. package/dist/{directive-host-C4TcPpxX.d.ts → directive-host-BOML4BQ7.d.ts} +27 -1
  11. package/dist/directives.cjs +101 -8
  12. package/dist/directives.cjs.map +1 -1
  13. package/dist/directives.d.cts +19 -3
  14. package/dist/directives.d.ts +19 -3
  15. package/dist/directives.js +101 -8
  16. package/dist/directives.js.map +1 -1
  17. package/dist/{host-types-a0XEr5b3.d.cts → host-types-CKu4ap5K.d.cts} +2 -2
  18. package/dist/{host-types-CEc86R-v.d.ts → host-types-CQ2oIzUy.d.ts} +2 -2
  19. package/dist/host.cjs.map +1 -1
  20. package/dist/host.d.cts +4 -4
  21. package/dist/host.d.ts +4 -4
  22. package/dist/host.js.map +1 -1
  23. package/dist/index.cjs +101 -8
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.d.cts +22 -6
  26. package/dist/index.d.ts +22 -6
  27. package/dist/index.js +101 -8
  28. package/dist/index.js.map +1 -1
  29. package/dist/react.cjs +99 -8
  30. package/dist/react.cjs.map +1 -1
  31. package/dist/react.d.cts +4 -4
  32. package/dist/react.d.ts +4 -4
  33. package/dist/react.js +99 -8
  34. package/dist/react.js.map +1 -1
  35. package/dist/resolver.d.cts +2 -2
  36. package/dist/resolver.d.ts +2 -2
  37. package/dist/{route-De9c5YgW.d.ts → route-D0f5H63n.d.ts} +29 -3
  38. package/dist/{route-YcoyR3Fj.d.cts → route-D2Yz3El4.d.cts} +29 -3
  39. package/dist/route.cjs.map +1 -1
  40. package/dist/route.d.cts +2 -2
  41. package/dist/route.d.ts +2 -2
  42. package/dist/route.js.map +1 -1
  43. package/package.json +3 -3
package/dist/route.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../route/kind-route.ts","../route/partial-kind-route.ts","../route/route-binding.ts"],"sourcesContent":["/**\n * THE KIND ROUTE — the render flip, as a pure block transform.\n *\n * A block whose `metadata.__ir` envelope resolved a REGISTERED kind is routed\n * to that kind's component: via the legacy-bridge facet (`legacyBlockType` +\n * `toLegacyServerData`) when the kind has one, so the block enters the host's\n * existing renderer as its real type with envelope-derived serverData;\n * otherwise via the component resolver. Blocks with no envelope, an\n * unregistered kind, or no bridge facet pass through UNTOUCHED — the strangler\n * seam.\n *\n * This is where a bare/fenced JSON flashcard_set — which a text detector could\n * only ever call \"code\" — becomes real flashcards, live while streaming.\n *\n * PORTABILITY. This function was matrx-frontend's `react/kind-route.ts` and is\n * the single most-copied thing in the system: every UI that renders a kind has\n * to make exactly these decisions in exactly this order, and a second\n * implementation of them is a guaranteed divergence. It takes its registries,\n * its platform, and its error sink as an {@link KindRouteEnv} argument rather\n * than importing them, so it is callable from a reducer, a stream accumulator,\n * a test, or a React render — in any app.\n *\n * Semantics: `matrx-frontend/features/content-ir/docs/SHAPE_SYSTEM.md`\n * (registry, dual gate, `kind_component` resolution, rulings R1 + R6).\n */\n\nimport {\n envelopeFromCompleteValue,\n isReservedDirectiveSlug,\n readEnvelope,\n readObjectKind,\n} from \"@ai-matrx/content-ir\";\nimport type { ComponentResolution } from \"../resolver/component-resolution.types\";\nimport type { IrRoutableBlock, KindRouteEnv } from \"../host/host-types\";\n\n/**\n * Runtime routing marker (the Shape System's verification hook): stamped on\n * `metadata.__ir_route` whenever a block routes AND the component resolver\n * produced the decision. `by` says which resolver tier answered (\"compiled\"\n * floor vs a warm `content_ir.kind_component` row) — the live proof of\n * registry-resolution vs hard-coded fallback. Metadata-only, non-breaking.\n */\nexport const IR_ROUTE_KEY = \"__ir_route\" as const;\n\n/**\n * The component key the R6 generic fallback routes to — the official renderer\n * for a KNOWN shape that nothing render-trusted claims. Hosts map this key to\n * their generic structured view (the package ships one: `GenericStructuredView`).\n */\nexport const GENERIC_STRUCTURED_COMPONENT_KEY = \"generic_structured\" as const;\n\n/**\n * The block type a DB-sourced (user-authored) kind component renders as.\n * FE-synthesized: produced ONLY here, never emitted upstream. A host that has\n * no sandbox for user components simply does not map this key — the block then\n * falls to that host's unknown-type handling, which is honest.\n */\nexport const DB_KIND_COMPONENT_KEY = \"db_kind_component\" as const;\n\n/**\n * THE DIRECTIVE TIER. A block whose root `__kind` is a reserved directive\n * slug (`directive_v…`) is typed to this block type and drawn by\n * `DirectiveRender` (`@ai-matrx/content-ir-react/directives`) — BEFORE the\n * component resolver is consulted. A directive is a kind whose display is the\n * directive card (the item inside it renders through the item's own kind —\n * THE DIRECTIVE⇄KIND SEAM), so no `kind_component` row exists or is needed,\n * and the \"unregistered\" / \"no-component\" floors must never claim one.\n * `\"matrx\"` is the block type matrx-frontend has dispatched directive fences\n * to since the envelope era; every host's dispatch table maps it to\n * `DirectiveRender`.\n */\nexport const DIRECTIVE_BLOCK_TYPE = \"matrx\" as const;\n\n/**\n * A DB row is render-trusted as a USER component when it is active, declares\n * `source='db'` (R1: db = web sandbox only), and actually carries a component\n * body. An active db-source row WITHOUT a body is a data defect — reported\n * loudly, and the route then falls through to the bundled behavior (never\n * un-render).\n */\nfunction isDbSourceResolution(\n resolution: ComponentResolution | null,\n): resolution is ComponentResolution {\n return (\n resolution !== null &&\n resolution.resolvedBy === \"db\" &&\n resolution.source === \"db\" &&\n resolution.isActive\n );\n}\n\n// SESSION LATCH ON A globalThis SLOT — never a module-level variable. With the\n// package built `splitting: false` in dual ESM/CJS and multiple subpath\n// entries, this module is duplicated into the root bundle and the `./route`\n// bundle, and CJS/ESM each instantiate their own graph — a module-level Set\n// would silently split the latch (the kit confirm-opener precedent). Never\n// \"clean this up\" into a module local.\nconst SOURCELESS_DB_ROW_SLOT = Symbol.for(\n \"ai-matrx.content-ir-react.sourceless-db-row-reports\",\n);\ntype SourcelessSlotHolder = typeof globalThis & {\n [SOURCELESS_DB_ROW_SLOT]?: Set<string>;\n};\nconst reportedSourcelessDbRows: Set<string> = ((globalThis as SourcelessSlotHolder)[\n SOURCELESS_DB_ROW_SLOT\n] ??= new Set<string>());\n\n/** Loud recovery: an active source='db' row with no component_source. */\nfunction reportDbRowWithoutSource(kind: string, env: KindRouteEnv): void {\n const message = `[content-ir] kind_component for \"${kind}\" declares source='db' + is_active but has NO component_source — data defect; falling through to bundled rendering.`;\n if (!reportedSourcelessDbRows.has(kind)) {\n reportedSourcelessDbRows.add(kind);\n console.error(message);\n }\n env.reportError({ source: \"content-ir\", message, raw: { kind } });\n}\n\n/** Test-only reset of the once-per-kind console latch. */\nexport function resetSourcelessDbRowReports(): void {\n reportedSourcelessDbRows.clear();\n}\n\n/**\n * The db-override flip (R6: db overrides bundled): an ACTIVE `source='db'` row\n * carrying a component body wins over BOTH the compiled bridge and any bundled\n * resolution. The block re-types to `db_kind_component`; the host re-resolves\n * the row and compiles/sandboxes it. Returns null when the flip does not apply.\n */\nfunction routeToDbComponent<T extends IrRoutableBlock>(\n block: T,\n kind: string,\n resolution: ComponentResolution | null,\n env: KindRouteEnv,\n): T | null {\n if (!isDbSourceResolution(resolution)) return null;\n // Gate on the FLAG, not body presence: a lazy host's warm list is\n // body-less (metadata only) and the body arrives per kind via the cold\n // fetch — the row still routes, and the renderer compiles the body once it\n // lands. A row whose flag says it truly has no body screams and falls\n // through, exactly as before.\n if (!resolution.hasComponentSource) {\n reportDbRowWithoutSource(kind, env);\n return null;\n }\n if (block.type === DB_KIND_COMPONENT_KEY) return block;\n return {\n ...block,\n type: DB_KIND_COMPONENT_KEY,\n // The compiled/sandboxed component reads the envelope, never the raw\n // region's annotation serverData (same poison rule as bridged kinds).\n serverData: undefined,\n metadata: withRouteMarker(block.metadata, resolution),\n };\n}\n\n/** Why a block landed on the generic viewer instead of a real renderer. */\nexport type GenericFallbackReason =\n /** No compiled bridge and no `content_ir.kind_component` row at all. */\n | \"no-component\"\n /** A component row exists but is held `is_active = false`. */\n | \"inactive\"\n /**\n * An ACTIVE component row exists and names `generic_structured` — i.e. the\n * fallback, registered under a component's name. This reads as coverage to\n * every count-the-rows check on the platform and is not: the reader still\n * gets a key/value dump. Kept as its own reason because the repair differs\n * (author a component AND retire the decoy row), and because a page that\n * silently marked itself `by: \"bundled\"` here is how 226 of 428 active\n * kinds came to be certified as renderable while rendering generically\n * (found 2026-08-23).\n */\n | \"generic-row\"\n /**\n * The envelope carries a kind-preserved RAW: the payload identified a\n * registered kind and its value FAILED a check — a schema violation, an\n * array-item kind mismatch, a duplicate key, a contradicted speculation.\n * The instance is BROKEN, not component-less — the repair is fixing the\n * payload or the schema, and the generic floor must acknowledge the kind and\n * surface the recorded problems.\n *\n * NOT this: a kind whose schema was never available (`kindState:\n * \"unverified\"`). Nothing checked that value, so calling it broken is a\n * false accusation — it routes to its component. The two were one state\n * until 2026-08-29 and conflating them was a platform-wide outage.\n */\n | \"broken-instance\"\n /**\n * The slug is not in the registry at all (typo, foreign emitter, a shape\n * not yet created). Routed anyway — Arman's 2026-08-29 ruling: a root\n * `__kind` key means the kind system owns the render, no exceptions. The\n * repair is creating/registering the shape (or fixing the slug).\n */\n | \"unregistered\";\n\nexport interface IrRouteMarker {\n by: ComponentResolution[\"resolvedBy\"] | \"generic\" | \"directive\";\n key: string;\n /**\n * Only on the generic fallback: the shape is NOT render-trusted, so the\n * viewer must say so out loud (R6 — never an error, never hidden content).\n */\n unverified?: true;\n reason?: GenericFallbackReason;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction isRouteMarker(value: unknown): value is IrRouteMarker {\n return (\n isRecord(value) &&\n typeof value.by === \"string\" &&\n typeof value.key === \"string\"\n );\n}\n\n/** Read the routing marker a block picked up at the seam (or null). */\nexport function readIrRouteMarker(\n metadata: Record<string, unknown> | null | undefined,\n): IrRouteMarker | null {\n const candidate = metadata?.[IR_ROUTE_KEY];\n return isRouteMarker(candidate) ? candidate : null;\n}\n\nfunction withRouteMarker(\n metadata: Record<string, unknown> | undefined,\n resolution: ComponentResolution,\n): Record<string, unknown> {\n return {\n ...metadata,\n [IR_ROUTE_KEY]: {\n by: resolution.resolvedBy,\n key: resolution.componentKey,\n } satisfies IrRouteMarker,\n };\n}\n\n/**\n * R6's sanctioned disposition for a shape the platform KNOWS (a kind\n * definition supplied its schema) but nothing render-trusted claims: the\n * generic structured viewer, carrying an honest \"unverified shape\" affordance\n * — never an error, never a raw code block, never hidden content.\n *\n * `serverData` is CLEARED for the same reason the resolver-only path clears\n * it: a raw region's annotation (`{ language: \"json\" }`) is not kind data, and\n * the generic viewer reads the envelope, not serverData.\n */\nfunction routeToGeneric<T extends IrRoutableBlock>(\n block: T,\n reason: GenericFallbackReason,\n): T {\n if (block.type === GENERIC_STRUCTURED_COMPONENT_KEY) return block;\n\n return {\n ...block,\n type: GENERIC_STRUCTURED_COMPONENT_KEY,\n serverData: undefined,\n metadata: {\n ...block.metadata,\n [IR_ROUTE_KEY]: {\n by: \"generic\",\n key: GENERIC_STRUCTURED_COMPONENT_KEY,\n unverified: true,\n reason,\n } satisfies IrRouteMarker,\n },\n };\n}\n\nexport interface KindRouteOptions {\n /**\n * Block types this host OWNS and the route must never re-type, however good\n * the envelope on them looks.\n *\n * matrx-frontend passes `[\"artifact\"]`: an artifact block has an identity, a\n * version, and a Canvas to open in, and since 2026-08-18 it carries\n * `metadata.__ir` so SELECTORS can read the envelope. That envelope is DATA\n * there, not a route — re-typing it to the bare kind component would strip\n * the artifact chrome and lose the door to the Canvas.\n */\n ownedTypes?: readonly string[];\n}\n\nexport function applyIrKindRoute<T extends IrRoutableBlock>(\n block: T,\n env: KindRouteEnv,\n options?: KindRouteOptions,\n): T {\n if (options?.ownedTypes?.includes(block.type)) return block;\n\n const envelope = readEnvelope(block.metadata);\n if (!envelope) return block;\n\n const kind = envelope.root.kind;\n if (!kind) return block; // raw / pending — the host's own rendering stands\n\n // An identified kind whose SCHEMA is still cold-fetching (pending_schema) has\n // no compliant value yet — routing now would hand a component early scalars\n // at best. The host's loading layer owns this window; the parser upgrades in\n // place the moment the schema lands, and end() converts a lost race to a\n // kind-preserving raw — both of which route normally.\n if (envelope.root.kindState === \"pending_schema\") return block;\n\n // ── THE DIRECTIVE TIER ────────────────────────────────────────────────────\n // A reserved slug is a directive; the directive tier owns its display, in\n // every kind state (a kind-preserved raw is still a directive the card can\n // name and the reader can apply — the server re-validates on confirm).\n if (isReservedDirectiveSlug(kind)) {\n if (block.type === DIRECTIVE_BLOCK_TYPE) return block;\n return {\n ...block,\n type: DIRECTIVE_BLOCK_TYPE,\n serverData: undefined,\n metadata: {\n ...(block.metadata ?? {}),\n [IR_ROUTE_KEY]: { by: \"directive\", key: DIRECTIVE_BLOCK_TYPE } satisfies IrRouteMarker,\n },\n };\n }\n\n const def = env.kinds.getDefinition(kind);\n const resolution = env.components.resolve(kind, env.platform, \"output\");\n\n // 🚨 THE COLD-VERDICT RULE (Arman, 2026-08-31). A registry that has not\n // loaded yet must never be allowed to publish a NEGATIVE verdict. Every\n // \"this shape isn't registered\" / \"no component\" answer below is a durable,\n // user-visible claim written into the block's metadata — and on the first\n // paint of a fresh tab the resolver has fetched nothing, so those claims\n // were being produced by a registry whose honest answer is \"I haven't\n // looked\". The reader saw a key/value dump captioned \"this shape isn't\n // registered on this platform\" for a shape that was registered, active, and\n // had a component the whole time.\n //\n // Holding the block (exactly as `pending_schema` does) hands the window to\n // the host's loading layer; `useEnsureKindRenderable` fetches, the per-kind\n // repaint fires, and this function re-runs with a settled registry. A\n // POSITIVE answer is never suppressed — if the compiled floor or an already\n // ingested row can name a component, the paths below run immediately.\n const componentsSettled = env.components.hasSettled?.() ?? true;\n if (!componentsSettled && !resolution && !def) return block;\n\n // A kind-preserved `raw` is a BROKEN instance: something CHECKED this value\n // and it failed — a schema violation, an array-item kind mismatch, a\n // duplicate key, a contradicted speculation. No component (bridge or db) may\n // claim a non-compliant value; the generic floor acknowledges the kind and\n // the envelope's recorded problems (residue notices, the raw_fallback\n // reason) are the host's to show. An UNREGISTERED slug routes here too —\n // Arman's 2026-08-29 ruling: a root `__kind` key means the kind system owns\n // the render, NO exceptions. Repaint upgrades it the moment the registries\n // learn more.\n //\n // 🚨 `unverified` DELIBERATELY DOES NOT MATCH HERE, AND MUST NEVER BE ADDED.\n // That state means no schema was ever available, so nothing was checked —\n // the value is intact and quite possibly perfect. It falls through to the\n // component paths below exactly as it did before 2026-08-28, when this gate\n // read the old undifferentiated `raw` and took ~221 live kinds' components\n // away overnight: every kind whose schema cannot be reconstructed (nested\n // objects, arrays of children, loose fields) degrades this way, and each one\n // rendered as a key/value dump while its purpose-built component sat one\n // line below, never asked for. Widening this condition re-opens that outage.\n // See `IrKindState` in @ai-matrx/content-ir.\n if (envelope.root.kindState === \"raw\") {\n return routeToGeneric(\n block,\n def || resolution ? \"broken-instance\" : \"unregistered\",\n );\n }\n\n // ── DB user-component path — db overrides bundled (ruling R6) ─────────────\n // Checked FIRST so a user's registered component actually renders; a\n // defective row (no source) screams and falls through to bundled behavior —\n // never un-renders.\n const dbRouted = routeToDbComponent(block, kind, resolution, env);\n if (dbRouted) return dbRouted;\n\n // ── Compiled-bridge path — trusted at bootstrap (ruling R6) ───────────────\n // A kind carrying a legacyBlockType facet ALWAYS routes: the host's existing\n // behavior for every registered kind, and the production floor a DB row can\n // refine (the marker records which tier resolved) but never un-render.\n if (def?.legacyBlockType) {\n // A block ALREADY emitted as the legacy type carrying its own serverData is\n // authoritative — the server typed it AND provided the component's data.\n if (block.type === def.legacyBlockType && block.serverData) return block;\n\n // ROUTING a raw region (e.g. \"code\" → \"flashcards\"): the envelope is the\n // single source of truth. The block's own serverData here is NOT kind data\n // — it is the raw region's annotation (`{ language: \"json\" }`). Preferring\n // that junk handed the legacy component `{ language: \"json\" }` instead of\n // cards/questions/slides — the 2026-07-04 \"No flashcards available yet\"\n // bug — so it is REPLACED (bridge output) or CLEARED (bridgeless kinds\n // parse `content` themselves), never forwarded.\n const serverData = def.toLegacyServerData?.(envelope);\n\n if (block.type === def.legacyBlockType && serverData === undefined) {\n return block; // nothing to change — keep reference stability\n }\n\n return {\n ...block,\n type: def.legacyBlockType,\n serverData,\n ...(resolution\n ? { metadata: withRouteMarker(block.metadata, resolution) }\n : null),\n };\n }\n\n // ── Resolver-only path (no compiled bridge): the registry decides ─────────\n // R6: only an ACTIVE resolution is render-trusted. An inactive row means\n // \"held\", not \"route it anyway\".\n if (resolution?.isActive) {\n // A row naming the fallback is NOT a resolution. Routing it as one stamped\n // `by: \"bundled\"` on the block and told every reader the shape had a\n // renderer — the platform's own generic viewer, wearing a component's\n // clothes. It goes to the honest generic path with its own reason instead.\n if (resolution.componentKey === GENERIC_STRUCTURED_COMPONENT_KEY) {\n return routeToGeneric(block, \"generic-row\");\n }\n if (block.type === resolution.componentKey) return block;\n\n return {\n ...block,\n type: resolution.componentKey,\n // No compiled bridge exists — the routed component parses `content`\n // itself; the raw region's annotation serverData is CLEARED.\n serverData: undefined,\n metadata: withRouteMarker(block.metadata, resolution),\n };\n }\n\n // ── R6 generic fallback: a KNOWN shape that nothing render-trusted claims ─\n // `def` exists ⇒ a kind definition supplied this kind's schema: the platform\n // knows the shape. It has no compiled bridge, and either no `kind_component`\n // row at all (`no-component`) or one held inactive (`inactive`). R6 sends\n // exactly this case to the generic structured viewer with an \"unverified\n // shape\" affordance — the disposition that retires permanently-red\n // \"no-component root\" kinds without pretending they have renderers.\n if (def) {\n return routeToGeneric(block, resolution ? \"inactive\" : \"no-component\");\n }\n\n // A kind slug the platform has NO definition for (a typo, a foreign\n // emitter, a not-yet-created shape). 🚨 Arman's ruling, 2026-08-29: a root\n // `__kind` key means the kind system owns the render — NO exceptions. The\n // old strangler carve-out (\"not ours to claim\", teaching content stayed a\n // raw code block) is retired: an unregistered kind renders through the\n // generic floor with `reason: \"unregistered\"`, so the reader always sees\n // the payload acknowledged AS a kind instance with what is known about it.\n // A repaint hook upgrades this block the moment the registries learn the\n // kind.\n return routeToGeneric(block, \"unregistered\");\n}\n\n/**\n * Rehydration route for STRUCTURED persisted artifacts.\n *\n * A materialized kind artifact stores its zero-loss value object (carrying\n * `__kind`) alongside its row. Given that stored value, derive the registered\n * kind's legacy `serverData` WITHOUT re-parsing any text: the value wraps into\n * a complete envelope and runs through the same `toLegacyServerData` bridge the\n * live stream uses. Returns null for non-objects, unregistered kinds, or kinds\n * without a legacy bridge — callers fall back to their string-payload path.\n */\nexport function kindServerDataFromStoredValue(\n value: unknown,\n env: Pick<KindRouteEnv, \"kinds\">,\n): Record<string, unknown> | null {\n if (!isRecord(value)) return null;\n const kind = readObjectKind(value);\n if (!kind) return null;\n\n const def = env.kinds.getDefinition(kind);\n if (!def?.toLegacyServerData) return null;\n\n return def.toLegacyServerData(envelopeFromCompleteValue(value, kind)) ?? null;\n}\n","/**\n * Routing the PROVISIONAL half of the streaming partial-kinds contract.\n *\n * Cross-repo system-of-record (read it before changing anything here):\n * `common-docs/systems/content-ir-system/STREAMING_PARTIAL_KINDS.md` §8.\n * The reader/validator half lives in `@ai-matrx/content-ir` (`wire/partial-kind`);\n * the wire gate runs in each host's stream ingest.\n *\n * WHAT THIS DOES\n * --------------\n * While a structured region streams, the server announces what it thinks the\n * region IS and what has arrived so far (`metadata.__ir_partial`). This module\n * turns that provisional event into a routed block that renders through the\n * EXACT SAME component the final value renders in — which is the entire point:\n * a bespoke skeleton renderer would be a second render path and is banned.\n *\n * HOW, without touching the verified channel\n * ------------------------------------------\n * `root` is deliberately `IrStructuredNode`-shaped, so the event wraps into a\n * `CanonicalBlockIR` and every existing reader — the compiled bridge, the\n * component resolver, the db-component flip, the generic viewer — works\n * unchanged. That provisional envelope is placed on a RENDER-LOCAL COPY of the\n * block's metadata under `__ir`, never on the wire and never in host state. The\n * block also carries `__ir_provisional: true` so any downstream reader can tell\n * a provisional render from a verified one.\n *\n * THE POSTURE: WITHHOLD BY DEFAULT, OPT IN PER KIND\n * -------------------------------------------------\n * A provisional value MAY be missing required fields — that is what the\n * `partial_unvalidated` notice declares — and §8 of the contract requires that\n * a component which throws on an absent field is not routed one. Rather than\n * audit every component, the default is WITHHOLD: nothing changes and the block\n * keeps its loading skeleton. A kind opts in with `partialReady: true` on its\n * registry definition. If an opted-in component throws anyway,\n * `ProvisionalKindBoundary` screams and calls `markKindPartialUnsafe`, which\n * drops that kind back to withhold for the rest of the session — loud recovery,\n * never a broken surface.\n *\n * TERMINALS\n * ---------\n * `superseded` and `retracted` produce NO provisional render, so the swap to\n * the final value happens in the same frame the terminal arrives — never a\n * flicker through an empty state. Both are explicit EVENTS: the terminal is\n * never inferred from the arrival of `__ir`, because a completed block often\n * has no `__ir` at all (unregistered kind, schema drift, cold catalog) and\n * inferring it would leave the skeleton up forever in exactly those cases.\n */\n\nimport {\n envelopeFromCompleteValue,\n IR_ENVELOPE_KEY,\n IR_PARTIAL_KEY,\n IR_VERSION,\n isProvisionalKind,\n readEnvelope,\n readObjectKind,\n readPartialKindEvent,\n} from \"@ai-matrx/content-ir\";\nimport type { CanonicalBlockIR, PartialKindEvent } from \"@ai-matrx/content-ir\";\nimport type { IrRoutableBlock, KindRouteEnv } from \"../host/host-types\";\nimport { applyIrKindRoute, type KindRouteOptions } from \"./kind-route\";\n\n/**\n * Marker stamped on a render-local block whose `__ir` is PROVISIONAL. Never\n * emitted by a producer, never persisted, never on the wire.\n */\nexport const IR_PROVISIONAL_KEY = \"__ir_provisional\" as const;\n\n/** True when this block's metadata carries a provisional (not verified) envelope. */\nexport function isProvisionalBlock(\n metadata: Record<string, unknown> | null | undefined,\n): boolean {\n return metadata?.[IR_PROVISIONAL_KEY] === true;\n}\n\n/** Wrap a validated `partial` event into the envelope shape every IR reader consumes. */\nexport function envelopeFromPartialKind(\n event: PartialKindEvent,\n): CanonicalBlockIR {\n return {\n v: IR_VERSION,\n // The partial channel is only ever produced by the Python detector; the\n // envelope's `engine` union has no third member and inventing one would\n // break every existing reader.\n engine: \"py-block-detector\",\n fingerprint: event.fingerprint,\n root: event.root,\n };\n}\n\n/**\n * Kinds whose component threw while rendering a provisional value. Session-\n * scoped: the kind falls back to withhold (its loading skeleton) until a\n * reload, so one bad component cannot keep re-throwing on every block.\n */\n// SESSION LATCH ON A globalThis SLOT — never a module-level variable. This\n// latch is WRITTEN from the `./react` bundle (ProvisionalKindBoundary calls\n// markKindPartialUnsafe) and READ from the `./route` bundle\n// (isPartialReadyKind); with `splitting: false` dual ESM/CJS output those are\n// different module instantiations, and a module-level Set would silently split\n// the writer from the reader (the kit confirm-opener precedent). Never \"clean\n// this up\" into a module local.\nconst PARTIAL_UNSAFE_SLOT = Symbol.for(\n \"ai-matrx.content-ir-react.partial-unsafe-kinds\",\n);\ntype PartialUnsafeSlotHolder = typeof globalThis & {\n [PARTIAL_UNSAFE_SLOT]?: Set<string>;\n};\nconst partialUnsafeKinds: Set<string> = ((globalThis as PartialUnsafeSlotHolder)[\n PARTIAL_UNSAFE_SLOT\n] ??= new Set<string>());\n\n/** Loud recovery hook — called by ProvisionalKindBoundary when a render throws. */\nexport function markKindPartialUnsafe(kind: string): void {\n partialUnsafeKinds.add(kind);\n}\n\n/** Test-only reset of the session latch. */\nexport function resetPartialUnsafeKinds(): void {\n partialUnsafeKinds.clear();\n}\n\n/**\n * Has this kind opted in to being handed a provisional value? Withhold is the\n * default; see the module doc.\n */\nexport function isPartialReadyKind(\n kind: string,\n env: Pick<KindRouteEnv, \"kinds\">,\n): boolean {\n if (!kind || partialUnsafeKinds.has(kind)) return false;\n return env.kinds.getDefinition(kind)?.partialReady === true;\n}\n\nexport interface PartialRenderOptions extends KindRouteOptions {\n /**\n * Is the STREAM still running? Message-wide, deliberately — not this block's\n * own completion.\n *\n * 🚨 THE ANTI-STUCK-SKELETON BACKSTOP. Law 1 of the contract says every\n * partial ends in exactly one terminal, and that law is the ONLY thing\n * standing between a user and a \"Still arriving\" skeleton that never\n * resolves. It is a producer guarantee with at least three ways to not fire:\n * the drain skips a block missing from the final block list, the emitter\n * early-returns once the stream ended or was cancelled (so a client abort\n * drops every retraction), and a flush failure is swallowed so it never kills\n * a run.\n *\n * Once the stream is over, no terminal can ever arrive, so a still-open\n * provisional is stuck by definition — drop it and let the block's own\n * content and `__ir` be the truth. Correct to be message-wide: a terminal for\n * THIS block may still be in flight while the block itself looks finished.\n *\n * `undefined` reads as active, so a caller that does not thread stream state\n * keeps live rendering rather than silently losing it.\n */\n streamActive?: boolean;\n}\n\n/**\n * The ANNOUNCED-but-not-yet-renderable state: the server has said what this\n * region is, and the region cannot render its real component yet.\n *\n * WHY THIS EXISTS SEPARATELY FROM THE VERIFIED CHANNEL. On a chat stream the\n * host's own accumulator fills `__ir` in as it parses. A WORKFLOW run's lane\n * does not: when the server opens the block scope it marks the text channel\n * `block_shadowed` and the lane stops feeding its accumulator, precisely so one\n * region is never rendered twice under two sets of block ids\n * (STREAMING_PARTIAL_KINDS.md §7b rule 4). So on a run page there is NO\n * streaming `__ir` — the ONLY thing that knows what the region is, is the\n * partial channel. Without this, a workflow node's structured answer fell\n * through to the raw-text renderer: a generic loader, then raw JSON\n * accumulating, then a swap at the end.\n *\n * Returns the provisional envelope to feed the kind's loading component, or\n * null when there is nothing announced (no event, a terminal, a dead stream).\n * Deliberately independent of `partialReady`: withholding a VALUE from a\n * component that might throw on it is a real decision, but withholding the\n * kind's own loading state is not — a skeleton cannot throw, and the reader\n * seeing what is coming is the whole point.\n */\nexport function resolveAnnouncedKindLoading(\n block: { metadata?: Record<string, unknown> },\n options?: Pick<PartialRenderOptions, \"streamActive\">,\n): { kind: string; envelope: CanonicalBlockIR } | null {\n // Same anti-stuck-skeleton backstop as resolveProvisionalKindRender: once the\n // stream is over no terminal can arrive, so a still-open announcement is\n // stuck by definition and must not hold a loader on screen forever.\n if (options?.streamActive === false) return null;\n\n const event = readPartialKindEvent(block.metadata);\n if (!isProvisionalKind(event)) return null;\n const kind = event.root.kind;\n if (!kind) return null;\n\n // A region that already VERIFIED is the truth; never cover it with a loader.\n const verified = readEnvelope(block.metadata);\n if (verified && verified.root.status === \"complete\") return null;\n\n return { kind, envelope: envelopeFromPartialKind(event) };\n}\n\nexport interface ProvisionalKindRender<T> {\n /** The routed block — same type/serverData shape the final value produces. */\n block: T;\n /** The announced (speculative) kind. */\n kind: string;\n /** Per-block ordering key, for diagnostics. */\n seq: number;\n /** The provisional envelope — feeds the loading skeleton used as the throw fallback. */\n envelope: CanonicalBlockIR;\n}\n\nexport interface SupersededKindRender<T> {\n /** The completed block routed through the announced kind's normal component. */\n block: T;\n /** The kind the producer announced and then confirmed at terminal. */\n kind: string;\n /** Per-block ordering key, for diagnostics. */\n seq: number;\n /** Render-local complete envelope reconstructed from the block's own content. */\n envelope: CanonicalBlockIR;\n}\n\nfunction parseCompletedJsonObject(content: string): Record<string, unknown> | null {\n let source = content.trim();\n const fenced = source.match(/^```(?:json)?\\s*\\n?([\\s\\S]*?)\\n?```$/i);\n if (fenced?.[1]) source = fenced[1].trim();\n\n try {\n const value = JSON.parse(source) as unknown;\n return typeof value === \"object\" && value !== null && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : null;\n } catch {\n return null;\n }\n}\n\n/**\n * Finish the partial-kind handoff for a `superseded` terminal.\n *\n * A workflow run deliberately shadows its text channel while server-built\n * render blocks stream, so the browser never builds a verified `__ir`\n * envelope for that region. The terminal still proves that the announced kind\n * completed, and the block's own content is now closed JSON. Reconstruct a\n * render-local COMPLETE envelope from that content and route it through the\n * same component path as persisted/reloaded data. `retracted` is never\n * eligible, and a malformed or mismatched payload stays on the host's honest\n * raw fallback.\n */\nexport function resolveSupersededKindRender<\n T extends IrRoutableBlock & {\n content: string;\n metadata?: Record<string, unknown>;\n },\n>(\n block: T,\n env: KindRouteEnv,\n options?: KindRouteOptions,\n): SupersededKindRender<T> | null {\n const event = readPartialKindEvent(block.metadata);\n if (event?.state !== \"superseded\") return null;\n\n // A verified envelope is already the higher-fidelity truth and the ordinary\n // kind route owns it.\n if (readEnvelope(block.metadata)?.root.status === \"complete\") return null;\n\n const value = parseCompletedJsonObject(block.content);\n if (!value || readObjectKind(value) !== event.kind) return null;\n\n const { [IR_PARTIAL_KEY]: _partial, ...rest } = block.metadata ?? {};\n void _partial;\n const envelope = envelopeFromCompleteValue(value, event.kind);\n const terminalBlock = {\n ...block,\n // A code/json block's serverData is an annotation, not kind data.\n serverData: undefined,\n metadata: { ...rest, [IR_ENVELOPE_KEY]: envelope },\n } as T;\n const routed = applyIrKindRoute(terminalBlock, env, options);\n if (routed === terminalBlock) return null;\n\n return { block: routed, kind: event.kind, seq: event.seq, envelope };\n}\n\n/**\n * Resolve a block's provisional render, or null when there is nothing to show\n * provisionally (no event, a terminal event, a withheld kind, a kind nothing\n * can route, or a verified envelope that already won).\n *\n * Pure: no React, no host state, no side effects beyond the registry reads.\n */\nexport function resolveProvisionalKindRender<\n T extends IrRoutableBlock & { metadata?: Record<string, unknown> },\n>(\n block: T,\n env: KindRouteEnv,\n options?: PartialRenderOptions,\n): ProvisionalKindRender<T> | null {\n if (options?.streamActive === false) return null;\n\n const event = readPartialKindEvent(block.metadata);\n // Terminal (superseded / retracted) → no provisional render, in this frame.\n if (!isProvisionalKind(event)) return null;\n\n const kind = event.root.kind;\n if (!isPartialReadyKind(kind, env)) return null;\n\n // A verified envelope that has already completed is the truth — a late or\n // duplicated partial must never displace it.\n const verified = readEnvelope(block.metadata);\n if (verified && verified.root.status === \"complete\") return null;\n\n const { [IR_PARTIAL_KEY]: _partial, ...rest } = block.metadata ?? {};\n void _partial;\n\n const envelope = envelopeFromPartialKind(event);\n\n const provisionalBlock = {\n ...block,\n // The raw region annotation (`{ language: \"json\" }`) is not kind data —\n // same poison rule the verified route follows.\n serverData: undefined,\n metadata: {\n ...rest,\n [IR_ENVELOPE_KEY]: envelope,\n [IR_PROVISIONAL_KEY]: true,\n },\n } as T;\n\n const routed = applyIrKindRoute(provisionalBlock, env, options);\n // Nothing claimed it (unknown kind, no component) — `applyIrKindRoute`\n // returns the SAME reference. Withhold rather than render raw partial JSON.\n if (routed === provisionalBlock) return null;\n // A bridged kind whose bridge DECLINED this value (too thin to render — a\n // quiz with no answerable question yet) routed on type alone, which would\n // hand the component the partial JSON text to parse. Withhold: the loading\n // skeleton stays up for this frame and the next `seq` tries again.\n if (\n env.kinds.getDefinition(kind)?.toLegacyServerData &&\n !(routed as { serverData?: unknown }).serverData\n ) {\n return null;\n }\n\n return { block: routed, kind, seq: event.seq, envelope };\n}\n","/**\n * THE BOUND ROUTE — the pure route functions with a host's env and owned\n * types partially applied, built ONCE in a host wiring module.\n *\n * Every host was writing the same wrapper file by hand: one function per pure\n * route, each forwarding `matrx…Env` + `ownedTypes` (matrx-frontend carried\n * two such modules; the dashboard a third). Per C22 that repeated delta is\n * package-provided: a host module now only INJECTS (its env, its owned block\n * types) and re-exports what this factory returns.\n *\n * The functions are the exact pure routes — read `kind-route.ts` /\n * `partial-kind-route.ts` for semantics; nothing behavioral lives here.\n */\n\nimport type { IrRoutableBlock, KindRouteEnv } from \"../host/host-types\";\nimport {\n applyIrKindRoute,\n kindServerDataFromStoredValue,\n type KindRouteOptions,\n} from \"./kind-route\";\nimport {\n isPartialReadyKind,\n resolveProvisionalKindRender,\n resolveSupersededKindRender,\n type PartialRenderOptions,\n type ProvisionalKindRender,\n type SupersededKindRender,\n} from \"./partial-kind-route\";\n\nexport interface KindRouteBinding {\n /** Route one block through the bound registries. */\n applyIrKindRoute<T extends IrRoutableBlock>(block: T): T;\n /**\n * Rehydration route for STRUCTURED persisted artifacts: given a stored\n * zero-loss value object, derive the registered kind's legacy `serverData`\n * with no re-parse. Null for non-objects, unregistered kinds, or kinds\n * without a legacy bridge.\n */\n kindServerDataFromStoredValue(value: unknown): Record<string, unknown> | null;\n /** Has this kind opted in to being handed a provisional value? */\n isPartialReadyKind(kind: string): boolean;\n /**\n * Resolve a block's provisional render, or null when there is nothing to\n * show provisionally (no event, a terminal event, a withheld kind, a kind\n * nothing can route, or a verified envelope that already won).\n */\n resolveProvisionalKindRender<\n T extends IrRoutableBlock & { metadata?: Record<string, unknown> },\n >(\n block: T,\n options?: Pick<PartialRenderOptions, \"streamActive\">,\n ): ProvisionalKindRender<T> | null;\n /**\n * Route a completed workflow block whose `superseded` terminal confirms the\n * kind but whose shadowed lane never built a verified envelope.\n */\n resolveSupersededKindRender<\n T extends IrRoutableBlock & {\n content: string;\n metadata?: Record<string, unknown>;\n },\n >(block: T): SupersededKindRender<T> | null;\n}\n\n/** Bind the pure routes to one host's env + owned block types. */\nexport function createKindRouteBinding(\n env: KindRouteEnv,\n options?: KindRouteOptions,\n): KindRouteBinding {\n const ownedTypes = options?.ownedTypes;\n return {\n applyIrKindRoute: (block) =>\n applyIrKindRoute(block, env, ownedTypes ? { ownedTypes } : undefined),\n kindServerDataFromStoredValue: (value) =>\n kindServerDataFromStoredValue(value, env),\n isPartialReadyKind: (kind) => isPartialReadyKind(kind, env),\n resolveProvisionalKindRender: (block, streamOptions) =>\n resolveProvisionalKindRender(block, env, {\n ...streamOptions,\n ...(ownedTypes ? { ownedTypes } : null),\n }),\n resolveSupersededKindRender: (block) =>\n resolveSupersededKindRender(\n block,\n env,\n ownedTypes ? { ownedTypes } : undefined,\n ),\n };\n}\n"],"mappings":";AA0BA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAWA,IAAM,eAAe;AAOrB,IAAM,mCAAmC;AAQzC,IAAM,wBAAwB;AAc9B,IAAM,uBAAuB;AASpC,SAAS,qBACP,YACmC;AACnC,SACE,eAAe,QACf,WA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A,IAGH,YAAY;AAAA,IACZ,UAAU;AAAA,MACR,GAAG;AAAA,MACH,CAAC,eAAe,GAAG;AAAA,MACnB,CAAC,kBAAkB,GAAG;AAAA,IACxB;AAAA,EACF;AAEA,QAAM,SAAS,iBAAiB,kBAAkB,KAAK,OAAO;AAG9D,MAAI,WAAW,iBAAkB,QAAO;AAKxC,MACE,IAAI,MAAM,cAAc,IAAI,GAAG,sBAC/B,CAAE,OAAoC,YACtC;AACA,WAAO;AAAA,EACT;AAEA,SAAO,EAAE,OAAO,QAAQ,MAAM,KAAK,MAAM,KAAK,SAAS;AACzD;;;AC1RO,SAAS,uBACd,KACA,SACkB;AAClB,QAAM,aAAa,SAAS;AAC5B,SAAO;AAAA,IACL,kBAAkB,CAAC,UACjB,iBAAiB,OAAO,KAAK,aAAa,EAAE,WAAW,IAAI,MAAS;AAAA,IACtE,+BAA+B,CAAC,UAC9B,8BAA8B,OAAO,GAAG;AAAA,IAC1C,oBAAoB,CAAC,SAAS,mBAAmB,MAAM,GAAG;AAAA,IAC1D,8BAA8B,CAAC,OAAO,kBACpC,6BAA6B,OAAO,KAAK;AAAA,MACvC,GAAG;AAAA,MACH,GAAI,aAAa,EAAE,WAAW,IAAI;AAAA,IACpC,CAAC;AAAA,IACH,6BAA6B,CAAC,UAC5B;AAAA,MACE;AAAA,MACA;AAAA,MACA,aAAa,EAAE,WAAW,IAAI;AAAA,IAChC;AAAA,EACJ;AACF;","names":["envelopeFromCompleteValue","readEnvelope","readObjectKind","readEnvelope","readObjectKind","envelopeFromCompleteValue"]}
1
+ {"version":3,"sources":["../route/kind-route.ts","../route/partial-kind-route.ts","../route/route-binding.ts"],"sourcesContent":["/**\n * THE KIND ROUTE — the render flip, as a pure block transform.\n *\n * A block whose `metadata.__ir` envelope resolved a REGISTERED kind is routed\n * to that kind's component: via the legacy-bridge facet (`legacyBlockType` +\n * `toLegacyServerData`) when the kind has one, so the block enters the host's\n * existing renderer as its real type with envelope-derived serverData;\n * otherwise via the component resolver. Blocks with no envelope, an\n * unregistered kind, or no bridge facet pass through UNTOUCHED — the strangler\n * seam.\n *\n * This is where a bare/fenced JSON flashcard_set — which a text detector could\n * only ever call \"code\" — becomes real flashcards, live while streaming.\n *\n * PORTABILITY. This function was matrx-frontend's `react/kind-route.ts` and is\n * the single most-copied thing in the system: every UI that renders a kind has\n * to make exactly these decisions in exactly this order, and a second\n * implementation of them is a guaranteed divergence. It takes its registries,\n * its platform, and its error sink as an {@link KindRouteEnv} argument rather\n * than importing them, so it is callable from a reducer, a stream accumulator,\n * a test, or a React render — in any app.\n *\n * Semantics: `matrx-frontend/features/content-ir/docs/SHAPE_SYSTEM.md`\n * (registry, dual gate, `kind_component` resolution, rulings R1 + R6).\n */\n\nimport {\n envelopeFromCompleteValue,\n isReservedDirectiveSlug,\n readEnvelope,\n readObjectKind,\n} from \"@ai-matrx/content-ir\";\nimport type { ComponentResolution } from \"../resolver/component-resolution.types\";\nimport type { IrRoutableBlock, KindRouteEnv } from \"../host/host-types\";\n\n/**\n * Runtime routing marker (the Shape System's verification hook): stamped on\n * `metadata.__ir_route` whenever a block routes AND the component resolver\n * produced the decision. `by` says which resolver tier answered (\"compiled\"\n * floor vs a warm `content_ir.kind_component` row) — the live proof of\n * registry-resolution vs hard-coded fallback. Metadata-only, non-breaking.\n */\nexport const IR_ROUTE_KEY = \"__ir_route\" as const;\n\n/**\n * The component key the R6 generic fallback routes to — the official renderer\n * for a KNOWN shape that nothing render-trusted claims. Hosts map this key to\n * their generic structured view (the package ships one: `GenericStructuredView`).\n */\nexport const GENERIC_STRUCTURED_COMPONENT_KEY = \"generic_structured\" as const;\n\n/**\n * The block type a DB-sourced (user-authored) kind component renders as.\n * FE-synthesized: produced ONLY here, never emitted upstream. A host that has\n * no sandbox for user components simply does not map this key — the block then\n * falls to that host's unknown-type handling, which is honest.\n */\nexport const DB_KIND_COMPONENT_KEY = \"db_kind_component\" as const;\n\n/**\n * THE DIRECTIVE TIER. A block whose root `__kind` is a reserved directive\n * slug (`directive_v…`) is typed to this block type and drawn by\n * `DirectiveRender` (`@ai-matrx/content-ir-react/directives`) — BEFORE the\n * component resolver is consulted. A directive is a kind whose display is the\n * directive card (the item inside it renders through the item's own kind —\n * THE DIRECTIVE⇄KIND SEAM), so no `kind_component` row exists or is needed,\n * and the \"unregistered\" / \"no-component\" floors must never claim one.\n * `\"matrx\"` is the block type matrx-frontend has dispatched directive fences\n * to since the envelope era; every host's dispatch table maps it to\n * `DirectiveRender`.\n */\nexport const DIRECTIVE_BLOCK_TYPE = \"matrx\" as const;\n\n/**\n * A DB row is render-trusted as a USER component when it is active, declares\n * `source='db'` (R1: db = web sandbox only), and actually carries a component\n * body. An active db-source row WITHOUT a body is a data defect — reported\n * loudly, and the route then falls through to the bundled behavior (never\n * un-render).\n */\nfunction isDbSourceResolution(\n resolution: ComponentResolution | null,\n): resolution is ComponentResolution {\n return (\n resolution !== null &&\n resolution.resolvedBy === \"db\" &&\n resolution.source === \"db\" &&\n resolution.isActive\n );\n}\n\n// SESSION LATCH ON A globalThis SLOT — never a module-level variable. With the\n// package built `splitting: false` in dual ESM/CJS and multiple subpath\n// entries, this module is duplicated into the root bundle and the `./route`\n// bundle, and CJS/ESM each instantiate their own graph — a module-level Set\n// would silently split the latch (the kit confirm-opener precedent). Never\n// \"clean this up\" into a module local.\nconst SOURCELESS_DB_ROW_SLOT = Symbol.for(\n \"ai-matrx.content-ir-react.sourceless-db-row-reports\",\n);\ntype SourcelessSlotHolder = typeof globalThis & {\n [SOURCELESS_DB_ROW_SLOT]?: Set<string>;\n};\nconst reportedSourcelessDbRows: Set<string> = ((globalThis as SourcelessSlotHolder)[\n SOURCELESS_DB_ROW_SLOT\n] ??= new Set<string>());\n\n/** Loud recovery: an active source='db' row with no component_source. */\nfunction reportDbRowWithoutSource(kind: string, env: KindRouteEnv): void {\n const message = `[content-ir] kind_component for \"${kind}\" declares source='db' + is_active but has NO component_source — data defect; falling through to bundled rendering.`;\n if (!reportedSourcelessDbRows.has(kind)) {\n reportedSourcelessDbRows.add(kind);\n console.error(message);\n }\n env.reportError({ source: \"content-ir\", message, raw: { kind } });\n}\n\n/** Test-only reset of the once-per-kind console latch. */\nexport function resetSourcelessDbRowReports(): void {\n reportedSourcelessDbRows.clear();\n}\n\n/**\n * The db-override flip (R6: db overrides bundled): an ACTIVE `source='db'` row\n * carrying a component body wins over BOTH the compiled bridge and any bundled\n * resolution. The block re-types to `db_kind_component`; the host re-resolves\n * the row and compiles/sandboxes it. Returns null when the flip does not apply.\n */\nfunction routeToDbComponent<T extends IrRoutableBlock>(\n block: T,\n kind: string,\n resolution: ComponentResolution | null,\n env: KindRouteEnv,\n): T | null {\n if (!isDbSourceResolution(resolution)) return null;\n // Gate on the FLAG, not body presence: a lazy host's warm list is\n // body-less (metadata only) and the body arrives per kind via the cold\n // fetch — the row still routes, and the renderer compiles the body once it\n // lands. A row whose flag says it truly has no body screams and falls\n // through, exactly as before.\n if (!resolution.hasComponentSource) {\n reportDbRowWithoutSource(kind, env);\n return null;\n }\n if (block.type === DB_KIND_COMPONENT_KEY) return block;\n return {\n ...block,\n type: DB_KIND_COMPONENT_KEY,\n // The compiled/sandboxed component reads the envelope, never the raw\n // region's annotation serverData (same poison rule as bridged kinds).\n serverData: undefined,\n metadata: withRouteMarker(block.metadata, resolution),\n };\n}\n\n/** Why a block landed on the generic viewer instead of a real renderer. */\nexport type GenericFallbackReason =\n /** No compiled bridge and no `content_ir.kind_component` row at all. */\n | \"no-component\"\n /** A component row exists but is held `is_active = false`. */\n | \"inactive\"\n /**\n * An ACTIVE component row exists and names `generic_structured` — i.e. the\n * fallback, registered under a component's name. This reads as coverage to\n * every count-the-rows check on the platform and is not: the reader still\n * gets a key/value dump. Kept as its own reason because the repair differs\n * (author a component AND retire the decoy row), and because a page that\n * silently marked itself `by: \"bundled\"` here is how 226 of 428 active\n * kinds came to be certified as renderable while rendering generically\n * (found 2026-08-23).\n */\n | \"generic-row\"\n /**\n * The envelope carries a kind-preserved RAW: the payload identified a\n * registered kind and its value FAILED a check — a schema violation, an\n * array-item kind mismatch, a duplicate key, a contradicted speculation.\n * The instance is BROKEN, not component-less — the repair is fixing the\n * payload or the schema, and the generic floor must acknowledge the kind and\n * surface the recorded problems.\n *\n * NOT this: a kind whose schema was never available (`kindState:\n * \"unverified\"`). Nothing checked that value, so calling it broken is a\n * false accusation — it routes to its component. The two were one state\n * until 2026-08-29 and conflating them was a platform-wide outage.\n */\n | \"broken-instance\"\n /**\n * The slug is not in the registry at all (typo, foreign emitter, a shape\n * not yet created). Routed anyway — Arman's 2026-08-29 ruling: a root\n * `__kind` key means the kind system owns the render, no exceptions. The\n * repair is creating/registering the shape (or fixing the slug).\n */\n | \"unregistered\";\n\nexport interface IrRouteMarker {\n by: ComponentResolution[\"resolvedBy\"] | \"generic\" | \"directive\";\n key: string;\n /**\n * Only on the generic fallback: the shape is NOT render-trusted, so the\n * viewer must say so out loud (R6 — never an error, never hidden content).\n */\n unverified?: true;\n reason?: GenericFallbackReason;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction isRouteMarker(value: unknown): value is IrRouteMarker {\n return (\n isRecord(value) &&\n typeof value.by === \"string\" &&\n typeof value.key === \"string\"\n );\n}\n\n/** Read the routing marker a block picked up at the seam (or null). */\nexport function readIrRouteMarker(\n metadata: Record<string, unknown> | null | undefined,\n): IrRouteMarker | null {\n const candidate = metadata?.[IR_ROUTE_KEY];\n return isRouteMarker(candidate) ? candidate : null;\n}\n\nfunction withRouteMarker(\n metadata: Record<string, unknown> | undefined,\n resolution: ComponentResolution,\n): Record<string, unknown> {\n return {\n ...metadata,\n [IR_ROUTE_KEY]: {\n by: resolution.resolvedBy,\n key: resolution.componentKey,\n } satisfies IrRouteMarker,\n };\n}\n\n/**\n * R6's sanctioned disposition for a shape the platform KNOWS (a kind\n * definition supplied its schema) but nothing render-trusted claims: the\n * generic structured viewer, carrying an honest \"unverified shape\" affordance\n * — never an error, never a raw code block, never hidden content.\n *\n * `serverData` is CLEARED for the same reason the resolver-only path clears\n * it: a raw region's annotation (`{ language: \"json\" }`) is not kind data, and\n * the generic viewer reads the envelope, not serverData.\n */\nfunction routeToGeneric<T extends IrRoutableBlock>(\n block: T,\n reason: GenericFallbackReason,\n): T {\n if (block.type === GENERIC_STRUCTURED_COMPONENT_KEY) return block;\n\n return {\n ...block,\n type: GENERIC_STRUCTURED_COMPONENT_KEY,\n serverData: undefined,\n metadata: {\n ...block.metadata,\n [IR_ROUTE_KEY]: {\n by: \"generic\",\n key: GENERIC_STRUCTURED_COMPONENT_KEY,\n unverified: true,\n reason,\n } satisfies IrRouteMarker,\n },\n };\n}\n\nexport interface KindRouteOptions {\n /**\n * Block types this host OWNS and the route must never re-type, however good\n * the envelope on them looks.\n *\n * matrx-frontend passes `[\"artifact\"]`: an artifact block has an identity, a\n * version, and a Canvas to open in, and since 2026-08-18 it carries\n * `metadata.__ir` so SELECTORS can read the envelope. That envelope is DATA\n * there, not a route — re-typing it to the bare kind component would strip\n * the artifact chrome and lose the door to the Canvas.\n */\n ownedTypes?: readonly string[];\n}\n\nexport function applyIrKindRoute<T extends IrRoutableBlock>(\n block: T,\n env: KindRouteEnv,\n options?: KindRouteOptions,\n): T {\n if (options?.ownedTypes?.includes(block.type)) return block;\n\n const envelope = readEnvelope(block.metadata);\n if (!envelope) return block;\n\n const kind = envelope.root.kind;\n if (!kind) return block; // raw / pending — the host's own rendering stands\n\n // An identified kind whose SCHEMA is still cold-fetching (pending_schema) has\n // no compliant value yet — routing now would hand a component early scalars\n // at best. The host's loading layer owns this window; the parser upgrades in\n // place the moment the schema lands, and end() converts a lost race to a\n // kind-preserving raw — both of which route normally.\n if (envelope.root.kindState === \"pending_schema\") return block;\n\n // ── THE DIRECTIVE TIER ────────────────────────────────────────────────────\n // A reserved slug is a directive; the directive tier owns its display, in\n // every kind state (a kind-preserved raw is still a directive the card can\n // name and the reader can apply — the server re-validates on confirm).\n if (isReservedDirectiveSlug(kind)) {\n if (block.type === DIRECTIVE_BLOCK_TYPE) return block;\n return {\n ...block,\n type: DIRECTIVE_BLOCK_TYPE,\n serverData: undefined,\n metadata: {\n ...(block.metadata ?? {}),\n [IR_ROUTE_KEY]: { by: \"directive\", key: DIRECTIVE_BLOCK_TYPE } satisfies IrRouteMarker,\n },\n };\n }\n\n const def = env.kinds.getDefinition(kind);\n const resolution = env.components.resolve(kind, env.platform, \"output\");\n\n // 🚨 THE COLD-VERDICT RULE (Arman, 2026-08-31). A registry that has not\n // loaded yet must never be allowed to publish a NEGATIVE verdict. Every\n // \"this shape isn't registered\" / \"no component\" answer below is a durable,\n // user-visible claim written into the block's metadata — and on the first\n // paint of a fresh tab the resolver has fetched nothing, so those claims\n // were being produced by a registry whose honest answer is \"I haven't\n // looked\". The reader saw a key/value dump captioned \"this shape isn't\n // registered on this platform\" for a shape that was registered, active, and\n // had a component the whole time.\n //\n // Holding the block (exactly as `pending_schema` does) hands the window to\n // the host's loading layer; `useEnsureKindRenderable` fetches, the per-kind\n // repaint fires, and this function re-runs with a settled registry. A\n // POSITIVE answer is never suppressed — if the compiled floor or an already\n // ingested row can name a component, the paths below run immediately.\n const componentsSettled = env.components.hasSettled?.() ?? true;\n if (!componentsSettled && !resolution && !def) return block;\n\n // A kind-preserved `raw` is a BROKEN instance: something CHECKED this value\n // and it failed — a schema violation, an array-item kind mismatch, a\n // duplicate key, a contradicted speculation. No component (bridge or db) may\n // claim a non-compliant value; the generic floor acknowledges the kind and\n // the envelope's recorded problems (residue notices, the raw_fallback\n // reason) are the host's to show. An UNREGISTERED slug routes here too —\n // Arman's 2026-08-29 ruling: a root `__kind` key means the kind system owns\n // the render, NO exceptions. Repaint upgrades it the moment the registries\n // learn more.\n //\n // 🚨 `unverified` DELIBERATELY DOES NOT MATCH HERE, AND MUST NEVER BE ADDED.\n // That state means no schema was ever available, so nothing was checked —\n // the value is intact and quite possibly perfect. It falls through to the\n // component paths below exactly as it did before 2026-08-28, when this gate\n // read the old undifferentiated `raw` and took ~221 live kinds' components\n // away overnight: every kind whose schema cannot be reconstructed (nested\n // objects, arrays of children, loose fields) degrades this way, and each one\n // rendered as a key/value dump while its purpose-built component sat one\n // line below, never asked for. Widening this condition re-opens that outage.\n // See `IrKindState` in @ai-matrx/content-ir.\n if (envelope.root.kindState === \"raw\") {\n return routeToGeneric(\n block,\n def || resolution ? \"broken-instance\" : \"unregistered\",\n );\n }\n\n // ── DB user-component path — db overrides bundled (ruling R6) ─────────────\n // Checked FIRST so a user's registered component actually renders; a\n // defective row (no source) screams and falls through to bundled behavior —\n // never un-renders.\n const dbRouted = routeToDbComponent(block, kind, resolution, env);\n if (dbRouted) return dbRouted;\n\n // ── Compiled-bridge path — trusted at bootstrap (ruling R6) ───────────────\n // A kind carrying a legacyBlockType facet ALWAYS routes: the host's existing\n // behavior for every registered kind, and the production floor a DB row can\n // refine (the marker records which tier resolved) but never un-render.\n if (def?.legacyBlockType) {\n // A block ALREADY emitted as the legacy type carrying its own serverData is\n // authoritative — the server typed it AND provided the component's data.\n if (block.type === def.legacyBlockType && block.serverData) return block;\n\n // ROUTING a raw region (e.g. \"code\" → \"flashcards\"): the envelope is the\n // single source of truth. The block's own serverData here is NOT kind data\n // — it is the raw region's annotation (`{ language: \"json\" }`). Preferring\n // that junk handed the legacy component `{ language: \"json\" }` instead of\n // cards/questions/slides — the 2026-07-04 \"No flashcards available yet\"\n // bug — so it is REPLACED (bridge output) or CLEARED (bridgeless kinds\n // parse `content` themselves), never forwarded.\n const serverData = def.toLegacyServerData?.(envelope);\n\n if (block.type === def.legacyBlockType && serverData === undefined) {\n return block; // nothing to change — keep reference stability\n }\n\n return {\n ...block,\n type: def.legacyBlockType,\n serverData,\n ...(resolution\n ? { metadata: withRouteMarker(block.metadata, resolution) }\n : null),\n };\n }\n\n // ── Resolver-only path (no compiled bridge): the registry decides ─────────\n // R6: only an ACTIVE resolution is render-trusted. An inactive row means\n // \"held\", not \"route it anyway\".\n if (resolution?.isActive) {\n // A row naming the fallback is NOT a resolution. Routing it as one stamped\n // `by: \"bundled\"` on the block and told every reader the shape had a\n // renderer — the platform's own generic viewer, wearing a component's\n // clothes. It goes to the honest generic path with its own reason instead.\n if (resolution.componentKey === GENERIC_STRUCTURED_COMPONENT_KEY) {\n return routeToGeneric(block, \"generic-row\");\n }\n if (block.type === resolution.componentKey) return block;\n\n return {\n ...block,\n type: resolution.componentKey,\n // No compiled bridge exists — the routed component parses `content`\n // itself; the raw region's annotation serverData is CLEARED.\n serverData: undefined,\n metadata: withRouteMarker(block.metadata, resolution),\n };\n }\n\n // ── R6 generic fallback: a KNOWN shape that nothing render-trusted claims ─\n // `def` exists ⇒ a kind definition supplied this kind's schema: the platform\n // knows the shape. It has no compiled bridge, and either no `kind_component`\n // row at all (`no-component`) or one held inactive (`inactive`). R6 sends\n // exactly this case to the generic structured viewer with an \"unverified\n // shape\" affordance — the disposition that retires permanently-red\n // \"no-component root\" kinds without pretending they have renderers.\n if (def) {\n return routeToGeneric(block, resolution ? \"inactive\" : \"no-component\");\n }\n\n // A kind slug the platform has NO definition for (a typo, a foreign\n // emitter, a not-yet-created shape). 🚨 Arman's ruling, 2026-08-29: a root\n // `__kind` key means the kind system owns the render — NO exceptions. The\n // old strangler carve-out (\"not ours to claim\", teaching content stayed a\n // raw code block) is retired: an unregistered kind renders through the\n // generic floor with `reason: \"unregistered\"`, so the reader always sees\n // the payload acknowledged AS a kind instance with what is known about it.\n // A repaint hook upgrades this block the moment the registries learn the\n // kind.\n return routeToGeneric(block, \"unregistered\");\n}\n\n/**\n * Rehydration route for STRUCTURED persisted artifacts.\n *\n * A materialized kind artifact stores its zero-loss value object (carrying\n * `__kind`) alongside its row. Given that stored value, derive the registered\n * kind's legacy `serverData` WITHOUT re-parsing any text: the value wraps into\n * a complete envelope and runs through the same `toLegacyServerData` bridge the\n * live stream uses. Returns null for non-objects, unregistered kinds, or kinds\n * without a legacy bridge — callers fall back to their string-payload path.\n */\nexport function kindServerDataFromStoredValue(\n value: unknown,\n env: Pick<KindRouteEnv, \"kinds\">,\n): Record<string, unknown> | null {\n if (!isRecord(value)) return null;\n const kind = readObjectKind(value);\n if (!kind) return null;\n\n const def = env.kinds.getDefinition(kind);\n if (!def?.toLegacyServerData) return null;\n\n return def.toLegacyServerData(envelopeFromCompleteValue(value, kind)) ?? null;\n}\n","/**\n * Routing the PROVISIONAL half of the streaming partial-kinds contract.\n *\n * Cross-repo system-of-record (read it before changing anything here):\n * `common-docs/systems/architecture/content-ir/STREAMING_PARTIAL_KINDS.md` §8.\n * The reader/validator half lives in `@ai-matrx/content-ir` (`wire/partial-kind`);\n * the wire gate runs in each host's stream ingest.\n *\n * WHAT THIS DOES\n * --------------\n * While a structured region streams, the server announces what it thinks the\n * region IS and what has arrived so far (`metadata.__ir_partial`). This module\n * turns that provisional event into a routed block that renders through the\n * EXACT SAME component the final value renders in — which is the entire point:\n * a bespoke skeleton renderer would be a second render path and is banned.\n *\n * HOW, without touching the verified channel\n * ------------------------------------------\n * `root` is deliberately `IrStructuredNode`-shaped, so the event wraps into a\n * `CanonicalBlockIR` and every existing reader — the compiled bridge, the\n * component resolver, the db-component flip, the generic viewer — works\n * unchanged. That provisional envelope is placed on a RENDER-LOCAL COPY of the\n * block's metadata under `__ir`, never on the wire and never in host state. The\n * block also carries `__ir_provisional: true` so any downstream reader can tell\n * a provisional render from a verified one.\n *\n * THE POSTURE: WITHHOLD BY DEFAULT, OPT IN PER KIND\n * -------------------------------------------------\n * A provisional value MAY be missing required fields — that is what the\n * `partial_unvalidated` notice declares — and §8 of the contract requires that\n * a component which throws on an absent field is not routed one. Rather than\n * audit every component, the default is WITHHOLD: nothing changes and the block\n * keeps its loading skeleton. A kind opts in with `partialReady: true` on its\n * registry definition. If an opted-in component throws anyway,\n * `ProvisionalKindBoundary` screams and calls `markKindPartialUnsafe`, which\n * drops that kind back to withhold for the rest of the session — loud recovery,\n * never a broken surface.\n *\n * TERMINALS\n * ---------\n * `superseded` and `retracted` produce NO provisional render, so the swap to\n * the final value happens in the same frame the terminal arrives — never a\n * flicker through an empty state. Both are explicit EVENTS: the terminal is\n * never inferred from the arrival of `__ir`, because a completed block often\n * has no `__ir` at all (unregistered kind, schema drift, cold catalog) and\n * inferring it would leave the skeleton up forever in exactly those cases.\n */\n\nimport {\n envelopeFromCompleteValue,\n IR_ENVELOPE_KEY,\n IR_PARTIAL_KEY,\n IR_VERSION,\n isProvisionalKind,\n readEnvelope,\n readObjectKind,\n readPartialKindEvent,\n} from \"@ai-matrx/content-ir\";\nimport type { CanonicalBlockIR, PartialKindEvent } from \"@ai-matrx/content-ir\";\nimport type { IrRoutableBlock, KindRouteEnv } from \"../host/host-types\";\nimport { applyIrKindRoute, type KindRouteOptions } from \"./kind-route\";\n\n/**\n * Marker stamped on a render-local block whose `__ir` is PROVISIONAL. Never\n * emitted by a producer, never persisted, never on the wire.\n */\nexport const IR_PROVISIONAL_KEY = \"__ir_provisional\" as const;\n\n/** True when this block's metadata carries a provisional (not verified) envelope. */\nexport function isProvisionalBlock(\n metadata: Record<string, unknown> | null | undefined,\n): boolean {\n return metadata?.[IR_PROVISIONAL_KEY] === true;\n}\n\n/** Wrap a validated `partial` event into the envelope shape every IR reader consumes. */\nexport function envelopeFromPartialKind(\n event: PartialKindEvent,\n): CanonicalBlockIR {\n return {\n v: IR_VERSION,\n // The partial channel is only ever produced by the Python detector; the\n // envelope's `engine` union has no third member and inventing one would\n // break every existing reader.\n engine: \"py-block-detector\",\n fingerprint: event.fingerprint,\n root: event.root,\n };\n}\n\n/**\n * Kinds whose component threw while rendering a provisional value. Session-\n * scoped: the kind falls back to withhold (its loading skeleton) until a\n * reload, so one bad component cannot keep re-throwing on every block.\n */\n// SESSION LATCH ON A globalThis SLOT — never a module-level variable. This\n// latch is WRITTEN from the `./react` bundle (ProvisionalKindBoundary calls\n// markKindPartialUnsafe) and READ from the `./route` bundle\n// (isPartialReadyKind); with `splitting: false` dual ESM/CJS output those are\n// different module instantiations, and a module-level Set would silently split\n// the writer from the reader (the kit confirm-opener precedent). Never \"clean\n// this up\" into a module local.\nconst PARTIAL_UNSAFE_SLOT = Symbol.for(\n \"ai-matrx.content-ir-react.partial-unsafe-kinds\",\n);\ntype PartialUnsafeSlotHolder = typeof globalThis & {\n [PARTIAL_UNSAFE_SLOT]?: Set<string>;\n};\nconst partialUnsafeKinds: Set<string> = ((globalThis as PartialUnsafeSlotHolder)[\n PARTIAL_UNSAFE_SLOT\n] ??= new Set<string>());\n\n/** Loud recovery hook — called by ProvisionalKindBoundary when a render throws. */\nexport function markKindPartialUnsafe(kind: string): void {\n partialUnsafeKinds.add(kind);\n}\n\n/** Test-only reset of the session latch. */\nexport function resetPartialUnsafeKinds(): void {\n partialUnsafeKinds.clear();\n}\n\n/**\n * Has this kind opted in to being handed a provisional value? Withhold is the\n * default; see the module doc.\n */\nexport function isPartialReadyKind(\n kind: string,\n env: Pick<KindRouteEnv, \"kinds\">,\n): boolean {\n if (!kind || partialUnsafeKinds.has(kind)) return false;\n return env.kinds.getDefinition(kind)?.partialReady === true;\n}\n\nexport interface PartialRenderOptions extends KindRouteOptions {\n /**\n * Is the STREAM still running? Message-wide, deliberately — not this block's\n * own completion.\n *\n * 🚨 THE ANTI-STUCK-SKELETON BACKSTOP. Law 1 of the contract says every\n * partial ends in exactly one terminal, and that law is the ONLY thing\n * standing between a user and a \"Still arriving\" skeleton that never\n * resolves. It is a producer guarantee with at least three ways to not fire:\n * the drain skips a block missing from the final block list, the emitter\n * early-returns once the stream ended or was cancelled (so a client abort\n * drops every retraction), and a flush failure is swallowed so it never kills\n * a run.\n *\n * Once the stream is over, no terminal can ever arrive, so a still-open\n * provisional is stuck by definition — drop it and let the block's own\n * content and `__ir` be the truth. Correct to be message-wide: a terminal for\n * THIS block may still be in flight while the block itself looks finished.\n *\n * `undefined` reads as active, so a caller that does not thread stream state\n * keeps live rendering rather than silently losing it.\n */\n streamActive?: boolean;\n}\n\n/**\n * The ANNOUNCED-but-not-yet-renderable state: the server has said what this\n * region is, and the region cannot render its real component yet.\n *\n * WHY THIS EXISTS SEPARATELY FROM THE VERIFIED CHANNEL. On a chat stream the\n * host's own accumulator fills `__ir` in as it parses. A WORKFLOW run's lane\n * does not: when the server opens the block scope it marks the text channel\n * `block_shadowed` and the lane stops feeding its accumulator, precisely so one\n * region is never rendered twice under two sets of block ids\n * (STREAMING_PARTIAL_KINDS.md §7b rule 4). So on a run page there is NO\n * streaming `__ir` — the ONLY thing that knows what the region is, is the\n * partial channel. Without this, a workflow node's structured answer fell\n * through to the raw-text renderer: a generic loader, then raw JSON\n * accumulating, then a swap at the end.\n *\n * Returns the provisional envelope to feed the kind's loading component, or\n * null when there is nothing announced (no event, a terminal, a dead stream).\n * Deliberately independent of `partialReady`: withholding a VALUE from a\n * component that might throw on it is a real decision, but withholding the\n * kind's own loading state is not — a skeleton cannot throw, and the reader\n * seeing what is coming is the whole point.\n */\nexport function resolveAnnouncedKindLoading(\n block: { metadata?: Record<string, unknown> },\n options?: Pick<PartialRenderOptions, \"streamActive\">,\n): { kind: string; envelope: CanonicalBlockIR } | null {\n // Same anti-stuck-skeleton backstop as resolveProvisionalKindRender: once the\n // stream is over no terminal can arrive, so a still-open announcement is\n // stuck by definition and must not hold a loader on screen forever.\n if (options?.streamActive === false) return null;\n\n const event = readPartialKindEvent(block.metadata);\n if (!isProvisionalKind(event)) return null;\n const kind = event.root.kind;\n if (!kind) return null;\n\n // A region that already VERIFIED is the truth; never cover it with a loader.\n const verified = readEnvelope(block.metadata);\n if (verified && verified.root.status === \"complete\") return null;\n\n return { kind, envelope: envelopeFromPartialKind(event) };\n}\n\nexport interface ProvisionalKindRender<T> {\n /** The routed block — same type/serverData shape the final value produces. */\n block: T;\n /** The announced (speculative) kind. */\n kind: string;\n /** Per-block ordering key, for diagnostics. */\n seq: number;\n /** The provisional envelope — feeds the loading skeleton used as the throw fallback. */\n envelope: CanonicalBlockIR;\n}\n\nexport interface SupersededKindRender<T> {\n /** The completed block routed through the announced kind's normal component. */\n block: T;\n /** The kind the producer announced and then confirmed at terminal. */\n kind: string;\n /** Per-block ordering key, for diagnostics. */\n seq: number;\n /** Render-local complete envelope reconstructed from the block's own content. */\n envelope: CanonicalBlockIR;\n}\n\nfunction parseCompletedJsonObject(content: string): Record<string, unknown> | null {\n let source = content.trim();\n const fenced = source.match(/^```(?:json)?\\s*\\n?([\\s\\S]*?)\\n?```$/i);\n if (fenced?.[1]) source = fenced[1].trim();\n\n try {\n const value = JSON.parse(source) as unknown;\n return typeof value === \"object\" && value !== null && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : null;\n } catch {\n return null;\n }\n}\n\n/**\n * Finish the partial-kind handoff for a `superseded` terminal.\n *\n * A workflow run deliberately shadows its text channel while server-built\n * render blocks stream, so the browser never builds a verified `__ir`\n * envelope for that region. The terminal still proves that the announced kind\n * completed, and the block's own content is now closed JSON. Reconstruct a\n * render-local COMPLETE envelope from that content and route it through the\n * same component path as persisted/reloaded data. `retracted` is never\n * eligible, and a malformed or mismatched payload stays on the host's honest\n * raw fallback.\n */\nexport function resolveSupersededKindRender<\n T extends IrRoutableBlock & {\n content: string;\n metadata?: Record<string, unknown>;\n },\n>(\n block: T,\n env: KindRouteEnv,\n options?: KindRouteOptions,\n): SupersededKindRender<T> | null {\n const event = readPartialKindEvent(block.metadata);\n if (event?.state !== \"superseded\") return null;\n\n // A verified envelope is already the higher-fidelity truth and the ordinary\n // kind route owns it.\n if (readEnvelope(block.metadata)?.root.status === \"complete\") return null;\n\n const value = parseCompletedJsonObject(block.content);\n if (!value || readObjectKind(value) !== event.kind) return null;\n\n const { [IR_PARTIAL_KEY]: _partial, ...rest } = block.metadata ?? {};\n void _partial;\n const envelope = envelopeFromCompleteValue(value, event.kind);\n const terminalBlock = {\n ...block,\n // A code/json block's serverData is an annotation, not kind data.\n serverData: undefined,\n metadata: { ...rest, [IR_ENVELOPE_KEY]: envelope },\n } as T;\n const routed = applyIrKindRoute(terminalBlock, env, options);\n if (routed === terminalBlock) return null;\n\n return { block: routed, kind: event.kind, seq: event.seq, envelope };\n}\n\n/**\n * Resolve a block's provisional render, or null when there is nothing to show\n * provisionally (no event, a terminal event, a withheld kind, a kind nothing\n * can route, or a verified envelope that already won).\n *\n * Pure: no React, no host state, no side effects beyond the registry reads.\n */\nexport function resolveProvisionalKindRender<\n T extends IrRoutableBlock & { metadata?: Record<string, unknown> },\n>(\n block: T,\n env: KindRouteEnv,\n options?: PartialRenderOptions,\n): ProvisionalKindRender<T> | null {\n if (options?.streamActive === false) return null;\n\n const event = readPartialKindEvent(block.metadata);\n // Terminal (superseded / retracted) → no provisional render, in this frame.\n if (!isProvisionalKind(event)) return null;\n\n const kind = event.root.kind;\n if (!isPartialReadyKind(kind, env)) return null;\n\n // A verified envelope that has already completed is the truth — a late or\n // duplicated partial must never displace it.\n const verified = readEnvelope(block.metadata);\n if (verified && verified.root.status === \"complete\") return null;\n\n const { [IR_PARTIAL_KEY]: _partial, ...rest } = block.metadata ?? {};\n void _partial;\n\n const envelope = envelopeFromPartialKind(event);\n\n const provisionalBlock = {\n ...block,\n // The raw region annotation (`{ language: \"json\" }`) is not kind data —\n // same poison rule the verified route follows.\n serverData: undefined,\n metadata: {\n ...rest,\n [IR_ENVELOPE_KEY]: envelope,\n [IR_PROVISIONAL_KEY]: true,\n },\n } as T;\n\n const routed = applyIrKindRoute(provisionalBlock, env, options);\n // Nothing claimed it (unknown kind, no component) — `applyIrKindRoute`\n // returns the SAME reference. Withhold rather than render raw partial JSON.\n if (routed === provisionalBlock) return null;\n // A bridged kind whose bridge DECLINED this value (too thin to render — a\n // quiz with no answerable question yet) routed on type alone, which would\n // hand the component the partial JSON text to parse. Withhold: the loading\n // skeleton stays up for this frame and the next `seq` tries again.\n if (\n env.kinds.getDefinition(kind)?.toLegacyServerData &&\n !(routed as { serverData?: unknown }).serverData\n ) {\n return null;\n }\n\n return { block: routed, kind, seq: event.seq, envelope };\n}\n","/**\n * THE BOUND ROUTE — the pure route functions with a host's env and owned\n * types partially applied, built ONCE in a host wiring module.\n *\n * Every host was writing the same wrapper file by hand: one function per pure\n * route, each forwarding `matrx…Env` + `ownedTypes` (matrx-frontend carried\n * two such modules; the dashboard a third). Per C22 that repeated delta is\n * package-provided: a host module now only INJECTS (its env, its owned block\n * types) and re-exports what this factory returns.\n *\n * The functions are the exact pure routes — read `kind-route.ts` /\n * `partial-kind-route.ts` for semantics; nothing behavioral lives here.\n */\n\nimport type { IrRoutableBlock, KindRouteEnv } from \"../host/host-types\";\nimport {\n applyIrKindRoute,\n kindServerDataFromStoredValue,\n type KindRouteOptions,\n} from \"./kind-route\";\nimport {\n isPartialReadyKind,\n resolveProvisionalKindRender,\n resolveSupersededKindRender,\n type PartialRenderOptions,\n type ProvisionalKindRender,\n type SupersededKindRender,\n} from \"./partial-kind-route\";\n\nexport interface KindRouteBinding {\n /** Route one block through the bound registries. */\n applyIrKindRoute<T extends IrRoutableBlock>(block: T): T;\n /**\n * Rehydration route for STRUCTURED persisted artifacts: given a stored\n * zero-loss value object, derive the registered kind's legacy `serverData`\n * with no re-parse. Null for non-objects, unregistered kinds, or kinds\n * without a legacy bridge.\n */\n kindServerDataFromStoredValue(value: unknown): Record<string, unknown> | null;\n /** Has this kind opted in to being handed a provisional value? */\n isPartialReadyKind(kind: string): boolean;\n /**\n * Resolve a block's provisional render, or null when there is nothing to\n * show provisionally (no event, a terminal event, a withheld kind, a kind\n * nothing can route, or a verified envelope that already won).\n */\n resolveProvisionalKindRender<\n T extends IrRoutableBlock & { metadata?: Record<string, unknown> },\n >(\n block: T,\n options?: Pick<PartialRenderOptions, \"streamActive\">,\n ): ProvisionalKindRender<T> | null;\n /**\n * Route a completed workflow block whose `superseded` terminal confirms the\n * kind but whose shadowed lane never built a verified envelope.\n */\n resolveSupersededKindRender<\n T extends IrRoutableBlock & {\n content: string;\n metadata?: Record<string, unknown>;\n },\n >(block: T): SupersededKindRender<T> | null;\n}\n\n/** Bind the pure routes to one host's env + owned block types. */\nexport function createKindRouteBinding(\n env: KindRouteEnv,\n options?: KindRouteOptions,\n): KindRouteBinding {\n const ownedTypes = options?.ownedTypes;\n return {\n applyIrKindRoute: (block) =>\n applyIrKindRoute(block, env, ownedTypes ? { ownedTypes } : undefined),\n kindServerDataFromStoredValue: (value) =>\n kindServerDataFromStoredValue(value, env),\n isPartialReadyKind: (kind) => isPartialReadyKind(kind, env),\n resolveProvisionalKindRender: (block, streamOptions) =>\n resolveProvisionalKindRender(block, env, {\n ...streamOptions,\n ...(ownedTypes ? { ownedTypes } : null),\n }),\n resolveSupersededKindRender: (block) =>\n resolveSupersededKindRender(\n block,\n env,\n ownedTypes ? { ownedTypes } : undefined,\n ),\n };\n}\n"],"mappings":";AA0BA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAWA,IAAM,eAAe;AAOrB,IAAM,mCAAmC;AAQzC,IAAM,wBAAwB;AAc9B,IAAM,uBAAuB;AASpC,SAAS,qBACP,YACmC;AACnC,SACE,eAAe,QACf,WAAW,eAAe,QAC1B,WAAW,WAAW,QACtB,WAAW;AAEf;AAQA,IAAM,yBAAyB,uBAAO;AAAA,EACpC;AACF;AAIA,IAAM,2BAA0C,WAC9C,sBACF,MAAM,oBAAI,IAAY;AAGtB,SAAS,yBAAyB,MAAc,KAAyB;AACvE,QAAM,UAAU,oCAAoC,IAAI;AACxD,MAAI,CAAC,yBAAyB,IAAI,IAAI,GAAG;AACvC,6BAAyB,IAAI,IAAI;AACjC,YAAQ,MAAM,OAAO;AAAA,EACvB;AACA,MAAI,YAAY,EAAE,QAAQ,cAAc,SAAS,KAAK,EAAE,KAAK,EAAE,CAAC;AAClE;AAGO,SAAS,8BAAoC;AAClD,2BAAyB,MAAM;AACjC;AAQA,SAAS,mBACP,OACA,MACA,YACA,KACU;AACV,MAAI,CAAC,qBAAqB,UAAU,EAAG,QAAO;AAM9C,MAAI,CAAC,WAAW,oBAAoB;AAClC,6BAAyB,MAAM,GAAG;AAClC,WAAO;AAAA,EACT;AACA,MAAI,MA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AAM,GAAG;AAAA,IAC1D,8BAA8B,CAAC,OAAO,kBACpC,6BAA6B,OAAO,KAAK;AAAA,MACvC,GAAG;AAAA,MACH,GAAI,aAAa,EAAE,WAAW,IAAI;AAAA,IACpC,CAAC;AAAA,IACH,6BAA6B,CAAC,UAC5B;AAAA,MACE;AAAA,MACA;AAAA,MACA,aAAa,EAAE,WAAW,IAAI;AAAA,IAChC;AAAA,EACJ;AACF;","names":["envelopeFromCompleteValue","readEnvelope","readObjectKind","readEnvelope","readObjectKind","envelopeFromCompleteValue"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-matrx/content-ir-react",
3
- "version": "0.16.1",
3
+ "version": "0.17.1",
4
4
  "description": "The shared AI Matrx Content IR RENDER layer: kind routing, the component resolver, provisional (streaming) rendering, the runtime-wrapper chrome, and the generic structured floor — as portable React.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -124,8 +124,8 @@
124
124
  "react": ">=19.0.0"
125
125
  },
126
126
  "dependencies": {
127
- "@ai-matrx/kit": "latest",
128
- "@ai-matrx/content-ir": "latest"
127
+ "@ai-matrx/content-ir": "latest",
128
+ "@ai-matrx/kit": "latest"
129
129
  },
130
130
  "devDependencies": {
131
131
  "@arethetypeswrong/cli": "^0.18.5",