litedbmodel 2.0.0 → 2.0.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.
Files changed (163) hide show
  1. package/dist/scp/authoring-sql.d.ts +78 -0
  2. package/dist/scp/authoring-sql.d.ts.map +1 -1
  3. package/dist/scp/authoring-sql.js +110 -2
  4. package/dist/scp/authoring-sql.js.map +1 -1
  5. package/dist/scp/catalog.d.ts +5 -2
  6. package/dist/scp/catalog.d.ts.map +1 -1
  7. package/dist/scp/catalog.js +32 -1
  8. package/dist/scp/catalog.js.map +1 -1
  9. package/dist/scp/codegen.d.ts +143 -85
  10. package/dist/scp/codegen.d.ts.map +1 -1
  11. package/dist/scp/codegen.js +374 -90
  12. package/dist/scp/codegen.js.map +1 -1
  13. package/dist/scp/coltype.d.ts +41 -0
  14. package/dist/scp/coltype.d.ts.map +1 -0
  15. package/dist/scp/coltype.js +188 -0
  16. package/dist/scp/coltype.js.map +1 -0
  17. package/dist/scp/dialect.d.ts +12 -3
  18. package/dist/scp/dialect.d.ts.map +1 -1
  19. package/dist/scp/dialect.js +12 -3
  20. package/dist/scp/dialect.js.map +1 -1
  21. package/dist/scp/find-filter-guard.d.ts +68 -0
  22. package/dist/scp/find-filter-guard.d.ts.map +1 -0
  23. package/dist/scp/find-filter-guard.js +88 -0
  24. package/dist/scp/find-filter-guard.js.map +1 -0
  25. package/dist/scp/fragment/assemble.d.ts +61 -0
  26. package/dist/scp/fragment/assemble.d.ts.map +1 -0
  27. package/dist/scp/fragment/assemble.js +156 -0
  28. package/dist/scp/fragment/assemble.js.map +1 -0
  29. package/dist/scp/fragment/compile-pg.d.ts +107 -0
  30. package/dist/scp/fragment/compile-pg.d.ts.map +1 -0
  31. package/dist/scp/fragment/compile-pg.js +142 -0
  32. package/dist/scp/fragment/compile-pg.js.map +1 -0
  33. package/dist/scp/fragment/index.d.ts +16 -0
  34. package/dist/scp/fragment/index.d.ts.map +1 -0
  35. package/dist/scp/fragment/index.js +34 -0
  36. package/dist/scp/fragment/index.js.map +1 -0
  37. package/dist/scp/fragment/model.d.ts +119 -0
  38. package/dist/scp/fragment/model.d.ts.map +1 -0
  39. package/dist/scp/fragment/model.js +66 -0
  40. package/dist/scp/fragment/model.js.map +1 -0
  41. package/dist/scp/fragment/pg-array-type.d.ts +13 -0
  42. package/dist/scp/fragment/pg-array-type.d.ts.map +1 -0
  43. package/dist/scp/fragment/pg-array-type.js +34 -0
  44. package/dist/scp/fragment/pg-array-type.js.map +1 -0
  45. package/dist/scp/guard.d.ts +2 -6
  46. package/dist/scp/guard.d.ts.map +1 -1
  47. package/dist/scp/guard.js +19 -22
  48. package/dist/scp/guard.js.map +1 -1
  49. package/dist/scp/index.cjs +18695 -3921
  50. package/dist/scp/index.d.ts +41 -24
  51. package/dist/scp/index.d.ts.map +1 -1
  52. package/dist/scp/index.js +134 -49
  53. package/dist/scp/index.js.map +1 -1
  54. package/dist/scp/index.mjs +4830 -1432
  55. package/dist/scp/makesql/authoring-compile.d.ts +90 -0
  56. package/dist/scp/makesql/authoring-compile.d.ts.map +1 -0
  57. package/dist/scp/makesql/authoring-compile.js +494 -0
  58. package/dist/scp/makesql/authoring-compile.js.map +1 -0
  59. package/dist/scp/makesql/compile-crud.d.ts +133 -0
  60. package/dist/scp/makesql/compile-crud.d.ts.map +1 -0
  61. package/dist/scp/makesql/compile-crud.js +288 -0
  62. package/dist/scp/makesql/compile-crud.js.map +1 -0
  63. package/dist/scp/makesql/compile-relation.d.ts +157 -0
  64. package/dist/scp/makesql/compile-relation.d.ts.map +1 -0
  65. package/dist/scp/makesql/compile-relation.js +425 -0
  66. package/dist/scp/makesql/compile-relation.js.map +1 -0
  67. package/dist/scp/makesql/compile-select.d.ts +52 -0
  68. package/dist/scp/makesql/compile-select.d.ts.map +1 -0
  69. package/dist/scp/makesql/compile-select.js +58 -0
  70. package/dist/scp/makesql/compile-select.js.map +1 -0
  71. package/dist/scp/makesql/compile.d.ts +63 -0
  72. package/dist/scp/makesql/compile.d.ts.map +1 -0
  73. package/dist/scp/makesql/compile.js +99 -0
  74. package/dist/scp/makesql/compile.js.map +1 -0
  75. package/dist/scp/makesql/handler.d.ts +58 -0
  76. package/dist/scp/makesql/handler.d.ts.map +1 -0
  77. package/dist/scp/makesql/handler.js +113 -0
  78. package/dist/scp/makesql/handler.js.map +1 -0
  79. package/dist/scp/makesql/index.d.ts +33 -0
  80. package/dist/scp/makesql/index.d.ts.map +1 -0
  81. package/dist/scp/makesql/index.js +114 -0
  82. package/dist/scp/makesql/index.js.map +1 -0
  83. package/dist/scp/makesql/ir.d.ts +42 -0
  84. package/dist/scp/makesql/ir.d.ts.map +1 -0
  85. package/dist/scp/makesql/ir.js +66 -0
  86. package/dist/scp/makesql/ir.js.map +1 -0
  87. package/dist/scp/makesql/json-array.d.ts +84 -0
  88. package/dist/scp/makesql/json-array.d.ts.map +1 -0
  89. package/dist/scp/makesql/json-array.js +118 -0
  90. package/dist/scp/makesql/json-array.js.map +1 -0
  91. package/dist/scp/makesql/json-batch.d.ts +102 -0
  92. package/dist/scp/makesql/json-batch.d.ts.map +1 -0
  93. package/dist/scp/makesql/json-batch.js +269 -0
  94. package/dist/scp/makesql/json-batch.js.map +1 -0
  95. package/dist/scp/makesql/makesql.d.ts +99 -0
  96. package/dist/scp/makesql/makesql.d.ts.map +1 -0
  97. package/dist/scp/makesql/makesql.js +122 -0
  98. package/dist/scp/makesql/makesql.js.map +1 -0
  99. package/dist/scp/makesql/outtype.d.ts +44 -0
  100. package/dist/scp/makesql/outtype.d.ts.map +1 -0
  101. package/dist/scp/makesql/outtype.js +197 -0
  102. package/dist/scp/makesql/outtype.js.map +1 -0
  103. package/dist/scp/makesql/pool-executor.d.ts +47 -0
  104. package/dist/scp/makesql/pool-executor.d.ts.map +1 -0
  105. package/dist/scp/makesql/pool-executor.js +50 -0
  106. package/dist/scp/makesql/pool-executor.js.map +1 -0
  107. package/dist/scp/makesql/static-bundle.d.ts +187 -0
  108. package/dist/scp/makesql/static-bundle.d.ts.map +1 -0
  109. package/dist/scp/makesql/static-bundle.js +1113 -0
  110. package/dist/scp/makesql/static-bundle.js.map +1 -0
  111. package/dist/scp/makesql/tx.d.ts +216 -0
  112. package/dist/scp/makesql/tx.d.ts.map +1 -0
  113. package/dist/scp/makesql/tx.js +788 -0
  114. package/dist/scp/makesql/tx.js.map +1 -0
  115. package/dist/scp/makesql/writeouttype.d.ts +66 -0
  116. package/dist/scp/makesql/writeouttype.d.ts.map +1 -0
  117. package/dist/scp/makesql/writeouttype.js +195 -0
  118. package/dist/scp/makesql/writeouttype.js.map +1 -0
  119. package/dist/scp/relation.d.ts +86 -74
  120. package/dist/scp/relation.d.ts.map +1 -1
  121. package/dist/scp/relation.js +186 -120
  122. package/dist/scp/relation.js.map +1 -1
  123. package/dist/scp/runtime.d.ts +158 -211
  124. package/dist/scp/runtime.d.ts.map +1 -1
  125. package/dist/scp/runtime.js +250 -515
  126. package/dist/scp/runtime.js.map +1 -1
  127. package/dist/scp/typed-object.d.ts +12 -1
  128. package/dist/scp/typed-object.d.ts.map +1 -1
  129. package/dist/scp/typed-object.js +25 -4
  130. package/dist/scp/typed-object.js.map +1 -1
  131. package/docs/proposal/litedbmodel-v2-scp-architecture.md +51 -0
  132. package/docs/proposal/v0-coverage-matrix.md +157 -0
  133. package/docs/proposal/v2-completeness-plan.md +90 -0
  134. package/docs/proposal/v2-sql-parity-checklist.md +162 -0
  135. package/package.json +3 -3
  136. package/dist/scp/bridge.d.ts +0 -64
  137. package/dist/scp/bridge.d.ts.map +0 -1
  138. package/dist/scp/bridge.js +0 -329
  139. package/dist/scp/bridge.js.map +0 -1
  140. package/dist/scp/compile-dialect.d.ts +0 -39
  141. package/dist/scp/compile-dialect.d.ts.map +0 -1
  142. package/dist/scp/compile-dialect.js +0 -62
  143. package/dist/scp/compile-dialect.js.map +0 -1
  144. package/dist/scp/compile-sqlite.d.ts +0 -114
  145. package/dist/scp/compile-sqlite.d.ts.map +0 -1
  146. package/dist/scp/compile-sqlite.js +0 -149
  147. package/dist/scp/compile-sqlite.js.map +0 -1
  148. package/dist/scp/ir.d.ts +0 -92
  149. package/dist/scp/ir.d.ts.map +0 -1
  150. package/dist/scp/ir.js +0 -28
  151. package/dist/scp/ir.js.map +0 -1
  152. package/dist/scp/render.d.ts +0 -40
  153. package/dist/scp/render.d.ts.map +0 -1
  154. package/dist/scp/render.js +0 -170
  155. package/dist/scp/render.js.map +0 -1
  156. package/dist/scp/write-plan.d.ts +0 -161
  157. package/dist/scp/write-plan.d.ts.map +0 -1
  158. package/dist/scp/write-plan.js +0 -528
  159. package/dist/scp/write-plan.js.map +0 -1
  160. package/dist/scp/write-runtime.d.ts +0 -80
  161. package/dist/scp/write-runtime.d.ts.map +0 -1
  162. package/dist/scp/write-runtime.js +0 -167
  163. package/dist/scp/write-runtime.js.map +0 -1
