diff --git a/plans/agent-briefings/primitives-loop.md b/plans/agent-briefings/primitives-loop.md index 71dbd98a..29d922e3 100644 --- a/plans/agent-briefings/primitives-loop.md +++ b/plans/agent-briefings/primitives-loop.md @@ -491,14 +491,17 @@ Primitives to add: - `(number->string 1/3)` → `"1/3"` Steps: -- [ ] Spec: add `SxRational` type; add `n/d` reader syntax to `spec/parser.sx`; extend +- [x] Spec: add `SxRational` type; add `n/d` reader syntax to `spec/parser.sx`; extend all arithmetic primitives for rational contagion (int op rational → rational, rational op float → float). -- [ ] OCaml: add `SxRational of int * int` (stored in reduced form); implement all arithmetic. -- [ ] JS bootstrapper: implement rational type. -- [ ] Tests: 30+ tests in `spec/tests/test-rationals.sx` — literals, arithmetic, reduction, - mixed numeric tower, exact<->inexact conversion. -- [ ] Commit: `spec: rational numbers — 1/3 literals, arithmetic, numeric tower integration` +- [x] OCaml: add `SxRational of int * int` (stored in reduced form); implement all arithmetic. + as_number + safe_eq extended for cross-type rational equality (= 2.5 5/2) → true. +- [x] JS bootstrapper: implement rational type. + JS keeps int/int → float for CSS backward compatibility; SxRational class with _rational marker. +- [x] Tests: 30+ tests in `spec/tests/test-rationals.sx` — literals, arithmetic, reduction, + mixed numeric tower, exact<->inexact conversion. 62 tests, all pass. +- [x] Commit: `spec: rational numbers — 1/3 literals, arithmetic, numeric tower integration` + Committed 036022cc. JS: 2232 passed. OCaml: 4532 passed (+11). --- @@ -748,6 +751,7 @@ _Newest first._ - 2026-04-25: Phase 1 spec step done — all 10 vector primitives in spec/primitives.sx have full :as type annotations, :returns, :doc; make-vector optional fill param added. - 2026-04-25: Phase 1 OCaml step done — bounds-checked vector-ref/set!, vector-copy now accepts optional start/end, spec/primitives.sx doc updated. 10/10 r7rs vector tests pass, 4747 total (394 pre-existing hs-upstream fails unchanged). - 2026-04-25: Phase 0 complete — stopped CL/APL/Ruby/Tcl loops (all 4 idle at shell); confirmed E38 (tokenizer :end/:line) and E39 (WebWorker stub) both have implementation commits. +- 2026-05-01: Phase 16 complete — rational numbers. SxRational type in OCaml (Rational of int*int, reduced, denom>0) and JS (SxRational class, _rational marker). n/d reader in spec/parser.sx. Arithmetic contagion: int op rational → rational, rational op float → float. JS keeps int/int → float for CSS compat. OCaml as_number+safe_eq extended for cross-type rational equality. 62 tests in test-rationals.sx, all pass. JS 2232, OCaml 4532 (+11). 036022cc. - 2026-05-01: Phase 15 complete — math completeness. stdlib.math module: sin/cos/tan/asin/acos/atan(1-2 args)/exp/log/expt/quotient/gcd/lcm/number->string(radix)/string->number(radix). OCaml atan updated for optional 2nd arg. Strict radix parsing in JS string->number. 44 tests in test-math.sx, all pass. JS 2311/4801, OCaml 4547/5629. be2b11ac. - 2026-05-01: Phase 14 OCaml done — Eof + Port{PortInput/PortOutput} in sx_types.ml; 15 port primitives in sx_primitives.ml; raw_serialize updated; 4532/4532 (+39, zero regressions). 8ba0a33f. - 2026-05-01: Phase 14 Spec+JS+Tests+Commit done — port type {_port,_kind,_source/_buffer,_pos,_closed}; eof singleton; 15 primitives in spec/primitives.sx (stdlib.ports) + platform.py; 39/39 tests in test-ports.sx. Committed 3d8937d7. OCaml step next.