behavior-contracts 0.10.1 → 0.11.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.
- package/README.md +246 -350
- package/cli-contract.yaml +49 -51
- package/dist/authoring.d.ts +61 -424
- package/dist/authoring.d.ts.map +1 -1
- package/dist/authoring.js +53 -1157
- package/dist/authoring.js.map +1 -1
- package/dist/behavior.d.ts +7 -15
- package/dist/behavior.d.ts.map +1 -1
- package/dist/behavior.js.map +1 -1
- package/dist/builder.d.ts +4 -4
- package/dist/builder.d.ts.map +1 -1
- package/dist/builder.js +9 -11
- package/dist/builder.js.map +1 -1
- package/dist/cli.js +5 -5
- package/dist/cli.js.map +1 -1
- package/dist/commands/codegen.d.ts.map +1 -1
- package/dist/commands/codegen.js +12 -56
- package/dist/commands/codegen.js.map +1 -1
- package/dist/commands/ts-compile.d.ts +23 -0
- package/dist/commands/ts-compile.d.ts.map +1 -0
- package/dist/commands/ts-compile.js +724 -0
- package/dist/commands/ts-compile.js.map +1 -0
- package/dist/commands/ts-extract.d.ts +67 -1
- package/dist/commands/ts-extract.d.ts.map +1 -1
- package/dist/commands/ts-extract.js +162 -31
- package/dist/commands/ts-extract.js.map +1 -1
- package/dist/generated/contract.d.ts.map +1 -1
- package/dist/generated/contract.js +2 -2
- package/dist/generated/contract.js.map +1 -1
- package/dist/generated/program.js +4 -4
- package/dist/generated/program.js.map +1 -1
- package/dist/generator/core.d.ts +11 -1
- package/dist/generator/core.d.ts.map +1 -1
- package/dist/generator/core.js +5 -4
- package/dist/generator/core.js.map +1 -1
- package/dist/generator/emit-php.d.ts +0 -17
- package/dist/generator/emit-php.d.ts.map +1 -1
- package/dist/generator/emit-php.js +25 -1
- package/dist/generator/emit-php.js.map +1 -1
- package/dist/generator/emit-python.d.ts +0 -7
- package/dist/generator/emit-python.d.ts.map +1 -1
- package/dist/generator/emit-python.js +34 -1
- package/dist/generator/emit-python.js.map +1 -1
- package/dist/generator/emit-straightline-typed-typescript.js +1 -1
- package/dist/generator/emit-straightline-typed-typescript.js.map +1 -1
- package/dist/generator/emit-typed-native-go.d.ts +1 -1
- package/dist/generator/emit-typed-native-go.d.ts.map +1 -1
- package/dist/generator/emit-typed-native-go.js +110 -107
- package/dist/generator/emit-typed-native-go.js.map +1 -1
- package/dist/generator/emit-typed-native-rust.d.ts +3 -2
- package/dist/generator/emit-typed-native-rust.d.ts.map +1 -1
- package/dist/generator/emit-typed-native-rust.js +55 -123
- package/dist/generator/emit-typed-native-rust.js.map +1 -1
- package/dist/generator/emit-typescript-native.js +1 -1
- package/dist/generator/emit-typescript-native.js.map +1 -1
- package/dist/generator/emit-typescript.js +1 -1
- package/dist/generator/emit-typescript.js.map +1 -1
- package/dist/generator/typed.d.ts +5 -1
- package/dist/generator/typed.d.ts.map +1 -1
- package/dist/generator/typed.js +40 -9
- package/dist/generator/typed.js.map +1 -1
- package/dist/guard.d.ts +4 -0
- package/dist/guard.d.ts.map +1 -1
- package/dist/guard.js +26 -8
- package/dist/guard.js.map +1 -1
- package/dist/index.d.ts +19 -57
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -101
- package/dist/index.js.map +1 -1
- package/dist/lowering.d.ts +251 -0
- package/dist/lowering.d.ts.map +1 -0
- package/dist/lowering.js +652 -0
- package/dist/lowering.js.map +1 -0
- package/dist/provenance.js +4 -4
- package/dist/provenance.js.map +1 -1
- package/dist/runtime.d.ts +52 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +77 -0
- package/dist/runtime.js.map +1 -0
- package/dist/spec-versions.d.ts +25 -0
- package/dist/spec-versions.d.ts.map +1 -0
- package/dist/spec-versions.js +26 -0
- package/dist/spec-versions.js.map +1 -0
- package/dist/type-gate.d.ts +12 -0
- package/dist/type-gate.d.ts.map +1 -1
- package/dist/type-gate.js +79 -3
- package/dist/type-gate.js.map +1 -1
- package/package.json +5 -1
- package/dist/bind.d.ts +0 -88
- package/dist/bind.d.ts.map +0 -1
- package/dist/bind.js +0 -155
- package/dist/bind.js.map +0 -1
- package/dist/lower.d.ts +0 -35
- package/dist/lower.d.ts.map +0 -1
- package/dist/lower.js +0 -118
- package/dist/lower.js.map +0 -1
|
@@ -68,7 +68,7 @@ export declare function goSharedWireTypesPackage(pkgName: string): string;
|
|
|
68
68
|
* whole-file zero (the ser_* NewObj is test glue, never on the consumer's read hot path). Emitted only for
|
|
69
69
|
* the fully-covered case (the equivalence harness); production consumers never use it.
|
|
70
70
|
*/
|
|
71
|
-
export declare function goTypedNativeObserve(ir: unknown, runtimeImport?: string, leaf?: LeafTransportOptions): string;
|
|
71
|
+
export declare function goTypedNativeObserve(ir: unknown, runtimeImport?: string, leaf?: LeafTransportOptions, namespace?: string): string;
|
|
72
72
|
/**
|
|
73
73
|
* goTypedNativeEmitter — language id `go-typed-native` (bc#77). Emits the generic straight-line
|
|
74
74
|
* body (for non-covered components / helpers) plus the COMBINED READ layer (native ports struct
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emit-typed-native-go.d.ts","sourceRoot":"","sources":["../../src/generator/emit-typed-native-go.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,OAAO,KAAK,EAAe,aAAa,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAiClF;;;;+GAI+G;AAC/G,wBAAgB,wBAAwB,CAAC,iBAAiB,EAAE,MAAM,GAAG,MAAM,CAE1E;
|
|
1
|
+
{"version":3,"file":"emit-typed-native-go.d.ts","sourceRoot":"","sources":["../../src/generator/emit-typed-native-go.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,OAAO,KAAK,EAAe,aAAa,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAiClF;;;;+GAI+G;AAC/G,wBAAgB,wBAAwB,CAAC,iBAAiB,EAAE,MAAM,GAAG,MAAM,CAE1E;AAk9FD;;;;;;6GAM6G;AAC7G,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAchE;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,OAAO,EAAE,aAAa,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,oBAAoB,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CA2TjI;AAED;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,EAAE,aAOlC,CAAC"}
|
|
@@ -1079,13 +1079,36 @@ function goPayloadBatch(itemsExpr, wireSel) {
|
|
|
1079
1079
|
const q = goWireQ(wireSel);
|
|
1080
1080
|
return `${q}WireRowOfFields([]${q}WireField{{Key: "items", Val: ${q}WireListOf(${itemsExpr})}})`;
|
|
1081
1081
|
}
|
|
1082
|
-
/**
|
|
1083
|
-
* (
|
|
1084
|
-
*
|
|
1085
|
-
*
|
|
1086
|
-
* sanitized component suffix keeps it unique per covered component. */
|
|
1082
|
+
/** #192: the generated entry is a 1:1 map of the authored method — its name is the EXPORTED Go form of
|
|
1083
|
+
* the component (method) name (`findByEmail` → `FindByEmail`), callable cross-package. No `In_<comp>`
|
|
1084
|
+
* box, no `RunNativeRawStruct_` prefix. `goFieldName` capitalizes the leading char (export) and safes
|
|
1085
|
+
* non-identifier chars; unique per covered component (one entry per method). */
|
|
1087
1086
|
function runnerName(compName) {
|
|
1088
|
-
return
|
|
1087
|
+
return goFieldName(compName);
|
|
1088
|
+
}
|
|
1089
|
+
/** #192: the Go package name = the namespace (declaring class), lower-cased (`UserQueries` → `userqueries`);
|
|
1090
|
+
* default `behaviors` when unset. Physical placement / namespace is set in ONE place (GenerateOptions.namespace).
|
|
1091
|
+
* The covered module and its test-only observe companion MUST share this package (same-package transport calls). */
|
|
1092
|
+
function goPackageName(ns) {
|
|
1093
|
+
if (ns === undefined)
|
|
1094
|
+
return "behaviors";
|
|
1095
|
+
const safe = ns.replace(/[^A-Za-z0-9]/g, "").toLowerCase();
|
|
1096
|
+
return safe.length > 0 && /[a-z_]/.test(safe[0]) ? safe : "behaviors";
|
|
1097
|
+
}
|
|
1098
|
+
/** Go keywords that a positional-parameter name must not collide with (prefixed with `p_` if it does). */
|
|
1099
|
+
const GO_KEYWORDS = /* @__PURE__ */ new Set([
|
|
1100
|
+
"break", "case", "chan", "const", "continue", "default", "defer", "else", "fallthrough", "for", "func",
|
|
1101
|
+
"go", "goto", "if", "import", "interface", "map", "package", "range", "return", "select", "struct",
|
|
1102
|
+
"switch", "type", "var", "nil", "true", "false", "iota", "in",
|
|
1103
|
+
]);
|
|
1104
|
+
/** #192: an input port's positional PARAMETER name — a valid, unexported (lower-first) Go identifier
|
|
1105
|
+
* from the port name. The single naming for a port's param at both the entry signature and every input
|
|
1106
|
+
* ref (goInputHeadRef seam). Digit/underscore-leading or keyword names are `p_`-prefixed. */
|
|
1107
|
+
function goParamName(port) {
|
|
1108
|
+
const safe = port.replace(/[^A-Za-z0-9_]/g, "_");
|
|
1109
|
+
const head = safe.charAt(0);
|
|
1110
|
+
const name = /[A-Za-z]/.test(head) ? head.toLowerCase() + safe.slice(1) : "p_" + safe;
|
|
1111
|
+
return GO_KEYWORDS.has(name) ? "p_" + name : name;
|
|
1089
1112
|
}
|
|
1090
1113
|
/** mapElemMaterializerName — the augmented-element copier for a covered map...into node. */
|
|
1091
1114
|
function mapElemMaterializerName(compName, nodeId) {
|
|
@@ -1131,8 +1154,10 @@ function goOverElemInfo(comp, over, typedNodes, plan, nodeId, label) {
|
|
|
1131
1154
|
if (e.kind === "ref" && e.path.length === 1) {
|
|
1132
1155
|
const schema = comp.inputPorts?.[e.path[0]];
|
|
1133
1156
|
const et = schema?.elemType;
|
|
1134
|
-
|
|
1135
|
-
|
|
1157
|
+
// #192: read the input port via the goInputHeadRef seam (single input-ref path) — not a parallel `in.<Field>`.
|
|
1158
|
+
const head = goInputHeadRef(e.path[0], comp, plan);
|
|
1159
|
+
if (et !== undefined && head !== null)
|
|
1160
|
+
return { elemRef: deriveTypeRef(et, plan), overExpr: head.expr, optArr: inputPortIsOptional(schema) };
|
|
1136
1161
|
}
|
|
1137
1162
|
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).`);
|
|
1138
1163
|
}
|
|
@@ -1272,23 +1297,18 @@ function reconstructG(e) {
|
|
|
1272
1297
|
// `dslcontracts.Value` leaves via the nv* helpers) is REMOVED — every covered port now lowers to a
|
|
1273
1298
|
// FULLY NATIVE Go value in emitPortInit (string / bool / static-string-array / number literal), and a
|
|
1274
1299
|
// genuinely-dynamic port fails closed. There is no boxed-Value fallback on the covered read plane.
|
|
1275
|
-
// ──
|
|
1300
|
+
// ── positional input params + NATIVE scalar port lowering (#192) ─────────────────────────────
|
|
1276
1301
|
//
|
|
1277
|
-
//
|
|
1278
|
-
//
|
|
1279
|
-
//
|
|
1280
|
-
//
|
|
1281
|
-
//
|
|
1282
|
-
//
|
|
1283
|
-
//
|
|
1284
|
-
// the
|
|
1285
|
-
//
|
|
1286
|
-
//
|
|
1287
|
-
// string key/table/projection ports never hit it).
|
|
1288
|
-
/** In_<comp> — the concrete per-component input struct name (fields = inputPorts). */
|
|
1289
|
-
function inStructName(compName) {
|
|
1290
|
-
return `In_${sanitize(compName)}`;
|
|
1291
|
-
}
|
|
1302
|
+
// The entry takes POSITIONAL params (one per input port, box removed — `goParamName(port)`), not a
|
|
1303
|
+
// generic *Obj nor an `In_<comp>` struct. A simple string/scalar port — a literal, a ref to a typed
|
|
1304
|
+
// input param (`userId`), a ref to a prior node's typed struct scalar field, or a concat of
|
|
1305
|
+
// statically-string parts — lowers DIRECTLY to a native Go expression (`"USER#" + userId`): NO
|
|
1306
|
+
// dslcontracts.Value, NO nvVE/nvBindVE helper, NO `.(string)` type-assert. The value is statically the
|
|
1307
|
+
// concrete type (the input schema / prior-node outType guarantee it, and literals are self-evidently
|
|
1308
|
+
// typed), so dropping the runtime TYPE_MISMATCH check is semantics-preserving. A port that CANNOT be
|
|
1309
|
+
// statically proven the concrete type (a ref to a non-matching-typed input, a refOpt / opt field, or a
|
|
1310
|
+
// dynamic operator) falls back to the nvVE Value path (documented — the only place a `.(T)` could
|
|
1311
|
+
// survive; the covered string key/table/projection ports never hit it).
|
|
1292
1312
|
/** Go type for an input port's declared type (scalar → concrete; array+elemType → []ElemT; else Value). */
|
|
1293
1313
|
function inputPortGoType(schema, plan, where = "input port") {
|
|
1294
1314
|
const ref = inputPortTypeRef(schema, plan);
|
|
@@ -1315,54 +1335,31 @@ function inputScalarKind(schema) {
|
|
|
1315
1335
|
return undefined;
|
|
1316
1336
|
}
|
|
1317
1337
|
}
|
|
1318
|
-
/** emitInStruct — the concrete input struct declaration for a covered component (fields = inputPorts,
|
|
1319
|
-
* declaration order = Object key order; gofmt-aligned). Empty inputPorts => empty struct. */
|
|
1320
|
-
function emitInStruct(comp, plan) {
|
|
1321
|
-
const name = inStructName(comp.name);
|
|
1322
|
-
const ports = Object.keys(comp.inputPorts ?? {});
|
|
1323
|
-
if (ports.length === 0) {
|
|
1324
|
-
return `// ${name} — the CONCRETE input for '${comp.name}' (no input ports).\ntype ${name} struct{}`;
|
|
1325
|
-
}
|
|
1326
|
-
const names = ports.map((p) => goFieldName(p));
|
|
1327
|
-
// #139: inputPortGoType reads the inputPortTypeRef SSoT — an OPTIONAL port is `*T` (absent → nil); an
|
|
1328
|
-
// optional whose inner type has no native lowering FAILS CLOSED (never a boxed Value escape).
|
|
1329
|
-
const types = ports.map((p) => inputPortGoType(comp.inputPorts[p], plan, `input port '${p}' of component '${comp.name}'`));
|
|
1330
|
-
const nameW = Math.max(0, ...names.map((n) => n.length));
|
|
1331
|
-
const typeW = Math.max(0, ...types.map((t) => t.length));
|
|
1332
|
-
const fields = ports
|
|
1333
|
-
.map((p, i) => `\t${names[i].padEnd(nameW)} ${types[i].padEnd(typeW)} // ${JSON.stringify(p)}`)
|
|
1334
|
-
.join("\n");
|
|
1335
|
-
return `// ${name} — the CONCRETE input for '${comp.name}' (fields = inputPorts; typed, consumer-built —
|
|
1336
|
-
// NO generic *Obj, NO per-field boxing crosses the covered read boundary).
|
|
1337
|
-
type ${name} struct {
|
|
1338
|
-
${fields}
|
|
1339
|
-
}`;
|
|
1340
|
-
}
|
|
1341
1338
|
/**
|
|
1342
|
-
* emitInDecoder — the TEST-glue decoder `
|
|
1343
|
-
* each declared input port from the generic *Obj into the
|
|
1344
|
-
* read
|
|
1345
|
-
*
|
|
1346
|
-
*
|
|
1347
|
-
* always supplied by the corpus); a present-but-wrong-scalar is a fail-closed decode error.
|
|
1339
|
+
* emitInDecoder — the TEST-glue decoder `decode_<comp>(input *Obj) (<positional args...>, err error)`. It reads
|
|
1340
|
+
* each declared input port from the generic *Obj into the entry's POSITIONAL arg (named return; scalar →
|
|
1341
|
+
* typed read on the SDK/wire Value; value-typed → the raw wire). Lives ONLY in the observe companion (test
|
|
1342
|
+
* harness), never in the covered module — the entry takes positional params (#192, box removed) and the
|
|
1343
|
+
* observe passes these decoded args positionally. A missing key leaves the zero value (every covered input
|
|
1344
|
+
* is required + always supplied by the corpus); a present-but-wrong-scalar is a fail-closed decode error.
|
|
1348
1345
|
*/
|
|
1349
1346
|
function emitInDecoder(comp, plan) {
|
|
1350
|
-
const name = inStructName(comp.name);
|
|
1351
1347
|
const ports = Object.keys(comp.inputPorts ?? {});
|
|
1348
|
+
if (ports.length === 0 || comp.inputPorts === undefined)
|
|
1349
|
+
return ""; // no input → observe calls the entry with no args.
|
|
1350
|
+
// #192: decode the generic *Obj test input into the entry's POSITIONAL args (named returns = the params,
|
|
1351
|
+
// in inputPorts order; a decode mismatch sets `err` and returns). The `In_<comp>` box is gone — this
|
|
1352
|
+
// test-glue decoder produces the values the observe companion passes positionally to the entry.
|
|
1353
|
+
const rets = ports
|
|
1354
|
+
.map((p) => `${goParamName(p)} ${inputPortGoType(comp.inputPorts[p], plan, `input port '${p}' of component '${comp.name}'`)}`)
|
|
1355
|
+
.join(", ");
|
|
1352
1356
|
const lines = [];
|
|
1353
|
-
lines.push(`func decode_${name}(input *${PKG}.Obj) (${
|
|
1354
|
-
lines.push(`\tvar in ${name}`);
|
|
1355
|
-
if (ports.length === 0 || comp.inputPorts === undefined) {
|
|
1356
|
-
lines.push(`\t_ = input`);
|
|
1357
|
-
lines.push(`\treturn in, nil`);
|
|
1358
|
-
lines.push(`}`);
|
|
1359
|
-
return lines.join("\n");
|
|
1360
|
-
}
|
|
1357
|
+
lines.push(`func decode_${sanitize(comp.name)}(input *${PKG}.Obj) (${rets}, err error) {`);
|
|
1361
1358
|
lines.push(`\tif input == nil {`);
|
|
1362
|
-
lines.push(`\t\treturn
|
|
1359
|
+
lines.push(`\t\treturn`);
|
|
1363
1360
|
lines.push(`\t}`);
|
|
1364
1361
|
for (const p of ports) {
|
|
1365
|
-
const
|
|
1362
|
+
const arg = goParamName(p);
|
|
1366
1363
|
const schema = comp.inputPorts[p];
|
|
1367
1364
|
const scalar = inputScalarKind(schema);
|
|
1368
1365
|
const et = schema.elemType;
|
|
@@ -1371,50 +1368,46 @@ function emitInDecoder(comp, plan) {
|
|
|
1371
1368
|
// #108: decode the boxed Value array into the native []ElemT (test glue — materialize each element
|
|
1372
1369
|
// via the typed materializer; a non-array or non-conforming element is a fail-closed decode error).
|
|
1373
1370
|
// bc#156: a `value[]` element is BC's opaque wire — decode it with the BC-owned valueToWire (the SAME
|
|
1374
|
-
// wire the output de-box uses), NOT the typed materializer (WireValue is not a de-box target).
|
|
1375
|
-
// the generic bound-value list built from a heterogeneous / empty input array.
|
|
1371
|
+
// wire the output de-box uses), NOT the typed materializer (WireValue is not a de-box target).
|
|
1376
1372
|
const elemRef = deriveTypeRef(et, plan);
|
|
1377
1373
|
const elemGo = renderTypeRef(elemRef);
|
|
1378
1374
|
const mat = elemRef.kind === "value" ? "valueToWire(ev)" : goTypedInternals.materializeExpr("ev", elemRef, plan);
|
|
1379
1375
|
lines.push(`\t\tarr, isArr := v.([]${PKG}.Value)`);
|
|
1380
1376
|
lines.push(`\t\tif !isArr {`);
|
|
1381
|
-
lines.push(`\t\t\
|
|
1377
|
+
lines.push(`\t\t\terr = ${PKG}.NewExprFailure("TYPE_MISMATCH", "input ${p}: expected array, got "+${PKG}.TypeName(v))`);
|
|
1378
|
+
lines.push(`\t\t\treturn`);
|
|
1382
1379
|
lines.push(`\t\t}`);
|
|
1383
1380
|
lines.push(`\t\tdec := make([]${elemGo}, 0, len(arr))`);
|
|
1384
1381
|
lines.push(`\t\tfor _, ev := range arr {`);
|
|
1385
|
-
// materializeExpr returns the must*-based decode (panics on a malformed corpus element — test glue).
|
|
1386
1382
|
lines.push(`\t\t\tdec = append(dec, ${mat})`);
|
|
1387
1383
|
lines.push(`\t\t}`);
|
|
1388
|
-
// #177 (A): an OPTIONAL array port
|
|
1389
|
-
lines.push(`\t\
|
|
1384
|
+
// #177 (A): an OPTIONAL array port param is `*[]E` (inputPortTypeRef opt → pointer), so take its address.
|
|
1385
|
+
lines.push(`\t\t${arg} = ${inputPortIsOptional(schema) ? "&dec" : "dec"}`);
|
|
1390
1386
|
lines.push(`\t}`);
|
|
1391
1387
|
continue;
|
|
1392
1388
|
}
|
|
1393
1389
|
if (schema?.type === "value") {
|
|
1394
|
-
|
|
1395
|
-
lines.push(`\t\tin.${field} = valueToWire(v)`);
|
|
1390
|
+
lines.push(`\t\t${arg} = valueToWire(v)`);
|
|
1396
1391
|
lines.push(`\t}`);
|
|
1397
1392
|
continue;
|
|
1398
1393
|
}
|
|
1399
1394
|
if (schema?.type === "map" && et !== undefined) {
|
|
1400
|
-
// #108-map: decode the boxed *Obj into the native map[string]V (test glue — the input map port
|
|
1401
|
-
// carries a declared elemType). materializeExpr covers the map de-box (Obj → map[string]V).
|
|
1402
1395
|
const mapRef = { kind: "map", value: deriveTypeRef(et, plan) };
|
|
1403
|
-
lines.push(`\t\
|
|
1396
|
+
lines.push(`\t\t${arg} = ${goTypedInternals.materializeExpr("v", mapRef, plan)}`);
|
|
1404
1397
|
lines.push(`\t}`);
|
|
1405
1398
|
continue;
|
|
1406
1399
|
}
|
|
1407
1400
|
if (scalar === undefined) {
|
|
1408
|
-
lines.push(`\t\
|
|
1401
|
+
lines.push(`\t\t${arg} = v`);
|
|
1409
1402
|
}
|
|
1410
1403
|
else {
|
|
1411
1404
|
// #139: materialize via the inputPortTypeRef SSoT so an OPTIONAL scalar reads as *T (present → &v);
|
|
1412
|
-
// an absent optional never enters this block (Get !ok), leaving the
|
|
1413
|
-
lines.push(`\t\
|
|
1405
|
+
// an absent optional never enters this block (Get !ok), leaving the param nil (not a required zero).
|
|
1406
|
+
lines.push(`\t\t${arg} = ${goTypedInternals.materializeExpr("v", inputPortTypeRef(schema, plan), plan)}`);
|
|
1414
1407
|
}
|
|
1415
1408
|
lines.push(`\t}`);
|
|
1416
1409
|
}
|
|
1417
|
-
lines.push(`\treturn
|
|
1410
|
+
lines.push(`\treturn`);
|
|
1418
1411
|
lines.push(`}`);
|
|
1419
1412
|
return lines.join("\n");
|
|
1420
1413
|
}
|
|
@@ -1668,8 +1661,12 @@ function emitNativeRawRunner(comp, plan, flags, wire, leaf) {
|
|
|
1668
1661
|
// interface, no generics (both are dynamic dispatch). Each transport returns the node's result WIRE (a
|
|
1669
1662
|
// single ${wire.value}); the runner de-boxes it INLINE (fully-unrolled probe/match — no decode helper, no
|
|
1670
1663
|
// output recursion) into the node's outType struct.
|
|
1671
|
-
|
|
1672
|
-
|
|
1664
|
+
// #192: 1:1 map of the authored signature — positional params (one per input port, box removed), not
|
|
1665
|
+
// an `In_<comp>` struct. Go allows unused function params, so no `_ = param` guard is needed.
|
|
1666
|
+
const entryParams = Object.keys(comp.inputPorts ?? {})
|
|
1667
|
+
.map((p) => `${goParamName(p)} ${inputPortGoType(comp.inputPorts[p], plan, `input port '${p}' of component '${comp.name}'`)}`)
|
|
1668
|
+
.join(", ");
|
|
1669
|
+
lines.push(`func ${runnerName(comp.name)}(${entryParams}) (${outStructType}, error) {`);
|
|
1673
1670
|
for (const k of order.keys()) {
|
|
1674
1671
|
const node = comp.body[order[k]];
|
|
1675
1672
|
const id = node.id;
|
|
@@ -2173,7 +2170,8 @@ function goInputHeadRef(head, comp, plan) {
|
|
|
2173
2170
|
const ref = inputPortTypeRef(comp.inputPorts?.[head], plan);
|
|
2174
2171
|
if (ref === undefined)
|
|
2175
2172
|
return null;
|
|
2176
|
-
|
|
2173
|
+
// #192: the input port is a positional PARAMETER of the entry (box removed) — read it by param name.
|
|
2174
|
+
return { expr: goParamName(head), ref };
|
|
2177
2175
|
}
|
|
2178
2176
|
/**
|
|
2179
2177
|
* emitCondArm — the struct-native exec of a covered cond node (#108). Mirrors run_behavior's cond
|
|
@@ -2690,18 +2688,18 @@ func bcExpr_strGt(a, b string) bool { return bcExpr_cmpCP(a, b) > 0 }
|
|
|
2690
2688
|
func bcExpr_strGe(a, b string) bool { return bcExpr_cmpCP(a, b) >= 0 }`;
|
|
2691
2689
|
}
|
|
2692
2690
|
// ── BindNativeRaw dispatch surface ──────────────────────────────────────────────────────
|
|
2693
|
-
/** The
|
|
2694
|
-
* (
|
|
2695
|
-
* (it returns the typed model — NO Value serialization on the read hot path, matching how graphddb
|
|
2696
|
-
*
|
|
2697
|
-
*
|
|
2698
|
-
*
|
|
2699
|
-
*
|
|
2691
|
+
/** The dispatch surface: ComponentNamesNativeRaw + the per-component entries (#192: the exported method
|
|
2692
|
+
* `<Method>(<positional params>) (T, error)`) ARE the exposed API. The consumer calls the entry directly
|
|
2693
|
+
* (it returns the typed model — NO Value serialization on the read hot path, matching how graphddb reads:
|
|
2694
|
+
* a model, never a boxed Value). There is deliberately NO Value dispatch map — that would require a Value
|
|
2695
|
+
* serializer (the boxing residue bc#77 eliminates). A canonical Value observation (equivalence pin) is
|
|
2696
|
+
* produced by the SEPARATE test-only observe companion (goTypedNativeObserve), which lives OUTSIDE this
|
|
2697
|
+
* module so the covered module stays literal whole-file zero. */
|
|
2700
2698
|
function emitStructSurface(native) {
|
|
2701
|
-
return `// ComponentNamesNativeRaw — covered reads exposed on the combined
|
|
2702
|
-
//
|
|
2703
|
-
//
|
|
2704
|
-
//
|
|
2699
|
+
return `// ComponentNamesNativeRaw — covered reads exposed on the combined native path (declaration order).
|
|
2700
|
+
// Each is a 1:1 entry <Method>(<positional params>) -> (T, error): a native return; the consumer keeps the
|
|
2701
|
+
// model native (no Value serialization on the read hot path — the boxing residue bc#77 removes) and
|
|
2702
|
+
// supplies the op-agnostic leaf transport symbols the entry calls. See INTEGRATION.md §6.
|
|
2705
2703
|
var ComponentNamesNativeRaw = []string{${native.map((c) => JSON.stringify(c.name)).join(", ")}}`;
|
|
2706
2704
|
}
|
|
2707
2705
|
/** Minimal module header for a FULLY-covered module (bc#90 / runtime-free). A fully-covered module
|
|
@@ -2742,7 +2740,7 @@ function emitMinimalHeader(ctx, needStrings, needSync, needFmt, needMath, needSt
|
|
|
2742
2740
|
// sequential runner below. There is NO generic Bind/dispatch/plan scaffolding AND NO bc-runtime import —
|
|
2743
2741
|
// a fully-covered module is FULLY NATIVE (zero bc-runtime reference; only the std-lib it uses).
|
|
2744
2742
|
|
|
2745
|
-
package
|
|
2743
|
+
package ${goPackageName(ctx.namespace)}
|
|
2746
2744
|
${importBlock}
|
|
2747
2745
|
// ExpectedSpecVersions are the spec versions baked at generation time (provenance only — the module
|
|
2748
2746
|
// is runtime-free, so there is no runtime SpecVersions to skew-check against, bc#90 / change #5).
|
|
@@ -2768,7 +2766,6 @@ function emit(ctx) {
|
|
|
2768
2766
|
const leaf = ctx.leafTransport;
|
|
2769
2767
|
// Emit the runners first so the nv* helper usage flags are known.
|
|
2770
2768
|
const flags = { bind: false, field: false, cat: false, arr: false };
|
|
2771
|
-
const inStructs = [];
|
|
2772
2769
|
const elemCopiers = [];
|
|
2773
2770
|
const runnerCodes = [];
|
|
2774
2771
|
// every covered node returns a WireValue the inline de-box classifies — the wire seam (probe kind
|
|
@@ -2778,7 +2775,7 @@ function emit(ctx) {
|
|
|
2778
2775
|
// inline at the call site), so there are NO per-node ports structs on either the covered plane or the
|
|
2779
2776
|
// shared package — the transport ABI is the generic WireRow, not a per-node/per-role concrete struct.
|
|
2780
2777
|
for (const c of native) {
|
|
2781
|
-
inStructs.
|
|
2778
|
+
// #192: no `In_<comp>` box — the entry takes positional params, so nothing is pushed to inStructs.
|
|
2782
2779
|
// build the full typed-node map FIRST so a map's over-element resolution can see every node.
|
|
2783
2780
|
const typedNodes = buildTypedNodes(c, plan);
|
|
2784
2781
|
// augmented-element copiers for covered map...into nodes (over fields + the de-boxed into value).
|
|
@@ -2839,15 +2836,16 @@ function emit(ctx) {
|
|
|
2839
2836
|
// carries NO bc-runtime reference at all — failures use the LOCAL *BehaviorError (same codes, byte-equal to
|
|
2840
2837
|
// run_behavior). Exec is INLINE sequential (no plan driver) so a relation child reads the parent's REAL
|
|
2841
2838
|
// struct result via direct field access and the child-present decision is made from the real parent value —
|
|
2842
|
-
// relationSingle / connection converge with run_behavior (fixes #323/#74). The exposed API is the
|
|
2843
|
-
// STRUCT-returning
|
|
2844
|
-
// same-package Leaf_<comp>, or a leafTransport import). This module is
|
|
2839
|
+
// relationSingle / connection converge with run_behavior (fixes #323/#74). The exposed API is the 1:1
|
|
2840
|
+
// STRUCT-returning entry <Method>(<positional params>) (the In_<comp> box removed); the consumer supplies
|
|
2841
|
+
// the leaf transport symbols (default same-package Leaf_<comp>, or a leafTransport import). This module is
|
|
2842
|
+
// FULLY NATIVE: a naive grep for
|
|
2845
2843
|
// boxing primitives OR for the bc-runtime package finds nothing, by design (bc#90/runtime-free).`;
|
|
2846
2844
|
const sections = [
|
|
2847
2845
|
banner,
|
|
2848
2846
|
`// Local concrete failure type (runtime-free) — a covered runner returns *BehaviorError (satisfies\n// error) instead of a bc-runtime failure, so the fully-covered module imports ZERO bc runtime.\n${behaviorErrorType}`,
|
|
2849
2847
|
decls ? `// Typed struct declarations (outType-derived; hash-dedup — shared type plan).\n${decls}` : undefined,
|
|
2850
|
-
|
|
2848
|
+
// #192: no per-component `In_<comp>` input structs — the entry takes positional params (box removed).
|
|
2851
2849
|
// the probe kind consts live in the covered module ALWAYS (the inline de-box compares against them); the
|
|
2852
2850
|
// shared wire package carries its own identical copy when the types are hoisted there (cross-package).
|
|
2853
2851
|
anyWire ? `// Probe kind consts (the inline de-box compares against these).\n${emitGoProbeKinds()}` : undefined,
|
|
@@ -2897,7 +2895,7 @@ ${emitGoWireTypes()}
|
|
|
2897
2895
|
* whole-file zero (the ser_* NewObj is test glue, never on the consumer's read hot path). Emitted only for
|
|
2898
2896
|
* the fully-covered case (the equivalence harness); production consumers never use it.
|
|
2899
2897
|
*/
|
|
2900
|
-
export function goTypedNativeObserve(ir, runtimeImport, leaf) {
|
|
2898
|
+
export function goTypedNativeObserve(ir, runtimeImport, leaf, namespace) {
|
|
2901
2899
|
const components = ir.components;
|
|
2902
2900
|
const native = components.filter(isNativeRaw);
|
|
2903
2901
|
const plan = buildTypePlan(ir);
|
|
@@ -2911,10 +2909,15 @@ export function goTypedNativeObserve(ir, runtimeImport, leaf) {
|
|
|
2911
2909
|
.map((c) => {
|
|
2912
2910
|
const outRef = c.outputType !== undefined ? deriveTypeRef(c.outputType, plan) : undefined;
|
|
2913
2911
|
const ser = outRef ? serializeTyped("tv", outRef, plan) : "tv";
|
|
2914
|
-
// decode the generic *Obj input into the
|
|
2915
|
-
//
|
|
2916
|
-
//
|
|
2917
|
-
|
|
2912
|
+
// #192: decode the generic *Obj test input into the entry's POSITIONAL args (test glue — ONE decode at
|
|
2913
|
+
// the top; a REQUIRED declared input absent is a fail-closed decode error here, never on the entry path),
|
|
2914
|
+
// then call the 1:1 entry positionally. A no-input entry is called with no args (no decoder).
|
|
2915
|
+
const args = Object.keys(c.inputPorts ?? {}).map((p) => goParamName(p));
|
|
2916
|
+
const decode = args.length === 0
|
|
2917
|
+
? ""
|
|
2918
|
+
: `\t\t${args.join(", ")}, ierr := decode_${sanitize(c.name)}(input)\n\t\tif ierr != nil {\n\t\t\treturn nil, ierr\n\t\t}\n`;
|
|
2919
|
+
const unusedInput = args.length === 0 ? "\t\t_ = input\n" : "";
|
|
2920
|
+
return `\tif name == ${JSON.stringify(c.name)} {\n${decode}${unusedInput}\t\ttv, err := ${runnerName(c.name)}(${args.join(", ")})\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn ${ser}, nil\n\t}`;
|
|
2918
2921
|
})
|
|
2919
2922
|
.join("\n");
|
|
2920
2923
|
// input decoders (TEST glue): generic *Obj -> concrete In_<comp>. Scalar fields read the typed value
|
|
@@ -3160,8 +3163,8 @@ func nextScripted(component string) (scriptSrc, bool) {
|
|
|
3160
3163
|
// module, so its transport calls resolve) that drain a shared package-level scripted queue + the CONCRETE
|
|
3161
3164
|
// WireValue/WireRow/WireList seam types. The consumer never uses this (it keeps the model native + supplies
|
|
3162
3165
|
// its own concrete WireValue + transport funcs); it exists only so the test harness can byte-compare the
|
|
3163
|
-
// STRUCT-only covered read against run_behavior. Same package as the module.
|
|
3164
|
-
package
|
|
3166
|
+
// STRUCT-only covered read against run_behavior. Same package as the module (#192: shared namespace).
|
|
3167
|
+
package ${goPackageName(namespace)}
|
|
3165
3168
|
|
|
3166
3169
|
import (
|
|
3167
3170
|
"sync"
|