Repository navigation
Commit 5db8f4d
feat: fit()/predict()/backtest() SQL surface + hardened training core
Reshape the tabular and evaluation surface into the scikit-learn shape agents
guess, and extract and harden the native-student training core that backs it.
Surface:
- fit(f1, ..., fN, label [, options]) is an aggregate over the caller's rows and
returns a registered model id or a serialized blob; predict(model, f1, ..., fN
[, options]) is a scalar serving one prediction per row (deserialized once,
cached on the model argument). The label is the last positional argument; the
optional trailing '{...}' is always the options object.
- backtest(ts, value, horizon [, options]) is an aggregate (matching forecast /
detect_anomalies) that runs rolling-origin evaluation and returns one JSON
document; backtest_rows() expands it into typed rows. The old TVF is renamed
predict_batch.
- The tabular training core (tree / gradient-boosted / MLP fitters) moves to
predict-train.{c,h}, shared by fit() and the distill recipes.
Correctness and safety hardening (a thorough review pass, fixed at the root and
swept across every sibling, not only where first flagged):
- Memory safety: a compile-time assert that predict()'s feature buffer holds any
student the loader admits; re-fetch after sqlite3_set_auxdata to avoid a
use-after-free; propagate OOM through the row-cursor mprintf paths instead of
silent NULL columns; 64-bit sizing for model-scaled allocations; bounded,
overflow-safe onnx io_spec arrays (a 32-bit-wasm overflow); a fit() training-set
cap.
- Determinism: total-order split comparators so the tree, and its content_hash,
are identical across platforms/libc (no reads of uninitialized task-union
fields).
- Fail loud, never silently: reject non-finite features/labels/teacher cells and
NULL labels; surface malformed-JSON parse errors, prepare failures, and
mid-read step errors; preserve distinct error codes; cap the classifier
vocabulary at PREDICT0_MAX_CLASS during interning and parsing; require a
positive json-array cap rather than a silent-unbounded footgun.
- The receipt tool's operation taxonomy is restructured (aggregate vs row-shaped,
with the *_rows TVFs first-class and wrapper-aware inference).
Tests: adversarial coverage for the new surface and every hardening path
(malformed/oversized/boundary/non-finite inputs asserting concrete PREDICT_ERR_*
codes); the corrupt-blob tests now supply a matching content hash so they reach
the bounds-checked deserializer; the C soak drivers assert row counts and the
specific error code per branch, and propagate statement failures to the exit
code.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent cb86af3 commit 5db8f4d
25 files changed
Lines changed: 3290 additions & 1787 deletions
File tree
- scripts
- skills/prediction-receipts/scripts
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
0 commit comments