Skip to content

v3.5.0 - #1955

Merged
singaraiona merged 540 commits into
masterfrom
dev
Nov 30, 2026
Merged

v3.5.0#1955
singaraiona merged 540 commits into
masterfrom
dev

Conversation

@singaraiona

Copy link
Copy Markdown
Collaborator

What & why

Checklist

  • PR targets dev (not master)
  • Commits follow Conventional Commits (feat: / fix: / perf: / docs: / …)
  • make builds cleanly (no new warnings)
  • make test passes; tests added/updated for behaviour changes

…l does

Inside a query, a "" literal operand of concat (the STR null) made every
row "", while a "" from a column, an expression or a reduced cell joined
as empty text. The eager call never nulls: (concat "" "a") is "a" and
(concat ["x" ""] "") is ["x" ""]. The query text kernel
(concat_text_values in ops/string.c) had a rule of its own: a null atom
operand that was not a cell of the rows nulled the row. The same rule was
in the bytecode/fallback path (ray_concat_text_fn), through a row mask.

The owner decided on empty text: the eager call, every column-cell query
route and the function reference already agreed. The kernel drops the
null-row rule and the cell flags that only served it. A null operand,
STR "" or SYM ', is empty text wherever it comes from. ray_concat_text_fn
loses its rows_mask argument. A STR cell reduced by first/last/min/max
still makes the result STR.

Inputs that change (were all "", now the eager answer):
- (concat s ""), (concat "" s), (concat s "" u): in a select projection,
  update, update where:, update by:, where:, a by: projection, and the
  grouped and keyless first/last of it. Over s = ["x" "" "y"] the
  projection is ["x" "" "y"], not ["" "" ""].
- the same with the SYM null literal ' over a SYM column: (concat y ')
  keeps y.
- (concat t "") in a query helper evaluated row by row.

The docs sentence "CONCAT is null if any argument is null" in
language/string.md (Null Propagation, and again in the DAG paragraph) was
wrong for the eager call and for every column route. It now says that
concat reads the STR null as empty text. The concat sections and rows in
string.md, functions.md and all-functions.md state the same, with examples.

Tests: test/rfl/strop/concat_str_null.rfl (@also-unfused) is a matrix of
every ordered pair of a "" literal, a text literal, two columns holding
"" cells and an expression over one, plus five triples. For each it
compares the eager row-by-row call, the select projection, update,
update where:, update by:, the by: projection (pairs), where:, and the
grouped and keyless first/last. On dev it fails at line 16
((concat "" s) gives ["" "" "" ""]). Two tests that pinned the old rule
are updated: helper_bytecode_provenance.rfl and the 65-operand case in
concat_helper_consistency.rfl, whose position-64 coverage stays.

Fixes #1584
…elper

A query's concat takes 2 to 255 operands (OP_CONCAT), and a keyless
projection, where:, update and an aggregate's argument all accepted
(concat s "-" u). Two routes did not. A by: projection, with or without
where:, evaluates its output through the interpreter. A helper that runs
as bytecode calls the builtin through the compiled call path. Both reached
the binary concat builtin and raised "concat: takes 2 arguments, got 3".

Inside a query, the interpreter (eval_impl) now rewrites a concat of more
than two operands as nested binary concats, (concat (concat a b) c), and
evaluates that. Each step takes the query text rule and row provenance
of the binary path. More than 255 operands is an arity error, as for
OP_CONCAT. The compiled call path (op_callf) folds the operands left to
right through vm_call_binary, with each operand's row flag. Outside a
query concat stays binary: (concat "a" "-" "b") is still an arity error.

Checked the other variadic string builtins on the same routes. substr and
replace work on every route. format formats row by row in a keyless
projection and whole vectors everywhere else. That is a different
question, not this arity limit, and is filed as #1594.

replace and the STR null: every route gives the eager answer for every
argument. A "" input row gives "", an empty `to` deletes each match, and
an empty `from` matches nothing and returns the input. string.md's "null
input produces null output" did not cover from and to. Null Propagation
and the replace section now say this, and so do the replace rows in
functions.md and all-functions.md. The concat section says it takes 2
to 255 operands in a query.

Tests: test/rfl/strop/concat_multi_arg.rfl (@also-unfused) checks eight
concats of three to five operands, mixing columns, literals, "" and
expressions. For each it compares the eager row-by-row answer (nested
binary concats) with the keyless projection, by: projection with and
without where:, where:, update, update where:, update by:, and the
grouped and keyless first/last. It also covers helpers, inlined and
bytecode, a 70-operand by: projection, the 256-operand arity error, and
binary concat outside a query. Without the fix it fails at line 16
(arity). test/rfl/strop/replace_empty_args.rfl pins the replace
behaviour above.

Fixes #1592
…is a domain error

A grouped select whose output took the name of a by: key but held another
value returned two columns of that name, the key and the output, and only
the key could be reached by name:

    (select {a: (* a 2) u: (count h) from: S by: a})   ; columns [a a u]
    (select {b: (sum h) from: S by: [a b]})            ; columns [a b b]

As decided by the owner on #1236 (2026-11-24), such an output is now an
error. `select_check_key_named_outputs`, called first in
`ray_select_lowered`, before the key projections are folded and before any
route is chosen, rejects an output named like a key unless its value is that
key itself (`a: a`). The error is `domain`, worded like the other by: output
errors: "select by: output `a` is named like a by: key but is not that key".
The keys it checks: a single name, a vector of names, and the aliases of a
by-dict, whether the alias names a column or a computed key.

Inputs that answered on dev and are now a domain error:
- a single key: `{a: (* a 2) by: a}`, `{a: (sum h) by: a}`, `{a: b by: a}`,
  `{a: 'a by: a}`, `{a: (first a) by: a}`;
- several keys: `{b: (sum h) by: [a b]}`, `{a: (* a 2) by: [a b]}`;
- a by-dict: `{k: (sum h) by: {k: a}}`, `{k: a by: {k: a}}`,
  `{k: (sum h) by: {k: (+ a 1)}}`, `{a: (sum h) by: {a: a}}`, and an output
  named like a key the grouping drops as dependent
  (`{j: (count v) by: {kk: k j: (- k 1)}}`);
- the same under where:, take:, asc:/desc:, running functions, helpers the
  planner cannot lower, count-distinct, and on splayed and parted tables.

Unchanged:
- the key under its own name, `a: a`, still folds into the key;
- a renamed key, `x: a`, is still an ordinary output (f77dbb4);
- a key computed without a name (`by: (+ a 1)`) still answers: an output
  taking the name it would get renames the key to `key`, as on dev;
- a select without by:, and update with by:, which writes the key column in
  place and makes no second column.

Tests: `rfl/query/key_named_output.rfl` (`@also-unfused`) covers every key
form and route above and the forms that still answer; it fails with dev's
query.c, which returns `[a a u]`. Tests that pinned the duplicate columns
(issue_756, concat_helper_consistency, key_reader_atom_const,
renamed_group_key) now expect the error; tests that named an aggregate like
its key only by chance (scan_range, aware, encstr, compress_save,
join_select_projection, group_branch_cov, composite_key_projection,
single_key_projection) name it otherwise, keeping what they cover.

Docs: queries/select.md, where by: outputs are described.

Fixes #1236
Two runs of the same left-join over duplicate keys returned each left
row's matches in different orders (#1253): on the radix path the order
follows partitions and threads. The owner decided on 2026-11-24 that the
order is unspecified, so the join keeps its fastest path, and that the
docs say so.

joins.md gets a "Row order" section, written from what dev does:
- inner-join, left-join and full-join: the order of a key's matches is not
  specified, and on the radix path neither is the order of the left rows
  (a left-join with a 200000-row right side did not keep left order). It
  can differ between runs, core counts and the small-input and radix
  routes; every run returns the same multiset of rows.
- anti-join keeps the left order, as anti-mask selects it; semi-mask and
  anti-mask give one value per left row.
- asof-join and window-join give one row per left row in left order, and
  an as-of tie on key and time takes the last right row.
- To get an order, sort with xasc by columns that tell rows apart, or
  number the right rows first; the example is checked against dev.
The inner, left and full sections link to it, and the DAG section's
sentence on radix-path inner-join order points there too.

Tests: test/rfl/join/join_row_order.rfl pins what remains guaranteed:
the same rows from two runs of inner, left and full join on the issue's
radix input and on the small path, compared after an explicit sort; the
left order of anti-join, asof-join and window-join; the as-of tie. It pins
no unsorted equi-join order.

Fixes #1253
agg_contract/cd_gate_read_ahead failed under memory pressure on its
major-fault budget (116 to 471 faults in a step whose ask-ahead byte
checks passed, #1579): the budget assumes pages asked for ahead stay in the
page cache until they are read, and reclaim can drop them first, so
reading them back is a fault the code did not cause.
pool/scan_read_ahead_queries makes the same assumption in its fault
budget with read-ahead on.

The kernel counts the reads back of reclaimed file pages as refaults.
test/page_cache.h reads that count (workingset_refault_file, from the
process's cgroup v2 memory.stat, else /proc/vmstat).  Each budgeted step
is judged always, with its budget raised by the refaults counted over the
step and by no more: refaults that are not the test's own (the count is
the cgroup's or the system's) cost the budget that much slack, never the
check, while a step that reads what it never asked for faults on hundreds
or thousands of pages.  The refaults are read outside the faults at both
ends of a step.  Where the count is not there (not Linux) the budgets are
judged as before.  The ask-ahead byte checks are judged always.

With the ask-ahead disabled (the madvise skipped, the bytes still
counted), in a cgroup shared by busy processes, both tests fail 30 of 30;
with it, both pass 30 of 30.

Fixes #1579
`make test-release` did not build with gcc: the -O3 .reltest.o flavour
inlines far enough for gcc to see three diagnostics that `make test`
(-O0) never shows, and -Werror stops the build on each.

- test_domain.c (gcc 11, 12, 16; -Wformat-truncation): dom_app_clean
  builds `<path>.lk` and `<path>.ix` in a char[256], and a caller passes
  a char[256] holding `<path>_new`, so a path that fills it was cut short
  and the cleanup unlinked a different name. The buffer now holds a
  256-byte path plus the suffix.
- test_parquet.c (gcc 11, 16; -Wformat-truncation): pq_synth_check
  builds `<dir>/.sym` in a char[200] without checking the result. A dir
  that does not fit now fails the check instead of reading a truncated
  path.
- test_repl.c (gcc 12, 16; -Wmaybe-uninitialized): when popen fails,
  run_cli_capture writes neither the status nor the output, and the
  failure message of cores_reject_malformed printed both. Both now start
  set (-1, "").

No warning is switched off.

Fixes #1587
gcc 12 (the Debian 12 compiler) raised two -Werror false positives that
neither the runner's default gcc nor clang 23 reports (#1531:
maybe-uninitialized in agg_engine.c, stringop-overflow in sort.c), so
`make release` and `make shared` stopped there while every CI leg was
green.

A new `gcc-12` job installs gcc-12 and runs `make release CC=gcc-12`
and `make shared CC=gcc-12`, without tests (the suite runs on the other
legs). It is pinned to ubuntu-24.04, whose archive ships gcc-12, and is
added to ci-success's required jobs, so a change that does not build
with gcc 12 cannot land.

