Skip to content

Commit 393ad18

Browse files
Phase D+E: stdlib expansion + conformance golden tests
## Phase D: ~35 new built-ins to close the gap with canonical Python omnicc ### Math (16) abs, floor, ceil, round, frac, clamp, sqrt, log, exp, sin, cos, tan, tanh, erf (Abramowitz & Stegun approximation), sigmoid, pow. Constants: pi(), e(), phi(). ### Strings (4) str_reverse, str_contains, str_slice, concat_many (variadic — the canonical workaround for OMC's broken cross-type `+` concat). to_string and concat_many render numerics as bare values (89) not as the HInt display form (HInt(89, φ=...)). ### Arrays (10) + arr_push fix arr_get, arr_set, arr_first, arr_last, arr_min, arr_max, arr_concat, arr_contains, arr_index_of, arr_slice, arr_resonance (mean across elements). Real arr_push (was a stub returning Null). ### Type coercion (6) to_int, to_float, to_string + int/float/string aliases. Polymorphic len(x) for arrays and strings (canonical OMC pattern). ### Parser fixes - Unary minus: `-5` now parses. - `for i in range(N)` single-arg form (canonical). 2-arg still works. ## Phase E: Conformance golden tests (omnimcode-core/tests/conformance.rs) 33 integration tests locking the language's "physics": - Fibonacci numbers have res >= 0.7 (1, 2, 3, 5, 8, 13, ... 610) - res(89) and res(610) are perfectly 1.0 - fold() snaps to Fibonacci attractor, preserves sign - fold(x, "fibonacci") string-mode 2-arg form works - 89/0 returns Singularity(89/0, ctx=div), is_singularity returns int 1/0 - resolve_singularity(p, "fold") snaps |numerator| to Fibonacci - Canonical smart_divide pattern from test_phase7_integration.omc - int+int=int, float+int=float arithmetic stability - phi.fold(x) === fold(x); phi.res(x) is HFloat - sqrt(144)=12, pow(2,10)=1024, sigmoid(0)=0.5, pi=π - arr_from_range(1,11) sums to 55 (Fibonacci coincidence) - arr_get/set/push/min/max round-trip - str_reverse, str_contains, concat_many semantics - Recursive fib(10)=55, while-loop sum(0..100)=4950 Tests are designed to be the contract between this Rust port and the canonical Python omnicc. If a test fails, it's either an intentional language semantics change (update Python+CHANGELOG) or a regression (fix the code, don't relax the test). ## Fixed (caught by conformance suite) - Expression::Resonance (1-arg res(x)) was returning HInt(resonance*1000) while the variadic call_function("res") path returns HFloat. Made consistent — both now return HFloat resonance score. - concat_many used Value::to_string() which produced the HInt display format. Now renders bare numerics like to_string built-in does. ## Compatibility milestone 4 canonical Python OMNIcode programs now run end-to-end on Rust OMC (up from 1 after Phase A+B): - miner_nuclear.omc (131 LOC, 7 stacked pragmas) - test_phase7_features.omc (import/module/typed-fn smoke tests) - test_phase8_arrays.omc (array-literal smoke tests) - test_array.omc (array stdlib regression suite) ## Tests 111 passing across the workspace (was 78 after Phase C). The new conformance suite contributes 33; Phase D added 0 unit tests but materially expanded what the conformance suite can exercise. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 30fc5d2 commit 393ad18

4 files changed

Lines changed: 720 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,41 @@ All notable changes to OMNIcode will be documented in this file.
44

55
## [Unreleased]
66

7+
### Added (Phase D: stdlib expansion to match canonical surface, 2026-05-13)
8+
Built out ~35 missing standard-library functions to close the gap with the canonical Python `omnicc/` interpreter at `Sovereign_Lattice/omninet_package/`.
9+
10+
**Math (16):** `abs`, `floor`, `ceil`, `round`, `frac`, `clamp`, `sqrt`, `log`, `exp`, `sin`, `cos`, `tan`, `tanh`, `erf` (Abramowitz & Stegun approximation), `sigmoid`, `pow`. Constants: `pi()`, `e()`, `phi()`.
11+
12+
**Strings (4):** `str_reverse`, `str_contains`, `str_slice`, `concat_many` (variadic — the canonical workaround for OMC's broken cross-type `+` concat). `concat_many` and `to_string` render numerics as bare values (`89`) instead of the HInt display form.
13+
14+
**Arrays (10):** `arr_get`, `arr_set`, `arr_first`, `arr_last`, `arr_min`, `arr_max`, `arr_concat`, `arr_contains`, `arr_index_of`, `arr_slice`, `arr_resonance` (mean resonance across elements). Plus a real implementation of `arr_push` (was a stub returning Null).
15+
16+
**Type coercion (6):** `to_int`, `to_float`, `to_string`, `int`, `float`, `string` aliases. The polymorphic `len(x)` works on both arrays and strings (canonical OMC pattern).
17+
18+
**Parser fixes:**
19+
- Unary minus: `-5` now parses (was: "Unexpected token in expression: Minus").
20+
- `for i in range(N)` single-arg form (canonical OMC). The 2-arg `range(start, end)` still works.
21+
22+
### Added (Phase E: Conformance golden tests, 2026-05-13)
23+
New integration test suite at `omnimcode-core/tests/conformance.rs` (~33 tests). Locks the language's "physics" — mathematical and semantic behaviors that must remain stable across implementations.
24+
25+
Sections: Fibonacci resonance ≥ 0.7 for canonical attractors; `fold()` snaps to Fibonacci preserving sign; `89/0` returns `Singularity` not crash; canonical `smart_divide` pattern; int+int=int, mixed=float arithmetic stability; `phi.X` module-qualified calls match unqualified; math identities (`sqrt(144)=12`, `pow(2,10)=1024`, `sigmoid(0)=0.5`, `pi=π`); array `get/set/push/min/max` semantics; string `reverse/contains`; recursion + while-loop control flow.
26+
27+
### Fixed
28+
- `Expression::Resonance` (1-arg `res(x)` path) now returns `HFloat`. Was returning `HInt(resonance * 1000)` — inconsistent with the variadic path. Caught by conformance tests.
29+
- `concat_many` and `to_string` no longer render numerics as `HInt(89, φ=…)` — they emit bare `89`.
30+
31+
### Compatibility milestone
32+
**4 canonical Python OMNIcode programs now run end-to-end on Rust OMC** (up from 1 after Phase A+B):
33+
- `miner_nuclear.omc` (131 LOC, 7 stacked pragmas)
34+
- `test_phase7_features.omc` (Phase 7 import/module/typed-fn smoke tests)
35+
- `test_phase8_arrays.omc` (Phase 8 array-literal smoke tests)
36+
- `test_array.omc` (array stdlib regression suite)
37+
38+
### Tests
39+
- **111 passing** across the workspace (was 78 after Phase C).
40+
- Conformance suite caught and forced fixes for 2 consistency bugs.
41+
742
### Added (Phase C: HSingularity as a first-class Value, 2026-05-13)
843
- **`Value::Singularity { numerator, denominator, context }`** — division by zero now produces a printable, first-class portal value instead of an `HInt` with a side-flag. `89 / 0` prints as `Singularity(89/0, ctx=div)`.
944
- **`is_singularity(v) -> int`** — returns `1` for any Singularity value, `0` otherwise. Returns int (not bool) to match the canonical Python idiom `if is_singularity(result) == 1`.

0 commit comments

Comments
 (0)