behavior-contracts 0.2.4 → 0.2.6

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 (48) hide show
  1. package/dist/generator/emit-raw-abi-go.d.ts +45 -0
  2. package/dist/generator/emit-raw-abi-go.d.ts.map +1 -0
  3. package/dist/generator/emit-raw-abi-go.js +345 -0
  4. package/dist/generator/emit-raw-abi-go.js.map +1 -0
  5. package/dist/generator/emit-raw-abi-rust.d.ts +45 -0
  6. package/dist/generator/emit-raw-abi-rust.d.ts.map +1 -0
  7. package/dist/generator/emit-raw-abi-rust.js +380 -0
  8. package/dist/generator/emit-raw-abi-rust.js.map +1 -0
  9. package/dist/generator/emit-straightline-go.d.ts +27 -46
  10. package/dist/generator/emit-straightline-go.d.ts.map +1 -1
  11. package/dist/generator/emit-straightline-go.js +688 -190
  12. package/dist/generator/emit-straightline-go.js.map +1 -1
  13. package/dist/generator/emit-straightline-php.d.ts +1 -1
  14. package/dist/generator/emit-straightline-php.d.ts.map +1 -1
  15. package/dist/generator/emit-straightline-php.js +451 -20
  16. package/dist/generator/emit-straightline-php.js.map +1 -1
  17. package/dist/generator/emit-straightline-python.d.ts.map +1 -1
  18. package/dist/generator/emit-straightline-python.js +426 -22
  19. package/dist/generator/emit-straightline-python.js.map +1 -1
  20. package/dist/generator/emit-straightline-rust.d.ts +5 -0
  21. package/dist/generator/emit-straightline-rust.d.ts.map +1 -1
  22. package/dist/generator/emit-straightline-rust.js +596 -48
  23. package/dist/generator/emit-straightline-rust.js.map +1 -1
  24. package/dist/generator/emit-straightline-typed-go.d.ts +95 -2
  25. package/dist/generator/emit-straightline-typed-go.d.ts.map +1 -1
  26. package/dist/generator/emit-straightline-typed-go.js +42 -3
  27. package/dist/generator/emit-straightline-typed-go.js.map +1 -1
  28. package/dist/generator/emit-straightline-typed-rust.d.ts +98 -2
  29. package/dist/generator/emit-straightline-typed-rust.d.ts.map +1 -1
  30. package/dist/generator/emit-straightline-typed-rust.js +50 -7
  31. package/dist/generator/emit-straightline-typed-rust.js.map +1 -1
  32. package/dist/generator/emit-straightline-typescript.d.ts +26 -15
  33. package/dist/generator/emit-straightline-typescript.d.ts.map +1 -1
  34. package/dist/generator/emit-straightline-typescript.js +703 -147
  35. package/dist/generator/emit-straightline-typescript.js.map +1 -1
  36. package/dist/generator/index.d.ts +4 -2
  37. package/dist/generator/index.d.ts.map +1 -1
  38. package/dist/generator/index.js +11 -2
  39. package/dist/generator/index.js.map +1 -1
  40. package/dist/generator/literal.d.ts +3 -1
  41. package/dist/generator/literal.d.ts.map +1 -1
  42. package/dist/generator/literal.js +13 -4
  43. package/dist/generator/literal.js.map +1 -1
  44. package/dist/generator/straightline.d.ts +81 -0
  45. package/dist/generator/straightline.d.ts.map +1 -1
  46. package/dist/generator/straightline.js +176 -0
  47. package/dist/generator/straightline.js.map +1 -1
  48. package/package.json +1 -1
