behavior-contracts 0.11.22 → 0.12.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 (76) hide show
  1. package/cli-contract.yaml +27 -20
  2. package/dist/behavior.d.ts +5 -0
  3. package/dist/behavior.d.ts.map +1 -1
  4. package/dist/behavior.js +11 -3
  5. package/dist/behavior.js.map +1 -1
  6. package/dist/cli.js +3 -3
  7. package/dist/cli.js.map +1 -1
  8. package/dist/generated/contract.d.ts.map +1 -1
  9. package/dist/generated/contract.js +2 -2
  10. package/dist/generated/contract.js.map +1 -1
  11. package/dist/generated/program.js +4 -4
  12. package/dist/generated/program.js.map +1 -1
  13. package/dist/generator/core.d.ts +13 -10
  14. package/dist/generator/core.d.ts.map +1 -1
  15. package/dist/generator/core.js.map +1 -1
  16. package/dist/generator/emit-native-dynamic.d.ts +203 -0
  17. package/dist/generator/emit-native-dynamic.d.ts.map +1 -0
  18. package/dist/generator/emit-native-dynamic.js +733 -0
  19. package/dist/generator/emit-native-dynamic.js.map +1 -0
  20. package/dist/generator/emit-native-php.d.ts +4 -0
  21. package/dist/generator/emit-native-php.d.ts.map +1 -0
  22. package/dist/generator/emit-native-php.js +668 -0
  23. package/dist/generator/emit-native-php.js.map +1 -0
  24. package/dist/generator/emit-native-python.d.ts +4 -0
  25. package/dist/generator/emit-native-python.d.ts.map +1 -0
  26. package/dist/generator/emit-native-python.js +592 -0
  27. package/dist/generator/emit-native-python.js.map +1 -0
  28. package/dist/generator/emit-php.d.ts +4 -0
  29. package/dist/generator/emit-php.d.ts.map +1 -1
  30. package/dist/generator/emit-php.js +6 -2
  31. package/dist/generator/emit-php.js.map +1 -1
  32. package/dist/generator/emit-python.d.ts +4 -0
  33. package/dist/generator/emit-python.d.ts.map +1 -1
  34. package/dist/generator/emit-python.js +2 -2
  35. package/dist/generator/emit-python.js.map +1 -1
  36. package/dist/generator/emit-shared-go-typed.d.ts +5 -78
  37. package/dist/generator/emit-shared-go-typed.d.ts.map +1 -1
  38. package/dist/generator/emit-shared-go-typed.js +8 -315
  39. package/dist/generator/emit-shared-go-typed.js.map +1 -1
  40. package/dist/generator/emit-shared-go.d.ts +12 -16
  41. package/dist/generator/emit-shared-go.d.ts.map +1 -1
  42. package/dist/generator/emit-shared-go.js +12 -1037
  43. package/dist/generator/emit-shared-go.js.map +1 -1
  44. package/dist/generator/emit-shared-rust-typed.d.ts +0 -93
  45. package/dist/generator/emit-shared-rust-typed.d.ts.map +1 -1
  46. package/dist/generator/emit-shared-rust-typed.js +7 -46
  47. package/dist/generator/emit-shared-rust-typed.js.map +1 -1
  48. package/dist/generator/emit-shared-rust.d.ts +5 -38
  49. package/dist/generator/emit-shared-rust.d.ts.map +1 -1
  50. package/dist/generator/emit-shared-rust.js +3 -1249
  51. package/dist/generator/emit-shared-rust.js.map +1 -1
  52. package/dist/generator/emit-typed-native-go.d.ts.map +1 -1
  53. package/dist/generator/emit-typed-native-go.js +31 -541
  54. package/dist/generator/emit-typed-native-go.js.map +1 -1
  55. package/dist/generator/emit-typed-native-rust.d.ts.map +1 -1
  56. package/dist/generator/emit-typed-native-rust.js +33 -455
  57. package/dist/generator/emit-typed-native-rust.js.map +1 -1
  58. package/dist/generator/index.d.ts +2 -0
  59. package/dist/generator/index.d.ts.map +1 -1
  60. package/dist/generator/index.js +9 -1
  61. package/dist/generator/index.js.map +1 -1
  62. package/dist/generator/native-coverage.d.ts +162 -0
  63. package/dist/generator/native-coverage.d.ts.map +1 -0
  64. package/dist/generator/native-coverage.js +412 -0
  65. package/dist/generator/native-coverage.js.map +1 -0
  66. package/dist/generator/native-expr.d.ts +1 -1
  67. package/dist/generator/native-expr.d.ts.map +1 -1
  68. package/dist/generator/straightline.d.ts +24 -6
  69. package/dist/generator/straightline.d.ts.map +1 -1
  70. package/dist/generator/straightline.js +79 -1
  71. package/dist/generator/straightline.js.map +1 -1
  72. package/dist/generator/typed.d.ts +6 -0
  73. package/dist/generator/typed.d.ts.map +1 -1
  74. package/dist/generator/typed.js +17 -0
  75. package/dist/generator/typed.js.map +1 -1
  76. package/package.json +1 -1
@@ -1,10 +1,11 @@
1
1
  import { entryPortOrder, GeneratorFailure } from "./core.js";
2
- import { isControlGate, mapNodeElemIsOpaqueWire, mapTransformExpr, nodeWirePassthrough } from "../behavior.js";
2
+ import { isControlGate, mapTransformExpr, nodeWirePassthrough } from "../behavior.js";
3
3
  import { goStraightlineInternals } from "./emit-shared-go.js";
4
4
  import { goTypedInternals } from "./emit-shared-go-typed.js";
5
5
  import { buildTypePlan, deriveTypeRef, findDecl, inputPortIsOptional, inputPortTypeRef, lowerProducedAwareRead, unproducedInSlot } from "./typed.js";
6
6
  import { concurrencyPlan, execPlan, analyzeSequentialOps, classifyExpr, buildComponentPlan, nodeNarrowedPaths, } from "./straightline.js";
7
7
  import { NativeExprCompiler } from "./native-expr.js";
8
+ import { NativeCoverage, buildTypedNodes, fanoutItemsElemRef, mapElemRowRef, resolveOverOrFail } from "./native-coverage.js";
8
9
  import { buildDeBoxPlan, buildWirePlan, notationOfRef } from "./emit-shared-debox.js";
9
10
  const PKG = "dslcontracts";
