@kernlang/python 4.0.1-canary.222.1.f06f1a51 → 4.0.1-canary.225.1.f5c8d5fe

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.
@@ -1,4 +1,5 @@
1
1
  import { generatePythonCoreNode } from '../codegen-python.js';
2
+ import { dedupeGroundPrelude } from '../generators/ground.js';
2
3
  function findServerNode(root) {
3
4
  if (root.type === 'server')
4
5
  return root;
@@ -78,8 +79,11 @@ export function emitModels(root, options) {
78
79
  lines.push('');
79
80
  }
80
81
  }
82
+ // Top-level ground statements inline their helper/import prelude per-statement
83
+ // (a `module` wrapper dedupes in generateModule); collapse repeats across the
84
+ // assembled top-level bodies so each helper block appears once in the module.
81
85
  return {
82
- code: lines.join('\n'),
86
+ code: dedupeGroundPrelude(lines).join('\n'),
83
87
  bodies,
84
88
  };
85
89
  }
@@ -1 +1 @@
1
- {"version":3,"file":"emit-models.js","sourceRoot":"","sources":["../../src/core/emit-models.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAE9D,SAAS,cAAc,CAAC,IAAY;IAClC,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IACxC,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,IAAI,EAAE,EAAE,CAAC;QACxC,MAAM,KAAK,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;QACpC,IAAI,KAAK;YAAE,OAAO,KAAK,CAAC;IAC1B,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU,CACxB,IAAY,EACZ,OAKC;IAED,MAAM,YAAY,GAAG,OAAO,EAAE,IAAI,KAAK,QAAQ,IAAI,OAAO,EAAE,MAAM,KAAK,QAAQ,CAAC;IAEhF,0BAA0B;IAC1B,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC;QAC7B,MAAM;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,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;KAC1D,CAAC;IAEF,IAAI,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7D,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAED,MAAM,WAAW,GAAG;QAClB,qBAAqB,EAAE,OAAO,EAAE,qBAAqB;QACrD,kBAAkB,EAAE,OAAO,EAAE,kBAAkB;KAChD,CAAC;IAEF,MAAM,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,sBAAsB,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC;IAElF,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,SAAS,IAAI,MAAM,EAAE,CAAC;QAC/B,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACzB,KAAK,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,CAAC;YACzB,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACjB,CAAC;IACH,CAAC;IAED,+EAA+E;IAC/E,8EAA8E;IAC9E,8EAA8E;IAC9E,OAAO;QACL,IAAI,EAAE,mBAAmB,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;QAC3C,MAAM;KACP,CAAC;AACJ,CAAC"}
@@ -1,8 +1,85 @@
1
+ export declare const KERN_NULLISH_HELPER_PY: string;
2
+ export declare const KERN_JSON_STRINGIFY_SHIM_PY: string;
1
3
  export declare const KERN_PAIR_HELPERS_PY: string;
4
+ /** DECIMAL Slice 1 — KERN-owned canonical Decimal stringifier (Python leg).
5
+ *
6
+ * KERN's parity invariant requires `str(decimalValue)` to render byte-identically
7
+ * on both legs. Python's stdlib `decimal` PRESERVES scale (`Decimal("1.5") +
8
+ * Decimal("2.5")` renders `"4.0"`, and a literal `Decimal("300")` renders `"300"`
9
+ * but `.normalize()` → `"3E+2"`), whereas decimal.js has NO scale concept and
10
+ * renders the significance-free form (`"4"`, `"300"`). To make the Python leg
11
+ * match decimal.js's `toString()` byte-for-byte, this helper re-renders a Python
12
+ * Decimal from its (sign, digits, exponent) tuple under decimal.js's exact
13
+ * notation rule (precision 28, toExpNeg=-7, toExpPos=21):
14
+ * - drop trailing-zero scale (normalize significance)
15
+ * - PLAIN decimal notation iff the adjusted exponent `adj` satisfies
16
+ * `-7 < adj < 21`; else LOWERCASE-`e`, signed sci notation (`1e-8`, `1e+21`)
17
+ * - `-0` / `0.0` / `+0` all render `"0"` (decimal.js drops the sign of zero)
18
+ *
19
+ * Validated byte-for-byte against decimal.js 10.6.0 across 225/226 cross-cases
20
+ * (literals + pairwise sums); the single outlier is a >28-significant-digit input,
21
+ * which is OUTSIDE KERN's certified 28-digit precision envelope. Both engines are
22
+ * configured to precision 28 / ROUND_HALF_EVEN so ARITHMETIC values agree before
23
+ * rendering; this helper only canonicalizes the RENDERING of an agreed value.
24
+ *
25
+ * DECIMAL Slice 2 (Finding B): this block is also EMBEDDED into KERN_FMT_HELPER_PY
26
+ * (below) so `_kern_fmt`'s Decimal branch has `_KernDecimal` + `_kern_decimal_str`
27
+ * in scope intrinsically — no separate registration to miss. */
28
+ export declare const KERN_DECIMAL_STR_HELPER_PY: string;
29
+ /** DECIMAL Slice 2 (Finding B) — the production `_kern_fmt` helper block, with the
30
+ * canonical Decimal stringifier EMBEDDED so `_kern_fmt(decimalValue)` renders the
31
+ * significance-free (decimal.js-matching) form. The embed keeps `_kern_decimal_str`
32
+ * single-sourced (KERN_DECIMAL_STR_HELPER_PY) while making the dependency intrinsic
33
+ * to this one block — so the 7 IR emit sites and the route ground prelude that
34
+ * register KERN_FMT_HELPER_PY automatically carry it, with no co-registration to
35
+ * miss. The decimal `import` rides along at the top of the embedded block. */
2
36
  export declare const KERN_FMT_HELPER_PY: string;
3
37
  export declare const KERN_I32_HELPER_PY: string;
38
+ /**
39
+ * ToNumericPrimitive substrate (slice 0.75) — Python twin of the
40
+ * `@kernlang/core` `to-numeric` decision kernel.
41
+ *
42
+ * Single Python-side source of numeric coercion truth for the FROZEN primitive
43
+ * domain (numbers, ECMA numeric strings, booleans, null, undefined sentinel).
44
+ * The emitted Python encodes the ECMA-262 StringNumericLiteral grammar
45
+ * EXPLICITLY rather than delegating to `float(...)`, because `float()` diverges
46
+ * from JS `Number()` on three load-bearing cases: it accepts numeric separators
47
+ * (`float('1_000') == 1000.0`), case-insensitive infinity/NaN words
48
+ * (`float('infinity')`, `float('nan')`), and raises on `0x`/`0b`/`0o` prefixes.
49
+ *
50
+ * Return-type contract (tribunal amendments 1 & 2):
51
+ * - `_kern_to_number(x)` -> Python `float` for EVERY numeric output
52
+ * (bool/null/hex/binary/octal inputs included); `-0.0` sign survives; NaN
53
+ * and ±inf preserved.
54
+ * - `_kern_string_to_number(text)` -> `float` (NaN for any non-grammar string).
55
+ * - `_kern_number_to_int32(n)` -> `int` (signed 32-bit, shift-mask domain).
56
+ * - `_kern_number_to_uint32(n)` -> `int` (unsigned 32-bit).
57
+ * - `_kern_to_int32(x)` -> `int` = int32(to_number(x)).
58
+ * - `_kern_to_uint32(x)` -> `int` = uint32(to_number(x)).
59
+ * - `_kern_to_integer_or_infinity(x)` -> `float` (int-valued, or ±inf).
60
+ *
61
+ * Fail-closed: objects/arrays/functions/symbols/custom-valueOf RAISE
62
+ * `_KernNumericCoercionError` (the caller decides) — full ToPrimitive deferred.
63
+ *
64
+ * Single-source-of-int32 note: this block is the coercion-correct int32 path
65
+ * going forward. The legacy `_i32` (KERN_I32_HELPER_PY) embeds its OWN
66
+ * float()-based coercion and is still wired to production
67
+ * (codegen-body-python.ts ToInt32 lowering). Slice 0.75 is a PURE ADDITION —
68
+ * nothing is rerouted here, so both coexist; the future routing slice retires
69
+ * `_i32` in favor of `_kern_to_int32` once the fallback count hits zero.
70
+ *
71
+ * The ECMA whitespace string below is the exact `StrWhiteSpace` set
72
+ * (`WhiteSpace` + `LineTerminator`) JS trims from a StringNumericLiteral, kept
73
+ * byte-aligned with `ECMA_STR_WHITESPACE` in the TS kernel.
74
+ */
75
+ export declare const KERN_TO_NUMBER_HELPER_PY: string;
4
76
  export declare const KERN_TMOD_HELPER_PY: string;
5
77
  export declare const KERN_JS_HELPER_PY: string;
6
78
  export declare const KERN_JS_ARRAY_HELPERS_PY: string;
7
79
  export declare const KERN_JS_OBJECT_HELPERS_PY: string;
80
+ export declare const KERN_JS_NUMBER_HELPERS_PY: string;
81
+ export declare const KERN_JS_MATH_HELPERS_PY: string;
82
+ export declare const KERN_JS_ARRAY_FROM_HELPER_PY: string;
8
83
  export declare const KERN_JS_STRING_HELPERS_PY: string;
84
+ export declare const KERN_REGEX_MATCH_HELPER_PY: string;
85
+ export declare const KERN_REGEX_MATCHALL_HELPER_PY: string;