behavior-contracts 0.8.14 → 0.8.15
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/dist/generator/emit-shared-debox.d.ts +36 -12
- package/dist/generator/emit-shared-debox.d.ts.map +1 -1
- package/dist/generator/emit-shared-debox.js +33 -18
- package/dist/generator/emit-shared-debox.js.map +1 -1
- package/dist/generator/emit-typed-native-go.d.ts.map +1 -1
- package/dist/generator/emit-typed-native-go.js +37 -1
- package/dist/generator/emit-typed-native-go.js.map +1 -1
- package/dist/generator/emit-typed-native-rust.d.ts.map +1 -1
- package/dist/generator/emit-typed-native-rust.js +35 -1
- package/dist/generator/emit-typed-native-rust.js.map +1 -1
- package/dist/generator/native-expr.d.ts +10 -2
- package/dist/generator/native-expr.d.ts.map +1 -1
- package/dist/generator/native-expr.js +21 -15
- package/dist/generator/native-expr.js.map +1 -1
- package/package.json +1 -1
|
@@ -66,39 +66,63 @@ interface DeBoxCommon {
|
|
|
66
66
|
* the `expectedType` literal baked into a mismatch error. */
|
|
67
67
|
expectedType: string;
|
|
68
68
|
}
|
|
69
|
-
/**
|
|
70
|
-
* one of these (the walk is total); a renderer folds the tree into inline native code
|
|
71
|
-
|
|
69
|
+
/** WirePlan — a node in the language-neutral wire-boundary plan tree. Every SCP-resolved type maps to
|
|
70
|
+
* exactly one of these (the walk is total); a renderer folds the tree into inline native code, either
|
|
71
|
+
* direction: OUT (wire→typed, de-box) or IN (typed→wire, box). The two directions share ONE walk
|
|
72
|
+
* ({@link buildWirePlan}) — the plan owns STRUCTURE + totality; each per-language renderer owns SYNTAX.
|
|
73
|
+
* - `value` is the opaque BC-owned wire itself (bc#156, INPUT-only): box = identity (already wire),
|
|
74
|
+
* de-box = fail-closed (a `value` at an output position is rejected at plan build). It carries no
|
|
75
|
+
* child plan — the datum crosses the boundary unchanged. */
|
|
76
|
+
export type WirePlan = ({
|
|
72
77
|
k: "scalar";
|
|
73
78
|
scalar: DeBoxScalar;
|
|
79
|
+
} & DeBoxCommon) | ({
|
|
80
|
+
k: "value";
|
|
74
81
|
} & DeBoxCommon) | ({
|
|
75
82
|
k: "record";
|
|
76
83
|
typeName: string;
|
|
77
84
|
fields: {
|
|
78
85
|
name: string;
|
|
79
|
-
plan:
|
|
86
|
+
plan: WirePlan;
|
|
80
87
|
}[];
|
|
81
88
|
} & DeBoxCommon) | ({
|
|
82
89
|
k: "list";
|
|
83
|
-
elem:
|
|
90
|
+
elem: WirePlan;
|
|
84
91
|
} & DeBoxCommon) | ({
|
|
85
92
|
k: "map";
|
|
86
|
-
value:
|
|
93
|
+
value: WirePlan;
|
|
87
94
|
} & DeBoxCommon);
|
|
95
|
+
/** DeBoxPlan — alias for {@link WirePlan}. A de-box (OUT) plan never contains a `value` node (fail-closed
|
|
96
|
+
* at plan build), so the de-box renderers carry an unreachable exhaustiveness guard for it. */
|
|
97
|
+
export type DeBoxPlan = WirePlan;
|
|
88
98
|
/**
|
|
89
99
|
* notationOfRef — the Portable Type Notation of a TypeRef (scp-error.md), resolving a named ref to its
|
|
90
100
|
* `obj{…}` notation via the plan. Baked as the `expectedType` literal: a rendering of the STATICALLY
|
|
91
101
|
* declared type, so nothing walks a type at runtime. Language-neutral (shared by every emitter).
|
|
92
102
|
*/
|
|
93
103
|
export declare function notationOfRef(ref: TypeRef, plan: TypePlan): string;
|
|
104
|
+
/** WireDir — the boundary crossing direction: `out` = wire→typed (de-box, a leaf RESULT), `in` =
|
|
105
|
+
* typed→wire (box, a transport INPUT). One walk, two renderers; the direction only decides whether a
|
|
106
|
+
* `value` node is admissible (IN = identity) or fail-closed (OUT = input-only declared type). */
|
|
107
|
+
export type WireDir = "in" | "out";
|
|
94
108
|
/**
|
|
95
|
-
*
|
|
96
|
-
* return the
|
|
97
|
-
* arbitrary shapes (opt(named), arr(arr(named)), map(opt(named)), …) are covered by
|
|
98
|
-
*
|
|
99
|
-
* at this position (a named type re-roots them to its own
|
|
100
|
-
* collection keeps the enclosing labels
|
|
109
|
+
* buildWirePlan — the ONE total walk (both directions). Given an SCP-resolved `ref` at a position reached
|
|
110
|
+
* via `access`, return the wire-boundary plan for a value of that type. Recurses over the FULL grammar at
|
|
111
|
+
* every nesting so arbitrary shapes (opt(named), arr(arr(named)), map(opt(named)), …) are covered by
|
|
112
|
+
* construction — no per-shape allow-list, no fail-close branch in generated code. `ctx.model` /
|
|
113
|
+
* `ctx.field` are the error labels inherited at this position (a named type re-roots them to its own
|
|
114
|
+
* name / field names; a collection keeps the enclosing labels — whole-field Error Value granularity).
|
|
115
|
+
* `dir` governs the one type that is direction-asymmetric: `value` (the opaque BC wire, INPUT-only) is a
|
|
116
|
+
* `value` plan node on the IN (box = identity) path and a fail-closed codegen error on the OUT (de-box)
|
|
117
|
+
* path — enforcing "value is input-only; a value in an output position is rejected".
|
|
101
118
|
*/
|
|
119
|
+
export declare function buildWirePlan(ref: TypeRef, access: DeBoxAccess, ctx: {
|
|
120
|
+
model: string;
|
|
121
|
+
field: string;
|
|
122
|
+
plan: TypePlan;
|
|
123
|
+
}, dir: WireDir): WirePlan;
|
|
124
|
+
/** buildDeBoxPlan — the OUT (wire→typed) entry: {@link buildWirePlan} in the de-box direction. The
|
|
125
|
+
* existing de-box call sites consume this; the walk is shared with the box (IN) direction. */
|
|
102
126
|
export declare function buildDeBoxPlan(ref: TypeRef, access: DeBoxAccess, ctx: {
|
|
103
127
|
model: string;
|
|
104
128
|
field: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emit-shared-debox.d.ts","sourceRoot":"","sources":["../../src/generator/emit-shared-debox.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAGH,OAAO,EAAY,KAAK,QAAQ,EAAE,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAEnE;2EAC2E;AAC3E,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,CAAC;AAE9D;;;;;;;;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,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,GAAG,SAAS,CAGlI"}
|
|
@@ -64,14 +64,17 @@ function deBoxUnsupported(message) {
|
|
|
64
64
|
throw new GeneratorFailure("UNSUPPORTED_NODE_STRAIGHTLINE", message);
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
67
|
-
*
|
|
68
|
-
* return the
|
|
69
|
-
* arbitrary shapes (opt(named), arr(arr(named)), map(opt(named)), …) are covered by
|
|
70
|
-
*
|
|
71
|
-
* at this position (a named type re-roots them to its own
|
|
72
|
-
* collection keeps the enclosing labels
|
|
67
|
+
* buildWirePlan — the ONE total walk (both directions). Given an SCP-resolved `ref` at a position reached
|
|
68
|
+
* via `access`, return the wire-boundary plan for a value of that type. Recurses over the FULL grammar at
|
|
69
|
+
* every nesting so arbitrary shapes (opt(named), arr(arr(named)), map(opt(named)), …) are covered by
|
|
70
|
+
* construction — no per-shape allow-list, no fail-close branch in generated code. `ctx.model` /
|
|
71
|
+
* `ctx.field` are the error labels inherited at this position (a named type re-roots them to its own
|
|
72
|
+
* name / field names; a collection keeps the enclosing labels — whole-field Error Value granularity).
|
|
73
|
+
* `dir` governs the one type that is direction-asymmetric: `value` (the opaque BC wire, INPUT-only) is a
|
|
74
|
+
* `value` plan node on the IN (box = identity) path and a fail-closed codegen error on the OUT (de-box)
|
|
75
|
+
* path — enforcing "value is input-only; a value in an output position is rejected".
|
|
73
76
|
*/
|
|
74
|
-
export function
|
|
77
|
+
export function buildWirePlan(ref, access, ctx, dir) {
|
|
75
78
|
const { plan } = ctx;
|
|
76
79
|
const expectedType = notationOfRef(ref, plan);
|
|
77
80
|
// Strip optional layers, counting depth; the presence logic is single-bit at the wire (a nested
|
|
@@ -86,34 +89,46 @@ export function buildDeBoxPlan(ref, access, ctx) {
|
|
|
86
89
|
switch (base.kind) {
|
|
87
90
|
case "scalar": {
|
|
88
91
|
if (base.scalar === "null")
|
|
89
|
-
// a bare `null` type is not a
|
|
90
|
-
//
|
|
91
|
-
//
|
|
92
|
-
deBoxUnsupported(`
|
|
92
|
+
// a bare `null` type is not a wire datum (no producer value is "the null type"); it only ever
|
|
93
|
+
// appears as an optional marker, which the optDepth path above already absorbed. Reaching here
|
|
94
|
+
// means a required bare-null field — degenerate; surface it rather than emit dead code.
|
|
95
|
+
deBoxUnsupported(`wire ${dir}: '${ctx.field}' of '${ctx.model}' is a bare 'null' type, which no producer datum satisfies`);
|
|
93
96
|
return { k: "scalar", scalar: base.scalar, ...common };
|
|
94
97
|
}
|
|
98
|
+
case "value":
|
|
99
|
+
// bc#156: the opaque BC-owned wire. IN (box) = identity (the datum is already a WireValue). OUT
|
|
100
|
+
// (de-box) = fail-closed: `value` is an INPUT-only declared type; a `value` in an output position
|
|
101
|
+
// is a codegen error (never a silent boxed escape into the typed covered plane).
|
|
102
|
+
if (dir === "out")
|
|
103
|
+
deBoxUnsupported(`wire out: '${ctx.field}' of '${ctx.model}' is a 'value' (opaque wire), which is INPUT-only and has no output de-box`);
|
|
104
|
+
return { k: "value", ...common };
|
|
95
105
|
case "named": {
|
|
96
106
|
const decl = findDecl(plan, base.name);
|
|
97
107
|
if (decl === undefined)
|
|
98
|
-
deBoxUnsupported(`
|
|
108
|
+
deBoxUnsupported(`wire ${dir}: named type '${base.name}' is not in the type plan`);
|
|
99
109
|
const fields = decl.fields.map((f) => ({
|
|
100
110
|
name: f.name,
|
|
101
|
-
plan:
|
|
111
|
+
plan: buildWirePlan(f.type, { from: "field", key: f.name }, { model: base.name, field: f.name, plan }, dir),
|
|
102
112
|
}));
|
|
103
113
|
return { k: "record", typeName: base.name, fields, ...common };
|
|
104
114
|
}
|
|
105
115
|
case "arr": {
|
|
106
|
-
const elem =
|
|
116
|
+
const elem = buildWirePlan(base.elem, { from: "elem" }, { model: ctx.model, field: ctx.field, plan }, dir);
|
|
107
117
|
return { k: "list", elem, ...common };
|
|
108
118
|
}
|
|
109
119
|
case "map": {
|
|
110
|
-
const value =
|
|
120
|
+
const value = buildWirePlan(base.value, { from: "mapval" }, { model: ctx.model, field: ctx.field, plan }, dir);
|
|
111
121
|
return { k: "map", value, ...common };
|
|
112
122
|
}
|
|
113
123
|
default:
|
|
114
|
-
// unreachable: the while-loop above strips every `opt`, so `base.kind` is scalar/named/arr/map.
|
|
115
|
-
|
|
116
|
-
deBoxUnsupported(`de-box: unexpected residual kind '${base.kind}'`);
|
|
124
|
+
// unreachable: the while-loop above strips every `opt`, so `base.kind` is scalar/value/named/arr/map.
|
|
125
|
+
deBoxUnsupported(`wire ${dir}: unexpected residual kind '${base.kind}'`);
|
|
117
126
|
}
|
|
118
127
|
}
|
|
128
|
+
/** buildDeBoxPlan — the OUT (wire→typed) entry: {@link buildWirePlan} in the de-box direction. The
|
|
129
|
+
* existing de-box call sites consume this; the walk is shared with the box (IN) direction. */
|
|
130
|
+
export function buildDeBoxPlan(ref, access, ctx) {
|
|
131
|
+
// "out" fail-closes a `value` node at plan build, so the result provably excludes `{k:"value"}`.
|
|
132
|
+
return buildWirePlan(ref, access, ctx, "out");
|
|
133
|
+
}
|
|
119
134
|
//# sourceMappingURL=emit-shared-debox.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emit-shared-debox.js","sourceRoot":"","sources":["../../src/generator/emit-shared-debox.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAA+B,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"emit-shared-debox.js","sourceRoot":"","sources":["../../src/generator/emit-shared-debox.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAA+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AE,GAAG,MAAM,EAAE,CAAC;QACxC,CAAC;QACD;YACE,sGAAsG;YACtG,gBAAgB,CAAC,QAAQ,GAAG,+BAAgC,IAAgB,CAAC,IAAI,GAAG,CAAC,CAAC;IAC1F,CAAC;AACH,CAAC;AAED;8FAC8F;AAC9F,MAAM,UAAU,cAAc,CAAC,GAAY,EAAE,MAAmB,EAAE,GAAqD;IACrH,iGAAiG;IACjG,OAAO,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,CAAc,CAAC;AAC7D,CAAC"}
|
|
@@ -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;
|
|
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;AAq5FlF;;;;;;;;oFAQoF;AACpF,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,OAAO,GAAG,MAAM,CAiC9E;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,OAAO,EAAE,aAAa,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,oBAAoB,GAAG,MAAM,CAoW7G;AAED;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,EAAE,aAOlC,CAAC"}
|
|
@@ -5,7 +5,7 @@ import { goTypedInternals } from "./emit-shared-go-typed.js";
|
|
|
5
5
|
import { buildTypePlan, deriveTypeRef, findDecl, inputPortIsOptional, inputPortTypeRef } from "./typed.js";
|
|
6
6
|
import { concurrencyPlan, execPlan, analyzeSequentialOps, classifyExpr, buildComponentPlan, } from "./straightline.js";
|
|
7
7
|
import { NativeExprCompiler } from "./native-expr.js";
|
|
8
|
-
import { buildDeBoxPlan, notationOfRef } from "./emit-shared-debox.js";
|
|
8
|
+
import { buildDeBoxPlan, buildWirePlan, notationOfRef } from "./emit-shared-debox.js";
|
|
9
9
|
const PKG = "dslcontracts";
|
|
10
10
|
/** resolveGoWire — the BC-OWNED wire type names the de-box classifies a node result against. bc OWNS +
|
|
11
11
|
* GENERATES `WireValue`/`WireRow`/`WireList` (emitGoWireTypes); the consumer supplies none. A configured
|
|
@@ -143,6 +143,9 @@ function goTypeOfPlan(plan) {
|
|
|
143
143
|
case "map":
|
|
144
144
|
base = `map[string]${goTypeOfPlan(plan.value)}`;
|
|
145
145
|
break;
|
|
146
|
+
case "value":
|
|
147
|
+
// unreachable: a de-box (OUT) plan never contains `value` (input-only, fail-closed at plan build).
|
|
148
|
+
throw new GeneratorFailure("UNSUPPORTED_NODE_STRAIGHTLINE", "go de-box: a 'value' node reached goTypeOfPlan (unreachable — value is input-only)");
|
|
146
149
|
}
|
|
147
150
|
return "*".repeat(plan.optDepth) + base;
|
|
148
151
|
}
|
|
@@ -165,6 +168,10 @@ function renderGoDeBox(plan, target, srcExpr, ctr, indent, fail, idxExpr = "") {
|
|
|
165
168
|
const I1 = indent + "\t";
|
|
166
169
|
const I2 = indent + "\t\t";
|
|
167
170
|
const id = ctr.n++;
|
|
171
|
+
// unreachable: a de-box (OUT) plan never contains `value` (input-only, fail-closed at plan build). This
|
|
172
|
+
// exhaustiveness guard narrows the union so the record/list/map branches below stay total.
|
|
173
|
+
if (plan.k === "value")
|
|
174
|
+
throw new GeneratorFailure("UNSUPPORTED_NODE_STRAIGHTLINE", "go de-box: a 'value' node reached the de-box renderer (unreachable — value is input-only)");
|
|
168
175
|
const ml = JSON.stringify(plan.model);
|
|
169
176
|
const fl = JSON.stringify(plan.field);
|
|
170
177
|
const nl = JSON.stringify(plan.expectedType);
|
|
@@ -2337,12 +2344,41 @@ const goExprUsed = { helpers: false };
|
|
|
2337
2344
|
/** GoNativeExprBackend — renders native-expr for Go. `zeroOut` is the runner's error-return zero
|
|
2338
2345
|
* value; `resolveHead` maps a ref head (input port / input-array $as elem / prior node) to a typed
|
|
2339
2346
|
* base expr. Sets goExprUsed.helpers when a fallible helper is emitted (so emit() bakes the helper lib). */
|
|
2347
|
+
/**
|
|
2348
|
+
* renderGoWireBox — the ONE inline BOX renderer (typed→wire) for Go, the mirror of renderRustWireBox. Folds
|
|
2349
|
+
* a language-neutral {@link WirePlan} (`dir:"in"`) into a Go EXPRESSION evaluating to a `WireValue` built
|
|
2350
|
+
* from the OWNED `srcExpr`. `value` is identity (already the opaque wire); a native scalar wraps in its wire
|
|
2351
|
+
* ctor. A `value[]` bound-value list carries scalar / opaque elements; a nested opt / collection / record
|
|
2352
|
+
* element is fail-closed here (C1 — the compound box lands with the batched WireRow contract).
|
|
2353
|
+
*/
|
|
2354
|
+
function renderGoWireBox(plan, srcExpr) {
|
|
2355
|
+
if (plan.optDepth === 0) {
|
|
2356
|
+
if (plan.k === "value")
|
|
2357
|
+
return srcExpr; // identity — already the opaque BC wire.
|
|
2358
|
+
if (plan.k === "scalar") {
|
|
2359
|
+
switch (plan.scalar) {
|
|
2360
|
+
case "string":
|
|
2361
|
+
return `WireStr(${srcExpr})`;
|
|
2362
|
+
case "int":
|
|
2363
|
+
return `WireInt(${srcExpr})`;
|
|
2364
|
+
case "float":
|
|
2365
|
+
return `WireFloat(${srcExpr})`;
|
|
2366
|
+
case "bool":
|
|
2367
|
+
return `WireBool(${srcExpr})`;
|
|
2368
|
+
}
|
|
2369
|
+
}
|
|
2370
|
+
}
|
|
2371
|
+
throw new GeneratorFailure("UNSUPPORTED_NODE_STRAIGHTLINE", `go wire box: a value[] element of type '${plan.expectedType}' is not a scalar / opaque value (a nested opt/collection/record bound-value is not native-covered)`);
|
|
2372
|
+
}
|
|
2340
2373
|
function makeGoExprBackend(zeroOut, resolveHead, plan) {
|
|
2341
2374
|
const used = goExprUsed;
|
|
2342
2375
|
return {
|
|
2343
2376
|
lang: "go",
|
|
2344
2377
|
freshTemp: () => `ex_${goExprTempSeq++}`,
|
|
2345
2378
|
renderType: (ref) => renderTypeRef(ref),
|
|
2379
|
+
wireType: () => renderTypeRef({ kind: "value" }),
|
|
2380
|
+
// bc#156/#160: box a value[] element into the opaque BC wire via the ONE box SSoT (owned element expr).
|
|
2381
|
+
wireBox: (item) => renderGoWireBox(buildWirePlan(item.ref, { from: "top" }, { model: "port", field: "port", plan }, "in"), item.expr),
|
|
2346
2382
|
scalarType: (s) => goScalar(s),
|
|
2347
2383
|
strLit: (s) => JSON.stringify(s),
|
|
2348
2384
|
boolLit: (b) => (b ? "true" : "false"),
|