@@ -0,0 +1,380 @@
1
+ import { GeneratorFailure } from "./core.js";
2
+ import { buildTypePlan, deriveTypeRef } from "./typed.js";
3
+ import { buildComponentPlan } from "./straightline.js";
4
+ import { rustTypedInternals } from "./emit-straightline-typed-rust.js";
5
+ const PORT_SCOPE = "port_scope()";
6
+ const { sanitize, rustFieldName, rustStrLit, renderTypeRef, rustScalar, typedCell, isTypedComponent, hasAnyTypeAnnotation, collectTypedNodes, emitTypeDecls, emitDefaults, emitSerializers, emitMarshallers, emitMarshalHelpers, serializeTyped, emitTypedValue, indentBlock, emitOpsLiteral, emitPlanLiteral, rustStraightlineEmitter, setRustForceRunPlanImports, } = rustTypedInternals;
7
+ // ── RAW marshallers (the de-box): read a RawValue field-by-field into a concrete struct ──
8
+ function emitRawMarshallers(plan) {
9
+ if (plan.decls.length === 0)
10
+ return "";
11
+ return plan.decls.map((d) => emitOneRawMarshaller(d, plan)).join("\n\n");
12
+ }
13
+ function emitOneRawMarshaller(d, plan) {
14
+ const lines = [];
15
+ lines.push(`#[allow(dead_code)]`);
16
+ lines.push(`fn marshal_raw_${d.name}(raw: &RawValue) -> Result<${d.name}, BehaviorError> {`);
17
+ // The row seam: a RawRow (native accessor), NOT a Value::Obj. This IS the de-box.
18
+ lines.push(` let row = match raw {`);
19
+ lines.push(` RawValue::Row(r) => r,`);
20
+ lines.push(` other => return Err(raw_type_mismatch(${rustStrLit("obj")}, other.type_name())),`);
21
+ lines.push(` };`);
22
+ const fieldInits = [];
23
+ for (const f of d.fields) {
24
+ const fieldVar = `field_${rustFieldName(f.name).replace(/^r#/, "")}`;
25
+ const keyLit = rustStrLit(f.name);
26
+ lines.push(` let ${fieldVar} = {`);
27
+ lines.push(` let fv = match row.field(${keyLit}) {`);
28
+ lines.push(` Some(v) => v,`);
29
+ lines.push(` None => return Err(raw_missing_prop(${rustStrLit(d.name)}, ${keyLit})),`);
30
+ lines.push(` };`);
31
+ lines.push(indentBlock(emitRawFieldMaterialize("fv", f.type, plan), 2));
32
+ lines.push(` };`);
33
+ fieldInits.push(` ${rustFieldName(f.name)}: ${fieldVar},`);
34
+ }
35
+ lines.push(` Ok(${d.name} {`);
36
+ lines.push(...fieldInits);
37
+ lines.push(` })`);
38
+ lines.push(`}`);
39
+ return lines.join("\n");
40
+ }
41
+ /**
42
+ * emitRawFieldMaterialize — materialize `src` (a `&RawValue` expr) into a concrete typed value
43
+ * per `ref` (a value-returning block). scalar -> RawValue match, named -> marshal_raw_T*, arr
44
+ * -> RawValue::Arr loop, opt -> RawValue::Null branch. No Value::Obj/Value ever built.
45
+ */
46
+ function emitRawFieldMaterialize(src, ref, plan) {
47
+ switch (ref.kind) {
48
+ case "scalar": {
49
+ if (ref.scalar === "null") {
50
+ // null-only field stays a Value::Null (the struct field type is Value for null-only).
51
+ return `Value::Null`;
52
+ }
53
+ const variant = ref.scalar === "int" ? "Int" : ref.scalar === "float" ? "Float" : ref.scalar === "bool" ? "Bool" : "Str";
54
+ const bind = ref.scalar === "string" ? "s.clone()" : "*s";
55
+ return [
56
+ `match ${src} {`,
57
+ ` RawValue::${variant}(s) => ${bind},`,
58
+ ` other => return Err(raw_type_mismatch(${rustStrLit(ref.scalar)}, other.type_name())),`,
59
+ `}`,
60
+ ].join("\n");
61
+ }
62
+ case "named": {
63
+ return `marshal_raw_${ref.name}(${src})?`;
64
+ }
65
+ case "arr": {
66
+ const elemTy = renderTypeRef(ref.elem);
67
+ const inner = emitRawFieldMaterialize("elem_raw", ref.elem, plan);
68
+ return [
69
+ `match ${src} {`,
70
+ ` RawValue::Arr(items) => {`,
71
+ ` let mut out: Vec<${elemTy}> = Vec::with_capacity(items.len());`,
72
+ ` for elem_raw in items.iter() {`,
73
+ ` let elem_out = ${indentBlock(inner, 3).trimStart()};`,
74
+ ` out.push(elem_out);`,
75
+ ` }`,
76
+ ` out`,
77
+ ` }`,
78
+ ` other => return Err(raw_type_mismatch(${rustStrLit("arr")}, other.type_name())),`,
79
+ `}`,
80
+ ].join("\n");
81
+ }
82
+ case "opt": {
83
+ const inner = emitRawFieldMaterialize("inner_raw", ref.inner, plan);
84
+ return [
85
+ `match ${src} {`,
86
+ ` RawValue::Null => None,`,
87
+ ` inner_raw => {`,
88
+ ` let inner_out = ${indentBlock(inner, 2).trimStart()};`,
89
+ ` Some(inner_out)`,
90
+ ` }`,
91
+ `}`,
92
+ ].join("\n");
93
+ }
94
+ }
95
+ }
96
+ /** scalar/arr/opt node RAW materializer name. */
97
+ function rawNodeMaterializerName(nodeId) {
98
+ return `materialize_raw_node_${typedCell(nodeId)}`;
99
+ }
100
+ function emitRawNodeMaterializers(comp, typedNodes, plan) {
101
+ const parts = [];
102
+ for (const [id, ref] of typedNodes.entries()) {
103
+ if (ref.kind === "named")
104
+ continue;
105
+ const ty = renderTypeRef(ref);
106
+ const body = emitRawFieldMaterialize("raw", ref, plan);
107
+ parts.push(`#[allow(dead_code)]\nfn ${rawNodeMaterializerName(id)}(raw: &RawValue) -> Result<${ty}, BehaviorError> {\n Ok(${indentBlock(body, 1).trimStart()})\n}`);
108
+ }
109
+ return parts.join("\n\n");
110
+ }
111
+ // ── RAW runner ────────────────────────────────────────────────────────────────────────
112
+ function assertRawSupported(comp) {
113
+ for (const n of comp.body) {
114
+ if ("map" in n || "cond" in n) {
115
+ const ot = n.outType;
116
+ if (ot !== undefined) {
117
+ throw new GeneratorFailure("UNSUPPORTED_NODE_STRAIGHTLINE", `rust 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 (rust-typed) — do NOT emit a raw module that re-boxes map/cond results.`);
118
+ }
119
+ }
120
+ }
121
+ }
122
+ function emitStoreRawNode(nodeId, srcExpr, ref, indent, producedCell) {
123
+ const pad = " ".repeat(indent);
124
+ if (ref === undefined)
125
+ return `${pad}let _ = ${srcExpr};`;
126
+ const call = ref.kind === "named" ? `marshal_raw_${ref.name}(${srcExpr})` : `${rawNodeMaterializerName(nodeId)}(${srcExpr})`;
127
+ const prod = ` ${producedCell(nodeId)}.set(true);`;
128
+ return `${pad}match ${call} {
129
+ ${pad} Ok(tv) => { *${typedCell(nodeId)}.borrow_mut() = tv;${prod} }
130
+ ${pad} Err(e) => {
131
+ ${pad} *err_cell = Some(e);
132
+ ${pad} return ExecOutcome::Error("aborted".to_string());
133
+ ${pad} }
134
+ ${pad}}`;
135
+ }
136
+ function producedCellName(id) {
137
+ return `produced_${typedCell(id)}`;
138
+ }
139
+ function emitRawExecArm(op, typedNodes, plan) {
140
+ if (op.kind !== "componentRef") {
141
+ throw new GeneratorFailure("UNSUPPORTED_NODE_STRAIGHTLINE", `rust raw ABI (bc#76): node '${op.id}' kind '${op.kind}' is not supported on the raw path (componentRef only). Regenerate on rust-typed.`);
142
+ }
143
+ const portRows = op.ports.length === 0
144
+ ? " Ok(Vec::new())"
145
+ : ` Ok(vec![\n${op.ports
146
+ .map((pt) => ` (${rustStrLit(pt.name)}.to_string(), (${pt.expr})?),`)
147
+ .join("\n")}\n ])`;
148
+ const ref = typedNodes.get(op.id);
149
+ const materialize = emitStoreRawNode(op.id, "v", ref, 4, producedCellName);
150
+ return ` if i == ${op.index} {
151
+ let eval_ports = || -> Result<Vec<(String, Value)>, behavior_contracts::ExprFailure> {
152
+ ${portRows}
153
+ };
154
+ let ports = match eval_ports() {
155
+ Ok(p) => p,
156
+ Err(e) => {
157
+ *err_cell = Some(e.into());
158
+ return ExecOutcome::Error("aborted".to_string());
159
+ }
160
+ };
161
+ let outcome = match handlers.exec_raw_ctx(${rustStrLit(op.id)}, ${rustStrLit(op.component ?? "")}, &ports, None) {
162
+ Some(o) => o,
163
+ None => {
164
+ *err_cell = Some(BehaviorError::new("UNKNOWN_COMPONENT", format!("component '{}' has no handler (fail-closed)", ${rustStrLit(op.component ?? "")})));
165
+ return ExecOutcome::Error("aborted".to_string());
166
+ }
167
+ };
168
+ let v = match &outcome {
169
+ RawOutcome::Ok(v) => v,
170
+ RawOutcome::Error(e) => {
171
+ *err_cell = Some(BehaviorError::new("OP_FAILED", e.clone()));
172
+ return ExecOutcome::Error("aborted".to_string());
173
+ }
174
+ };
175
+ ${materialize}
176
+ return ExecOutcome::Ok(Value::Null);
177
+ }`;
178
+ }
179
+ function emitRawRunner(comp, plan) {
180
+ assertRawSupported(comp);
181
+ const fn = sanitize(comp.name);
182
+ const plans = buildComponentPlan(comp, rustTypedInternals.rustStraightlineInternals.dialect, PORT_SCOPE);
183
+ const typedNodes = collectTypedNodes(comp, plan);
184
+ const cellDecls = [...typedNodes.entries()]
185
+ .map(([id, ref]) => ` let ${typedCell(id)}: RefCell<${renderTypeRef(ref)}> = RefCell::new(Default::default());`)
186
+ .join("\n");
187
+ const producedDecls = [...typedNodes.keys()]
188
+ .map((id) => ` let ${producedCellName(id)} = std::cell::Cell::new(false);`)
189
+ .join("\n");
190
+ const portScopeNodeInjections = [...typedNodes.entries()]
191
+ .map(([id, ref]) => {
192
+ const isBareCopyScalar = ref.kind === "scalar" && (ref.scalar === "int" || ref.scalar === "float" || ref.scalar === "bool");
193
+ const owned = isBareCopyScalar ? `*${typedCell(id)}.borrow()` : `${typedCell(id)}.borrow().clone()`;
194
+ const ser = serializeTyped(owned, ref, plan);
195
+ return ` if ${producedCellName(id)}.get() {\n s.push((${rustStrLit(id)}.to_string(), ${ser}));\n }`;
196
+ })
197
+ .join("\n");
198
+ const arms = plans.ops.map((op) => emitRawExecArm(op, typedNodes, plan)).join("\n");
199
+ const planExpr = comp.plan ? emitPlanLiteral(comp.plan) : "None";
200
+ const outRef = comp.outputType !== undefined ? deriveTypeRef(comp.outputType, plan) : undefined;
201
+ const out = emitTypedValue(comp.output, outRef, typedNodes, plan);
202
+ const outRefFinal = out.ref ?? outRef;
203
+ const serialized = outRefFinal ? serializeTyped("__typed_out", outRefFinal, plan) : "__typed_out";
204
+ const opsLiteral = emitOpsLiteral(plans);
205
+ return `// run_typed_raw_${fn} — RAW-ABI STRUCT-NATIVE exec (bc#76 de-box): the run_plan primitive drives the
206
+ // plan (plan SSoT); per-node arms call the RAW handler (exec_raw_ctx -> RawValue, NOT a boxed Value) and
207
+ // materialize the node's outType struct DIRECTLY from the RawValue via marshal_raw_T*. The dynamic
208
+ // Value/Value::Obj tree is NEVER built on the row data plane — that is the de-box the boxed typed path
209
+ // only LAYERED. Output is assembled as a struct and serialized to a Value ONLY at the final return
210
+ // boundary (the equivalence pin), so the OBSERVED result equals run_behavior. Called by bind_raw.
211
+ fn run_typed_raw_${fn}<H: RawComponentExec>(
212
+ handlers: &mut H,
213
+ input: &[(String, Value)],
214
+ ) -> Result<Value, BehaviorError> {
215
+ let ops: Vec<OpSpec> = ${opsLiteral};
216
+ ${cellDecls ? cellDecls + "\n" : ""}${producedDecls ? producedDecls + "\n" : ""} let port_scope = || -> Vec<(String, Value)> {
217
+ let mut s = input.to_vec();
218
+ ${portScopeNodeInjections ? portScopeNodeInjections + "\n" : ""} s
219
+ };
220
+ let _ = &port_scope;
221
+ let mut pending_err: Option<BehaviorError> = None;
222
+
223
+ let run = {
224
+ let err_cell = &mut pending_err;
225
+ let exec = |op: &OpSpec, _bound: Option<&Value>| -> ExecOutcome {
226
+ if err_cell.is_some() {
227
+ return ExecOutcome::Error("aborted".to_string());
228
+ }
229
+ let i = match ops.iter().position(|o| o.id == op.id) {
230
+ Some(i) => i,
231
+ None => {
232
+ *err_cell = Some(no_typed_exec_arm(&op.id));
233
+ return ExecOutcome::Error("aborted".to_string());
234
+ }
235
+ };
236
+ let _ = i;
237
+ ${arms}
238
+ *err_cell = Some(BehaviorError::new("UNKNOWN_NODE_KIND", format!("op '{}' has no generated raw exec arm (fail-closed)", op.id)));
239
+ ExecOutcome::Error("aborted".to_string())
240
+ };
241
+ run_plan(${planExpr}, &ops, exec)
242
+ };
243
+
244
+ if let Some(e) = pending_err {
245
+ return Err(e);
246
+ }
247
+ let _run = run?;
248
+
249
+ let __typed_out = ${out.expr};
250
+ Ok(${serialized})
251
+ }`;
252
+ }
253
+ // ── bind_raw dispatch surface ───────────────────────────────────────────────────────
254
+ function emitBindRaw(ctx) {
255
+ const typedComps = ctx.ir.components.filter((c) => isTypedComponent(c));
256
+ const names = typedComps.map((c) => rustStrLit(c.name));
257
+ const arms = typedComps
258
+ .map((c) => ` ${rustStrLit(c.name)} => run_typed_raw_${sanitize(c.name)}(&mut self.handlers, input),`)
259
+ .join("\n");
260
+ return `// COMPONENT_NAMES_RAW — typed components exposed on the RAW-ABI de-boxed path.
261
+ pub const COMPONENT_NAMES_RAW: [&str; ${names.length}] = [${names.join(", ")}];
262
+
263
+ // bind_raw / BoundRaw — the RAW-ABI dispatch surface (bc#76): binds a RawComponentExec (native-backed
264
+ // handler results) to the de-boxed struct-native runners. Mirrors bind/Bound::call but drives the raw
265
+ // runner. Untyped components stay on the boxed bind.
266
+ pub fn bind_raw<H: RawComponentExec>(handlers: H) -> BoundRaw<H> {
267
+ BoundRaw { handlers }
268
+ }
269
+
270
+ pub struct BoundRaw<H: RawComponentExec> {
271
+ handlers: H,
272
+ }
273
+
274
+ impl<H: RawComponentExec> BoundRaw<H> {
275
+ pub fn call(&mut self, name: &str, input: &[(String, Value)]) -> Result<Value, BehaviorError> {
276
+ match name {
277
+ ${arms}
278
+ other => Err(BehaviorError::new("UNKNOWN_ENTRY", format!("component '{other}' is not a raw-typed entry (fail-closed)"))),
279
+ }
280
+ }
281
+ }`;
282
+ }
283
+ // ── module assembly ──────────────────────────────────────────────────────────────────
284
+ function emit(ctx) {
285
+ const typed = hasAnyTypeAnnotation(ctx);
286
+ if (!typed) {
287
+ throw new GeneratorFailure("UNSUPPORTED_NODE_STRAIGHTLINE", "rust raw ABI (bc#76): the IR has no outType/outputType annotations — there is nothing to de-box. Use rust-straightline for untyped IR.");
288
+ }
289
+ const plan = buildTypePlan(ctx.ir);
290
+ const decls = emitTypeDecls(plan);
291
+ const defaults = emitDefaults(plan);
292
+ const rawMarshallers = emitRawMarshallers(plan);
293
+ const serializers = emitSerializers(plan);
294
+ // Boxed marshallers + helpers exist ONLY for the Value-space output-assembly fallback
295
+ // (materializeExpr on an output that directly refs an input param of a named type — a Value
296
+ // boundary read, NOT the row data plane). The ROW data plane is de-boxed via marshal_raw_* in
297
+ // the runner (asserted by the anti-sham gate).
298
+ const boxedMarshallers = emitMarshallers(plan);
299
+ const marshalHelpers = emitMarshalHelpers();
300
+ const nodeMaterializers = [];
301
+ for (const comp of ctx.ir.components) {
302
+ if (!isTypedComponent(comp))
303
+ continue;
304
+ const typedNodes = new Map();
305
+ for (const n of comp.body) {
306
+ if ("map" in n)
307
+ continue;
308
+ const ot = n.outType;
309
+ if (ot !== undefined)
310
+ typedNodes.set(n.id, deriveTypeRef(ot, plan));
311
+ }
312
+ const nm = emitRawNodeMaterializers(comp, typedNodes, plan);
313
+ if (nm)
314
+ nodeMaterializers.push(nm);
315
+ }
316
+ const runners = ctx.ir.components
317
+ .filter((c) => isTypedComponent(c))
318
+ .map((c) => emitRawRunner(c, plan))
319
+ .join("\n\n");
320
+ const bindRaw = emitBindRaw(ctx);
321
+ const banner = `// ── RAW handler ABI layer (bc#76 — Rust de-box: struct materialized DIRECTLY from the wire payload) ──
322
+ // This layer is ADDITIVE to the straight-line body above. A RawComponentExec handler returns a RawValue
323
+ // (native-backed, NOT a Value::Obj tree — see rust/src/rawabi.rs). marshal_raw_T* matches on it straight
324
+ // into the concrete struct: the dynamic Value tree the boxed typed path built and then re-walked NEVER
325
+ // exists here. bind_raw drives the de-boxed runners.
326
+ use std::cell::RefCell;
327
+ use behavior_contracts::{RawComponentExec, RawOutcome, RawValue, raw_missing_prop, raw_type_mismatch};`;
328
+ const sections = [
329
+ banner,
330
+ decls || undefined,
331
+ defaults || undefined,
332
+ rawMarshallers
333
+ ? `// RAW marshallers (§4.4, de-box): materialize a concrete struct field-by-field from a native RawValue.\n// NO Value::Obj on this data plane — that is the whole point of #76.\n${rawMarshallers}`
334
+ : undefined,
335
+ marshalHelpers,
336
+ boxedMarshallers
337
+ ? `// Value-space output-assembly fallback (marshal_*): 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}`
338
+ : undefined,
339
+ nodeMaterializers.length
340
+ ? `// scalar/arr/opt node RAW materializers: FAIL-CLOSED de-box (TYPE_MISMATCH/MISSING_PROP) from RawValue.\n${nodeMaterializers.join("\n\n")}`
341
+ : undefined,
342
+ serializers
343
+ ? `// typed -> Value serializers (final return boundary only): canonical observation for the equivalence pin.\n${serializers}`
344
+ : undefined,
345
+ `// RAW-ABI struct-native runners: the REAL de-box exec path (called by bind_raw).\n${runners}`,
346
+ bindRaw,
347
+ ];
348
+ const typedBody = sections.filter((s) => !!s).join("\n\n");
349
+ // Force the RunPlan-path imports the raw runner needs (run_plan/OpSpec/ExecOutcome). Ports are
350
+ // Value-space, so the straight-line body's expression helpers are reused unchanged. relationKind
351
+ // is needed when a raw op literal carries a relationKind (parent-field child/relation nodes, #74).
352
+ setRustForceRunPlanImports({
353
+ runPlan: true,
354
+ relationKind: /\bRelationKind\b/.test(typedBody),
355
+ json: /\bjson!\(/.test(typedBody),
356
+ });
357
+ const straightlineCode = rustStraightlineEmitter.emit(ctx);
358
+ setRustForceRunPlanImports(null);
359
+ // The RAW module reuses the straight-line body as a SUBSTRATE (its expression helpers drive the
360
+ // Value-space ports), but drives dispatch through bind_raw — so the boxed bind/Bound/run_* and the
361
+ // boxed-only marshal helpers are unused in this artifact. A module-level allow keeps the generated
362
+ // RAW module clippy -D warnings clean without hand-editing the shared straight-line emitter. This
363
+ // is a GENERATED-TOOLKIT allowance on dead SUBSTRATE, not a blanket allow on the de-box path: the
364
+ // de-box (marshal_raw_*, run_typed_raw_*, bind_raw) is exercised and asserted by the anti-sham gate.
365
+ const moduleAllow = `#![allow(dead_code, unused_imports)]\n`;
366
+ return `${moduleAllow}${straightlineCode.replace(/\n+$/, "\n")}\n${typedBody}\n`;
367
+ }
368
+ /**
369
+ * rustRawAbiEmitter — language id `rust-typed-raw` (bc#76). Emits the straight-line body (for
370
+ * untyped components / helpers) plus the RAW-ABI de-boxed layer (struct materialized directly from
371
+ * RawValue) and the bind_raw surface. Requires at least one outType/outputType annotation.
372
+ */
373
+ export const rustRawAbiEmitter = {
374
+ language: "rust-typed-raw",
375
+ fileExtension: ".rs",
376
+ defaultRuntimeImport: "behavior_contracts",
377
+ filenameHint: "behaviors_typed_raw_generated.rs",
378
+ emit,
379
+ };
380
+ //# sourceMappingURL=emit-raw-abi-rust.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emit-raw-abi-rust.js","sourceRoot":"","sources":["../../src/generator/emit-raw-abi-rust.ts"],"names":[],"mappings":"AAsCA,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,aAAa,EAA8C,MAAM,YAAY,CAAC;AACtG,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAGvE,MAAM,UAAU,GAAG,cAAc,CAAC;AAElC,MAAM,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1C,YAAY,EAAE,kCAAkC;IAChD,IAAI;CACL,CAAC"}
@@ -1,63 +1,48 @@
1
1
  /**
2
- * emit-straightline-go.ts — Go 直線 emitter(bc#38 / Layer A2, de-interpretation)。
2
+ * emit-straightline-go.ts — Go 直線 emitter(bc#38 / Layer A2 → bc#75 static-code rework)。
3
3
  *
4
- * typed-codegen.md §4.1 の Go 具体化。language-neutral な {@link StraightlineDialect} を
5
- * 実装し、component ごとに「plan A0 `RunPlan` primitive で直呼び・各ノードの port 評価と
6
- * handler 呼びを直線展開した」ネイティブ **Go** 関数を emit する。生成コードは
7
- * **`RunBehavior` の tree-walk(nodeKind ディスパッチ / evalPorts / 汎用 output 評価)を
8
- * 経由しない**(A1 と同じ骨組み)。
4
+ * typed-codegen.md §4.1 の Go 具体化。bc#75 で「解釈機構の転写」を排し、**本当の静的コード**を
5
+ * emit する(TS oracle と同じ static-wiring 解析 {@link sequentialOrder}/{@link analyzeSequentialOps}/
6
+ * {@link classifyExpr}/{@link isScopeFree} を消費する):
9
7
  *
10
- * 式の綴じ方(A2 の眼目 = Phase B の脱解釈利得 TS oracle と決定的に異なる点):
11
- * - **単純式はネイティブ化する(AC#2)**:
12
- * - `ref` / `refOpt` 生成モジュール内の native Go helper(`slRef` / `slRefOpt`)で
13
- * `*Obj.Get` を直接歩く scope/field アクセス。`EvaluateExpression` `Prim*` も呼ばない。
14
- * - `concat` → native Go `strings.Builder` 連結(`slConcat`。part は再帰的に native emit)。
15
- * これで単純 port の式ツリー `evaluate()` 解釈が生成コードから**消える**。native helper
16
- * expr.go の意味論(`UNKNOWN_BINDING` / `NULL_REF` / `MISSING_PROP` / `TYPE_MISMATCH` /
17
- * `refOpt` null 伝播 / concat の「string 以外は TYPE_MISMATCH」/ arity>=2)を
18
- * **同じ Failure code で**再現する(意味論の等価は conformance pin)。
19
- * - **overflow / 短絡系はネイティブ化しない**: `add`/`sub`/`mul`/`neg`/`div`/`mod`
20
- * INT_OVERFLOW / PRECISION_LOSS / MOD_ZERO 等の fail-closed 意味論、`and`/`or`/`cond`/
21
- * `coalesce` は短絡(未評価 IR を渡して primitive evaluate が短絡)を保存するため、
22
- * A0 primitive SSoT(`Prim*`)を直呼びする(再実装しない)。`eq`/`ne`/比較/`obj`/`arr`/
23
- * `len`/`int`/`float` も SSoT を呼ぶ(型判定・code-point 順・checked リテラルの一本化)。
24
- * - 上記いずれにも当たらないむき出しスカラ(cond then/else の bare リテラル等)は `EvalExpr`
25
- * (同一 SSoT)へ落とす(型判定を生成コードに残さない)。
8
+ * - **逐次 plan(plan 無し / stage 高々 1 op)は素の文列**として直線展開する。`RunPlan`
9
+ * `[]OpSpec` テーブルも `baseScope()` snapshot も `exec` closure も `for k := range ops { if ops[k].ID== }`
10
+ * 線形探索も emit しない。ノード結果は素のローカル(`r_<id>`)に住み、skip 伝播(parent 連鎖 /
11
+ * bindField null-binding / continue policy)は静的に確定した分岐として展開する(Failure code /
12
+ * message plan.go interpretOutcome byte 一致)。
13
+ * - **静的形状の式はネイティブ inline**: string/bool/null リテラルは Go リテラル、静的 path の
14
+ * ref/refOpt は「ローカル直読み(配線は生成時に確定)+ field walk helper `slField`」、concat
15
+ * 可変長 `slCat(...)`(評価済み値を受ける closure per-part func 値も無い)。
16
+ * - **per-expression scope snapshot を廃止**: scope を本当に読む residual dynamic 式(ref を含む
17
+ * primitive 経路)がある component だけが「進行形 scope(`scope *Obj`)」を組み、ノード完了ごとに
18
+ * 1 key Set する。scope-free primitive 式には空 scope 定数(`slEmpty()`)を渡す。
19
+ * - **RunPlan primitive は実並行 plan(複数 op stage)だけ**が使う(bounded 並行の意味論 SSoT)。
20
+ * その経路も per-op exec は index で確定した switch(`for k := range ops` 線形探索は無い)。
21
+ *
22
+ * fail-closed 演算子意味論(overflow 算術・短絡 and/or/cond/coalesce・obj/arr 構築・比較・len・
23
+ * checked リテラル)は従来どおり A0 primitive SSoT(`Prim*`)を直呼びする(再実装しない)。
26
24
  *
27
25
  * この emitter は A1 の TS golden oracle と観測等価(値・発行 op 列・Failure)であることを
28
26
  * conformance(codegen-straightline.test.ts の Go 節)で実 Go toolchain 実行により pin する。
29
27
  */
30
28
  import type { EmitterPlugin } from "./core.js";
31
29
  import { type ComponentPlan, type StraightlineDialect } from "./straightline.js";
30
+ export declare function setGoForceRunPlanHelpers(on: boolean): void;
32
31
  /**
33
- * emitExpr — Expression IR ノードを「scope を受けて (Value, error) を返す」Go 式に落とす。
34
- *
35
- * 単純式は **native Go helper** へ(脱解釈 — AC#2)、overflow/短絡系は A0 primitive SSoT へ、
36
- * むき出しスカラは EvalExpr(同一 SSoT)へ落とす。生成される Go 式はどれも `(Value, error)` を
37
- * 返すので、直線関数側は `must(<expr>)` で 1 行に畳んで scope へ束ねる。
38
- * - `{ref:[...]}` → `${PKG}.slRef(<path>, scope)` (native scope/field walk)
39
- * - `{refOpt:[...]}` → `${PKG}? no — slRefOpt` (native, null 伝播)
40
- * - `{concat:[...]}` → `slConcat([]slPart{...}, scope)` (native strings.Builder)
41
- * - overflow/短絡 → `${PKG}.PrimAdd(...)` 等 (SSoT 直呼び)
42
- * - bare scalar → `${PKG}.EvalExpr(<lit>, scope)` (SSoT)
43
- * slRef/slRefOpt/slConcat は **生成モジュール内の native helper**(`EvaluateExpression`/`Prim*`
44
- * を呼ばない)で、pure ref/concat の生成コードには evaluate/primitive 呼びが一切現れない
45
- * (AC#2 の構造的 grep 証明)。
32
+ * emitExpr — Expression IR ノードを「scope を受けて (Value, error) を返す」Go 式に落とす
33
+ * (**dynamic 式専用**の legacy 経路 — RunPlan 経路と typed emitter が流用する seam)。
46
34
  */
47
35
  declare function emitExpr(node: unknown, scopeVar: string): string;
36
+ /** component 名を Go 関数名に使える形へ(決定的。名前一意は DUPLICATE_COMPONENT で保証)。 */
37
+ declare function sanitize(name: string): string;
48
38
  /** ops リテラル(RunPlan に渡す []OpSpec の Go リテラル)を綴じる。 */
49
39
  declare function emitOpsLiteral(plan: ComponentPlan): string;
50
- /** port ローカル変数名(Go 識別子として安全・一意)。宣言順に p0,p1,… を index で衝突回避。 */
40
+ /** port ローカル変数名(Go 識別子として安全)。 */
51
41
  declare function goPortVar(name: string): string;
52
42
  /** behavior plan({groups, concurrency})を *ExecutionPlanSpec Go リテラルへ。 */
53
43
  declare function emitBehaviorPlanLiteral(plan: unknown): string;
54
- /** component 名を Go 関数名に使える形へ(決定的。名前一意は DUPLICATE_COMPONENT で保証)。 */
55
- declare function sanitize(name: string): string;
56
44
  /**
57
- * go-typed(bc#47)が struct-native exec を綴じるために再利用する内部 emit ヘルパ。straight-line の
58
- * plan/handler-dispatch SSoT(RunPlan + ExecHandler + native/primitive port eval)をそのまま使い、
59
- * 「結果を Value scope でなく struct scope に持つ」差分だけを typed 側で足すための seam。runtime 語彙
60
- * (PKG)と ops/plan リテラル・式 emit を共有する(意味論の二重実装を避ける)。
45
+ * go-typed(bc#47)が struct-native exec を綴じるために再利用する内部 emit ヘルパ。
61
46
  */
62
47
  export declare const goStraightlineInternals: {
63
48
  PKG: string;
@@ -68,10 +53,6 @@ export declare const goStraightlineInternals: {
68
53
  sanitize: typeof sanitize;
69
54
  dialect: StraightlineDialect;
70
55
  };
71
- /**
72
- * goStraightlineEmitter — 言語識別子 `"go-straightline"` の emitter plugin。
73
- * 既存の `go`(リテラル焼き込み・endpoint 3-literal)と併存する additive な第2モード。
74
- */
75
56
  export declare const goStraightlineEmitter: EmitterPlugin;
76
57
  export {};
77
58
  //# sourceMappingURL=emit-straightline-go.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"emit-straightline-go.d.ts","sourceRoot":"","sources":["../../src/generator/emit-straightline-go.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,KAAK,EAAe,aAAa,EAAE,MAAM,WAAW,CAAC;AAE5D,OAAO,EAEL,KAAK,aAAa,EAElB,KAAK,mBAAmB,EACzB,MAAM,mBAAmB,CAAC;AAyD3B;;;;;;;;;;;;;;GAcG;AACH,iBAAS,QAA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