behavior-contracts 0.5.0 → 0.6.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.
Files changed (112) hide show
  1. package/dist/behavior.d.ts +7 -0
  2. package/dist/behavior.d.ts.map +1 -1
  3. package/dist/behavior.js.map +1 -1
  4. package/dist/builder.d.ts.map +1 -1
  5. package/dist/builder.js +10 -3
  6. package/dist/builder.js.map +1 -1
  7. package/dist/generator/async-plan.d.ts +78 -0
  8. package/dist/generator/async-plan.d.ts.map +1 -0
  9. package/dist/generator/async-plan.js +116 -0
  10. package/dist/generator/async-plan.js.map +1 -0
  11. package/dist/generator/core.d.ts +30 -9
  12. package/dist/generator/core.d.ts.map +1 -1
  13. package/dist/generator/core.js.map +1 -1
  14. package/dist/generator/{emit-straightline-typed-go.d.ts → emit-shared-go-typed.d.ts} +11 -17
  15. package/dist/generator/emit-shared-go-typed.d.ts.map +1 -0
  16. package/dist/generator/emit-shared-go-typed.js +572 -0
  17. package/dist/generator/emit-shared-go-typed.js.map +1 -0
  18. package/dist/generator/emit-shared-go.d.ts +29 -0
  19. package/dist/generator/emit-shared-go.d.ts.map +1 -0
  20. package/dist/generator/{emit-straightline-go.js → emit-shared-go.js} +2 -34
  21. package/dist/generator/emit-shared-go.js.map +1 -0
  22. package/dist/generator/{emit-straightline-typed-rust.d.ts → emit-shared-rust-typed.d.ts} +11 -17
  23. package/dist/generator/emit-shared-rust-typed.d.ts.map +1 -0
  24. package/dist/generator/emit-shared-rust-typed.js +576 -0
  25. package/dist/generator/emit-shared-rust-typed.js.map +1 -0
  26. package/dist/generator/{emit-straightline-rust.d.ts → emit-shared-rust.d.ts} +1 -36
  27. package/dist/generator/emit-shared-rust.d.ts.map +1 -0
  28. package/dist/generator/{emit-straightline-rust.js → emit-shared-rust.js} +2 -16
  29. package/dist/generator/emit-shared-rust.js.map +1 -0
  30. package/dist/generator/emit-shared-typescript.d.ts +12 -0
  31. package/dist/generator/emit-shared-typescript.d.ts.map +1 -0
  32. package/dist/generator/{emit-straightline-typescript.js → emit-shared-typescript.js} +5 -20
  33. package/dist/generator/emit-shared-typescript.js.map +1 -0
  34. package/dist/generator/emit-straightline-typed-typescript.d.ts +1 -1
  35. package/dist/generator/emit-straightline-typed-typescript.d.ts.map +1 -1
  36. package/dist/generator/emit-straightline-typed-typescript.js +1 -1
  37. package/dist/generator/emit-straightline-typed-typescript.js.map +1 -1
  38. package/dist/generator/emit-typed-native-go.d.ts.map +1 -1
  39. package/dist/generator/emit-typed-native-go.js +495 -75
  40. package/dist/generator/emit-typed-native-go.js.map +1 -1
  41. package/dist/generator/emit-typed-native-rust.d.ts +2 -1
  42. package/dist/generator/emit-typed-native-rust.d.ts.map +1 -1
  43. package/dist/generator/emit-typed-native-rust.js +553 -103
  44. package/dist/generator/emit-typed-native-rust.js.map +1 -1
  45. package/dist/generator/index.d.ts +2 -12
  46. package/dist/generator/index.d.ts.map +1 -1
  47. package/dist/generator/index.js +10 -62
  48. package/dist/generator/index.js.map +1 -1
  49. package/dist/generator/native-expr.d.ts +120 -0
  50. package/dist/generator/native-expr.d.ts.map +1 -0
  51. package/dist/generator/native-expr.js +456 -0
  52. package/dist/generator/native-expr.js.map +1 -0
  53. package/dist/generator/typed.d.ts.map +1 -1
  54. package/dist/generator/typed.js +8 -0
  55. package/dist/generator/typed.js.map +1 -1
  56. package/dist/guard.js +14 -0
  57. package/dist/guard.js.map +1 -1
  58. package/dist/index.d.ts +2 -2
  59. package/dist/index.d.ts.map +1 -1
  60. package/dist/index.js +1 -1
  61. package/dist/index.js.map +1 -1
  62. package/dist/plan.d.ts +6 -2
  63. package/dist/plan.d.ts.map +1 -1
  64. package/dist/plan.js +4 -0
  65. package/dist/plan.js.map +1 -1
  66. package/package.json +1 -1
  67. package/dist/generator/emit-go.d.ts +0 -19
  68. package/dist/generator/emit-go.d.ts.map +0 -1
  69. package/dist/generator/emit-go.js +0 -79
  70. package/dist/generator/emit-go.js.map +0 -1
  71. package/dist/generator/emit-raw-abi-go.d.ts +0 -45
  72. package/dist/generator/emit-raw-abi-go.d.ts.map +0 -1
  73. package/dist/generator/emit-raw-abi-go.js +0 -346
  74. package/dist/generator/emit-raw-abi-go.js.map +0 -1
  75. package/dist/generator/emit-raw-abi-rust.d.ts +0 -45
  76. package/dist/generator/emit-raw-abi-rust.d.ts.map +0 -1
  77. package/dist/generator/emit-raw-abi-rust.js +0 -380
  78. package/dist/generator/emit-raw-abi-rust.js.map +0 -1
  79. package/dist/generator/emit-rust.d.ts +0 -25
  80. package/dist/generator/emit-rust.d.ts.map +0 -1
  81. package/dist/generator/emit-rust.js +0 -125
  82. package/dist/generator/emit-rust.js.map +0 -1
  83. package/dist/generator/emit-straightline-go.d.ts +0 -60
  84. package/dist/generator/emit-straightline-go.d.ts.map +0 -1
  85. package/dist/generator/emit-straightline-go.js.map +0 -1
  86. package/dist/generator/emit-straightline-native-go.d.ts +0 -54
  87. package/dist/generator/emit-straightline-native-go.d.ts.map +0 -1
  88. package/dist/generator/emit-straightline-native-go.js +0 -835
  89. package/dist/generator/emit-straightline-native-go.js.map +0 -1
  90. package/dist/generator/emit-straightline-native-rust.d.ts +0 -27
  91. package/dist/generator/emit-straightline-native-rust.d.ts.map +0 -1
  92. package/dist/generator/emit-straightline-native-rust.js +0 -624
  93. package/dist/generator/emit-straightline-native-rust.js.map +0 -1
  94. package/dist/generator/emit-straightline-php.d.ts +0 -46
  95. package/dist/generator/emit-straightline-php.d.ts.map +0 -1
  96. package/dist/generator/emit-straightline-php.js +0 -941
  97. package/dist/generator/emit-straightline-php.js.map +0 -1
  98. package/dist/generator/emit-straightline-python.d.ts +0 -36
  99. package/dist/generator/emit-straightline-python.d.ts.map +0 -1
  100. package/dist/generator/emit-straightline-python.js +0 -855
  101. package/dist/generator/emit-straightline-python.js.map +0 -1
  102. package/dist/generator/emit-straightline-rust.d.ts.map +0 -1
  103. package/dist/generator/emit-straightline-rust.js.map +0 -1
  104. package/dist/generator/emit-straightline-typed-go.d.ts.map +0 -1
  105. package/dist/generator/emit-straightline-typed-go.js +0 -1114
  106. package/dist/generator/emit-straightline-typed-go.js.map +0 -1
  107. package/dist/generator/emit-straightline-typed-rust.d.ts.map +0 -1
  108. package/dist/generator/emit-straightline-typed-rust.js +0 -1155
  109. package/dist/generator/emit-straightline-typed-rust.js.map +0 -1
  110. package/dist/generator/emit-straightline-typescript.d.ts +0 -47
  111. package/dist/generator/emit-straightline-typescript.d.ts.map +0 -1
  112. package/dist/generator/emit-straightline-typescript.js.map +0 -1
