Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

add Ternary Bonsai 2 27B as a drafter-free llama-server launcher preset

[._.]/ Adam Eivy11d0f9ca35cd
diff --git a/docs/README.md b/docs/README.md
index a0aff24dbb..8ceb0acc2e 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -45,7 +45,7 @@ Start with the [product surface map](./features/product-surfaces.md) for a compl
App management: [app-wizard](./features/app-wizard.md) · [autofixer](./features/autofixer.md) · [browser](./features/browser.md) · [error-handling](./features/error-handling.md) · [jira-sprint-manager](./features/jira-sprint-manager.md)
-Chief of Staff: [chief-of-staff](./features/chief-of-staff.md) · [cos-agent-runner](./features/cos-agent-runner.md) · [cos-enhancement](./features/cos-enhancement.md) · [self-improvement-audits](./features/self-improvement-audits.md) · [agent-context](./features/agent-context.md) · [agent-skills](./features/agent-skills.md) · [memory-system](./features/memory-system.md) · [claude-ollama](./features/claude-ollama.md) · [grok-box-local-mind](./features/grok-box-local-mind.md) · [fleet-llm-host](./features/fleet-llm-host.md) · [mtplx](./features/mtplx.md) · [slotstream](./features/slotstream.md) · [dflash2](./features/dflash2.md) ([DSpark vs DFlash 2](./research/2026-08-19-dspark-vs-dflash2.md)) · [qwen38-rtx3090](./features/qwen38-rtx3090.md) ([3090 bring-up](./research/2026-08-21-qwen38-rtx3090-vllm.md)) · [sglang-qwen38](./features/sglang-qwen38.md) ([SGLang Hopper/Blackwell evaluation](./research/2026-08-21-sglang-qwen38-27b.md)) · [prompt-manager](./features/prompt-manager.md)
+Chief of Staff: [chief-of-staff](./features/chief-of-staff.md) · [cos-agent-runner](./features/cos-agent-runner.md) · [cos-enhancement](./features/cos-enhancement.md) · [self-improvement-audits](./features/self-improvement-audits.md) · [agent-context](./features/agent-context.md) · [agent-skills](./features/agent-skills.md) · [memory-system](./features/memory-system.md) · [claude-ollama](./features/claude-ollama.md) · [grok-box-local-mind](./features/grok-box-local-mind.md) · [fleet-llm-host](./features/fleet-llm-host.md) · [mtplx](./features/mtplx.md) · [slotstream](./features/slotstream.md) · [dflash2](./features/dflash2.md) ([DSpark vs DFlash 2](./research/2026-08-19-dspark-vs-dflash2.md), [Ternary Bonsai 2 27B](./research/2026-09-18-ternary-bonsai-2-27b.md)) · [qwen38-rtx3090](./features/qwen38-rtx3090.md) ([3090 bring-up](./research/2026-08-21-qwen38-rtx3090-vllm.md)) · [sglang-qwen38](./features/sglang-qwen38.md) ([SGLang Hopper/Blackwell evaluation](./research/2026-08-21-sglang-qwen38-27b.md)) · [prompt-manager](./features/prompt-manager.md)
- [Persistent Mind continuous play + local context](./features/persistent-mind-continuous-play.md) — explore/invent playbook and mind-adjustable `numCtx` clamps
Identity & self: [digital-twin](./features/digital-twin.md) · [identity-system](./features/identity-system.md) · [soul-system](./features/soul-system.md) · [privacy-center](./features/privacy-center.md) · [post](./features/post.md) (insights design spike: [plans/2026-06-03](./plans/2026-06-03-cross-domain-insights-engine.md))
diff --git a/docs/features/dflash2.md b/docs/features/dflash2.md
index 745e560977..2f038758a5 100644
--- a/docs/features/dflash2.md
+++ b/docs/features/dflash2.md
@@ -167,6 +167,18 @@ can't fight your choice:
Vocabulary reference: llama.cpp `docs/speculative.md`.
+### 2d. Presets that speculate with nothing at all
+
+A preset may also carry `--spec-type none` and no drafter, in which case the
+launcher is just PortOS's way of starting one checkpoint. That exists for models
+whose weights `llama-server` is the only local runtime able to load — the
+**Ternary Bonsai 2 27B** preset is the case it was added for. Its ternary packs
+(`PQ2_0`, `PTQ1_0`) need a build of PrismML's llama.cpp fork; Ollama and LM
+Studio both embed a stock llama.cpp and cannot run them, which is why that model
+has no entry in the Ollama/LM Studio catalog. Build recipe, PATH wiring, and the
+measured cost of using the fork's *prebuilt* macOS binary instead of a
+from-source build: [Ternary Bonsai 2 27B on Apple M5 Max](../research/2026-09-18-ternary-bonsai-2-27b.md).
+
### 3. Use in PortOS
1. Navigate to **AI Providers** (`/ai`) or **Models → Runtimes**.
2. Verify **OpenCode llama TUI** is enabled.
diff --git a/docs/research/2026-09-18-ternary-bonsai-2-27b.md b/docs/research/2026-09-18-ternary-bonsai-2-27b.md
new file mode 100644
index 0000000000..b7e613698c
--- /dev/null
+++ b/docs/research/2026-09-18-ternary-bonsai-2-27b.md
@@ -0,0 +1,132 @@
+# Ternary Bonsai 2 27B — harness and runtime on Apple M5 Max
+
+Date: 2026-09-18
+
+## Decision
+
+Run it on **llama.cpp built from the PrismML fork's source**, served by
+**`llama-server`** — which is PortOS's existing `llama` local runtime, so the
+model needed a launcher preset (`ternary-bonsai-2-27b` in
+`server/lib/specDecodePresets.js`) and no new runtime, provider kind, or
+process manager.
+
+Take the **`PQ2_0`** pack (6.7 GiB on disk), not the smaller `PTQ1_0` (5.9 GB)
+and not the `F16` reference (53.8 GB).
+
+Three runtimes that look plausible are not options here:
+
+- **Ollama and LM Studio** both embed a stock llama.cpp and cannot load the
+ file. This is why the model is absent from `server/lib/localLlmCatalog.js`,
+ which is the Ollama↔LM Studio catalog; that module now carries a note saying
+ so, because the failure mode on the neighbouring Bonsai 1 pack is silent.
+- **Stock llama.cpp** — including the Homebrew build this machine already had
+ on PATH — refuses `PQ2_0` and `PTQ1_0` as unknown types. Measured below.
+- **MLX** has a pack (`prism-ml/Ternary-Bonsai-2-27B-mlx-2bit`, 8.60 GB) and it
+ is the faster-on-paper option, but it declares `model_type:
+ prism_hadamard_qwen35` and ships its own loader in `runtime/`. An ordinary
+ MLX loader skips the activation transform and the inverse embedding lookup
+ and returns *wrong output rather than an error*. It also exposes no
+ OpenAI-compatible server, so PortOS would have to grow one — where
+ `llama-server` already speaks the protocol every PortOS provider path uses.
+
+## What the model is
+
+PrismML's ternary pack of Qwen3.8-27B, published 2026-09-17 under Apache 2.0.
+Weights are `{−1, 0, +1}` with one FP16 scale per group of 128, covering
+embeddings, attention projections, MLP projections and the LM head — 2.13
+effective bits per weight for `PQ2_0`. The publisher reports an aggregate 84.78
+across 14 thinking-mode benchmarks, 98.2% of the FP16 baseline, at roughly 11%
+of its size. 262K context, and a vision tower via a separate `mmproj` sidecar.
+
+`PQ2_0` over `PTQ1_0` is the publisher's own guidance and it matches the
+hardware: `PQ2_0` is the pack measured on Apple Silicon and the faster
+prompt-processing pack on every backend, while `PTQ1_0`'s decode advantage is
+specific to Ada-generation and L4 cards. The 1.3 GB saved is irrelevant on a
+128 GB machine.
+
+## Measurements
+
+Apple M5 Max, 128 GB unified memory, macOS 26.6.2. `llama-bench -p 512 -n 128
+-r 2` against `Ternary-Bonsai-2-27B-PQ2_0.gguf` (6.70 GiB, 26.90 B params,
+reported by the loader as `qwen35 27B PQ2_0 - 2.13 bpw (group 128)`).
+
+| Binary | Prompt (pp512) | Decode (tg128) |
+| --- | ---: | ---: |
+| Fork built from source (`5d80cff`, AppleClang 21) | 701.76 ± 5.64 t/s | 40.57 ± 1.36 t/s |
+| Fork prebuilt `macos-arm64` asset (`prism-b10685`) | 243.57 ± 2.64 t/s | 38.45 ± 1.52 t/s |
+| Homebrew llama.cpp 0.4.0 (build 10809) | failed to load model | — |
+
+**Build the fork; do not use its published macOS binary.** The prebuilt
+`llama-prism-*-bin-macos-arm64.tar.gz` was compiled on an older macOS runner,
+so on this OS it logs `ggml_metal_library_init_from_source: error compiling
+source` and then `the tensor API is not supported in this environment -
+disabling`. It still runs, which is the trap — it just does prompt processing
+**2.9× slower**. Decode barely moves, because decode is memory-bandwidth bound
+and the Metal 4 tensor path is a compute win. The fork's own HEAD commit is
+`release: build macOS arm64 on macos-26 so the Metal 4 tensor path compiles
+(#177)`, dated two days before this evaluation, so the published macOS asset
+should catch up; verify `has tensor = true` in the startup log before trusting
+one.
+
+Decode landed ~14% under the publisher's ~47 t/s figure for this chip. The most
+likely explanation is contention rather than a configuration fault: the machine
+was running other work throughout, and the `has tensor = true` line confirms the
+fast path was active.
+
+The preset's own launch line was then run end to end
+(`--spec-type none --ctx-size 8192 -ngl 99 --parallel 1 --alias …`):
+`/v1/models` reported the alias and `/v1/chat/completions` returned the
+requested string with a coherent token count, so the OpenAI-compatible surface
+every PortOS provider path depends on works against this pack unmodified.
+
+## Recipe
+
+Weights and binaries are machine-local; none of this belongs in the repository.
+
+```bash
+# 1. Build the fork (Metal is the default on macOS; the CUDA flag is Linux/Windows)
+git clone --depth 1 https://github.com/PrismML-Eng/llama.cpp.git \
+ ~/.portos/runtimes/llama.cpp-prism-src
+cd ~/.portos/runtimes/llama.cpp-prism-src
+cmake -B build -DCMAKE_BUILD_TYPE=Release -DLLAMA_CURL=OFF
+cmake --build build -j "$(sysctl -n hw.ncpu)"
+
+# 2. Put it ahead of any stock llama.cpp on the PATH the PortOS server inherits
+mkdir -p ~/.portos/bin
+ln -sf ~/.portos/runtimes/llama.cpp-prism-src/build/bin/llama-server ~/.portos/bin/llama-server
+```
+
+PortOS resolves the binary with `findCommandOnPath('llama-server')` against the
+server process's own PATH (`resolveLlamaServerBinary` in
+`server/services/llamaServerManager.js`), so `~/.portos/bin` has to precede
+`/opt/homebrew/bin` for the PortOS process — not merely in an interactive
+shell. Its Homebrew update path already handles a foreign binary correctly: it
+detects that the active `llama-server` is not the linked keg and declines to
+touch it rather than overwriting the fork.
+
+Then fetch the weights from **Models → Runtimes** by selecting the
+**Ternary Bonsai 2 27B** preset and using its Download button, or by hand:
+
+```bash
+curl -L -o ~/.portos/models/Ternary-Bonsai-2-27B-PQ2_0.gguf \
+ https://huggingface.co/prism-ml/Ternary-Bonsai-2-27B-gguf/resolve/main/Ternary-Bonsai-2-27B-PQ2_0.gguf
+```
+
+The preset launches with no drafter (`--spec-type none`). Sampling the
+publisher recommends: thinking mode `temperature=1.0, top_p=0.95, top_k=20`;
+instruct mode `temperature=0.7, top_p=0.80, top_k=20`.
+
+## Known gaps
+
+- **Vision is not reachable through PortOS.** The model's image input needs
+ `--mmproj` pointed at a sidecar (`Ternary-Bonsai-2-27B-mmproj-Q8_0.gguf`,
+ 629 MB), and the launcher builds no such flag — `pickGgufSibling` in
+ `server/services/specDecodeModels.js` actively filters projector files out of
+ the download candidates. A text-only launch is what the preset delivers;
+ tracked as #7611.
+- **Speculative decoding is untested here.** The preset drafts with nothing.
+ PrismML's demo repository documents a speculative setup; nothing in this
+ evaluation measured whether a drafter helps this pack.
+- **The MLX pack was not measured.** Rejected on runtime-integration grounds
+ (custom loader, no OpenAI-compatible server), not on performance — the two
+ are within noise of each other on published numbers.
diff --git a/server/lib/README.md b/server/lib/README.md
index 5032be5c45..ba70605cd7 100644
--- a/server/lib/README.md
+++ b/server/lib/README.md
@@ -494,7 +494,7 @@ pm` default, `NPM_CONFIG_PREFIX`, nvm/Volta) installed `codex` successfully and
| `modelAbuseGuard.js` | Pinned model-abuse boundary contract: Prompt Guard metadata, deterministic abuse signals (`hiddenCodePointSummary` for invisible/direction-control/C0-C1 code points, `invisibleClusterSummary` for a dense cluster of the exempt ones, `describeEncodedPayload` for compressed/opaque blobs — the last scoped to `CODE_CONTENT_SOURCES` so a private message carrying base64 is not model abuse — plus hidden HTML comments/collapsed markup that address a model), complete classifier-window coverage validation, chunk/timeout limits, fixed dependency versions (`MODEL_ABUSE_GUARD_PYTHON_PACKAGES`), and `MODEL_ABUSE_GUARD_STAGES` / `modelAbuseGuardStageReadiness` for the operator-facing install checklist. Pure. |
| `diffHiddenContentScan.js` | Pre-LLM gate over a unified diff — `scanDiffForHiddenContent(diff)` reports invisible/direction-control Unicode (added lines and filenames), dense clusters of the invisible characters the rules otherwise exempt, compressed or opaque encoded payloads, a new symlink that leaves the repository or a new git submodule, a non-media binary patch, and inline script in SVG/HTML/XML, keyed `path:line`; `formatHiddenContentFindings` renders them for a CI log. Detectors for the Unicode/encoded rules are shared with `modelAbuseGuard.js` (same rules, applied to external PR content). Lockfiles skip the encoded rule but never the Unicode ones, a leading BOM is allowed, and `portos-allow-hidden-content` on the line itself opts out of the added-line rules. Driven by `scripts/scan-diff-hidden-content.js`, which CI runs on every pull request before any reviewer reads the diff (`core.quotepath=false` so a stealth filename is not octal-escaped past the detector). Pure. |
| `localLlmDisk.js` | Pure on-disk reasoning for the migrate "copy GGUF locally instead of re-downloading" fast-path (Ollama manifest/blob parsing, LM Studio path layout, MLX/projector/shard detection) plus the Hugging Face registry addressing used to finish an abandoned Ollama pull. |
-| `specDecodePresets.js` | Curated llama-server speculative-decoding presets (target + drafter GGUF paths, `--spec-type`, and the Hugging Face repo/quant each file comes from) plus `findSpecDecodePreset` / `specDecodeSource` / `hfSearchUrl`. Also owns the `--spec-type` vocabulary: `SPEC_TYPE_SUGGESTIONS` (published to the launcher card), `parseSpecTypes` (the flag is a comma-separated list) and `isDraftSpecType` (the `draft-` prefix is what needs a drafter GGUF — every `ngram-*` type runs without one). Server-owned so the launcher card can offer a Download button per file. Pure. |
+| `specDecodePresets.js` | Curated llama-server launch presets (target + optional drafter GGUF paths, `--spec-type`, and the Hugging Face repo/quant each file comes from) plus `findSpecDecodePreset` / `specDecodeSource` / `hfSearchUrl`. A preset whose spec type drafts with nothing (`none`, any `ngram-*`) carries an empty `draftModel` and is just a launch line for one checkpoint — which is what makes this the home for a model only llama-server can load, e.g. `ternary-bonsai-2-27b`, whose ternary packs stock llama.cpp (and therefore Ollama and LM Studio) cannot run. Also owns the `--spec-type` vocabulary: `SPEC_TYPE_SUGGESTIONS` (published to the launcher card), `parseSpecTypes` (the flag is a comma-separated list) and `isDraftSpecType` (the `draft-` prefix is what needs a drafter GGUF — every `ngram-*` type runs without one). Server-owned so the launcher card can offer a Download button per file. Pure. |
| `llamaCppInstall.js` | Where a llama.cpp install comes from on this host, for `services/llamaServerManager.js`. `llamaCppInstallPlan(platform)` → the frozen descriptor for that platform's package manager — Homebrew on macOS/Linux (`brew install llama.cpp`), winget on Windows (`winget install ggml.llamacpp`) — carrying `manager`, `managerLabel`, `packageId`, `installCommand`, the install/upgrade (and, for winget, list/upgrade-check) argv, and the three refusal strings a caller would otherwise hardcode: `missingManagerError`, `notInstalledError`, `pathRepairHint`. The LLMs page renders `installCommand` out of the llama-server status payload, which is what stopped a Windows install prompt from telling the user to run Homebrew. Also the winget-side readers Homebrew needs no equivalent for: `parseWingetPackageFields(stdout, id)` (winget has NO machine-readable output mode and LOCALIZED table headers, so fields are read positionally from the tokens after the id token — `Version [Available] [Source]`; `null` = not installed), `wingetLinkDirs(env)` (the portable-shim directories winget adds to the USER PATH, which an already-running server has not inherited) and `isWingetManagedPath` (counterpart of the manager's `isHomebrewLlamaServer`: a source build earlier on PATH must not be offered a `winget upgrade`). Every WinGet path is reasoned about with `path.win32` regardless of host, so both branches are coverable from a macOS/Linux checkout. Pure. |
| `ollamaContext.js` | Ollama runtime context-window reasoning. `resolveOllamaContextLength(provider, env)` → the window PortOS should hold the daemon at (`provider.numCtx`, then `OLLAMA_CONTEXT_LENGTH`, then `null` = leave Ollama's VRAM-based auto-pick alone); `withOllamaContextEnv(env, n)` builds the `ollama serve` child env; `parseOllamaContextOverflow(text)` recognizes the `exceed_context_size_error` rejection and pulls `{ promptTokens, contextLength }` out of either the JSON body or the human message; `describeOllamaContextOverflow` / `describeOllamaContextTooSmall` render the actionable one-liners; `isSameOllamaDaemon(providerBase, managedBase)` compares host+port so a provider pointed at a *remote* Ollama never triggers a local-daemon reload, with `managedOllamaBaseUrl(env)` supplying the managed side (`OLLAMA_URL` → `OLLAMA_HOST` → the stock local daemon); `managedOllamaContextLength(provider, env)` is `resolveOllamaContextLength` gated on that comparison, and `withOllamaRuntimeContextWindow(provider, env)` stamps it onto an in-memory provider projection as `runtimeContextWindow` — how the env rung reaches the vendored toolkit’s `clampToRuntimeContextWindow`, which may not import out here (#7472); `OLLAMA_AGENT_MIN_CONTEXT` is the window below which an agent harness is warned. Pure — the daemon side lives in `services/ollamaManager.js` (`ensureContextWindow`), the pre-spawn enforcement in `services/ollamaAgentContext.js`. |
| `localModelHeuristics.js` | Capability heuristics for untyped local (Ollama/LM Studio) models. `isEmbeddingModel`/`isGenerationModel` (so a generation/fallback run never picks an embedding model like `nomic-embed-text`); `isVisionModel(model)` (string id or model card — prefers explicit `type:'vlm'`/`capabilities:['vision']` metadata, falls back to id regex; used by the LoRA captioner); `recommendEditorialModel(models, { measured })` ranks installed models for editorial review/editing, dropping any a fresh measurement proved cannot run here. Pure — `client/src/utils/localModelHeuristics.js` re-exports `isEmbeddingModel`/`isVisionModel`/`isToolUseModel` from here. |
diff --git a/server/lib/localLlmCatalog.js b/server/lib/localLlmCatalog.js
index 2f22de0433..b21dc25485 100644
--- a/server/lib/localLlmCatalog.js
+++ b/server/lib/localLlmCatalog.js
@@ -83,6 +83,19 @@ export const LOCAL_LLM_CATEGORIES = [
// to the Ollama library as `:cloud`-only tags whose manifests carry no weights —
// pulling one gets you an API passthrough, not a local model. Verify a tag has a
// non-zero manifest size before adding it here.
+//
+// Nor may an entry name weights whose KERNELS the backend lacks. Ollama and LM
+// Studio both embed a stock llama.cpp, so a build carrying a vendor's private
+// quantization type belongs in `specDecodePresets.js` (the llama-server launcher,
+// where the operator chooses the binary) and NOT here. Ternary Bonsai 2 27B is
+// the worked example: stock llama.cpp rejects its `PQ2_0`/`PTQ1_0` packs as
+// unknown types, and — the reason this is a hard rule rather than a preference —
+// it loads a plain ternary `Q2_0` with no warning and generates garbage, so the
+// install would look like it worked. The same applies on the MLX side: that
+// model's `mlx-2bit` pack declares a `prism_hadamard_qwen35` model type and ships
+// its own loader, and a stock MLX loader skips the activation transform and
+// returns wrong output rather than an error. See
+// docs/research/2026-09-18-ternary-bonsai-2-27b.md.
export const LOCAL_LLM_CATALOG = [
{
key: 'vulnllm-r-7b-gguf', name: 'VulnLLM-R 7B (GGUF)',
diff --git a/server/lib/specDecodePresets.js b/server/lib/specDecodePresets.js
index c2a12ddf70..0e9c4235ad 100644
--- a/server/lib/specDecodePresets.js
+++ b/server/lib/specDecodePresets.js
@@ -1,5 +1,6 @@
/**
- * Speculative-decoding launcher presets (llama-server target + drafter pairs).
+ * llama-server launcher presets — a target on its own, or a target paired with
+ * a speculative-decoding drafter.
*
* Server-owned because the paths are only half the story: each preset also
* carries the Hugging Face repo the GGUF comes from, so PortOS can report
@@ -14,6 +15,12 @@
* it appears only where the quant tag cannot discriminate the target, so a pin
* that stops resolving is an error, not a cue to fall back to the hint.
*
+ * Not every preset is a PAIR. A preset whose `specType` drafts with nothing
+ * (`none`, any `ngram-*`) carries an empty `draftModel` and is simply the
+ * launch line for one checkpoint — which is what makes this list, not the
+ * Ollama/LM Studio catalog, the right home for a model whose weights only
+ * llama-server can load (Ternary Bonsai 2 below).
+ *
* A file with no published single-file GGUF (the DSpark 8B block ships as a
* tokenizer-less checkpoint that has to be converted against its target) simply
* carries no `repo` — the UI then links out to a Hugging Face search instead of
@@ -110,6 +117,29 @@ export const SPEC_DECODE_PRESETS = Object.freeze([
quant: 'Q4_K_M',
},
},
+ {
+ // PrismML's ternary pack of Qwen3.8-27B, and the first preset here that
+ // speculates with nothing.
+ //
+ // PQ2_0 over the 1.3 GB smaller PTQ1_0: PQ2_0 is the pack PrismML measures
+ // on Apple Silicon and the faster prompt-processing pack on every backend,
+ // while PTQ1_0's decode edge is specific to Ada-generation and L4 cards.
+ // Either one needs a build of PrismML's llama.cpp fork on PATH, which is
+ // what the label warns about — and a launch that starts is NOT evidence the
+ // right binary is there, because a stock build accepts a plain ternary Q2_0
+ // and then emits garbage. Measurements, build recipe and why this model is
+ // absent from the Ollama/LM Studio catalog:
+ // docs/research/2026-09-18-ternary-bonsai-2-27b.md
+ id: 'ternary-bonsai-2-27b',
+ label: 'Ternary Bonsai 2 27B — no drafter (needs a PrismML llama.cpp build)',
+ specType: 'none',
+ model: {
+ path: 'models/Ternary-Bonsai-2-27B-PQ2_0.gguf',
+ repo: 'prism-ml/Ternary-Bonsai-2-27B-gguf',
+ quant: 'PQ2_0',
+ },
+ draftModel: { path: '' },
+ },
{
id: 'custom',
label: 'Custom GGUF / Manual Paths',
diff --git a/server/services/specDecodeModels.test.js b/server/services/specDecodeModels.test.js
index 02614a0c95..3a31622d6e 100644
--- a/server/services/specDecodeModels.test.js
+++ b/server/services/specDecodeModels.test.js
@@ -110,6 +110,25 @@ describe('pickGgufSibling', () => {
expect(pickGgufSibling(model, { file: entry.file, quant: entry.quant, repo: entry.repo }))
.toBe('Muse-Glimmer-30B-KQuant-17GB-Q4_K_M.gguf');
});
+
+ // The Ternary Bonsai preset carries NO `file` pin, which is only correct while
+ // its quant hint discriminates. Its repo publishes two ternary packs whose tags
+ // differ by one leading letter (`PQ2_0` / `PTQ1_0`) next to a 53.8 GB `F16` — so
+ // a hint that fell through to the shortest name would fetch 46 GB of the wrong
+ // weights, and one matching loosely would fetch the 1-bit pack instead.
+ it('resolves the Ternary Bonsai 2 preset to PQ2_0, not PTQ1_0 or the 53.8 GB F16', () => {
+ const entry = specDecodePresets.findSpecDecodePreset('ternary-bonsai-2-27b').model;
+ const model = siblings(
+ 'Ternary-Bonsai-2-27B-F16.gguf',
+ 'Ternary-Bonsai-2-27B-PQ2_0.gguf',
+ 'Ternary-Bonsai-2-27B-PTQ1_0.gguf',
+ 'Ternary-Bonsai-2-27B-mmproj-BF16.gguf',
+ 'Ternary-Bonsai-2-27B-mmproj-Q8_0.gguf',
+ );
+ expect(entry.file).toBeUndefined();
+ expect(pickGgufSibling(model, { quant: entry.quant, repo: entry.repo }))
+ .toBe('Ternary-Bonsai-2-27B-PQ2_0.gguf');
+ });
});
describe('getSpecDecodePresetStatus', () => {
@@ -129,6 +148,15 @@ describe('getSpecDecodePresetStatus', () => {
expect(q2k.draftModel.downloadable).toBe(true);
// `custom` carries no paths, so it has no weights rows to render.
expect(presets.find((p) => p.id === 'custom').model).toBeNull();
+ // A drafter-free preset is the MIXED state neither of the above produces:
+ // a populated, downloadable base beside a null drafter. That is what the
+ // launcher card reads to render one weights row instead of two and to leave
+ // its drafter field empty, so `custom`'s both-null row does not stand in
+ // for it.
+ const bonsai = presets.find((p) => p.id === 'ternary-bonsai-2-27b');
+ expect(bonsai.specType).toBe('none');
+ expect(bonsai.model.downloadable).toBe(true);
+ expect(bonsai.draftModel).toBeNull();
expect(fetchSpy).not.toHaveBeenCalled();
});
});