@@ -1,131 +1,189 @@
1
1
  /**
2
- * litedbmodel v2 SCP — mode-3 codegen (WS7f, #35; spec §9 exec-mode 3 / §10 / §11).
2
+ * litedbmodel v2 SCP — mode-3 codegen (WS7f, #35; spec §9 exec-mode 3 / §10 / §11; makeSQL flip,
3
+ * epic #43/#45 Phase B; #60 milestone 1 — typed-NATIVE READ codegen, bc#77/#90).
3
4
  *
4
- * The static-codegen execution mode ("Codegen・静的(全言語)— IR → 各言語ソース生成
5
- * runtime≈0, 入力は可搬IRのみ, bc#13 共有 generator に SQL catalog を供給" — spec §9). It
6
- * takes a §8 {@link SqlBundle} (already Backend-Compiled TS-side, WS1↔WS3) and, per target
7
- * language, emits:
5
+ * The static-codegen execution mode ("Codegen・静的(全言語)— IR → 各言語ソース生成 runtime≈0,
6
+ * 入力は可搬IRのみ, bc#13 共有 generator に SQL catalog を供給" — spec §9). It takes a §8 STATIC
7
+ * makeSQL {@link SqlBundle} and, per target language, emits:
8
8
  *
9
- * 1. **Behavior module** — bc's SHARED generator (`generateModule`, bc#13) run over the
10
- * bundle's SURROGATE component wrapped as a portable {@link ComponentGraphIR}. The generator
11
- * bakes that IR as a language-native LITERAL (no runtime JSON parse) and emits a `bind(handlers)`
12
- * accessor that delegates to the EXISTING runtime-core `runBehavior`. litedbmodel writes NO
13
- * execution logic here — codegen is upstream-owned (bc), we only SUPPLY the input.
14
- * 2. **SQL catalog companion** — a pure-JSON sidecar carrying the litedbmodel-specific bundle
15
- * fields that are OUTSIDE bc's portable-IR vocabulary (`operations` / `dialect` /
16
- * `optionalHeads` / `relations` / `transaction`). This is the "SQL catalog supplied to the
17
- * shared generator" (§9): a codegen consumer's thin SQL-handler layer reads it to render →
18
- * execute, exactly as the mode-2 thin-runtime handler does. It is byte-identical to the bundle
19
- * minus the (now baked-as-literal) `component`/`irVersion`/`exprVersion`.
9
+ * 1. **Behavior module** — bc's SHARED generator run over the bundle's portable IR through bc's
10
+ * de-interpreted, RUNTIME-FREE emitter. For a READ bundle covered by bc's typed-NATIVE
11
+ * endpoint (`rust-typed-native` / `go-typed-native`, bc#77/#90 — the 1.0 read de-box: fully
12
+ * concrete `HandlerNR<Comp>`/`InNR<Comp>`/`PortsNR<Comp><node>`/`RawRowNR<Comp><node>` structs,
13
+ * ZERO boxed `Value`/`RawValue`, ZERO IR baked into the module), the CODEGEN-ONLY lowering
14
+ * below ({@link lowerReadGraphForTypedNative}) makes the read's shape structurally ELIGIBLE
15
+ * (splits the surrogate `__scope` boxed-obj port into individual scalar ref ports + types the
16
+ * component's `inputPorts` from the schema) before handing it to bc. For a WRITE bundle, or a
17
+ * READ shape typed-native does not (yet) cover, codegen uses bc's existing de-interpreted
18
+ * STRAIGHT-LINE endpoint (`<lang>-straightline`, bc#75) — see {@link typedEmitterFor}.
19
+ * 2. **SQL catalog companion** — the pure-JSON STATIC makeSQL catalog (per-node statement
20
+ * templates / relations / transaction). A codegen consumer's thin SQL layer reads it to
21
+ * evaluate skip + value-specs → assemble → render → execute (identically to the mode-2 runtime).
20
22
  *
21
- * ## Why this is byte-identical to the thin-runtime (mode-2), by construction
23
+ * ## #60 milestone 1 scope (CODEGEN-PATH ONLY)
22
24
  *
23
- * The mode-2 thin-runtime ({@link executeBundle}) computes
24
- * `runBehavior({components:[bundle.component]}, buildHandlers(db, operations, dialect),
25
- * normalizeInput(...), name)`. The generated module bakes `IR === bundle.component` (proven by
26
- * the FNV-1a fingerprint the generator embeds and re-checks at load) and its `bind(handlers)`
27
- * calls the SAME `runBehavior(IR, handlers, input, name)`. So when a codegen runtime pairs the
28
- * generated `bind` with the SAME {@link buildHandlers} + {@link normalizeInput} (from the SQL
29
- * catalog companion), it drives the identical core over the identical IR and handlers — the SQL
30
- * text (all dialects) and the results are identical, NOT approximately equal. The TS leg PROVES
31
- * this by executing the generated module and asserting exact equality vs `executeBundle` AND vs
32
- * the frozen conformance vector (see `codegenExecuteBundleForTest`).
25
+ * This lowering exists SOLELY for the codegen emitter call — it builds a NEW, separate
26
+ * `ComponentGraphIR` from the bundle's `readGraph`; it never mutates `SqlBundle`/`ReadGraph` and
27
+ * never touches the shared `readGraph`/`executeReadGraph` the ir/interpret exec surface (and the
28
+ * frozen conformance corpus) depend on. Those keep consuming the ORIGINAL boxed-`__scope`-port
29
+ * surrogate IR ({@link bundleToPortableIR}), completely unaffected by anything in this file.
33
30
  *
34
- * ## Language support (bc#13 capability — the honest scope boundary)
31
+ * ## Behavior-identical to the thin-runtime (mode-2), by construction
35
32
  *
36
- * bc's shared generator registers emitters for FIVE languages
37
- * ({@link CODEGEN_LANGUAGES}); Go IS among them (bc#13 SP2 `emit-go.ts`). So litedbmodel mode-3
38
- * codegen covers all five — TS/Python/Go/Rust/PHP. If a future litedbmodel construct needed an
39
- * emitter bc does not provide, the honest move is to ESCALATE to bc (bc#22 pattern), never to
40
- * fork a parallel litedbmodel-local generator (that would defeat the "codegen は上流所有" design).
33
+ * The generated module is observationally equivalent to `runBehavior` (same values, same emitted
34
+ * op sequence, same Failure code/message), and the companion IS the bundle, so a codegen runtime
35
+ * that drives it follows the IDENTICAL static-makeSQL render/execute path {@link executeBundle}
36
+ * uses — SQL text (all dialects) and results are identical, not approximately equal. The TS leg
37
+ * PROVES this by executing via the artifact and asserting exact equality vs {@link executeBundle}
38
+ * (see {@link codegenExecuteBundleForTest}).
39
+ *
40
+ * ## No literal-bake / no boxed fallback
41
+ *
42
+ * typed-native fails CLOSED on an uncovered shape (a `map`/`cond` relation kind it does not cover,
43
+ * or an input head that cannot lower to a native scalar — e.g. an IN-list's array-typed head).
44
+ * Such a shape is NOT silently regenerated on the boxed `-typed`/`-typed-raw` emitter — it THROWS,
45
+ * naming the exact gap, so it can be tracked as a bc coverage gap (bc#86) rather than masked.
41
46
  */
