Skip to content

feat(unsloth): model-load keystone (#24) — ensure the engine has a model (TDD) - #1712

Merged
joelteply merged 1 commit into
canaryfrom
feat/unsloth-autoload-keystone
Jun 21, 2026
Merged

joelteply merged 1 commit into
canaryfrom
feat/unsloth-autoload-keystone

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

unsloth Studio starts empty — nothing serves until a model is loaded. This is the reliable-startup keystone: pure delegation over unsloth's HTTP surface (GET /v1/models, POST /api/inference/load), never a CLI subprocess.

TDD-first: the decision (loaded → skip; empty → load; unreachable/failed → degrade, never panic) lives in ensure_model_loaded() over the UnslothControl trait, unit-tested against a fake (zero network). UnslothHttp is the real reqwest impl, mirroring endpoints verified live on this box (manual /api/inference/load + /v1/chat reply confirmed end-to-end).

Tests (4, green): already-loaded no-op (no reload churn) · empty→load · unreachable→degrade-without-loading · failed-load→degrade-with-reason. Degrade-not-panic (#26).

Next: call it at startup with the configured model → live persona bringup reasons through the fueled engine. Additive (new module behind a trait).

…del (TDD)

unsloth Studio starts EMPTY (/v1/models -> []; inference -> "No GGUF model
loaded"), so nothing a persona needs serves until something tells unsloth what
to load. This is that keystone — the reliable-startup piece ("automatic after
the key"), pure delegation over unsloth's HTTP surface (UNSLOTH-INTEGRATION.md
§3.5), never a CLI subprocess.

TDD-first: the decision (loaded? -> skip; empty? -> load; unreachable/failed
-> DEGRADE, never panic) lives in ensure_model_loaded() over the UnslothControl
trait, unit-tested against a fake with zero network — that's the part that must
be reliable. UnslothHttp is the real reqwest impl (GET /v1/models,
POST /api/inference/load), mirroring the endpoints verified live on this box
(manual load + /v1/chat reply already confirmed end-to-end).

Tests (4, all green): already-loaded is a no-op (no reload churn); empty engine
loads the desired model; unreachable engine degrades WITHOUT attempting a load;
failed load degrades with the reason. Degrade-not-panic per #26.

Next: call ensure_model_loaded at startup with the configured model, then the
live persona bringup reasons through the fueled engine.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@joelteply
joelteply merged commit 0bfa415 into canary Jun 21, 2026
4 checks passed
@joelteply
joelteply deleted the feat/unsloth-autoload-keystone branch June 21, 2026 05:13
joelteply added a commit that referenced this pull request Jun 21, 2026
The keystone (#1712) gave us ensure_model_loaded over a TDD'd trait; this
wires it into boot so the engine is fueled "automatically after the key."

unsloth Studio boots EMPTY — /v1/models is [] and any inference returns
"No GGUF model loaded" until something loads one. On startup the core now
spawns ensure_startup_model(): reads UNSLOTH_MODEL from config and, if set,
ensures that model is loaded into the engine.

- startup_model_action(Option<String>) -> StartupModelAction is the pure,
  TDD-tested config decision: set+non-empty -> Ensure(model); unset or blank
  -> Skip(reason). NO hardcoded default model path — auto-pick from
  /api/hub/cached-models is a future enhancement, not a baked-in path that's
  wrong on every box but the author's.
- ensure_startup_model() dispatches on it, delegating to ensure_model_loaded
  over the real HTTP surface, logging the outcome.
- Spawned fire-and-forget in main.rs alongside the other boot tasks: boot is
  never gated on the engine, and it's fully degrade-safe — engine down or
  load fails -> degrade+log, the substrate stays up on its fallback path,
  never panics ([[substrate-is-a-good-citizen-on-the-host]] / #26).

4 new unit tests cover the config decision (ensure / skip-no-default /
blank-is-unset / trimmed). Existing keystone tests unchanged.

Co-authored-by: Claude Opus 4.8 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant