@ai-matrx/content-ir 0.9.0 → 0.10.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 (45) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/README.md +24 -5
  3. package/dist/convert.cjs +1680 -0
  4. package/dist/convert.cjs.map +1 -0
  5. package/dist/convert.d.cts +230 -0
  6. package/dist/convert.d.ts +230 -0
  7. package/dist/convert.js +1666 -0
  8. package/dist/convert.js.map +1 -0
  9. package/dist/core.cjs +2493 -0
  10. package/dist/core.cjs.map +1 -0
  11. package/dist/core.d.cts +370 -0
  12. package/dist/core.d.ts +370 -0
  13. package/dist/core.js +2452 -0
  14. package/dist/core.js.map +1 -0
  15. package/dist/index.cjs +3 -1
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.d.cts +9 -2030
  18. package/dist/index.d.ts +9 -2030
  19. package/dist/index.js +3 -1
  20. package/dist/index.js.map +1 -1
  21. package/dist/ir-tree-DbLVxbf1.d.cts +441 -0
  22. package/dist/ir-tree-Dsc_66ek.d.ts +441 -0
  23. package/dist/ir-types-95bA2cXH.d.cts +119 -0
  24. package/dist/ir-types-95bA2cXH.d.ts +119 -0
  25. package/dist/kind-schema.types-CwncWj9U.d.cts +139 -0
  26. package/dist/kind-schema.types-CwncWj9U.d.ts +139 -0
  27. package/dist/registry.cjs +468 -0
  28. package/dist/registry.cjs.map +1 -0
  29. package/dist/registry.d.cts +357 -0
  30. package/dist/registry.d.ts +357 -0
  31. package/dist/registry.js +456 -0
  32. package/dist/registry.js.map +1 -0
  33. package/dist/session.cjs +2052 -0
  34. package/dist/session.cjs.map +1 -0
  35. package/dist/session.d.cts +75 -0
  36. package/dist/session.d.ts +75 -0
  37. package/dist/session.js +2047 -0
  38. package/dist/session.js.map +1 -0
  39. package/dist/wire.cjs +310 -0
  40. package/dist/wire.cjs.map +1 -0
  41. package/dist/wire.d.cts +326 -0
  42. package/dist/wire.d.ts +326 -0
  43. package/dist/wire.js +291 -0
  44. package/dist/wire.js.map +1 -0
  45. package/package.json +73 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,68 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.10.0 — 2026-08-30
4
+
5
+ **Non-breaking.** Every existing `@ai-matrx/content-ir` import keeps working
6
+ unchanged — the root export is still the FULL surface. What is new is that the
7
+ package's four clean internal areas are now addressable directly.
8
+
9
+ - **Five new subpath exports — `/core`, `/session`, `/registry`, `/convert`,
10
+ `/wire`.** Each is a real build entry (dual ESM + CJS with matching
11
+ `.d.ts`/`.d.cts`), so a consumer that only reads wire contracts no longer
12
+ pulls the streaming parser — or `ajv`, which rides `/registry` and
13
+ `/convert` — into its graph. `.` re-exports all five, so nothing that
14
+ imports the root changes.
15
+
16
+ | Subpath | What it holds |
17
+ |---|---|
18
+ | `/core` | IR types + tree, JSON tokenizer, kind parser, snapshots, normalize, fingerprint, discriminator, envelope read/value/cache, region, schema structure |
19
+ | `/session` | `ParseSession`, `openParseSession` / `getParseSession` / `disposeParseSession` |
20
+ | `/registry` | kind registry types, storage transform, the dual gate |
21
+ | `/convert` | kind ⇄ JSON Schema, the OpenAI structured-output converter |
22
+ | `/wire` | partial-kind events, runtime wrapper readers, emit payload |
23
+
24
+ - **Fixed: the parse-session registry could silently SPLIT across module
25
+ graphs.** `session/session-manager.ts` held its `Map` in a module-level
26
+ variable. The package builds `splitting: false` in dual ESM/CJS format, so
27
+ that module is duplicated into every bundle that reaches it — and with the
28
+ new `/session` subpath, a host importing the root and the subpath would have
29
+ gotten TWO registries: "one writer per stream identity" would stop being
30
+ enforced across them and a second writer would open cleanly onto a live
31
+ stream. The registry now lives on `globalThis` under
32
+ `Symbol.for("ai-matrx.content-ir.parse-sessions")`. The tarball canary
33
+ proves the slot across BOTH loaders by opening a session through `/session`
34
+ and resolving it through the root; the guard was verified failing against
35
+ the old module-level form before this release.
36
+
37
+ - **Contract locked: `expectedRootKind` is a PREDICTION, never a free pass.**
38
+ Three new tests pin the behavior that was already correct but untested —
39
+ a payload predicted into a kind whose required field is missing degrades to
40
+ `kindState: "raw"` carrying a `raw_fallback` notice naming the field; a
41
+ valid payload still promotes to `resolved`. No behavior changed.
42
+
43
+ ### Consumer action (C28)
44
+
45
+ Nothing is required — this release is non-breaking and the root export is
46
+ unchanged. Two things are worth doing at your next working session:
47
+
48
+ 1. **Prefer the area subpath over the root for new and touched imports**
49
+ (`@ai-matrx/content-ir/wire` instead of `@ai-matrx/content-ir` when you
50
+ only read wire contracts, and so on). Root stays supported indefinitely;
51
+ the subpaths are the preferred imports because they keep the parser and
52
+ `ajv` out of graphs that do not need them.
53
+
54
+ 2. **🚨 Audit every place you gate a typed path on `envelope.root.kind`.**
55
+ `kind` is PRESERVED on failure by design (KIND PRESERVATION, 0.x
56
+ 2026-08-29): a payload that fails its schema stays a *broken*
57
+ `flashcard_set` rather than becoming an anonymous object. `status` says
58
+ only that parsing finished. **`kindState` is the validity signal** —
59
+ `"resolved"` is the only state a typed consumer may act on
60
+ (`"unverified"` means no schema existed and still routes to a component;
61
+ `"raw"` means checked and failed). A guard written as
62
+ `if (root.kind !== "x" || root.status !== "complete") return null` reads a
63
+ degraded root as a good one. Found in matrx-frontend's
64
+ `generatedSetFromEnvelope` and fixed in the same session as this release.
65
+
3
66
  ## 0.9.0 — 2026-08-29
