@ai-matrx/content-ir 0.1.2 → 0.2.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/index.d.cts CHANGED
@@ -1598,4 +1598,327 @@ declare function collectReferencedKinds(fields: Record<string, FieldSchema>): st
1598
1598
  declare function collectSchemaReferencedKinds(schema: KindSchema): string[];
1599
1599
  declare function kindSchemaToJsonSchema(kind: string, resolve: (kind: string) => KindSchema | undefined, options?: KindJsonSchemaOptions): KindJsonSchemaExport | null;
1600
1600
 
1601
- export { type ArrayItemKindBinding, type ArrayItemScalarType, type BlockSchemaDraft, type CanonicalBlockIR, type CanonicalContent, type CanonicalSegment, type CompleteValueEnvelopeOptions, type CompliantKindSnapshot, type ContentRegionInit, type ConversionProblem, type DroppedMetadata, type DualGateDefinition, type DualGateInput, type DualGateResolvedComponent, type DualGateResult, type FieldComparison, type FieldSchema, type Fingerprinter, IR_ENVELOPE_CACHE_VERSION, IR_ENVELOPE_KEY, IR_VERSION, type InboundEnvelopeHooks, type InboundEnvelopeVerdict, type IrDiscriminator, type IrEnvelopeCache, type IrKindState, type IrPath, type IrResidue, type IrStructuredNode, IrTree, type IrTreeNode, type ItemKindRefCheck, JSON_DISCRIMINATOR, type JsonPath, type JsonSchemaNode, JsonStreamTokenizer, type JsonToken, KIND_KEY, type KindBlockProps, type KindDefinition, type KindEdgeSpec, type KindJsonSchemaExport, type KindJsonSchemaOptions, type KindResolution, type KindSchema, KindStorageError, type KindStorageShape, type KindStreamEvent, KindStreamParser, type KindStreamParserOptions, type KindTier, type LegResult, type NormalizeJsonRegionOptions, ParseSession, type ParseSessionOptions, type Punct, ROOT_STORAGE_NAME, type RecordValueType, type RegionEndReason, type RegionFormat, type RegionSourceKind, type SavePlanEntry, type SavePlanValidation, type ScalarFieldType, type SchemaConversionResult, type SchemaLayoutMode, type SchemaResolver, type StoredFieldElement, buildAgentSchemaWithRenderBlockSupport, buildCompliantKindSnapshot, classifyInboundEnvelopeMetadata, collectReferencedKinds, collectSchemaReferencedKinds, compareWithExistingKindSchema, convertAiSchemaToBlockFields, createFingerprinter, createKindStreamParser, describeDualGateFailure, disposeParseSession, emptyValueForFieldSchema, envelopeCacheFromEnvelopes, envelopeFromCompleteValue, fenceDiscriminator, fieldsToDbPayload, fingerprintText, formatBlockLabel, getParseSession, injectKindIntoObjectSchema, irPathIsUnderOrEqual, irPathKey, irPathLabel, irPathsEqual, isCanonicalBlockIR, isDuplicateBlockSlug, isEmptyResidue, isIrEnvelopeCache, isJsonAnyField, isScalarArrayType, kindSchemaToJsonSchema, kindSchemaToStorage, mergeResidueIntoValue, normalizeAiSchemaInput, normalizeJsonRegion, openParseSession, readEnvelope, readObjectKind, reconstructRegionValue, reuseEnvelopeIfCurrent, runKindDualGate, runSchemaConversion, sanitizeInboundEnvelopeMetadata, scalarArrayItemType, schemaLayoutMode, schemaStructureDepth, setJsonRootKeyLookup, storageToKindSchema, stripKindDeep, validateBlockSchemaSavePlan, validateStructuralLeg, xmlDiscriminator };
1601
+ /**
1602
+ * Streaming partial kinds — the TS twin of the Python producer's contract.
1603
+ *
1604
+ * Cross-repo system-of-record (read it before changing anything here):
1605
+ * `common-docs/systems/content-ir-system/STREAMING_PARTIAL_KINDS.md`.
1606
+ * Python twin: `aidream/packages/matrx-graph/matrx_graph/content_ir/partial.py`.
1607
+ *
1608
+ * WHAT THIS IS
1609
+ * ------------
1610
+ * While a structured region streams, the server announces what it thinks the
1611
+ * region IS and what has arrived so far, so the UI fills in progressively
1612
+ * instead of showing a spinner until the closing brace. Three events, a CLOSED
1613
+ * union on `state`, all riding `metadata.__ir_partial` on the `render_block`
1614
+ * events this app already receives:
1615
+ *
1616
+ * partial — repeatable. A provisional instance whose `root.value` is
1617
+ * VALID, CLOSED JSON (the server truncates and closes it, so
1618
+ * this side never repairs or guesses). `kindState` is
1619
+ * "speculative": it MAY still turn out to be something else.
1620
+ * superseded — TERMINAL. The region completed as the announced kind; drop
1621
+ * the provisional render, the block's own content/`__ir` is the
1622
+ * truth.
1623
+ * retracted — TERMINAL escape hatch. Detection was wrong; `becameKind` /
1624
+ * `becameBlockType` name what it actually is. Never a silent
1625
+ * swap.
1626
+ *
1627
+ * WHY IT IS NOT ON `__ir`
1628
+ * -----------------------
1629
+ * `__ir` means "validated against the registered schema", and a valid `__ir`
1630
+ * is SEEDED into the fingerprint-keyed envelope memo. A provisional value
1631
+ * there would poison every later read of that region. The two channels never
1632
+ * touch: `classifyInboundEnvelopeMetadata` sees `absent` for a partial and
1633
+ * passes the metadata through by reference.
1634
+ *
1635
+ * Pure kernel module: types + validators only. No React, no Redux, no IO.
1636
+ * Lives in @ai-matrx/content-ir `wire/` so EVERY UI (Matrix, Workflow Studio,
1637
+ * the dashboard, the Chrome extension, the desktop app) reads the channel
1638
+ * through the same reader.
1639
+ */
1640
+
1641
+ /** The reserved metadata key carrying every event of this contract. */
1642
+ declare const IR_PARTIAL_KEY: "__ir_partial";
1643
+ type PartialKindState = "partial" | "superseded" | "retracted";
1644
+ /** The provisional node. Deliberately `IrStructuredNode`-shaped so existing IR readers work. */
1645
+ interface PartialKindNode {
1646
+ role: "structured";
1647
+ /** The server's DETECTION GUESS for this region. */
1648
+ kind: string;
1649
+ /** Always "speculative" on a partial — pre-recognition, not a resolved kind. */
1650
+ kindState: "speculative";
1651
+ discriminator: IrDiscriminator;
1652
+ path: IrPath;
1653
+ status: "streaming";
1654
+ /**
1655
+ * Valid, closed JSON carrying its own `__kind`. MAY be missing required
1656
+ * schema fields — that is what `partial_unvalidated` in `residue.notices`
1657
+ * says. A renderer that throws on an absent field is not partial-ready and
1658
+ * must not be routed a provisional value.
1659
+ */
1660
+ value: Record<string, unknown>;
1661
+ residue: IrResidue | null;
1662
+ }
1663
+ interface PartialKindEvent {
1664
+ v: typeof IR_VERSION;
1665
+ engine: string;
1666
+ state: "partial";
1667
+ /** Monotonic PER BLOCK — the ordering / staleness key. Keep the highest. */
1668
+ seq: number;
1669
+ fingerprint: string;
1670
+ root: PartialKindNode;
1671
+ }
1672
+ interface SupersededKindEvent {
1673
+ v: typeof IR_VERSION;
1674
+ engine: string;
1675
+ state: "superseded";
1676
+ seq: number;
1677
+ kind: string;
1678
+ }
1679
+ interface RetractedKindEvent {
1680
+ v: typeof IR_VERSION;
1681
+ engine: string;
1682
+ state: "retracted";
1683
+ seq: number;
1684
+ /** The kind that was WRONGLY announced. */
1685
+ kind: string;
1686
+ reason: string;
1687
+ /** What it actually is — null when it resolved to no registered kind. */
1688
+ becameKind: string | null;
1689
+ /** The detector's final block type, so a consumer re-routes without guessing. */
1690
+ becameBlockType: string | null;
1691
+ }
1692
+ type AnyPartialKindEvent = PartialKindEvent | SupersededKindEvent | RetractedKindEvent;
1693
+ /**
1694
+ * Read + validate a partial-channel event off a block's metadata.
1695
+ *
1696
+ * Returns null for anything malformed, foreign, or of an unknown `state`. A
1697
+ * malformed partial degrades to "no live rendering" — never to a wrong render,
1698
+ * and never to a thrown error inside a stream handler.
1699
+ */
1700
+ declare function readPartialKindEvent(metadata: Record<string, unknown> | null | undefined): AnyPartialKindEvent | null;
1701
+ /**
1702
+ * Ingest guard for the partial channel on a `render_block` event — the twin of
1703
+ * `sanitizeInboundEnvelopeMetadata` for `__ir`, and it exists for the same
1704
+ * reason: a malformed server event must be stripped at the wire boundary, not
1705
+ * carried into Redux where every later reader has to re-decide whether to
1706
+ * trust it.
1707
+ *
1708
+ * - no `__ir_partial` key → the SAME metadata reference back (zero-touch).
1709
+ * - valid event → the SAME metadata reference back (idempotence law).
1710
+ * - malformed → a COPY with the key stripped, plus a loud `reportMalformed`.
1711
+ * Dropping it degrades that block to "no live rendering" and nothing more.
1712
+ *
1713
+ * Pure: the host injects the reporter, exactly like the envelope gate, so
1714
+ * aidream's Workflow Studio can bind its own.
1715
+ */
1716
+ declare function sanitizeInboundPartialKindMetadata(metadata: Record<string, unknown> | null | undefined, context: {
1717
+ blockId: string;
1718
+ }, hooks?: {
1719
+ reportMalformed?: (info: {
1720
+ blockId: string;
1721
+ raw: unknown;
1722
+ }) => void;
1723
+ }): Record<string, unknown> | undefined;
1724
+ /** Narrowing helper: is this the repeatable provisional event? */
1725
+ declare function isProvisionalKind(event: AnyPartialKindEvent | null): event is PartialKindEvent;
1726
+ /**
1727
+ * Narrowing helper: is this a TERMINAL event? Every partial ends in exactly
1728
+ * one of these — that law is what makes a stuck skeleton impossible, so a
1729
+ * consumer clears its provisional render here and nowhere else.
1730
+ */
1731
+ declare function isTerminalKindEvent(event: AnyPartialKindEvent | null): event is SupersededKindEvent | RetractedKindEvent;
1732
+ /**
1733
+ * Per-block staleness gate. Events can be re-dispatched, replayed on reconnect,
1734
+ * or arrive out of order; only a strictly higher `seq` advances a block.
1735
+ * Returns null when the event should be ignored.
1736
+ *
1737
+ * Pure: the caller owns the `seen` map, so this composes into a reducer
1738
+ * without hiding module state.
1739
+ */
1740
+ declare function advancePartialKind(seen: Record<string, number>, blockId: string, event: AnyPartialKindEvent | null): AnyPartialKindEvent | null;
1741
+ /**
1742
+ * The per-block staleness GATE, as a stateful closure over `advancePartialKind`
1743
+ * — one per stream.
1744
+ *
1745
+ * `upsertRenderBlock` REPLACES the stored block, so an event landing on a block
1746
+ * would regress what the user is looking at (a filled-in quiz snapping back to
1747
+ * two questions, or a terminal being undone by a late `partial`). The highest
1748
+ * accepted event is CARRIED FORWARD rather than dropped, so it is a no-op on
1749
+ * screen instead of a flicker back to the skeleton.
1750
+ *
1751
+ * 🚨 TWO arrivals must be carried, and the second one is the common case:
1752
+ *
1753
+ * 1. A STALE key — a replay or an out-of-order event (`seq <= last`).
1754
+ * 2. **NO key at all.** The producer clears `__ir_partial` at the top of every
1755
+ * stamp and re-adds it only when the value genuinely advanced
1756
+ * (`stream_processor.py::_stamp_partial` → `_partials.advanced(...)`), so
1757
+ * it is CORRECT for it to omit the key — re-shipping an identical payload
1758
+ * every token is pure wire cost. But the block still ships whole, and
1759
+ * replacing the stored block with one that has no partial metadata is what
1760
+ * made the provisional render vanish between advances: every non-advancing
1761
+ * token dropped the user back to the pending skeleton.
1762
+ *
1763
+ * Carrying stops at the TERMINAL, and only there. After `superseded` /
1764
+ * `retracted` the region's truth is its own content or `__ir`, so resurrecting
1765
+ * a provisional value would be a lie that outlives its own contract.
1766
+ *
1767
+ * Returns the metadata to store: the same reference when nothing changed, a
1768
+ * copy with the carried-forward event otherwise.
1769
+ */
1770
+ declare function makePartialKindStalenessGate(): (blockId: string, metadata: Record<string, unknown> | undefined) => Record<string, unknown> | undefined;
1771
+
1772
+ /**
1773
+ * Runtime wrapper kinds — the reader, and THE elision gate.
1774
+ *
1775
+ * Cross-repo contract (system of record):
1776
+ * `common-docs/systems/content-ir-system/RUNTIME_WRAPPER_WIRE.md`.
1777
+ *
1778
+ * A runtime wrapper is the CLOSED set of envelopes that carry instance
1779
+ * context with a data kind NESTED inside: `node_outcome` (one settled node
1780
+ * invocation) and `run_result` (one terminated run, nesting one
1781
+ * `node_outcome` per terminal node). `tool_result` is registered server-side
1782
+ * but nothing emits it yet, so nothing here reads it.
1783
+ *
1784
+ * ## THE ELISION RULE — do it ONCE, here
1785
+ *
1786
+ * The payload is NEVER sent twice. On the wire `output` is `null` and
1787
+ * `output_ref` names the FRAME field that already holds the value:
1788
+ *
1789
+ * - `"output"` → the frame's own `output` (`node_completed.output`,
1790
+ * the run row's `output`).
1791
+ * - `"output.<node_id>"` → that key of the frame's terminal output map.
1792
+ *
1793
+ * PRESENCE OF `output_ref` IS THE MARKER. A bare `output: null` with NO ref is
1794
+ * a legitimately empty payload — never an elision, never something to go
1795
+ * looking for. This is the same rule the `__ir` envelope follows with
1796
+ * `value_ref`, for the same reason: otherwise every payload is serialized
1797
+ * twice per streamed event, twice per durable row and twice per run read.
1798
+ *
1799
+ * Rehydration happens at the single INGEST GATE (each host's one ingest point —
1800
+ * Matrix's workflow-runs reducer, the Studio's inbound-envelope gate),
1801
+ * before anything reads the wrapper. No renderer, selector or component ever
1802
+ * sees an un-rehydrated wrapper, so none of them may re-implement this.
1803
+ *
1804
+ * ## Never load-bearing
1805
+ *
1806
+ * Assembly is a pure read. A malformed wrapper yields `null` and the frame's
1807
+ * own fields carry the surface exactly as they did before the wrapper
1808
+ * existed — additive on the wire, additive here.
1809
+ */
1810
+ /** The registered slugs — named once, never spelled by hand elsewhere. */
1811
+ declare const NODE_OUTCOME_KIND = "node_outcome";
1812
+ declare const RUN_RESULT_KIND = "run_result";
1813
+ /** One settled node invocation, with its data kind nested in `output`. */
1814
+ interface NodeOutcomeWrapper {
1815
+ __kind: typeof NODE_OUTCOME_KIND;
1816
+ run_id: string;
1817
+ node_id: string;
1818
+ workflow_id: string | null;
1819
+ step: number | null;
1820
+ attempt: number;
1821
+ status: string;
1822
+ started_at: string | null;
1823
+ ended_at: string | null;
1824
+ /** `0` is a REAL duration, not "unknown"; `null` is unknown. */
1825
+ duration_ms: number | null;
1826
+ /** null = the node declared no kind (a loud defect, never a pass). */
1827
+ output_kind: string | null;
1828
+ /** null = never checked / degraded — NEVER renderable as a pass. */
1829
+ output_kind_ok: boolean | null;
1830
+ output_kind_errors: string[] | null;
1831
+ /** Rehydrated by {@link rehydrateNodeOutcome}; null = genuinely empty. */
1832
+ output: unknown;
1833
+ }
1834
+ /** One terminated run. `outputs` is one wrapper per TERMINAL node. */
1835
+ interface RunResultWrapper {
1836
+ __kind: typeof RUN_RESULT_KIND;
1837
+ run_id: string;
1838
+ workflow_id: string | null;
1839
+ status: string;
1840
+ started_at: string | null;
1841
+ ended_at: string | null;
1842
+ duration_ms: number | null;
1843
+ output_kind: string | null;
1844
+ output: unknown;
1845
+ outputs: NodeOutcomeWrapper[];
1846
+ }
1847
+ /**
1848
+ * Resolve a dotted `output_ref` against the frame that carries the payload.
1849
+ * Returns `undefined` when the path does not resolve — the caller keeps
1850
+ * `output: null` rather than inventing a value.
1851
+ */
1852
+ declare function readOutputRef(frame: unknown, ref: string): unknown;
1853
+ /**
1854
+ * Read a `node_outcome` off a frame and rehydrate its elided payload.
1855
+ *
1856
+ * `frame` is the object the wrapper travelled ON — the `node_completed` event,
1857
+ * or the run read response for a `run_result`'s children. Returns null for
1858
+ * anything that is not a node_outcome (including a missing wrapper: the
1859
+ * producer fails OPEN, so an absent wrapper is a normal, non-fatal state).
1860
+ */
1861
+ declare function rehydrateNodeOutcome(raw: unknown, frame: unknown): NodeOutcomeWrapper | null;
1862
+ /**
1863
+ * Read an ALREADY-REHYDRATED node_outcome value into its typed form.
1864
+ *
1865
+ * Deliberately does NOT require `__kind`: the render bridge strips the root
1866
+ * discriminator before the component sees the value, and it does NOT touch
1867
+ * `output_ref` — by the time anything renders, the ingest gate has already
1868
+ * resolved the elision, and a second resolution attempt against a frame that
1869
+ * is no longer there is how a payload goes missing.
1870
+ */
1871
+ declare function readNodeOutcomeValue(raw: unknown): NodeOutcomeWrapper | null;
1872
+ /**
1873
+ * Read a `run_result` off the run read response and rehydrate every elided
1874
+ * payload — its own, and each terminal node's. Both resolve against the SAME
1875
+ * frame (the run read response), which is what `"output.<node_id>"` addresses.
1876
+ */
1877
+ declare function rehydrateRunResult(raw: unknown, frame: unknown): RunResultWrapper | null;
1878
+ /**
1879
+ * Read an ALREADY-REHYDRATED run_result value into its typed form. Same
1880
+ * contract as {@link readNodeOutcomeValue}: no `__kind` requirement, no
1881
+ * second elision pass.
1882
+ */
1883
+ declare function readRunResultValue(raw: unknown): RunResultWrapper | null;
1884
+ /**
1885
+ * The kind verdict, as three states the UI must keep distinct.
1886
+ *
1887
+ * `unchecked` is NEVER a pass: the engine either did not check (no declared
1888
+ * kind) or checked and could not conclude. Collapsing it into "ok" is how a
1889
+ * confidently-rendered document gets shown for a shape nobody verified.
1890
+ */
1891
+ type KindVerdict = "passed" | "failed" | "unchecked";
1892
+ declare function kindVerdictOf(wrapper: {
1893
+ output_kind: string | null;
1894
+ output_kind_ok: boolean | null;
1895
+ }): KindVerdict;
1896
+
1897
+ /**
1898
+ * The forward composer: given a kind's stored example, produce the EMIT/RENDER
1899
+ * payload — `{ "__kind": <slug>, ...data }`.
1900
+ *
1901
+ * Pure kernel module (@ai-matrx/content-ir `wire/`): no React, no Redux, no IO.
1902
+ *
1903
+ * Since 2026-08-23 stored examples and instances ALREADY carry their marker
1904
+ * (`__kind` is part of the data — KINDS_EVERYWHERE_PLAN §4.2), so for a
1905
+ * well-formed row this is an IDENTITY with a guarantee attached: the marker is
1906
+ * the FIRST key and it names the right slug. It stays because it is also the
1907
+ * repair for the legacy rows and hand-typed values that do not, and because a
1908
+ * caller wanting a copy-ready render payload should not have to know which it
1909
+ * has.
1910
+ *
1911
+ * Scalars/arrays are returned unchanged — for those kinds the identity travels
1912
+ * out of band (`root.kind`); there is no key to add.
1913
+ */
1914
+ declare function withRootKind(kind: string, value: unknown): unknown;
1915
+ /** The copy-ready render payload: pretty JSON of `{ __kind, ...data }`. */
1916
+ declare function emitPayloadJson(kind: string, value: unknown): string;
1917
+ /**
1918
+ * The copy-ready render BLOCK — the render payload inside a ```json fence, the
1919
+ * exact form an agent emits and a user pastes into a prompt or a message to see
1920
+ * it render live.
1921
+ */
1922
+ declare function emitPayloadFence(kind: string, value: unknown): string;
1923
+
1924
+ export { type AnyPartialKindEvent, type ArrayItemKindBinding, type ArrayItemScalarType, type BlockSchemaDraft, type CanonicalBlockIR, type CanonicalContent, type CanonicalSegment, type CompleteValueEnvelopeOptions, type CompliantKindSnapshot, type ContentRegionInit, type ConversionProblem, type DroppedMetadata, type DualGateDefinition, type DualGateInput, type DualGateResolvedComponent, type DualGateResult, type FieldComparison, type FieldSchema, type Fingerprinter, IR_ENVELOPE_CACHE_VERSION, IR_ENVELOPE_KEY, IR_PARTIAL_KEY, IR_VERSION, type InboundEnvelopeHooks, type InboundEnvelopeVerdict, type IrDiscriminator, type IrEnvelopeCache, type IrKindState, type IrPath, type IrResidue, type IrStructuredNode, IrTree, type IrTreeNode, type ItemKindRefCheck, JSON_DISCRIMINATOR, type JsonPath, type JsonSchemaNode, JsonStreamTokenizer, type JsonToken, KIND_KEY, type KindBlockProps, type KindDefinition, type KindEdgeSpec, type KindJsonSchemaExport, type KindJsonSchemaOptions, type KindResolution, type KindSchema, KindStorageError, type KindStorageShape, type KindStreamEvent, KindStreamParser, type KindStreamParserOptions, type KindTier, type KindVerdict, type LegResult, NODE_OUTCOME_KIND, type NodeOutcomeWrapper, type NormalizeJsonRegionOptions, ParseSession, type ParseSessionOptions, type PartialKindEvent, type PartialKindNode, type PartialKindState, type Punct, ROOT_STORAGE_NAME, RUN_RESULT_KIND, type RecordValueType, type RegionEndReason, type RegionFormat, type RegionSourceKind, type RetractedKindEvent, type RunResultWrapper, type SavePlanEntry, type SavePlanValidation, type ScalarFieldType, type SchemaConversionResult, type SchemaLayoutMode, type SchemaResolver, type StoredFieldElement, type SupersededKindEvent, advancePartialKind, buildAgentSchemaWithRenderBlockSupport, buildCompliantKindSnapshot, classifyInboundEnvelopeMetadata, collectReferencedKinds, collectSchemaReferencedKinds, compareWithExistingKindSchema, convertAiSchemaToBlockFields, createFingerprinter, createKindStreamParser, describeDualGateFailure, disposeParseSession, emitPayloadFence, emitPayloadJson, emptyValueForFieldSchema, envelopeCacheFromEnvelopes, envelopeFromCompleteValue, fenceDiscriminator, fieldsToDbPayload, fingerprintText, formatBlockLabel, getParseSession, injectKindIntoObjectSchema, irPathIsUnderOrEqual, irPathKey, irPathLabel, irPathsEqual, isCanonicalBlockIR, isDuplicateBlockSlug, isEmptyResidue, isIrEnvelopeCache, isJsonAnyField, isProvisionalKind, isScalarArrayType, isTerminalKindEvent, kindSchemaToJsonSchema, kindSchemaToStorage, kindVerdictOf, makePartialKindStalenessGate, mergeResidueIntoValue, normalizeAiSchemaInput, normalizeJsonRegion, openParseSession, readEnvelope, readNodeOutcomeValue, readObjectKind, readOutputRef, readPartialKindEvent, readRunResultValue, reconstructRegionValue, rehydrateNodeOutcome, rehydrateRunResult, reuseEnvelopeIfCurrent, runKindDualGate, runSchemaConversion, sanitizeInboundEnvelopeMetadata, sanitizeInboundPartialKindMetadata, scalarArrayItemType, schemaLayoutMode, schemaStructureDepth, setJsonRootKeyLookup, storageToKindSchema, stripKindDeep, validateBlockSchemaSavePlan, validateStructuralLeg, withRootKind, xmlDiscriminator };
package/dist/index.d.ts CHANGED
@@ -1598,4 +1598,327 @@ declare function collectReferencedKinds(fields: Record<string, FieldSchema>): st
1598
1598
  declare function collectSchemaReferencedKinds(schema: KindSchema): string[];