@@ -1,346 +0,0 @@
1
- import { GeneratorFailure } from "./core.js";
2
- import { buildTypePlan, deriveTypeRef, findDecl } from "./typed.js";
3
- import { goTypedInternals } from "./emit-straightline-typed-go.js";
4
- const { PKG, sanitize, goFieldName, renderTypeRef, goScalar, typedLocal, isTypedComponent, collectTypedNodes, hasAnyTypeAnnotation, emitTypeDecls, emitSerializers, emitMarshallers, serializeTyped, emitTypedValue, buildComponentPlanForTyped, emitOpsLiteral, emitBehaviorPlanLiteral, goPortVar, setGoForceRunPlanHelpers, goStraightlineEmitter, } = goTypedInternals;
5
- // ── RAW marshallers (the de-box): read a RawValue field-by-field into a concrete struct ──
6
- /** Emit `marshal_raw_T*` for every named struct in the plan. */
7
- function emitRawMarshallers(plan) {
8
- if (plan.decls.length === 0)
9
- return "";
10
- return plan.decls.map((d) => emitOneRawMarshaller(d, plan)).join("\n\n");
11
- }
12
- function emitOneRawMarshaller(d, plan) {
13
- const lines = [];
14
- lines.push(`func marshal_raw_${d.name}(raw ${PKG}.RawValue) (${d.name}, error) {`);
15
- lines.push(`\tvar out ${d.name}`);
16
- // The row seam: a RawRow (native accessor), NOT a *Obj. This is the de-box — no dynamic
17
- // Value tree is walked; RawRow.Field is a direct native read.
18
- lines.push(`\trow, ok := raw.(${PKG}.RawRow)`);
19
- lines.push(`\tif !ok {`);
20
- lines.push(`\t\treturn out, ${PKG}.NewExprFailure("TYPE_MISMATCH", "typed raw marshal ${d.name}: expected obj, got "+${PKG}.RawFieldType(raw))`);
21
- lines.push(`\t}`);
22
- for (const f of d.fields) {
23
- const goName = goFieldName(f.name);
24
- const keyLit = JSON.stringify(f.name);
25
- lines.push(`\t{`);
26
- lines.push(`\t\tfv, present := row.Field(${keyLit})`);
27
- lines.push(`\t\tif !present {`);
28
- lines.push(`\t\t\treturn out, ${PKG}.NewExprFailure("MISSING_PROP", "typed raw marshal ${d.name}: missing property ."+${keyLit})`);
29
- lines.push(`\t\t}`);
30
- lines.push(emitRawFieldMaterialize(`out.${goName}`, "fv", f.type, plan, 2));
31
- lines.push(`\t}`);
32
- }
33
- lines.push(`\treturn out, nil`);
34
- lines.push(`}`);
35
- return lines.join("\n");
36
- }
37
- /**
38
- * emitRawFieldMaterialize — materialize `src` (a RawValue expr) into typed `target` per
39
- * `ref`. scalar -> native type-switch on RawValue, named -> marshal_raw_T*, arr ->
40
- * []RawValue loop, opt -> null branch. All concrete Go types; no *Obj/Value ever built.
41
- */
42
- function emitRawFieldMaterialize(target, src, ref, plan, indent) {
43
- const t = "\t".repeat(indent);
44
- switch (ref.kind) {
45
- case "scalar": {
46
- if (ref.scalar === "null") {
47
- // null-only field: store nil (the RawValue must be nil; mismatches are rare and the
48
- // boxed path also passes through, so keep symmetric — a non-nil here is not asserted).
49
- return `${t}${target} = nil`;
50
- }
51
- const gt = goScalar(ref.scalar);
52
- const at = ref.scalar === "int" ? "int64" : ref.scalar === "float" ? "float64" : gt;
53
- return [
54
- `${t}sv, sok := ${src}.(${at})`,
55
- `${t}if !sok {`,
56
- `${t}\treturn out, ${PKG}.NewExprFailure("TYPE_MISMATCH", "typed raw marshal: expected ${ref.scalar}, got "+${PKG}.RawFieldType(${src}))`,
57
- `${t}}`,
58
- `${t}${target} = sv`,
59
- ].join("\n");
60
- }
61
- case "named": {
62
- return [
63
- `${t}mv, merr := marshal_raw_${ref.name}(${src})`,
64
- `${t}if merr != nil {`,
65
- `${t}\treturn out, merr`,
66
- `${t}}`,
67
- `${t}${target} = mv`,
68
- ].join("\n");
69
- }
70
- case "arr": {
71
- const elemGo = renderTypeRef(ref.elem);
72
- const inner = emitRawFieldMaterialize("elemOut", "elemRaw", ref.elem, plan, indent + 1);
73
- return [
74
- `${t}arr, aok := ${src}.([]${PKG}.RawValue)`,
75
- `${t}if !aok {`,
76
- `${t}\treturn out, ${PKG}.NewExprFailure("TYPE_MISMATCH", "typed raw marshal: expected arr, got "+${PKG}.RawFieldType(${src}))`,
77
- `${t}}`,
78
- `${t}slice := make([]${elemGo}, 0, len(arr))`,
79
- `${t}for _, elemRaw := range arr {`,
80
- `${t}\tvar elemOut ${elemGo}`,
81
- inner,
82
- `${t}\tslice = append(slice, elemOut)`,
83
- `${t}}`,
84
- `${t}${target} = slice`,
85
- ].join("\n");
86
- }
87
- case "opt": {
88
- const innerGo = renderTypeRef(ref.inner);
89
- const inner = emitRawFieldMaterialize("optOut", src, ref.inner, plan, indent + 1);
90
- return [
91
- `${t}if ${src} == nil {`,
92
- `${t}\t${target} = nil`,
93
- `${t}} else {`,
94
- `${t}\tvar optOut ${innerGo}`,
95
- inner,
96
- `${t}\t${target} = &optOut`,
97
- `${t}}`,
98
- ].join("\n");
99
- }
100
- }
101
- }
102
- /** Node materializer for scalar/arr/opt outType nodes on the raw path (fail-closed). */
103
- function rawNodeMaterializerName(compName, nodeId) {
104
- return `materializeRawNode_${sanitize(compName)}_${nodeId.replace(/[^A-Za-z0-9_]/g, "_")}`;
105
- }
106
- function emitRawNodeMaterializers(comp, typedNodes, plan) {
107
- const parts = [];
108
- for (const [id, ref] of typedNodes.entries()) {
109
- if (ref.kind === "named")
110
- continue;
111
- const ty = renderTypeRef(ref);
112
- const fn = rawNodeMaterializerName(comp.name, id);
113
- const body = emitRawFieldMaterialize("out", "raw", ref, plan, 1);
114
- parts.push(`func ${fn}(raw ${PKG}.RawValue) (${ty}, error) {\n\tvar out ${ty}\n${body}\n\treturn out, nil\n}`);
115
- }
116
- return parts.join("\n\n");
117
- }
118
- // ── RAW runner: RunPlan-driven struct-native exec through the RAW handler ─────────────
119
- const PORT_SCOPE = "portScope()";
120
- function emitRawStoreNode(nodeId, srcExpr, ref, compName, indent, producedName) {
121
- const t = "\t".repeat(indent);
122
- if (ref === undefined)
123
- return `${t}_ = ${srcExpr}`;
124
- const prod = `\n${t}${producedName(nodeId)} = true`;
125
- const store = `${t}scopeMu.Lock()\n${t}${typedLocal(nodeId)} = tv${prod}\n${t}scopeMu.Unlock()`;
126
- const call = ref.kind === "named" ? `marshal_raw_${ref.name}(${srcExpr})` : `${rawNodeMaterializerName(compName, nodeId)}(${srcExpr})`;
127
- return `${t}tv, merr := ${call}\n${t}if merr != nil {\n${t}\treturn abort(idx, merr)\n${t}}\n${store}`;
128
- }
129
- function assertRawSupported(comp) {
130
- for (const n of comp.body) {
131
- if ("map" in n || "cond" in n) {
132
- const ot = n.outType;
133
- if (ot !== undefined) {
134
- throw new GeneratorFailure("UNSUPPORTED_NODE_STRAIGHTLINE", `go raw ABI (bc#76): component '${comp.name}' node '${n.id}' is a typed ${"map" in n ? "map" : "cond"} node. The raw handler ABI de-box currently covers the componentRef read-handler shape (graphddb's row hydrator). Regenerate this component on the boxed typed path (go-typed) — do NOT emit a raw module that re-boxes map/cond results.`);
135
- }
136
- }
137
- }
138
- }
139
- function emitRawExecArm(op, compName, typedNodes, plan, producedName) {
140
- if (op.kind !== "componentRef") {
141
- // Guarded by assertRawSupported for typed nodes; an UNtyped map/cond in a typed
142
- // component cannot reach here on the raw path (fail-closed at generation).
143
- throw new GeneratorFailure("UNSUPPORTED_NODE_STRAIGHTLINE", `go raw ABI (bc#76): node '${op.id}' kind '${op.kind}' is not supported on the raw path (componentRef only). Regenerate on go-typed.`);
144
- }
145
- const gp = goPortVar;
146
- const portEvals = op.ports
147
- .map((p) => `\t\t\t${gp(p.name)}, err := ${p.expr}
148
- \t\t\tif err != nil {
149
- \t\t\t\treturn abort(idx, err)
150
- \t\t\t}
151
- \t\t\tports.Set(${JSON.stringify(p.name)}, ${gp(p.name)})`)
152
- .join("\n");
153
- const body = op.ports.length === 0 ? "" : `\n${portEvals}`;
154
- const ref = typedNodes.get(op.id);
155
- const materialize = emitRawStoreNode(op.id, "outcome.Ok", ref, compName, 3, producedName);
156
- return `\t\tif i == ${op.index} {
157
- \t\t\tports := ${PKG}.NewObj()${body}
158
- \t\t\toutcome, resolved := ${PKG}.ExecRawHandler(handlers, ${JSON.stringify(op.id)}, ${JSON.stringify(op.component)}, ports, nil)
159
- \t\t\tif !resolved {
160
- \t\t\t\treturn abort(idx, ${PKG}.NewBehaviorFailure("UNKNOWN_COMPONENT", "component '${op.component}' has no handler (fail-closed)"))
161
- \t\t\t}
162
- \t\t\tif outcome.IsError {
163
- \t\t\t\treturn ${PKG}.ErrOutcome(outcome.Err)
164
- \t\t\t}
165
- ${materialize}
166
- \t\t\treturn ${PKG}.OkOutcome(nil)
167
- \t\t}`;
168
- }
169
- function emitRawRunner(comp, plan) {
170
- assertRawSupported(comp);
171
- const fn = sanitize(comp.name);
172
- const cplan = buildComponentPlanForTyped(comp);
173
- const typedNodes = collectTypedNodes(comp, plan);
174
- const decls = [...typedNodes.entries()]
175
- .map(([id, ref]) => `\tvar ${typedLocal(id)} ${renderTypeRef(ref)}`)
176
- .join("\n");
177
- const producedName = (id) => `__produced_${id.replace(/[^A-Za-z0-9_]/g, "_")}`;
178
- const producedDecls = [...typedNodes.keys()]
179
- .map((id) => `\t${producedName(id)} := false\n\t_ = ${producedName(id)}`)
180
- .join("\n");
181
- // #74: expose produced typed node results in the port scope by serializing the struct
182
- // cells on demand (same discipline as the boxed typed runner — the struct is SoT).
183
- const portScopeNodeInjections = [...typedNodes.entries()]
184
- .map(([id, ref]) => {
185
- const ser = serializeTyped(typedLocal(id), ref, plan);
186
- return `\t\tif ${producedName(id)} {\n\t\t\ts.Set(${JSON.stringify(id)}, ${ser})\n\t\t}`;
187
- })
188
- .join("\n");
189
- const arms = cplan.ops.map((op) => emitRawExecArm(op, comp.name, typedNodes, plan, producedName)).join("\n");
190
- const planLiteral = comp.plan ? emitBehaviorPlanLiteral(comp.plan) : `(*${PKG}.ExecutionPlanSpec)(nil)`;
191
- const outRef = comp.outputType !== undefined ? deriveTypeRef(comp.outputType, plan) : undefined;
192
- const out = emitTypedValue(comp.output, outRef, typedNodes, plan);
193
- const outRefFinal = out.ref ?? outRef;
194
- const serialized = outRefFinal ? serializeTyped("__typed_out", outRefFinal, plan) : "__typed_out";
195
- return `// run_typed_raw_${fn} — RAW-ABI STRUCT-NATIVE exec (bc#76 de-box): the RunPlan primitive drives the
196
- // plan (plan SSoT); per-node arms call the RAW handler (ExecRawHandler -> RawValue, NOT a boxed Value)
197
- // and materialize the node's outType struct DIRECTLY from the RawValue via marshal_raw_T*. The dynamic
198
- // Value/*Obj tree is NEVER built on the row data plane — that is the de-box the boxed typed path only
199
- // LAYERED. The output is assembled as a struct and serialized to a Value ONLY at the final return
200
- // boundary (the equivalence pin), so the OBSERVED result equals run_behavior. Called by BindRaw.
201
- func run_typed_raw_${fn}(handlers ${PKG}.RawComponentExec, input *${PKG}.Obj) (${PKG}.Value, error) {
202
- \tops := ${emitOpsLiteral(cplan)}
203
- \tif input == nil {
204
- \t\tinput = ${PKG}.NewObj()
205
- \t}
206
- ${decls ? decls + "\n" : ""}${producedDecls ? producedDecls + "\n" : ""}\tvar scopeMu sync.Mutex
207
- \t_ = scopeMu.Unlock
208
- \tportScope := func() *${PKG}.Obj {
209
- \t\ts := ${PKG}.NewObj()
210
- \t\tfor _, k := range input.Keys {
211
- \t\t\ts.Set(k, input.Vals[k])
212
- \t\t}
213
- ${portScopeNodeInjections ? "\t\tscopeMu.Lock()\n" + portScopeNodeInjections + "\n\t\tscopeMu.Unlock()\n" : ""}\t\treturn s
214
- \t}
215
- \t_ = portScope
216
- \texecErrs := make([]error, len(ops))
217
- \tabort := func(idx int, err error) ${PKG}.ExecOutcome {
218
- \t\texecErrs[idx] = err
219
- \t\treturn ${PKG}.ErrOutcome("aborted")
220
- \t}
221
- \texec := func(op ${PKG}.OpSpec, _ ${PKG}.Value) ${PKG}.ExecOutcome {
222
- \t\tidx := -1
223
- \t\tfor k := range ops {
224
- \t\t\tif ops[k].ID == op.ID {
225
- \t\t\t\tidx = k
226
- \t\t\t\tbreak
227
- \t\t\t}
228
- \t\t}
229
- \t\ti := idx
230
- ${arms}
231
- \t\treturn abort(idx, ${PKG}.NewBehaviorFailure("UNKNOWN_NODE_KIND", "op '"+op.ID+"' has no generated raw exec arm (fail-closed)"))
232
- \t}
233
- \tplan := ${planLiteral}
234
- \trun, err := ${PKG}.RunPlan(plan, ops, exec)
235
- \tif firstErr := ${PKG}.FirstExecErrInVisitOrder(execErrs, plan, len(ops), err); firstErr != nil {
236
- \t\treturn nil, firstErr
237
- \t}
238
- \tif err != nil {
239
- \t\treturn nil, err
240
- \t}
241
- \t_ = run
242
- \t__typed_out := ${out.expr}
243
- \t_ = __typed_out
244
- \treturn ${serialized}, nil
245
- }`;
246
- }
247
- // ── BindRaw dispatch surface ──────────────────────────────────────────────────────────
248
- function emitBindRaw(ctx) {
249
- const arms = ctx.ir.components
250
- .filter((c) => isTypedComponent(c))
251
- .map((c) => {
252
- const fn = sanitize(c.name);
253
- return `\tm[${JSON.stringify(c.name)}] = func(input *${PKG}.Obj) (${PKG}.Value, error) {\n\t\treturn run_typed_raw_${fn}(handlers, input)\n\t}`;
254
- })
255
- .join("\n");
256
- return `// BindRaw is the RAW-ABI dispatch surface (bc#76): it binds a RawComponentExec (native-backed
257
- // handler results) to the de-boxed struct-native runners. Only typed components are exposed on the raw
258
- // path; a consumer keeps untyped components on the boxed Bind. This mirrors Bind but drives the raw runner.
259
- func BindRaw(handlers ${PKG}.RawComponentExec) map[string]func(*${PKG}.Obj) (${PKG}.Value, error) {
260
- \tm := map[string]func(*${PKG}.Obj) (${PKG}.Value, error){}
261
- ${arms}
262
- \treturn m
263
- }`;
264
- }
265
- // ── module assembly ──────────────────────────────────────────────────────────────────
266
- function emit(ctx) {
267
- const typed = hasAnyTypeAnnotation(ctx);
268
- if (!typed) {
269
- throw new GeneratorFailure("UNSUPPORTED_NODE_STRAIGHTLINE", "go raw ABI (bc#76): the IR has no outType/outputType annotations — there is nothing to de-box. Use go-straightline for untyped IR.");
270
- }
271
- // Reuse the straight-line body so port evaluation helpers (slRef/slConcat/slPart) and the
272
- // RunPlan primitive helpers are present (raw runner reuses them; ports are Value-space).
273
- setGoForceRunPlanHelpers(true);
274
- const straightlineCode = goStraightlineEmitter.emit(ctx);
275
- setGoForceRunPlanHelpers(false);
276
- const plan = buildTypePlan(ctx.ir);
277
- const decls = emitTypeDecls(plan);
278
- const rawMarshallers = emitRawMarshallers(plan);
279
- const serializers = emitSerializers(plan);
280
- // Boxed marshallers exist ONLY for the Value-space output-assembly fallback (mustMarshal_*),
281
- // reached only when a component output directly references an INPUT PARAM of a named type — a
282
- // Value-space boundary read, NOT the row data plane. The ROW data plane (handler result ->
283
- // struct) is de-boxed via marshal_raw_* in the runner (asserted by the anti-sham gate).
284
- const boxedMarshallers = emitMarshallers(plan);
285
- const mustHelpers = goTypedInternals.emitMustHelpers(plan);
286
- const arrOptNodeHelpers = goTypedInternals.emitArrOptNodeHelpers(ctx, plan);
287
- const nodeMaterializers = ctx.ir.components
288
- .filter((c) => isTypedComponent(c))
289
- .map((c) => {
290
- const typedNodes = new Map();
291
- for (const n of c.body) {
292
- if ("map" in n)
293
- continue;
294
- const ot = n.outType;
295
- if (ot !== undefined)
296
- typedNodes.set(n.id, deriveTypeRef(ot, plan));
297
- }
298
- return emitRawNodeMaterializers(c, typedNodes, plan);
299
- })
300
- .filter((s) => s.length > 0)
301
- .join("\n\n");
302
- const runners = ctx.ir.components
303
- .filter((c) => isTypedComponent(c))
304
- .map((c) => emitRawRunner(c, plan))
305
- .join("\n\n");
306
- const bindRaw = emitBindRaw(ctx);
307
- const banner = `// ── RAW handler ABI layer (bc#76 — Go de-box: struct materialized DIRECTLY from the wire payload) ──
308
- // This layer is ADDITIVE to the straight-line body above. A RawComponentExec handler returns a
309
- // RawValue (native-backed, NOT a *Obj/Value tree — see go/rawabi.go). marshal_raw_T* reads it via
310
- // RawRow.Field / native scalar type-switch straight into the concrete struct: the dynamic Value tree
311
- // the boxed typed path built and then re-walked NEVER exists here. BindRaw drives the de-boxed runners.`;
312
- const sections = [
313
- banner,
314
- decls || undefined,
315
- rawMarshallers
316
- ? `// RAW marshallers (§4.4, de-box): materialize a concrete struct field-by-field from a native RawValue.\n// NO *Obj/NewObj/PrimObj on this data plane — that is the whole point of #76.\n${rawMarshallers}`
317
- : undefined,
318
- boxedMarshallers
319
- ? `// Value-space output-assembly fallback (mustMarshal_*): reached ONLY when an output directly refs an\n// input param of a named type (a Value boundary read, not the row data plane). Off the de-box hot path.\n${boxedMarshallers}`
320
- : undefined,
321
- `// typed -> Value serializers (final return boundary only): canonical observation for the equivalence pin.\n${serializers}`,
322
- `// must-form helpers reused for the output assembly (Value-space, off the row data plane).\n${mustHelpers}`,
323
- arrOptNodeHelpers ? `// arr/opt node de-box helpers (Value-space output assembly).\n${arrOptNodeHelpers}` : undefined,
324
- nodeMaterializers
325
- ? `// scalar/arr/opt node RAW materializers: FAIL-CLOSED de-box (TYPE_MISMATCH/MISSING_PROP) from RawValue.\n${nodeMaterializers}`
326
- : undefined,
327
- `// RAW-ABI struct-native runners: the REAL de-box exec path (called by BindRaw).\n${runners}`,
328
- bindRaw,
329
- ];
330
- const typedBody = sections.filter((s) => !!s).join("\n\n");
331
- return `${straightlineCode.replace(/\n+$/, "\n")}\n${typedBody}\n`;
332
- }
333
- /**
334
- * goRawAbiEmitter — language id `go-typed-raw` (bc#76). Emits the straight-line body (for
335
- * untyped components / helpers) plus the RAW-ABI de-boxed layer (struct materialized directly
336
- * from RawValue) and the BindRaw surface. Requires at least one outType/outputType annotation.
337
- */
338
- export const goRawAbiEmitter = {
339
- language: "go-typed-raw",
340
- fileExtension: ".go",
341
- // JSON-free codegen runtime (bc no-json invariant, 0.5.0): see emit-straightline-go.ts.
342
- defaultRuntimeImport: "github.com/foo-ogawa/behavior-contracts/go/coderuntime",
343
- filenameHint: "behaviors.typed.raw.generated.go",
344
- emit,
345
- };
346
- //# sourceMappingURL=emit-raw-abi-go.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"emit-raw-abi-go.js","sourceRoot":"","sources":["../../src/generator/emit-raw-abi-go.ts"],"names":[],"mappings":"AAsCA,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,QAAQ,EAA8C,MAAM,YAAY,CAAC;AAChH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAGnE,MAAM,EACJ,GAAG,EACH,QAAQ,EACR,WAAW,EACX,aAAa,EACb,QAAQ,EACR,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EACpB,aAAa,EACb,eAAe,EACf,eAAe,EACf,cAAc,EACd,cAAc,EACd,0BAA0B,EAC1B,cAAc,EACd,uBAAuB,EACvB,SAAS,EACT,wBAAwB,EACxB,qBAAqB,GACtB,GAAG,gBAAgB,CAAC;AAErB,4FAA4F;AAE5F,gEAAgE;AAChE,SAAS,kBAAkB,CAAC,IAAc;IACxC,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACvC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,oBAAoB,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC3E,CAAC;AAED,SAAS,oBAAoB,CAAC,CAAW,EAAE,IAAc;IACvD,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC,IAAI,QAAQ,GAAG,eAAe,CAAC,CAAC,IAAI,YAAY,CAAC,CAAC;IACnF,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,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GAIwF,CAAC;IACxG,MAAM,QAAQ,GAA2B;QACvC,MAAM;QACN,KAAK,IAAI,SAAS;QAClB,cAAc;YACZ,CAAC,CAAC,4LAA4L,cAAc,EAAE;YAC9M,CAAC,CAAC,SAAS;QACb,gBAAgB;YACd,CAAC,CAAC,oNAAoN,gBAAgB,EAAE;YACxO,CAAC,CAAC,SAAS;QACb,+GAA+G,WAAW,EAAE;QAC5H,+FAA+F,WAAW,EAAE;QAC5G,iBAAiB,CAAC,CAAC,CAAC,kEAAkE,iBAAiB,EAAE,CAAC,CAAC,CAAC,SAAS;QACrH,iBAAiB;YACf,CAAC,CAAC,6GAA6G,iBAAiB,EAAE;YAClI,CAAC,CAAC,SAAS;QACb,qFAAqF,OAAO,EAAE;QAC9F,OAAO;KACR,CAAC;IACF,MAAM,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAe,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACxE,OAAO,GAAG,gBAAgB,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC;AACrE,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAkB;IAC5C,QAAQ,EAAE,cAAc;IACxB,aAAa,EAAE,KAAK;IACpB,wFAAwF;IACxF,oBAAoB,EAAE,wDAAwD;IAC9E,YAAY,EAAE,kCAAkC;IAChD,IAAI;CACL,CAAC"}
@@ -1,45 +0,0 @@
1
- /**
2
- * emit-raw-abi-rust.ts — Rust RAW handler ABI emitter (bc#76): the de-boxed typed path.
3
- *
4
- * # What this replaces
5
- *
6
- * The boxed typed emitter (emit-straightline-typed-rust.ts) generates
7
- * `marshal_T*(raw: &Value) -> Result<T*, BehaviorError>`: the handler builds a full dynamic
8
- * `Value::Obj` tree and the marshaller WALKS it into a struct — a Value->struct conversion
9
- * LAYERED on top of boxing. Rust felt the residual ~22% gap #75 measured most: the `Value`
10
- * enum heap-boxes every `Obj` pair into `Vec<(String, Value)>`, cloned at the ABI, re-walked.
11
- *
12
- * # What this emits
13
- *
14
- * A RAW module that materializes structs DIRECTLY from a `RawValue` (native-backed, NOT a
15
- * `Value` — see rust/src/rawabi.rs). The generated code:
16
- *
17
- * - `marshal_raw_T*(raw: &RawValue) -> Result<T*, BehaviorError>`: matches on RawValue
18
- * (scalar / RawRow / Arr) straight into the concrete struct. It NEVER constructs a
19
- * `Value::Obj`/`Value` on the row data plane.
20
- * - `run_typed_raw_<comp><H: RawComponentExec>(handlers, input) -> Result<Value, ...>`:
21
- * drives the plan with the run_plan primitive (plan SSoT, reused), evaluates ports with
22
- * the native/primitive straight-line expressions (unchanged — ports are Value-space, off
23
- * the row data plane), calls the RAW handler (`exec_raw_ctx` -> `RawValue`), and
24
- * materializes the node struct via `marshal_raw_T*` at the boundary. The output is
25
- * assembled as a struct and serialized to a Value ONLY at the final return boundary (the
26
- * equivalence pin), exactly as the boxed typed path — so the OBSERVED result equals
27
- * run_behavior while the row data plane never boxed.
28
- * - `bind_raw<H: RawComponentExec>(handlers) -> BoundRaw<H>` + `BoundRaw::call`: the raw
29
- * dispatch surface (mirrors bind/Bound::call). `COMPONENT_NAMES_RAW` lists the typed
30
- * components exposed on the raw path.
31
- *
32
- * # Scope
33
- *
34
- * The raw de-box covers the componentRef read-handler shape (graphddb's row hydrator). Typed
35
- * map/cond nodes LOUD-fail (UNSUPPORTED_NODE_STRAIGHTLINE) so a consumer regenerates those on
36
- * the boxed typed path rather than getting a module that silently re-boxes.
37
- */
38
- import type { EmitterPlugin } from "./core.js";
39
- /**
40
- * rustRawAbiEmitter — language id `rust-typed-raw` (bc#76). Emits the straight-line body (for
41
- * untyped components / helpers) plus the RAW-ABI de-boxed layer (struct materialized directly from
42
- * RawValue) and the bind_raw surface. Requires at least one outType/outputType annotation.
43
- */
44
- export declare const rustRawAbiEmitter: EmitterPlugin;
45
- //# sourceMappingURL=emit-raw-abi-rust.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"emit-raw-abi-rust.d.ts","sourceRoot":"","sources":["../../src/generator/emit-raw-abi-rust.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,OAAO,KAAK,EAAe,aAAa,EAAE,MAAM,WAAW,CAAC;AA8a5D;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,aAM/B,CAAC"}