42
47
  import { type ComponentGraphIR, type GeneratedModule, type Scope, type Value } from 'behavior-contracts';
43
48
  import type { SqlBundle, SqliteDb } from './runtime';
44
- import { type DialectName } from './dialect';
45
- import type { CompiledOperation } from './ir';
49
+ import type { DialectName } from './dialect';
46
50
  import type { RelationOp } from './relation';
47
- import type { TransactionPlan } from './write-plan';
51
+ import type { ReadGraph } from './makesql/static-bundle';
52
+ import type { TransactionPlan } from './makesql/tx';
53
+ import { type ColumnTypeResolver } from './coltype';
48
54
  /**
49
55
  * The languages litedbmodel mode-3 codegen supports — exactly the set bc's shared generator
50
- * registers (bc#13 SP1 typescript/python + SP2 go/rust/php). This is a FIXED capability the
51
- * generator advertises via `registeredLanguages()`; {@link assertLanguageSupported} verifies the
52
- * requested language against the LIVE registry so a bc capability change is caught loudly rather
53
- * than silently drifting from this constant.
56
+ * registers (bc#13 SP1 typescript/python + SP2 go/rust/php). {@link codegenEmitterFor}
57
+ * verifies against the LIVE registry so a bc capability drift is caught loudly.
54
58
  */
