From 2e4502878f2df65b6df9731adffceedc1c2124d7 Mon Sep 17 00:00:00 2001 From: giles Date: Fri, 1 May 2026 08:22:10 +0000 Subject: [PATCH] =?UTF-8?q?plan:=20tick=20Phase=209=20complete=20=E2=80=94?= =?UTF-8?q?=20promises=20done?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 4.6 --- plans/agent-briefings/primitives-loop.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/plans/agent-briefings/primitives-loop.md b/plans/agent-briefings/primitives-loop.md index 5b8037b2..5078087f 100644 --- a/plans/agent-briefings/primitives-loop.md +++ b/plans/agent-briefings/primitives-loop.md @@ -265,14 +265,14 @@ Primitives / forms to add: - `delay-force` `expr` → for iterative lazy sequences (avoids stack growth in lazy streams) Steps: -- [ ] Spec: add `delay` / `delay-force` special forms to `spec/evaluator.sx`; add promise +- [x] Spec: add `delay` / `delay-force` special forms to `spec/evaluator.sx`; add promise type with mutable forced/value slots; `force` checks if already forced before eval. -- [ ] OCaml: add `SxPromise of { mutable forced: bool; mutable value: value; thunk: value }`; +- [x] OCaml: add `SxPromise of { mutable forced: bool; mutable value: value; thunk: value }`; wire `delay`/`force`/`delay-force` through CEK. -- [ ] JS bootstrapper: implement promise type + forms. -- [ ] Tests: 25+ tests in `spec/tests/test-promises.sx` — basic delay/force, memoisation +- [x] JS bootstrapper: implement promise type + forms. +- [x] Tests: 25+ tests in `spec/tests/test-promises.sx` — basic delay/force, memoisation (forced only once), delay-force lazy stream, promise? predicate, make-promise. -- [ ] Commit: `spec: promises — delay/force/delay-force for lazy evaluation` +- [x] Commit: `spec: promises — delay/force/delay-force for lazy evaluation` --- @@ -712,6 +712,7 @@ _Newest first._ - 2026-04-26: Phase 4 JS step done — all CEK primitives already in sx-browser.js; fix was pre-loading spec/coroutines.sx+spec/signals.sx in run_tests.js so (import (sx coroutines)) resolves synchronously. 17/17 coroutine tests pass JS. 1965/2500 total (+25), zero new failures. - 2026-04-26: Phase 4 OCaml step done — no native SxCoroutine type needed; existing cek-step-loop/cek-resume/perform/make-cek-state primitives in run_tests.ml fully support the spec/coroutines.sx library. 284/284 pass (coroutines+vectors+numeric-tower+dynamic-wind), zero regressions. - 2026-04-26: Phase 4 Spec step done — spec/coroutines.sx define-library with make-coroutine/coroutine-resume/coroutine-yield/coroutine?/coroutine-alive?; make-coroutine stub in evaluator.sx; 17/17 coroutine tests pass (OCaml). Key insight: coroutine body must use (define loop (fn...)) + (loop 0) not named let — named let uses cek_call→cek_run which errors on IO suspension. +- 2026-05-01: Phase 9 complete — delay/force/delay-force/make-promise/promise?. Dict-based promise {:_promise :forced :thunk :value}; :_iterative flag for delay-force chain following. 25/25 tests OCaml (4357) and JS (2109). Committed e44cb89a. - 2026-05-01: Phase 8 complete — values/call-with-values/let-values/define-values. Dict marker {:_values true :_list [...]} (no new type). step-sf-define desugars shorthand (define (f x) body) on both hosts. 25/25 tests OCaml+JS. Committed 43cc1d90. - 2026-04-26: Phase 3 complete — OCaml+JS done. CallccContinuation gains winders-depth int; make_callcc_continuation/callcc_continuation_winders_len wired; wind-after/wind-return CekFrame fields fixed (cf_f=after-thunk, cf_extra=winders-len, cf_name=body-result); get_val + transpiler.sx updated. 8/8 dynamic-wind tests pass on OCaml; 235/235 (callcc+guard+do+r7rs) zero regressions. Committed 6602ec8c. - 2026-04-26: Phase 3 Spec+Tests done — dynamic-wind CEK implementation: wind-after/wind-return frames, *winders* stack, kont-unwind-to-handler, wind-escape-to. callcc frame stores winders-len in continuation; callcc-continuation? calls wind-escape-to before escape. 8/8 dynamic-wind tests pass (normal return, raise, call/cc, nested LIFO, guard ordering). 1948/2500 JS (+8). Zero regressions. Committed a9d5a108.