4
67
 
5
68
  - **A nested `__kind` object now registers the CHILD's schema, not just a ref
package/README.md CHANGED
@@ -6,20 +6,39 @@ The framework-independent Content IR kernel used by AI Matrx applications. It pa
6
6
  pnpm add @ai-matrx/content-ir
7
7
  ```
8
8
 
9
+ ## Entry points
10
+
11
+ The root export is the full surface and always will be. Since 0.10.0 each internal area is also addressable on its own — prefer these, so a consumer that only reads wire contracts never pulls the parser (or `ajv`) into its graph.
12
+
13
+ | Import | What it holds |
14
+ |---|---|
15
+ | `@ai-matrx/content-ir` | everything below |
16
+ | `@ai-matrx/content-ir/core` | IR types + tree, JSON tokenizer, kind parser, snapshots, normalize, fingerprint, discriminator, envelope read/value/cache, region, schema structure |
17
+ | `@ai-matrx/content-ir/session` | `ParseSession` and the one-writer-per-identity registry |
18
+ | `@ai-matrx/content-ir/registry` | kind registry types, storage transform, the dual gate |
19
+ | `@ai-matrx/content-ir/convert` | kind ⇄ JSON Schema, the OpenAI structured-output converter |
20
+ | `@ai-matrx/content-ir/wire` | partial-kind events, runtime wrapper readers, emit payload |
21
+
9
22
  ```ts
23
+ import { createKindStreamParser, envelopeFromCompleteValue } from "@ai-matrx/content-ir/core";
24
+ import { validateStructuralLeg } from "@ai-matrx/content-ir/registry";
10
25
  import {
11
- createKindStreamParser,
12
- envelopeFromCompleteValue,
13
- validateStructuralLeg,
14
- // wire layer (0.2.0): streaming partial kinds + runtime wrappers + emit payload
15
26
  readPartialKindEvent,
16
27
  makePartialKindStalenessGate,
17
28
  rehydrateNodeOutcome,
18
29
  rehydrateRunResult,
19
30
  withRootKind,
20
- } from "@ai-matrx/content-ir";
31
+ } from "@ai-matrx/content-ir/wire";
21
32
  ```
22
33
 
34
+ ## Reading an envelope: `kindState`, never `kind` alone
35
+
36
+ `root.kind` is **preserved** when a payload fails its schema — a broken `flashcard_set` stays a `flashcard_set` so you can say what broke. `root.status` reports only that parsing finished. The validity signal is `root.kindState`:
37
+
38
+ - `"resolved"` — the only state a typed consumer may act on.
39
+ - `"unverified"` — the kind has no registered schema, so nothing was ever checked; it still routes to its component.
40
+ - `"raw"` / `"pending_*"` / `"speculative"` — do not consume as typed data.
41
+
23
42
  The package has no browser, React runtime, application store, database client, routing, or renderer dependency. `ajv` is its only runtime dependency. Host-specific registry fetching, component compilation, rendering, and error capture remain adapters around this kernel.
24
43
 
25
44
  ## Release gate