55
59
  export declare const CODEGEN_LANGUAGES: readonly ["typescript", "python", "go", "rust", "php"];
56
60
  export type CodegenLanguage = (typeof CODEGEN_LANGUAGES)[number];
57
61
  /**
58
- * The SQL catalog companion (spec §9 — the "SQL catalog supplied to the shared generator"): the
59
- * litedbmodel-specific §8 bundle fields that live OUTSIDE bc's portable-IR vocabulary and so are
60
- * NOT baked into the generated behavior module. A codegen consumer's thin SQL-handler layer reads
61
- * this sidecar to render → bind → execute (identically to the mode-2 handler). Pure JSON —
62
- * round-trips losslessly (proven by the codegen conformance leg).
62
+ * The bc READ emitter litedbmodel drives for each codegen target (#60 milestone 1): the
63
+ * **de-interpreted, RUNTIME-FREE typed-NATIVE** endpoint (bc#77/#90) for go/rust — ZERO boxed
64
+ * `Value`/`RawValue`, ZERO IR baked into the module, concrete `HandlerNR`/`InNR`/`PortsNR`/
65
+ * `RawRowNR` structs. There is **NO literal / straight-line / boxed-typed fallback** for a read: an
66
+ * unspec'd fallback is INVALID (it silently swallows the "this shape can't be natively codegen'd"
67
+ * signal) — a read shape typed-native does not cover MUST fail loudly at generation, naming the gap
68
+ * (report it as a bc#86 coverage gap), never silently regenerate on `-typed`/`-typed-raw`.
69
+ *
70
+ * `-typed-raw` (bc#76, the boxed-wire intermediate) and `-typed` (the boxed-Value intermediate) are
71
+ * RETIRED from litedbmodel's codegen surface entirely (#60 milestone 1) — typed-native supersedes
72
+ * both for every read shape it covers (bc#77/#90: single-componentRef reads AND the `map`
73
+ * relationKind:single|connection shape, bc#86 part 2).
74
+ *
75
+ * - ts: **no typed-native endpoint registered yet** (bc has not shipped `typescript-typed-native`).
76
+ * TS stays on its existing `typescript-typed` (boxed) endpoint until bc adds one — a DECLARED,
77
+ * reported gap (not silently mirrored to go/rust's retirement), tracked as a bc#77 TS follow-up.
78
+ * - **python/php: NOT present.** bc registers no de-boxed typed endpoint for them (capability limit).
79
+ * litedbmodel does NOT substitute the literal (≈ir) emitter — that would be an unspec'd fallback.
80
+ * Codegen for py/php is a bc capability gap that ERRORS (ESCALATE to bc), never a silent literal.
81
+ *
82
+ * WRITES (batchInsert / gate-first tx) are NOT reads — they are NOT routed through this table at
83
+ * all (#60 milestone 1): a write bundle stays on the existing write/tx execution path
84
+ * (`executeTransactionBundle` / the native adapter's hand-written tx mirror), never a codegen
85
+ * module, boxed or typed-raw. {@link generateCodegenArtifact} throws if asked to codegen a write.
86
+ */
87
+ export declare const CODEGEN_EMITTER: Partial<Record<CodegenLanguage, string>>;
88
+ /**
89
+ * The SQL catalog companion (spec §9): the STATIC makeSQL bundle fields the codegen consumer's
90
+ * thin SQL layer reads to evaluate + render + execute. Pure JSON — round-trips losslessly.
63
91
  */
