feat(lang): 27.3 - a reducer on a table's row: reducer T in S.table on A, @Target, Row<T>, @RowVerb, @Column

An action names one row of a ludic.base Table<T> by its handle, in a field marked @Target, and
`reducer Deer in Herd.deer on Spook(r: mut Row<Deer>, n: Noise, a: Spook)` runs once, for that row
alone (the table may sit down a path, S.w.tab). The drain resolves the handle (tb_row) and hands the
reducer a Row<T> - new in ludic.base: tb, row, h, rec - that the queue keeps, one per row reducer,
filled in place, so a targeted action allocates nothing; a stale handle runs nothing, and
LUDIC_ACTIONS_LOG=1 prints a line for it (@alloc_ok). Row reducers order among an action's by their
state's name, then the table's path.

Checked at compile time (actions_rows.ludic): the row reaches r.rec and r.h only - r.tb / r.row
refused, the view never assigned, stored, copied or handed on except to a @RowVerb (a function of
the record's own module taking Row<T> first; any other function taking a row is refused); a field
marked @Column (a table column mirrors it) is not written through r.rec; only the module owning the
state declares a row reducer; one @Target, an int, per action; the states between the row and the
action are read. `mut` is allowed on a Row<T> parameter.

ludic schema's code section gains row_reducers (record, table, state, action, target, predicted,
net, module, at) and row_verbs (name, record, module, at), and every action its target; row
reducers are left out of `reducers`. ludic deps and ludic-lsp name a row reducer
`reducer Deer in Herd.deer on Spook`. vocab: @Target, @Column, @RowVerb; docs/language pages;
LANGUAGE.md "A reducer on a row"; examples actions/rows and ten rejects; test.ludic feat, reject and
schema cases (not run); changes/row-reducers.md. Reseeded; bootstrap-cfree fixpoint holds (307497
lines); Maroon Lake's `ludic build --check` is clean against this tree.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-30 16:14:59 +03:00
parent d22abae476
commit ab0b84b87e
37 changed files with 125923 additions and 110956 deletions

View file

@ -86,6 +86,11 @@ allocates nothing per query:
- **Parallel work reads, never writes, a state.** `Job.parallel_for(n, fn work, ctx)` over a
table's columns runs on every core; the compiler refuses a worker that takes a state as `mut`
(a result goes into `ctx`, a shared count through a `Sync` handle kept in the state).
- **A row, for a row reducer.** `Row<T>` (`tb`, `row`, `h`, `rec`) is one row as the action drain
hands it to `reducer T in S.table on A(r: mut Row<T>, a: A)` (LANGUAGE.md, "A reducer on a row"):
the action's `@Target` field carries the handle, the drain resolves it and fills a Row it keeps.
The table's owner writes a row through its `@RowVerb`s, which take the Row first and keep the
columns with the record's `@Column` fields.
- **Stable ids.** `IntMap` (`imap_new`, `imap_put`, `imap_get(m, k, none)`, `imap_del`) maps an
id kept in a save or a message to a handle without a scan.

View file

@ -0,0 +1,10 @@
# ludic.base/ecs_row.ludic - a Row<T>: one row of a Table<T>, as the action drain hands it to a row
# reducer (`reducer T in S.table on A(r: mut Row<T>, a: A)`). The drain keeps one per reducer and
# fills it in place, so a targeted action allocates nothing. A row reducer reads `r.rec` and `r.h`;
# `r.tb` and `r.row` are for the @RowVerbs of T's own module, which keep the columns and indexes.
export property Row<T> {
tb: Table<T>
row: int = -1 # the row the handle named when the drain resolved it
h: int = -1 # the handle the action carried
rec: T
}

View file

@ -20,6 +20,7 @@ import "save.ludic"
import "save_fields.ludic"
import "system.ludic"
import "ecs_table.ludic"
import "ecs_row.ludic"
import "ecs_hooks.ludic"
import "ecs_table_remove.ludic"
import "ecs_table_reserve.ludic"