10
11
  /** resolveGoWire — the BC-OWNED wire type names the de-box classifies a node result against. bc OWNS +
@@ -118,12 +119,7 @@ func deMissingField(model, field, expected string) *BehaviorError {
118
119
  }`;
119
120
  }
120
121
  const { sanitize, emitExpr } = goStraightlineInternals;
121
- const { goFieldName, renderTypeRef, goScalar, serializeTyped, emitTypeDecls, emitTypedValue, checkOutputFieldType, } = goTypedInternals;
122
- /** typed node-result local — MUST match goTypedInternals.typedLocal (`t_<id>`) so the reused
123
- * emitTypedValue (output assembly via struct field access) reads the same locals. */
124
- function typedLocal(nodeId) {
125
- return `t_${nodeId.replace(/[^A-Za-z0-9_]/g, "_")}`;
126
- }
122
+ const { goFieldName, renderTypeRef, goScalar, serializeTyped, emitTypeDecls, emitTypedValue, checkOutputFieldType, typedLocal, } = goTypedInternals;
127
123
  // ── strict de-box: the ONE inline renderer over the SSoT plan ─────────────────────────────
128
124
  //
129
125
  // A covered node result de-box is compiled INLINE at its consumption point from the language-neutral
@@ -679,17 +675,7 @@ func ProbeListOf(w *WireValue) ListProbe {
679
675
  }
680
676
  }`;
681
677
  }
682
- /** mapFanoutElemRef — the element ROW TypeRef a map/fanout node decodes (the per-element record). */
683
- function mapFanoutElemRef(node, typedNodes, plan) {
684
- const ref = typedNodes.get(node.id);
685
- if ("fanout" in node)
686
- return fanoutItemsElemRef(node, ref, plan);
687
- return mapElemRowRef(node, ref, plan);
688
- }
689
- /** scalar TypeRef → PortFieldType (native go scalar kind). */
690
- function goScalarPortField(scalar) {
691
- return scalar === "string" ? "string" : scalar === "int" ? "int64" : scalar === "float" ? "float64" : "bool";
692
- }
678
+ // ── native ports struct (mirrors the native emitter: typed fields, direct assignment) ──
693
679
  /**
694
680
  * goNativeResolveHead — the ONE ref-head resolver the runtime-free native-expr compiler reads, for cond
695
681
  * `if`/branches, a map/fanout `when` guard, AND a port. A head is a `$as` element binding, a prior body
@@ -743,403 +729,13 @@ function compilePortNode(node, comp, plan, typedNodes, isPrior, where, expected,
743
729
  // no separate input-side integrity gate exists.
744
730
  return c;
745
731
  }
746
- /**
747
- * portFieldGoType — the NATIVE Go type for a covered port field (bc#90 / runtime-free). The covered
748
- * ports struct carries NO `dslcontracts.Value` field: every port lowers to a concrete Go type.
749
- * - a static string-array (projection) → `[]string` (change #2);
750
- * - a bare int/float number literal (e.g. Query `limit: 20`) → `int64`/`float64`;
751
- * - a string/bool/scalar-input port → the scalar Go type (inferPortType).
752
- * A port that would otherwise infer to the boxed `Value` (a dynamic operator, a non-static array, a
753
- * Value-typed input) FAILS CLOSED — the covered read plane admits NO boxed escape (there is no
754
- * `dslcontracts.Value` fallback on the native module). `where` names the emission site for the error.
755
- */
756
- function portFieldGoType(node, comp, plan, typedNodes, expected, where = "port", opts) {
757
- const c = compilePortNode(node, comp, plan, typedNodes, (h) => typedNodes.has(h), where, expected, opts);
758
- return renderTypeRef(c.ref);
759
- }
760
- function staticArrElems(node) {
761
- if (node === null || typeof node !== "object" || Array.isArray(node))
762
- return null;
763
- const keys = Object.keys(node);
764
- if (keys.length !== 1 || keys[0] !== "arr")
765
- return null;
766
- const arg = node.arr;
767
- return Array.isArray(arg) ? arg : null;
768
- }
769
- /**
770
- * isNativeRawComponent — a component covered by the combined read emitter. Strictly sequential
771
- * (no real concurrency), body is ALL componentRef (no map/cond), default 'fail'/'continue'
772
- * policy, relationKind is single/connection or absent, and EVERY node carries outType + the
773
- * component carries outputType. the relation bindField ARE the point — inline exec makes
774
- * the child-present decision from the real parent result. Ports AND the output are evaluated via
775
- * the primitive SSoT over a Value-space portScope (so a dynamic operator in a port or an
776
- * obj-assembly output is fine — the SSoT handles fail-closed semantics; only the RESULT plane +
777
- * PORT container go native). A covered SHAPE that lacks outType is a fail-closed error raised at
778
- * emit (see assertTypedCoverage) — never a silent re-box.
779
- */
780
- /**
781
- * numLiteralGoExpr — a BARE numeric port literal (JSON number, e.g. the `limit: 20` Query port).
782
- * `classifyExpr` deliberately leaves a bare number `dynamic` (its checked int/float range rules are
783
- * the evaluate SSoT, expr.go evalNumberLiteral), so a plain number never reaches the str/bool/null
784
- * static branch. But a number literal IS statically resolvable to a native Go Value: the SAME
785
- * range check the runtime applies is performed HERE at generation time (integral literal in the
786
- * safe 2^53-1 window → int64; a fractional/exponent literal → the checked float64). Returns the Go
787
- * expression for the literal's Value, or null when the node is not a bare number OR the integral
788
- * literal is out of the safe window (that out-of-range case keeps the runtime INVALID_LITERAL
789
- * semantics — the port is NOT covered natively, so the whole component falls through, never a
790
- * silently-wrong inline). Mirrors coderuntime.evalNumberLiteral exactly.
791
- */
792
- const NUM_SAFE_INT = 9007199254740991; // 2^53 - 1 (expr.go safeInt)
793
- function numLiteralGoExpr(node) {
794
- if (typeof node !== "number" || !Number.isFinite(node))
795
- return null;
796
- if (Number.isInteger(node)) {
797
- if (node < -NUM_SAFE_INT || node > NUM_SAFE_INT)
798
- return null; // out of safe window → not covered (runtime INVALID_LITERAL)
799
- return `${PKG}.Value(int64(${node}))`;
800
- }
801
- // fractional / exponent literal → checked float64 (finite, already guaranteed above).
802
- return `${PKG}.Value(float64(${node}))`;
803
- }
804
- /** A port node is static (literal / ref / concat of those / static arr / bare number literal) —
805
- * resolvable to a native Go Value with no NewObj / no evaluate interpreter. */
806
- /** planForComp — a TypePlan for a single component (its named types are component-scoped, so a
807
- * one-component IR yields the same plan the full-IR build would for this component). */
808
- function planForComp(comp) {
809
- return buildTypePlan({ irVersion: 2, exprVersion: 2, components: [comp] });
810
- }
811
- /** buildTypedNodes — the prior-node typed-local TypeRef map for a component (control-gate nodes are
812
- * typeless; a map node carries its produced-array ref). An untyped node is omitted (not an error here). */
813
- function buildTypedNodes(comp, plan) {
814
- const typedNodes = new Map();
815
- for (const n of comp.body) {
816
- if (isControlGate(n))
817
- continue;
818
- try {
819
- typedNodes.set(n.id, "map" in n ? mapNodeArrRef(n, plan) : deriveTypeRef(n.outType, plan));
820
- }
821
- catch {
822
- /* untyped node — omit */
823
- }
824
- }
825
- return typedNodes;
826
- }
827
- /** mapAsBinding — the `$as` element binding for a map/fanout node's element ports (the over-element
828
- * TypeRef), or undefined when the over source does not resolve (an uncovered map). */
829
- function mapAsBinding(comp, node, typedNodes, plan) {
830
- try {
831
- return { name: node.map.as, ref: mapOverElemInfo(comp, node, typedNodes, plan).elemRef, plan };
832
- }
833
- catch {
834
- return undefined;
835
- }
836
- }
837
- /** portIsStatic — the ELIGIBILITY gate ASKS the one port lowering (compilePortNode / native-expr)
838
- * whether it can lower this port, rather than re-deriving the shape rules — so the gate and the emitter
839
- * can never disagree. A port that does not lower (or lowers fallibly) fails closed. */
840
- function portIsStatic(node, comp, plan, typedNodes, expected, asBinding, narrowed) {
841
- try {
842
- void 0;
843
- // #170: eligibility asks the SAME lowering emission uses, with the SAME node narrowing — so a
844
- // gate/guard-proven opt-in-required port is judged covered iff it also emits (they cannot disagree).
845
- // #173: with the SAME declared `expected` port type (covered iff it materializes to that type).
846
- const opts = asBinding !== undefined ? { asBinding, asBase: asBinding.name, narrowed } : narrowed !== undefined ? { narrowed } : undefined;
847
- compilePortNode(node, comp, plan, typedNodes, (h) => typedNodes.has(h), "port", expected, opts);
848
- return true;
849
- }
850
- catch {
851
- return false;
852
- }
853
- }
854
- /** The output must lower to a typed struct/value with no Value-scope read: a ref whose head is a
855
- * BODY NODE (typed), an obj/arr of native-lowerable outputs, or a concat of them. A ref to an
856
- * input param or a non-concat operator is NOT native-lowerable here (falls through). */
857
- function outputIsNativeLowerable(comp) {
858
- const bodyIds = new Set(comp.body.map((n) => n.id));
859
- const walk = (node) => {
860
- const arr = staticArrElems(node);
861
- if (arr !== null)
862
- return arr.every(walk);
863
- if (node !== null && typeof node === "object" && !Array.isArray(node)) {
864
- const keys = Object.keys(node);
865
- if (keys.length === 1 && keys[0] === "obj") {
866
- const obj = node.obj;
867
- return Object.keys(obj).every((k) => walk(obj[k]));
868
- }
869
- if (keys.length === 1 && keys[0] === "arr")
870
- return true; // handled by staticArrElems above
871
- }
872
- const e = classifyExpr(node);
873
- if (e.kind === "str" || e.kind === "bool" || e.kind === "null")
874
- return true;
875
- // ref OR refOpt to a body node (typed). refOpt is how a produced-aware output reads a skippable
876
- // relation child: the head node's produced flag gates it, yielding opt-nil when unproduced.
877
- if (e.kind === "ref")
878
- return bodyIds.has(e.path[0]); // must ref a body node (typed), not input
879
- if (e.kind === "concat")
880
- return e.parts.every((p) => walk(reconstructG(p)));
881
- return false;
882
- };
883
- return walk(comp.output);
884
- }
885
- /** A native-raw component MUST be fully typed (outType on every node + outputType). */
886
- function isFullyTyped(comp) {
887
- if (comp.outputType === undefined)
888
- return false;
889
- for (const n of comp.body) {
890
- // #125: a control-gate cond is a typeless skip marker (A3) — it never de-boxes a result, so it is
891
- // exempt from the "every node carries outType" de-box requirement (matches type-gate's exemption).
892
- if (isControlGate(n))
893
- continue;
894
- if (n.outType === undefined)
895
- return false;
896
- }
897
- return true;
898
- }
899
- function isNativeRaw(comp) {
900
- return isSequentialComponentRefRead(comp) && isFullyTyped(comp);
901
- }
902
- /**
903
- * coveredMapNode — the #86 part 2 covered map shape (nestedBatchGet). A BATCHED `map` node whose:
904
- * - over is a static ref (to a prior node's typed collection field OR an input array),
905
- * - `into` is set (zip-attach the batched handler result onto every over element),
906
- * - every element port is static (literal / ref into the element binding / concat / static arr),
907
- * - element outType is a NAMED struct (the augmented element type — over element + the into field),
908
- * - no `when` guard (guard+into => heterogeneous elements, not one []T — stays boxed),
909
- * - relationKind single/connection or absent (every Error Policy Kind is covered — goPolicyArm).
910
- * This is the struct-native de-box of a typed `map...into` element collection: build the per-element
911
- * native ports struct, dispatch the batched handler ONCE (RawValue out), and assemble each augmented
912
- * element struct by copying the over element's typed fields + materializing the into field from the
913
- * aligned batch raw — NO boxed Value on any plane.
914
- */
915
- function coveredMapNode(n, bodyIds, comp) {
916
- if (n === null || typeof n !== "object" || !("map" in n))
917
- return false;
918
- const m = n.map;
919
- // #86 pt2: batched map...into. #93 shape 2/3: (non-)batched map...into / connection-collect. #108:
920
- // a guarded map (`when`) IS covered when it has NO `into`. #177/#182/#232: a `map...into` ALWAYS has a
921
- // well-defined unproduced value for the into field — the into field is OPT (unproduced → nil, #177) OR
922
- // relationKind:connection (unproduced → the empty connection {items:[],cursor:null}, #182). The type
923
- // gate (`mapIntoHoldsUnproduced`, run for every component at the codegen entry) rejects anything else
924
- // BEFORE any emitter sees it (#232), so the augmented list is homogeneous here by construction (kept
925
- // element → present into, unproduced → the skip value), EXACTLY run_behavior's applyInto. The skip
926
- // value below (goZero of the into row type) yields nil / connection-struct-zero.
927
- if (m.relationKind !== undefined && m.relationKind !== "connection")
928
- return false;
929
- // A map node must carry an outType (its ELEMENT type per the recorder SoT — authoring.ts recordMap
930
- // holds `node.outType = mapElem`, the PRE-array-wrap element; the emitter synthesizes the produced
931
- // `[]element`). A map WITHOUT outType is uncovered. Legacy hand-built IR that already carries the
932
- // The map node's outType is the ELEMENT type; mapNodeArrRef wraps it to the produced array ref.
933
- // bc#164: an OPAQUE ELEMENT (`outType:"value"` on an output-passthrough map — mapNodeElemIsOpaqueWire,
934
- // the shared rule) IS covered: each element wire is stored AS-IS in the produced list (no de-box, no
935
- // per-op re-box), exactly as the componentRef path treats a passthrough result. Any other non-compound
936
- // element type stays uncovered (loud), as before.
937
- const outT = n.outType;
938
- // #225: 純式 map(`transform`)の要素は**式から native に組む**(ワイヤも de-box も無い)ので、要素型が
939
- // スカラでも被覆される — 宣言型 materializer が組めれば良く、組めなければそこで loud に落ちる。
940
- // Component map は要素 wire を de-box するので従来どおり compound / opaque wire に限る。
941
- const isTransformMap = mapTransformExpr(m) !== undefined;
942
- if (outT === undefined)
943
- return false;
944
- if (!isTransformMap && typeof outT !== "object" && !mapNodeElemIsOpaqueWire(n))
945
- return false;
946
- // `over` element type must be STATICALLY resolvable: a ref to a PRIOR BODY NODE's typed arr field
947
- // (mapOverElemType) OR a ref to an INPUT array port that carries `elemType` (#108 — the C3 "BC does
948
- // not infer" rule: an input array WITHOUT elemType stays fail-closed / uncovered).
949
- const overE = classifyExpr(m.over);
950
- if (overE.kind !== "ref")
951
- return false;
952
- const head = overE.path[0];
953
- if (!bodyIds.has(head)) {
954
- // input-array over: covered only when the input port declares elemType (#108 — the C3 "BC does not
955
- // infer" rule: an input array WITHOUT elemType stays uncovered). #177 (A): an OPT input array
956
- // (`{opt:{arr}}`, required:false) IS covered — its null iterates EMPTY (goOverElemInfo.optArr → the arm
957
- // binds `over` via a nil-safe deref, `range` over a nil slice = 0), byte-equal to run_behavior.
958
- if (overE.path.length !== 1)
959
- return false;
960
- const schema = comp.inputPorts?.[head];
961
- if (schema === undefined || schema.elemType === undefined)
962
- return false;
963
- }
964
- // 純式 map(#222)は port を持たない: 被覆条件は「要素式が宣言された要素型へ native に materialize
965
- // できること」で、それは compilePortNode(宣言型 materializer)が失敗したときに loud に落ちる。
966
- const ports = (m.ports ?? {});
967
- const plan = planForComp(comp);
968
- const typedNodes = buildTypedNodes(comp, plan);
969
- const asBinding = mapAsBinding(comp, n, typedNodes, plan);
970
- const narrowed = nodeNarrowedPaths(comp, n);
971
- const mSchemas = m.portSchemas;
972
- for (const p of Object.keys(ports))
973
- if (!portIsStatic(ports[p], comp, plan, typedNodes, inputPortTypeRef(mSchemas?.[p], plan), asBinding, narrowed))
974
- return false;
975
- return true;
976
- }
977
- /**
978
- * coveredFanoutNode (v3) — a FANOUT node (first-class `@refs` id-list fan-out) is covered when:
979
- * - over is a static ref to a PRIOR BODY NODE's typed arr field OR an INPUT array port with elemType,
980
- * - every element port is static (literal / ref into the $as binding / concat / static arr),
981
- * - relationKind connection (guard-checked by the guard/builder); every Error Policy Kind is covered.
982
- * The fanout de-boxes to: one deduped batched dispatch → first-seen dedupe (by the elem's dedupeKey
983
- * field) + dangling drop + implicitSource strip + connection wrap {items, cursor:nil} — NO boxed Value.
984
- */
985
- function coveredFanoutNode(n, bodyIds, comp) {
986
- if (n === null || typeof n !== "object" || !("fanout" in n))
987
- return false;
988
- const f = n.fanout;
989
- if (f.relationKind !== "connection")
990
- return false;
991
- const overE = classifyExpr(f.over);
992
- if (overE.kind !== "ref")
993
- return false;
994
- const head = overE.path[0];
995
- if (!bodyIds.has(head)) {
996
- // input-array over: covered only when the port declares elemType (C3 — no inference). #177 (A): an OPT
997
- // input array (`{opt:{arr}}`, required:false) IS covered — its null iterates EMPTY (goOverElemInfo.optArr
998
- // → nil-safe deref, `range`/`len` over a nil slice = 0), byte-equal to run_behavior.
999
- if (overE.path.length !== 1)
1000
- return false;
1001
- const schema = comp.inputPorts?.[head];
1002
- if (schema === undefined || schema.elemType === undefined)
1003
- return false;
1004
- }
1005
- const ports = f.ports;
1006
- const plan = planForComp(comp);
1007
- const typedNodes = buildTypedNodes(comp, plan);
1008
- let asBinding;
1009
- try {
1010
- asBinding = { name: f.as, ref: fanoutOverElemInfo(comp, n, typedNodes, plan).elemRef, plan };
1011
- }
1012
- catch {
1013
- asBinding = undefined;
1014
- }
1015
- const fSchemas = f.portSchemas;
1016
- for (const p of Object.keys(ports))
1017
- if (!portIsStatic(ports[p], comp, plan, typedNodes, inputPortTypeRef(fSchemas?.[p], plan), asBinding))
1018
- return false;
1019
- return true;
1020
- }
1021
- /** A covered read SHAPE (typing-independent) — sequential componentRef reads + covered map...into,
1022
- * OR a real-concurrency staged plan (bc#87) whose parallel-stage members are plain componentRef point
1023
- * reads. A real-concurrency plan whose parallel members include a map / bindField-relation child is
1024
- * NOT covered here (falls through) — the static-parallel orchestration covers the componentRef fan-out
1025
- * (the GroupAccessRead shape); a parallel map/relation-child stage is a further shape (out of scope). */
1026
- function isSequentialComponentRefRead(comp) {
1027
- return coverageRejectReason(comp) === null;
1028
- }
1029
- /**
1030
- * coverageRejectReason — the DIAGNOSTIC twin of isSequentialComponentRefRead (bc#86/#89). Returns
1031
- * null when the component IS a covered native read; otherwise a SPECIFIC human-readable reason naming
1032
- * the exact disqualifier and the offending node id. The predicate logic is IDENTICAL to
1033
- * isSequentialComponentRefRead (which is defined as `coverageRejectReason(c) === null`) so the two can
1034
- * never disagree. This is the message the fail-closed dispatch surfaces per non-native component — the
1035
- * user's signal to add native coverage, fix a genuinely-dynamic spec, or use the --ir dynamic surface.
1036
- */
1037
- function coverageRejectReason(comp) {
1038
- const crPlan = planForComp(comp);
1039
- const crTypedNodes = buildTypedNodes(comp, crPlan);
1040
- const ep = execPlan(comp);
1041
- if (ep === null)
1042
- return "component is not a straight-line/staged sequential exec plan (no static exec plan)";
1043
- // A parallel-stage member must be a componentRef node (no map) so the static parallel orchestration
1044
- // is a clean fan-out — the bounded-concurrency error-precedence protocol is proven for that shape.
1045
- // A map child inside a parallel stage still falls through (its per-element loop is a further shape).
1046
- // #114: a bindField relation child (single|connection) IS covered inside a parallel stage — the
1047
- // sibling hasMany fan-out (parent → members ∥ permissions). Its bound-key skip-gate is preflighted
1048
- // per member (from the settled parent) BEFORE dispatch, so the parallel fan-out keeps run_behavior's
1049
- // per-member skip semantics; the per-node relationKind constraint below (single|connection) applies
1050
- // to it too. A non-single/connection bindField member is rejected by that shared check.
1051
- for (const [i] of ep.parallelStageOf) {
1052
- const n = comp.body[i];
1053
- // #125/#108: a cond node IS allowed as a parallel-stage member — it is a pure Expression (no
1054
- // dispatch), evaluated in preflight ascending order, so its produced flag / typed result cell is
1055
- // settled before any dispatch. It carries no handler and no boxed result, so it does not disturb the
1056
- // bounded-concurrency error-precedence protocol (which governs the componentRef fan-out members).
1057
- // Covers BOTH the when(...) control-gate cond (#136, {ok}/null skip marker) AND the Φ-merge VALUE
1058
- // cond (#108, has outType, then/else are data branches — the sibling Φ-join). The cond's own
1059
- // validity (a value cond REQUIRES outType; a control gate is exempt) is enforced by the per-node
1060
- // cond check below, so a parallel value cond without outType still loud-rejects there.
1061
- // #225: 純式 map(`map.transform` — Component 呼びなし)も同じ性質を持つ: handler も boxed result も
1062
- // 無い変換なので、昇順 preflight で確定させれば bounded-concurrency の error-precedence 協定
1063
- // (componentRef fan-out メンバを統べる)を乱さない。cond の免除根拠がそのまま当てはまる。
1064
- if ("cond" in n)
1065
- continue;
1066
- if ("map" in n && mapTransformExpr(n.map) !== undefined)
1067
- continue;
1068
- if (!("component" in n))
1069
- return `node '${n.id}' is a non-componentRef member of a parallel stage (not native-covered)`;
1070
- }
1071
- const bodyIds = new Set(comp.body.map((b) => b.id));
1072
- for (const n of comp.body) {
1073
- if ("cond" in n) {
1074
- // #125: a when(...) control-gate cond (`{if, then:{obj:{ok:true}}, else:null}`) は制御スキップ
1075
- // マーカーで出力データ型を持たない(A3 の意図的 typeless design)— outType を要求しない。gate は
1076
- // if を native bool へコンパイルし produced_<gate> に写すだけで、分岐内ノードは既存の
1077
- // `parent=gate, bindField:"ok"` skip-gate(run_behavior の null-binding skip)が実行選択する。
1078
- if (isControlGate(n))
1079
- continue;
1080
- // #108: a DATA-JOIN cond node (Φ 合流) is native-covered — its `if`/`then`/`else` compile to native
1081
- // expressions via the runtime-free NativeExprCompiler (byte-equal to run_behavior's cond lower). If an
1082
- // expression is not statically compilable (uncovered op / refOpt / opt operand / type mismatch), the
1083
- // compiler fails closed at emit (a loud GeneratorFailure) — never a silent box. A data-join cond
1084
- // requires outType(合流値を de-box する対象だから — control gate だけがこの要求を免除される)。
1085
- if (n.outType === undefined)
1086
- return `node '${n.id}' cond has no outType (required to de-box the branch join)`;
1087
- continue;
1088
- }
1089
- if ("fanout" in n) {
1090
- // v3: a first-class fanout node (deduped connection list-in fan-out) IS covered when its over is a
1091
- // covered ref (prior-node arr / input array with elemType) and its element ports are static.
1092
- if (!coveredFanoutNode(n, bodyIds, comp))
1093
- return `node '${n.id}' is a non-covered fanout shape (over an input array without elemType, or a dynamic element port)`;
1094
- continue;
1095
- }
1096
- if ("map" in n) {
1097
- // #86 pt2 batched map...into / #93 shape 2/3 / #108 guarded map (no into) / map-over-input (with
1098
- // elemType) ARE covered. A non-covered map shape (guard+into heterogeneous / over-input without
1099
- // elemType) falls through to the loud fail-closed reject.
1100
- if (!coveredMapNode(n, bodyIds, comp))
1101
- return `node '${n.id}' is a non-covered map shape (guard+into heterogeneous, or over an input array without elemType)`;
1102
- continue;
1103
- }
1104
- if (!("component" in n))
1105
- return `node '${n.id}' is not a componentRef, map, or cond node (not native-covered)`;
1106
- const cr = n;
1107
- // Every Error Policy Kind IS covered on a componentRef: `continue` makes the node unproduced, which the
1108
- // produced-aware output lowering (typed.ts `lowerProducedAwareRead`, driven by the same canSkip the
1109
- // bindField skip uses) already renders, and `retry` shares `fail`'s control flow with the Kind named
1110
- // (the attempts themselves are Runtime-owned — scp-error.md §Separating Policy Kind and Tuning, which
1111
- // in native mode is the per-Component leaf transport). Proven by real go build + run, not by assertion.
1112
- // #86 part 1: a relation child WITH bindField IS covered. When the
1113
- // bound parent field is null/absent the child is UNPRODUCED — the produced-aware output lowering
1114
- // (`lowerProducedAwareRead`, handed to the ONE output recursion so it reaches every output slot) then
1115
- // yields the unproduced rep (null / opt-nil) for a ref/refOpt into it, matching run_behavior's
1116
- // bindUnproduced. #93 shape 1: a bindField on a relationKind:connection child is ALSO covered — the
1117
- // connection's unproduced rep is the empty connection {items:[],cursor:null}
1118
- // (unproducedValue("connection")), which `unproducedInSlot` emits explicitly for a skipped connection
1119
- // node (a ref into it yields {items:[],cursor:null}, matching run_behavior).
1120
- // relationKind の閉集合は `connection` の 1 値で、**注記の不在**が「未生成は null」を意味する。ゆえに
1121
- // bindField 由来 skip は 2 形(connection = 空 connection / 不在 = null)とも produced-aware 出力が
1122
- // 表現でき、被覆条件は無い(かつての「明示的に single と書け」は既定値の重複綴りの要求だった)。
1123
- if (cr.relationKind !== undefined && cr.relationKind !== "connection")
1124
- return `relationKind '${cr.relationKind}' not native-covered (node '${n.id}')`;
1125
- // #170: a control-gate child's ports may narrow a gate-proven opt ref to non-null (the (a3) gated read).
1126
- const crNarrowed = nodeNarrowedPaths(comp, cr);
1127
- for (const p of Object.keys(cr.ports))
1128
- if (portIsStatic(cr.ports[p], comp, crPlan, crTypedNodes, inputPortTypeRef(cr.portSchemas?.[p], crPlan), undefined, crNarrowed) === false)
1129
- return `node '${n.id}' port '${p}' is not statically resolvable`;
1130
- }
1131
- if (!outputIsNativeLowerable(comp))
1132
- return "output is not natively lowerable";
1133
- return null;
1134
- }
1135
- /** Fail closed if a covered read SHAPE lacks the typed annotations (no silent boxed re-box). */
1136
- function assertTypedCoverage(comp) {
1137
- if (!isSequentialComponentRefRead(comp))
1138
- return;
1139
- if (isFullyTyped(comp))
1140
- return;
1141
- throw new GeneratorFailure("UNSUPPORTED_NODE_STRAIGHTLINE", `go combined read (bc#77): component '${comp.name}' is a sequential componentRef read but lacks outType/outputType on every node — the combined emitter de-boxes the RESULT into the node's outType struct, so a covered read MUST be fully typed (bc#45). Add outType annotations, or regenerate on go-straightline-native (boxed result).`);
1142
- }
732
+ /** goCoverage — the ONE native coverage rule (native-coverage.ts) bound to the Go port lowering: eligibility
733
+ * asks {@link compilePortNode} — the SAME lowering emission uses, with the SAME narrowing and declared port
734
+ * type — so a port is judged covered iff it also emits. */
735
+ const goCoverage = new NativeCoverage("go", "go typed-native", (node, comp, plan, typedNodes, expected, { asBinding, narrowed }) => {
736
+ const opts = asBinding !== undefined ? { asBinding, asBase: asBinding.name, narrowed } : narrowed !== undefined ? { narrowed } : undefined;
737
+ compilePortNode(node, comp, plan, typedNodes, (h) => typedNodes.has(h), "port", expected, opts);
738
+ });
1143
739
  /**
1144
740
  * resolveLeafSymbol — the op-agnostic transport symbol a covered leaf (= catalog component) is called
1145
741
  * through at its execution point. A consumer-supplied override (`leafTransport.symbols[component]`) wins;
@@ -1232,51 +828,19 @@ function mapElemMaterializerName(compName, nodeId) {
1232
828
  return `materializeMapElemNR_${sanitize(compName)}_${nodeId.replace(/[^A-Za-z0-9_]/g, "_")}`;
1233
829
  }
1234
830
  /**
1235
- * fanoutItemsElemRef (v3) — the connection items ELEMENT TypeRef for a covered fanout node. The fanout
1236
- * outType is a connection struct `{items:[]Elem, cursor:*string}`; this returns Elem (the per-body row
1237
- * the batched handler yields, aligned to the deduped id list, before dedupe/drop). Fails closed if the
1238
- * outType is not that connection shape (named struct with an `items` arr field).
1239
- */
1240
- function fanoutItemsElemRef(node, connRef, plan) {
1241
- if (connRef.kind !== "named") {
1242
- throw new GeneratorFailure("UNSUPPORTED_NODE_STRAIGHTLINE", `go fanout (v3): node '${node.id}' outType must be a connection struct {items,cursor} (got ${JSON.stringify(connRef.kind)}).`);
1243
- }
1244
- const decl = findDecl(plan, connRef.name);
1245
- const itemsField = decl.fields.find((fd) => fd.name === "items");
1246
- if (!itemsField || itemsField.type.kind !== "arr") {
1247
- throw new GeneratorFailure("UNSUPPORTED_NODE_STRAIGHTLINE", `go fanout (v3): node '${node.id}' connection struct '${connRef.name}' has no 'items' array field.`);
1248
- }
1249
- return itemsField.type.elem;
1250
- }
1251
- /**
1252
- * goOverElemInfo — the ONE resolver of a fanout/map `over` to its element TypeRef + native Go over-slice
1253
- * expression (fanoutOverElemInfo / mapOverElemInfo both delegate here — single definition, no forked twin).
1254
- *
1255
- * `optArr` is true when the over's declared type is `{opt:{arr}}` (a prior-node opt-arr field OR an OPT
1256
- * input array port). #177 (A): a null opt-arr over then iterates EMPTY — the emitted `overExpr` is a
1257
- * `*[]E` pointer (nil when the optional collection is absent), which the arm binds via a nil-safe deref so
1258
- * `range`/`len` see a 0-length slice, byte-equal to run_behavior's empty iteration. A REQUIRED arr (nil)
1259
- * still fails run_behavior FANOUT/MAP_OVER_NOT_ARRAY, so it stays optArr:false (non-covered on null).
831
+ * goOverElemInfo — the Go read of a fanout/map `over` collection: the element TypeRef, the optional-array
832
+ * flag and the source come from the ONE resolver {@link resolveOverOrFail} (native-coverage.ts); this
833
+ * renders only the native Go over-slice expression of that source (fanoutOverElemInfo / mapOverElemInfo
834
+ * both delegate here). #177 (A): for an `optArr` over the emitted `overExpr` is a `*[]E` pointer (nil when
835
+ * the optional collection is absent), which the arm binds via a nil-safe deref so `range`/`len` see a
836
+ * 0-length slice, byte-equal to run_behavior's empty iteration.
1260
837
  */
1261
838
  function goOverElemInfo(comp, over, typedNodes, plan, nodeId, label) {
1262
- const e = classifyExpr(over);
1263
- if (e.kind === "ref" && e.path.length >= 1 && typedNodes.has(e.path[0])) {
1264
- const baseRef = typedNodes.get(e.path[0]);
1265
- const { expr, ref } = goTypedInternals.typedFieldAccess(typedLocal(e.path[0]), baseRef, e.path.slice(1), plan);
1266
- if (ref.kind === "arr")
1267
- return { elemRef: ref.elem, overExpr: expr, optArr: false };
1268
- if (ref.kind === "opt" && ref.inner.kind === "arr")
1269
- return { elemRef: ref.inner.elem, overExpr: expr, optArr: true };
1270
- }
1271
- if (e.kind === "ref" && e.path.length === 1) {
1272
- const schema = comp.inputPorts?.[e.path[0]];
1273
- const et = schema?.elemType;
1274
- // #192: read the input port via the goInputHeadRef seam (single input-ref path) — not a parallel `in.<Field>`.
1275
- const head = goInputHeadRef(e.path[0], comp, plan);
1276
- if (et !== undefined && head !== null)
1277
- return { elemRef: deriveTypeRef(et, plan), overExpr: head.expr, optArr: inputPortIsOptional(schema) };
1278
- }
1279
- throw new GeneratorFailure("UNSUPPORTED_NODE_STRAIGHTLINE", `go ${label}: '${nodeId}' 'over' must be a ref to a prior node's typed arr field OR an input array port with a declared elemType (got ${JSON.stringify(over)}). BC does not infer input-array element types (consumer-interface C3).`);
839
+ const r = resolveOverOrFail("go", comp, over, typedNodes, plan, nodeId, label);
840
+ const overExpr = r.source.kind === "node"
841
+ ? goTypedInternals.typedFieldAccess(typedLocal(r.source.head), typedNodes.get(r.source.head), r.source.path, plan).expr
842
+ : goInputHeadRef(r.source.port, comp, plan).expr; // #192: the input port via the goInputHeadRef seam
843
+ return { elemRef: r.elemRef, overExpr, optArr: r.optArr };
1280
844
  }