64
92
  export interface SqlCatalogCompanion {
65
- /** Backend-Compiled SQL IR per catalog node id (§8) — `sql` + fragment tree + closed-set params. */
66
- readonly operations: Record<string, CompiledOperation>;
67
93
  /** Target SQL dialect (`sqlite`/`postgres`/`mysql`) — compiled once, TS-side (spec §10). */
68
94
  readonly dialect: DialectName;
95
+ /** READ bundles: the portable read graph (surrogate IR + per-node makeSQL statements). */
96
+ readonly readGraph?: ReadGraph;
97
+ /** WRITE bundles: the single base-write makeSQL statement template. */
98
+ readonly statement?: {
99
+ readonly sql: string;
100
+ readonly params: readonly unknown[];
101
+ readonly skip?: unknown;
102
+ };
69
103
  /** Input heads normalized to present-as-null (absent-key SKIP) — mirrors the bundle. */
70
104
  readonly optionalHeads: readonly string[];
71
- /** Pre-compiled read-relation batch ops (spec §5/§8), keyed by relation name. */
105
+ /** Pre-compiled STATIC read-relation batch ops (spec §5/§8), keyed by relation name. */
72
106
  readonly relations: Record<string, RelationOp>;
73
107
  /** Derived gate-first write-time-relations transaction plan (spec §6/§8), for a Command bundle. */
74
108
  readonly transaction?: TransactionPlan;
109
+ /**
110
+ * WRITE bundles: the codegen typed-de-box `outputType` (the TransactionResult typed shape). Rides
111
+ * the companion so a codegen consumer that reassembles the bundle from the artifact round-trips it
112
+ * losslessly (the read de-box carries its outType/outputType inside `readGraph.ir` instead).
113
+ */
114
+ readonly outputType?: unknown;
75
115
  }
