@ai-matrx/content-ir 0.2.0 โ†’ 0.2.2

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
@@ -392,7 +392,6 @@ type KindStreamParserOptions = {
392
392
  expectedRootKind?: string;
393
393
  };
394
394
  declare class KindStreamParser {
395
- private readonly options;
396
395
  private readonly resolver;
397
396
  private readonly stack;
398
397
  private readonly objectKinds;
@@ -427,6 +426,7 @@ declare class KindStreamParser {
427
426
  private rootKind;
428
427
  private rootDone;
429
428
  private failed;
429
+ private readonly options;
430
430
  constructor(options: KindStreamParserOptions);
431
431
  push(chunk: string): void;
432
432
  end(): void;
@@ -677,13 +677,13 @@ type JsonToken = {
677
677
  at: number;
678
678
  };
679
679
  declare class JsonStreamTokenizer {
680
- private readonly onToken;
681
680
  private mode;
682
681
  private pos;
683
682
  private stringBuffer;
684
683
  private primitiveBuffer;
685
684
  private unicodeBuffer;
686
685
  private tokenStart;
686
+ private readonly onToken;
687
687
  constructor(onToken: (token: JsonToken) => void);
688
688
  get position(): number;
689
689
  push(chunk: string): void;
@@ -950,7 +950,18 @@ declare function sanitizeInboundEnvelopeMetadata(metadata: Record<string, unknow
950
950
  * a schema knew about it.
951
951
  */
952
952
  declare function reconstructRegionValue(envelope: CanonicalBlockIR): Record<string, unknown>;
953
- /** Deep-remove the __kind discriminator (the parser injects it into snapshots). */
953
+ /**
954
+ * Deep-remove the `__kind` discriminator.
955
+ *
956
+ * ๐Ÿšจ NOT A TRANSFORM FOR PLATFORM DATA. `__kind` is part of the data
957
+ * (KINDS_EVERYWHERE_PLAN ยง4.2) and stripping it from anything stored, passed or
958
+ * rendered was annihilated on 2026-08-23. This helper survives for exactly two
959
+ * shapes of caller, both of which are guarded:
960
+ * - a SYMMETRIC COMPARISON that reduces both sides and returns a boolean;
961
+ * - legacy validation TOLERANCE against a pre-2026-08-23 schema version.
962
+ * Guards: aidream `scripts/check_kind_marker_law.py`,
963
+ * matrx-frontend `pnpm check:kind-marker-law`.
964
+ */
954
965
  declare function stripKindDeep(value: unknown): unknown;
955
966
 
956
967
  /**
@@ -1406,8 +1417,8 @@ interface DualGateResult {
1406
1417
  /**
1407
1418
  * The structural leg, exported on its own so the shape doctor
1408
1419
  * (`shape-doctor.ts`) RECOMPUTES gate validation with the exact same ajv
1409
- * config + `__kind`-stripping semantics as activation โ€” never a parallel
1410
- * validator. `sample` is `unknown` (not `Record`) because kind examples may
1420
+ * config + marker semantics as activation (verbatim first, marker-free retry
1421
+ * second) โ€” never a parallel validator. `sample` is `unknown` (not `Record`) because kind examples may
1411
1422
  * legitimately be scalars/arrays (workflow I/O kinds like `text`/`number`).
1412
1423
  */
1413
1424
  declare function validateStructuralLeg(sample: unknown, emittedJsonSchema: unknown): LegResult;
package/dist/index.d.ts CHANGED
@@ -392,7 +392,6 @@ type KindStreamParserOptions = {
392
392
  expectedRootKind?: string;
393
393
  };
394
394
  declare class KindStreamParser {
395
- private readonly options;
396
395
  private readonly resolver;
397
396
  private readonly stack;
398
397
  private readonly objectKinds;
@@ -427,6 +426,7 @@ declare class KindStreamParser {
427
426
  private rootKind;
428
427
  private rootDone;
429
428
  private failed;
429
+ private readonly options;
430
430
  constructor(options: KindStreamParserOptions);
431
431
  push(chunk: string): void;
432
432
  end(): void;
@@ -677,13 +677,13 @@ type JsonToken = {
677
677
  at: number;
678
678
  };
679
679
  declare class JsonStreamTokenizer {
680
- private readonly onToken;
681
680
  private mode;
682
681
  private pos;
683
682
  private stringBuffer;
684
683
  private primitiveBuffer;
685
684
  private unicodeBuffer;
686
685
  private tokenStart;
686
+ private readonly onToken;
687
687
  constructor(onToken: (token: JsonToken) => void);
688
688
  get position(): number;
689
689
  push(chunk: string): void;
@@ -950,7 +950,18 @@ declare function sanitizeInboundEnvelopeMetadata(metadata: Record<string, unknow
950
950
  * a schema knew about it.
951
951
  */
952
952
  declare function reconstructRegionValue(envelope: CanonicalBlockIR): Record<string, unknown>;
953
- /** Deep-remove the __kind discriminator (the parser injects it into snapshots). */
953
+ /**
954
+ * Deep-remove the `__kind` discriminator.
955
+ *
956
+ * ๐Ÿšจ NOT A TRANSFORM FOR PLATFORM DATA. `__kind` is part of the data
957
+ * (KINDS_EVERYWHERE_PLAN ยง4.2) and stripping it from anything stored, passed or
958
+ * rendered was annihilated on 2026-08-23. This helper survives for exactly two
959
+ * shapes of caller, both of which are guarded:
960
+ * - a SYMMETRIC COMPARISON that reduces both sides and returns a boolean;
961
+ * - legacy validation TOLERANCE against a pre-2026-08-23 schema version.
962
+ * Guards: aidream `scripts/check_kind_marker_law.py`,
963
+ * matrx-frontend `pnpm check:kind-marker-law`.
964
+ */
954
965
  declare function stripKindDeep(value: unknown): unknown;
955
966
 
956
967
  /**
@@ -1406,8 +1417,8 @@ interface DualGateResult {
1406
1417
  /**
1407
1418
  * The structural leg, exported on its own so the shape doctor
1408
1419
  * (`shape-doctor.ts`) RECOMPUTES gate validation with the exact same ajv
1409
- * config + `__kind`-stripping semantics as activation โ€” never a parallel
1410
- * validator. `sample` is `unknown` (not `Record`) because kind examples may
1420
+ * config + marker semantics as activation (verbatim first, marker-free retry
1421
+ * second) โ€” never a parallel validator. `sample` is `unknown` (not `Record`) because kind examples may
1411
1422
  * legitimately be scalars/arrays (workflow I/O kinds like `text`/`number`).
1412
1423
  */
1413
1424
  declare function validateStructuralLeg(sample: unknown, emittedJsonSchema: unknown): LegResult;
package/dist/index.js CHANGED
@@ -398,16 +398,19 @@ var IrTree = class {
398
398
 
399
399
  // core/json-tokenizer.ts
400
400
  var JsonStreamTokenizer = class {
401
- constructor(onToken) {
402
- this.onToken = onToken;
403
- }
404
- onToken;
405
401
  mode = "normal";
406
402
  pos = 0;
407
403
  stringBuffer = "";
408
404
  primitiveBuffer = "";
409
405
  unicodeBuffer = "";
410
406
  tokenStart = 0;
407
+ onToken;
408
+ // Explicit field rather than a parameter property: consumers compile this
409
+ // source directly, and a strict host (the dashboard) sets
410
+ // `erasableSyntaxOnly`, under which parameter properties are a hard error.
411
+ constructor(onToken) {
412
+ this.onToken = onToken;
413
+ }
411
414
  get position() {
412
415
  return this.pos;
413
416
  }
@@ -630,16 +633,6 @@ function safeCopy(value) {
630
633
  }
631
634
  }
632
635
  var KindStreamParser = class {
633
- constructor(options) {
634
- this.options = options;
635
- this.resolver = isSchemaResolver(options.schemas) ? options.schemas : {
636
- get: (kind) => options.schemas[kind]
637
- };
638
- this.tokenizer = new JsonStreamTokenizer(
639
- (token) => this.handleToken(token)
640
- );
641
- }
642
- options;
643
636
  resolver;
644
637
  stack = [];
645
638
  objectKinds = /* @__PURE__ */ new Map();
@@ -674,6 +667,18 @@ var KindStreamParser = class {
674
667
  rootKind = "";
675
668
  rootDone = false;
676
669
  failed = false;
670
+ options;
671
+ // Explicit field, not a parameter property โ€” see the note in
672
+ // `json-tokenizer.ts`: `erasableSyntaxOnly` hosts compile this source.
673
+ constructor(options) {
674
+ this.options = options;
675
+ this.resolver = isSchemaResolver(options.schemas) ? options.schemas : {
676
+ get: (kind) => options.schemas[kind]
677
+ };
678
+ this.tokenizer = new JsonStreamTokenizer(
679
+ (token) => this.handleToken(token)
680
+ );
681
+ }
677
682
  push(chunk) {
678
683
  if (this.failed || this.rootDone) return;
679
684
  try {
@@ -2767,6 +2772,12 @@ function storageToKindSchema(kind, shape) {
2767
2772
  }
2768
2773
  return { kind, fields };
2769
2774
  }
2775
+ var GENERIC_FALLBACK_COMPONENT_KEY = "generic_structured";
2776
+ function satisfies(resolved) {
2777
+ return Boolean(
2778
+ resolved?.isActive && resolved.componentKey !== GENERIC_FALLBACK_COMPONENT_KEY
2779
+ );
2780
+ }
2770
2781
  var ajv = new Ajv({ allErrors: true, strict: false });
2771
2782
  function stripKind(value) {
2772
2783
  if (Array.isArray(value)) return value.map(stripKind);
@@ -2780,6 +2791,14 @@ function stripKind(value) {
2780
2791
  }
2781
2792
  return value;
2782
2793
  }
2794
+ function describeAjvErrors(errors) {
2795
+ return (errors ?? []).map((e) => `${e.instancePath || "(root)"} ${e.message ?? ""}`.trim()).slice(0, 8);
2796
+ }
2797
+ function schemaDeclaresKind(emittedJsonSchema) {
2798
+ if (!emittedJsonSchema || typeof emittedJsonSchema !== "object") return false;
2799
+ const properties = emittedJsonSchema.properties;
2800
+ return !!properties && typeof properties === "object" && KIND_KEY in properties;
2801
+ }
2783
2802
  function validateStructuralLeg(sample, emittedJsonSchema) {
2784
2803
  let validate;
2785
2804
  try {
@@ -2790,9 +2809,11 @@ function validateStructuralLeg(sample, emittedJsonSchema) {
2790
2809
  detail: `emitted_json_schema failed to compile: ${err instanceof Error ? err.message : String(err)}`
2791
2810
  };
2792
2811
  }
2793
- const ok = validate(stripKind(sample));
2794
- if (ok) return { ok: true };
2795
- const errors = (validate.errors ?? []).map((e) => `${e.instancePath || "(root)"} ${e.message ?? ""}`.trim()).slice(0, 8);
2812
+ if (validate(sample)) return { ok: true };
2813
+ const markedErrors = describeAjvErrors(validate.errors);
2814
+ if (validate(stripKind(sample))) return { ok: true };
2815
+ const strippedErrors = describeAjvErrors(validate.errors);
2816
+ const errors = schemaDeclaresKind(emittedJsonSchema) ? markedErrors : strippedErrors;
2796
2817
  return { ok: false, detail: `sample failed schema: ${errors.join("; ")}` };
2797
2818
  }
2798
2819
  var SERVER_DATA_ANNOTATION_KEYS = /* @__PURE__ */ new Set(["language"]);
@@ -2842,16 +2863,18 @@ function validateRender(kind, sample, definition, resolvedComponent, dataOnly) {
2842
2863
  detail: "data-only contract kind \u2014 render leg is structurally inapplicable (n/a)"
2843
2864
  };
2844
2865
  }
2845
- if (!definition && !resolvedComponent?.isActive) {
2866
+ const onlyFallback = resolvedComponent?.isActive && resolvedComponent.componentKey === GENERIC_FALLBACK_COMPONENT_KEY;
2867
+ const noComponentDetail = onlyFallback ? `the only active role='output' component for kind "${kind}" is '${GENERIC_FALLBACK_COMPONENT_KEY}' \u2014 that IS the generic viewer, i.e. no component. A reader would get a key/value dump. Author a real source='db' component (or register a compiled one), then retire the generic row.` : null;
2868
+ if (!definition && !satisfies(resolvedComponent)) {
2846
2869
  return {
2847
2870
  ok: false,
2848
- detail: `kind "${kind}" has no component (not in the compiled registry, and no active role='output' kind_component row) \u2014 nothing to render`
2871
+ detail: noComponentDetail ?? `kind "${kind}" has no component (not in the compiled registry, and no active role='output' kind_component row) \u2014 nothing to render`
2849
2872
  };
2850
2873
  }
2851
- if (definition && !definition.legacyBlockType && !definition.component && !definition.toLegacyServerData && !resolvedComponent?.isActive) {
2874
+ if (definition && !definition.legacyBlockType && !definition.component && !definition.toLegacyServerData && !satisfies(resolvedComponent)) {
2852
2875
  return {
2853
2876
  ok: false,
2854
- detail: `kind "${kind}" has no component (no compiled legacyBlockType/component facet, and no active role='output' kind_component row) \u2014 nothing to render`
2877
+ detail: noComponentDetail ?? `kind "${kind}" has no component (no compiled legacyBlockType/component facet, and no active role='output' kind_component row) \u2014 nothing to render`
2855
2878
  };
2856
2879
  }
2857
2880
  if (definition?.toLegacyServerData) {
@@ -2875,7 +2898,7 @@ function validateRender(kind, sample, definition, resolvedComponent, dataOnly) {
2875
2898
  }
2876
2899
  return { ok: true };
2877
2900
  }
2878
- const satisfier = definition?.legacyBlockType ? `compiled component "${definition.legacyBlockType}"` : definition?.component ? "compiled component facet" : resolvedComponent ? `resolved ${resolvedComponent.source} component "${resolvedComponent.componentKey}"` : "component";
2901
+ const satisfier = definition?.legacyBlockType ? `compiled component "${definition.legacyBlockType}"` : definition?.component ? "compiled component facet" : satisfies(resolvedComponent) && resolvedComponent ? `resolved ${resolvedComponent.source} component "${resolvedComponent.componentKey}"` : "component";
2879
2902
  return {
2880
2903
  ok: true,
2881
2904
  detail: `bridgeless kind \u2014 ${satisfier} parses content itself; full DOM render check deferred to an RTL harness`
@@ -4347,7 +4370,7 @@ function rehydrateRunResult(raw, frame) {
4347
4370
  if (raw[KIND_KEY] !== RUN_RESULT_KIND) return null;
4348
4371
  const ref = str(raw, "output_ref");
4349
4372
  const resolved = ref === null ? void 0 : readOutputRef(frame, ref);
4350
- const outputs = Array.isArray(raw.outputs) ? raw.outputs.map((child) => rehydrateNodeOutcome(child, frame) ?? child) : [];
4373
+ const outputs = Array.isArray(raw.outputs) ? raw.outputs.map((child) => rehydrateNodeOutcome(child, frame)).filter((child) => child !== null) : [];
4351
4374
  return readRunResultValue({
4352
4375
  ...raw,
4353
4376
  ...resolved === void 0 ? {} : { output: resolved },