[
 {
  "name": "concat",
  "category": "string",
  "signature": "concat(a, b) -> String | concat(a: List, b: List) -> List",
  "brief": "Concatenate strings, or join two lists (numeric list `+` is elementwise, so this is THE list concat).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "pad_left",
  "category": "string",
  "signature": "pad_left(s, width: Int, fill?: String) -> String",
  "brief": "Left-pad to `width` characters: pad_left(\"7\", 4, \"0\") = \"0007\". Default fill is a space.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "pad_right",
  "category": "string",
  "signature": "pad_right(s, width: Int, fill?: String) -> String",
  "brief": "Right-pad to `width` characters.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "split",
  "category": "string",
  "signature": "split(s: String, delim: String) -> List<String>",
  "brief": "Split a string on a delimiter into a list of substrings.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "replace",
  "category": "string",
  "signature": "replace(s: String, old: String, new: String) -> String",
  "brief": "Replace every occurrence of `old` with `new`.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "contains",
  "category": "string",
  "signature": "contains(haystack: String, needle: String) -> Bool | contains(list: List, x) -> Bool | contains(m: Map, key) -> Bool",
  "brief": "Substring test; list membership (structural equality); map key membership.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "starts_with",
  "category": "string",
  "signature": "starts_with(s: String, prefix: String) -> Bool",
  "brief": "True if `s` begins with `prefix`.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "ends_with",
  "category": "string",
  "signature": "ends_with(s: String, suffix: String) -> Bool",
  "brief": "True if `s` ends with `suffix`.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "lowercase",
  "category": "string",
  "signature": "lowercase(s: String) -> String",
  "brief": "Lowercase the string (non-strings are stringified first).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "uppercase",
  "category": "string",
  "signature": "uppercase(s: String) -> String",
  "brief": "Uppercase the string (non-strings are stringified first).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "trim",
  "category": "string",
  "signature": "trim(s: String) -> String | trim(s: String, chars: String) -> String",
  "brief": "Strip leading and trailing whitespace — or any of the characters in `chars` (Go's strings.Trim(s, cutset)).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "format",
  "category": "string",
  "signature": "format(fmt: String, args...) -> String",
  "brief": "printf subset: %d %s %f %.2f %8.2f %3d %-8s %05d %% — widths, precision (rounded half away from zero on the decimal text), left-align with '-', zero-pad with '0'.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "to_fixed",
  "category": "math",
  "signature": "to_fixed(x: Float, digits: Int) -> String",
  "brief": "x with exactly `digits` decimals (\"%.2f\"), rounded half away from zero on the decimal text: to_fixed(1.005, 2) = \"1.01\".",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "div_round",
  "category": "math",
  "signature": "div_round(n: Int, d: Int) -> Int",
  "brief": "Exact integer division rounded to the nearest, half away from zero (BigDecimal HALF_UP): div_round(10125 * 600, 120000) == 51, div_round(-7, 2) == -4. Money in cents stays exact.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "floor_div",
  "category": "math",
  "signature": "floor_div(a: Int, b: Int) -> Int",
  "brief": "Division rounded toward -∞ (Ruby/Python `//`): floor_div(-150, 100) = -2. `idiv` truncates toward zero; `/` is exact.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "mod",
  "category": "math",
  "signature": "mod(a: Int, b: Int) -> Int",
  "brief": "Modulo with the DIVISOR's sign (Ruby/Python `%`): mod(-150, 100) = 50. The `%` operator keeps the dividend's sign (C/Rust): -150 % 100 = -50.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "divmod",
  "category": "math",
  "signature": "divmod(a: Int, b: Int) -> [q, r]",
  "brief": "[floor_div(a, b), mod(a, b)] — q * b + r == a with 0 <= r < |b|.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "parse_date",
  "category": "time",
  "signature": "parse_date(s: \"YYYY-MM-DD\") -> {year, month, day, weekday, epoch_day}",
  "brief": "Strict ISO date to its parts (weekday 1 = Monday); raises kind \"date\" otherwise.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "add_days",
  "category": "time",
  "signature": "add_days(date: String, n: Int) -> String",
  "brief": "The ISO date n days later (negative n goes back), across month and year ends.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "add_months",
  "category": "time",
  "signature": "add_months(date: String, n: Int) -> String",
  "brief": "Same day n months later, clamped to the month's length (Ruby's Date >> n): add_months(\"2026-01-31\", 1) = \"2026-02-28\".",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "days_between",
  "category": "time",
  "signature": "days_between(a: String, b: String) -> Int",
  "brief": "Days from a to b (negative when b is earlier).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "months_between",
  "category": "time",
  "signature": "months_between(a: String, b: String) -> Int",
  "brief": "Whole months from a to b (\"YYYY-MM-DD\"), day-of-month aware like java.time MONTHS.between: 2026-01-15 → 2026-04-14 is 2, → 2026-04-20 is 3.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "days_in_month",
  "category": "time",
  "signature": "days_in_month(year: Int, month: Int) -> Int",
  "brief": "28–31, leap years included.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "fields",
  "category": "string",
  "signature": "fields(s: String) -> List<String>",
  "brief": "Split on any run of whitespace, no empty pieces (Go's strings.Fields; split(s, \" \") keeps empties).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "index_of",
  "category": "string",
  "signature": "index_of(s: String, sub: String) -> Int",
  "brief": "Character index of the first occurrence of `sub`, or -1 if absent.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "substring",
  "category": "string",
  "signature": "substring(s: String, start: Int, end: Int) -> String",
  "brief": "Character-based slice [start, end) — end is exclusive and clamped.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "escape_html",
  "category": "string",
  "signature": "escape_html(s: String) -> String",
  "brief": "Escape &, <, >, double and single quotes for safe HTML embedding.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "str_len",
  "category": "string",
  "signature": "str_len(s: String) -> Int",
  "brief": "Byte length of a string (cf. len(), which counts characters).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "str_at",
  "category": "string",
  "signature": "str_at(s: String, i: Int) -> Int",
  "brief": "Byte value at index `i`; errors if out of range.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "str_eq",
  "category": "string",
  "signature": "str_eq(a: String, b: String) -> Bool",
  "brief": "Exact string equality (fast path for [native] code).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "len",
  "category": "types",
  "signature": "len(x: String|List|Map) -> Int",
  "brief": "Characters of a string, elements of a list, or entries of a map.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "to_string",
  "category": "types",
  "signature": "to_string(x) -> String",
  "brief": "Render any value with its display formatting.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "to_int",
  "category": "types",
  "signature": "to_int(x) -> Int",
  "brief": "Convert to Int (floats truncate, strings parse, BigInt-exact); returns () on failure.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "to_float",
  "category": "types",
  "signature": "to_float(x) -> Float",
  "brief": "Convert to Float; returns () if a string fails to parse.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "to_json",
  "category": "types",
  "signature": "to_json(x) -> String",
  "brief": "Serialize a value as JSON (strings escaped, NaN/inf become null).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "from_json",
  "category": "types",
  "signature": "from_json(s: String) -> Any",
  "brief": "Parse a JSON string into a Map/List/scalar; maps and lists pass through. Invalid JSON RAISES (kind \"json\") — wrap LLM output in try { from_json(s) }.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "type_of",
  "category": "types",
  "signature": "type_of(x) -> String",
  "brief": "Type name: \"Int\" (any size), \"Float\", \"String\", \"Bool\", \"List\", \"Map\", \"Function\", \"Variant\", or \"Unit\".",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "is_type",
  "category": "types",
  "signature": "is_type(value: Map, type_name: String) -> Bool",
  "brief": "True if a record's `_type` field equals `type_name`.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "is_a",
  "category": "types",
  "signature": "is_a(value: Map, type_name: String) -> Bool",
  "brief": "Alias of is_type.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "abs",
  "category": "math",
  "signature": "abs(x: Int|Float) -> Int|Float",
  "brief": "Absolute value; errors on i64::MIN overflow.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "round",
  "category": "math",
  "signature": "round(x: Float) -> Int | round(x: Float, digits: Int) -> Float",
  "brief": "Round half away from zero to the nearest integer, or keep `digits` decimals: round(2.345, 2) = 2.35.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "floor",
  "category": "math",
  "signature": "floor(x: Float) -> Int",
  "brief": "Largest integer <= x.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "ceil",
  "category": "math",
  "signature": "ceil(x: Float) -> Int",
  "brief": "Smallest integer >= x.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "sqrt",
  "category": "math",
  "signature": "sqrt(x: Int|Float) -> Float",
  "brief": "Square root.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "sin",
  "category": "math",
  "signature": "sin(x: Int|Float) -> Float",
  "brief": "Sine (radians). Also cos, tan, atan, atan2(y, x).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "cos",
  "category": "math",
  "signature": "cos(x: Int|Float) -> Float",
  "brief": "Cosine (radians).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "tan",
  "category": "math",
  "signature": "tan(x: Int|Float) -> Float",
  "brief": "Tangent (radians).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "atan",
  "category": "math",
  "signature": "atan(x: Int|Float) -> Float",
  "brief": "Arc tangent.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "atan2",
  "category": "math",
  "signature": "atan2(y: Float, x: Float) -> Float",
  "brief": "Arc tangent of y/x, quadrant-aware.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "log",
  "category": "math",
  "signature": "log(x: Int|Float) -> Float",
  "brief": "Natural logarithm.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "ln",
  "category": "math",
  "signature": "ln(x: Int|Float) -> Float",
  "brief": "Alias of log (natural logarithm).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "exp",
  "category": "math",
  "signature": "exp(x: Int|Float) -> Float",
  "brief": "e raised to the power x.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "log10",
  "category": "math",
  "signature": "log10(x: Int|Float) -> Float",
  "brief": "Base-10 logarithm.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "pow",
  "category": "math",
  "signature": "pow(base: Int|Float, exp: Int|Float) -> Float",
  "brief": "base raised to exp (always a Float).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "min",
  "category": "math",
  "signature": "min(a, b) -> Int|Float | min(list: List) -> Int|Float",
  "brief": "Smaller of two numbers, or the minimum of a list (Float if any element is).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "max",
  "category": "math",
  "signature": "max(a, b) -> Int|Float | max(list: List) -> Int|Float",
  "brief": "Larger of two numbers, or the maximum of a list (Float if any element is).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "sum",
  "category": "math",
  "signature": "sum(list: List) -> Int|Float",
  "brief": "Sum of a list of numbers (Int-exact unless any element is a Float); 0 when empty.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "product",
  "category": "math",
  "signature": "product(list: List) -> Int|Float",
  "brief": "Product of a list of numbers; 1 when empty.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "avg",
  "category": "math",
  "signature": "avg(list: List) -> Int|Float",
  "brief": "Mean of a list of numbers, by the rule of `/`: avg([1, 2]) = 1.5, an exact mean of Ints stays an Int; () when empty.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "parse_int",
  "category": "math",
  "signature": "parse_int(s: String) -> Int | ()",
  "brief": "Strict integer parse: () unless the WHOLE string is an integer (\"1.5\", \"12abc\", \"\" → ()). to_int() is lenient and truncates.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "parse_float",
  "category": "math",
  "signature": "parse_float(s: String) -> Float | ()",
  "brief": "Strict float parse: () unless the whole string is a finite number.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "idiv",
  "category": "math",
  "signature": "idiv(a: Int, b: Int) -> Int",
  "brief": "Integer division truncating toward zero; errors on division by zero.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "clamp",
  "category": "math",
  "signature": "clamp(v, lo, hi) -> Int|Float",
  "brief": "Constrain v to [lo, hi]; errors if lo > hi.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "random",
  "category": "math",
  "signature": "random() -> Float | random(max: Int) -> Int | random(min: Int, max: Int) -> Int",
  "brief": "Time-seeded PRNG: float in [0,1), or int in [0,max) / [min,max).",
  "deterministic": false,
  "replay": "recorded by --record, replayed by soma replay"
 },
 {
  "name": "gcd",
  "category": "math",
  "signature": "gcd(a: Int, b: Int) -> Int",
  "brief": "Greatest common divisor (Euclid, absolute values).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "sqrt_int",
  "category": "math",
  "signature": "sqrt_int(n: Int) -> Int",
  "brief": "Integer square root; errors on negative input.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "pow_mod",
  "category": "math",
  "signature": "pow_mod(base: Int, exp: Int, m: Int) -> Int",
  "brief": "Modular exponentiation base^exp mod m; errors if m is zero.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "band",
  "category": "math",
  "signature": "band(a: Int, b: Int) -> Int",
  "brief": "Bitwise AND.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "bor",
  "category": "math",
  "signature": "bor(a: Int, b: Int) -> Int",
  "brief": "Bitwise OR.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "bxor",
  "category": "math",
  "signature": "bxor(a: Int, b: Int) -> Int",
  "brief": "Bitwise XOR.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "bnot",
  "category": "math",
  "signature": "bnot(a: Int) -> Int",
  "brief": "Bitwise NOT.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "shl",
  "category": "math",
  "signature": "shl(a: Int, n: Int) -> Int",
  "brief": "Exact left shift (a * 2^n), arbitrary precision like every Int op. For a 64-bit wrapping shift (xorshift), mask: band(shl(x, 13), 18446744073709551615).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "shr",
  "category": "math",
  "signature": "shr(a: Int, n: Int) -> Int",
  "brief": "Arithmetic shift right by n bits (wrapping).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "bit_test",
  "category": "math",
  "signature": "bit_test(a: Int, i: Int) -> Int",
  "brief": "1 if bit i of a is set, else 0.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "bit_set",
  "category": "math",
  "signature": "bit_set(a: Int, i: Int) -> Int",
  "brief": "a with bit i set.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "bit_clr",
  "category": "math",
  "signature": "bit_clr(a: Int, i: Int) -> Int",
  "brief": "a with bit i cleared.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "bit_next",
  "category": "math",
  "signature": "bit_next(a: Int, i: Int) -> Int",
  "brief": "Index of the lowest set bit at or above i, or -1 if none.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "bit_len",
  "category": "math",
  "signature": "bit_len(a: Int) -> Int",
  "brief": "Number of significant bits (estimated for BigInt).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "list",
  "category": "collection",
  "signature": "list(items...) -> List",
  "brief": "Build a list; list(existing_list, more...) appends to a copy.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "map",
  "category": "collection",
  "signature": "map(key, value, ...) -> Map | list |> map(x => expr) -> List",
  "brief": "Build a map from key-value pairs (even arg count), or — with a lambda — transform each list element.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "push",
  "category": "collection",
  "signature": "push(list: List, items...) -> List",
  "brief": "Return a new list with the items appended (the original is unchanged).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "nth",
  "category": "collection",
  "signature": "nth(list: List, i: Int) -> Any",
  "brief": "Element at index i, or () when out of bounds.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "reverse",
  "category": "collection",
  "signature": "reverse(list: List) -> List",
  "brief": "Return the list in reverse order.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "range",
  "category": "collection",
  "signature": "range(start: Int, end: Int, step?: Int) -> List<Int>",
  "brief": "Integers from start toward end (exclusive); optional step may be negative to count down.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "sort",
  "category": "collection",
  "signature": "sort(list: List, order?: \"desc\") -> List",
  "brief": "Sort scalars ascending (or \"desc\"); errors on incomparable element types.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "flatten",
  "category": "collection",
  "signature": "flatten(list: List) -> List",
  "brief": "Flatten one level of nested lists.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "zip",
  "category": "collection",
  "signature": "zip(a: List, b: List) -> List<{left, right}>",
  "brief": "Pair elements positionally; stops at the shorter list.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "enumerate",
  "category": "collection",
  "signature": "enumerate(list: List) -> List<{index, value}>",
  "brief": "Attach a 0-based index to each element.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "with",
  "category": "collection",
  "signature": "with(m: Map, key, value, ...) -> Map | with(list: List, i: Int, value) -> List",
  "brief": "Copy of the map with key-value pairs inserted, or copy of the list with element i replaced.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "without",
  "category": "collection",
  "signature": "without(m: Map, keys...) -> Map",
  "brief": "Return a copy of the map with the given keys removed.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "merge",
  "category": "collection",
  "signature": "merge(a: Map, b: Map) -> Map",
  "brief": "Copy of `a` with all entries of `b` inserted (b wins on conflict).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "join",
  "category": "collection",
  "signature": "join(list: List, sep: String) -> String | join(left: List, right: List, key) -> List",
  "brief": "Join list elements into a string — or, with two lists, an inner data join on `key`.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "filter_by",
  "category": "pipeline",
  "signature": "filter_by(rows: List<Map>, field, op: \">\"|\">=\"|\"<\"|\"<=\"|\"==\"|\"!=\", value) -> List<Map>",
  "brief": "Keep rows whose `field` compares true against `value` (op defaults to == with 3 args).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "fail",
  "category": "types",
  "signature": "fail(kind: String, detail?) -> never | fail(r: TryResult) -> never",
  "brief": "Raise a domain error. `try { f() }` yields {value, error, kind, detail}: branch on r.kind (\"not_found\", \"invalid_transition\", \"guard_failed\", \"invariant\", a `require … else Tag` tag, …); fail(r) re-raises a caught error unchanged.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "slice",
  "category": "collection",
  "signature": "slice(xs: List|String, start: Int, end?: Int) -> List|String",
  "brief": "Sub-list / substring, end exclusive; negative indexes count from the end (slice(xs, -2) = last two). Clamped, never raises.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "keys",
  "category": "collection",
  "signature": "keys(m: Map) -> List<String>",
  "brief": "Keys of a map VALUE, in insertion order. (Memory slots: slot.keys().)",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "values",
  "category": "collection",
  "signature": "values(m: Map) -> List",
  "brief": "Values of a map VALUE, in insertion order. (Memory slots: slot.values().)",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "entries",
  "category": "collection",
  "signature": "entries(m: Map) -> List<{key, value}>",
  "brief": "Key/value records of a map VALUE: for e in entries(m) { e.key  e.value }.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "sort_by",
  "category": "pipeline",
  "signature": "sort_by(rows: List<Map>, field, order?: \"desc\") -> List<Map> | sort_by(list, x => key, order?: \"desc\") -> List",
  "brief": "Stable sort by a field (numbers by value, strings lexicographically) or by a key function; a list key sorts on several keys: sort_by(rows, r => [0 - r.total, r.name]).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "top",
  "category": "pipeline",
  "signature": "top(rows: List, n: Int) -> List",
  "brief": "First n elements.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "bottom",
  "category": "pipeline",
  "signature": "bottom(rows: List, n: Int) -> List",
  "brief": "Last n elements.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "sum_by",
  "category": "pipeline",
  "signature": "sum_by(rows: List<Map>, field) -> Int",
  "brief": "Sum of a field across rows (integer arithmetic).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "avg_by",
  "category": "pipeline",
  "signature": "avg_by(rows: List<Map>, field) -> Int|Float",
  "brief": "Mean of a field; Int when whole, () on an empty list.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "min_by",
  "category": "pipeline",
  "signature": "min_by(rows: List<Map>, field) -> Map",
  "brief": "Row with the smallest integer value of `field`, or ().",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "max_by",
  "category": "pipeline",
  "signature": "max_by(rows: List<Map>, field) -> Map",
  "brief": "Row with the largest integer value of `field`, or ().",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "pluck",
  "category": "pipeline",
  "signature": "pluck(rows: List<Map>, field) -> List",
  "brief": "Extract one field from every row (missing fields become ()).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "group_by",
  "category": "pipeline",
  "signature": "group_by(rows: List<Map>, field) -> Map<String, List>",
  "brief": "Group rows into a map keyed by the field's stringified value.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "distinct",
  "category": "pipeline",
  "signature": "distinct(rows: List, field?) -> List",
  "brief": "Unique elements — or, with `field`, the unique VALUES of that field (distinct_by keeps the rows).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "distinct_by",
  "category": "pipeline",
  "signature": "distinct_by(rows: List<Map>, field: String) -> List<Map>",
  "brief": "The first row per distinct value of `field` (lodash uniqBy / dedup by id). Alias: unique_by.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "count_by",
  "category": "pipeline",
  "signature": "count_by(rows: List<Map>, field, value) -> Int",
  "brief": "Number of rows whose `field` stringifies equal to `value`.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "select",
  "category": "pipeline",
  "signature": "select(rows: List<Map>, fields...) -> List<Map>",
  "brief": "Project each row down to the named fields.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "agg",
  "category": "pipeline",
  "signature": "agg(rows: List<Map>, group_field, \"col:func\"...) -> List<Map>",
  "brief": "Group + aggregate: func is sum|avg|min|max|count; every group also gets a `count`.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "inner_join",
  "category": "pipeline",
  "signature": "inner_join(left: List<Map>, right: List<Map>, key) -> List<Map>",
  "brief": "Merge rows whose `key` matches in both lists (left fields win).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "left_join",
  "category": "pipeline",
  "signature": "left_join(left: List<Map>, right: List<Map>, key) -> List<Map>",
  "brief": "Keep every left row, merging matching right-row fields when found.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "filter",
  "category": "lambda",
  "signature": "filter(list: List, x => Bool) -> List",
  "brief": "Keep elements where the lambda returns truthy.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "find",
  "category": "lambda",
  "signature": "find(list: List, x => Bool) -> Any",
  "brief": "First element where the lambda is truthy, or ().",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "any",
  "category": "lambda",
  "signature": "any(list: List, x => Bool) -> Bool",
  "brief": "True if the lambda is truthy for at least one element.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "all",
  "category": "lambda",
  "signature": "all(list: List, x => Bool) -> Bool",
  "brief": "True if the lambda is truthy for every element (true on empty).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "count",
  "category": "lambda",
  "signature": "count(list: List, x => Bool) -> Int",
  "brief": "Number of elements where the lambda is truthy.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "reduce",
  "category": "lambda",
  "signature": "reduce(list: List, initial, p => expr) -> Any",
  "brief": "Fold the list; the lambda receives {acc, val} and returns the next acc.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "print",
  "category": "io",
  "signature": "print(args...) -> ()",
  "brief": "Print arguments space-separated, then a newline.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "read_file",
  "category": "io",
  "signature": "read_file(path: String) -> String | {error}",
  "brief": "Read a file as a string; returns {error: ...} on failure.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "write_file",
  "category": "io",
  "signature": "write_file(path: String, content) -> Bool | {error}",
  "brief": "Write content (stringified) to a file; true on success.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "read_csv",
  "category": "io",
  "signature": "read_csv(path: String) -> List<Map> | {error}",
  "brief": "Parse a CSV with header row into maps; cells auto-typed to Int/Float/String.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "write_csv",
  "category": "io",
  "signature": "write_csv(path: String, rows: List<Map>) -> Bool | {error}",
  "brief": "Write rows as CSV using the first row's keys as the header.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "read_files",
  "category": "io",
  "signature": "read_files(dir: String, count: Int) -> List<{path, content}>",
  "brief": "Read up to `count` files from a directory.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "par_read_files",
  "category": "io",
  "signature": "par_read_files(dir: String, count: Int) -> List<{path, content}>",
  "brief": "Thread-parallel variant of read_files.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "word_count",
  "category": "io",
  "signature": "word_count(text: String | docs: List) -> Map<String, Int>",
  "brief": "Lowercased word frequency of a string or of {content} docs (Rust-speed).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "par_word_count",
  "category": "io",
  "signature": "par_word_count(docs: List) -> Map<String, Int>",
  "brief": "Thread-parallel variant of word_count over a list.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "load_template",
  "category": "template",
  "signature": "load_template(path: String, key, value, ...) -> String",
  "brief": "Read a file and substitute each {key} placeholder with its value.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "load",
  "category": "template",
  "signature": "load(path: String, key, value, ...) -> String",
  "brief": "Alias of load_template.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "include",
  "category": "template",
  "signature": "include(path: String, key, value, ...) -> String",
  "brief": "Alias of load_template.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "render",
  "category": "template",
  "signature": "render(template: String, key, value, ...) -> String",
  "brief": "Substitute {key} placeholders in an in-memory template string.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "render_each",
  "category": "template",
  "signature": "render_each(rows: List<Map>, template: String) -> String",
  "brief": "Render the template once per row, substituting {field} from each map.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "html",
  "category": "web",
  "signature": "html(body) -> Response | html(status: Int, body) -> Response",
  "brief": "text/html response; auto-injects HTMX on full pages that use hx- attributes.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "response",
  "category": "web",
  "signature": "response(status: Int, body, header_key, header_value, ...) -> Response",
  "brief": "Response with explicit status, body, and optional headers.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "redirect",
  "category": "web",
  "signature": "redirect(url: String) -> Response",
  "brief": "302 redirect to `url`.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "sse",
  "category": "web",
  "signature": "sse(streams...) -> Response",
  "brief": "Open a Server-Sent-Events connection subscribed to the named streams.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "publish",
  "category": "web",
  "signature": "publish(stream: String, data) -> ()",
  "brief": "Push data to a runtime-chosen SSE stream name on the event bus.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "http_get",
  "category": "http",
  "signature": "http_get(url: String, opts?: {timeout, max_bytes, headers}) -> Map|List|String",
  "brief": "GET a URL. 2xx: the body (JSON parsed). Never raises: otherwise {error, kind, status, body} — kind http_status (status + the upstream body), timeout, refused or network. timeout defaults to 30000 ms.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "http_post",
  "category": "http",
  "signature": "http_post(url: String, body, opts?: {timeout, max_bytes, headers}) -> Map|List|String",
  "brief": "POST body (a Map/List is sent as JSON, a String as is). Same result shape and default timeout as http_get. Also http_put, http_patch, http_delete(url, opts?).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "http_put",
  "category": "http",
  "signature": "http_put(url: String, body, opts?) -> Map|List|String",
  "brief": "PUT; same shape as http_post.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "http_patch",
  "category": "http",
  "signature": "http_patch(url: String, body, opts?) -> Map|List|String",
  "brief": "PATCH; same shape as http_post.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "http_delete",
  "category": "http",
  "signature": "http_delete(url: String, opts?) -> Map|List|String",
  "brief": "DELETE; same shape as http_get.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "ws_connect",
  "category": "http",
  "signature": "ws_connect(url: String) -> Map",
  "brief": "Open a WebSocket connection; incoming messages dispatch as signals.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "ws_send",
  "category": "http",
  "signature": "ws_send(msg) -> ()",
  "brief": "Send a message on the current WebSocket connection; errors if not connected.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "link",
  "category": "http",
  "signature": "link(addr: \"host:port\") -> ()",
  "brief": "Open a TCP signal-bus link to a peer node.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "subscribe",
  "category": "http",
  "signature": "subscribe(url: String) -> ()",
  "brief": "Subscribe to a remote event stream; events dispatch as signals.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "now",
  "category": "time",
  "signature": "now() -> Int",
  "brief": "Current Unix timestamp in seconds.",
  "deterministic": false,
  "replay": "recorded by --record, replayed by soma replay"
 },
 {
  "name": "now_ms",
  "category": "time",
  "signature": "now_ms() -> Int",
  "brief": "Current Unix timestamp in milliseconds.",
  "deterministic": false,
  "replay": "recorded by --record, replayed by soma replay"
 },
 {
  "name": "today",
  "category": "time",
  "signature": "today() -> String",
  "brief": "Today's date as \"YYYY-MM-DD\" (UTC).",
  "deterministic": false,
  "replay": "recorded by --record, replayed by soma replay"
 },
 {
  "name": "format_date",
  "category": "time",
  "signature": "format_date(ts: Int) -> String",
  "brief": "Format a Unix-seconds timestamp as \"YYYY-MM-DD\" (UTC).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "sleep",
  "category": "time",
  "signature": "sleep(ms: Int) -> ()",
  "brief": "Block the current handler for `ms` milliseconds.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "next_id",
  "category": "state",
  "signature": "next_id() -> Int",
  "brief": "Monotonic per-cell counter; REQUIRES a memory slot — without one it returns 1 on every call.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "transition",
  "category": "state",
  "signature": "transition(id, target_state: String) -> {id, from, to}",
  "brief": "Move instance `id` to `target_state` (read the new state with get_status(id)); raises kind \"invalid_transition\" with the valid targets, or \"guard_failed\". Rolled back if the handler later fails.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "get_status",
  "category": "state",
  "signature": "get_status(id) -> String",
  "brief": "Current state of instance `id` — the INITIAL state when `id` was never transitioned (an unknown id looks like a fresh instance; use has_state(id) to tell them apart).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "has_state",
  "category": "state",
  "signature": "has_state(id) -> Bool",
  "brief": "True when instance `id` was transitioned at least once (a recorded state exists). get_status(id) alone cannot distinguish an unknown id from a fresh one.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "valid_transitions",
  "category": "state",
  "signature": "valid_transitions(id) -> List<String>",
  "brief": "States reachable from instance `id`'s current state.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "remember",
  "category": "memory",
  "signature": "remember(key, value) -> ()",
  "brief": "Persist a value in the cell's agent memory slot.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "recall",
  "category": "memory",
  "signature": "recall(key: String) -> Any",
  "brief": "Fetch a remembered value from any storage slot, or ().",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "append",
  "category": "memory",
  "signature": "slot.append(value) -> ()",
  "brief": "Memory-slot method: append a value to a list-backed slot (alias: slot.push).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "think",
  "category": "agent",
  "signature": "think(prompt: String, system?: String, opts?: {max_tokens, timeout}) -> String",
  "brief": "Call the configured LLM with tool-calling, multi-turn context, and budget enforcement.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "think_json",
  "category": "agent",
  "signature": "think_json(prompt: String, system?: String, opts?: {max_tokens, timeout}) -> Map",
  "brief": "Like think(), but parses the response as JSON into a Map.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "delegate",
  "category": "agent",
  "signature": "delegate(cell: String, signal: String, args...) -> Any",
  "brief": "Invoke another cell's handler and return its result.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "set_budget",
  "category": "agent",
  "signature": "set_budget(max_tokens: Int) -> ()",
  "brief": "Hard cap on LLM tokens; think() fails once exhausted.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "tokens_used",
  "category": "agent",
  "signature": "tokens_used() -> Int",
  "brief": "LLM tokens consumed since the budget was set.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "tokens_remaining",
  "category": "agent",
  "signature": "tokens_remaining() -> Int",
  "brief": "Tokens left in the budget, or -1 if unlimited.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "trace",
  "category": "agent",
  "signature": "trace() -> List",
  "brief": "Structured execution log: every think(), tool call, and approval.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "clear_trace",
  "category": "agent",
  "signature": "clear_trace() -> ()",
  "brief": "Empty the agent trace log.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "clear_context",
  "category": "agent",
  "signature": "clear_context() -> ()",
  "brief": "Reset the multi-turn LLM conversation history.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "approve",
  "category": "agent",
  "signature": "approve(action: String) -> Bool",
  "brief": "Human-in-the-loop gate. Answered by `mock approve true|false` in tests, by SOMA_APPROVE=always|never, or by a person at the terminal under `soma run`; otherwise (e.g. under soma serve) it RAISES kind \"approval_required\" — it never approves on its own.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "matrix",
  "category": "linalg",
  "signature": "matrix(\"1 2; 3 4\") -> List<List<Float>>",
  "brief": "MATLAB-style matrix literal: ';' separates rows, whitespace/',' separates entries.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "mat",
  "category": "linalg",
  "signature": "mat(rows: Int, cols: Int, values: List<Float>) -> List<List<Float>>",
  "brief": "Reshape a flat list into an r×c matrix; errors if the count mismatches.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "reshape",
  "category": "linalg",
  "signature": "reshape(values, rows: Int, cols: Int) -> Matrix",
  "brief": "Lay a flat list or matrix out row-major as rows×cols; also m.reshape(r,c).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "transpose",
  "category": "linalg",
  "signature": "transpose(m: Matrix) -> Matrix",
  "brief": "Transpose; also m.transpose().",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "shape",
  "category": "linalg",
  "signature": "shape(m) -> List<Int>",
  "brief": "[rows, cols] for a matrix, [n] for a vector; also m.shape().",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "matmul",
  "category": "linalg",
  "signature": "matmul(a: Matrix, b: Matrix) -> Matrix",
  "brief": "Matrix product (also the `*` operator on two matrices); inner dims must agree.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "det",
  "category": "linalg",
  "signature": "det(m: Matrix) -> Float",
  "brief": "Determinant of a square matrix (LU with partial pivoting).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "diag_sum",
  "category": "linalg",
  "signature": "diag_sum(m: Matrix) -> Float",
  "brief": "Matrix trace: sum of the diagonal.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "identity",
  "category": "linalg",
  "signature": "identity(n: Int) -> Matrix",
  "brief": "n×n identity matrix (alias of eye).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "scale",
  "category": "linalg",
  "signature": "scale(m: Matrix, k) -> Matrix",
  "brief": "Scalar-multiply every entry (also `k * m`).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "flatten_mat",
  "category": "linalg",
  "signature": "flatten_mat(m: Matrix) -> List<Float>",
  "brief": "Flatten a matrix to a row-major vector.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "rows",
  "category": "linalg",
  "signature": "rows(r1: List<Float>, r2: List<Float>, ...) -> List<List<Float>>",
  "brief": "Build a matrix from row vectors.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "cols",
  "category": "linalg",
  "signature": "cols(c1: List<Float>, c2: List<Float>, ...) -> List<List<Float>>",
  "brief": "Build a matrix from column vectors (transposes).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "eye",
  "category": "linalg",
  "signature": "eye(n: Int) -> List<List<Float>>",
  "brief": "n×n identity matrix.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "zeros",
  "category": "linalg",
  "signature": "zeros(r: Int, c: Int) -> List<List<Float>>",
  "brief": "r×c matrix of zeros.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "ones",
  "category": "linalg",
  "signature": "ones(r: Int, c: Int) -> List<List<Float>>",
  "brief": "r×c matrix of ones.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "diag",
  "category": "linalg",
  "signature": "diag(values: List<Float>) -> List<List<Float>>",
  "brief": "Square diagonal matrix from a list.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "to_sampled",
  "category": "linalg",
  "signature": "to_sampled(A: List<List<Float>>, opts?: {max_rows, max_cols}) -> Map",
  "brief": "Build a BST-backed length-squared sampling handle (Tang); O(log n) per sample after.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "sample_row",
  "category": "linalg",
  "signature": "sample_row(A) -> Map",
  "brief": "Draw one row index by ℓ²-norm importance sampling (time-seeded PRNG).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "drop_sampled",
  "category": "linalg",
  "signature": "drop_sampled(handle: Map) -> Bool",
  "brief": "Free a to_sampled() registry entry; true if it existed.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "importance_sample_rows",
  "category": "linalg",
  "signature": "importance_sample_rows(A, opts: {samples}) -> Map",
  "brief": "Sample rows by squared-norm importance (time-seeded PRNG).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "svd_lowrank",
  "category": "linalg",
  "signature": "svd_lowrank(A, opts: {row_samples, col_samples, rank, max_dim}) -> Map",
  "brief": "Sublinear randomized low-rank SVD with declared sampling bounds.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "regress_sgd",
  "category": "linalg",
  "signature": "regress_sgd(A, b: List<Float>, opts: {eps, lambda, max_iter, max_dim}) -> Map",
  "brief": "Ridge regression via stochastic gradient descent with declared bounds.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "clean_covariance",
  "category": "linalg",
  "signature": "clean_covariance(returns: List<List<Float>>, opts: {method: \"rie\"|\"clip\"|\"raw\", eta, center, max_assets, max_obs}) -> Map",
  "brief": "RMT (Bouchaud-Potters) covariance cleaning; .matrix is the cleaned N×N.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "impact_sqrt",
  "category": "linalg",
  "signature": "impact_sqrt(qty: Float, daily_volume: Float, sigma: Float, opts?: {Y}) -> Map",
  "brief": "Bouchaud square-root market-impact law; .bps is expected slippage.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "quantile",
  "category": "linalg",
  "signature": "quantile(values: List<Float>, q: Float) -> Float",
  "brief": "q-th quantile with linear interpolation between the two nearest sorted values (numpy's default): quantile(xs, 0.5) == median(xs).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "median",
  "category": "math",
  "signature": "median(xs: List) -> Int | Float",
  "brief": "Middle value of the sorted list (mean of the two middles for even n, exact Int when it is one) — statistics.median.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "pstdev",
  "category": "math",
  "signature": "pstdev(xs: List) -> Float",
  "brief": "Population standard deviation (divide by n) — statistics.pstdev.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "stddev",
  "category": "math",
  "signature": "stddev(xs: List) -> Float",
  "brief": "Same as pstdev (population).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "stdev",
  "category": "math",
  "signature": "stdev(xs: List) -> Float",
  "brief": "SAMPLE standard deviation (divide by n - 1) — statistics.stdev / pandas .std(); needs two values.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "variance",
  "category": "math",
  "signature": "variance(xs: List) -> Float",
  "brief": "SAMPLE variance (divide by n - 1) — statistics.variance; pvariance is the population form.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "pvariance",
  "category": "math",
  "signature": "pvariance(xs: List) -> Float",
  "brief": "Population variance (divide by n) — statistics.pvariance.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "chr",
  "category": "string",
  "signature": "chr(n: Int) -> String",
  "brief": "The character with code point n: chr(65) == \"A\".",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "ord",
  "category": "string",
  "signature": "ord(s: String) -> Int",
  "brief": "Code point of the first character: ord(\"A\") == 65.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "var_historical",
  "category": "linalg",
  "signature": "var_historical(returns: List<Float>, opts?: {alpha, max_obs}) -> Float",
  "brief": "Historical Value-at-Risk — no distributional assumption.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "expected_shortfall_historical",
  "category": "linalg",
  "signature": "expected_shortfall_historical(returns: List<Float>, opts?: {alpha, max_obs}) -> Float",
  "brief": "Historical expected shortfall (CVaR) beyond the VaR threshold.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "var_gaussian",
  "category": "linalg",
  "signature": "var_gaussian(returns: List<Float>, opts?: {alpha, mu, sigma}) -> Float",
  "brief": "Gaussian VaR assuming N(mu, sigma^2); moments inferred unless overridden.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "_coalesce",
  "category": "internal",
  "signature": "_coalesce(a, b) -> Any",
  "brief": "Desugared form of `a ?? b`: returns b only when a is ().",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "regex_count",
  "category": "string",
  "signature": "regex_count(text: String, pattern: String) -> Int",
  "brief": "Number of non-overlapping matches (Rust regex syntax). Same in [native] (pattern must be a literal there).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "regex_match",
  "category": "string",
  "signature": "regex_match(text: String, pattern: String) -> Int",
  "brief": "1 when the pattern matches anywhere in text, else 0.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "regex_replace",
  "category": "string",
  "signature": "regex_replace(text: String, pattern: String, replacement: String) -> String",
  "brief": "Replace every match; $1 refers to the first capture group.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "read_stdin",
  "category": "io",
  "signature": "read_stdin() -> String",
  "brief": "The whole standard input (for `soma run` filters).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "write_str",
  "category": "io",
  "signature": "write_str(s: String) -> Int",
  "brief": "Write s to stdout without a newline; returns the byte count.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "buffer",
  "category": "native",
  "signature": "buffer(n: Int) -> Buf   [native] only",
  "brief": "Array of n Ints, zeroed. Random access with buf_get / buf_set. Not available in interpreted handlers.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "buf_get",
  "category": "native",
  "signature": "buf_get(b: Buf, i: Int) -> Int   [native] only",
  "brief": "Read b[i].",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "buf_set",
  "category": "native",
  "signature": "buf_set(b: Buf, i: Int, v: Int) -> ()   [native] only",
  "brief": "Write b[i] = v.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "buffer_f",
  "category": "native",
  "signature": "buffer_f(n: Int) -> BufF   [native] only",
  "brief": "Array of n Floats, zeroed (buf_get_f / buf_set_f).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "buf_get_f",
  "category": "native",
  "signature": "buf_get_f(b: BufF, i: Int) -> Float   [native] only",
  "brief": "Read b[i].",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "buf_set_f",
  "category": "native",
  "signature": "buf_set_f(b: BufF, i: Int, v: Float) -> ()   [native] only",
  "brief": "Write b[i] = v.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "hashmap",
  "category": "native",
  "signature": "hashmap() -> HMap   [native] only",
  "brief": "Int → Int hash map (hm_get / hm_set / hm_inc / hm_len / hm_has).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "hm_get",
  "category": "native",
  "signature": "hm_get(m: HMap, k: Int) -> Int   [native] only",
  "brief": "Value at k, 0 when absent.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "hm_set",
  "category": "native",
  "signature": "hm_set(m: HMap, k: Int, v: Int) -> ()   [native] only",
  "brief": "m[k] = v.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "hm_inc",
  "category": "native",
  "signature": "hm_inc(m: HMap, k: Int) -> ()   [native] only",
  "brief": "m[k] += 1 (inserting 1).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "hm_len",
  "category": "native",
  "signature": "hm_len(m: HMap) -> Int   [native] only",
  "brief": "Number of keys.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "hm_has",
  "category": "native",
  "signature": "hm_has(m: HMap, k: Int) -> Bool   [native] only",
  "brief": "Whether k is present.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "strbuf",
  "category": "native",
  "signature": "strbuf() -> SBuf   [native] only",
  "brief": "Growable string builder (sb_push / sb_push_int / sb_push_char / sb_len / sb_finish).",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "sb_push",
  "category": "native",
  "signature": "sb_push(b: SBuf, s: String) -> ()   [native] only",
  "brief": "Append a string.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "sb_push_int",
  "category": "native",
  "signature": "sb_push_int(b: SBuf, n: Int) -> ()   [native] only",
  "brief": "Append an Int's decimal digits.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "sb_push_char",
  "category": "native",
  "signature": "sb_push_char(b: SBuf, c: Int) -> ()   [native] only",
  "brief": "Append one character by code point.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "sb_len",
  "category": "native",
  "signature": "sb_len(b: SBuf) -> Int   [native] only",
  "brief": "Bytes so far.",
  "deterministic": true,
  "replay": "pure"
 },
 {
  "name": "sb_finish",
  "category": "native",
  "signature": "sb_finish(b: SBuf) -> String   [native] only",
  "brief": "The built String.",
  "deterministic": true,
  "replay": "pure"
 }
]