76
116
  /** The full codegen artifact for one bundle × one language. */
77
117
  export interface CodegenArtifact {
78
118
  /** The target language. */
79
119
  readonly language: CodegenLanguage;
80
- /** The generated behavior module (bc's shared generator output — IR baked as a native literal). */
120
+ /** The generated behavior module (bc's SHARED STRAIGHT-LINE generator output — real static code). */
81
121
  readonly module: GeneratedModule;
82
- /** The SQL catalog companion sidecar (the litedbmodel-specific execution catalog). */
122
+ /** The SQL catalog companion sidecar (the STATIC makeSQL execution catalog). */
83
123
  readonly companion: SqlCatalogCompanion;
84
- /**
85
- * The portable IR that WAS baked into {@link module} (the surrogate component + envelope). Kept
86
- * on the artifact so the in-process TS equivalence check drives the IDENTICAL IR the emitted
87
- * source embeds — the generator's fingerprint (checked at the emitted module's load) proves the
88
- * baked literal equals this object.
89
- */
90
- readonly ir: ComponentGraphIR;
124
+ /** The originating bundle (so the equivalence leg re-executes the SAME static bundle). */
125
+ readonly bundle: SqlBundle;
91
126
  }
92
127
  /**
93
- * The portable {@link ComponentGraphIR} view of a §8 bundle: the surrogate component (wiring /
94
- * plan / output / `__scope` ports only — every SQL-structural port already collapsed to portable
95
- * Expression IR TS-side) wrapped with the bundle's IR envelope. This is EXACTLY the IR
96
- * {@link executeBundle} feeds `runBehavior`, so baking it is what makes codegen equivalent.
128
+ * The portable {@link ComponentGraphIR} view of a §8 bundle: a read bundle's surrogate IR (each
129
+ * SQL node → a `makeSQL` node), or the single `makeSQL` component IR for a write. This is the
130
+ * ORIGINAL boxed-`__scope`-port form the ir/interpret exec surface's `executeReadGraph` also
131
+ * consumes (via `bundle.readGraph.ir` directly) — {@link generateCodegenArtifact} does NOT use
132
+ * this for a READ bundle (it uses the codegen-only lowered form, {@link lowerReadGraphForTypedNative});
133
+ * this function is kept for callers that want the untouched portable IR (e.g. diagnostics, the
134
+ * write path, or a future straight-line fallback caller).
97
135
  */
