behavior-contracts 0.11.15 → 0.11.17
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/behavior.d.ts.map +1 -1
- package/dist/behavior.js +8 -3
- package/dist/behavior.js.map +1 -1
- package/dist/expr-eval.d.ts +2 -0
- package/dist/expr-eval.d.ts.map +1 -1
- package/dist/expr-eval.js +5 -2
- package/dist/expr-eval.js.map +1 -1
- package/dist/generator/emit-typed-native-rust.d.ts.map +1 -1
- package/dist/generator/emit-typed-native-rust.js +198 -49
- package/dist/generator/emit-typed-native-rust.js.map +1 -1
- package/dist/generator/native-expr.d.ts.map +1 -1
- package/dist/generator/native-expr.js +36 -1
- package/dist/generator/native-expr.js.map +1 -1
- package/package.json +1 -1
|
@@ -72,11 +72,23 @@ pub struct BehaviorError {
|
|
|
72
72
|
|
|
73
73
|
impl BehaviorError {
|
|
74
74
|
pub fn new(code: impl Into<String>, message: impl Into<String>) -> Self {
|
|
75
|
-
BehaviorError {
|
|
75
|
+
BehaviorError {
|
|
76
|
+
code: code.into(),
|
|
77
|
+
message: message.into(),
|
|
78
|
+
detail: None,
|
|
79
|
+
}
|
|
76
80
|
}
|
|
77
81
|
/// The same failure carrying the leaf's structured Error Value.
|
|
78
|
-
pub fn with_detail(
|
|
79
|
-
|
|
82
|
+
pub fn with_detail(
|
|
83
|
+
code: impl Into<String>,
|
|
84
|
+
message: impl Into<String>,
|
|
85
|
+
detail: ErrorDetail,
|
|
86
|
+
) -> Self {
|
|
87
|
+
BehaviorError {
|
|
88
|
+
code: code.into(),
|
|
89
|
+
message: message.into(),
|
|
90
|
+
detail: Some(Box::new(detail)),
|
|
91
|
+
}
|
|
80
92
|
}
|
|
81
93
|
/// The stable failure code (byte-equal to run_behavior) WITHOUT a bc-runtime type.
|
|
82
94
|
pub fn code(&self) -> &str {
|
|
@@ -106,10 +118,17 @@ function emitErrorHelpers() {
|
|
|
106
118
|
fn op_failed(node: &str, policy: &str, e: BehaviorError) -> BehaviorError {
|
|
107
119
|
// The Kind names itself, and 'retry' says it gave up — the attempts are Runtime-owned (scp-error.md:
|
|
108
120
|
// tuning never enters the IR), so what the plan reports is the exhausted retry.
|
|
109
|
-
let exhausted = if policy == "retry" {
|
|
121
|
+
let exhausted = if policy == "retry" {
|
|
122
|
+
" (exhausted)"
|
|
123
|
+
} else {
|
|
124
|
+
""
|
|
125
|
+
};
|
|
110
126
|
BehaviorError {
|
|
111
127
|
code: "OP_FAILED".to_string(),
|
|
112
|
-
message: format!(
|
|
128
|
+
message: format!(
|
|
129
|
+
"operation '{node}' failed under '{policy}' policy{exhausted}: {}",
|
|
130
|
+
e.message
|
|
131
|
+
),
|
|
113
132
|
detail: e.detail,
|
|
114
133
|
}
|
|
115
134
|
}
|
|
@@ -119,7 +138,13 @@ fn op_failed(node: &str, policy: &str, e: BehaviorError) -> BehaviorError {
|
|
|
119
138
|
// (TYPE_MISMATCH / MISSING_PROP) so the covered read stays equivalent to run_behavior; detail.kind
|
|
120
139
|
// distinguishes typeMismatch / missingField.
|
|
121
140
|
#[allow(dead_code)]
|
|
122
|
-
fn de_type_mismatch(
|
|
141
|
+
fn de_type_mismatch(
|
|
142
|
+
model: &str,
|
|
143
|
+
field: &str,
|
|
144
|
+
expected: &str,
|
|
145
|
+
actual_wire: &str,
|
|
146
|
+
raw: Cow<'static, str>,
|
|
147
|
+
) -> BehaviorError {
|
|
123
148
|
BehaviorError::with_detail(
|
|
124
149
|
"TYPE_MISMATCH",
|
|
125
150
|
format!("node '{model}': {field}: expected {expected}, got {actual_wire}"),
|
|
@@ -231,8 +256,14 @@ function emitRustProbeWireTypes(clone) {
|
|
|
231
256
|
// of the result set and is not forbidden.
|
|
232
257
|
pub enum Probe<T> {
|
|
233
258
|
Got(T),
|
|
234
|
-
Wrong {
|
|
235
|
-
|
|
259
|
+
Wrong {
|
|
260
|
+
actual_wire_type: &'static str,
|
|
261
|
+
raw_value: Cow<'static, str>,
|
|
262
|
+
},
|
|
263
|
+
Null {
|
|
264
|
+
actual_wire_type: &'static str,
|
|
265
|
+
raw_value: Cow<'static, str>,
|
|
266
|
+
},
|
|
236
267
|
Absent,
|
|
237
268
|
}
|
|
238
269
|
|
|
@@ -305,7 +336,10 @@ impl WireRow {
|
|
|
305
336
|
// from being copied: the String travels from the wire into the typed struct without a heap copy.
|
|
306
337
|
// Undeclared extras are simply left behind with the row.
|
|
307
338
|
pub fn take(&mut self, field: &str) -> Option<WireValue> {
|
|
308
|
-
self.entries
|
|
339
|
+
self.entries
|
|
340
|
+
.iter()
|
|
341
|
+
.position(|(k, _)| k == field)
|
|
342
|
+
.map(|i| self.entries.swap_remove(i).1)
|
|
309
343
|
}
|
|
310
344
|
}
|
|
311
345
|
|
|
@@ -316,8 +350,14 @@ pub fn probe_string_at(v: Option<WireValue>) -> Probe<Cow<'static, str>> {
|
|
|
316
350
|
match v {
|
|
317
351
|
None => Probe::Absent,
|
|
318
352
|
Some(WireValue::Str(s)) => Probe::Got(s),
|
|
319
|
-
Some(WireValue::Null) => Probe::Null {
|
|
320
|
-
|
|
353
|
+
Some(WireValue::Null) => Probe::Null {
|
|
354
|
+
actual_wire_type: "NULL",
|
|
355
|
+
raw_value: Cow::Borrowed("null"),
|
|
356
|
+
},
|
|
357
|
+
Some(o) => Probe::Wrong {
|
|
358
|
+
actual_wire_type: o.tag(),
|
|
359
|
+
raw_value: o.into_raw(),
|
|
360
|
+
},
|
|
321
361
|
}
|
|
322
362
|
}
|
|
323
363
|
pub fn probe_int_at(v: Option<WireValue>) -> Probe<i64> {
|
|
@@ -328,9 +368,19 @@ pub fn probe_int_at(v: Option<WireValue>) -> Probe<i64> {
|
|
|
328
368
|
// below. A wire numeric type that spells the same attribute 1 or 1.0 leaves the producer no way to
|
|
329
369
|
// pick the variant. Non-integral, or beyond i64, stays LOUD (an exact conversion with a
|
|
330
370
|
// fail-closed boundary, not a fallback).
|
|
331
|
-
Some(WireValue::Float(f))
|
|
332
|
-
|
|
333
|
-
|
|
371
|
+
Some(WireValue::Float(f))
|
|
372
|
+
if (-9223372036854775808.0..9223372036854775808.0).contains(&f) && f == f.trunc() =>
|
|
373
|
+
{
|
|
374
|
+
Probe::Got(f as i64)
|
|
375
|
+
}
|
|
376
|
+
Some(WireValue::Null) => Probe::Null {
|
|
377
|
+
actual_wire_type: "NULL",
|
|
378
|
+
raw_value: Cow::Borrowed("null"),
|
|
379
|
+
},
|
|
380
|
+
Some(o) => Probe::Wrong {
|
|
381
|
+
actual_wire_type: o.tag(),
|
|
382
|
+
raw_value: o.into_raw(),
|
|
383
|
+
},
|
|
334
384
|
}
|
|
335
385
|
}
|
|
336
386
|
// a float position accepts an int and widens it — the same widening the interpreter's outType check does,
|
|
@@ -340,32 +390,56 @@ pub fn probe_float_at(v: Option<WireValue>) -> Probe<f64> {
|
|
|
340
390
|
None => Probe::Absent,
|
|
341
391
|
Some(WireValue::Float(f)) => Probe::Got(f),
|
|
342
392
|
Some(WireValue::Int(n)) => Probe::Got(n as f64),
|
|
343
|
-
Some(WireValue::Null) => Probe::Null {
|
|
344
|
-
|
|
393
|
+
Some(WireValue::Null) => Probe::Null {
|
|
394
|
+
actual_wire_type: "NULL",
|
|
395
|
+
raw_value: Cow::Borrowed("null"),
|
|
396
|
+
},
|
|
397
|
+
Some(o) => Probe::Wrong {
|
|
398
|
+
actual_wire_type: o.tag(),
|
|
399
|
+
raw_value: o.into_raw(),
|
|
400
|
+
},
|
|
345
401
|
}
|
|
346
402
|
}
|
|
347
403
|
pub fn probe_bool_at(v: Option<WireValue>) -> Probe<bool> {
|
|
348
404
|
match v {
|
|
349
405
|
None => Probe::Absent,
|
|
350
406
|
Some(WireValue::Bool(b)) => Probe::Got(b),
|
|
351
|
-
Some(WireValue::Null) => Probe::Null {
|
|
352
|
-
|
|
407
|
+
Some(WireValue::Null) => Probe::Null {
|
|
408
|
+
actual_wire_type: "NULL",
|
|
409
|
+
raw_value: Cow::Borrowed("null"),
|
|
410
|
+
},
|
|
411
|
+
Some(o) => Probe::Wrong {
|
|
412
|
+
actual_wire_type: o.tag(),
|
|
413
|
+
raw_value: o.into_raw(),
|
|
414
|
+
},
|
|
353
415
|
}
|
|
354
416
|
}
|
|
355
417
|
pub fn probe_row_at(v: Option<WireValue>) -> Probe<WireRow> {
|
|
356
418
|
match v {
|
|
357
419
|
None => Probe::Absent,
|
|
358
420
|
Some(WireValue::Row(r)) => Probe::Got(r),
|
|
359
|
-
Some(WireValue::Null) => Probe::Null {
|
|
360
|
-
|
|
421
|
+
Some(WireValue::Null) => Probe::Null {
|
|
422
|
+
actual_wire_type: "NULL",
|
|
423
|
+
raw_value: Cow::Borrowed("null"),
|
|
424
|
+
},
|
|
425
|
+
Some(o) => Probe::Wrong {
|
|
426
|
+
actual_wire_type: o.tag(),
|
|
427
|
+
raw_value: o.into_raw(),
|
|
428
|
+
},
|
|
361
429
|
}
|
|
362
430
|
}
|
|
363
431
|
pub fn probe_list_at(v: Option<WireValue>) -> Probe<WireList> {
|
|
364
432
|
match v {
|
|
365
433
|
None => Probe::Absent,
|
|
366
434
|
Some(WireValue::List(l)) => Probe::Got(l),
|
|
367
|
-
Some(WireValue::Null) => Probe::Null {
|
|
368
|
-
|
|
435
|
+
Some(WireValue::Null) => Probe::Null {
|
|
436
|
+
actual_wire_type: "NULL",
|
|
437
|
+
raw_value: Cow::Borrowed("null"),
|
|
438
|
+
},
|
|
439
|
+
Some(o) => Probe::Wrong {
|
|
440
|
+
actual_wire_type: o.tag(),
|
|
441
|
+
raw_value: o.into_raw(),
|
|
442
|
+
},
|
|
369
443
|
}
|
|
370
444
|
}`;
|
|
371
445
|
}
|
|
@@ -892,53 +966,84 @@ function rustFloatLitExpr(n) {
|
|
|
892
966
|
* are the LOCAL BehaviorError with the SAME code strings as run_behavior.
|
|
893
967
|
*/
|
|
894
968
|
function emitExprHelpersRust() {
|
|
969
|
+
// rustfmt-canonical (genuine clean, NOT skipped): this helper library is STATIC — its content is fixed and
|
|
970
|
+
// IR-width-INDEPENDENT (byte-equal to expr-eval.ts core), so it is written in the exact form rustfmt
|
|
971
|
+
// produces (verified by running `cargo fmt` to a zero diff). Same treatment as the shared wire seam; the
|
|
972
|
+
// #[rustfmt::skip] surface is reserved for IR-width-dependent items that no fixed template can match.
|
|
895
973
|
return `// ── native-expr runtime-free helper library (#108) — byte-equal to expr-eval.ts core ──
|
|
896
974
|
#[allow(dead_code)]
|
|
897
975
|
fn bc_expr_add_i64(a: i64, b: i64) -> Result<i64, BehaviorError> {
|
|
898
|
-
a.checked_add(b)
|
|
976
|
+
a.checked_add(b)
|
|
977
|
+
.ok_or_else(|| BehaviorError::new("INT_OVERFLOW", "i64 overflow"))
|
|
899
978
|
}
|
|
900
979
|
#[allow(dead_code)]
|
|
901
980
|
fn bc_expr_sub_i64(a: i64, b: i64) -> Result<i64, BehaviorError> {
|
|
902
|
-
a.checked_sub(b)
|
|
981
|
+
a.checked_sub(b)
|
|
982
|
+
.ok_or_else(|| BehaviorError::new("INT_OVERFLOW", "i64 overflow"))
|
|
903
983
|
}
|
|
904
984
|
#[allow(dead_code)]
|
|
905
985
|
fn bc_expr_mul_i64(a: i64, b: i64) -> Result<i64, BehaviorError> {
|
|
906
|
-
a.checked_mul(b)
|
|
986
|
+
a.checked_mul(b)
|
|
987
|
+
.ok_or_else(|| BehaviorError::new("INT_OVERFLOW", "i64 overflow"))
|
|
907
988
|
}
|
|
908
989
|
#[allow(dead_code)]
|
|
909
990
|
fn bc_expr_neg_i64(a: i64) -> Result<i64, BehaviorError> {
|
|
910
|
-
a.checked_neg()
|
|
991
|
+
a.checked_neg()
|
|
992
|
+
.ok_or_else(|| BehaviorError::new("INT_OVERFLOW", "i64 overflow"))
|
|
911
993
|
}
|
|
912
994
|
#[allow(dead_code)]
|
|
913
995
|
fn bc_expr_check_finite(v: f64) -> Result<f64, BehaviorError> {
|
|
914
|
-
if v.is_finite() {
|
|
996
|
+
if v.is_finite() {
|
|
997
|
+
Ok(v)
|
|
998
|
+
} else {
|
|
999
|
+
Err(BehaviorError::new("NAN_OR_INF", "non-finite float"))
|
|
1000
|
+
}
|
|
915
1001
|
}
|
|
916
1002
|
#[allow(dead_code)]
|
|
917
|
-
fn bc_expr_add_f(a: f64, b: f64) -> Result<f64, BehaviorError> {
|
|
1003
|
+
fn bc_expr_add_f(a: f64, b: f64) -> Result<f64, BehaviorError> {
|
|
1004
|
+
bc_expr_check_finite(a + b)
|
|
1005
|
+
}
|
|
918
1006
|
#[allow(dead_code)]
|
|
919
|
-
fn bc_expr_sub_f(a: f64, b: f64) -> Result<f64, BehaviorError> {
|
|
1007
|
+
fn bc_expr_sub_f(a: f64, b: f64) -> Result<f64, BehaviorError> {
|
|
1008
|
+
bc_expr_check_finite(a - b)
|
|
1009
|
+
}
|
|
920
1010
|
#[allow(dead_code)]
|
|
921
|
-
fn bc_expr_mul_f(a: f64, b: f64) -> Result<f64, BehaviorError> {
|
|
1011
|
+
fn bc_expr_mul_f(a: f64, b: f64) -> Result<f64, BehaviorError> {
|
|
1012
|
+
bc_expr_check_finite(a * b)
|
|
1013
|
+
}
|
|
922
1014
|
#[allow(dead_code)]
|
|
923
|
-
fn bc_expr_neg_f(a: f64) -> Result<f64, BehaviorError> {
|
|
1015
|
+
fn bc_expr_neg_f(a: f64) -> Result<f64, BehaviorError> {
|
|
1016
|
+
bc_expr_check_finite(-a)
|
|
1017
|
+
}
|
|
924
1018
|
#[allow(dead_code)]
|
|
925
|
-
fn bc_expr_mod_f(a: f64, b: f64) -> Result<f64, BehaviorError> {
|
|
1019
|
+
fn bc_expr_mod_f(a: f64, b: f64) -> Result<f64, BehaviorError> {
|
|
1020
|
+
bc_expr_check_finite(a % b)
|
|
1021
|
+
}
|
|
926
1022
|
#[allow(dead_code)]
|
|
927
1023
|
fn bc_expr_mod_i64(a: i64, b: i64) -> Result<i64, BehaviorError> {
|
|
928
|
-
if b == 0 {
|
|
1024
|
+
if b == 0 {
|
|
1025
|
+
return Err(BehaviorError::new("MOD_ZERO", "int mod by zero"));
|
|
1026
|
+
}
|
|
929
1027
|
// Rust % is truncated (sign of dividend) — matches modCore. MIN % -1 would panic; guard it.
|
|
930
|
-
if a == i64::MIN && b == -1 {
|
|
1028
|
+
if a == i64::MIN && b == -1 {
|
|
1029
|
+
return Ok(0);
|
|
1030
|
+
}
|
|
931
1031
|
Ok(a % b)
|
|
932
1032
|
}
|
|
933
1033
|
#[allow(dead_code)]
|
|
934
1034
|
fn bc_expr_widen_i64f(a: i64) -> Result<f64, BehaviorError> {
|
|
935
1035
|
if !(-9007199254740992..=9007199254740992).contains(&a) {
|
|
936
|
-
return Err(BehaviorError::new(
|
|
1036
|
+
return Err(BehaviorError::new(
|
|
1037
|
+
"PRECISION_LOSS",
|
|
1038
|
+
"int exceeds exact float range (±2^53)",
|
|
1039
|
+
));
|
|
937
1040
|
}
|
|
938
1041
|
Ok(a as f64)
|
|
939
1042
|
}
|
|
940
1043
|
#[allow(dead_code)]
|
|
941
|
-
fn bc_expr_div_f(a: f64, b: f64) -> Result<f64, BehaviorError> {
|
|
1044
|
+
fn bc_expr_div_f(a: f64, b: f64) -> Result<f64, BehaviorError> {
|
|
1045
|
+
bc_expr_check_finite(a / b)
|
|
1046
|
+
}
|
|
942
1047
|
#[allow(dead_code)]
|
|
943
1048
|
fn bc_expr_len_arr<T>(a: &[T]) -> Result<i64, BehaviorError> {
|
|
944
1049
|
i64::try_from(a.len()).map_err(|_| BehaviorError::new("INT_OVERFLOW", "i64 overflow"))
|
|
@@ -955,20 +1060,32 @@ fn bc_expr_cmp_cp(a: &str, b: &str) -> std::cmp::Ordering {
|
|
|
955
1060
|
(Some(_), None) => return std::cmp::Ordering::Greater,
|
|
956
1061
|
(Some(ca), Some(cb)) => {
|
|
957
1062
|
if ca != cb {
|
|
958
|
-
return if (ca as u32) < (cb as u32) {
|
|
1063
|
+
return if (ca as u32) < (cb as u32) {
|
|
1064
|
+
std::cmp::Ordering::Less
|
|
1065
|
+
} else {
|
|
1066
|
+
std::cmp::Ordering::Greater
|
|
1067
|
+
};
|
|
959
1068
|
}
|
|
960
1069
|
}
|
|
961
1070
|
}
|
|
962
1071
|
}
|
|
963
1072
|
}
|
|
964
1073
|
#[allow(dead_code)]
|
|
965
|
-
fn bc_expr_str_lt(a: &str, b: &str) -> bool {
|
|
1074
|
+
fn bc_expr_str_lt(a: &str, b: &str) -> bool {
|
|
1075
|
+
bc_expr_cmp_cp(a, b) == std::cmp::Ordering::Less
|
|
1076
|
+
}
|
|
966
1077
|
#[allow(dead_code)]
|
|
967
|
-
fn bc_expr_str_le(a: &str, b: &str) -> bool {
|
|
1078
|
+
fn bc_expr_str_le(a: &str, b: &str) -> bool {
|
|
1079
|
+
bc_expr_cmp_cp(a, b) != std::cmp::Ordering::Greater
|
|
1080
|
+
}
|
|
968
1081
|
#[allow(dead_code)]
|
|
969
|
-
fn bc_expr_str_gt(a: &str, b: &str) -> bool {
|
|
1082
|
+
fn bc_expr_str_gt(a: &str, b: &str) -> bool {
|
|
1083
|
+
bc_expr_cmp_cp(a, b) == std::cmp::Ordering::Greater
|
|
1084
|
+
}
|
|
970
1085
|
#[allow(dead_code)]
|
|
971
|
-
fn bc_expr_str_ge(a: &str, b: &str) -> bool {
|
|
1086
|
+
fn bc_expr_str_ge(a: &str, b: &str) -> bool {
|
|
1087
|
+
bc_expr_cmp_cp(a, b) != std::cmp::Ordering::Less
|
|
1088
|
+
}`;
|
|
972
1089
|
}
|
|
973
1090
|
/**
|
|
974
1091
|
* boundRustType (change #3 — typed `bound`) — the CONCRETE Rust type of a covered node's `bound` handler
|
|
@@ -2608,7 +2725,10 @@ pub const COMPONENT_NAMES_NATIVE_RAW: [&str; ${names.length}] = [${names.join(",
|
|
|
2608
2725
|
// ── unknown_component helper (self-contained; the module carries no straight-line body) ──
|
|
2609
2726
|
const UNKNOWN_COMPONENT_HELPER = `#[allow(dead_code)]
|
|
2610
2727
|
fn unknown_component(component: &str) -> BehaviorError {
|
|
2611
|
-
BehaviorError::new(
|
|
2728
|
+
BehaviorError::new(
|
|
2729
|
+
"UNKNOWN_COMPONENT",
|
|
2730
|
+
format!("component '{component}' has no handler (fail-closed)"),
|
|
2731
|
+
)
|
|
2612
2732
|
}
|
|
2613
2733
|
|
|
2614
2734
|
// leaf_failure — a failure the LEAF reports (test glue): the runner assigns the node's failure code
|
|
@@ -2645,6 +2765,30 @@ ${emitErrorTypeDefs()}
|
|
|
2645
2765
|
${emitRustProbeWireTypes(true)}
|
|
2646
2766
|
`;
|
|
2647
2767
|
}
|
|
2768
|
+
// #275: BC OWNS the formatting of the covered module. The IR-shaped items — the outType struct decls (their
|
|
2769
|
+
// trailing field comments align width-dependently), their Default impls, the map elem-materializers, the
|
|
2770
|
+
// combined-read runners (payload literals + de-box match arms wrap by width), and the component-names const
|
|
2771
|
+
// (a width-wrapping array) — are assembled from the IR (SQL text, field names, port/entry counts, nesting),
|
|
2772
|
+
// so rustfmt's inline-vs-wrapped choice is width-dependent: there is NO content-independent template form
|
|
2773
|
+
// that is byte-identical to rustfmt for every IR (matching would reimplement rustfmt's line-wrapper), while
|
|
2774
|
+
// `bc check` drift-gates the emitted bytes byte-identical, so a post-hoc rustfmt pass is impossible. The
|
|
2775
|
+
// generator therefore declares `#[rustfmt::skip]` on each such top-level item: `cargo fmt --check` passes on
|
|
2776
|
+
// the bytes as emitted, and clippy stays FULLY enforced (rustfmt::skip is rustfmt-only). It is an OUTER
|
|
2777
|
+
// per-item attribute, NOT the module-level inner `#![rustfmt::skip]`, because the inner form is unstable on
|
|
2778
|
+
// stable rust (E0658 custom_inner_attributes → the covered crate would not compile). The STATIC items (the
|
|
2779
|
+
// wire seam + error type shared byte-for-byte with the genuinely-clean shared wire module, and the fixed
|
|
2780
|
+
// helpers) are NOT skipped — they are byte-fixed and emitted rustfmt-clean, keeping the wire.rs gate real.
|
|
2781
|
+
//
|
|
2782
|
+
// Items in a covered-module section are top-level and blank-line ("\n\n") separated (no runner/decl body
|
|
2783
|
+
// carries an interior blank line — verified across the whole golden corpus), so prepending the attribute to
|
|
2784
|
+
// each blank-line-separated block lands it above that item (any leading doc-comment sits between the
|
|
2785
|
+
// attribute and the item, which rust allows). op-agnostic: every item is covered, not a per-op subset.
|
|
2786
|
+
function withRustfmtSkip(section) {
|
|
2787
|
+
return section
|
|
2788
|
+
.split("\n\n")
|
|
2789
|
+
.map((item) => `#[rustfmt::skip]\n${item}`)
|
|
2790
|
+
.join("\n\n");
|
|
2791
|
+
}
|
|
2648
2792
|
function emit(ctx) {
|
|
2649
2793
|
// bc#97 (increment 2): the SSoT language-agnostic propagation pass derives, PER COMPONENT + PER NODE,
|
|
2650
2794
|
// which handler-call boundaries must be awaited (bottom-up over the declared async terminal handlers).
|
|
@@ -2672,7 +2816,7 @@ function emit(ctx) {
|
|
|
2672
2816
|
// an empty native surface (no covered read) carries no runner and no failure — nothing references
|
|
2673
2817
|
// bc-runtime, so it stays runtime-free (bc#90) with only the component-names const.
|
|
2674
2818
|
return `#![allow(dead_code, unused_imports)]
|
|
2675
|
-
${emitStructSurface([])}
|
|
2819
|
+
${withRustfmtSkip(emitStructSurface([]))}
|
|
2676
2820
|
`;
|
|
2677
2821
|
}
|
|
2678
2822
|
const plan = buildTypePlan(ctx.ir);
|
|
@@ -2783,7 +2927,12 @@ use std::borrow::Cow;
|
|
|
2783
2927
|
use std::cell::RefCell;`;
|
|
2784
2928
|
const sections = [
|
|
2785
2929
|
banner,
|
|
2786
|
-
|
|
2930
|
+
// #275: the leaf-transport `use <mod>::{…}` import is width-variable — its symbol set (and so its line
|
|
2931
|
+
// width) depends on the consumer's leaves, so rustfmt wraps it past max_width and no fixed template is
|
|
2932
|
+
// byte-identical for every consumer. Same class as the IR-shaped covered items → generator-owned
|
|
2933
|
+
// #[rustfmt::skip] (verified valid + warning-free on a `use` item on stable rust). sharedImportBlock is a
|
|
2934
|
+
// single fixed-width glob `use <path>::*;` → always clean, not skipped.
|
|
2935
|
+
importBlock ? withRustfmtSkip(importBlock) : undefined,
|
|
2787
2936
|
sharedImportBlock,
|
|
2788
2937
|
// #165: cross-package puts the concrete failure TYPE in the shared crate (imported via the glob above),
|
|
2789
2938
|
// so the transport crate returns `Result<WireValue, BehaviorError>` without importing the covered crate;
|
|
@@ -2792,8 +2941,8 @@ use std::cell::RefCell;`;
|
|
|
2792
2941
|
crossPackage
|
|
2793
2942
|
? `// De-box / op-failure constructors (produce the shared BehaviorError, imported above). Runtime-free.\n${emitErrorHelpers()}`
|
|
2794
2943
|
: `// Local concrete failure type (runtime-free) — a covered runner returns Result<T, BehaviorError> over\n// THIS local type instead of a bc-runtime failure, so the fully-covered module imports ZERO bc runtime.\n${emitBehaviorErrorType()}`,
|
|
2795
|
-
decls
|
|
2796
|
-
defaults
|
|
2944
|
+
decls ? withRustfmtSkip(decls) : undefined,
|
|
2945
|
+
defaults ? withRustfmtSkip(defaults) : undefined,
|
|
2797
2946
|
UNKNOWN_COMPONENT_HELPER,
|
|
2798
2947
|
rustExprUsed.helpers
|
|
2799
2948
|
? `// #108 native-expr helper library (runtime-free; byte-equal to expr-eval.ts core) — used by\n// cond / map-guard checked arithmetic. NO bc-runtime reference (failures use the LOCAL BehaviorError).\n${emitExprHelpersRust()}`
|
|
@@ -2803,10 +2952,10 @@ use std::cell::RefCell;`;
|
|
|
2803
2952
|
? `// strict de-box wire seam — the BC-OWNED, BC-GENERATED concrete WireValue (+ WireRow/WireList): the\n// consumer's single transport takes a WireRow payload + builds + returns a WireValue, implements NOTHING over\n// it. The generated INLINE de-box classifies it against the STATICALLY declared type and owns strictness\n// (required/optional, present/absent, error assembly, fail-closed). Self-contained concrete types.\n${emitRustProbeWireTypes(true)}`
|
|
2804
2953
|
: undefined,
|
|
2805
2954
|
elemMaterializers.length
|
|
2806
|
-
? `// map augmented-element copiers (pure struct field assignment — no dynamic value read).\n${elemMaterializers.join("\n\n")}`
|
|
2955
|
+
? `// map augmented-element copiers (pure struct field assignment — no dynamic value read).\n${withRustfmtSkip(elemMaterializers.join("\n\n"))}`
|
|
2807
2956
|
: undefined,
|
|
2808
|
-
`// Combined read runners (STRUCT-returning — the fully de-plumbed CONCRETE path).\n${runners}`,
|
|
2809
|
-
structSurface,
|
|
2957
|
+
`// Combined read runners (STRUCT-returning — the fully de-plumbed CONCRETE path).\n${withRustfmtSkip(runners)}`,
|
|
2958
|
+
withRustfmtSkip(structSurface),
|
|
2810
2959
|
];
|
|
2811
2960
|
return `${sections.filter((x) => !!x).join("\n\n")}\n`;
|
|
2812
2961
|
}
|