1599
1599
  declare function kindSchemaToJsonSchema(kind: string, resolve: (kind: string) => KindSchema | undefined, options?: KindJsonSchemaOptions): KindJsonSchemaExport | null;
1600
1600
 
1601
- export { type ArrayItemKindBinding, type ArrayItemScalarType, type BlockSchemaDraft, type CanonicalBlockIR, type CanonicalContent, type CanonicalSegment, type CompleteValueEnvelopeOptions, type CompliantKindSnapshot, type ContentRegionInit, type ConversionProblem, type DroppedMetadata, type DualGateDefinition, type DualGateInput, type DualGateResolvedComponent, type DualGateResult, type FieldComparison, type FieldSchema, type Fingerprinter, IR_ENVELOPE_CACHE_VERSION, IR_ENVELOPE_KEY, IR_VERSION, type InboundEnvelopeHooks, type InboundEnvelopeVerdict, type IrDiscriminator, type IrEnvelopeCache, type IrKindState, type IrPath, type IrResidue, type IrStructuredNode, IrTree, type IrTreeNode, type ItemKindRefCheck, JSON_DISCRIMINATOR, type JsonPath, type JsonSchemaNode, JsonStreamTokenizer, type JsonToken, KIND_KEY, type KindBlockProps, type KindDefinition, type KindEdgeSpec, type KindJsonSchemaExport, type KindJsonSchemaOptions, type KindResolution, type KindSchema, KindStorageError, type KindStorageShape, type KindStreamEvent, KindStreamParser, type KindStreamParserOptions, type KindTier, type LegResult, type NormalizeJsonRegionOptions, ParseSession, type ParseSessionOptions, type Punct, ROOT_STORAGE_NAME, type RecordValueType, type RegionEndReason, type RegionFormat, type RegionSourceKind, type SavePlanEntry, type SavePlanValidation, type ScalarFieldType, type SchemaConversionResult, type SchemaLayoutMode, type SchemaResolver, type StoredFieldElement, buildAgentSchemaWithRenderBlockSupport, buildCompliantKindSnapshot, classifyInboundEnvelopeMetadata, collectReferencedKinds, collectSchemaReferencedKinds, compareWithExistingKindSchema, convertAiSchemaToBlockFields, createFingerprinter, createKindStreamParser, describeDualGateFailure, disposeParseSession, emptyValueForFieldSchema, envelopeCacheFromEnvelopes, envelopeFromCompleteValue, fenceDiscriminator, fieldsToDbPayload, fingerprintText, formatBlockLabel, getParseSession, injectKindIntoObjectSchema, irPathIsUnderOrEqual, irPathKey, irPathLabel, irPathsEqual, isCanonicalBlockIR, isDuplicateBlockSlug, isEmptyResidue, isIrEnvelopeCache, isJsonAnyField, isScalarArrayType, kindSchemaToJsonSchema, kindSchemaToStorage, mergeResidueIntoValue, normalizeAiSchemaInput, normalizeJsonRegion, openParseSession, readEnvelope, readObjectKind, reconstructRegionValue, reuseEnvelopeIfCurrent, runKindDualGate, runSchemaConversion, sanitizeInboundEnvelopeMetadata, scalarArrayItemType, schemaLayoutMode, schemaStructureDepth, setJsonRootKeyLookup, storageToKindSchema, stripKindDeep, validateBlockSchemaSavePlan, validateStructuralLeg, xmlDiscriminator };
1601
+ /**
1602
+ * Streaming partial kinds — the TS twin of the Python producer's contract.
1603
+ *
1604
+ * Cross-repo system-of-record (read it before changing anything here):
1605
+ * `common-docs/systems/content-ir-system/STREAMING_PARTIAL_KINDS.md`.
1606
+ * Python twin: `aidream/packages/matrx-graph/matrx_graph/content_ir/partial.py`.
1607
+ *
1608
+ * WHAT THIS IS
1609
+ * ------------
1610
+ * While a structured region streams, the server announces what it thinks the
1611
+ * region IS and what has arrived so far, so the UI fills in progressively
1612
+ * instead of showing a spinner until the closing brace. Three events, a CLOSED
1613
+ * union on `state`, all riding `metadata.__ir_partial` on the `render_block`
1614
+ * events this app already receives:
1615
+ *
1616
+ * partial — repeatable. A provisional instance whose `root.value` is
1617
+ * VALID, CLOSED JSON (the server truncates and closes it, so
1618
+ * this side never repairs or guesses). `kindState` is
1619
+ * "speculative": it MAY still turn out to be something else.
1620
+ * superseded — TERMINAL. The region completed as the announced kind; drop
1621
+ * the provisional render, the block's own content/`__ir` is the
1622
+ * truth.
1623
+ * retracted — TERMINAL escape hatch. Detection was wrong; `becameKind` /
1624
+ * `becameBlockType` name what it actually is. Never a silent
1625
+ * swap.
1626
+ *
1627
+ * WHY IT IS NOT ON `__ir`
1628
+ * -----------------------
1629
+ * `__ir` means "validated against the registered schema", and a valid `__ir`
1630
+ * is SEEDED into the fingerprint-keyed envelope memo. A provisional value
1631
+ * there would poison every later read of that region. The two channels never
1632
+ * touch: `classifyInboundEnvelopeMetadata` sees `absent` for a partial and
1633
+ * passes the metadata through by reference.
1634
+ *
1635
+ * Pure kernel module: types + validators only. No React, no Redux, no IO.
1636
+ * Lives in @ai-matrx/content-ir `wire/` so EVERY UI (Matrix, Workflow Studio,
1637
+ * the dashboard, the Chrome extension, the desktop app) reads the channel
1638
+ * through the same reader.
1639
+ */
1640
+
1641
+ /** The reserved metadata key carrying every event of this contract. */
1642
+ declare const IR_PARTIAL_KEY: "__ir_partial";
1643
+ type PartialKindState = "partial" | "superseded" | "retracted";
1644
+ /** The provisional node. Deliberately `IrStructuredNode`-shaped so existing IR readers work. */
1645
+ interface PartialKindNode {
1646
+ role: "structured";
1647
+ /** The server's DETECTION GUESS for this region. */
1648
+ kind: string;
1649
+ /** Always "speculative" on a partial — pre-recognition, not a resolved kind. */
1650
+ kindState: "speculative";
1651
+ discriminator: IrDiscriminator;
1652
+ path: IrPath;
1653
+ status: "streaming";
1654
+ /**
1655
+ * Valid, closed JSON carrying its own `__kind`. MAY be missing required
1656
+ * schema fields — that is what `partial_unvalidated` in `residue.notices`
1657
+ * says. A renderer that throws on an absent field is not partial-ready and
1658
+ * must not be routed a provisional value.
1659
+ */
1660
+ value: Record<string, unknown>;
1661
+ residue: IrResidue | null;
1662
+ }
1663
+ interface PartialKindEvent {
1664
+ v: typeof IR_VERSION;
1665
+ engine: string;
1666
+ state: "partial";
1667
+ /** Monotonic PER BLOCK — the ordering / staleness key. Keep the highest. */
1668
+ seq: number;
1669
+ fingerprint: string;
1670
+ root: PartialKindNode;
1671
+ }
1672
+ interface SupersededKindEvent {
1673
+ v: typeof IR_VERSION;
1674
+ engine: string;
1675
+ state: "superseded";
1676
+ seq: number;
1677
+ kind: string;
1678
+ }
1679
+ interface RetractedKindEvent {
1680
+ v: typeof IR_VERSION;
1681
+ engine: string;
1682
+ state: "retracted";
1683
+ seq: number;
1684
+ /** The kind that was WRONGLY announced. */
1685
+ kind: string;
1686
+ reason: string;
1687
+ /** What it actually is — null when it resolved to no registered kind. */
1688
+ becameKind: string | null;
1689
+ /** The detector's final block type, so a consumer re-routes without guessing. */
1690
+ becameBlockType: string | null;
1691
+ }
1692
+ type AnyPartialKindEvent = PartialKindEvent | SupersededKindEvent | RetractedKindEvent;
1693
+ /**
1694
+ * Read + validate a partial-channel event off a block's metadata.
1695
+ *
1696
+ * Returns null for anything malformed, foreign, or of an unknown `state`. A
1697
+ * malformed partial degrades to "no live rendering" — never to a wrong render,
1698
+ * and never to a thrown error inside a stream handler.
1699
+ */
1700
+ declare function readPartialKindEvent(metadata: Record<string, unknown> | null | undefined): AnyPartialKindEvent | null;
1701
+ /**
1702
+ * Ingest guard for the partial channel on a `render_block` event — the twin of
1703
+ * `sanitizeInboundEnvelopeMetadata` for `__ir`, and it exists for the same
1704
+ * reason: a malformed server event must be stripped at the wire boundary, not
1705
+ * carried into Redux where every later reader has to re-decide whether to
1706
+ * trust it.
1707
+ *
1708
+ * - no `__ir_partial` key → the SAME metadata reference back (zero-touch).
1709
+ * - valid event → the SAME metadata reference back (idempotence law).
1710
+ * - malformed → a COPY with the key stripped, plus a loud `reportMalformed`.
1711
+ * Dropping it degrades that block to "no live rendering" and nothing more.
1712
+ *
1713
+ * Pure: the host injects the reporter, exactly like the envelope gate, so
1714
+ * aidream's Workflow Studio can bind its own.
1715
+ */
1716
+ declare function sanitizeInboundPartialKindMetadata(metadata: Record<string, unknown> | null | undefined, context: {
1717
+ blockId: string;
1718
+ }, hooks?: {
1719
+ reportMalformed?: (info: {
1720
+ blockId: string;
1721
+ raw: unknown;
1722
+ }) => void;
1723
+ }): Record<string, unknown> | undefined;
1724
+ /** Narrowing helper: is this the repeatable provisional event? */
1725
+ declare function isProvisionalKind(event: AnyPartialKindEvent | null): event is PartialKindEvent;
1726
+ /**
1727
+ * Narrowing helper: is this a TERMINAL event? Every partial ends in exactly
1728
+ * one of these — that law is what makes a stuck skeleton impossible, so a
1729
+ * consumer clears its provisional render here and nowhere else.
1730
+ */
1731
+ declare function isTerminalKindEvent(event: AnyPartialKindEvent | null): event is SupersededKindEvent | RetractedKindEvent;
1732
+ /**
1733
+ * Per-block staleness gate. Events can be re-dispatched, replayed on reconnect,
1734
+ * or arrive out of order; only a strictly higher `seq` advances a block.
1735
+ * Returns null when the event should be ignored.
1736
+ *
1737
+ * Pure: the caller owns the `seen` map, so this composes into a reducer
1738
+ * without hiding module state.
1739
+ */
1740
+ declare function advancePartialKind(seen: Record<string, number>, blockId: string, event: AnyPartialKindEvent | null): AnyPartialKindEvent | null;
1741
+ /**
1742
+ * The per-block staleness GATE, as a stateful closure over `advancePartialKind`
1743
+ * — one per stream.
1744
+ *
1745
+ * `upsertRenderBlock` REPLACES the stored block, so an event landing on a block
1746
+ * would regress what the user is looking at (a filled-in quiz snapping back to
1747
+ * two questions, or a terminal being undone by a late `partial`). The highest
1748
+ * accepted event is CARRIED FORWARD rather than dropped, so it is a no-op on
1749
+ * screen instead of a flicker back to the skeleton.
1750
+ *
1751
+ * 🚨 TWO arrivals must be carried, and the second one is the common case:
1752
+ *
1753
+ * 1. A STALE key — a replay or an out-of-order event (`seq <= last`).
1754
+ * 2. **NO key at all.** The producer clears `__ir_partial` at the top of every
1755
+ * stamp and re-adds it only when the value genuinely advanced
1756
+ * (`stream_processor.py::_stamp_partial` → `_partials.advanced(...)`), so
1757
+ * it is CORRECT for it to omit the key — re-shipping an identical payload
1758
+ * every token is pure wire cost. But the block still ships whole, and
1759
+ * replacing the stored block with one that has no partial metadata is what
1760
+ * made the provisional render vanish between advances: every non-advancing
1761
+ * token dropped the user back to the pending skeleton.
1762
+ *
1763
+ * Carrying stops at the TERMINAL, and only there. After `superseded` /
1764
+ * `retracted` the region's truth is its own content or `__ir`, so resurrecting
1765
+ * a provisional value would be a lie that outlives its own contract.
1766
+ *
1767
+ * Returns the metadata to store: the same reference when nothing changed, a
1768
+ * copy with the carried-forward event otherwise.
1769
+ */
1770
+ declare function makePartialKindStalenessGate(): (blockId: string, metadata: Record<string, unknown> | undefined) => Record<string, unknown> | undefined;
1771
+
1772
+ /**
1773
+ * Runtime wrapper kinds — the reader, and THE elision gate.
1774
+ *
1775
+ * Cross-repo contract (system of record):
1776
+ * `common-docs/systems/content-ir-system/RUNTIME_WRAPPER_WIRE.md`.
1777
+ *
1778
+ * A runtime wrapper is the CLOSED set of envelopes that carry instance
1779
+ * context with a data kind NESTED inside: `node_outcome` (one settled node
1780
+ * invocation) and `run_result` (one terminated run, nesting one
1781
+ * `node_outcome` per terminal node). `tool_result` is registered server-side
1782
+ * but nothing emits it yet, so nothing here reads it.
1783
+ *
1784
+ * ## THE ELISION RULE — do it ONCE, here
1785
+ *
1786
+ * The payload is NEVER sent twice. On the wire `output` is `null` and
1787
+ * `output_ref` names the FRAME field that already holds the value:
1788
+ *
1789
+ * - `"output"` → the frame's own `output` (`node_completed.output`,
1790
+ * the run row's `output`).
1791
+ * - `"output.<node_id>"` → that key of the frame's terminal output map.
1792
+ *
1793
+ * PRESENCE OF `output_ref` IS THE MARKER. A bare `output: null` with NO ref is
1794
+ * a legitimately empty payload — never an elision, never something to go
1795
+ * looking for. This is the same rule the `__ir` envelope follows with
1796
+ * `value_ref`, for the same reason: otherwise every payload is serialized
1797
+ * twice per streamed event, twice per durable row and twice per run read.
1798
+ *
1799
+ * Rehydration happens at the single INGEST GATE (each host's one ingest point —
1800
+ * Matrix's workflow-runs reducer, the Studio's inbound-envelope gate),
1801
+ * before anything reads the wrapper. No renderer, selector or component ever
1802
+ * sees an un-rehydrated wrapper, so none of them may re-implement this.
1803
+ *
1804
+ * ## Never load-bearing
1805
+ *
1806
+ * Assembly is a pure read. A malformed wrapper yields `null` and the frame's
1807
+ * own fields carry the surface exactly as they did before the wrapper
1808
+ * existed — additive on the wire, additive here.
1809
+ */
1810
+ /** The registered slugs — named once, never spelled by hand elsewhere. */
1811
+ declare const NODE_OUTCOME_KIND = "node_outcome";
1812
+ declare const RUN_RESULT_KIND = "run_result";
1813
+ /** One settled node invocation, with its data kind nested in `output`. */
1814
+ interface NodeOutcomeWrapper {
1815
+ __kind: typeof NODE_OUTCOME_KIND;
1816
+ run_id: string;
1817
+ node_id: string;
1818
+ workflow_id: string | null;
1819
+ step: number | null;
1820
+ attempt: number;
1821
+ status: string;
1822
+ started_at: string | null;
1823
+ ended_at: string | null;
1824
+ /** `0` is a REAL duration, not "unknown"; `null` is unknown. */
1825
+ duration_ms: number | null;
1826
+ /** null = the node declared no kind (a loud defect, never a pass). */
1827
+ output_kind: string | null;
1828
+ /** null = never checked / degraded — NEVER renderable as a pass. */
1829
+ output_kind_ok: boolean | null;
1830
+ output_kind_errors: string[] | null;
1831
+ /** Rehydrated by {@link rehydrateNodeOutcome}; null = genuinely empty. */
1832
+ output: unknown;
1833
+ }
1834
+ /** One terminated run. `outputs` is one wrapper per TERMINAL node. */
1835
+ interface RunResultWrapper {
1836
+ __kind: typeof RUN_RESULT_KIND;
1837
+ run_id: string;
1838
+ workflow_id: string | null;
1839
+ status: string;
1840
+ started_at: string | null;
1841
+ ended_at: string | null;
1842
+ duration_ms: number | null;
1843
+ output_kind: string | null;
1844
+ output: unknown;
1845
+ outputs: NodeOutcomeWrapper[];
1846
+ }
1847
+ /**
1848
+ * Resolve a dotted `output_ref` against the frame that carries the payload.
1849
+ * Returns `undefined` when the path does not resolve — the caller keeps
1850
+ * `output: null` rather than inventing a value.
1851
+ */
1852
+ declare function readOutputRef(frame: unknown, ref: string): unknown;
1853
+ /**
1854
+ * Read a `node_outcome` off a frame and rehydrate its elided payload.
1855
+ *
1856
+ * `frame` is the object the wrapper travelled ON — the `node_completed` event,
1857
+ * or the run read response for a `run_result`'s children. Returns null for
1858
+ * anything that is not a node_outcome (including a missing wrapper: the
1859
+ * producer fails OPEN, so an absent wrapper is a normal, non-fatal state).
1860
+ */
1861
+ declare function rehydrateNodeOutcome(raw: unknown, frame: unknown): NodeOutcomeWrapper | null;
1862
+ /**
1863
+ * Read an ALREADY-REHYDRATED node_outcome value into its typed form.
1864
+ *
1865
+ * Deliberately does NOT require `__kind`: the render bridge strips the root
1866
+ * discriminator before the component sees the value, and it does NOT touch
1867
+ * `output_ref` — by the time anything renders, the ingest gate has already
1868
+ * resolved the elision, and a second resolution attempt against a frame that
1869
+ * is no longer there is how a payload goes missing.
1870
+ */
1871
+ declare function readNodeOutcomeValue(raw: unknown): NodeOutcomeWrapper | null;
1872
+ /**
1873
+ * Read a `run_result` off the run read response and rehydrate every elided
1874
+ * payload — its own, and each terminal node's. Both resolve against the SAME
1875
+ * frame (the run read response), which is what `"output.<node_id>"` addresses.
1876
+ */
1877
+ declare function rehydrateRunResult(raw: unknown, frame: unknown): RunResultWrapper | null;
1878
+ /**
1879
+ * Read an ALREADY-REHYDRATED run_result value into its typed form. Same
1880
+ * contract as {@link readNodeOutcomeValue}: no `__kind` requirement, no
1881
+ * second elision pass.
1882
+ */
1883
+ declare function readRunResultValue(raw: unknown): RunResultWrapper | null;
1884
+ /**
1885
+ * The kind verdict, as three states the UI must keep distinct.
1886
+ *
1887
+ * `unchecked` is NEVER a pass: the engine either did not check (no declared
1888
+ * kind) or checked and could not conclude. Collapsing it into "ok" is how a
1889
+ * confidently-rendered document gets shown for a shape nobody verified.
1890
+ */
1891
+ type KindVerdict = "passed" | "failed" | "unchecked";
1892
+ declare function kindVerdictOf(wrapper: {
1893
+ output_kind: string | null;
1894
+ output_kind_ok: boolean | null;
1895
+ }): KindVerdict;
1896
+
1897
+ /**
1898
+ * The forward composer: given a kind's stored example, produce the EMIT/RENDER
1899
+ * payload — `{ "__kind": <slug>, ...data }`.
1900
+ *
1901
+ * Pure kernel module (@ai-matrx/content-ir `wire/`): no React, no Redux, no IO.
1902
+ *
1903
+ * Since 2026-08-23 stored examples and instances ALREADY carry their marker
1904
+ * (`__kind` is part of the data — KINDS_EVERYWHERE_PLAN §4.2), so for a
1905
+ * well-formed row this is an IDENTITY with a guarantee attached: the marker is
1906
+ * the FIRST key and it names the right slug. It stays because it is also the
1907
+ * repair for the legacy rows and hand-typed values that do not, and because a
1908
+ * caller wanting a copy-ready render payload should not have to know which it
1909
+ * has.
1910
+ *
1911
+ * Scalars/arrays are returned unchanged — for those kinds the identity travels
1912
+ * out of band (`root.kind`); there is no key to add.
1913
+ */
1914
+ declare function withRootKind(kind: string, value: unknown): unknown;
1915
+ /** The copy-ready render payload: pretty JSON of `{ __kind, ...data }`. */
1916
+ declare function emitPayloadJson(kind: string, value: unknown): string;
1917
+ /**
1918
+ * The copy-ready render BLOCK — the render payload inside a ```json fence, the
1919
+ * exact form an agent emits and a user pastes into a prompt or a message to see
1920
+ * it render live.
1921
+ */
1922
+ declare function emitPayloadFence(kind: string, value: unknown): string;
1923
+
1924
+ export { type AnyPartialKindEvent, type ArrayItemKindBinding, type ArrayItemScalarType, type BlockSchemaDraft, type CanonicalBlockIR, type CanonicalContent, type CanonicalSegment, type CompleteValueEnvelopeOptions, type CompliantKindSnapshot, type ContentRegionInit, type ConversionProblem, type DroppedMetadata, type DualGateDefinition, type DualGateInput, type DualGateResolvedComponent, type DualGateResult, type FieldComparison, type FieldSchema, type Fingerprinter, IR_ENVELOPE_CACHE_VERSION, IR_ENVELOPE_KEY, IR_PARTIAL_KEY, IR_VERSION, type InboundEnvelopeHooks, type InboundEnvelopeVerdict, type IrDiscriminator, type IrEnvelopeCache, type IrKindState, type IrPath, type IrResidue, type IrStructuredNode, IrTree, type IrTreeNode, type ItemKindRefCheck, JSON_DISCRIMINATOR, type JsonPath, type JsonSchemaNode, JsonStreamTokenizer, type JsonToken, KIND_KEY, type KindBlockProps, type KindDefinition, type KindEdgeSpec, type KindJsonSchemaExport, type KindJsonSchemaOptions, type KindResolution, type KindSchema, KindStorageError, type KindStorageShape, type KindStreamEvent, KindStreamParser, type KindStreamParserOptions, type KindTier, type KindVerdict, type LegResult, NODE_OUTCOME_KIND, type NodeOutcomeWrapper, type NormalizeJsonRegionOptions, ParseSession, type ParseSessionOptions, type PartialKindEvent, type PartialKindNode, type PartialKindState, type Punct, ROOT_STORAGE_NAME, RUN_RESULT_KIND, type RecordValueType, type RegionEndReason, type RegionFormat, type RegionSourceKind, type RetractedKindEvent, type RunResultWrapper, type SavePlanEntry, type SavePlanValidation, type ScalarFieldType, type SchemaConversionResult, type SchemaLayoutMode, type SchemaResolver, type StoredFieldElement, type SupersededKindEvent, advancePartialKind, buildAgentSchemaWithRenderBlockSupport, buildCompliantKindSnapshot, classifyInboundEnvelopeMetadata, collectReferencedKinds, collectSchemaReferencedKinds, compareWithExistingKindSchema, convertAiSchemaToBlockFields, createFingerprinter, createKindStreamParser, describeDualGateFailure, disposeParseSession, emitPayloadFence, emitPayloadJson, emptyValueForFieldSchema, envelopeCacheFromEnvelopes, envelopeFromCompleteValue, fenceDiscriminator, fieldsToDbPayload, fingerprintText, formatBlockLabel, getParseSession, injectKindIntoObjectSchema, irPathIsUnderOrEqual, irPathKey, irPathLabel, irPathsEqual, isCanonicalBlockIR, isDuplicateBlockSlug, isEmptyResidue, isIrEnvelopeCache, isJsonAnyField, isProvisionalKind, isScalarArrayType, isTerminalKindEvent, kindSchemaToJsonSchema, kindSchemaToStorage, kindVerdictOf, makePartialKindStalenessGate, mergeResidueIntoValue, normalizeAiSchemaInput, normalizeJsonRegion, openParseSession, readEnvelope, readNodeOutcomeValue, readObjectKind, readOutputRef, readPartialKindEvent, readRunResultValue, reconstructRegionValue, rehydrateNodeOutcome, rehydrateRunResult, reuseEnvelopeIfCurrent, runKindDualGate, runSchemaConversion, sanitizeInboundEnvelopeMetadata, sanitizeInboundPartialKindMetadata, scalarArrayItemType, schemaLayoutMode, schemaStructureDepth, setJsonRootKeyLookup, storageToKindSchema, stripKindDeep, validateBlockSchemaSavePlan, validateStructuralLeg, withRootKind, xmlDiscriminator };