1281
845
  /**
1282
846
  * goBindOver — emit the `over_<s>` binding lines. A non-opt over binds the slice directly; an opt-arr over
@@ -1297,33 +861,6 @@ function goBindOver(indent, s, overExpr, optArr, overElemGo) {
1297
861
  function fanoutOverElemInfo(comp, node, typedNodes, plan) {
1298
862
  return goOverElemInfo(comp, node.fanout.over, typedNodes, plan, node.id, "fanout (v3)");
1299
863
  }
1300
- /** mapNodeArrRef — the map node's PRODUCED-ARRAY TypeRef from its `outType`.
1301
- *
1302
- * A map node's `outType` is its ELEMENT type (scp-error.md "Map element type"), so the produced array
1303
- * is `{arr: element}`. This is the same reading the compiler applies when it resolves what a node
1304
- * result reference has (`type-gate`: `"map" in n ? {arr:ot} : ot`) — the emitter follows that SSoT
1305
- * rather than inspecting the annotation's shape, so an element that is ITSELF an `arr` stays
1306
- * expressible (element `arr(T)` produces `arr(arr(T))`). */
1307
- function mapNodeArrRef(node, plan) {
1308
- const outT = node.outType;
1309
- return deriveTypeRef({ arr: outT }, plan);
1310
- }
1311
- /** mapElemRowRef — the handler's per-element RETURN shape for a covered map node: the `into` field's
1312
- * type (into) or the element outType directly (no-into). This is the type of RawElem_<comp>_<node>. */
1313
- function mapElemRowRef(node, arrRef, plan) {
1314
- const m = node.map;
1315
- if (m.into === undefined)
1316
- return arrRef.elem;
1317
- if (arrRef.elem.kind !== "named") {
1318
- throw new GeneratorFailure("UNSUPPORTED_NODE_STRAIGHTLINE", `go combined map (#86 pt2): node '${node.id}' element outType must be a named struct (got ${JSON.stringify(arrRef.elem.kind)}) — the augmented element de-boxes into a struct. Regenerate as boxed typed/straight-line.`);
1319
- }
1320
- const decl = findDecl(plan, arrRef.elem.name);
1321
- const intoField = decl.fields.find((f) => f.name === m.into);
1322
- if (!intoField) {
1323
- throw new GeneratorFailure("UNSUPPORTED_NODE_STRAIGHTLINE", `go combined map (#86 pt2): element struct '${arrRef.elem.name}' has no '${m.into}' (into) field.`);
1324
- }
1325
- return intoField.type;
1326
- }
1327
864
  /**
1328
865
  * emitMapElemMaterializers — for each covered map...into node, emit the AUGMENTED-element copier: copy
1329
866
  * the over element's typed fields + place the already-de-boxed `into` value into its field. Pure struct
@@ -1346,7 +883,7 @@ function emitMapElemMaterializers(comp, typedNodes, plan) {
1346
883
  // over element type (all element fields EXCEPT the into field): these come from the over element
1347
884
  // struct (the parent collection element). We copy each by same-named field access.
1348
885
  const overFields = decl.fields.filter((f) => f.name !== intoKey);
1349
- const intoRowRef = mapElemRowRef(n, arrRef, plan);
886
+ const intoRowRef = mapElemRowRef("go", n, arrRef, plan);
1350
887
  const fn = mapElemMaterializerName(comp.name, n.id);
1351
888
  const overElemGo = mapOverElemType(comp, n, typedNodes, plan);
1352
889
  const lines = [];
@@ -1378,38 +915,7 @@ function mapOverElemInfo(comp, node, typedNodes, plan) {
1378
915
  function mapOverElemType(comp, node, typedNodes, plan) {
1379
916
  return renderTypeRef(mapOverElemInfo(comp, node, typedNodes, plan).elemRef);
1380
917
  }
1381
- function classifyPort(node) {
1382
- if (staticArrElems(node) !== null)
1383
- return "static";
1384
- const e = classifyExpr(node);
1385
- switch (e.kind) {
1386
- case "str":
1387
- case "bool":
1388
- case "null":
1389
- case "ref":
1390
- return "static";
1391
- case "concat":
1392
- return e.parts.every((p) => classifyPort(reconstructG(p)) === "static") ? "static" : "dynamic";
1393
- default:
1394
- return "dynamic";
1395
- }
1396
- }
1397
- function reconstructG(e) {
1398
- switch (e.kind) {
1399
- case "str":
1400
- return e.value;
1401
- case "bool":
1402
- return e.value;
1403
- case "null":
1404
- return null;
1405
- case "ref":
1406
- return { [e.opt ? "refOpt" : "ref"]: e.path };
1407
- case "concat":
1408
- return { concat: e.parts.map(reconstructG) };
1409
- case "dynamic":
1410
- return e.node;
1411
- }
1412
- }
918
+ // ── the combined runner (INLINE sequential, native ports in, raw struct out) ────────────
1413
919
  // bc#90 / runtime-free: the old nvVE-based `emitStaticVE` / `valueLeaf` port lowering (which built
1414
920
  // `dslcontracts.Value` leaves via the nv* helpers) is REMOVED — every covered port now lowers to a
1415
921
  // FULLY NATIVE Go value in emitPortInit (string / bool / static-string-array / number literal), and a
@@ -2028,7 +1534,7 @@ function emitMapArm(comp, node, atPos, typedNodes, plan, priorNodeAt, zeroOut, f
2028
1534
  // it against the element ref (the `into` field's type for map...into, else the element type). A de-box
2029
1535
  // mismatch fails closed regardless of elementPolicy (matching the interpreter's whole-node outType
2030
1536
  // throw); elementPolicy still governs the handler's own leaf failures only.
2031
- const elemRowRef = mapElemRowRef(node, arrRef, plan);
1537
+ const elemRowRef = mapElemRowRef("go", node, arrRef, plan);
2032
1538
  const elemRowGo = renderTypeRef(elemRowRef);
2033
1539
  const renderElemDeBox = (target, src, il) => renderResultDeBox(elemRowRef, target, src, node.id, plan, il, returnZeroFail(zeroOut), wireSel, nodeWirePassthrough(node));
2034
1540
  // #177/#182 keep-with-skip-value: the into value for a guard-skipped element is driven by relationKind,
@@ -2260,7 +1766,7 @@ function emitFanoutArm(comp, node, atPos, typedNodes, plan, priorNodeAt, zeroOut
2260
1766
  const wvQ = goWireQ(wireSel);
2261
1767
  const leafSym = resolveLeafSymbol(f.component, leaf, f.leafSymbol);
2262
1768
  const connRef = typedNodes.get(node.id);
2263
- const elemRef = fanoutItemsElemRef(node, connRef, plan);
1769
+ const elemRef = fanoutItemsElemRef("go", node, connRef, plan);
2264
1770
  const elemGo = renderTypeRef(elemRef);
2265
1771
  const { elemRef: overElemRef, overExpr, optArr: overOptArr } = fanoutOverElemInfo(comp, node, typedNodes, plan);
2266
1772
  const overElemGo = renderTypeRef(overElemRef);
@@ -2929,11 +2435,10 @@ var ExpectedSpecVersions = map[string]int64{"behavior": ${sv.behavior}, "express
2929
2435
  }
2930
2436
  // ── module assembly ──────────────────────────────────────────────────────────────────
2931
2437
  function emit(ctx) {
2932
- // Fail closed if a covered read SHAPE lacks the typed annotations (no silent re-box).
2933
- for (const c of ctx.ir.components)
2934
- assertTypedCoverage(c);
2935
- const native = ctx.ir.components.filter(isNativeRaw);
2936
- const nonNative = ctx.ir.components.filter((c) => !isNativeRaw(c));
2438
+ // FAIL CLOSED (bc#86/#89): the native codegen surface is native-only — every component must be a covered,
2439
+ // fully typed native read (the ONE coverage rule, native-coverage.ts), or generation fails LOUDLY naming
2440
+ // each uncovered component and its specific reason (never a silently boxed component).
2441
+ const native = goCoverage.assertCovered(ctx.ir.components);
2937
2442
  const plan = buildTypePlan(ctx.ir);
2938
2443
  const wire = resolveGoWire(ctx);
2939
2444
  // bc#156: renderTypeRef({kind:"value"}) must resolve to the SAME wire type name the transport returns
@@ -2988,22 +2493,7 @@ function emit(ctx) {
2988
2493
  // bc#90: the ONLY std-lib `fmt.Sprintf` site on the covered plane is the batched-map result-count
2989
2494
  // mismatch error — so `fmt` is imported iff a covered component has a batched map node.
2990
2495
  const needFmt = native.some((c) => c.body.some((n) => ("map" in n && n.map.batched === true) || "fanout" in n));
2991
- // The FULLY-covered module (no non-native components) gets a MINIMAL, RUNTIME-FREE header — NO
2992
- // bc-runtime import at all (bc#90).
2993
- // FAIL CLOSED (bc#86/#89): the --typed-native (native codegen) surface is native-only. If ANY
2994
- // component is not a covered native read, we do NOT silently box it through the straight-line
2995
- // emitter (the old concealment) — we throw a LOUD GeneratorFailure naming every uncovered component
2996
- // and its specific reject reason. A fully-covered module (nonNative.length === 0) is unchanged: the
2997
- // minimal, runtime-free header.
2998
- if (nonNative.length > 0) {
2999
- const rejects = nonNative
3000
- .map((c) => ` - component '${c.name}': ${coverageRejectReason(c) ?? "not a covered native read"}`)
3001
- .join("\n");
3002
- throw new GeneratorFailure("UNSUPPORTED_NODE_STRAIGHTLINE", `go typed-native (native codegen) surface: ${nonNative.length} component(s) are NOT a covered native read:\n${rejects}\n\n` +
3003
- `The --typed-native (native codegen) surface is native-only and fail-closed: it does not silently ` +
3004
- `box uncovered shapes. Implement native coverage for this shape, fix the spec if the shape is ` +
3005
- `genuinely runtime-dynamic, or generate this component on the --ir dynamic interpreter surface.`);
3006
- }
2496
+ // The FULLY-covered module gets a MINIMAL, RUNTIME-FREE header — NO bc-runtime import at all (bc#90).
3007
2497
  // #108: `math` is imported iff the native-expr compiler emitted a fallible helper (bcExpr_modF uses
3008
2498
  // math.Mod). The helper library itself is baked into the module only when used (goExprUsed.helpers).
3009
2499
  const needMath = goExprUsed.helpers;