# GizStack ## Start - [Gizlang documentation](https://gizstack.com/docs.md): The Gizlang documentation: every page, by what you want to do. - [Tour](https://gizstack.com/docs/tour.md): Each part of Gizlang in one short program that runs: the language, tasks, GizDB, GizWeb, tensors, storage, devices, AI, JavaScript and Python. - [Start](https://gizstack.com/docs/start.md): Install Gizlang, then make, run, test and build a first program, in a few minutes. ## Guides - [Gizlang language guide](https://gizstack.com/docs/guides/language.md): Learn Gizlang if you know TypeScript, JavaScript or Go: a first program, then a tour of the language. - [Use the Gizlang command line](https://gizstack.com/docs/guides/command-line.md): The daily work with the giz command: make a project, run it, check it, test it and build it. - [Packages](https://gizstack.com/docs/guides/packages.md): Gizlang packages: the manifest, pins, dependencies, publication to the GizStack registry, offline validation and npm packages. - [Build web apps with GizWeb](https://gizstack.com/docs/guides/web.md): Build a server-rendered web app with GizWeb. - [Model your data](https://gizstack.com/docs/guides/model.md): Model data in Gizlang with one record type for the table, typed queries, forms and views. - [Use GizDB](https://gizstack.com/docs/guides/data.md): Use GizDB, the database of GizStack, in a program or as a server. - [Vector search in GizDB](https://gizstack.com/docs/guides/vector.md): Store embeddings, index them and find the nearest rows with SQL in GizDB, with the pgvector interface, for data in memory or larger than memory. - [Machine learning in GizDB](https://gizstack.com/docs/guides/sql-ml.md): Train, deploy and use machine learning models with SQL in GizDB, with the pgml interface of PostgresML. - [Tensors, GPU kernels and AI models](https://gizstack.com/docs/guides/compute.md): Compute with tensors on the CPU and the GPU, write your own GPU kernels as tile programs, take gradients, run language models, and generate images and video. - [Run AI models on your computer](https://gizstack.com/docs/guides/ai.md): Chat with a language model, make images and serve the OpenAI API on your own computer, by model name. The first use downloads the weights. - [Use GizStack storage from the command line](https://gizstack.com/docs/guides/storage.md): Use GizStack storage from the command line, against a local range or gizstack.com. - [JavaScript, TypeScript and Python](https://gizstack.com/docs/guides/javascript-python.md): Run JavaScript, TypeScript and Python programs on the Gizlang VM, with npm packages, Node's modules and Python's standard library. - [Use your Giz account from the command line](https://gizstack.com/docs/guides/giz-account.md): Sign in to your Giz account, then use its models, media jobs, Drive, tables, Computers, Apps, plugins and Agents, and its MCP server, from the giz command. - [Move to GizStack](https://gizstack.com/docs/guides/migrate.md): Move to GizStack from Node.js or Bun, Next.js, PostgreSQL, Redis, S3, Vercel or Supabase, with the equivalent of each thing you use today. ## Operations - [Operate the GizDB server](https://gizstack.com/docs/operations/gizdb-server.md): Install the GizDB server and operate it on one Linux machine. - [Operate GizStack storage](https://gizstack.com/docs/operations/storage-range.md): Run GizStack storage on your own machines, from one local disk to more nodes, and know where each byte is. ## Reference - [Reference](https://gizstack.com/docs/reference.md): The Gizlang reference: the language, the differences from TypeScript, GHTML, the settings, the command line, the standard library and the libraries. - [Gizlang language reference](https://gizstack.com/docs/reference/language.md): The Gizlang language specification: the meaning of every form of a .giz file. - [Gizlang for TypeScript programmers](https://gizstack.com/docs/reference/typescript.md): Every difference between Gizlang and TypeScript, on one page. - [GHTML](https://gizstack.com/docs/reference/ghtml.md): The GHTML markup language: pages, components, state, events, styles and languages in .ghtml files. - [Command line](https://gizstack.com/docs/reference/cli.md): Every gizlang command with its options, examples and exit status, from the toolchain's command table. - [gizdb](https://gizstack.com/docs/reference/gizdb.md): The database: SQL, typed models, transactions, vectors and the PostgreSQL-protocol server. - [gizfs](https://gizstack.com/docs/reference/gizfs.md): Storage: buckets and objects, embedded in a program or on a range of machines. - [gizhw](https://gizstack.com/docs/reference/gizhw.md): Devices: GPUs, NPUs, cameras, audio, video codecs, sensors and the platform. - [gizml](https://gizstack.com/docs/reference/gizml.md): Tensors on the CPU and GPU, gradients, GPU kernels, and language, image and video models. - [gizweb](https://gizstack.com/docs/reference/gizweb.md): Server-rendered web apps: pages, models, actions, tables and live views. - [SDK modules](https://gizstack.com/docs/reference/sdk.md): Every gizlang:NAME module with its public declarations. - [Settings](https://gizstack.com/docs/reference/settings.md): Every environment variable that Gizlang, its libraries and its tools read, with its effect and the page that explains it. - [SQL functions](https://gizstack.com/docs/reference/sql.md): Every SQL function that GizDB runs, by subject, with its arguments and the database whose function it follows. ## Standard library - [gizlang:acme](https://gizstack.com/docs/reference/sdk/acme.md): ACME v2 (RFC 8555). One account and one domain set per private Dir. Mount challenge(dir, request) on the caller's public HTTP port 80 before certificate() runs. No listener, HTTP codec or JSON codec is owned here. - [gizlang:bench](https://gizstack.com/docs/reference/sdk/bench.md): benchmarks as data. A suite declares its items (the rows of published tables), its tables (groups, with their method), its goals, and one function that measures the chosen items at a size. A suite program is `Bench.main(sys, suite)`; that is its whole command line: giz SUITE.giz list the items giz SUITE.giz run [ITEM...] [--size S] [--out FILE] giz SUITE.giz show the published results of the suite giz SUITE.giz compare [ITEM...] [--size S] a run beside the published values giz SUITE.giz record [ITEM...] a full run merged into the published file (a source checkout) ITEM is an item id, with or without the suite id before it. S is `quick` (seconds), `std` (the default) or `full` (the size that was published). A run keeps what it measured item by item, so a stopped run is still of use. A measure can run a program of any language: the program prints one line `benchITEMSUBJECTVALUE` for each value (`report` writes it), and `program` runs it and reads the lines (`reported`). A tool that is not on the machine skips its items with the way to get it (`needs`). A published file (`gizlang.bench.v1`, results/AREA/NAME.json in the published results folder) is the one place a measurement is written: the site, the READMEs and `compare` read it. A row holds the value of each subject (Gizlang and the tools it is compared with), when and where it was measured, and whether a program wrote it (`run`) or it was moved in from a page by hand (`migrated`). `text` is shown instead of the number when a cell is not a single number. - [gizlang:capability](https://gizstack.com/docs/reference/sdk/capability.md): The kernel and library capabilities this process has, probed when asked. A name is available when its probe succeeds. `require` is the startup check: a configured capability that is missing, or a name that is not known, fails it with the name in the message, and nothing falls back. CPU features are in gizlang:machine (Machine.has). - [gizlang:collections](https://gizstack.com/docs/reference/sdk/collections.md): gizlang:collections reference. - [gizlang:compress](https://gizstack.com/docs/reference/sdk/compress.md): DEFLATE (RFC 1951), gzip (RFC 1952) and CRC checksums, written in Gizlang. deflate finds repeats greedily in a two-way hash table of 4-byte prefixes over a 32 KB window (tokenize), counts the symbols, and writes one block with Huffman codes built for them (dynamic) or DEFLATE's fixed codes, whichever is shorter. Both are canonical codes from lengths, built by the same functions. The tables are constant Vec literals. The checksums run in the runtime (gizlang_crc32_update), on the CPU's CRC instructions. - [gizlang:core](https://gizstack.com/docs/reference/sdk/core.md): Values that may fail or be absent. `try` unwraps the first case and returns any other case from the enclosing function. - [gizlang:crypto](https://gizstack.com/docs/reference/sdk/crypto.md): Modern cryptographic primitives in Gizlang (RFC 5869/8439/7748/8032). SHA-256 blocks run in the runtime on the CPU's SHA instructions where it has them, and AES-GCM in libcrypto. Length contracts are public. Secret arithmetic uses fixed loops and masks. - [gizlang:csv](https://gizstack.com/docs/reference/sdk/csv.md): CSV retains bytes and reuses one record's range table: no field copies in next/field/integer. text alone decodes; number reads the range in place (Text.decimalPrefix). Field ranges refer to the caller's input. - [gizlang:erasure](https://gizstack.com/docs/reference/sdk/erasure.md): Erasure codes over GF(2^8) (polynomial 0x11D): Reed-Solomon and locally repairable codes (LRC). DATA pieces of equal length give parity pieces; any DATA independent pieces give back each lost one. An LRC adds to each group of data pieces a local parity (their XOR), so one lost piece of a group is rebuilt from its group alone, and global parities (Cauchy rows) for more losses. The products run 32 bytes a step: each nibble one table lookup (pshufb, NEON tbl). - [gizlang:functions](https://gizstack.com/docs/reference/sdk/functions.md): compiled units that a running program loads: new Function sources (JavaScript) and kernels (Gizlang functions over columns, which a database generates for a statement). The runtime finds the unit of a source by its sha256 in GIZLANG_CACHE/functions, or has `$GIZLANG_CLI function HASH` compile it, and loads it into this process. The unit's SDK calls bind to this program's SDK. - [gizlang:gateway](https://gizstack.com/docs/reference/sdk/gateway.md): the front door of a host. One program takes the HTTP and HTTPS ports (HTTP/1.1, HTTP/2 and HTTP/3), picks a route for each request by its host and path, and relays the request to the route's upstreams (Http.Balancer: turns, failover, streamed bodies, WebSocket and other upgrades). A JSON file describes the routes and the certificates; the program reads it again when the file changes, and reloads a certificate when its file changes, with no restart and no dropped connection. It counts every request in gizlang:metrics (GET /metrics on its own port) and writes one JSON line for each to an access log. { "http": 80, "https": 443, "host": "", "metrics": "127.0.0.1:18082", "accessLog": "/var/log/gateway/access.log", "challenges": "/var/lib/gateway/challenges", "headers": { "strict-transport-security": "max-age=31536000; includeSubDomains" }, "certs": [ { "names": ["example.com", "*.example.com"], "chain": "/etc/gateway/a.crt", "key": "/etc/gateway/a.key" }, { "names": ["api.example.com"], "acme": { "folder": "/var/lib/gateway/api", "contact": "mailto:ops@example.com" } } ], "routes": [ { "name": "site", "hosts": ["example.com", "*.example.com"], "prefix": "/", "stripPrefix": false, "upstreams": ["http://10.0.0.2:8800"], "standby": ["http://10.0.0.3:8800"], "holdMs": 2000, "keepHost": true, "headers": {}, "upstreamHeaders": {}, "priority": 0, "responseMs": 120000, "pathRegex": "^/v[0-9]+/", "hostRegex": "^app[0-9]+\\.example\\.com$", "basicAuth": { "realm": "private", "users": ["alice:$apr1$salt$hash", "bob:{SHA}base64sha1"] }, "retry": { "attempts": 2, "statuses": [502] }, "errors": { "statuses": [502, 503, 504], "upstream": "http://127.0.0.1:18089" } }, { "name": "old", "hosts": ["old.example.com"], "redirect": { "to": "https://example.com/", "status": 301 } } ] } A host is exact or `*.suffix`; no hosts means any. A prefix matches a whole path segment ("/api" matches "/api" and "/api/x"). Of the routes that match, an exact host beats a wildcard, a wildcard beats none, and then the longer prefix wins. The first certificate answers a client that names no host or one no certificate has; the others answer for their names (the server name of the handshake). `pathRegex` and `hostRegex` must also match the request path (without its query) and the host (lower case, without a port). `basicAuth` answers 401 unless the request has a listed user and password; a user line is an htpasswd line with an `$apr1$`, `$1$`, `$2y$` (bcrypt) or `{SHA}` hash (a bcrypt hash `$2y$` is checked once per password and remembered). A higher `priority` beats every other rule. `standby` upstreams get a request only when no upstream can take it (a refused connection passes on any request, since nothing was sent). `responseMs` is the longest wait for an upstream's response head. `upstreamHeaders` are set on each request the route sends on, in place of any copy the client sent (a key the upstream checks). `retry` sends an idempotent request again, up to `attempts` more times, when an upstream answers with one of the `statuses`. `errors` answers with the page that `upstream` serves at "/", under the upstream's own status, when that status is listed or no upstream can be reached (502). A route with `redirect` has no upstreams: it answers with the status (302 unless given) and the Location `to`. A top-level `limit` { "requests": 600, "windowMs": 60000, "proxies": ["10.0.0.1"] } answers 429 with Retry-After to a client over it, before any route. A request from one of the `proxies` keeps the scheme of its X-Forwarded-Proto (a TLS proxy in front of a plain port). - [gizlang:gguf](https://gizstack.com/docs/reference/sdk/gguf.md): GGUF files, llama.cpp's model format. A file is the magic "GGUF", a version (2 or 3), the counts of tensors and of metadata values, the metadata (typed key-value pairs: the architecture, its sizes, the tokenizer), the tensors' names, shapes, GGML types and offsets, then their data from an aligned start. A reader takes the header alone; the tensors are Stored (gizlang:safetensors), whose reads decode the GGML block types. The Hugging Face view (config, tokenizer, tensors by their Hugging Face names) lets a model converter take a GGUF file as it takes a model folder. - [gizlang:grpc](https://gizstack.com/docs/reference/sdk/grpc.md): gRPC (https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md) over HTTP/2. A message is bytes (the caller encodes it with gizlang:protobuf, or any codec). `service` makes the Http handler of the methods of a server; `dial` and `Channel.call` call a server. A call sends all its request messages and reads all its replies: unary, client-streaming and server-streaming calls fit, and the server may send its replies as it makes them. Messages are not compressed. - [gizlang:html](https://gizstack.com/docs/reference/sdk/html.md): HTML as a typed value. Markup in source compiles to it: function Row(t: Todo): Html { return
  • {t.title}
  • ; } The compiler joins each element's fixed parts into one constant at compile time and writes the holes in between: text is escaped, numbers are written, Html goes in as it is, a flag attribute is there or not. So a page is one buffer filled in order, and text never becomes markup unless the program says `raw`. A tag that starts upper case is a component, a function called with its attributes as a record and its children as Html. - [gizlang:http](https://gizstack.com/docs/reference/sdk/http.md): HTTP/1.1 (RFC 9112) over any Stream of gizlang:system, so HTTPS is the same code over a stream secured by gizlang:tls. `serve` keeps its connections in a Ready set, without a task each, and answers what they send in a few worker tasks; `exchange` sends one request and reads its response, and a `Pool` keeps client connections alive to send more on them. Header names are kept in lower case. - [gizlang:http3](https://gizstack.com/docs/reference/sdk/http3.md): an HTTP/3 server (RFC 9114) over the QUIC of OpenSSL 3.5 or later (found at run time; `supported` says whether this host has it). A request is read whole (headers, then body) and answered as an HTTP/2 stream is: the same `Request`, `ReplyPlan` and `Http.replyOn`. Header fields use QPACK with the static table only (RFC 9204): the server announces a dynamic table of capacity 0. The engine runs in one task (`Server.serve`); each connection and each stream is a task of its own. - [gizlang:hub](https://gizstack.com/docs/reference/sdk/hub.md): the files of Hugging Face Hub repositories in a local folder, at REPO/FILE as the hub serves them. A file that the folder does not have is downloaded once from HUB/REPO/resolve/REVISION/FILE (HUB: $HF_ENDPOINT, else https://huggingface.co; with $HF_TOKEN when it is set) and written to its place at once. The pin of a repository (.pins/REPO.pin in the folder) keeps the commit that its first download resolved and the SHA-256 of each file downloaded: later downloads use that commit, and each read checks the file against its SHA-256. A snapshot downloads the data files of a repository folder (a model's weights stay on disk: Hub.path). And the client of a chat model behind an OpenAI-compatible API (modelApi), for the stack's builder and the database's pgml.transform. - [gizlang:image](https://gizstack.com/docs/reference/sdk/image.md): JPEG, PNG and WebP pictures decoded at the smallest scale that a use needs, scaled, turned upright and coded again, written in Gizlang. A JPEG is decoded at 1/8, 1/4, 1/2 or full scale: the inverse DCT runs on the low n × n coefficients of each block only (n = 1 is the DC term, the block's mean), and a progressive file at 1/8 reads its DC scans and skips the others. A PNG streams through inflate, and each pixel is added into its box of a power-of-two downscale, so a full-size picture is never in memory. A lossy WebP decodes whole, bit for bit as libwebp decodes it. fit scales by area averaging, resize as Pillow's LANCZOS does; jpeg writes a baseline JPEG with the Annex K tables, png an RGB or RGBA PNG, webp a lossy WebP that libwebp decodes to the same pixels. - [gizlang:journal](https://gizstack.com/docs/reference/sdk/journal.md): Shared log coordinates. Durable publication, retention and product events remain with their storage owners; no database or wire adapter is imported. - [gizlang:json](https://gizstack.com/docs/reference/sdk/json.md): JSON (RFC 8259) as a value, read with parse and written with stringify as JavaScript's JSON.stringify writes it. Objects keep their keys in order; a repeated key keeps the last value, as JSON.parse. - [gizlang:linalg](https://gizstack.com/docs/reference/sdk/linalg.md): dense linear algebra over row-major buffers: f32 vector products and distances (BLAS level 1), and in f64 products, Cholesky, the symmetric eigendecomposition (cyclic Jacobi), least squares and the principal components. A matrix is a Vec with its dimensions beside it. - [gizlang:live](https://gizstack.com/docs/reference/sdk/live.md): State that survives code changes. Under `giz live`, each new generation of the program sees the same named state; when the state's type changed, fields whose name and type are unchanged keep their values and the others start from `initial`. - [gizlang:locale](https://gizstack.com/docs/reference/sdk/locale.md): the linguistic data of the Unicode CLDR (48.2.3, pinned; the CLDR generator writes the tables at the end of this file) and the algorithms that read it, once for the server, the browser and workers. Nothing here is a foreign runtime: a locale is a value built from a record, and every function is a pure function of that value and its arguments. tags BCP 47 (RFC 5646) canonical case, CLDR likely scripts and parent locales; RFC 4647 lookup with script awareness plurals the CLDR cardinal and ordinal rules of every language, compiled to Gizlang conditions (operands n i v w f t c) numbers decimal, percent, currency and compact patterns with the locale's symbols, grouping and digits dates the Gregorian date, time and date-time styles, a set of skeletons, and patterns; an instant and an offset relative "yesterday", "in 3 days", "5 minutes ago"; lists "a, b, and c"; the name of a language in itself Unicode data: https://www.unicode.org/license.txt (CLDR is under the Unicode License v3). - [gizlang:machine](https://gizstack.com/docs/reference/sdk/machine.md): What this machine is: its CPU's instruction-set features, the CPUs this process may use, the caches they share and the memory nodes, detected at run time by the runtime, never inferred from a model name. Code that sizes its work to the hardware (a hash table to a cache, a kernel to its vector width, a pool to its CPUs) reads it here. One cap rules every choice: GIZLANG_CPU sets the x86-64 level code runs at, and the features stop at that level, so a kernel or a compiled unit chosen from them never uses more. GIZLANG_THREADS lowers `threads` as it lowers Task.parallel's pool. - [gizlang:math](https://gizstack.com/docs/reference/sdk/math.md): IEEE 754 primitives and general numerical kernels. `import * as Math from "gizlang:math"` gives `Math.floor(x)`; sqrt is built in. libm domain errors are NaN, not faults. - [gizlang:memory](https://gizstack.com/docs/reference/sdk/memory.md): gizlang:memory reference. - [gizlang:mesh](https://gizstack.com/docs/reference/sdk/mesh.md): which servers of one service are alive, and which of them owns a key. A node listens on a TCP port and, every interval, exchanges its view with each node it knows (and each seed) in one short connection: it sends its own line and reads the live members of the other node. A member not heard of for holdMs is dead. Ownership is rendezvous hashing: each key goes to the live member with the highest hash of (member, key), so a join or a leave moves only the keys of that member. A mesh belongs to the thread that made it; threads of one process share one node, not one mesh each. - [gizlang:metrics](https://gizstack.com/docs/reference/sdk/metrics.md): counters, gauges and histograms that every thread of a process can change without a lock or an allocation, and their exposition in the Prometheus text format 0.0.4 (GET /metrics). OTLP push reads the same metrics later; there is one registry of values, the process's atomics. A metric declares its label values up front: its series set is bounded and known. Each series cell is Task.atomicGlobal of the series identity, so two declarations of the same metric (in two modules or threads) share values. Exposition takes the metrics to show; there is no hidden global list. Values are i64 in the metric's base unit. `scale` (a power of ten) states how many base units make one exposed unit, so an exposed value is exact decimal text (for example microseconds observed, seconds exposed). - [gizlang:mp4](https://gizstack.com/docs/reference/sdk/mp4.md): MP4 files (ISO/IEC 14496-12 and 14496-14) of a video track (H.264, HEVC or AV1) and an AAC-LC track (ISO/IEC 14496-3). A browser plays the file as it arrives: the index (moov) comes before the samples. - [gizlang:native](https://gizstack.com/docs/reference/sdk/native.md): Native code a library did not compile itself: a dynamic library's symbols and calls through them (a GPU driver), raw memory, a generated CPU kernel run on every core, and a native resource a Gizlang value owns. A `Native` comes only from a `System`, so only code main handed its authority loads native code. - [gizlang:natural](https://gizstack.com/docs/reference/sdk/natural.md): natural numbers of any size, for the integer and decimal types built on them (vm/bigint's Python int and JavaScript BigInt, db/decimal's wide NUMERIC). A natural is a Vec of 32-bit limbs, least significant first, with no zero limb on top: [] is 0. Each function takes and gives naturals in that form. - [gizlang:odbc](https://gizstack.com/docs/reference/sdk/odbc.md): Thin ODBC driver boundary. SQL semantics and planning belong to the data layer. Exact text/binary cells, bounded forward cursors, explicit transactions, no retries. - [gizlang:path](https://gizstack.com/docs/reference/sdk/path.md): gizlang:path reference. - [gizlang:pdf](https://gizstack.com/docs/reference/sdk/pdf.md): the words of a PDF file (ISO 32000-2), as search and reading need them: each page's text in the order its content streams draw it, a line where the text moves to another line and a space where it jumps right (by the font's glyph widths). Objects are found by scanning the file, so a broken cross-reference table does not matter; object streams are opened; FlateDecode, ASCIIHexDecode and ASCII85Decode streams are decoded. A font reads by its ToUnicode CMap; a simple font without one reads as WinAnsi with its Differences. An encrypted file and a picture of text (a scan) have no words here. - [gizlang:postgres](https://gizstack.com/docs/reference/sdk/postgres.md): PostgreSQL protocol v3 over System's Stream. One operation owns a connection until ReadyForQuery; rows are owned UTF-8 text, SQL NULL is Option.none(). - [gizlang:protobuf](https://gizstack.com/docs/reference/sdk/protobuf.md): the Protocol Buffers wire format. A message is a list of fields; a field has a number, a wire type and its value: a varint, a fixed 32 or 64 bit word (both in `value`), or length-delimited bytes (a string, bytes, a nested message or a packed list, in `data`). The schema is the caller's: it reads the numbers it knows and skips the rest, as the format asks. - [gizlang:random](https://gizstack.com/docs/reference/sdk/random.md): a seeded generator (SplitMix64), so a run can be repeated from its seed. `System.entropy()` gives an unpredictable seed. - [gizlang:regex](https://gizstack.com/docs/reference/sdk/regex.md): regular expressions with JavaScript's syntax and match results (leftmost match; alternatives and quantifiers prefer as written; lazy quantifiers; capture groups) over UTF-8 text, in time linear in the text. Structure (as RE2 and Rust's regex): a pattern parses to a tree over code-point sets. The tree compiles to a program over bytes: each set becomes the UTF-8 sequences of its code points, so every automaton reads one byte a step through a table of byte classes. regex() builds the automata of the pattern once and keeps them in the Regex value: - a DFA without captures (test, count, the end of a match); - a tagged DFA (Laurikari) that also keeps the capture positions in registers, with copy and set operations on its transitions, so exec finds the start, the end and the groups in one pass; both with a bounded number of states built ahead. A search that needs a state outside them adds it to its own copy (a lazy DFA whose cache is bounded and starts over when full, as in RE2). An assertion that one byte of look-ahead cannot decide uses a bounded backtracker that replays the program, each (instruction, position) at most once. So no pattern takes more than time linear in the text (there are no backreferences and no lookaround, as in RE2). Before the automata: a literal pattern is a substring search, an anchored literal is a comparison, literal alternatives use selective byte scans, a literal-delimited lazy single-set loop searches its delimiters directly, and a start state jumps to the next byte that can begin a match, or to a prefix. Syntax: JavaScript's (the one parser of ECMAScript mode below, in its Annex B form over code points): literals, `.`, classes, escapes, groups `(...)` `(?:...)` `(?...)`, modifiers `(?i:...)`, `|`, quantifiers with a lazy `?`, ^ and $. The parser marks the features a pattern uses (ES_USES); regex() refuses those the automata cannot run: lookaround, backreferences, a bound over 1000. Flags: `i` (ASCII case-insensitive), `s` (`.` takes line terminators), `m` (^ and $ at line terminators), `y` (a match starts only at the search position), and `g` and `u`, accepted as no-ops (every search API here is global; text is always Unicode). Anything else is an error, never a silent difference. ECMAScript mode (esCompile, EsRegex.exec, checkPattern, at the end of this file) is the JavaScript RegExp: the whole grammar of ECMA-262 over UTF-16 code units. A pattern the parser marked with none of ES_NOT_LINEAR runs on the automata above; the rest on a backtracking matcher. - [gizlang:runtime](https://gizstack.com/docs/reference/sdk/runtime.md): The runtime written in Gizlang: what the compiler lowers a construct to (the compiler appends this module wherever string( occurs). string(x) of bytes checks them with utf8Valid, which bytes.isUtf8 (gizlang:text) shares. - [gizlang:safetensors](https://gizstack.com/docs/reference/sdk/safetensors.md): safetensors files and the model folders that hold them. A file is an 8-byte little-endian header length, a JSON header (each tensor's dtype, shape and data offsets, and an optional "__metadata__"), then the data. A reader takes the header alone (Stored) and reads a tensor's elements or bytes when it needs them; a writer puts the header first (header) and each tensor's data at its offset (writeAt). The Tensor of a file is gizml:tensor's (save, load, upload). - [gizlang:security](https://gizstack.com/docs/reference/sdk/security.md): Shared identity, session proof and authorization decisions. Protocols adapt credentials and persistence; they do not define a second permission system. - [gizlang:sqlite](https://gizstack.com/docs/reference/sdk/sqlite.md): SQLite through its C library (`giz bind` wrote the declarations, reviewed by hand). The same shape as gizlang:postgres: text parameters and values, SQL NULL as Option.none(), Result errors, and `transaction(work, failure)`. Calls block the calling thread while SQLite works. - [gizlang:stats](https://gizstack.com/docs/reference/sdk/stats.md): descriptive statistics over f64 samples: moments, order statistics and the sort they share; streaming moments, variance and least squares (the SQL aggregates and their merges). - [gizlang:stringprep](https://gizstack.com/docs/reference/sdk/stringprep.md): SASLprep (RFC 4013) as PostgreSQL 16 runs it on SCRAM passwords: the frozen Unicode 3.2 stringprep ranges of RFC 3454 and the SDK normalizer, including its normalization corrections. - [gizlang:system](https://gizstack.com/docs/reference/sdk/system.md): The program's authority: files, network, arguments and environment. A process receives it as `main(sys: System)`; library code can use only what it is passed, and every value here has private fields, so none can be forged. Directories, streams, listeners and sockets belong to the task that opened them and close when it ends; using one after it closed is fault 14. Reads, writes, connects, accepts and receives suspend only the calling task. Failures a program should handle are `IoError` values. - [gizlang:task](https://gizstack.com/docs/reference/sdk/task.md): Structured tasks. A task runs a closure alongside the rest of the program on the same thread (`thread` runs one on an OS thread of its own); sleeping, joining and I/O suspend only the calling task. A task never outlives the task that spawned it: when its work returns, its unjoined children are cancelled and awaited. Cancellation reaches a task at its next suspension point as fault 12. - [gizlang:test](https://gizstack.com/docs/reference/sdk/test.md): assertions, generated inputs and shrinking, for test functions (`function testName(): void`, run by `giz test FILE`) and for programs. An assertion that does not hold faults (R004) inside itself, so the fault trace carries what failed with its values and where it was called: `equal line 1 (actual = 4, expected = 5) <- testAdd (main.giz:12)`. The test fails with that trace and a replay test reproducing the call, and the other tests still run. Nothing is collected or formatted on success. - [gizlang:text](https://gizstack.com/docs/reference/sdk/text.md): Text and byte operations written in Gizlang over the built-in string primitives (slice, comparison, concatenation, push, string()). Strings are UTF-8: offsets count bytes, and a match always starts and ends on character boundaries because both sides are valid UTF-8. - [gizlang:time](https://gizstack.com/docs/reference/sdk/time.md): calendar dates in UTC from milliseconds since 1970-01-01, as JavaScript's Date keeps them (proleptic Gregorian; System.time() is now). - [gizlang:tls](https://gizstack.com/docs/reference/sdk/tls.md): TLS over a TCP Stream of gizlang:system. After `client` or `server` succeeds, the same Stream reads and writes through TLS, and `close` sends close_notify first. A failed handshake leaves the stream to close. Failures are IoError values whose message() names the TLS or certificate error. Importing this module links OpenSSL. - [gizlang:unicode](https://gizstack.com/docs/reference/sdk/unicode.md): gizlang:unicode reference. - [gizlang:url](https://gizstack.com/docs/reference/sdk/url.md): the URL Standard (url.spec.whatwg.org) over UTF-8 bytes: the basic URL parser with its state overrides (the API's setters), the host parser (IPv4, IPv6, opaque hosts, and domain to ASCII), and the serializer with the offsets of each part, as ada's url_aggregator keeps them. Node's URL is a thin adapter onto this; gizlang:http's `url` stays the client's narrow view of http URLs. - [gizlang:worker](https://gizstack.com/docs/reference/sdk/worker.md): giz's inference worker protocol, version 1 (giz's ml/worker and wgp-api speak it): a service takes jobs over HTTP on a thread of its own, the caller runs them one at a time where its models are, and the worker keeps each result until giz acknowledges it. POST /v1/jobs takes {operation, model, input, idempotencyKey} as JSON, or as the form field "request" with the files it names ({"$file": field}), which stream to disk as they arrive; the executor sees each such file as {"$inputFile": {name, contentType, path}}. A key gives the same job for the same request (the first 32 hex digits of SHA-256 of model, operation and key). The worker holds `capacity` jobs (queued and processing) and answers 429 WORKER_BUSY beyond them. GET, DELETE /v1/jobs/{id} read and cancel a job, POST /v1/jobs/{id}/ack frees a finished one, GET /files/{id}/{name} serves its outputs. GET /v1/queue, /v1/health, /v1/models and /metrics describe the worker; POST /v1/intake/close and /v1/intake/open stop and start new jobs. Each job lives in its own folder under the state folder (job.json, its inputs and outputs), so a restart keeps the queued and finished ones; a job that was processing fails with WORKER_INTERRUPTED. Under `serve`, where GIZ_WORKER_AUTHORIZATION is set, every /v1/ request must carry it as its Authorization header (401 otherwise). ## Libraries - [gizdb:access](https://gizstack.com/docs/reference/gizdb/access.md): The native application boundary of db/server's existing actor. This module owns session/cursor delivery, never an Engine, storage ledger, executor or change log. - [gizdb:core/analyzer](https://gizstack.com/docs/reference/gizdb/core/analyzer.md): Text analysis: the tokens of a text for the inverted index and for queries. Text is normalized (NFKC: full-width and compatibility forms become their plain ones) and case-folded (Unicode full folding); words are runs of letters and digits, and runs of Hangul, Han, Hiragana and Katakana become overlapping two-character grams (a one-character run stays one token), so Korean, Chinese and Japanese match inside words without a dictionary, as Lucene's CJK bigrams do. ASCII text takes a byte path. Segments store the tokens, not these rules: a change to the rules needs every text index rebuilt. - [gizdb:core/vector](https://gizstack.com/docs/reference/gizdb/core/vector.md): Nearest-neighbour search over a vector column: a HNSW graph per segment (Malkov and Yashunin; the layout of hnswlib and USearch: a flat neighbour array for layer 0, the few upper-layer nodes in their own arrays), and an exact scan where it is cheaper or the filter is selective. A filter is a set of allowed rows; the graph is walked through every row but only allowed ones are returned, and when the allowed rows are few the exact scan answers instead, so recall does not collapse under a 1% filter. One walk (walk) serves a graph in memory and a graph whose level 0 links and values stay in its segment file (Graph.onDisk): it estimates distances on the codes of the index's quantizer (Spec: RaBitQ, SQ8 or none), takes the nearest nodes not taken (one at a time in memory, a beam of reads on disk, as DiskANN), and offers each node it takes to the answer at its exact distance. So the answer is exact over the nodes taken, which hold the walk's final pool. Distances: l2 (squared Euclidean), cosine (1 - cosine similarity) and ip (negative inner product), so smaller is always nearer. Ties go to the lower row, as in BM25 top-k. - [gizdb:data](https://gizstack.com/docs/reference/gizdb/data.md): A stored application's typed records, by their Model.Shape: on a GizDB engine this process serves, or on a SQL store. Actions, packages and the platform write and read them here; one transaction is one Connection.begin. A page follows them with Data.follow and Web.live (web/app.giz). - [gizdb:decimal](https://gizstack.com/docs/reference/gizdb/decimal.md): Exact decimals, as PostgreSQL's NUMERIC: a value is C × 10^-s with a scale s of 0..16383 and at most 131072 digits before the point. A coefficient that fits an i64 (most values) is the `narrow` case: `c` and `s`, so columns and SIMD kernels work on `c` alone and a Dec stays 24 bytes (a wider Value made the decimal and integer sums 10-14% slower). A wider coefficient is the `wide` case: m[0] = s << 1 | sign, then |C| in base-10^9 limbs with the least significant first and no zero limb on top. Read a Dec through decScale, decCoef, decNegative and the limb helpers here. A value has one form at a scale, so `===` compares values of one scale. Every operation is exact, or rounds half away from zero at a scale it names, or reports overflow (none): nothing goes through binary floating point. ln, log, exp and power are correctly rounded at the scales PostgreSQL picks. Oracle's NUMBER keeps 40 digits by its own rule (`numberArith`, `decNumber`). - [gizdb:error](https://gizstack.com/docs/reference/gizdb/error.md): Typed failures shared by database owners; protocol spelling lives in sql/errors.giz. - [gizdb:gate](https://gizstack.com/docs/reference/gizdb/gate.md): who may read and write which rows of a Shape. It is the one place that applies the Policy (grants on records and the ancestry of records, db/policy.giz) to a Shape's rows, so a page, an API, an agent's tool and a background job that act through a Db with a Scope (db/data.giz) are all judged the same way, by the same function. A stored Shape is a record of the Policy named SPACE/table/NAME, and each of its rows is SPACE/NAME/KEY below it (or below the row that its @Within field names). A grant on the table reaches every row; a grant on one row reaches that row and its children. A read adds a condition to the query, so a row the actor may not read is never selected; a field the actor may not read is selected as NULL. A write is checked before it runs, and a row is placed in the Policy in the transaction that inserts it. - [gizdb](https://gizstack.com/docs/reference/gizdb/main.md): gizdb, the embedded GizDB: open a database in a folder, run SQL in a session and read its values. The subject modules (gizdb:access, gizdb:model, gizdb:query, ...) are imported by their own names. - [gizdb:model](https://gizstack.com/docs/reference/gizdb/model.md): a record type's meaning as a value (a Shape), and what is derived from it besides HTML: typed input validation, SQL wire rows, DDL for SQLite and PostgreSQL, additive migration, JSON and agent tool schemas. A Shape comes from the record type's declaration, docs and annotations at run time (`shapeOf`), so the declaration stays the one source; so do a record's rows (`rowOf`, `valueOf`) and the actions' table (`action`, `handlers`, `dispatch`). - [gizdb:policy](https://gizstack.com/docs/reference/gizdb/policy.md): The DAL's Policy (GIZSTACK-PLATFORM §3 item 5). Grants on records live in one table, `grants`; record ancestry lives in one closure table, `ancestry`, which the writing transaction keeps with the record. Security.decide judges an actor over the grants on a target and its ancestors, read at one snapshot. A record that has no ancestry row has no access (default deny). Only Policy Operations write `grants`; they check the granting actor with `decide` first. A group is a record of type `group`: a grant on it makes its grantee a member, and a grant to Principal.group reaches every member. - [gizdb:query](https://gizstack.com/docs/reference/gizdb/query.md): A stored table that follows a record type. The @was that a field rename records (giz edit), and by which live state migrates, renames the table's column, so a generation that renamed a field reads the rows the old one wrote. New fields become columns; a column no field names is kept, and its data with it. Typed queries and commands lower only to the existing Select tree and source cursor. Their value contracts are in gizdb:typed. - [gizdb:relay](https://gizstack.com/docs/reference/gizdb/relay.md): realtime as a position in a log the database keeps. Every committed change appends its topic and key (not its value: the store is the state, so a subscriber reads the rows a change names); a subscriber asks for a topic's changes after the position it holds and waits (a long poll) until there are some or its wait ends. Positions belong to the database, not to a process, so every worker process of the application (GIZLANG_WORKERS) and every later run answers the same position the same way. A position older than what the log keeps, or from another database, gets a snapshot answer: the caller renders the topic again. So a reconnect, a missed message, a restart and a request served by another worker are one path. - [gizdb:schema](https://gizstack.com/docs/reference/gizdb/schema.md): One pure schema planner. Catalog readers and command executors belong to callers. - [gizdb:semantic](https://gizstack.com/docs/reference/gizdb/semantic.md): Analytical meaning is metadata attached to stable declarations. Calculations remain the existing typed SQL AST/Rel; this module owns grain/unit validation and the pivot of a certified metric (its cells and exact totals). - [gizdb:server/server](https://gizstack.com/docs/reference/gizdb/server/server.md): The authoritative DB actor: one Ready loop owns Engine publication, durability, recovery, checkpoint work and the PostgreSQL, Kafka and RESP transports. A wait (a shard hold, a sync, a login to the primary) runs the loop again, so each function that can wait is in this module. The actor's state is in actor.giz, the PostgreSQL steps that do not wait are in pg/session.giz and the relay to a primary or to another shard is in forward.giz. Native operation adapters never own a second writer or release a committed reply before this actor's durability gate. - [gizdb:source](https://gizstack.com/docs/reference/gizdb/source.md): One typed data-source contract. An adapter reports its actual abilities and returns owned column pages. It never manufactures global snapshot/CDC semantics. - [gizdb:sql/types/dialect](https://gizstack.com/docs/reference/gizdb/sql/types/dialect.md): A SQL dialect as a value: its name and the rules where the engines it imitates differ in meaning, not spelling. A rule that many modules read is a field (`d.emptyIsNull`), so a new dialect is a new value here. A quirk of one function reads `name` in that function (Oracle's substr of position 0, SQL Server's natural log), and so do PostgreSQL's own types, catalogs and errors (xid, inet, pg_lsn, timetz, pg_catalog, 42P01). Spellings that mean the same in every dialect (lcase, getdate, nvl) are one vocabulary the parser and function library accept everywhere. - [gizdb:store](https://gizstack.com/docs/reference/gizdb/store.md): the database a web app keeps its records in, one call shape over three engines. GizDB is the default: a folder, whose engine this process serves (other processes, a worker or the platform, reach it at the folder's unix socket with its password). DATABASE_URL selects another: PostgreSQL (a server; each worker process holds a pool) or a SQLite file (embedded; every worker process opens it). Apps, the feed and the model write one SQL for all (ON CONFLICT, RETURNING, $N, TRUE and FALSE); what differs, DDL types and locks, is chosen here or by the SQL Dialect (db/sql/types/dialect.giz). Typed records (db/data.giz) use the same GizDB engine through db/access.giz. - [gizdb:typed](https://gizstack.com/docs/reference/gizdb/typed.md): Typed data contracts: Slot, Codec, the codecs, logical Contract and the exact JSON transport of a Value. Applications, web models and generated code import only this module. It imports no SQL engine, session or executor, so a typed web model does not link the database (db/query.giz holds the typed queries and commands). - [gizdb:value](https://gizstack.com/docs/reference/gizdb/value.md): Values, types and schemas, and their one binary encoding (used by the log and by segment files alike). - [gizweb](https://gizstack.com/docs/reference/gizweb/main.md): gizweb, the one public name of GizWeb. The application's own API is flat; the large subject modules (charts, content, Markdown, ready components, forms) are namespaces. - [gizweb:pages](https://gizstack.com/docs/reference/gizweb/pages.md): File-system routing: a folder of pages is a site. `giz` writes the module `PAGES/.routes` for it (a program imports `site` from it); this file serves what that module declares. A route file is a .ghtml file in lower case (index.ghtml, [slug].ghtml), a .md file (rendered by Markdown) or a .html file (sent as it is). `[name]` in a path is a parameter, `index` is its folder, `_layout.ghtml` wraps the pages of its folder and below, `404.*` is the not-found page. - [gizweb:region](https://gizstack.com/docs/reference/gizweb/region.md): the live parts of a page of GHTML. The compiler puts a range around each part of a route file that reads a table, and a keyed list around each `each` over a table whose rows are one element. A range is the HTML between the comments `` and ``; a row of a list is the element whose `data-k` is `ID:KEY`. When rows of a table change, the long poll (Pages) runs the page again with a Focus (gizweb:table) that names the table and the changed keys. Then nothing renders but what read that table: a range renders again whole; a list reads the changed rows only and sends those rows, the place of each, and the rows that left. The browser puts the patches in. - [gizweb:table](https://gizstack.com/docs/reference/gizweb/table.md): the typed table of a page. A route file declares `const todos = table("created desc");` and reads and writes it as the records of its type; the generated code calls this module. Every read and write goes through Data and its Gate, so a page shows and changes only what the person who asks may. The SQL of `where` and `count` is made at build time from the lambda; every value in it is a parameter, so a value cannot become SQL. - [gizfs:cli](https://gizstack.com/docs/reference/gizfs/cli.md): The storage command group, `giz storage OPERATION ...`: one table of storage operations over the typed Client of volume.giz. The command line, its help and the Operation registry read the table. A local range and gizstack.com differ only in GIZ_STORAGE_NODES (the endpoint list of protocol.giz) and GIZ_STORAGE_CREDENTIAL (an issued credential: fs/issue.giz or `key create`). - [gizfs:codec](https://gizstack.com/docs/reference/gizfs/codec.md): The one binary encoding every stored byte of GizDB goes through: the log, segment files, the manifest and key-value snapshots. Little-endian words, u32-length-prefixed blobs, and a masked CRC-32 that seals a whole file or frame. Reads never fault on short or malformed input: they return a zero value and set `bad`, which the caller checks once after decoding. - [gizfs:disk](https://gizstack.com/docs/reference/gizfs/disk.md): What the engine needs of a directory and its files. The engine and log take these interfaces, not gizlang:system's Dir and Stream, so a test can put a disk between them that fails where a real one can: a failed sync stops the engine. - [gizfs:node](https://gizstack.com/docs/reference/gizfs/node.md): A storage node: one process owns one locked durable range. Connection tasks authenticate and enqueue; only the volume actor changes Raft or filesystem/object metadata. fs/server.giz runs one node from its command line; `embedded` runs one inside another process. Automatic scrub preserves policy coverage; no auto-GC. - [gizfs:object](https://gizstack.com/docs/reference/gizfs/object.md): Object names are semantic catalog entries over the same immutable Store as files. This owner is deterministic; only the volume journal publishes commands. - [gizfs:ordered](https://gizstack.com/docs/reference/gizfs/ordered.md): An ordered map from byte strings to integers: a B+tree whose inner nodes keep each child's largest key and entry count, so seek, insert and delete cost O(log n) and rank queries too. Keys compare as bytes; callers encode what they order so that byte order is their order (the caller's value encoding). One structure serves retained roots, database ordered indexes and key-value sorted sets. Nodes live in one pool and name each other by position. The pool is kept in pages of NP nodes: when a tree is shared with other threads' readers (an engine or storage snapshot), a write copies the pages it changes, not every node. Leaves are linked both ways for scans. A child's recorded largest key may be stale after a delete (larger than its real largest): it still bounds the child, so routing stays correct, and it is never smaller. - [gizfs:raft](https://gizstack.com/docs/reference/gizfs/raft.md): A bounded durable Raft range. Network authentication, timeout scheduling and deterministic application of committed entries belong to the service. No local-clock lease is assumed. - [gizfs:s3](https://gizstack.com/docs/reference/gizfs/s3.md): Bounded S3 profile. HTTP parsing/framing, URI codecs, calendar and cryptography remain SDK owners. Mutation preparation never publishes catalog state: the caller commits its command to the shared volume journal first. - [gizfs:volume](https://gizstack.com/docs/reference/gizfs/volume.md): Files and objects are deterministic clients of the same committed range. This owner restores both catalogs at one snapshot cut and never exposes proposals. - [gizml:ai](https://gizstack.com/docs/reference/gizml/ai.md): AI models on this computer, by name. A name is one of the catalog's (Qwen 3.5 chat models, FLUX.3 klein images) or a Hugging Face repository ("owner/name") of a family that gizml:llm reads. The first use downloads the model into the models folder (gizlang:hub: $GIZLANG_CACHE/huggingface, else ~/.cache/gizlang/huggingface; $HF_TOKEN for a gated repository, $HF_ENDPOINT for a mirror) and converts it once; later uses need no network. `text` gives a chat model, `ready` its warm engine, `reply` an answer as it comes, `image` a text-to-image model, and `serve` the OpenAI API of both. Each family's recipe stays in its module (gizml:llm, gizml:diffusion); this one finds, fetches and serves. An absolute path names a converted model's folder instead. - [gizml:cluster](https://gizstack.com/docs/reference/gizml/cluster.md): clustering with a predict step: k-means (k-means++ and Lloyd), mini-batch k-means, BIRCH (CF subclusters, then Ward agglomeration by the nearest-neighbor chain), affinity propagation and mean shift. A model is a set of centers with a cluster label each: a row takes the label of its nearest center. Matrices are row-major. - [gizml:diffusion](https://gizstack.com/docs/reference/gizml/diffusion.md): video and image generation models (diffusion transformers), fast on any hardware. A model family is a recipe: its config.json read as an Arch, and the names of its tensors. Every family runs on the same operations: the linears are gizml:tensor products on the matrix cores (BF16, or INT8 from a W4 checkpoint as production quantizes H3), and the row operations and attention are the kernels below. A GPU runs them; the host runs the same block in f32, which is the reference of the tests. MiniMax H3 (the first family) is one single-stream transformer over a packed sequence of text, conditioning, audio and video rows. Each row has rotary (t, h, w) coordinates and a modulation row: the (timestep, modality) pair whose shift, scale and gate its block applies. Attention is full and unmasked over the whole sequence, so the order of the rows does not matter beyond the layout the caller keeps. - [gizml:grad](https://gizstack.com/docs/reference/gizml/grad.md): derivatives of tensor programs. A Graph records each operation on its values as it runs (a tape); `backward` walks it once in reverse for the gradient of a scalar against every value (reverse mode), and `tangent` walks it forward for the derivative along a direction (forward mode). Each rule is the textbook one over gizml:tensor's own operations, so gradients run fused on the CPU's lanes and cores like the forward pass. - [gizml:grammar](https://gizstack.com/docs/reference/gizml/grammar.md): the texts a model may write, for constrained decoding. A Grammar is compiled once from a JSON schema (or is any JSON object); a Recognizer reads a text byte by byte and says whether the text so far can still become one the grammar allows, and whether it is one already. A sampler masks each token whose bytes the recognizer refuses (gizml:llm), so the answer is JSON of the schema. The recognizer keeps each reading that is still possible (anyOf, enum values and object keys with a common start), so it needs no lookahead. - [gizml:llm](https://gizstack.com/docs/reference/gizml/llm.md): language models, fast on any hardware. A model family is a recipe: its config.json read as an Arch, and the names of its tensors. Every family runs on the same operations, so a new family is one recipe. `convert` turns a Hugging Face folder into this module's format once: each linear is stored in a format (Formats), after a Hadamard rotation of each block of 128 inputs, in the order the GPU reads it. `load` opens a converted model on the best device it finds, and its Engine runs steps of many sequences at once. - [gizml:ltx](https://gizstack.com/docs/reference/gizml/ltx.md): Lightricks' LTX-2.5 (22B), the audio and video flow transformer of giz.ai's ltx2-5-distilled. Two streams of rows run side by side through 48 blocks: video (4096 wide, 32 heads of 128; a row a latent pixel of 8 frames and 32 x 32 pixels) and audio (2048 wide, 32 heads of 64; a row a 40 ms latent). In each block each stream attends to itself, then to its text, then the audio to the video and the video to the audio, then runs a GELU MLP; each step is modulated (AdaLN) by the stream's timestep, and the text's keys and values by the largest one. Attention reads q and k over their RMS across all heads, then rotated (RoPE by split halves) by the rows' positions (video: time, height, width; audio: time), and its output is gated a head by the input's linear. A text's conditioning (Gemma4's hidden states projected to [rows, 4096 + 2048], the shared encoder's answer) first runs through each stream's connector: 8 blocks of self attention over the rows padded to 1024 with learned registers. The linears are INT8 rows rotated by ConvRot's Hadamard of 256, a scale a row (ComfyUI's ltx-2.5-22b-distilled-transformer-comfy-int8-convrot file, read as it is: gizml:diffusion's comfyInt8Rows), run on the INT8 matrix cores against x quantized as N.int8Rows quantizes it. Every weight block is in page-locked host memory (gizml:diffusion's Staged) and, while the card has room, on the GPU: the blocks first (each step reads them), then the connectors and the AdaLN modules (a request reads them once: every step's modulation is made at its start). The blocks that stay are spread over the 48, and the others copy to one of two slots, each as soon as its slot is free, so the copies run all through a pass. Ltx.free gives memory back for the VAEs; a block that copies for its use stays on the GPU again while there is room, so the next request gets it back at no cost. On a 16 GB card the copies bound a step, so every byte left on the card counts. The residual streams are F32; every product's output rounds to BF16, as ComfyUI stores it. - [gizml:ml](https://gizstack.com/docs/reference/gizml/ml.md): one interface over the estimators of gizlang:{linalg,trees,svm,cluster}, with the algorithms and default hyperparameters of scikit-learn, xgboost, LightGBM and CatBoost: fit, predict, predict_proba, the metrics, and the model bytes. The linear models, the optimizers (L-BFGS, SGD) and the metrics are here. Matrices are row-major f64. - [gizml:netops](https://gizstack.com/docs/reference/gizml/netops.md): the operations of networks on gizml:tensor Tensors. Each one runs where its operand is, on the CPU or a GPU, and adds in one order on both: row terms and norms, losses, argmax, attention (plain, packed rows, 8-bit matrix cores), dropout, convolution and pooling, the modulated norm with INT8 rows, and the rows of a language model's step (argmax, sampling candidates, split sums, rotated norm and SwiGLU). - [gizml:nn](https://gizstack.com/docs/reference/gizml/nn.md): what training a network needs on top of gizml:grad. Layers are functions of a Graph and their parameters (plain Tensors the caller keeps), losses are Graph values, and optimizers update the parameters in fused passes. Files of parameters are gizml:tensor's (save, load). - [gizml:npullm](https://gizstack.com/docs/reference/gizml/npullm.md): Gemma 4 E2B's forward pass on an AMD NPU (XDNA 2), with the AIE kernels of FastFlowLM (the layer and lm_head xclbins, MIT runtime, binaries free to use unmodified). gizml:llm loads such a folder as a model like any other (its chat, sampling and serving); this module gives it the logits of the tokens it reads (Model.read). A token runs the 35 decoder layers as 35 runs of the layer kernel and then one run of the lm_head kernel; this module writes each run's control code (an AIE transaction) for the current context length, and the CPU does the embeddings and the rotary tables. The model folder holds config.json, tokenizer.json, model.q4nx (a safetensors file of 4.125-bit Q41 blocks, bf16 and q8_0 tensors) and xclbins/. - [gizml:onnx](https://gizstack.com/docs/reference/gizml/onnx.md): ONNX model files (ModelProto, IR version 8) of gizml:ml models, and gizml:ml models of ONNX files. encode writes opset 17 and ai.onnx.ml 3: LinearRegressor, LinearClassifier (and Normalizer), TreeEnsembleRegressor, TreeEnsembleClassifier, PCA as Sub and MatMul, and k-means as the nearest center (MatMul, ReduceSumSquare, ArgMin). decode reads the ai.onnx.ml linear and tree ensemble operators as skl2onnx and onnxmltools write them for scikit-learn, XGBoost and LightGBM models, with Cast, Identity, ZipMap, Softmax and Normalizer (L1) nodes around them, and a Scaler before a linear operator (a pipeline of StandardScaler), which goes into its coefficients. ONNX Runtime (and scikit-learn's trees) round an input to f32 before a tree compares it with an f32 threshold. encode writes the nearest f32 of each threshold; decode turns each f32 test (BRANCH_LEQ, LT, GT, GTE) into the test on f64 that gives the same branch for each input: x <= T as f32 is x <= the largest f64 that rounds to at most T. network reads a convolutional network's graph (Conv, pooling, Resize, MatMul and the shape operators that YOLOX and RTMPose use) and runs it with gizml:tensor, on a GPU when one is given, with f32 values. - [gizml:quant](https://gizstack.com/docs/reference/gizml/quant.md): the formats of stored weights, apart from the model families and the kernels that run them. A format says how a linear's weights are stored: a codebook of 2 to 8 bits, F8, BF16 or F16, each block of GROUP inputs rotated (Rotation), in the order the matrix cores read it (Quantization); or W4, the checkpoint format of production's H3 (a 16-value codebook, E4M3 group scales, the regular Hadamard of netops' ROTATED); or K4 and K6, a GGUF file's Q4_K and Q6_K blocks as they are (K formats). This module encodes a format when a model is converted, and decodes it on the host and to the matrix cores' INT8. - [gizml:svm](https://gizstack.com/docs/reference/gizml/svm.md): support vector machines. The SMO solver of LIBSVM (second-order working set selection, Fan, Chen and Lin 2005) for C-SVC, nu-SVC, epsilon-SVR and nu-SVR, one-vs-one for more than two classes, and the dual coordinate descent of LIBLINEAR for linear SVC (squared hinge) and linear SVR (epsilon-insensitive). Matrices are row-major. - [gizml:tensor](https://gizstack.com/docs/reference/gizml/tensor.md): n-dimensional f32 arrays on the CPU's vector lanes and cores. One Tensor type over one storage (row-major Vec), numpy broadcasting, elementwise chains fused into one pass (Lazy: a small tensor IR run 1024 elements at a time in L1), reductions with a policy for their order, and matmul on packed 6x32 FMA tiles across cores. - [gizml:tile](https://gizstack.com/docs/reference/gizml/tile.md): GPU kernels as ordinary Gizlang over tiles, on every device. A tile program says what one block of the output is; this module decides everything else: threads, which thread holds which element, workgroup memory, barriers, bounds masks, matrix-core fragments, layout conversions and the device. The same program runs on host tensors (the CPU, one program per grid point in turn) and on a GPU's tensors (NVIDIA PTX, AMD LLVM through comgr, both from gizhw:kernel). A tile program is ordinary Gizlang, and it reads as math: `a * b + c` is `a.mul(b).add(c)`. Tile.run([Tile.cdiv(m, 128), Tile.cdiv(n, 128)], (p: Tile.Program): void => { const i = p.id(0); const j = p.id(1); const A = p.read(a, [128, 32]); const B = p.read(b, [32, 128]); const acc = p.fold(p.int(0), A.blocks(1), p.zeros([128, 128]), (k: Tile.Index, acc: Tile.Tile): Tile.Tile => acc.add(A.at([i, k]).dot(B.at([k, j])))); p.write(c, [128, 128]).put(acc.relu(), [i, j]); }); The body runs once per launch and records the tile IR (below). Tiles are immutable values of a static shape whose sizes are powers of two; a 1-d tile of C elements is the row [1, C]. Method names are the operators' (add, sub, mul, div, lt, ...) and `k` lifts a literal, so operator syntax can lower onto them. - [gizml:tokenizer](https://gizstack.com/docs/reference/gizml/tokenizer.md): text into model inputs. The token ids that a Hugging Face tokenizer.json gives a text or a pair of texts, as the tokenizers 0.19 crate runs it. The added tokens are found first and are not normalized. Each other part goes through the normalizer, the pre-tokenizer splits it into words, and the model turns each word into vocabulary pieces: WordPiece takes the longest pieces (BERT), Unigram the most likely ones (SentencePiece models: XLM-RoBERTa, multilingual E5, BGE-M3, T5), BPE the merges in rank order (byte-level BPE of GPT-2, Llama 3, Qwen2, Mistral). The post-processor's template puts the special tokens around the pieces, and the decoder turns ids back into text. - [gizml:trees](https://gizstack.com/docs/reference/gizml/trees.md): decision trees and their ensembles: CART (scikit-learn's exact splitter and its random splitter for extra trees), forests, bagging, AdaBoost (SAMME and R2), gradient boosting, and one histogram GBDT with depth-wise, leaf-wise and oblivious growth that the xgboost, LightGBM, HistGradientBoosting and CatBoost defaults share. Matrices are row-major f64; a row goes left when its value is at most the threshold. - [gizml:video](https://gizstack.com/docs/reference/gizml/video.md): video on top of gizhw:codec and gizlang:mp4. H.264 tracks of frame tensors (NVENC, or x264 through ffmpeg on other GPUs), NVIDIA's RTX Video effects and frame interpolation, DWPose's pose frames, an AAC-LC encoder on the host, WAV files and resampling, and any audio file and the frames of any video file through ffmpeg. - [gizhw:alsa](https://gizstack.com/docs/reference/gizhw/alsa.md): the Linux backend of gizhw:audio. PCM audio through ALSA (libasound.so.2, loaded at run time, so no build-time link): play and capture 16-bit little-endian interleaved frames on a PCM name ("default", "hw:0,0"). The library's constants are ALSA's (SND_PCM_STREAM_PLAYBACK 0, SND_PCM_STREAM_CAPTURE 1, SND_PCM_FORMAT_S16_LE 2, SND_PCM_ACCESS_RW_INTERLEAVED 3). - [gizhw:amdxdna](https://gizstack.com/docs/reference/gizhw/amdxdna.md): AMD XDNA (the Ryzen AI NPU, driver amdxdna): its GET_INFO queries (the layouts of drm/amdxdna_accel.h) and the run of a kernel: a hardware context, a device heap that holds the buffers, a firmware image and control code loaded into it, and an ERT START_NPU packet (amdxdna_ctx.h) that starts one run. A request is an ioctl on a Handle of gizhw:device; the NPU's generic view is gizhw:npu. - [gizhw:audio](https://gizstack.com/docs/reference/gizhw/audio.md): PCM sound on any platform. `devices` lists each sound device by an id the platform gives and a name; `open` takes the id, the direction and the wanted rate, channels and sample format. Linux plays and captures through ALSA (gizhw:alsa). A platform without a backend fails each call with the class and the platform named. - [gizhw:block](https://gizstack.com/docs/reference/gizhw/block.md): NVMe controllers through the kernel's passthrough ioctls (NVME_IOCTL_ADMIN_CMD and NVME_IOCTL_IO_CMD on the controller's node, /dev/nvmeN): Identify (the controller), the SMART health log, and a read of blocks by passthrough. The command is struct nvme_admin_cmd or nvme_passthru_cmd (72 bytes, the same layout), and the ioctls are the kernel's (linux/nvme_ioctl.h, checked against it). Every call is on a Handle of gizhw:device. - [gizhw:bus](https://gizstack.com/docs/reference/gizhw/bus.md): the buses a board exposes: a serial port's speed (termios2, any rate through BOTHER), GPIO lines (the character device's chardev v2 interface: a line request, then its values), I2C transfers (I2C_RDWR), SPI transfers (SPI_IOC_MESSAGE), USB control transfers (usbfs), and CAN frames (SocketCAN, raw). The ioctl numbers and the structs are the kernel's (termios.h, gpio.h, i2c-dev.h, spidev.h, usbdevice_fs.h, can.h), checked against those headers. Every ioctl is on a Handle of gizhw:device; the CAN socket and the interface lookup are libc calls through libcCall. - [gizhw:camera](https://gizstack.com/docs/reference/gizhw/camera.md): video capture on any platform. `cameras` lists each camera by an id the platform gives and a name; `open` takes the id with the wanted size and pixel format, and the frames come in that format. Linux captures through V4L2 (gizhw:v4l2). A platform without a backend fails each call with the class and the platform named. - [gizhw:codec](https://gizstack.com/docs/reference/gizhw/codec.md): the GPU's video codecs. NVIDIA's encoder (NVENC) makes H.264, HEVC and AV1 tracks (gizlang:mp4) from frames on the GPU; NVIDIA's decoder (NVDEC) reads video files into RGBA frames on the GPU. - [gizhw:device](https://gizstack.com/docs/reference/gizhw/device.md): the devices the machine has, as the program opens and drives them. Discovery reads sysfs (each class folder of /sys/class: its devices, their node, bus, ids and model); sensors and RAPL energy are readings; the NVIDIA GPU boards are read and controlled through NVML (the driver's management library). A Handle is one open device node: ioctl, mmap, read, write, poll and close through libc, with arguments in native memory. Every class module (npu, v4l2, evdev, bus, tpm, block, rdma, codec) drives its device through a Handle and calls libc through libcCall only here. The CPU's facts (features, caches, NUMA nodes) are gizlang:machine's. - [gizhw:drm](https://gizstack.com/docs/reference/gizhw/drm.md): The DRM requests every DRM-based accelerator of the accel class answers (drm/drm.h): the version request, which names the driver bound to a node, and the wait on a timeline syncobj. A request is an ioctl on a Handle of gizhw:device; the layouts are the kernel's. - [gizhw:evdev](https://gizstack.com/docs/reference/gizhw/evdev.md): the Linux backend of gizhw:input. Input devices (evdev, /dev/input/eventN): a device's name and ids, and its events as the kernel reports them (struct input_event: 24 bytes on 64-bit). Every call is on a Handle of gizhw:device, so no libc call is here. - [gizhw:gpu](https://gizstack.com/docs/reference/gizhw/gpu.md): a GPU found at run time through its vendor's driver library, opened with gizlang:native (nothing is linked or required at build time). AMD GPUs run LLVM IR compiled in-process by ROCm's code object manager (comgr, no clang); NVIDIA GPUs run PTX the CUDA driver compiles; Apple GPUs run the MSL that the system compiler turns into a pipeline (gizhw:metal, unified memory: a copy to the device is a plain copy). A program uses one `Gpu` for device memory (`Buffer`, freed when its last copy is dropped), kernels compiled once per source and launches; gizml:tensor generates the kernels. - [gizhw:input](https://gizstack.com/docs/reference/gizhw/input.md): keyboards, mice and other input devices on any platform. `inputs` lists each device by an id the platform gives and a name; `open` takes the id, and events come as Linux numbers them (linux/input-event-codes.h), the numbering each backend maps its own codes to. Linux reads evdev (gizhw:evdev). A platform without a backend fails each call with the class and the platform named. - [gizhw:kernel](https://gizstack.com/docs/reference/gizhw/kernel.md): GPU kernels written once and printed for every GPU. A Kernel is a small structured program (values, variables, if, loop, buffers, workgroup memory, barriers) built by calls; `llvm` prints it as LLVM IR for AMD (compiled by comgr), `ptx` as PTX for NVIDIA. A value is used only inside the block that made it and the blocks within; what crosses blocks goes through a variable. - [gizhw:metal](https://gizstack.com/docs/reference/gizhw/metal.md): an Apple GPU through Metal, driven with Objective-C's runtime and gizlang:native (nothing links at build time). gizhw:gpu opens it as kind "metal" and runs the MSL that Kernel.msl prints. Memory is unified: one MTLBuffer in shared storage is its `contents` on the CPU and its `gpuAddress` on the GPU, so a copy to or from the device is a plain copy. The GPU address is a buffer's address everywhere (a view is that address plus an offset, as with CUDA and HIP), and a kernel gets its arguments as one struct of 8-byte words, so no buffer is bound by index. Every live buffer is made resident (useResources) for the commands that follow. The driver does not know any program: it calls what `Objc` gives. `system` gives the libraries' own; a test gives a fake that records the calls. - [gizhw:npu](https://gizstack.com/docs/reference/gizhw/npu.md): the NPUs of the machine, whatever their driver, and the runs of kernels on them. An NPU is an accel-class device (/dev/accel/accelN) whose driver a backend serves (amdxdna.giz: AMD XDNA). A program uses one `Session` for device buffers, loaded kernels and their runs; a kernel's firmware image and control code are in its backend's formats (XDNA: an xclbin's PDI and an AIE instruction list, which Amdxdna.Txn writes). The DRM driver's name and version are read the same way for every NPU (drm.giz), and each backend adds its own firmware reads. Adding an NPU vendor is one backend and one case in each function here. - [gizhw:rdma](https://gizstack.com/docs/reference/gizhw/rdma.md): RDMA devices through libibverbs (libibverbs.so.1, loaded at run time): each device's name, firmware, node GUID and ids, and each port's state, MTU, LID, link width and speed, and link layer. The struct layouts are those of rdma-core's verbs.h (ibv_device_attr 232 bytes, ibv_port_attr 52 bytes), read by offset; the library's own functions do all the work. - [gizhw:tpm](https://gizstack.com/docs/reference/gizhw/tpm.md): a TPM 2.0 through the kernel's resource manager (/dev/tpmrm0): commands are built as bytes (big-endian, the TPM's wire format) and replies are checked and parsed. The TPM command codes and the layouts are the TCG TPM 2.0 specification's. Every call is on a Handle of gizhw:device. - [gizhw:v4l2](https://gizstack.com/docs/reference/gizhw/v4l2.md): the Linux backend of gizhw:camera. Video capture devices (V4L2, /dev/videoN): the capability and formats, and streaming through buffers the kernel maps. The ioctl numbers and the layouts are the kernel's (linux/videodev2.h, checked against it). Every call is on a Handle of gizhw:device. ## Internals - [Compiler](https://gizstack.com/docs/internals/compiler.md): How the compiler works: its modules, the bootstrap from the seed, golden cases and the build cache. - [Compute: all of the hardware from one program](https://gizstack.com/docs/internals/compute.md): How the compute engine works: SIMD, tensors, GPU kernels and models on every device class. - [GizDB: one database for records, analytics and search](https://gizstack.com/docs/internals/database.md): How GizDB works: storage, transactions, the SQL engine, analytics, search and the server. - [Multilingual architecture](https://gizstack.com/docs/internals/localization.md): How a page is translated: messages, catalogs, the language of a request and its cost. - [Memory](https://gizstack.com/docs/internals/memory.md): How Gizlang manages memory: values, references, regions, the collector and limits. - [Performance](https://gizstack.com/docs/internals/performance.md): How Gizlang is measured: the rules, the suites, the published results and their method. - [Runtime](https://gizstack.com/docs/internals/runtime.md): How the C runtime works: the platform layer that every program links. - [PGML: the PostgresML interface of GizDB](https://gizstack.com/docs/internals/sql-ml.md): How GizDB gives the PostgresML interface: the pgml functions, models, training and their tests. - [GizFS: storage internals](https://gizstack.com/docs/internals/storage.md): How GizFS works: owners, the physical format, durability, the file, block, object and S3 profiles, and their tests. - [System interface](https://gizstack.com/docs/internals/system.md): How a program reaches outside itself: the System value, files, processes, sockets, JavaScript and Python, and effects. - [Tools](https://gizstack.com/docs/internals/tools.md): How the toolchain is built and run: bin/giz, the command line and its caches. - [VM](https://gizstack.com/docs/internals/vm.md): How the VM runs JavaScript and Python: values, the collector, the interpreter, the JIT, Node and the CPython bridge. ## GizStack platform - [Deploy to GizStack](https://gizstack.com/docs/platform/deploy.md): Deploy a Gizlang app to GizStack from the console or the terminal, change it live, roll it back, and add domains, secrets and a database connection. - [Build an app on a team Database](https://gizstack.com/docs/platform/data-api.md): Read and write the tables of a team Database over HTTP, sign people in, and follow changes live, with supabase-js or plain HTTP. - [Built for AI agents](https://gizstack.com/docs/platform/agents.md): How AI agents read this site, call the toolchain and the console, and how a team's own Agents work in chats, apps, sites and APIs, with the same permissions as people. - [GizStack APIs](https://gizstack.com/docs/platform/api.md): Run Gizlang over HTTP: the Playground API and its result contract. ## Products - [Platform](https://gizstack.com/platform.md): GizStack is one platform built on one stack. Gizlang, GizDB, GizWeb and Storage are the base; Giz Apps, Computer, Drive, Agent, Ontology and Data are services on it. - [Gizlang](https://gizstack.com/gizlang.md): Gizlang is a compiled language with TypeScript syntax. Native speed, typed records, Result errors, no garbage collector, markup in the language and live code swap, in one toolchain. - [GizDB](https://gizstack.com/gizdb.md): GizDB is one database engine for transactions, analytics, key-value data and change feeds. Embed it in a Gizlang program, or run it as a PostgreSQL-protocol and Redis-protocol server. - [GizWeb](https://gizstack.com/gizweb.md): GizWeb builds full-stack web apps from one typed model. Server HTML is the state, a 1.2 KB kernel adds interaction, and live views update open pages when data commits. - [Storage](https://gizstack.com/storage.md): GizStack Storage keeps objects, files and block volumes in one replicated layer, with the S3 API, a POSIX mount, snapshots, clones and resumable transfers. - [Giz Apps](https://gizstack.com/apps.md): Describe an app or start from a template, edit its Gizlang code in the browser, and deploy it live in about two seconds. Each app gets its own address, database and storage. - [Giz Computer](https://gizstack.com/computer.md): Giz Computer gives persistent computers and volumes in GizStack regions, with terminals, a browser and a language server that people and agents share. - [Giz Drive](https://gizstack.com/drive.md): Giz Drive keeps files and documents with versions, sharing, search and sync, on the same storage as your apps and computers. - [Giz Agent](https://gizstack.com/agent.md): Giz Agent runs AI agents that change code, data and documents through the same checked Operations as people, with approvals, budgets and one-step restore. - [Giz Ontology](https://gizstack.com/ontology.md): Giz Ontology models a business as typed objects, relations and Actions, with grids, forms, charts and dashboards derived from them, and industry packages that run from day one. - [Giz Data](https://gizstack.com/data.md): Giz Data gives analytics, dashboards and BI directly on GizDB, with metrics defined once and live results, and no copy to a warehouse. - [Roadmap](https://gizstack.com/roadmap.md): Every GizStack capability and whether it runs today, from one status table, and the goals we measure ourselves against. ## Trust - [Security](https://gizstack.com/security.md): How to report a vulnerability, and how GizStack protects your work. - [Private preview](https://gizstack.com/private-preview.md): gizstack.com is invite-only during the preview: who gets in, what others see, and how to ask for access. - [Status](https://gizstack.com/status.md): The health address of each service, and the incident history. - [Pricing](https://gizstack.com/pricing.md): What GizStack costs. During the preview, nothing is charged. ## Footer - [Install Gizlang](https://gizstack.com/download.md): Install the native Gizlang toolchain in your home folder, with one command or a signed installer. - [License](https://gizstack.com/license.md): Gizlang is open source under the MIT license. The full license text, and what GizStack charges for.