diff --git a/design/INDEX.md b/design/INDEX.md index f891ff6..f823f9d 100644 --- a/design/INDEX.md +++ b/design/INDEX.md @@ -110,4 +110,4 @@ is the default. | authoring-surface | onboarding / evolves | design/models/0001-authoring-surface.md | | prose-projection | onboarding / evolves | design/models/0006-prose-projection.md | | pipeline | onboarding / evolves | design/models/0003-pipeline.md | -| kernel-extensions | onboarding / evolves (mechanisms milestone closed 2026-05-28; ratified end-to-end by the `ailang-kernel/src/raw_buf` base extension; series milestone pending) | design/models/0007-kernel-extensions.md | +| kernel-extensions | onboarding / evolves (mechanisms milestone closed 2026-05-28; ratified end-to-end by the `ailang-kernel/src/raw_buf` base extension; series library extension step-1 shipped via `ailang-kernel/src/series`, SoA step-2 #62 pending) | design/models/0007-kernel-extensions.md | diff --git a/design/models/0007-kernel-extensions.md b/design/models/0007-kernel-extensions.md index 0abc086..4311b4a 100644 --- a/design/models/0007-kernel-extensions.md +++ b/design/models/0007-kernel-extensions.md @@ -6,8 +6,11 @@ landed). The four language-level mechanisms — type-scoped namespacing, `Term::New`, kernel-tier modules + auto-import, and `param-in` — are shipped and ratified by the `raw_buf` base extension (`crates/ailang-kernel/src/raw_buf/`). The base-extension -milestone (`raw-buf`) has shipped; the library-extension milestone -(`series`) is pending. This +milestone (`raw-buf`) has shipped. The library-extension milestone +(`series`) has shipped its step-1 primitive Series over `{Int, Float}` +(`crates/ailang-kernel/src/series/`, the first pure-AILang library +extension; `param-in` defers `Bool`); step 2 — struct-of-arrays +record elements (#62) — is pending. This whitepaper describes the design as a coherent whole; the per-milestone specs in `docs/specs/` carry the implementation- level detail. Sections describing the now-shipped mechanisms read @@ -74,10 +77,12 @@ moving average over a stream of float values, window size 3": (ret (own (con Unit))) (effects IO))) (params s n) (body - (if (app >= (app Series.total_count s) n) - (app print (app / - (app sum_window_step s n 0 0.0) - (app int_to_float n))) + (if (app ge (app Series.total_count s) n) + (seq + (app print (app / + (app sum_window_step s n 0 0.0) + (app int_to_float n))) + (do io/print_str "\n")) (do io/print_str "")))) (fn run_stream @@ -108,8 +113,10 @@ moving average over a stream of float values, window size 3": (term-ctor FloatList FNil)))))))))))) ``` -Four constructs in this program are not in today's AILang. Each -maps onto one of the four mechanisms this whitepaper defines: +Four constructs in this program rest on the four mechanisms this +whitepaper defines — all now shipped (the mechanisms via the +`raw_buf` base extension, `Series` itself via the step-1 library +extension): - `Series` appears in type position with no module qualifier (`(con Series (con Float))`) — *kernel-tier modules*. @@ -437,33 +444,38 @@ handles allocation, drop, and copy-on-share. `Series a` is a bounded ring buffer with financial-style indexing (index 0 = newest). It is a plain AILang ADT in a kernel-tier -`.ail` module: +`.ail` module. Source of truth: +`crates/ailang-kernel/src/series/source.ail` — the listing below +is that module with the per-item `(doc …)` strings elided for +readability: ``` -(module series (kernel) +(module series + (kernel) (data Series (vars a) - (param-in (a Int Float Bool)) - (ctor S (con RawBuf a) ; the storage (no mode: modes live on - ; fn params/ret, not on ADT fields) + (param-in (a Int Float)) ; Bool deferred (#61) + (ctor S (con RawBuf a) ; the storage (no mode: modes live on + ; fn params/ret, not on ADT fields) (con Int) ; lookback (con Int) ; head index (con Int) ; current count (con Int))) ; total pushes ever (fn new - (type (fn-type + (type (forall (vars a) (fn-type (params (own (con Int))) - (ret (own (con Series a))))) + (ret (own (con Series a)))))) (params lookback) (body (term-ctor Series S - (new RawBuf (con a) lookback) lookback 0 0 0))) + ; element solved from the (con RawBuf a) ctor field — no type-arg + (new RawBuf lookback) lookback 0 0 0))) (fn push - (type (fn-type - (params (own (con Series a)) (own (con a))) - (ret (own (con Series a))))) + (type (forall (vars a) (fn-type + (params (own (con Series a)) (own a)) + (ret (own (con Series a)))))) (params s v) (body (match s @@ -472,31 +484,31 @@ handles allocation, drop, and copy-on-share. (app RawBuf.set buf head v) lookback (app % (app + head 1) lookback) - (if (app < count lookback) (app + count 1) count) + (if (app lt count lookback) (app + count 1) count) (app + total 1)))))) (fn at - (type (fn-type + (type (forall (vars a) (fn-type (params (borrow (con Series a)) (own (con Int))) - (ret (own (con a))))) + (ret (own a))))) (params s i) (body (match s (case (pat-ctor S buf lookback head count total) (app RawBuf.get buf - (app % (app + (app - head 1) (app + (app * lookback 2) i)) lookback)))))) + (app % (app + (app - (app - head 1) i) (app * lookback 2)) lookback)))))) (fn len - (type (fn-type + (type (forall (vars a) (fn-type (params (borrow (con Series a))) - (ret (own (con Int))))) + (ret (own (con Int)))))) (params s) (body (match s (case (pat-ctor S buf lookback head count total) count)))) (fn total_count - (type (fn-type + (type (forall (vars a) (fn-type (params (borrow (con Series a))) - (ret (own (con Int))))) + (ret (own (con Int)))))) (params s) (body (match s (case (pat-ctor S buf lookback head count total) total))))) ```