Part of #1531
…by: (#1468)

    (update {l: 7 from: L where: (== k 1)})   ; type: vec_new: ... got LIST
    (update {l: 'a from: L by: k})            ; the same

with l a LIST column.  The where: route built the updated column with
ray_vec_new of the column's type, which refuses LIST; only a SYM atom had
its own boxed branch.  The by: route built each group's sub-table the same
way, so it failed for any LIST column of the table, even when another
column was updated, and a group's result had no LIST column to go into.

Under where:, a LIST column is now rebuilt as a boxed list: each kept row
takes its cell of the value, an atom boxed into every one of them, and the
other rows keep theirs.  Under by:, a group's LIST cells are gathered into
its sub-table, and an updated LIST column boxes each group's result into
its rows, whatever its type.  This is how the keyless update already
boxes (#1458), on the in-place routes too.  A value of another length
raises `length`, as for a typed column.

first and last of a LIST column are one cell per group (or for the
rows), as select gives them, and every row of the group now holds that
cell.  This covers by:, keyless and where:, in place, and a new column.
Before, a cell was read as a column of values: a one-element cell [7]
was collapsed to 7, a cell as long as the group was spread over its rows,
and any other length raised `length`.  A cell into a typed column is a
`type` error, as a LIST value is.  A where: that keeps no row leaves the
column unchanged.  A row-wise value, such as (at l i) with i a column,
gives each row its own cell, its index counting within the group under
by:, as a typed column's update does.  update_list_column_matrix.rfl
crosses first, last, at with a constant or a column index, count, a
constant list, the column and reverse with by:, keyless, and where:
keeping all, some and no rows, as a copy, in place and as a new column.
The cell forms are checked against select with each group's cell
written back.

Not changed:
- Under by:, (at l k) with a constant index over a LIST column raises
  nyi, naming #1429.  Whether k counts within the group is the owner's
  open question there, and every update by: of a LIST column raised on
  dev.  Keyless it keeps dev's answer.  Under where: an existing LIST
  column takes an answer where dev raised type: the index is read over
  the whole table and a one-element cell collapses.
- A new column under where: from first/last of a LIST column keeps dev's
  legacy answer.  A one-element cell is collapsed to its value
  ([0Nl 0Nl 4 4 4]), and any other cell fails as on dev.  Which rule it
  should follow is the design question #1574.
- A constant list of another length raises length, as documented.

Lands together with the #1429 commit stacked above it.  On its own the
constant-index at case is not final: #1429 makes (at l k) under by: and
under where: the group's (or the kept rows') cell.

Fixes #1468
…on the fallback too (#1571)

A keyless select gave two answers for (sum (count v)): 16 on the
planned route (the count, 4, spread over 4 rows) and 4 on the evaluator
fallback (the route taken when another output is declined), and 9 against
3 under a where: keeping 3 rows.  by: refuses the output.

The documented rule says a scalar stands for every row, as 1 does in
(sum 1), and the bind-first oracle agrees: (set C 4) then (sum C) is 16.
So the fallback now spreads a scalar its source gives over the rows when
the source holds an aggregate, as the planned route does.  A non-inlined
helper's scalar is still folded once, as every route gives it and #1401
pins: (sum (hq v)) is 4.  Whether it should spread too is the design
question #1576.

The fallback's answers that change (keyless, beside a declined output;
T has 4 rows, the where: keeps 3), each now equal to the planned route:
- sum and prod of a scalar source: (sum (count v)) 4 -> 16, under the
  where: 3 -> 9; (sum (max v)) 40 -> 160; (sum (sum c)) 14 -> 56;
  (sum (first v)) under the where: 20 -> 60; (prod (count v)) 4 -> 256.
- count of a scalar source counts the rows: (count (max v)) 1 -> 4,
  under the where: 1 -> 3.
- over a where: that keeps no row, the empty column's answer:
  (sum (+ 1 (count v))) 1 -> 0, (count (count v)) 1 -> 0,
  (max (count v)) 0 -> 0Nl, (avg (sum c)) 0.0 -> 0Nf.
- other scalar-source cases, each now equal to the planned route and
  the bind-first oracle:
  (sum (count (distinct s))) 3 -> 12 (distinct sends the output to the
  fallback, so its planned answer moves too);
  (avg (last d)) 2024.01.04 -> 8769.0, as (avg (last d)) alone gives;
  (med (last d)), (dev (last d)), (var (last d)): type -> 8769.0 / 0.0
  / 0.0;
  (var (count v)) and every var of a scalar 0Nf -> 0.0 (equal values);
  (sum (> (count v) 2)) true -> 4;
  over a where: keeping no row, (all (count v)) false -> true and
  (any (+ 1 (count v))) true -> false, the empty column's.
- first, last, min, max, avg, med, all and any over row sources are
  unchanged.

Over 13 aggregates of 9 sources with no where:, a where: keeping 3 rows
and one keeping none, the fallback now equals the planned route
everywhere except one pre-existing case.  prod over no row is 0Nl
planned and 1 on the fallback, for any source; that is filed as #1577
and not changed.  No #1429-class answer moves:
keyless_fold_const_index_parity passes unchanged.

Fixes #1571
…nner (#1567, #1568)

    (set t (table [g s v] ...))   (set u (table [k v] ...))
    (select {from: t by: g r: (count (at (select {from: u by: k x: (sum v)}) 'x))})
    ; r [3 2], expected [3 3]
    (select {r: (sum (max (at (select {from: u by: k x: (sum v)}) 'x))) from: t})
    ; type: sum: list elements must be numeric, expected [7500] as bound

At run time a nested select binds its own table's columns, and its
outputs as aliases, after the outer query's, so its v is u's.  The
planner's column walk (collect_col_refs_walk) entered the nested select's
dict and read v as the outer table's column.  It therefore took the nested
value as row-aligned: sliced by group under by: (the count of a 3-value
result was each group's row count, the sum [3600 0]) and spread by row
keyless.  Renaming u's column to y gave the right answers on dev, so the
two issues are one cause.  It is not the value's length: a computed value
that merely matches a group's length is aggregated as it stands.

The walk now follows the run time.
- Inside a nested (select D), a name that is a column of D's table is the
  nested select's own, not a column of the outer table.
- So is one of D's outputs, but only within D's outputs: D's where:,
  by: and from: do not see them, so a name there that only an output
  has is a correlated reference.
- D's table is known when its from: is:
  - a name bound to a table: a global, a parameter or a let;
  - an expression of pure builtins over such names that reads no outer
    column.  That expression is evaluated to learn its columns; no user
    code runs.
- from: itself is read in the enclosing scope.
- A name only the outer table has (a correlated reference) is read as
  before.

nested_select_name_scope.rfl compares, against the same value returned
by a helper the planner does not inline or bound first:
- a name in both tables, under by: and keyless;
- #1568's keyless aggregate;
- two levels of nesting;
- an inner alias named like an outer column;
- update under by:, keyless, where: and as a projection;
- a nested select over a parameter, a let and (take u 3);
- a correlated name in the inner where: beside an inner output of the
  same name.
It pins dev's answers for correlated names.  No #1429-class answer moves.

Fixes #1567
Fixes #1568
…ept rows keyless (#1429)

The owner decided #1429 on 2026-11-24: under by:, every expression in an
output sees the group's rows of each column, as select.md says.  That
covers fold over a column, at of a column at any index (a constant, a
vector or a column of indexes) and an aggregate inside a call such as
(til (count v)).  Keyless it sees the rows a where: keeps; update by:
sees the group and writes back to its rows; update where: sees the kept
rows.  Each answer now equals the same expression evaluated outside the
query on those rows' values.  The one exception is documented: a query's
first and last skip nulls (#1368).

How:
- fold (and fold-left, fold-right, fold-while) with an argument that
  reads a row column, and at whose source is a column (a column, or
  atomic calls over columns), are read like the whole-column verbs.  They go per group under by:, over the kept rows
  for keyless projections and aggregates, and over the kept rows for
  update where:.
- A fold, at at a one-value index, a helper that folds, and an
  expression built from such values and aggregates ((+ (fold + v) 1),
  (at v (- (count v) 1))) are one value of the rows, as an aggregate
  is.  A collection it gives is one cell, filled into every row beside a
  row output, never read as rows.
- A helper whose body folds is read the same way keyless, inlined or
  not.
- Over no rows, a keyless output or aggregate of these reads as on dev:
  per row, so nothing ((fold + v) over no row is an empty column, and
  (sum (fold + v)) is 0).
- In a helper's body, any fold or at counts, as a whole-column verb
  there does.
- The arithmetic-of-aggregates rewrite no longer takes a non-elementwise
  head ((til (count v)) was til of the column of per-group counts).

Undone:
- #1401's guard that kept these sources on the parent's path:
  keyless_fold_const_index_parity.rfl (746 cases pinned to the parent)
  is replaced by keyless_fold_const_index_group.rfl.  That file checks
  the same cases, 788 with the plain outputs, each against the
  per-group or kept-rows oracle.
- #1468's nyi for (at l <constant>) under update by: is gone.  A LIST
  column at a one-value index is one cell of the group, as select by:
  gives it, and update writes it to every row of the group (and, keyless
  or under where:, of the rows).

Answers that change (t: g [a a a b b], v [30 10 20 5 7], i [1 0 2 1 0];
where: keeps v > 6), before -> after:
- select by:, plain output:
  (- v (fold + v)) [[-42 -62 -52] [-67 -65]] -> [[-30 -50 -40] [-7 -5]];
  (- v (at v 0)) [[0 -20 -10] [-25 -23]] -> [[0 -20 -10] [0 2]];
  (at v i) [[10 30 20] [10 30]] -> [[10 30 20] [7 5]];
  (til (count v)) type -> [[0 1 2] [0 1]].
- select by:, aggregates over at or fold:
  (sum (at v [1 0])) [40 0] -> [40 12];
  (sum (at v i)) [60 40] -> [60 12];
  (count (at v [0])) [3 2] -> [1 1];
  (max (- v (at v 0))) [0 -23] -> [0 2];
  (sum (- v (fold + v))) [-156 -132] -> [-120 -12];
  (sum (fold + v)) type -> [60 12];
  under where:, the kept rows of each group instead of the table's.
- keyless, with and without where: and beside a declined output: fold
  and at of a column raised type (fold: vec arg must be a list; at:
  cannot index i64), evaluated per row.  They now give the kept rows'
  answer: (fold + v) [72] / [67], (- v (at v 0)) [0 -20 -10 -25 -23],
  (sum (at c [3 2 1 0])) [14], (at v i) [10 30 20 10 30].
- update where:: (fold + v) [72 72 72 0Nl 72] -> [67 67 67 0Nl 67], and
  likewise any fold or at of a column: the kept rows, not the table.
- update by:: unchanged (it already evaluated each group's sub-table),
  except (at l k) over a LIST column: nyi -> the group's cell.
- (at l k) of a LIST column keyless or under where:: the length error
  -> the cell on every (kept) row; (at l 1) [3 3 3 3 3] -> (list [3] ...).
- A new column under where: from such a cell keeps #1574's legacy
  reading.  A cell of several values is now always the documented
  typed-vector error, never spread over the kept rows; dev gave the
  length error for those it failed on.
- fold over a free vector as long as the table (W [100 200 300 400 500]):
  the owner decided on 2026-11-24 that it folds the group's slice, as
  sum sums it.  fv_arg_rows now reads fold's vector as rows on every
  route:
  (fold + W) by g [1500 1500] -> [600 900];
  under where: [600 500];
  keyless under where: [1100];
  update by: [600 600 600 900 900].
  Another length is the aggregate length error; a one-element vector, a
  computed collection and an empty table read as on dev.
- the fold family, previously still read over the whole table:
  (- v (fold-left + 0 v)) by g [[-42 -62 -52] [-67 -65]] ->
  [[-30 -50 -40] [-7 -5]], likewise fold-right and fold-while;
  keyless (fold-left + 0 v) under where: type -> [67].
- a helper that folds, keyless: (H v) with H (fn [x] (fold + x)) type ->
  [72], under where: [67].
- by: over no rows: (til (count v)) raised type and (sum (fold + v))
  domain; both are now the empty grouped result every by: over no rows
  gives (dev's errors came from reading the whole table).
- (at v [1 0]) beside a row output (vv: v): type -> length (a value of
  two rows beside five).
Over the 788 former parity cases, 372 change, every one to the oracle.

Not changed:
- at over a vector that is no column is a lookup, read whole (#1492):
  (sum (at W i)) by g is [600 300].  So is at of a column at an index
  read from a free vector as long as the table, a row position per row:
  (at v (- (div W 100) 1)) by g [[30 10 20] [5 7]], under update where:
  [30 10 20 0Nl 7], keyless under where: type, all as on dev.  A vector
  written in place is a constant index and sees the group.
- Empty inputs, keyless and under update, answer as on dev.
- An aggregate of an aggregate of the group is still refused (#1469):
  (count (til (count v))) by g.
- #1572 (landed while this was written; this is rebased on it): its
  memory-safety guard stands.  Its test pinned two G by: g answers of
  med over a constant-index at, [3.0 0Nf] and [5.0 0Nf].  Under this
  rule they are each group's own, [3.0 4.0] and [5.0 6.0], equal to the
  group oracle, and by_med_short_source.rfl is updated so.

Fixes #1429
…ound differently

## Issue

In a select or update, sum and avg of (+ x c), (+ c x) or (- x c) are
computed from the column total: the query sums x once and adds n * c (for
avg, the mean of x plus c) at the end instead of forming the rows x + c.
Over an F64 column the answer can differ from summing the rows one by
one. With rows 2^53 and -2^53 and c = 1.0 the query answers 2.0 (avg
1.0), while the rows, where 2^53 + 1 rounds to 2^53, sum to 1.0 (avg
0.5). The routes can also disagree about overflow.

## Decision

The difference is allowed and is now documented (math.md, "A column
plus a constant in a query"), with the bound stated under its conditions:

- Conditions: n counts the non-null rows, and no intermediate overflows
  (every row x + c, n * c, and every partial total either route forms
  stays finite); sum |x| + n * |c| <= 2^1023 is a sufficient check.
- With T = sum |x| + n * |c|, the sums differ by at most
  (n + 1) * 2^-51 * T, and the averages by at most that over n plus
  2^-1074. Both routes are within gamma_(n+1) * T of the exact total;
  2 * gamma_(n+1) <= (n + 1) * 2^-51 for n < 2^52. Subnormal sums obey
  the relative bound because a subnormal addition is exact, and n * c is
  exact when subnormal; each route's division by n can underflow and lose
  up to 2^-1075, hence the absolute 2^-1074 term. Rows 5e-324 and 0.0 with
  c = 5e-324 show it: the query's mean is 2^-1074, the rows' 2 * 2^-1074.
- Outside the conditions no bound is guaranteed: an overflowing total is
  0Nf, and either route may overflow in a partial total while the other
  does not, however far the exact total is from the limit. Rows M, 2^970,
  -M with c = -2^969 have exact total -2^969; the query answers 0Nf, the
  rows cancel to 0.0.
- A constant of magnitude 2^970 or more is applied row by row, so the
  issue's 1e308 + -1e308 case answers 0.0.
- I64 with an integer constant is exact: the column total and n * c are
  added in 128 bits and divided once (adeb2d5, 9db52ab), on every
  route.

The sum section points to the new subsection.

## Test

test/rfl/agg/affine_f64_tolerance.rfl asserts the documented tolerance,
never bit equality: the issue's two rows on the keyless, where:, beside
count, constant-first and subtracted forms; 100000 mixed rows for sum and
avg; the subnormal mean, which needs the 2^-1074 term; overflow to 0Nf on
both routes, a near-limit disagreement and the intermediate overflow with
cancellation; the row-by-row path for a constant of 2^970 or more; and
exact I64 sum and avg of a column plus 2^62.

Fixes #1178
The ten builtins for vector distances, nearest neighbours and the HNSW
index were global names. They move under one namespace:

  cos-dist, inner-prod, l2-dist   -> .emb.cos-dist, .emb.inner-prod, .emb.l2-dist
  knn, ann                        -> .emb.knn, .emb.ann
  hnsw-build, -free, -save,       -> .emb.hnsw-build, .emb.hnsw-free, .emb.hnsw-save,
  -load, -info                       .emb.hnsw-load, .emb.hnsw-info

Breaking: the old names are removed, not kept as aliases.

Behaviour is otherwise unchanged. select's nearest: clause recognises
.emb.ann and .emb.knn; signatures and the texts of errors follow.
norm is linear algebra and keeps its global name beside mmu, lsq, inv,
flip and gram.

Docs: a reference page for the namespace, listed in the namespace index;
every mention of the old names updated.
…iled kernel (#1619)

mmu and gram computed every product and sum in double, whatever they
were given: F32 rows were widened element by element and the result
narrowed at the end. They now compute in the operands' own precision.

- F32 operands multiply and sum in float, eight to a register where
  there were four; the result is written as F32 directly.
- Matrix by matrix runs on a tiled kernel: four rows of the right
  operand are added at a time into a tile of 256 columns that stays
  in L1. Both element types use it.
- The right operand is copied into one block first: its rows are
  vectors of their own, and rows of one size fall on the same cache
  sets.
- gram's 4x4 tile holds its sums as vectors of the rows' own type.

inv and lsq still solve in double.

Behaviour: an F32 result of mmu or gram now has single-precision sums
(about 2e-5 from the double product on values of magnitude ten, where
it was 2e-6). F64 and mixed operands are unchanged.

One worker on one core, fastest of 400 runs, the two binaries in turn
(ms, before -> after): F32 128x384 by 384x384 1.60 -> 0.68; by 384x1536
7.51 -> 2.99; 128x1536 by 1536x384 7.62 -> 3.46; F64 1.77 -> 1.31,
11.67 -> 5.64, 13.96 -> 14.06; gram F32 5.58 -> 3.45, F64 6.32 -> 6.25.
The release binary grows by 8.3 KB.

Tests: the tiled path on shapes that are no multiple of its tile or of
its four rows, against the other kernel and against the product in
double; gram against mmu with flip; a null in an F32 row. Docs say
which precision each linear-algebra builtin computes in.
…get and set (#1622)

#1618 gathered the vector functions under .emb.* but kept the index's
names hyphenated and its disk verbs as save and load. The engine's own
pattern is a dotted sub-namespace and get/set with the path first, as
.db.splayed.get and .db.splayed.set have it:

  .emb.hnsw-build -> .emb.hnsw.build
  .emb.hnsw-load  -> .emb.hnsw.get
  .emb.hnsw-save  -> .emb.hnsw.set
  .emb.hnsw-info  -> .emb.hnsw.info
  .emb.hnsw-free  -> .emb.hnsw.free

Breaking, like the first rename; nothing was released in between.
.emb.hnsw.set takes the path first: (.emb.hnsw.set "dir" idx).
Access flags are unchanged: get, set and free stay restricted.

The distances and the searches keep their names. Tests and docs follow.
## What

A text-embedding model runs inside the engine. Four functions join `.emb.*`:

| Function | |
|---|---|
| `(.emb.model.get dir)` | opens a model as it is published: `config.json`, `tokenizer.json`, `model.safetensors`; returns a handle |
| `(.emb.model.info m)` | `{kind tokenizer vocab dim layers heads inner tokens}` |
| `(.emb.tokens m text)` | the token ids of a text (I32), or a list of them for a vector of strings |
| `(.emb.encode m text [max-tokens])` | the vector of a text (F32, length one), or a list of them, computed on the worker pool |

```lisp
(set m (.emb.model.get "models/my-encoder"))
(set t (table [text vec] (list docs (.emb.encode m docs))))
(select {from: t nearest: (.emb.knn vec (.emb.encode m "restart") 2)})
```

Nothing is linked and nothing is called: the three files are read with the engine's own JSON reader and file mapping, and the arithmetic is the kernels `mmu` and `gram` have. The weights are mapped and never copied: every tensor is used where the file has it.

## How

- `src/store/embtok.h`, `embextend.h`: a Unigram tokenizer: normalization through the model's table of replacements, the likeliest cut by Viterbi, the begin and end marks.
- `src/store/embmodel.{h,c}`: the model. `model.safetensors` is mapped and every tensor is a pointer into the mapping; the model owns the tokenizer and an array of pointers, nothing else. The forward pass is the BERT one: query, key and value, attention head by head, GELU by erf, mean over tokens, length one. `exp` and `erf` are polynomial forms the compiler vectorizes.
- The handle is a new kind beside the index and the graph (`RAY_ATTR_EMBMODEL` on an I64 atom). A model never changes, so a copy of the handle shares it by count and there is no function to free it.
- `src/ops/linalg.c`:
  - `ray_lin_rowdot_acc_f32`, rows against rows: a product with the right matrix on its side, `[out x in]`, which is how the file holds a layer's weights, so no weight is turned or copied. Its tile is two rows by four: eight sums, which fit the sixteen registers of AVX2 where the four-by-four tile of `gram` spills.
  - `ray_lin_gemm_acc_f32`, the tiled F32 kernel of `mmu` for callers that hold rows already (attention's weights times the values).
  - the tiled kernel takes four rows of the left matrix against four of the right, so a row of the right is read once for sixteen products; the expression for each element is unchanged, and the parallel split of `mmu` is at multiples of four rows so that a row is computed one way whatever the number of workers.
- The pool is used either way: many texts go to the workers whole; one text, or fewer texts than workers, is computed by all the workers together (rows of each product, heads of attention).
- A computation that is interrupted returns `cancel`, never vectors that were not computed.

Only `"model_type": "bert"` with a Unigram tokenizer and F32 weights is read; anything else is refused by name.

## Measured

Against the reference implementation of a published multilingual encoder (12 layers, 384 dimensions, vocabulary of 250,002), outside the tree:

- tokens: 36,215 of 36,215 texts give identical ids (7.9 million tokens);
- vectors: 400 texts at random, cut to 256 tokens: the largest difference in one component is 2.4e-7, cosine distance at most 1.1e-12.

On a machine that was busy throughout (8 performance and 12 efficiency cores, AVX2), so the figures are rough; each is the fastest of repeated single runs:

| one text | 1 worker | 8 workers |
|---|---|---|
| 256 tokens | 148 ms | 41 ms |
| 22 tokens | 12.7 ms | 5.8 ms |

400 texts (57,820 tokens) on 8 workers: 6.7 s. The model opens in 0.16 s with a peak of 114 MB resident; the 470 MB of weights are paged in as texts need them.

`mmu` with the four-by-four block, one worker, before and after: F32 256x384 by 384x1152 4.7 to 3.2 ms; F32 512 cubed 4.7 to 3.8 ms; F64 512 cubed 12.1 to 7.4 ms.

## Tests

`test/rfl/embedding/model.rfl` opens `test/data/emb/tiny`, an encoder of two layers and eight dimensions written by `scripts/emb-tiny-model.py`, which also computes the expected vectors with the standard library alone, apart from the engine's arithmetic. It covers the cut of text, the vectors, both truncations, a batch of 600 and a batch of 3 against each text alone, a `nearest:` query over the vectors, the handle outliving its first name, and what is refused.

Not covered in the tree: the tokenizer's table of replacements (the tiny model has none); it is covered by the 36,215 texts above only.

The full suite under the sanitizers: 7225 of 7231 pass, 4 skipped; the two that fail (`rfl/type/as_atom_vector`, `rfl/query/as_column_types`) stop on a signed overflow at `src/ops/builtins.c:1041`, a file this change does not touch.

## Docs

`docs/docs/namespaces/emb.md` (a section and four entries), `reference/all-functions.md`, `language/functions.md` (the handle stays boxed under `map`), `README.md`; `mkdocs build --strict` passes.
DATE -> TIMESTAMP multiplied the day count by the nanoseconds per day
unchecked. In the vector cast (cast_range_worker) the null date,
INT32_MIN, overflowed int64: undefined behaviour that UBSan reports in
`make test-ndebug` (as_atom_vector, as_column_types). Its slot was
patched to 0Np only afterwards. Any date outside about 1708 to 2292
overflowed the same way in both the vector cast and the atom cast,
which wrapped to an unrelated timestamp (200000 days gave a negative
one).

Both casts now go through date_to_ts_ns: the null date is the null
timestamp, and a date whose nanoseconds do not fit saturates to
INT64_MAX or INT64_MIN + 1 (never the null), as temporal_as_ns already
does when it compares a date with a timestamp. The other temporal
widenings do not multiply by more than int32 can carry (TIME -> TIMESPAN
is ms * 1e6) or are relabels, so they are unchanged.

test/rfl/type/cast_date_timestamp_null.rfl covers the null and
out-of-range dates as a vector, as atoms and through the parallel cast.
The data-types cast table and the types guide state the null and
saturation behaviour.

Fixes #1597
…rs stop at the thread's stack reserve

#1546 made the compiler stop at the thread's stack reserve. Other
recursion that the input's depth drives still relied on a fixed level
count, or had none, and overflowed the C stack where a level costs more
than the count assumed (an unoptimized sanitizer build) or the thread's
stack is smaller than the main one:

- the interpreter (eval_impl, 512 levels): an ASan build overflowed a
  512 KB or 1 MB thread stack on a 500-level body;
- a compiled body re-entered from a builtin that calls it back (map,
  fold, a sort key): calls between compiled bodies use the VM's own
  stack, but each builtin callback opens a new vm_exec_rows frame on
  the C stack (4.6 KB at -O3, 63 KB under ASan at -O0) and nothing
  counted them. A release build crashed (SIGSEGV) at 5000 levels on the
  8 MB main stack, and at 300 on a 512 KB or 1 MB thread;
- the parser (1024), the JSON reader and writer (1024), read-value
  (1024) and deserialisation (512): ASan overflowed small threads, and
  the main stack too for the parser.

The per-thread floor that #1546 kept in the compiler is now
ray_stack_short() in the platform layer, and each of these walks checks
it next to its count, failing with the error it already gives at the
count: limit "eval depth exceeded", limit "stack overflow" for the VM's
re-entry, parse, limit for JSON and read-value, domain for
deserialisation. The counts are unchanged. The reserve is a sixteenth of
the stack, between 64 KB and 512 KB, as before. In a sanitizer build it
is an eighth, between 256 KB and 1 MB, because one level of the VM's
re-entry needs over 100 KB there and must fit between two checks.
ray_stack_short() is out of line. The evaluator and the parser call it
every fourth level, as one unlikely branch next to their count, since
four of their levels are far below the reserve in any build. The
compiler, the VM's re-entry and the readers call it at every level.
Release build, best of five, five alternating runs (macOS arm64):
`(sum (map h (til 1000000)))` 105.9 ms on dev and 106.2 ms now;
200,000 `(eval e)` of a 6-level expression 75.9 ms and 74.2 ms; 20,000
parses of it 11.96 ms and 12.17 ms.

Walks that recurse on a value's depth with no count and no error path
(format, ser, equality and hashing of nested lists) still crash on a
deep enough value, in release too. That needs a design decision and is
#1591.

Tests:
- lang/stack_guard_small_thread runs each path on a 256 KB thread with
  its own VM: a 500-level interpreted body, a compiled body recursing
  300 deep through map, 1000-deep parse, .json.parse and read-value
  input, and .json.format and de of a 500-deep list. Each must give its
  value or its clean error. On dev the -O1 test binary dies with a bus
  error and ASan reports a stack overflow. Removing any one guard in the
  ASan build overflows at that site, except the VM's, which the
  evaluator's check catches there.
- rfl/lang/stack_depth: a compiled body recursing 100000 deep through
  map on the main stack gives limit, and the body is usable after it.
  On dev, and with only the VM's guard removed, the -O1 test binary
  segfaults.

Docs: the parser's nesting note and the closure paragraph of the syntax
page, and the depth limit rows of the JSON and read-value pages.

Linux review (#1590): on glibc a thread's static TLS (about 87 KB) sits at
the top of the stack block pthread_getattr_np reports, so a 256 KB thread
started below its reserve under ASan and lang/stack_guard_small_thread
failed in make test-full. The reserve is now sized on the stack left
below the frame that first reads it, and the test keeps its VM on the
heap. The first read is noinline and cold, so the check's fast path has
no frame of its own. A count of compiled bodies open on the stack
(vm_reentry, at most 10,000) backs the stack check where the platform
gives no bound: under `ulimit -s unlimited` recursion through map now
ends with limit instead of growing until memory runs out.

Fixes #1590
upsert matched keys by two inconsistent rules, the same on in-memory and
splayed tables (#1152):

- A null key matched an existing null-keyed row for I16, I32, I64,
  TIMESTAMP, TIMESPAN, GUID, SYM and STR keys, but never for DATE, TIME,
  F32 and F64 keys, so each upsert of such a null appended another row.
  A DATE / TIME null atom keeps its sentinel in the low 32 bits only, and
  the atom was read as int64, so it never equalled the widened cell; F32
  and F64 compared NaN with ==.  A null of another type (0Nh against an
  I64 key, 0Nl against a DATE key) missed the same way.
- An integer key value the key column cannot hold (65537 against an I16
  key, 257 against a U8 key) was compared widened, missed, and was then
  narrowed on append, leaving two rows with one key.

The key atom is now compared with what the key column stores for it
(upsert_atom_key): a null of any type is the column's null, and an
integer is read at its own width.  F32 / F64 keys compare by value with
one exception, a null (NaN) equals a null, and a NaN hashes as the one
null on the hashed path.  upsert_key_check raises a domain error for a
U8, I16 or I32 key value outside the column's range, the I16 / I32 null
bit pattern included, before anything is written.  One rule serves the
keyed map, the scan, the hash-index probe (a null key goes to the scan),
the column-wise batch path and the splayed match scan, for single and
compound keys.

Changed answers versus dev:

- null DATE, TIME, F32 or F64 key against a table holding a null key of
  that type: appended a row, now updates the null-keyed row (atom, typed
  key vector, boxed list and table payloads; in memory and splayed;
  single and compound keys). A repeated null inside one batch now lands
  once.
- a null of another type as the key (0Nh or 0Ni against I64, 0Nl
  against I32, DATE or F64): appended, now matches the null-keyed row.
- a null against a BOOL or U8 key (stored as 0): appended a second 0
  row, now matches the 0 row.
- an F32 atom against a splayed F64 key: never matched (the atom was
  read as an integer), now matches by value as in memory.
- a U8, I16 or I32 key value out of the column's range (257 or -1 into
  U8, 65537 into I16, 4294967297 into I32), as an atom or inside a key
  vector, list or table payload: appended a narrowed duplicate, now a
  domain error and the table is unchanged, the rest of the batch
  included.
- -32768 against an I16 key, -2147483648 against an I32 key: matched or
  stored the null, now a domain error.

Tests: test/rfl/table/upsert_key_match.rfl pins every case above; on dev
it fails at its first null-key check ("expected 2, got 3").
upsert_f32.rfl, upsert_keys_splayed.rfl and upsert_vector.rfl pinned the
old "a null float key always appends" answer and now pin the new rule.

Docs: the key-matching rule in language/functions.md (Query Operations),
a Key Matching section under Upsert in queries/select.md, and the upsert
row of reference/all-functions.md.

Fixes #1152
A live IPC request marks each argument list with the literal-fallback mark
(RAY_EVAL_LITERAL_FALLBACK): an argument list whose head does not resolve,
or names a global that is not a function, evaluates to itself, so the
handler receives it as data. Journal replay (.log.replay, .log.replay_report
and the -l/-L startup recovery) evaluated the journaled frame without that
mark. A data list whose head named a bound global was then called during
replay, and replay rebuilt a different state from the live one. With
`a` bound to 42 and `upd` appending its argument to `state`:

    live  : [['a 1 s] ['zz 1 2] false]
    replay: [false]        ; chunk 0 raised type, chunk 1 raised name

Fix: the marking moves into ray_ipc_mark_request_args (src/core/ipc.c), which
the live request and journal_replay_from (src/store/journal.c) both call. A
SYNC frame is an IPC request journaled as it arrived, so replay marks its
arguments; a .log.write entry is an ASYNC frame and is evaluated as written.
Live behaviour does not change: as decided on #1006, a head that resolves to
a function is still called (`(in 1 2)` gives false live and on replay).

What replay does, unchanged by this commit: it evaluates the journaled
message directly. An installed .ipc.on.sync hook ran the request live but is
not run on replay, so the hook's own side effects are not replayed.

Behaviour change for existing journals. The journal format is unchanged, but
a journal written by an earlier build now recovers to a different state:
the state the live server had. With `a` bound to 42, the requests
`(upd (zz 1 2))`, `(upd (a 1 "s"))` and `(upd (in 1 2))` left the live state
at `((zz 1 2) (a 1 "s") false)`. An earlier build replays them to `(false)`,
raising name and type on the first two; this build replays them to the live
state. A journal written by this build and replayed by an earlier one still
gives `(false)`.

Tests:
- ipc/journal_replay_literal_args sends three requests to a journaled
  server: a head bound to a global that is not a function, an unbound head,
  and a head naming a builtin. It recovers the journal by reopening it (the
  -l path) and replays it with .log.replay. Each replayed state must equal
  the live one. Without the fix, replay gives `(list false)`.
- ipc/journal_replay_skips_sync_hook runs the same requests through a
  .ipc.on.sync hook that counts its calls and evaluates the message. The
  hook runs three times live and not at all on either replay route, and the
  replayed state still equals the live one.

Docs: namespaces/log.md, .log.replay. It says what replay does, that the
sync hook is not run on replay, and that older journals now recover to the
live state.

Fixes #1006
…oduct

A keyless select whose where: keeps no row runs as one group of zero
rows. emit_agg_columns treated that group like an all-null one and
emitted the null for prod (0Nl, 0Nf), while the evaluator fallback,
taken when another output is declined, gave 1, as does the builtin
`(prod (as 'I64 []))`. The answer for one output depended on what else
the select asked for.

A group with no row now emits the empty product (1, or 1.0 for a float
output) on both the integer and the float branch. A group whose rows
are all null keeps the null that the planned route gives today; that
mismatch with the builtin and the fallback is reported on the issue and
left unchanged here. The other aggregates' empty-selection results
already agree on both routes (sum 0, count 0, the rest null).

free_vector_matrix_exceptions.rfl had pinned the null for the same shape
over a free vector (`(prod W)` with W [7] or [0Nl] under a where: that
keeps no row, where `(sum W)` gives 0); both lines now expect 1.

test/rfl/query/prod_empty_where.rfl covers I64, F64, I32, F32 and I16
on both routes, beside other outputs, and over a source large enough
for the parallel selection. The prod reference states the empty
product.

Fixes #1577
A list can be nested arbitrarily deep at run time, e.g.
(times n (set L (list L))), and many walks over values recursed once per
level with no count and no error path. A release build crashed with
SIGSEGV on 1,000,000 levels in format, show, repr, println, ser, the
element-wise ops (==, !=, <, +, neg, not), in, as, distinct, group,
except, union and find, and in saving a list column. The planner crashed
on a query expression built that deep and passed to select through eval.
A restricted (-U) client could do this with let and times: replying with
a 1,000,000-deep value, or comparing two 60,000-deep ones, killed a
release server.

Each walk now either works without recursing on depth, or stops with a
clean error:

- Exact at any depth, no error path needed: atom_eq compares two lists on
  an explicit stack (list_eq), so distinct, group, except, union and find
  answer as before at any depth. The key walks (key_hash, key_span_flags,
  key_inexact_bits, ray_key_float_free) stop descending past 128 levels
  and give their conservative answer: every flag set, a hash of the
  list's length alone. The bound is a depth, not the stack, so equal
  values still hash alike wherever they are hashed, and atom_eq decides.
  ray_retained_bytes (the C API's footprint walk) sums on an explicit
  stack.
- A limit error at the thread's stack reserve (ray_stack_short, #1590),
  for walks whose result can be an error: format and the REPL
  pretty-printer (fmt_obj, fmt_pp), atomic_map_unary and
  atomic_map_binary_op, not, as, in. println writes to a stream with no
  error to give, so it prints "..." for the part nested too deep.
- A fixed depth, user-visible: ser, an IPC reply, the journal and saving
  a list column refuse a value nested deeper than 512 levels (limit).
  That is the depth de reads, counted the same way, so whatever ser
  writes, de reads back; before this, ser wrote frames de refused. A
  query whose expressions nest deeper than 1024 levels, the deepest text
  the parser reads, is refused by select, window, update and delete
  (ray_nests_deeper_than measures it without recursing), so no planner
  walk meets one.

Building and freeing a deep value were already fine, as were copy, raze,
reverse, concat and the JSON writer (capped).

A restricted client after this: it can still build a value as deep as it
likes within memory, and compute with it. A reply with it gets a limit
error (serialize: value nested deeper than 512 levels). Formatting or
comparing it gives a value, or a limit error once the server thread's
stack reserve is reached. A deep query gives limit. The server stays
up and answers the next request.

Cost (release, one core, best of three): ser of a list of 1,000,000
two-element lists 20 ms to 23 ms (the containers are counted; atoms and
vectors are not); ser of a 10M-element vector, == on a 100,000-element
list and distinct of a 1,000,000-element list unchanged.

Tests:
- rfl/lang/deep_values: every walk above at 60,000 and 1,000,000 levels
  gives a value or limit; distinct, group, except and union give exact
  counts at both depths; ser refuses both; 511 lists round-trip through
  ser and de, 512 give limit.
- rfl/system/deep_value_restricted: against a -U server, the 70-byte
  reply message gives limit, format and == give a value or limit, a
  1,000,000-deep reply gives limit, and the server answers (+ 1 2) after
  each. On the parent commit a release server dies with SIGSEGV on the
  1,000,000-deep reply and on == of two 60,000-deep values.

Docs: the collections page (deeply nested lists), the IPC page's ser
section and limitations, and the ser rows of the function tables.

Review (#1591): nesting through dicts and tables still recursed. atom_eq's
dict and table branches went back through atom_eq per level, so distinct,
group, in, except, union and find crashed on dicts nested in dicts, on
lists and dicts alternating, and on tables held in their own list cells,
on pool threads too; identical recursed with no guard on lists, dicts and
tables; ray_atom_hash recursed through all three. Now:
- atom_eq compares any two lists, dicts or tables on one explicit stack
  (container_eq, which replaces list_eq): a list frame walks its cells, a
  table pushes its column pairs and a dict its key and value pairs,
  compared as cells as atom_eq_cell_col compares them; answers are exact
  at any depth and on any thread;
- ray_atom_hash stops descending past 128 levels, as the key walks do (a
  container then hashes by type and length);
- identical stops with limit at the thread's stack reserve.
A sweep of the walks over values (30 expressions over 1,000,000-deep lists
and dicts, 500,000-deep list/dict alternation and 100,000-deep
self-nesting tables, on the main thread and in pmap, release and
ASan+UBSan) finds no crash. Saving a list column nested too deep now says
why ("save: list column nested deeper than 512 levels").

Tests added: in rfl/lang/deep_values, distinct/group/in/except/union/find
over deep dicts, the alternating shape and self-nesting tables, on the main
thread and in pmap, identical over deep lists, dicts and tables (main and
pmap), and the save's message; in rfl/system/deep_value_restricted, the
four ways a -U client still killed a server (identical of deep lists,
distinct of deep dicts, in over the alternating shape, group of
self-nesting tables). On the previous head the server dies on the first
and deep_values segfaults.

Cost (#1591): flat keys cost no more than before the explicit stack.
atom_eq is one body with two instances. Its list, table and dict cases
compare a flat value in place, as before; a list's cells go to the
second instance, whose container cases hand the pair to container_eq.
The cell's own type switch routes it, so a flat cell pays no extra test
and the C stack holds a few frames however deep the value. The key
walks (span flags, float check, atom hash) decide a dict's keys and
values, a table's columns and a list's atom cells without a call, and
recurse only into a list, dict or table. User-space instructions per
operation over 1M rows (gcc release, one core), parent 3b8064d -> this:
group/distinct/by: over two-element lists -7.4/-4.2/-5.4%, over
two-key dicts -5.1/-2.4/-0.8%; the I64 control unchanged.

Fixes #1591
…p partition pruning (#1604)

A select over a parted table whose where: compares a timestamp column
skips the partitions that column's statistics rule out, provided every
other conjunct and every output reads only the rows the where keeps.
The gate that decides this (prune_where_elementwise_impl) admits calls
flagged ATOMIC and a few named forms. These row-local spellings carry
no ATOMIC flag, so the same select read every partition:

- (like t "a*"), in where: or in a column;
- (nil? v), and in where: (not (nil? v)) and (not (in s ['y]));
- (== s (quote x)), the spelling for a symbol named like a column;
- (as 'GUID "…") beside a GUID column in ==, != or an or of ==, and
  (as 'GUID (list "…" "…")) as the set of an in.

Each answers a value per row: like with a constant pattern string (a
literal or a name bound to one), nil?, and not over an in with a
constant set or over nil?. (quote x) is always the symbol, even when a
column is named x. A cast whose operands are literals is one constant
whatever the source; as an operand it must be a cast of an atom, since
a vector's length would meet the row count, while an in's set may be a
cast of a list. A type name or quoted symbol that names a column of the
source is not a literal and stays declined, as does any spelling rebound
to another function. So the stand-in row of a skipped partition still
fails the where by the timestamp comparison, and every answer is the
one without pruning. The partition mask is unchanged: none of these
spellings narrows it.

On the issue's two-partition fixture, where the first partition's ts
data is overwritten with the second's so a read of it shows in the
count, (like t "a*") gives [23334] instead of [46668], (not (in s ['y]))
[46667] instead of [93334], (not (nil? v)) [70000] instead of [140000],
the GUID cast and (quote x) [23334] instead of [46668].

Not changed, each for its own reason (see #1604): an if holding a
string, a grouped sum(if) beside a timestamp comparison, and a by: key
computing an if.

Test: test/rfl/system/part_prune_rowlocal.rfl, the issue's fixture for
every spelling above, the declined spellings, and each answer against
the same select with pruning off on an untouched root.

Docs: the pruning section of the storage page lists the spellings.

Part of #1604
…rtition pruning (#1604)

A select over a parted table whose where: compares a timestamp column
skips the partitions that column's statistics rule out. A grouped
sum(if) has its own bounded proof (prune_group_shape_ok), whose where:
grammar (prune_group_cond) admitted same-type I64, F64 and DATE
comparisons. TIMESTAMP was missing, so this read every partition:

    (select {c: (sum (if (== s 'x) 1 0)) by: s from: P where: (>= ts 2026.01.06D00:00:00.000)})

while (sum v) by the same key, which the ordinary proof admits, skipped.

TIMESTAMP is now admitted beside DATE: a comparison of a timestamp
column (or a timestamp partition key) with a timestamp value. Like an
I64 one, it orders a null below every value on the filter's routes as
in the statistics, so the stand-in row of a skipped partition fails it.
A date literal against a timestamp column is still declined, as before.

On the issue's two-partition fixture, where the first partition's ts
data is overwritten with the second's so a read of it shows in the
count, the select above gives 23334 instead of 46668, and a sum(if) by
an I64 key 9 instead of 18.

Test: test/rfl/system/part_prune_grouped_ts.rfl, the fixture for a SYM
key, an I64 key, other aggregates beside the sum(if) and an extra where:
conjunct, and eight selects against the same select with pruning off on
a compressed root with null timestamps. It fails without the change
(46668 for 23334). compress/select_parted_prunes_grouped_if_ts_key
checks a table partitioned by a TIMESTAMP key, plain and compressed:
the key compared with a timestamp prunes (the test counter), a date
literal against it stays declined, and every answer equals the one with
pruning off; without the change its first case is not pruned.

Docs: the grouped bullet of the storage page's pruning section.

Part of #1604
A where: (== c k) or (in c set) on a column of a partitioned table never
consulted the hash each partition saved for its column.  idx_filter_decode
and idx_filter_in_decode declined parted columns, so every remaining
segment was scanned and .idx.uses reported nothing.

The filter now decodes EQ and IN of a parted default-table column first.
After partition pruning, each non-empty segment is answered by its own
index with the unparted probes: an attached HASH or PART, a generation-2
segment's recorded HASH probed where it is mapped (integer, SYM and STR),
or a generation-2 GUID segment materialized for its hash, as unparted.
Every probe checks its index against the segment, so a stale or
mismatched one declines exactly as on an unparted column.  A segment no
index answers is matched row by row, read by range as the scan reads it
(generation 2 a vector at a time, never materialized), when no needle is
null.  The segments' rows are joined into one selection in row order.
The whole filter falls back to the scan when no segment has a usable
index, a segment is missing (ragged), a needle is null on a segment that
must be scanned, or the column is float.

.idx.uses sums the uses noted on each segment's own index, and a use is
noted only when the whole route answered.

On two 100k-row partitions with saved hashes, (== id k) goes from 0.068
to 0.007 ms and (== s "k") from 2.71 to 0.007 ms; a where: with no index
is unchanged.

Fixes #1422
…or carries its own

An error object held only its code. Its message lived in the thread's
last-error buffer, and serialization read that buffer for every error
record. A list holding several errors was therefore written with the
last-raised message in every record, over ser/de, IPC and the journal. An
error made on a worker thread and serialized on another thread carried the
reading thread's message. A `try` handler, the REPL and the timer printer
also showed whatever was raised last, not the caught error's text.

The error now owns its message. ray_error formats into the thread buffer,
as before, then copies the text (at most 255 bytes) into the error's own
block, after the header. Its length is kept in the header's aux bytes,
which an error did not use. The message lives and is freed with the error
by ray_error_free, on any thread: it is part of the block, so it needs no
reference counting of its own, and a cross-heap free goes through the
usual path. An error without a message is still a 32-byte block. When the
heap cannot hold the bigger block, the error is made without a message,
and only after that does ray_error fall back to the static OOM error.

Serialization writes each error's own message, so the size and write
passes agree by construction. The ray_serde_msg_hold/release pair that
kept them consistent is removed. The wire format is unchanged: a v4
error record is still category[8], a length byte and up to 255 bytes.

The readers that have the error at hand read its own message: `try` (both
engines), the REPL error line, the timer's error line, the format
column-load cause, builtin-usage noting, the parted, splayed and encoded
column loaders, parquet's per-file prefix, and read-value. `raise x` makes
an error without a message. The IPC server used to render x into the
thread buffer through a throwaway error. It now replaces the reply's
error with one that owns the rendered text.

C API (include/rayforce.h):
- new: const char* ray_err_msg(ray_t* err), the error's own message.
  It is NULL for no message, a non-error, and RAY_OOM_OBJ.
- removed: ray_error_msg_set. It rewrote the thread buffer "in place"
  and nothing called it. An error's message is fixed when the error is
  made.
- ray_error_msg() keeps its meaning: the last message made on the
  calling thread.
- RAY_ERROR objects use a new union member, err_msg_len (aux bytes 0-1).
  The per-VM err.msg copy, which was written on every raise and never
  read, is removed.

The cost of raising stays about the same. The 256-byte copy into the VM
slot is gone, and a copy of the message's own length into the error's
block replaces it. Counted with callgrind over 100k
`(try (+ 1 'a) 1)` iterations: +6 instructions per raise with a message
(1331 to 1337), +1 per raise without one.

Changed answers versus dev, all toward the error's own text:
- `(update {r: (+ d 1) s: (nil? r) from: A})`: an update output does not
  see a sibling output. The handler's msg was "'r' undefined", the text
  of a later name error, beside the schema code. It is now
  "column 'r' not found", the schema error's own message, which `select`
  already gives for a name no column has. temporal_int_arith.rfl is
  updated.
- An update output naming any non-column, by the same mechanism:
  `(update {x: (+ nosuch 1) from: t})`, with or without `by:`, also
  after an output the planner declined. The schema error's message was
  "'nosuch' undefined" and is now "column 'nosuch' not found". The code
  is still schema. The update_fallback_semantics.rfl lines that pin
  these (70, 78, 79, 81, 83) check the code only, so they are unchanged.
- RAY_OOM_OBJ serializes with an empty message. It used to carry the
  thread's last text.

Decoding is unchanged: a LIST stops at its first error cell and answers
with it. That error now has its own message where dev gave the last one.

Tests: store/serde_error_list_own_messages (the bytes of every error
record of a three-error list, the decoded first error, an earlier error
after a later raise, no message), store/journal_error_list_own_messages
(the .log.write frame), ipc/error_list_own_messages (the client's frame
as a peer reads it), store/worker_error_own_messages (16 errors raised on
pool workers read, serialized and freed on the main thread).
store/serde_error_msg_held now pins that a later error changes neither
the size nor the record. All four new tests fail on dev, every record
carrying "third" or the reading thread's message.

Docs: c-api/core.md (ray_error ownership, ray_err_code / ray_err_msg),
storage/ipc.md (each record's own message), architecture/memory.md.

Fixes #1214
A list that arrives as an IPC request argument carries the literal-fallback
mark (RAY_EVAL_LITERAL_FALLBACK). Its head does not resolve, or names a
global that is not a function, so the list evaluates to itself and the
handler receives it as data. A handler that stores the list stores the
mark with it, as decided on #1006, and evaluating the stored list later
gives it back. Log recovery keeps this since #1006: replay marks the
arguments as the live request did. A journal snapshot did not. The mark
is a bit in attrs that the serializer never wrote, so after recovery from
`<base>.qdb` the stored list was evaluated as a call. With `a` bound to 42
and `keep` appending its argument to `S2`, after the request
`(keep (a 1 2))`, `(eval (first S2))` gives:

    live                     : ['a 1 2]
    after log recovery       : ['a 1 2]
    after snapshot recovery  : type "head is not callable, got i64"

Fix: the snapshot writes the mark and recovery reads it. It uses the
switch that already carries a lambda's .sys.trust mark into the snapshot
and nowhere else. That switch is renamed from ray_serde_keep_trust to
ray_serde_keep_marks, since it now covers both marks. While it is on, a
LIST record's attr byte carries the bit, the same bit as in memory, and
the decoder restores it. The bit is outside RAY_SERDE_ATTR_WIRE_MASK (a
static assert pins that), so:
- ser/de, IPC and journal entries never carry it, and a frame that does
  marks nothing when read with the switch off;
- a reader that predates this change drops the bit and recovers as
  before.
The wire version does not change.

Behaviour change for existing snapshots: none on load. A snapshot written
by an earlier build never held the mark, so it still recovers such a list
unmarked; a new snapshot keeps it. Live behaviour does not change.

Stacked on the #1006 commit (fix/1006-replay-literal-fallback), which
was not yet on dev when this was written.

Tests:
- ipc/journal_snapshot_literal_args. A journaled server stores two
  request arguments, one flat and one nested. Live, a snapshot is taken,
  then the journal is reopened: the -l recovery path, which loads the
  snapshot. Evaluating the stored lists must give the live answer. Before
  the fix both raised "head is not callable, got i64".
- journal/serde_keeps_literal_mark. The mark on a list and on a nested
  list round-trips only while ray_serde_keep_marks is on. It is dropped
  when written with the switch off, and when read with it off. The bytes
  are the same length either way.
Reverting the two serde hunks fails both.

Docs: namespaces/log.md, .log.snapshot. It says the snapshot keeps the
mark, gives the example, and describes snapshots from earlier builds.

Fixes #1609
Rayfall had no way to pause: a script that drives a server over IPC
(enable a profiler, wait, read it back) or a test driver that polls a
condition had to leave the language and wait in the calling shell, or
start a `sleep` subprocess through .sys.exec.

(.time.sleep ms) blocks the calling thread and returns null.

- ms is an integer atom of any width (u8, i16, i32, i64) in
  milliseconds, or a timespan, which is the duration itself rounded up
  to the next whole millisecond.  0 returns at once.
- A negative or null duration is a domain error; anything else (a
  float, bool, string, symbol, date, time, timestamp, vector, list or
  dict) is a type error.
- The deadline is kept in nanoseconds of the monotonic clock
  (ray_time_now_ns, new beside ray_time_now_ms), so it never wakes
  early.  A duration past the clock's range waits until cancelled.
- The wait is cut into slices of at most 10 ms and checks
  ray_interrupted() after each, the flag the REPL's Ctrl-C handler and
  a client's IPC cancel raise and long-running builtins poll, so a
  cancel ends it within about 10 ms with a `cancel` error.  A script or
  piped session has no SIGINT handler, so Ctrl-C stops the process
  there, as it does for any long evaluation.  A Ctrl-C typed at a
  server's terminal does not reach a running request (the idle REPL
  keeps the terminal raw); `kill -INT` of a server with a terminal does.
- In a SYNC request it also ends when the requesting client hangs up
  (ray_ipc_request_peer_gone, over a new ray_sock_peer_closed probe of
  the request's socket): nobody waits for the answer any more.  Without
  this a sleep whose client was killed held the server for its whole
  length, and forever for an endless one.  A client that only shuts
  down its sending side reads the same and counts as hung up.
- In an ASYNC message the sleep runs its full time even after the
  sender has gone, since work posted behind it may rely on the delay;
  only a server-side interrupt ends it.  As nothing on the client side
  could ever end it, an async sleep too large for the clock is a domain
  error instead of a wait that never ends (ray_ipc_request_kind tells
  the two kinds apart).
- Under a journal replay it returns null at once
  (ray_journal_in_replay).  The journal logs a sync request before it
  runs, so a logged sleep was slept again on every restart, and an
  endless one kept the restarted server from ever listening.  A sleep
  changes no state, so skipping it changes nothing the replay restores.
- A client's cancel is honoured whenever it comes once its sync request
  has started.  The client looked at the interrupt flag only when a
  signal broke its wait for the reply, so a Ctrl-C that landed while the
  request was still being sent was lost until the deadline: the client
  now looks before each wait, and waits in slices of at most 50 ms so a
  signal that lands just before a wait is found by the next look.  On
  the server, a cancel byte that arrived between its first look and the
  running request being published is looked for again once it is.
- It holds no lock, but a server evaluates one request at a time, so
  while it sleeps the server's other connections, timers and hooks
  wait, as they do behind any long query.  It is restricted under -U,
  like .time.timer.set and .sys.exec, so only a full-privilege client
  can stall a server this way.  The docs say so and point to
  .time.timer.set for waiting inside a server.

Tests:
- test/rfl/system/time_sleep.rfl: the return value, a lower bound and
  a wide upper bound on the time slept for integers and timespans, and
  the domain and type errors.
- test/rfl/system/time_sleep_server.rfl: clients killed mid-sleep (a
  5 s and an endless sync sleep), each confirmed running by a probe
  that finds the server busy, then another client answered within
  2.5 s; replaying the log that holds the 5 s sleep takes under 2.5 s;
  a restart on the log that holds the endless sleep comes up with its
  state; a client that posts a stamp, a 1.5 s sleep and a stamp and
  exits gets stamps at least 1.5 s apart; an endless async sleep is
  refused and the work posted behind it runs at once.  It waits for the
  posted names to be bound before reading them: requests on different
  connections are served in no fixed order.
- lang/time_sleep_cancel: SIGUSR2 to the sleeping thread, whose handler
  raises the interrupt as the REPL's does, ends a 30 s sleep; a pending
  cancel ends a 0 ms one.
- lang/time_sleep_restricted: access under restricted mode.
- ipc/time_sleep_cancel: a signal on the client's thread makes the
  client send the cancel byte itself, as a terminal Ctrl-C does, once
  at once (before the client waits for the reply) and once 200 ms in;
  each ends the longest sleep on a spawned server, and the connection
  then answers the next request.  No second thread touches the handle
  or the interrupt flag, so the cancel tests are clean under TSan.
- The IPC test's spawned-server helpers are now built on every POSIX
  platform, not only Linux.

Docs: the .time namespace page (how each mode ends a sleep, the sync
and async rules on a server, that a sleeping server answers nobody,
replay, and the stall a sleep causes), the function
reference, the language functions table and the restricted-mode
summary.

Fixes #1489
…roduct

A keyless prod whose selected rows were all null gave the null (0Nl,
0Nf) on the planned route, while the evaluator fallback, taken when
another output is declined, gave 1 (1.0), as does the builtin
`(prod [0Nl 0Nl])`. The answer for one output depended on what else
the select asked for. It held with and without where:, on plain and
parted tables, serial and parallel.

emit_agg_columns now writes the empty product for a keyless prod with
no non-null row (1, or 1.0 for an F64 output). This also covers a
where: that keeps no row, which #1577 already answers with 1; the
check here comes first and #1577's zero-row branch stays for any
other caller. Under by:, a group whose rows are all null keeps its
null, as on dev and as the tests pin it.

Changed answers (planned route; the fallback already gave these):
- keyless (prod c) over selected rows that are all null: [0Nl] -> [1];
  F64 and F32 inputs: [0Nf] -> [1.0]; I32 and I16: [0Nl] -> [1]
- the same with no where: and every row null, e.g.
  (select {p: (prod v) from: (table [v] (list [0N 0N]))}): [0Nl] -> [1]

Re-pinned: grouped_agg_null_correctness.rfl (the scalar prod over
[0N 0N] is now 1), and free_vector_matrix_exceptions.rfl lines 877,
1193 and 1194 (keyless (prod W) selects with W [0Nl] and rows kept;
the by: lines keep [0Nl]; lines 720 and 878 are #1577's).

test/rfl/query/prod_keyless_all_null.rfl covers I64, F64, I32, F32 and
I16 on both routes, without where:, beside other outputs, the by: null,
and plain and parted sources large enough for the parallel scan. The
prod rows of the function tables and the select guide state the
keyless empty product and the by: null.

Stacked on #1577 (7789829, fix(group): keyless prod over a where:
keeping no row is the empty product).

Fixes #1613
A keyless select of aggregates over a table with no rows, with or
without where:, gave no row on the planned route. The evaluator
fallback, taken when another output is declined, gave one row, and so
does a where: that keeps no row of a non-empty table. The keyless
scalar route in exec_group_run was guarded by `nrows > 0`, so a 0-row
input fell through to the hash path, which found no group to emit.

The scalar route now takes a keyless select whatever its row count, and
emits the one row of the aggregates over no values. The per-partition
merge already dropped that row for a partition with no survivors when
the select groups on partition keys alone; it now drops it for a
partition that holds no rows too, so `by: part` over a parted table
with an empty partition still shows no group for it. A select with by:
over no rows still answers no row.

Changed answers (planned route; one row where there was none):
- keyless select over a 0-row table, with or without where:, for every
  aggregate: sum, count, all, any, min, max, avg, first, last, med,
  median, mode, dev, var, stddev, dev_pop, var_pop, stddev_pop,
  quantile, percentile, top, bot, prod. E.g. (sum c) [] -> [0],
  (count c) [] -> [0], (all c) [] -> [true], (any c) [] -> [false],
  (min c) [] -> [0Nl], (avg c) [] -> [0Nf], (quantile f 0.5) [] -> [0Nf],
  (first s) [] -> ['], (max d) [] -> [0Nd], (top c 2) [] -> [0],
  (prod c) [] -> [1]; each is the answer a
  where: keeping no row of a non-empty table already gives
- the same over a free vector, e.g. (select {s: (sum [1 2]) from:
  (take t 0)}) [] -> [0]
- a select over a nested source that came back empty, e.g.
  (select {from: (select {from: T where: (> x 9)}) s: (sum x)}) 0 rows
  -> 1 row
- parted: a where: on the partition key that prunes every partition,
  0 rows -> 1 row
The binary aggregates (cov, scov, wsum, wavg, pearson_corr) take
another route and answer no row over no rows, as over a where: keeping
none; they are unchanged.

Re-pinned: free_vector_matrix_exceptions.rfl (152 keyless select lines
over the empty table, [] or () -> the identity row, the 8 (prod W)
lines among them -> [1]; its header now says so), keyless_quantile_probability.rfl (9 lines, [] -> [0Nf]),
nested_select_merge.rfl (3 counts, 0 -> 1), width_matrix.rfl (2
counts, 0 -> 1), select_whole_column_projection.rfl (1 count, 0 -> 1).

test/rfl/query/keyless_empty_table.rfl compares each aggregate over an
empty table, with and without where:, with its answer over a where:
keeping no row, and covers several outputs, the fallback, by:, a
nested empty source, a pruned parted select, by: part with an empty
partition, and a source large enough for the parallel scan. The select
guide states the one-row answer and the by: none, and the offloading
page and the quantile note follow it.

Stacked on #1613 (keyless prod over rows that are all null), itself on
#1577 (7789829).

Fixes #1614
ser-vasilich and others added 22 commits November 28, 2026 22:47
…whole column (#1899)

A projection's (fill k x) had no DAG lowering, so the select ran it through
the per-row evaluator, one call a row: 425 ms over 2M rows against 2.5 ms
for the same fill outside a select.  An `if` that read the filled alias
fell to the per-row path with it.

(fill k x), k an atom of x's own type and x an I16, I32, I64, DATE, TIME,
TIMESTAMP or F64 column expression, now compiles to
OP_IF(OP_ISNULL(x), k, x), which is ray_fill_fn's answer row by row.  A k
of another type (which ray_fill_fn casts), a vector k, or any other column
type is left to the evaluator as before.

On the evaluator a column of the table, or an earlier output of the
select, named fill binds before the global, so the head is that value and
the call fails as "head is not callable".  The lowering declines when the
table has a column, or the select an earlier output, of that name, so the
same table gives the same answer either way.

The lowered (if (nil? x) k x) is not flagged as holding nulls it does not
hold: the if kernel flags its output when either side holds a null, and
the else side, x, does wherever the fill has anything to replace.  With a
non-null k none of x's nulls reach the output, so the else side's flag is
not carried over when the condition is nil? of the column the else side
scans.  A hand-written (if (nil? l) 7 l) gets the same.  A null k still
flags the output.

lang/eval/select_fill_dag_admission checks that a column named fill
declines the lowering, that a select with a column or an earlier output
named fill fails as with a declined fill, and that the lowered columns,
an (if (nil? l) 7 l) and a fill of an expression carry no null flag
while (fill 0N l) does.
… its contents (#1922)

println prints a dict with its contents ({a:1 b:2}) but a table only as its
dimensions, <table 3x2>, and nothing in the docs said so: println was "Print
values with newline", so a reader taking it for "print the value" had to
find show on their own.  That is how println prints a table, and it stays.

The println entry in the function reference now says a table prints as its
dimensions, that show prints its grid and that (format "%" t) gives its
contents, and links a new "Printing a table" note in the tables
documentation (data-types/collections.md), which shows the three forms on
one table with their output.  The entry's extra text is in sig.c's docs
comment, from which the reference rows are generated.  Every output shown
is the binary's.

Fixes #1919
…DELTA_BYTE_ARRAY pages (#1209)

Implements DELTA encoding support for the parquet reader:
DELTA_BINARY_PACKED for INT32/INT64 feeding the existing logical-type
conversions, plus DELTA_LENGTH_BYTE_ARRAY and DELTA_BYTE_ARRAY reusing the
integer-stream machinery.  The unsupported-encoding rejection stays for
combinations not implemented (BYTE_STREAM_SPLIT, and similar).

DELTA_BINARY_PACKED: block size multiple of 128, values-per-miniblock
multiple of 32, zigzag min-delta and first value, miniblocks read lazily,
unneeded trailing miniblocks accepted with arbitrary widths, bit widths 0
and 64, wraparound reconstruction in 32 or 64 bits.  INT32 streams (data
and byte-array length streams) are reconstructed in 64-bit arithmetic with
widths up to 64 and truncated to 32 bits, so writers that encode INT32
min-deltas outside int32 now decode; genuinely malformed streams still
refuse (widths above 64, truncated headers/varints/blocks, invalid block
layouts, count mismatches, negative lengths).

DELTA_LENGTH_BYTE_ARRAY and DELTA_BYTE_ARRAY: shared length-stream
machinery, previous string cursor-owned in the direct path, batch-owned
STR after `next` and `close`, partial skips decode-and-discard and advance
codec history, whole-page skips bypass, decoder state resets on every data
page including PLAIN/dictionary transitions.

NULL rows consume no DELTA value; the sentinel/empty/strict conversion
applies after physical reconstruction.

Page cap: a DELTA_BYTE_ARRAY page's reconstructed total is capped at
PQ_MAX_PAGE (64 MiB), the same bound PLAIN pages have.  A page that would
reconstruct past it is refused with `delta byte array page expands past
the 64 MiB page limit` before the expansion is allocated, on
`.parquet.read`, on `.parquet.splayed` SYM import (direct and grouped) and
on the discard path.  Repeated identical values (`prefix == previous
length`, empty suffix) reuse the previous arena offset instead of copying
again.

A hybrid dictionary-id stream whose final bit-packed run over-declares
fails with `excess dictionary indices` for every file, whoever wrote it,
and definition-level streams use the same strict rule.

Behaviour state: one refusal (the 64 MiB reconstructed-total cap), one cap
(the arena budget), one widening (INT32 DELTA streams that previously
refused now read); everything else is unchanged, and the differential
decode stays byte-identical.

Fixtures: 19 deterministic generated files in test/data/parquet/delta/
(regenerable byte-identically via gen-delta.py): DATA_PAGE_V1 and V2,
PLAIN/dictionary/DELTA transitions within one column, native and grouped
SYM imports, release-before-next sequences, the long repeated-prefix page,
and generator/page/encoding metadata in manifest.txt.  The generated files
carry neutral metadata: the footer's writer string is `external-writer
(version 26.0.1)` and the schema sidecar key is `schema:bytes`, both set by
the generator.  The fuzzer's committed seeds include one file of each
DELTA encoding: delta-dbp, delta-dlba and delta-dba.

Verification: differential decode against the unpatched reader at the dev
baseline: the shared fixtures are byte-identical, accepted and refused
alike.  Byte-level cross-checks against two independent reference readers
cover every new encoding at the batch seams.  DELTA-encoded UINT64 and
DECIMAL columns decode through the existing logical-type conversions.
Sixteen new DELTA test entries cover decode, bounds, import paths,
transitions, provenance, the arena floor and the staged-directory cleanup.

The reproducible import's seeding (pq_seed_read_values) decodes a
DELTA_BYTE_ARRAY symbol chunk with a column of its own; that column now
takes the arena's ceiling (pq_cursor_budget) and frees the DELTA buffers,
so such a chunk is seeded and its import keeps no memory.  Rebased onto
dev after #1917 and #1920: the new allocation failures answer the
reader's named out-of-memory messages, so they take the oom class.

Fixes #1188
…lds, not its spelling (#1923)

A query over .parquet.scan decided what it could stream, push down as a
row-group range, prefilter with like, or project by the spelling of each
call's head.  The name was looked up only to reject a lambda, so a
parameter or global spelled like a builtin but holding another function
was computed as the builtin of that spelling: a parameter `sum` holding
max streamed the sum (74 where plain evaluation answers 9), a parameter
`>` holding < pruned to the wrong rows (10 for 6), `and` holding or kept
4 rows of 18, `like` holding != 6 of 18.  An alias of a builtin, and a
column named like one, answered right but were refused every fast path.

Each head is now resolved as evaluation and the planner resolve it (a
parameter or let, else the global; the query's columns do not hide it)
and recognised by the native function it holds: the streamed aggregates
by the planner's own aggregate opcode (ray_query_agg_opcode), the
comparisons, and, within, like, let and the row-wise calls the
projection walks through by a table of functions.  A column named like
the head no longer disables projection; it is read as well.  The guard
for names recognised by spelling now covers src/io/parquet.c.

Fixes #1921
… stamp (#1925)

The DELTA fixtures under test/data/parquet/delta/ carry a neutral footer:
gen-delta.py rewrites the writer library's created_by stamp to
'external-writer (version ...)' and its schema metadata key to
'schema:bytes', in place and at the same length.  The three DELTA fuzz
seeds added with them, fuzz/seeds/parquet/delta-dba.parquet,
delta-dbp.parquet and delta-dlba.parquet, are copies of dba-v1,
dbp-i32-v1 and dlba-v1 taken before that step, so they still named the
writer.  test/data/parquet/nested.parquet named its writer in its
created_by stamp and in the schema root's name.

The seeds are now byte-identical to their neutral fixtures: gen-delta.py's
neutralise() run on the old seeds gives exactly those bytes, so only the
two footer strings change, and the fuzzer starts from the same
DELTA_BYTE_ARRAY, DELTA_BINARY_PACKED and DELTA_LENGTH_BYTE_ARRAY pages.
nested.parquet's stamp becomes 'external-writer (version v1.5.6 069cc9f)'
and its root 'nested_schema', both rewritten in place at the same length;
it reads back as the same table and its test is unchanged.
test/data/parquet/parallel.parquet names no product (its created_by is
'rayforce fixture writer'; two matches a name search finds in it are bytes
inside its data pages) and is left as it is.  No source change.

Fixes #1924
… read (#1926)

A hybrid RLE/bit-packed stream (definition levels, dictionary ids, RLE
booleans) may end in a bit-packed run padded to its whole length: the
run's header declares groups*8 values, its bytes are all in the stream,
and the values past the page's count are padding.  The format allows
any number of such groups; the reader's end-of-page rule accepted at
most the seven of one group and refused the page with "excess definition
levels" or "excess dictionary indices" although every value decoded.

pq_rle_done now accepts any rest of a final bit-packed run, for every
file alike.  Its bytes were bounds-checked against the stream when the
run began (pq_take), and the stream must still be fully consumed, so
what stays refused is unchanged: a run whose bytes end past the stream,
an RLE run longer than the values, a run of no values, and any run after
the values are complete.  One rule serves .parquet.read, the scan's
symbol import, and the direct and grouped imports of .parquet.splayed
and .parquet.parted.  Repetition levels are not decoded: a page with
them is refused before its streams are read.

Fixes #1658
An error that nothing catches prints where it was raised and the calls
that led to it. The same error caught with `try` reached the handler as
`{code msg}` (plus `usage`) only. The frames the report would have shown
were recorded, and both catch paths then threw them away.

The handler's dict now has `trace` when the error was raised inside a
function. It is a list of `{file line col}` dicts, innermost first: the
same frames the uncaught report prints. There are at most 16, then
`{more: n}` with the count of the rest. Frames carry no source text and
no function names.

The frames come from state already in hand at the catch:
- the frames inner unwinds recorded (a builtin's callback, the tree
  walker's call sites);
- at a compiled trap, the body's own frame and each call above the trap's
  return-stack depth, taken before they are released.

The report and the dict locate a frame through one function
(ray_error_frame_locate / ray_nfo_locate in lang/nfo.c), so the two
cannot disagree. A line deep in a long text is found through a
per-thread index of that text's line starts. It is built once per text
and dropped, with the keys vector the frame dicts share, when the
thread's heap is handed on or torn down. Without the index, a catch in
a loop rescanned the file once per frame. With a function at line 5000
of a 340 KB script, a million catches did not finish in two minutes.

What does not change:
- An error outside any function has no trace key.
- `(raise x)` still hands the handler x.
- A plain-value handler builds nothing.
- The no-error path does no work.
- The frames the dict holds are its own references.
- The query paths that swallow an error still drop its frames.
- IPC still carries code and message only.

Also fixed: try_error_value dropped the error object of a failed
`usage` string without freeing it, which leaked 64 bytes per failure. The
new allocation sweep found it.

Timings: ns per iteration, 1M iterations through map, -c 1, median of 7
interleaved runs. Fresh clang and gcc release builds; "ctl" is a byte
copy of the dev binary.

                       clang                 gcc
                  dev   ctl   new       dev   ctl   new
  plain call      120   117   118       129   118   121
  try, no error   117   119   121       118   118   119
  caught, value   172   173   170       196   199   190
  raise caught    299   305   299       316   318   319
  caught, fn:
    1 frame       617   635   817       669   673   896
    4 frames      678   680  1268       980   743  1332
    map callback  797   805  1138       922   870  1172

A function handler pays about 200 ns for the first frame (clang; 225
gcc) and 150 ns for each further one. Every other shape is equal to dev
within the control's spread. At line 5000 of a 340 KB script the cost
per frame is the same.

Per frame, a dict, its value list and two integer atoms are allocated.
The keys vector they share is made once per thread. A frame is located
without a walk per byte when its line is ASCII.

Tests:
- test/rfl/hof/try_trace.rfl covers one frame, three deep, the top level,
  map/fold/pmap callbacks, a try inside pmap workers, nested try, a
  handler that raises again, raise, a lambda with no source, and
  recursion past the cap.
- The C test lang/eval/try_trace_matches_report compares the dict's
  frames with the report's for the same failures.
- lang/eval/try_trace_oom fails every allocation of a catch in turn and
  checks that no bytes are left behind.
- try_catch_releases gains cases with frames whose handler ignores the
  dict.
- Two tests that printed whole caught dicts from inside functions now
  take the first two keys.

Part of #1789
BREAKING CHANGE: a caught error's dict gains a `trace` key when the error
  was raised inside a function; code that prints, counts or compares the
  whole dict sees it (take `code`, `msg` and `usage` by key instead).
…1927)

.parquet.splayed and .parquet.parted stage into
<destination>.parquet-partial and publish it by rename.  An import that
failed partway left that directory behind, and pq_stage refuses to
stage over an existing one, so every later import into the same
destination failed until it was removed by hand; test runs accumulated
them in /tmp.

A failed import now leaves nothing, as a failed .csv.splayed does.  The
staging directory goes on every error exit, after the import's files
are closed, and only when this import created it: one left by hand or
by another import under way is still refused and kept, and once the
rename has published the destination nothing is removed, whatever fails
after it (the destination's directory sync).  If it cannot
be removed, the error keeps its code and message and names the
directory left.  The .csv.parted rule (completed partitions kept and
named) does not fit here: a splayed table is one unit, and a parted
import writes its partitions by row group in any order, naming a
symbol file flushed only before publication, so no part of a failed
staging tree is readable on its own.

Fixes #1298
…ry (#1932)

In a query, `in` against a one-value set written as an atom (a literal,
a bound name or a lambda's argument) took the atom's value from the
64-bit i64 field of its union.  An I16 or I32 atom holds its payload in
the low bytes (ray_i16, ray_i32), so -1h read as 65535 and -1i as
4294967295: (select {from: t where: (in v -1h)}) over [-1 65535] kept
65535.  The integer route read an F32 atom, which keeps its value in
f64, as the integer of its bits, so (in f (as 'F32 0.5)) matched
nothing.  The same reads were made of an atom on the value side,
(in -1h h), and so in an output and in by:.  The function `in`
answered right.

The kernel's set builder now reads a set atom at its own width
(in_atom_i64, in_atom_f64).  An I16 or I32 atom on the value side is
handed to the kernel as the same atom with i64 its signed value, and an
F32 one as the F64 atom of its value (in_atom_norm, at the planned
OP_IN and at ray_in_vec_exec).  The per-row loops are unchanged.

Over 14,400 combinations, each query's answer equals the membership the
function gives, with null rows false (functions.md); dev gives 474 wrong
answers.  The combinations cover U8, I16, I32, I64, F64, F32, DATE and
TIME columns against atoms, one-element vectors, bound names and
ten-element sets of each of those types, nulls included.  They run as a
where:, a not, an output and a lambda argument, on flat, compressed
parted, hashed and 160,000-row compressed tables.

Fixes #1930
…hunks as the literal does (#1928)

A where: comparison whose bound is a cast of a literal, (> ts (as
'TIMESTAMP n)), pruned partitions as the timestamp literal does (#1743),
but inside the kept partitions it decoded every chunk the literal skips:
the query compiler has no DAG node for a temporal cast, so the where:
was evaluated as one eager mask and the filter's statistics routes never
saw the bound.  On a compressed table of three partitions of 300,000
rows the first such query decoded 10.2 MB that the literal does not.

The select now rewrites its where: once, after from: is evaluated, with
each such bound replaced by the atom the cast denotes, so the partition
mask, the scan gate and the filter's chunk and index routes read it as
the typed literal.  The fold is confined to a comparison's bound (==,
!=, <, <=, >, >=, on either side, under canonical and/or), a scalar
cast of a scalar literal to a fixed-width numeric or temporal type.
The cast is the builtin the head holds, judged by the object (an alias
of as folds; a lexical binding, a column or an output of the name does
not), with the type a literal symbol no binding, column or output names.
The value is the cast's own, computed once as the evaluator computes it
for the column, so a cast that rounds, wraps, saturates or gives a null
compares as it did; a cast that raises is left as written and raises as
before.  A where: with an effect is left as written.  An `in` set is
left as written, as it is for the partition mask: an `in` of a narrow
typed atom answers differently from the cast's ((in v -1h) keeps 65535
of [-1 65535]).  So is a `within` range: the evaluator's within refuses
TIMESTAMP, TIMESPAN, I16 and U8 values a planned one reads, so a folded
range would answer where the query raised.

One class of answers changes: == and != of a TIMESTAMP, DATE or TIME
column against a numeric null cast, (== ts (as 'I64 0Nl)), raised type
in the select (which planned the numeric cast as a DAG cast) while the
comparison outside a select answers; the select now gives that answer.
Over 11,880 combinations (10 column types, 11 cast targets, 18 literals
including raising, rounding, saturating, wrapping, null and temporal
ones, six operators), each select equals the comparison evaluated
outside a select, on a flat table and on a compressed parted copy;
dev differs in exactly those 60 on each.

Fixes #1745
…te (#1933)

Since the previous step a caught error has `trace`, its frames on this
process. An error that came back from a server over IPC still had only
its code and message. Where it was raised on the server, and the calls
that led there, stayed on the server; debugging a remote script meant
calling its functions one at a time.

The client now gets the server's frames. `try` hands them to the
handler as `remote`, next to `trace`: the same `{file line col}` dicts,
innermost first, capped at 16 with `{more: n}`. The REPL prints them
under the error line as "  on server: file:line:col", and so does the
remote REPL session (.repl.connect).

How it crosses the wire, with no version bump:
- Every client sets a new handshake capability, 0x20
  (RAY_IPC_CAP_ETRACE). A server that knows it answers it; one that does
  not masks it off, as it does any bit it does not know.
- Only for such a client, a server that replies with an error appends a
  trace record after the error record. Byte 7 of the code field, always
  0 before, flags it, and the record holds a count and the entries
  (layout in store/serde.c, notes in store/serde.h).
- The writer is gated per thread (ray_serde_error_trace), and only the
  IPC reply turns the gate on. .ser, saved objects, .qdb snapshots and
  the journal never write the record.
- The decoder checks the whole record against fixed bounds (at most 18
  entries, file names of at most 4096 bytes) and the bytes left before
  it reads or allocates anything. A record that breaks a bound, an
  unknown kind and an unknown flag are each a domain error in place of
  the reply.

On the client, the frames hang on the received error through the spare
aux bytes 8-15 of the error block (ray_err_trace / ray_err_set_trace).
The error does not grow, a local error holds NULL, and ray_error_free
releases them.

On the server, the frames are those of the request's own evaluation.
The error trace is cleared when such a request starts, and the frames
are hung on the reply error after a raise is made again with its value
as the message. A journal failure that replaces the reply gets no
frames.

Restricted servers: a server started with -U keeps only the frames that
lie in the request's own text. All of its own frames become one
{hidden: n} marker at the place of the first, with no file, line or
name. A frame is the request's own by identity, never by its content:
ray_eval_str_source hands the request path the source object it made
for the request's text, and a frame is kept only when its source is
that object. Server-side text that equals the request, or is named
"repl" like it, stays hidden, so the rule cannot be used to test a
guess of a server file's text. A request sent as a parsed expression
has no text, so all its frames are hidden. -u (a password only) is not
restricted today: the connection's restricted flag is set by -U alone
(main.c, poll.c). So a -u server sends every frame, its file names as
given.

A file name a server sends is printed with its control bytes escaped,
as a string is inside a printed dict or list (\033, \n, \t, a
backslash doubled), in the REPL's "on server:" lines and in a printed
`remote`, so a server cannot write terminal control sequences to the
client's screen through it. A string shown on its own at the REPL
prints raw, as any string does (a server's error message already
did).

Error rebuilds: of the sites that make an error again from another's
code and message, one is on the reply path: the raise rebuild in
eval_payload_core. It now runs before the frames are hung, so they
survive. The send_response fallbacks make a new error for a value that
cannot be sent, so no frames are lost. The client's receive path
(deser_frame, ray_ipc_send, .ipc.send) passes the decoded error through
unchanged, the verbose [captured result] reply included. The other sites
(journal.c, json.c, readval.c, table.c, enccol.c, graph.c, heap.c,
splay.c, serde.c's ray_ser failure and v3 decode) are local and never
hold a remote error.

Compatibility, both directions:
- ipc/etrace/old_client: a raw client that sends no capability gets the
  error record byte for byte as before, with no flag and no bytes after
  the message. One that sends 0x20 gets the record.
- ipc/etrace/old_server: a fake server answers with no capability and
  replies with a plain error. The new client asked, was not answered,
  and gets the error with no frames. A fake server that answers the bit
  and sends a record past the bounds gives a clean domain error.
- ipc/etrace/decoder: with and without the record, every cut of a valid
  record, bad counts, kinds, lengths and flags. Under DEBUG every
  allocation fails in turn, leaking nothing.
- ipc/etrace/gate: the size and bytes with the gate on and off; ray_ser
  writes no record.
- ipc/etrace/restricted: a function defined from "/srv/secret/app.rfl".
  -U sends {hidden: 1} and the request's call frame, and nothing of the
  file reaches the client; -u sends the file, line and column. A parsed
  request has only the marker under -U. A request whose evaluation runs
  server-side text equal to the request's own, and named "repl" too,
  gets that text's two frames as {hidden: 2} under -U.
- test/rfl/system/ipc_error_trace.rfl (posix, spawned servers):
  `remote` from an unrestricted and a restricted server, inside a
  function next to `trace`, a raise, and the REPL's "on server" lines.
  It also covers the review's repro: a -U server loading a file whose
  whole text is the request, where the client sees only {hidden: 1} and
  its own frame. And a server script whose file name holds ESC[31m: the
  REPL lines and the printed dict show \033, and no ESC byte reaches
  the output.

Timing, clean clang release, median of interleaved runs against dev
(with step 1) and a byte copy of dev as control:
- 40,000 .ipc.send of (+ 1 2): 3359 / 3369 / 3386 ns (dev/ctl/new),
  equal within dev's own spread of 3271-3528.
- An error with three server frames caught by a function handler:
  4593 -> 5704 ns. That is the frames built, sent and decoded; a client
  that does not ask pays nothing.
- The local catch loops of step 1 are unchanged (plain 113/114, no-error
  try 114/114, plain-value catch 165/164, 1 frame 795/795).

Also: the remote REPL session printed the code of a remote error from
its raw 7-byte field and never freed the error. It now uses
ray_err_code and frees the error, and an error cell of a verbose reply
list too.

Fixes #1789
BREAKING CHANGE: a caught error from .ipc.send gains a `remote` key when
  the server sends its frames, so code that prints, counts or compares
  the whole dict sees it (take `code` and `msg` by key). The REPL prints
  "on server:" lines under such an error. An error record whose byte 7
  is not 0 or 0x01 is now refused as a domain error; no writer ever
  produced one.
The evaluator's within had typed loops for I64, F64 and the 32-bit
I32/DATE/TIME values, and refused every other value type and every
atom.  It read the range at the values' element width whatever the
range's type, so a range of another type was the wrong bytes:
(within [1 2 3] [2h 3h]), (within [1.0 2.0 3.0] [2 3]) and a DATE
column against a TIMESTAMP range all answered all false.  The planned
within built (and (>= col lo) (<= col hi)) without the operand rule
every >= and <= in a query takes (#974), so a DATE against an
integer range compared the stored day count with the integer, where
the comparisons raise type.  A TIMESPAN range fell back from the
planned route to the evaluator's within, which refused it.

within is now (and (>= x lo) (<= x hi)) on both routes.  The evaluator
evaluates the two comparisons with the comparison kernels and keeps
the typed loops as a fast path when the range's type is the values'
(I64, F64, I32, DATE, TIME).  There a null is the type's least value,
so the loop ranks it as the comparisons do; an F64 null bound (a NaN)
takes the comparisons.  The range may be a two-element vector or list.
The planned lowering checks both comparisons with dag_cmp_operands_ok,
as >= and <= do.

Over 539 value-type x range-type shapes (11 value types including nulls;
each range type forward, reversed, and with a null lo, hi or both),
every route equals the comparison pair: the evaluator on a vector and
on an atom, and where: with a written range, a (list lo hi) range and a
bound one, and an output.  On dev the evaluator differs from the pair
in 372 shapes.

Changes against dev:
- An error becomes the comparisons' answer for the values the evaluator
  refused (BOOL, U8, I16, F32, TIMESTAMP, TIMESPAN, SYM, an atom), a
  list range, and a TIMESPAN range in a query.
- A wrong answer becomes right for a range of another type than the
  values' (64 shapes in the evaluator, 9 in where:).
- An answer becomes the comparisons' type error for any pair they
  reject: a number against a DATE, TIME, TIMESTAMP, SYM, STR or GUID
  range and the reverse, a temporal value against a SYM, STR or GUID
  range, and a DATE against a TIMESPAN.  Dev compared stored values
  there, a day count against an integer (in this differential 108
  shapes in the evaluator and 192 to 197 per query route; a review grid
  of 30,420 cells counts 444 eager and 8,920 query cells).
A reversed range holds nothing on both routes, as on dev.  The cast-bound
test of #1928 pinned a TIMESTAMP range in a select raising type; it now
pins the answer.

BREAKING CHANGE: within of any pair of value and range types that >= and <= reject now raises the same type error, in a query and outside one, where dev compared stored values (a number against a DATE, TIME, TIMESTAMP, SYM, STR or GUID range and the reverse, a temporal value against a SYM, STR or GUID range, a DATE against a TIMESPAN range).
Fixes #1931
…s symbol (#1938)

In a query, a SYM value compared with a string atom read the string as
the symbol it spells when the planner ran the comparison: == and != by
symbol (#1493), < <= > >= by the symbol's text against the string's
bytes (exec_sym_order).  When the evaluator ran it instead, the same
comparison raised type: a mapped column, (> (map (fn [x] x) s) "c"), a
computed string, an output or by: over such a value, an update, and a
computed within range, (within s (V "c" "m")).  The answer depended on
whether the planner could lower an operand.

In a query (ray_env_query_scope_above, the test `in` uses), the
evaluator's comparisons now read a string atom against a SYM value,
vector or atom, as the planner does, through the planner's own kernels.
== and != go through the query `in` kernel against the one string
(ray_in_vec_exec): a string no symbol spells matches nothing, "" is the
null symbol, and nothing is interned.  < <= > >= go through
exec_sym_order, the bytes order of asc on symbols.  The vector map hands
such a pair to it whole (atomic_map_binary_op_c), and the atom
comparisons take it in the branch that raised.  within, being the pair,
follows.  min and max, which pick with <= and >=, keep raising, as they
do on the planned route.  A string vector or a STR column against a
symbol stays a type error, as on the planned route.  A LIST of strings,
which dev refused on both routes, is now compared cell by cell on both,
each string as the symbol it spells, as a list of symbols is; a cell
that is not a string compares as itself (a number raises type), and
outside a query it stays a type error.  Outside a query
nothing changes.

A differential of 2,176 cases covers the six comparisons and within of a
SYM column against "c", "kiwi", a string no symbol spells, "", "café",
"Kiwi" and "zz", with a null symbol in the column, on flat, splayed,
parted and compressed parted tables of 160,000 rows.  Each compares the
planned route with the evaluator routes (two forcing wrappers, a
computed string, a lambda, an output, by:, update, a computed within
range), with reversed operands and string-vector and numeric operands.
On 1 and 4 workers every route answers alike and the planned route
matches a bytes-order oracle.  Against dev, 912 cases change, each an
evaluator-route type error becoming the planned answer; no answer
changes.  A thousand comparisons with fresh strings add no symbol.

Fixes #1936
…1937)

The REPL, scripts, timers and the remote session printed the text in an
error line raw. That text is an error's message, a rendered raise
value, the usage, a file name or a line of source. Whoever wrote it
controlled the terminal it reached: a server's error message could
recolour, move the cursor or set the title on a client's screen, for
example (raise "x\033[31mred") answered to an .ipc.send. Every byte but
NUL got through.

One helper (src/core/termesc.c, ray_esc_unit / ray_esc_write) now
writes all of it, the same to a terminal, a file or a pipe:
- a byte below 0x20 and 0x7f as \n, \r, \t or \NNN, as compact
  formatting spells them in a string;
- a byte that is not part of well-formed UTF-8 (overlong forms,
  surrogates, past U+10FFFF, cut short, a stray continuation byte such
  as the 8-bit CSI 0x9b) as \NNN;
- each byte of a C1 control character spelt in UTF-8 (U+0080..U+009F,
  so U+009B too) as \NNN, since some terminals act on it;
- everything else as it is: valid text in any script, emoji, combining
  marks, and backslashes.

Every other diagnostic that prints text from outside uses it too, found
by one sweep of every fprintf, printf, fputs and fwrite to stderr or the
REPL's output in src/app, src/core and the printers elsewhere. Such a
line is written with ray_esc_fprintf: fprintf with every %s argument
written escaped and whole, streamed, at any length. A path with nothing
to escape prints byte for byte as before, however long; the other
conversions print as fprintf prints them, and the format attribute
checks their arguments. With a precision (%.*s) the text is read up to
the precision and no further, so a length-delimited buffer need not be
terminated. A format with a conversion it does not take (%n, a
positional %1$s, an unknown length or conversion, a trailing %) is
refused whole before any argument is read and written as it stands, so
the argument list cannot fall out of step with it; every call in the
tree passes the check.

Escaped (text from a file, a peer, the command line or user data):
- main.c: flag_value's "expects a value"; "bad -p bind address" and
  "bad -p port"; the -c and integer-flag errors (flag and value);
  "unknown option"; "log: open failed for base="; "listening on" and
  "failed to listen on" (the bind host); "startup script %s failed;
  closing listener on %s".
- repl.c: ". Unknown command:" (the command as typed).
- syscmd.c: :env's binding names; :h's echo of the name, a lambda's
  parameter names, and a namespace's name.
- store/journal.c: "cannot open", "is open in another process" and
  "cannot lock" (paths); a replayed chunk's error code; the snapshot
  lines (path, code); "replayed ... from", "replay aborted ... in" and
  "replay interrupted ... in" (log path); the roll's rename paths.
- table/domain.c: the sym-domain OOM and preload lines (domain path).
- Developer traces behind RAY_*_TRACE switches: csv.c (file, column and
  leaf names); parquet.c (column names); splay.c and part.c (dirs,
  paths, table names); builtins.c's read_parted failure (root, table).

Safe as they stand:
- Fixed literals or engine-chosen labels: ipc.c's hook names
  (".ipc.on.open"/".ipc.on.close"); the progress bar's op and phase
  labels and the profiler's span names (builtin and opcode names);
  syscmd's help table, builtin usage lines and summaries (lang/sig.c);
  parquet's phase names; idxop's trace labels; csv's
  ray_err_code_str; crash.c's banner (version strings).
- Numbers, errno text (strerror) and pointers: the rest of the format
  arguments of the lines above, heap.c's diagnostics.
- An embedder's registration name (eval.c's "cannot register builtin"),
  the C name a program passed.
- query.c's private-id check (__FILE__ and __LINE__), and ops/dump.c's
  plan dump (ray_graph_dump, no caller in the engine; a debugging aid).
- The line editor (term.c): it echoes what is being typed and this
  process's own completions; it is input, not a report.
- By decision: values (a string at the prompt, println, show) and the
  remote session's captured server output.

Values are not error lines and keep their formatting: a string shown at
the prompt, println and show print text as before. So does the server
output a remote session shows.

The marker follows what is printed: an escaped byte before the failing
position counts as the width of its spelling (\033 is four cells). The
header's column stays the character's column in the source, as try
reports it (lang/nfo.c).

Nothing else changes. The REPL's output was compared over the test
suite's own inputs: every .rfl file without a shell, temporary path or
posix marker (644 files), each line's expression fed to the piped REPL,
on clean clang release builds of dev, a byte copy of dev and this
branch. Of 51,393 error and report lines, none differs. Three files
whose output varies from run to run on dev alone differed once and
matched on rerun: pmap's order, a join's values under load, a stack
depth's frame count. The engine's own messages and usage lines hold no
control byte. No evaluation path is touched: only the printing of an
error goes through the helper.

Tests:
- runtime/termesc_rules: each rule, the UTF-8 edge cases, valid text
  unchanged, and every byte value alone and after a lead byte, checked
  by an independent byte scan.
- runtime/timer_callback_error_escaped: a timer callback raising a
  string with ESC[31m, a bare CR, U+009B and 0xff.
- repl/error_line_escaped: a script's one-line error with the same
  message.
- repl/report_escaped: a script whose file name holds ESC[31m, failing
  at a line with raw ESC, 0xff and 0x01 before the failing call next to
  é and 日. Name and line are escaped, the valid text is unchanged, and
  the marker sits at the call's cell as printed.
- test/rfl/system/repl_error_escape.rfl (posix): a server raising such
  a message from a script whose file name holds 0x01 (a name on disk
  stays valid UTF-8: macOS refuses others). The client's error line and
  "on server:" line show \033, \r, \302\233, \377 and \001, and no ESC,
  CR, 0x01, 0x9b or 0xff byte reaches its output.
  Then three lines off the printer, each with ESC: "unknown option"
  from argv, a server's "startup script ... failed" for a script whose
  path holds ESC, and the REPL's "Unknown command" for what was typed.
  All three are escaped, and no ESC reaches the output.
  It also checks that long paths with nothing to escape print whole:
  main.c's "log: open failed for base=" with a 3000-byte base, and the
  journal's "cannot open" with a 1008-byte base. The journal bounds its
  paths at 1024 bytes (RAY_JOURNAL_PATH_MAX), on dev too, so that is
  near the longest it takes.
- runtime/termesc_fprintf: ray_esc_fprintf against fprintf, byte for
  byte, for every conversion the diagnostics use (%s with width and
  precision, %.*s, %d %u %x %lld %zu %.1f %c %% and PRId64), and a
  3000-byte path whole, plain and with an ESC in it.
- runtime/termesc_fprintf_bounds: %.*s over an exact-length heap buffer
  with no terminator (ASan reports any byte read past it), and seven
  formats it refuses (%n, %1$s, %q, %Ld, %hs, %lllld, a trailing %),
  each written as it stands.
The output checks fail on dev, which prints the bytes raw; the helper's
unit test is new with the helper.

Fixes #1935
BREAKING CHANGE: text from elsewhere in an error line or report is now
  escaped. A raised string holding a newline, such as (raise "a\nb"),
  prints as `error: domain: a\nb` on one line instead of two, and the
  "on server:" lines no longer double a backslash.
…ed' (#1944)

ray_ipc_connect needs a poll attached to the runtime: the connection
lives in the poll's selector table, and its handle is the selector id.
Without one it returned -1 before opening any socket. -1 is also what a
refused connection returns, and .ipc.open turned every negative it did
not name into "connection refused: HOST:PORT". An embedder whose server
was up was told it was refused, and looked at the network.

The guide's C client example (docs/docs/guides/ipc.md) created a runtime
and connected without a poll, so it printed "Connection failed" against
a running server. Several other failures also returned -1 and read as
"refused":
- an auth byte in the handshake reply that this client does not know;
- user:password too long for the handshake;
- out of memory, or a poll that took no more connections;
- a transport upgrade that failed midway.
A socket error while sending the credentials returned -1 too. And -6 and
-7, which ipc.c and system.c used, were missing from the code table in
src/core/ipc.h.

Every failure now has a code of its own. The codes are named and listed
next to ray_ipc_connect in include/rayforce.h, the public header, as
RAY_IPC_ERR_*:
  -1 REFUSED (ECONNREFUSED only), -2 AUTH_NEEDED, -3 AUTH_FAILED,
  -4 WIRE, -5 TIMEOUT, -6 SOCKET (errno holds it),
  -7 TRANSPORT (existing codes, values unchanged);
  -8 NO_POLL, -9 HANDSHAKE, -10 CREDENTIALS, -11 RESOURCES,
  -12 UPGRADE (new).
A socket error while sending the credentials is now classified by errno,
as the connect's own errors are: -5, -6 or -1. src/core/ipc.h points to
the table.

.ipc.open (ray_hopen_fn, the only caller of ray_ipc_connect_with in the
tree) gives each code its own message:
- NO_POLL: "no event loop to connect to HOST:PORT from: attach a poll
  with ray_poll_create and ray_runtime_set_poll before connecting";
- HANDSHAKE: "handshake failed: unexpected reply from HOST:PORT";
- CREDENTIALS: "credentials too long for HOST:PORT (255 bytes at
  most)", a domain error (from the C API only: .ipc.open bounds each
  field first, below);
- RESOURCES: "connect failed: out of memory or connection slots";
- UPGRADE: "transport upgrade failed".
A code it does not name says "connect failed (code N)", never
"refused".

.ipc.open also stopped emptying long credentials. It copied the user
and the password into 128-byte buffers and, when a part did not fit,
silently left it empty. A long password was sent as no password at all,
while docs/namespaces/ipc.md promised a domain error for an oversized
user or password. Now a user or password of 128 bytes or more is that
domain error ("user too long" / "password too long, got N bytes (at
most 127)"), checked as the host and port are. On dev an emptied
password was never accepted where it should not be:
- a server without a password never reads credentials, so it accepted
  the connection as it would with any password;
- a server with one compares the password first (ray_poll_auth_check),
  so it rejected the empty one as "authentication failed";
- .ipc.on.auth is consulted only after that check passes.
The defect was the silent change and the wrong message.

Three more cases are still reported as something they are not. Each
needs more than a line, so they are filed as #1947 and not changed
here:
- a stall or a close while waiting for the auth result reads
  "authentication failed";
- a close before the greeting reads "connect failed: Connection reset by
  peer";
- a password containing ':' is cut at the ':' by .ipc.open.

Docs:
- The guide's C example now creates and attaches a poll, includes only
  rayforce.h and stdio.h, prints the code on failure, and detaches and
  destroys the poll at the end.
- The guide's C API table states the poll requirement and points to the
  code table.
- The guide's error examples show the messages as printed
  (io: connection refused: HOST:PORT; access: server requires
  authentication).
- The .ipc.open page lists every io message.

Every complete C program in the docs was built from the docs text with
gcc against librayforce.a and run:
- guides/ipc.md:395, the C client: on dev it prints "Connection failed"
  against a running server. Now it prints "Result: 3", and with its two
  poll lines removed it reports code -8.
- c-api/core.md:56 and c-api/dag.md:541, 613, 655, 715: they build and
  exit 0, before and after; nothing in them changes. dag.md:541 has an
  unused variable for a borrowed result, a warning only.

Tests (test/test_ipc.c):
- ipc/connect/no_poll: a server is up and no poll is attached.
  ray_ipc_connect returns -8, and .ipc.open's message names the poll
  calls and not "refused". With the poll back, the same connect
  succeeds. On dev it returns -1.
- ipc/connect/codes_stable: each code's value; a refused connect is still
  -1; credentials past 255 bytes give -10.
- ipc/connect/handshake_code (POSIX): a peer whose handshake reply
  carries an unknown auth byte gives -9, and "handshake failed".
- ipc/connect/open_credential_bounds: .ipc.open with a user, then a
  password, of 127, 128 and 300 bytes. At 127 bytes the user connects
  and the password is sent and judged ("access"); at 128 and 300 bytes
  each gives the domain error. On dev the 128-byte user connected with
  the user field emptied.
The existing refused, timed-out, auth and wire-mismatch tests
(test_ipc.c, test/rfl/system/ipc_open_errors.rfl) pass unchanged.

Fixes #1939
BREAKING CHANGE: failures that returned -1 without being a refused
  connection now return their own codes: no poll -8, an unknown
  handshake reply -9, credentials too long -10, out of memory or no
  connection slot -11, a failed transport upgrade -12, and a socket
  error while sending credentials -5, -6 or -1 by errno. .ipc.open's
  message for them is no longer "connection refused". -1 now means a
  refused connection only; every other existing code keeps its value.
  .ipc.open refuses a user or password of 128 bytes or more with a
  domain error instead of sending the field empty.
ray_list_set released the slot's old item before it retained the new
one.  When the two were one value and the slot held its only
reference, as in ray_list_set(l, i, ray_list_get(l, i)), the release
freed it and the retain then touched the freed block, which the slot
kept.  The same happened when the new item was held only by the value
it replaced.  ray_dict_upsert reached it through its vals list, for a
key's own value.

The new item is now stored and retained before the old one is
released, and setting a slot to the item it already holds is a no-op.

Fixes #1941
#1945)

include/rayforce.h stated ownership for some functions (ray_dict_new
"consumes both", the borrowed table columns, the growing writes) and
was silent on others.  So an embedder had to read the .c file to learn
that ray_ipc_send borrows its message, that ray_list_append retains
its item, that ray_list_get, ray_env_get and ray_sym_str are borrowed,
and what ray_fmt's mode means.

The header now opens with an ownership-conventions paragraph:
arguments are borrowed unless marked consumed, results owned unless
marked borrowed (with what they point into and until when), errors
freed with ray_error_free, and const char* results never freed.  An
error given in place of a value is answered as it is by the writes and
the functions that build an owned value from their argument; the
getters answer NULL.  Every function was checked against those rules
and its definition, and each one they do not describe has a short
comment: ray_vec_set and ray_list_set are growing writes and are
listed with them; ray_table_validate_rectangular answers a new error
even for an error argument, ray_fmt formats one, and the IPC sends
send it; ray_realloc_raw frees p as realloc does.

ray_sym_str's rule comes from the symbol table's arena: the atom is
never released and stays valid until ray_sym_destroy, because
interning never moves an atom.  The comment on its definition said
the pointer could go stale, which was the strings array's rule.
ray_fmt's comment lists the four mode values.

docs/docs/c-api/core.md gains the same conventions and sections for
ray_sym_str, ray_env_get/ray_env_set, ray_fmt and the IPC sends, and
now agrees with the header on every function it describes.  It
corrects entries that said to always reassign a growing write's
answer, that a null STR element reads as NULL, and that
ray_table_add_col keeps its table.

Reading the code found three behaviours a comment should not paper
over, filed as issues: ray_list_set freed an item already in the slot
(#1941, fixed first, so its comment states the fixed behaviour),
ray_str_vec_insert_at borrows where ray_vec_insert_at consumes (#1942),
and ray_err_code answers one thread-local buffer (#1943); the comments
on the last two state today's behaviour and name the issue.

test/test_ownership.c checks the stated rules for the reported
functions by reference counts and the heap trace: the IPC sends, the
list item writes and reads, ray_sym_str across 100,000 interns,
ray_env_get/set, ray_fmt's four modes, ray_select, ray_err_code,
ray_vec_set taking its vector, and the functions that do not answer
an error argument as it is.  No behaviour changes.

Fixes #1940
…ke stalls say so (#1950)

Three defects in how a connection logs in (#1947):

1. .ipc.open cut a password at its first ':'. The address
   host:port:user:password was split on every ':' into at most four
   parts, so the fourth ended at the next one: "h:5000:u:p:w" sent the
   password "p". A server started with -u 'p:w' could not be reached
   from Rayfall at all.

2. The server compared at most the first 255 bytes of a password.
   ray_poll_auth_set cut a longer secret to 255 bytes, and
   ray_poll_auth_check compared at most 255 bytes of the one a client
   sent. So a prefix could stand in for the whole, while no client could
   send more than 253 bytes of password anyway.

3. Two handshake failures were reported as something else:
   - a stall or a close while waiting for the auth result read as
     "authentication failed" (-3);
   - a close before the greeting read as "connect failed: ... Connection
     reset by peer" (-6).

The fix:

1. The password is everything after the user's ':', colons included.
   Host, port and user end at their ':'. A user holds no ':', as the
   server already assumes: it splits the credentials at the first ':'
   (ray_poll_auth_check, and the .ipc.on.auth hook's arguments).
   '@' and other punctuation stay as written. The 127-byte bound from
   #1944 applies to each field as parsed, colons counted. .repl.connect
   parses with ray_hopen_fn, so it follows the same rule. -u and -U take
   their argument whole, as before.

2. RAY_POLL_PASSWORD_MAX (253, include/rayforce.h) is the longest
   password the handshake carries: one length byte for "user:password"
   and its NUL, at least ":password".
   - -u and -U refuse a longer password at startup ("error: -u password
     is N bytes, at most 253", exit 2).
   - ray_poll_auth_set given a longer one does not cut it. The poll then
     refuses every login: it fails closed, and a login is still asked
     for (ray_poll_auth_required).
   - ray_poll_auth_check compares the whole password, and one longer
     than the bound never matches.
   The comparison is the existing constant-time one: an XOR over a fixed,
   zero-padded 256-byte buffer, whatever the lengths. It now takes the
   two lengths in as well: the secret's length is found by the same
   walk, with no early exit or branch on its bytes, and the difference of
   the lengths goes into the same accumulator. Only the exact password
   matches. On dev the right password followed by more NUL bytes matched,
   since zero padding hid them. One trailing NUL, which a client ends the
   credentials with, is still ignored. The only early answer is for a
   password past the public bound, so it reveals nothing about the
   secret.
   Writing the test found a client bug as well: "user:password" of
   exactly 255 bytes passed ray_ipc_connect's size check, and adding the
   NUL wrapped the length byte to 0. The bound is now 254 bytes, and a
   longer one is RAY_IPC_ERR_CREDENTIALS (-10). .ipc.open, whose user and
   password are at most 127 bytes each, says so for 127 + 127:
   "credentials too long for H:P: user:password is at most 254 bytes".
   The docs state the combined bound next to the per-field one.

3. A failed read or write of the handshake (greeting, credentials, auth
   result) is classified by what happened:
   - the server closing the connection there (end of stream or a reset)
     is RAY_IPC_ERR_HANDSHAKE (-9), with errno ECONNRESET. .ipc.open
     says "handshake failed: the server closed the connection: HOST:PORT";
   - a stall is RAY_IPC_ERR_TIMEOUT (-5), "connection timed out";
   - only a received rejection byte is RAY_IPC_ERR_AUTH_FAILED (-3);
   - an unexpected reply is still -9, with errno 0, and "handshake
     failed: unexpected reply".
   No new code; every code keeps its value.

Docs:
- guides/ipc.md and namespaces/ipc.md: the address rule (the user holds
  no ':', the password may) and the bounds.
- storage/ipc.md: the 253-byte server bound and the whole,
  constant-time comparison.
- The io and access messages.
- include/rayforce.h: RAY_POLL_PASSWORD_MAX, ray_poll_auth_set and
  ray_poll_auth_check, and the -3, -5, -9 and -10 entries of the code
  table.

Tests:
- ipc/connect/open_password_colons: a server with the password
  "p:w@!x:". Reached with "u:p:w@!x:", with no user, and with an '@' in
  the user; "u:p" (what dev sent) and a password one byte short are
  refused (access). A 127-byte password with colons is sent, a 128-byte
  one is the domain error.
- ipc/connect/auth_whole_password: ray_poll_auth_check takes the whole
  password and not a longer or shorter one; a 253-byte secret matches
  whole and not with a byte more; a 254-byte secret refuses every login,
  its cut included, and still asks for one. End to end, a 253-byte
  password reaches a server over the C API, and with a user it is -10.
- ipc/connect/handshake_steps (POSIX peer), through ray_ipc_connect and
  through .ipc.open, a peer that:
  - closes before its greeting: -9, "the server closed the connection";
  - stalls before its greeting: -5;
  - asks for a login, reads the credentials and closes: -9;
  - asks for a login, reads the credentials and stalls: -5;
  - rejects the login: -3, "authentication failed".
- ipc/connect/open_credentials_combined: a 127-byte user with a
  126-byte password is sent (access); with a 127-byte password it is the
  domain error, naming the 254-byte bound.
- ipc/connect/auth_exact_length (POSIX raw client): "u:pw" and "u:pw"
  plus one NUL are accepted. "u:pw" plus two NULs, plus eight NULs,
  "u:p<NUL>w" and the bare "pw" plus two NULs are refused. The same holds
  for ray_poll_auth_check called directly.
- test/rfl/system/ipc_auth_bounds.rfl (posix): -u with 254 bytes and -U
  with 300 bytes exit 2 with the message, and -u with 253 bytes starts;
  a server started with -u 'p:w' is reached with "u:p:w" and refuses
  "u:p".
All but the 253-byte start fail on dev.

Fixes #1947
BREAKING CHANGE: what an existing client or script can observe:
  (1) .ipc.open and .repl.connect send a password containing ':' whole;
  a script that relied on the cut sends a different password. (2) A
  stall while waiting for the auth result is -5 "connection timed out",
  not -3 "authentication failed". (3) The server closing the connection
  during the handshake (before its greeting, or after the credentials)
  is -9 "handshake failed: the server closed the connection", not -6
  "connect failed: ... reset by peer" or -3; a write to a peer that
  closed during the handshake is -9 rather than -6. (4) -u and -U refuse
  a password over 253 bytes at startup; before, they kept its first 255
  bytes. (5) ray_poll_auth_set with a password over 253 bytes refuses
  every login instead of matching a 255-byte prefix, and
  ray_poll_auth_check never matches a password over 253 bytes. (6)
  ray_ipc_connect with "user:password" of 255 bytes returns -10 instead
  of sending a wrapped length and failing as -3. (7) The right password
  followed by more than one NUL byte is refused; dev accepted it.
ray_err_code copied the error's code into one thread-local buffer and
answered it, so every call on a thread answered the same pointer and
the next call overwrote the last answer.  Two codes could not be held
at once: strcmp(ray_err_code(a), ray_err_code(b)) compared the buffer
with itself and always found them equal, and a binding that kept one
code while asking for another read the wrong one.

It now answers one NUL-terminated copy of each distinct code, kept for
the life of the process.  A code and its NUL fit one 64-bit word, kept
in a slot of an open-address hash table; the first table is static and
each later one twice the last, made when the last is half full, so
there is no limit on the number of codes (a peer can send any over
IPC; each costs 32 to 64 bytes, kept) and a lookup stays a few
probes.  A lookup reads without a lock,
and a new code is added under the lock after a second lookup, so equal
codes always answer one slot.  Only when no memory is left for a new
table does a new code answer the static "error".  The text answered is
the same as before and lives longer: valid after its error is freed
and on any thread.  All 55 callers in the tree read the code before
their next call or copy it, so each behaves as before.  Nothing an
embedder could rely on changes; only the lifetime grows.

The header comment and docs/docs/c-api/core.md say the result is
static and never freed.

Fixes #1943
The env binders released the binding's old value before they retained
the new one.  When the two were one value and the binding held its
only reference, as in ray_env_set(n, ray_env_get(n)), the release
freed it and the retain then touched the freed block, which the
binding kept.  The same happened when the new value was held only
inside the old one.  The local-frame binder had the same order, and so
did ray_raise_fn for the value the VM holds.

Each now stores and retains the new value before it releases the old
one, and binding or raising the value already held is a no-op.  The
dict test that #1948 added interned its key with no symbol table (id
-1); it now has one.

Fixes #1946
ray_str_vec_insert_at borrowed its vector and answered a new one,
while ray_vec_insert_at and the other ray_str_vec_* writes take the
caller's vector on success.  Code written like them,
v = ray_str_vec_insert_at(v, ...), leaked the old vector on every
call; the suite's own tests did it four times.

It is now a growing write with the same contract as the others: on
success it takes the caller's vector and answers the new one; on a
failure it answers an owned error and leaves the vector untouched and
the caller's.  ray_str_vec_insert_at_take, added with the other _take
forms, releases it on a failure instead.  The one caller in the tree
that released the vector itself after the call, the STR vector arm of
insert in src/ops/query.c, now uses the _take form.  The header and
docs/docs/c-api/core.md list it with the growing writes.

The siblings were checked: ray_str_vec_append, ray_str_vec_set,
ray_str_vec_compact and ray_list_insert_at already follow the
growing-write contract.  ray_vec_insert_vec_at, ray_vec_insert_many and
ray_list_insert_many borrow and answer a new block, as their comments
say; they insert a vector or many items, not one, so they are left
as they are.

Fixes #1942
BREAKING CHANGE: ray_str_vec_insert_at now takes its vector on
success: an embedder that releases the vector after the call must stop
(that release is now a stale one) and release only the answer.
…n, and an append writes the hash sidecar in place (#1953)

A bulk write read every symbol file back to hash it.  An import and a
compression wrote the hash sidecar (.ixh) of each symbol file they
finished by reading the whole file back through a fresh mapping, one
thread, no readahead; with compression the plain file was read for a
sidecar that the coded file replaced a second later, and the coded file
was read again.  On a box whose page cache cannot hold the symbol files
this re-read every byte from disk: a 100M-row load read 18 GB more and
took 14% longer on a 2 GB machine with a network disk.

The import dictionary now hashes each block of 28 records once its
positions are final (one-by-one adds at a sync, a grouped task's two runs
when it is written, collision records as they are put), from the pages it
has just written; blocks not covered are hashed at the durable sync.  The
coder hashes each coded block from its output buffer on the pool.  Both
pass the hashes to the index save, so neither reads its file back.  The
sidecar is the one an open derives from the records, byte for byte.

Every append to a symbol file rewrote its whole hash sidecar to a
temporary file renamed over it, after summing all the old hashes: 200
appends of 20,000 symbols wrote 137 MB of sidecars for a 1.4 MB final
one.  The sidecar was trusted only on its file's identity, so a hard link
or a chmod (a ctime change) followed by an append from a release without
the sidecar made the holder's remount fail with corrupt.

Sidecar format 2 (header 72 bytes): the header also holds `last`, the
hash of the image's last block, and `sum` covers the slots of the blocks
before it plus `last`.  An append reads the header, hashes the block the
old entries ended in and the new ones from the records it wrote, writes
those slots and then the header.  When the room runs out the sidecar is
written whole once, its old hashes copied from the old sidecar.  A process
that dies between the slots and the header leaves a header stale for the
grown file: the next open hashes the records anew.  An append into a
sidecar shorter than the room its header claims writes it whole.

An open holds the sidecar's slots to the sum in its header (8 bytes read
per 28 records): one that does not sum is not this image's, and the
records are hashed once and the sidecar written anew.  A holder relies
only on what no append changes: the slots of the blocks before its
image's last one, and the `last` and `sum` it read at open.  A remount
that sees growth sums them; when they do not sum, or the sidecar's size
changed under the mapping, the sidecar was written over in place (a copy
of another root over a live one) and the remount fails with corrupt.  No
file identity is compared, so links and chmod no longer matter.

Compatibility: .ix stays at format 5; releases without the sidecar still
ignore .ixh; a format 1 sidecar is hashed anew once.

Tests: parquet/symfile_column (every sidecar an import or a compression
wrote equals the one an open derives, under RAY_SYM_INDEX_MIN 0);
domain/ixh_append (an append of 10 entries writes at most a header and two
slots, at 1,000 entries and at 3,100; running out of room rewrites once;
the appended sidecar holds the hashes an open derives; a sidecar of
another count or file is not appended to); domain/ixh_held (the last
block's slot is never read; another root copied in place at the same size
and a sidecar cut in place are refused); domain/ixh_lazy (one slot written
over in place at the same size is refused; on macOS that case expects the
remount to be taken, because a private mapping is a snapshot there, so
the holder still reads the slots it summed at the open); domain/ixh_stale_open (a slot
that does not sum under an intact header is hashed anew at the open, an
append by another writer and the holder's remount are taken, and a sidecar
cut short under the holder makes its append write the sidecar whole); and
storage/sym_inplace.rfl (a hard link to the sidecar and an append under a
holder).
@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Rayforce targeted audit failed

This PR did not pass the required Rayforce audit gate. Fix the blocking findings below and push an update; the audit will rerun automatically.

Workflow run: https://github.com/RayforceDB/rayforce/actions/runs/46410735171

Rayforce targeted audit did not publish a report

The Rayforce audit workflow completed with conclusion: success.

Open the workflow run for logs: https://github.com/RayforceDB/rayforce/actions/runs/46410735171

RAYFORCE_AUDIT_VERDICT: FAIL

singaraiona added a commit that referenced this pull request Nov 30, 2026
…again

The dev -> master release pull request carries only commits that each
passed rayforce-audit on their own pull request before entering dev. Its
whole-range diff (998 files for v3.5.0) does not fit the fast gate, so the
audit failed it as inconclusive without finding a defect (#1955). It now
takes the merge-group path: ubuntu-latest, no checkout, no audit run, no
failure comment, success.

A release pull request is one whose base is master, whose head is dev, and
whose head repository is this one. A pull request runs the workflow from
its merge commit, so the release pull request picks this up as soon as it
is on dev. CONTRIBUTING.md and RELEASE.md say so.
…again (#1956)

The dev -> master release pull request carries only commits that each
passed rayforce-audit on their own pull request before entering dev. Its
whole-range diff (998 files for v3.5.0) does not fit the fast gate, so the
audit failed it as inconclusive without finding a defect (#1955). It now
takes the merge-group path: ubuntu-latest, no checkout, no audit run, no
failure comment, success.

A release pull request is one whose base is master, whose head is dev, and
whose head repository is this one. A pull request runs the workflow from
its merge commit, so the release pull request picks this up as soon as it
is on dev. CONTRIBUTING.md and RELEASE.md say so.
)

agg_contract/comoment_large_magnitude (#1850) sweeps 20 value shapes,
three widths with and without nulls, three key forms, six queries and two
worker counts over 120,000 rows. Under ASan it takes about 200 s on a fast
machine. On the release pull request's 4-core runners it passed the
parallel runner's 600 s per-test limit, so the full tier failed on the
ubuntu debug, clang-current and NDEBUG legs (#1955).

The sweep now runs as agg_contract/comoment_large_magnitude_a to _d, five
shapes each, with the data, queries and checks unchanged. Each part takes
46 to 54 s under ASan locally (168 s for all four in one process), and the
runner can hand the parts to different workers. A static assertion ties
the four ranges to CM_SHAPES.
@singaraiona
singaraiona merged commit 61a56d8 into master Nov 30, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants