Skip to content

j0yen/cradle

Repository files navigation

cradle

A pipeline for small self-trained models: harvest labeled data from Claude transcripts, orchestrate a training shellout, and bake the result toward a Rust crate.

Why it exists

A personal-tools stack accumulates judgments worth learning — which session a turn should redirect to, whether a session was productive, which playbook a request matches. The training data for those judgments already exists, scattered through ~/.claude/projects/**/*.jsonl. cradle turns those transcripts into labeled examples, drives a per-model trainer, and generates the scaffolding to bake a trained checkpoint into a Rust crate that the consumer can call without ever touching Python.

What's actually here

The harvest and orchestration core is built and tested. The model side is mostly scaffolding — read the status of each piece before depending on it.

A workspace of three Rust crates plus the cradle binary:

cradle/
├── crates/
│   ├── cradle-harvest/    transcript JSONL → labeled examples + train/val/test split
│   └── cradle-features/   shared featurization registry (turn_pair_v1)
├── src/                   cradle binary (clap CLI + orchestrator)
└── models/
    ├── redirect/             spec.toml + a train.py stub; the one model with a label extractor
    ├── session-productivity/ spec.toml only
    └── playbook-match/       spec.toml only

Subcommands

Command What it does Real state
cradle harvest <model> Walk transcripts, apply the named label extractor, write data/<model>/{train,val,test}.jsonl Works — redirect is the only model with an extractor
cradle train <model> Shell out to uv run python models/<model>/train.py with stable env vars Orchestration works; train.py is a user-supplied skeleton, not real training
cradle bake <model> Generate output/morsel-<model>/ — a Rust crate with Cargo.toml, src/lib.rs, and a placeholder weights.rs Generates the crate skeleton; real weight baking awaits a morsel bake binary that doesn't exist yet
cradle build <model> harvest → train → bake, end to end Works, subject to the limits above
cradle status [--json] Per-model on-disk status Works

The honest summary: cradle can harvest real data and produce a real, compilable output crate, but the two ends — actual PyTorch training and actual weight baking — are stubs waiting on a real train.py and a real morsel CLI.

Install / run

cargo build --workspace
cargo test  --workspace
cargo run --bin cradle -- status
cargo run --bin cradle -- harvest redirect --models-dir models --transcripts-dir ~/.claude/projects

Requires Rust 1.85+, edition 2024.

Why a Python shellout for training

PyTorch's training story is mature, and the trainer runs once, offline, per re-bake cycle. The trained safetensors then leave the Python world entirely and never reach the consumer — the bake step is what carries them into Rust. A pure-Rust trainer (candle, burn) is a later question; the harvest, features, and orchestration surfaces don't change either way.

Status

v0.2.0, under construction. The intent-card (agent/intent-card.json) lists 12 MUST + 1 SHOULD acceptance criteria, all green at gate time, with tests at tests/acceptance_acN.rs. "Green at gate time" covers the orchestration contract — the shellout wiring, the file layout, the crate codegen — not end-to-end model quality, because the trainer and the baker are still stubs. Treat this as a working skeleton, not a trained-model factory.

Origin

Built via /autobuilder from PRD-cradle.md on 2026-05-27, replacing a hand-built prototype. cradle bake and the full cradle build pipeline landed in v0.1.1 (2026-05-30); v0.2.0 (2026-06-02) aligned the workspace versions.

Workspace lint posture

  • unsafe_code = "deny" workspace-wide.
  • clippy pedantic + nursery as warn; BAD_RUST patterns (unwrap, expect, panic, todo, unimplemented, dbg!) as deny in production code.
  • cargo deny check bans licenses sources is the supported subset (full cargo deny check errors against cargo-deny 0.18.3 on a CVSS 4.0 advisory entry — fixed upstream in 0.18.4+).

License

Dual-licensed under MIT OR Apache-2.0. See LICENSE-MIT and LICENSE-APACHE.

About

Under construction: harvest labeled data from Claude transcripts, orchestrate train, bake toward a Rust crate

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors