Loaders¶
Loaders turn dropped files into sources, reading CSV, Parquet, JSON, NumPy, safetensors, image and WAV files, refusing pickle, Arrow IPC and HDF5 files, and running a Python loader in its own process for other formats.
| Field | Value |
|---|---|
| ID | SPC-03 |
| Status | Shipped |
| Scope | Core |
| Pillar | Builder and Specs |
| Sprint | None |
| Depends On | None |
| Unblocks | Mesh Files (REN-18)Catalog ( SPC-04)Arrow IPC Reader ( SPC-31)HDF5 Reader ( SPC-32)Image Stacks ( SPC-33)Python Loader over Many Files ( SPC-34) |
| Docs | Builder Pane, Sources |
| Branches | None |
| Design | Loaders |
Coverage Ledger¶
- Branch
sprint3-int-kind, 0 commits that main lacks (107 ahead of the merge base). Work on the loader kinds in the spec format, which reached main through a pull request (patch ids and subjects match). - Branch
sprint3-loaders, 0 commits that main lacks (24 ahead of the merge base). Work on the loaders, which reached main through a pull request (patch ids and subjects match). - Branch
sprint3-pyloader, 0 commits that main lacks (38 ahead of the merge base). Work on the Python loader, which reached main through a pull request (patch ids and subjects match). - design/builder-overview.md, under The parts. Parts diagram and table: spec format, loaders, catalog, command layer, session, caliper-mcp, side chat, widget agent, caliper-agent.
- design/builder-overview.md, under What is built. Loaders read CSV, TSV, Parquet, JSON, JSONL, npy, npz, safetensors, PNG, JPEG, WAV; refuse pickle; run a Python loader out of process.
- design/builder-overview.md, under The integration order after sprint 2. Item 6: drag and drop of files into the window.
- design/builder-pane.md, under The file drop. Files dropped on the window import through data.import from the ui origin, select the new sources and list each refused path with its reason.
- design/builder-session.md, under Loaders, paths and approval. Loader commands record their undo, accept outside paths only from ui and builder or earlier grants, and ask before an agent runs a Python loader.
- design/builder-session.md, under Loaders, paths and approval. loader.delete with keep_outputs answers loader.unsupported because the store deletes a loader's outputs with it.
- design/builder-session.md, under Limits. loader.delete with keep_outputs needs LoaderStore::remove(id, keep_outputs).
- design/command-layer.md, under data. data.query runs one read-only SELECT and data.import imports files into loaders; outside paths only from ui and builder.
- design/command-layer.md, under loader. loader.list, loader.describe, loader.create, loader.update, loader.run and loader.delete; running a Python script always asks every origin except ui and builder.
- design/loaders.md, under The loader format v0. A loader is a TOML recipe loaders/<id>.loader.toml with caliper_loader = 0, an input path and reader, reader options and outputs; parsing is strict with line and column errors.
- design/loaders.md, under Keys. The table of loader keys: id, title, input.path and reader, reader options, and per-output name, mode (view or table), sql, tensor, table and transform.
- design/loaders.md, under Readers. The reader table: csv, parquet, json, jsonl, arrow, npy, npz, safetensors, hdf5, image, wav and python, with extensions, magic bytes and options.
- design/loaders.md, under Readers. The tabular readers csv, parquet, json and jsonl through DuckDB, with options such as header, delimiter and union_by_name.
- design/loaders.md, under What each reader produces. The tensor readers: npy (versions 1 to 3, all byte orders), npz (zip, stored or deflate, zip64), safetensors (header plus mapped bytes, BF16 converted to f32), image (PNG and JPEG to u8 [H, W, C]) and wav (PCM and float to [frames, channels] with rate_hz).
- design/loaders.md, under What each reader produces. The json and jsonl readers need DuckDB's JSON extension, which the page says the host does not link yet.
- design/loaders.md, under Inferring the reader. Reader inference from extension and the first 16 bytes, with loader.reader_mismatch and loader.no_reader, and infer_loader making the default loader for a dropped file.
- design/loaders.md, under Globs. input.path may be a glob (*, ?, **), expanded by the library with confinement checks, sorted, bounded, giving one relation for tabular readers and one tensor per file for tensor readers.
- design/loaders.md, under Tables, views and SQL. Table outputs become views (default, read on each query) or copied tables in workspace.duckdb, with an optional single SELECT over the relation input checked by DuckDB's parser.
- design/loaders.md, under Tensor outputs and transforms. Tensor outputs select one tensor or all with tensor = "*" and may apply the slice, reduce and normalise transforms, whose CPU reference implementation fixes the numeric rules.
- design/loaders.md, under Statistics for catalog.sample. tensor_stats and tensor_sample give the count, non-finite count, min, max, mean and standard deviation and a bounded slice that catalog.sample returns.
- design/loaders.md, under Where loaders and their outputs are stored. The workspace layout of loaders/, tensors/, loader-outputs/, inputs.toml and workspace.duckdb, and LoaderStore::rebuild() that recreates every database row from the text files.
- design/loaders.md, under caliper.loaders. The caliper.loaders table holds each loader's recipe, times and last run status.
- design/loaders.md, under caliper.sources. The caliper.sources table holds each output's kind, columns, dtype, shape, storage columns and wire flag, and runs are atomic.
- design/loaders.md, under The C++ interface. The public headers of caliper_builder_loaders and LoaderStore with its mutex and the DuckDB-behind-one-file rule.
- design/loaders.md, under The pickle policy. Native readers never load a pickle: .pkl, .pt, .pth, .ckpt and .joblib files, pickle markers, torch zip archives and object-dtype arrays are refused with loader.pickle_refused, which points to safetensors or the Python loader.
- design/loaders.md, under The Python loader. A Python loader runs a user's script in a separate process and takes back only .npy, Parquet and CSV files, which Caliper checks as untrusted input.
- design/loaders.md, under The recipe. The Python loader recipe: reader = "python", a script inside the workspace, an interpreter and a timeout, with outputs that select tensor or table by name or "*".
- design/loaders.md, under The script. The script defines load(path, out) and uses out.tensor, out.table, out.warn and out.torch_weights, which reads torch files weights-only; without pyarrow tables are written as typed CSV.
- design/loaders.md, under The host and the process. loader_host.py is embedded in the library and run with python -I through acp::run_process, with a scrubbed environment, a time limit with SIGTERM then SIGKILL and bounded output.
- design/loaders.md, under The manifest and what Caliper checks. The script's manifest.json is treated as hostile input: names, file names, links, sizes, dtype and shape are all checked before the files are read by the native readers.
- design/loaders.md, under Where the outputs are kept. Checked outputs move to loader-outputs/<id>/run-<n>/ and are read back by rebuild() without running the script.
- design/loaders.md, under Approval. LoaderStore::run refuses a Python loader without RunOptions::allow_python and the command layer sets it only after the person approved, so an agent's run of a script asks.
- design/loaders.md, under Limits. The Python loader's limits table: 120 s time default (3,600 at most), 1 MiB per output stream, 4 GiB per file, 16 GiB in all and one input file.
- design/loaders.md, under What the Python loader does not do yet. A script that leaves a process behind or leaves the process group keeps running; this is a known gap, not a planned change.
- design/loaders.md, under Safety. Safety of loaders: confinement of paths, size checks of every header, a locked-down DuckDB and a read-only query helper.
- design/loaders.md, under Paths and confinement. A loader reads files inside the workspace or granted by the person; grants live in inputs.toml and only a user action calls grant(); symbolic links that leave are refused.
- design/loaders.md, under Sizes. Every reader checks header sizes against the file's real size and a table of limits for dimensions, bytes, members, image sides and results.
- design/loaders.md, under What the database may read. workspace.duckdb is opened with external access off, allowed directories and files, extensions off and the configuration locked.
- design/loaders.md, under The query helper. LoaderStore::query runs exactly one SELECT in a transaction that is always rolled back, with a row limit and a timeout; it backs data.query and catalog.sample.
- design/loaders.md, under Errors. The table of loader.*, catalog.*, tensor.*, query.timeout and transform.* error codes.
- design/loaders.md, under What is built and what is planned. Built on the branches sprint3-loaders and sprint3-pyloader: the tensor type and transforms, the readers, the refusals, the tabular readers, the loader format, LoaderStore and the Python loader with tests.
- design/loaders.md, under What is built and what is planned. Planned: the CatalogProvider adapter for loader outputs.
- design/loaders.md, under Decisions. Recorded loader decisions: grants in inputs.toml, absolute paths in views, library-side glob expansion, bf16 to f32, .npy derived tensors, unknown keys as errors and the Python loader's rules.
- design/roadmap.md, under Phase 3: agent-built panels. Drop data in, make loaders, build visuals by hand in a builder pane, with the side chat, the widget agent, or an outside agent over MCP; everything built is data.
- design/roadmap.md, under Phase 3: agent-built panels. The parts: command layer, loaders, catalog, spec format with seven primitives, spec applet kind, caliper-mcp, side chat, widget agent.
- design/widget-agent.md, under Entry points. A prompt line under a dropped file's row, working on the loader the drop created and its outputs, with no change for a question.
- Builder Pane, Sources. The Sources palette lists the spec sources and the catalog grouped as Tables, Tensors, Live, Feeds and Metrics, with refused files.
- Pull request #17. Pull request 17 (merged) delivers sprint 3: the builder libraries, spec format, loaders, catalog, command layer and session, caliper-mcp, the side chat, the widget agent, command endpoints of Caliper API, the spec runtime and applets, the builder pane, drag and drop, approval cards and the first slice of the browser spec page.
- Orchestrators' notes,
sprint3-integration/PR.md. Libraries under src/builder: the spec format, validator and schema, loaders, the catalog, the command layer and the session.