98
136
  export declare function bundleToPortableIR(bundle: SqlBundle): ComponentGraphIR;
137
+ /** A head could not be typed for typed-native codegen — the read is NOT typed-native-coverable. */
138
+ export declare class TypedNativeCoverageError extends Error {
139
+ readonly component: string;
140
+ readonly reasons: readonly string[];
141
+ constructor(component: string, reasons: readonly string[]);
142
+ }
99
143
  /**
100
- * Assert the requested language is one bc's shared generator can actually emit — checked against
101
- * the LIVE generator registry, not just the {@link CODEGEN_LANGUAGES} constant, so a bc capability
102
- * drift (an emitter removed/renamed upstream) fails LOUDLY here instead of surfacing as a broken
103
- * generated module. `generateModule` itself also fail-closes on an unknown language; this is the
104
- * earlier, litedbmodel-scoped guard with the honest "bc supports X" message.
144
+ * Lower a read bundle's surrogate `ComponentGraphIR` into a NEW, CODEGEN-ONLY IR eligible for bc's
145
+ * typed-native endpoint (#60 milestone 1): split the single `__scope: {obj:{...}}` boxed port into
146
+ * individual scalar `{ref:[head]}` ports, and type the component's `inputPorts` from the schema
147
+ * (via {@link deriveHeadTypesFromStatements}). Throws {@link TypedNativeCoverageError} if any
148
+ * referenced head cannot be natively typed (e.g. an IN-list's array head) — NO silent `unknown`
149
+ * port, NO fallback. Does NOT mutate `bundle`/`bundle.readGraph` (a fresh IR object is returned);
150
+ * the ir/interpret exec surface's `executeReadGraph` keeps consuming the ORIGINAL `readGraph.ir`.
151
+ *
152
+ * Scope: bc's typed-native predicate itself still governs `map`/`cond`/relationKind/policy
153
+ * coverage (this lowering does not special-case those — `generateModule` fails closed on them with
154
+ * its own detailed diagnostic, which this function does not need to duplicate).
105
155
  */
106
- export declare function assertLanguageSupported(language: string, registered: readonly string[]): asserts language is CodegenLanguage;
156
+ export declare function lowerReadGraphForTypedNative(readGraph: ReadGraph, resolveColumnType: ColumnTypeResolver): ComponentGraphIR;
107
157
  /**
108
- * Generate the mode-3 codegen artifact for ONE §8 bundle in ONE target language: bc's SHARED
109
- * generator bakes the surrogate IR literal + emits `bind(handlers)`, and we attach the SQL catalog
110
- * companion. litedbmodel supplies the input (IR + catalog); bc owns the emitter.
111
- *
112
- * @param registeredLanguages the live `registeredLanguages()` from bc (injected so the guard sees
113
- * the actual generator capability; the caller passes `bc.registeredLanguages()`).
114
- * @param runtimeImport optional runtime-core import specifier override (test/vendored layouts);
115
- * forwarded verbatim to the generator so the generated code stays deterministic.
158
+ * Resolve the READ codegen emitter for a target language, or throw. No fallback: a language
159
+ * without a registered endpoint is a bc capability gap that fails LOUDLY (never a silent
160
+ * substitution of the literal/interpreter/boxed emitter — an unspec'd fallback is invalid).
116
161
  */
117
- export declare function generateCodegenArtifact(bundle: SqlBundle, language: string, registeredLanguages: readonly string[], runtimeImport?: string): CodegenArtifact;
162
+ export declare function typedEmitterFor(language: string, registered: readonly string[]): string;
118
163
  /**
119
- * The TS codegen EXECUTION path used to PROVE byte-identity: reconstruct the exact call the
120
- * generated TS module's `bind(handlers)` makes — `runBehavior(IR, handlers, normalizedInput,
121
- * name)` — where `IR` is the baked portable IR and `handlers` are the SAME SQL handlers the SQL
122
- * catalog companion drives ({@link buildHandlers}). Executing this and comparing to
123
- * {@link executeBundle} is a REAL byte-identity check on the codegen path (the generated TS module
124
- * is separately IMPORTED and run in the conformance leg to prove the emitted source itself agrees).
164
+ * Shape-INDEPENDENT emitter resolution — identical to {@link typedEmitterFor} now that there is
165
+ * exactly one READ endpoint per language (kept as a distinct export for callers that historically
166
+ * used the shape-independent form; both resolve the SAME table).
167
+ */
168
+ export declare function codegenEmitterFor(language: string, registered: readonly string[]): string;
169
+ /**
170
+ * Generate the mode-3 READ codegen artifact for ONE §8 READ bundle in ONE target language. For a
171
+ * typed-NATIVE target (go/rust, bc#77/#90), lowers the bundle's surrogate read graph into the
172
+ * typed-native-eligible IR ({@link lowerReadGraphForTypedNative}) first — REAL static native
173
+ * source, RUNTIME-FREE, no baked-IR interpret path. For any OTHER registered endpoint (currently
174
+ * only TS's boxed `typescript-typed`, which has no typed-native counterpart yet), the ORIGINAL
175
+ * portable IR ({@link bundleToPortableIR}) is used unchanged — the lowering is typed-native-only
176
+ * and would needlessly narrow a boxed endpoint's existing coverage. litedbmodel supplies the
177
+ * input (portable IR + catalog); bc owns the emitter.
125
178
  *
126
- * This mirrors {@link executeBundle} field-for-field, but drives the components/handlers via the
127
- * codegen ARTIFACT (baked IR + companion) rather than the raw bundle — so a divergence between the
128
- * codegen artifact and the bundle would surface as a mismatch.
179
+ * WRITE bundles are OUT OF SCOPE (#60 milestone 1: writes stay on the existing write/tx execution
180
+ * path, never a codegen module) — throws if `bundle.readGraph` is absent.
181
+ */
182
+ export declare function generateCodegenArtifact(bundle: SqlBundle, language: string, registeredLanguages: readonly string[], resolveColumnType: ColumnTypeResolver, runtimeImport?: string): CodegenArtifact;
183
+ /**
184
+ * The TS codegen EXECUTION path used to PROVE behavior-identity: a codegen runtime reads the SQL
185
+ * catalog companion (the STATIC makeSQL bundle) and evaluates skip + value-specs → assemble →
186
+ * render → execute — which is EXACTLY {@link executeBundle} over the SAME bundle.
129
187
  */
130
188
  export declare function codegenExecuteBundleForTest(artifact: CodegenArtifact, input: Scope, db: SqliteDb): Value;
131
189
  //# sourceMappingURL=codegen.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"codegen.d.ts","sourceRoot":"","sources":["../../src/scp/codegen.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,EAAkB,KAAK,gBAAgB,EAAE,KAAK,eAAe,EAAE,KAAK,KAAK,EAAE,KAAK,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACzH,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAGrD,OAAO,EAAc,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,wDAAyD,CAAC;AACxF,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEjE;;;;;;GAMG;AACH,MAAM,WAAW,mBAAmB;IAClC,oGAAoG;IACpG,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAA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