Commit Graph
10 Commits
Author SHA1 Message Date
Jeremy FowersandClaude Opus 5.5 465b172a61 fix(docs): only re-commit API examples whose response shape changed (#4114)
* Only re-commit API examples whose response shape changed

The recorded examples show the shape of each response, but backend update
PRs re-recorded them on every pin bump and committed whatever values came
back, plus CRLF files from the Windows recording runner. #4106 changed
19k lines with no real content change; #3964 changed 6.5k lines, one of
which was a real shape change.

- Key the example cache on the request only, not the backend pin
- Add --refresh RECIPE: re-run the examples a recipe serves and keep each
  recorded response unless its shape (status, content type, keys, value
  types, SSE event names) changed
- The llama.cpp, sd.cpp and vLLM update workflows pass --refresh
- Force LF for the generated API pages and the cache
- A llama.cpp update run dispatched from a branch opens its PR against
  that branch

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Drop the branch-dispatch PR targeting used to test the workflow

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Fix API example refresh validation and stream shape comparison

* Address remaining API example refresh review feedback

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
2026-11-15 20:18:32 +00:00
Jeremy FowersandClaude Opus 5.5 4e238fcb8b docs(api): re-record API examples for llama.cpp b12109 (#4064)
#4057 bumped the llama.cpp Vulkan pin from b11846 to b12109. The recorded
API examples are keyed on that pin, so every llama.cpp-backed example went
stale and gen_api_boilerplate.py --check failed in backend-docs-drift.

Co-authored-by: Claude Opus 5.5 <[email protected]>
2026-11-04 22:22:17 +00:00
Michele Balistreri 6c5a26aeb8 Remove image_defaults and audio_defaults (#4049)
* remove image defaults

* remove audio defaults

* add typed option accessors

* address review comments

* align documentation to changes

* add user_configurable concept for recipe options

* address review comment

* never show hidden fields

* retrigger-ci
2026-11-04 13:21:01 +00:00
Satya Devineni d397a6e8fa Add SystemOne decision models: /v1/systemone, GGUF zero-shot on /v1/classify, and the systemone router classifier (#3956)
* main into zero shot, post refactoring

* cleanup

* cleanup

* CR feedback: fixed the residency document clarification bug

* cr feedback: fake tests with propoer assertions

* stacks on the zero shot work in 3952

* pr feedback: better policy checks and logging for backend failures

* pr feedback: adding on_truncation

* pr feedback: adding the truncation support for classifier and fixing documentation issues

* CI fix and doc enhancement

* pr feedback: fixed edge cases

* added check for 0.3.7 truncated verification

* pr feedback: router validation and argument handling

* Added the example lfm2 ONNX model

* pr feedback: added max-length and 3 flag truncate flags

* pin bump to 0.4.0 and more tests for zero-shot

* CI fix

* pr feedback: model level filtering

* PR Feedback: CR feedback

* restricting decision models based on model family. 8k context limit by default for encoder decision models

* checks at router level to reject wrongly labeled systemone models with 400

* pr feedback: default set to 4k, limits passed down by llama-server, truncated  is added to systemone

* truncated documentation

* pr feedback: checks the token count instead of the template
2026-11-04 05:34:34 +00:00
Piotr Wilkin (ilintar)andjeremyfowers 4e368aad98 chore: bump pwilkin backend versions (#3993)
* chore(backends): bump TRELLIS to v0.8.1

TRELLIS moves from v0.4.3 to v0.8.1. All six release assets still use the
trellis-<backend>-<os>-x64.<zip|tar.gz> names the install cases expect, and the
binary contract is unchanged: trellis-server --models <dir> --host 127.0.0.1
--port <p> --res 512, with GET /health readiness. Since v0.4.3 the changes are
additive (CORS, Pixal3D, retopology, --threads/--device-style extras).

The per-asset sha256 values are the digests GitHub publishes for each v0.8.1
asset and replace the v0.4.3 block.

Note: v0.6.0 split CUDA into trellis-cuda-* (CUDA 13.1, Turing+) and the new
trellis-cuda12-* (CUDA 12.9, Pascal/Volta). The cuda pin now resolves to the
CUDA 13.1 archive; a cuda12 variant is not added here.

* chore(backends): bump ACE-Step to v0.1.2

ACE-Step moves from v0.1.1 to v0.1.2. v0.1.2 is the first release built on the
fork after syncing 38 upstream commits from ServeurpersoCom/acestep.cpp master
(ggml 0.26.0, static batched decode, heterogeneous request batching, --device,
fail-loud on a taken port).

Lemonade's launch contract is unchanged: --models/--host/--port/--keep-loaded,
the /lm, /synth, /understand, /vae, /health, /props, /logs, /job routes, and the
ace-batch-boundary multipart response. --device replaces the GGML_BACKEND env
var, which Lemonade never set.

All six assets keep the acestep-<backend>-<os>-x64.<zip|tar.gz> names. The
per-asset sha256 values are the digests GitHub publishes for the v0.1.2 assets.

* feat(trellis): add the CUDA 12 build for Pascal and Volta GPUs

v0.8.1 is the first TRELLIS release after upstream split its CUDA artifacts:
trellis-cuda-* is now CUDA 13.1 and needs Turing or newer, and Pascal/Volta
moved to a separate trellis-cuda12-* family. Pinning only cuda therefore left
those cards with no working build.

Declare cuda12 as a support row restricted to sm_60, sm_61, sm_62, sm_70 and
sm_72, placed before the existing cuda row: within a recipe the row order is
the backend preference order, so cuda12 wins where it matches. cuda keeps its
unconstrained nvidia_gpu row, so every card that resolved to cuda before still
does, including one whose compute capability cannot be determined.

The launch path compared backend == "cuda" exactly, which left a cuda12 launch
with an empty environment: no loader path for the bundled CUDA runtime and no
CUDA_VISIBLE_DEVICES. Match the family by prefix, as the rocm variant selector
in get_install_params already does.

Both cuda12 archives carry the sha256 GitHub publishes for v0.8.1.

* docs(config): regenerate the example config for the trellis cuda12 variant

The bin_variants addition emits a trellis.cuda12_bin default, so the generated config example in this file drifted. Caught by the backend-docs-drift CI job.

* docs(api): re-record the ACE-Step and TRELLIS examples for their new pins

gen_api_boilerplate.py keys recorded responses on the recipe's Vulkan pin, so the acestep v0.1.2 and trellis v0.8.1 bumps invalidated these two Binary examples. Re-recorded both examples against the new pinned Vulkan backends.

---------

Co-authored-by: jeremyfowers <[email protected]>
2026-11-03 02:14:36 +00:00
Satya Devineni f9004ca0a8 Adding zero-shot classifier support (#3952)
* main into zero shot, post refactoring

* cleanup

* cleanup

* CR feedback: fixed the residency document clarification bug

* cr feedback: fake tests with propoer assertions

* pr feedback: better policy checks and logging for backend failures

* pr feedback: adding on_truncation

* pr feedback: adding the truncation support for classifier and fixing documentation issues

* CI fix and doc enhancement

* pr feedback: fixed edge cases

* added check for 0.3.7 truncated verification

* Added the example lfm2 ONNX model

* pr feedback: added max-length and 3 flag truncate flags

* pin bump to 0.4.0 and more tests for zero-shot

* CI fix

* pr feedback: clarified on the PII detector
2026-10-29 17:21:53 +00:00
Michele Balistreriandfl0rianr fb8935641c Model Manager refactoring (#3828)
* draft model manager refactoring

* draft model management spec

* address review comments

* remove eol

* remove some non-relevant comments

* step 0: tests

* step 1: move recipe option store

* step 2: locator

* step 3: artifact transfer

* step 4a: store_builder

* step 4b: store_snapshot

* step 4c: catalog

* step 5: change notifier, generation on the snapshot

- ModelChangeNotifier with two signals and one subscriber each; ModelManager
  owns it and Server registers both routing subscribers on it
- StoreSnapshot::helper_models computed at publish by collect_helper_models();
  Server::active_policy_helper_models() and the startup seed block are gone
- notify_models_changed fires the snapshot generation; notify_generation_ and
  next_notify_generation() deleted
- fix: build_cache no longer mints a generation on a read that changes nothing,
  which had made generation-based coalescing impossible
- fix: set_model_update_available_for_test wrote the cache without publishing
- test_change_notifier: 16 checks, CI ON

* step 6a: RegistryId and the registry descriptor table

- RegistryId (string, no enum) plus RegistryDescriptor holding the per-host
  spellings, display name, scheme prefix, cache-dir prefix and default revision
- model_registry.cpp vocabulary and cache-dir naming read the table; the enum
  no longer carries facts of its own
- registry_id_from() yields nullopt for an unknown host, the primitive behind
  the spec's warn-and-skip delta (not wired to the load path yet)
- fix: descriptor_for() returned a pointer into a by-value vector
- registry_id.cpp compiled into the CLI as well; it does not link core
- test_registry_identity: 18 checks, CI ON

* step 6b: remove RemoteRegistrySource; registries are strings

- model_registry.h exposes models::RegistryId; the enum is deleted
- function names unchanged, only the carried type: parse/name/display/scheme/
  is_remote/detect_url/search/cache_dir_name/model_registry/ModelRegistry::source
- require_descriptor() throws when a caller invents an id
- test/app/app-regression/registrySearch.test.cjs slices model_registry.cpp by
  literal text; updated to match, and added to the standing gate list
- Locator now carries optional<RegistryId>

* test: pin the unknown-registry load-path delta

A persisted entry naming an unregistered host warns naming model and id,
contributes no entry, and leaves the rest of the catalog loading. That is
already the behavior via parse_model_source_fields throwing inside the
per-entry catch in build_cache; this pins it so a later step cannot regress it.

Test-only: ctest 81/81, app regression 136/136.

* step 6c': backends stop naming hosts

6b renamed the hf/modelscope dichotomy instead of removing it. Backends may
handle a source differently, but not by splitting the world in two hosts.

- vLLM quant probe: the identity test became an endpoint fact, the URL is built
  from the descriptor, and the hand-rolled "models--" + $HOME cache naming uses
  hf_cache::repo_id_to_cache_dir_name() + get_hf_cache_dir(). Passing the repo id
  rather than the raw checkpoint also fixes a latent miss for repo:variant ids.
- RegistryDescriptor gains endpoint_default; empty for ModelScope, which serves
  files through its API, preserving today's never-fetch behavior.
- FLM no longer guesses Hugging Face when the model manager is absent; both sites
  throw, as vLLM already did.
- dropped two unused default args that asserted a host.

Remaining sites for step 7 (vllm snapshot branch, flm --modelscope argv, whisper
resolve URL) need a port fact and are recorded in the plan.

Gates: ctest 81/81, cli2 73 OK, endpoints 171 OK, llm/vulkan 31 OK.

* step 6c: ArtifactSource, FetchableRepository, registration macro

- ArtifactRef names a checkpoint; from_locator carries the path for bytes that
  came from no host, so two files never share a ref
- ArtifactSource answers resolve/present/acquisition/deletion for one checkpoint
- FetchableRepository layers the pullable role on it; the whole interface is
  implementable from the value types alone
- LEMONADE_REGISTER_ARTIFACT_REPOSITORY is now the single writer of the
  descriptor table: seeded deque (pointer stability, not vector), replace on same
  id, first factory kept with duplicate claims reported rather than link-ordered
- RepositoryDescriptor and descriptor() deliberately absent; the spec lets step 12
  add them with a default

test/cpp/test_artifact_source.cpp, CI ON, 20 checks, mutation-checked twice.

Gates: ctest 82/82, app regression 136/136, cli2 73 OK, endpoints 171 OK,
llm/vulkan 31 OK.

* step 7a: artifact_resolver

* step 7b: fetchable_repository

* step 13: scancatalog

* step 7c: artifact_resolver

* move npu download

* step 7f: vllm/flm download

* reduce comment slop

* step 14: ListedCatalog per provider, and locality leaves the design

Cloud listing becomes one catalog per installed provider, so an
unreachable provider costs only its own entries.
CloudServer::discover_provider_models() owns the credential and
plaintext-endpoint guards for every caller of a listing, which deletes
the duplicated guard block in refresh_cloud_models() and orphans
CloudOps::discover_models().

CatalogDescriptor replaces the id()/required() overrides and carries
{id, required} only. Locality is deleted from the design rather than
introduced: every minter already distinguishes itself in the name it
emits (provider id leading a listing name, -FLM for discovery, the
parent-directory qualifier for the scan), nothing splits a name on '.',
and no persisted format ever carried a middle segment. Registering
user.<provider>.NAME is therefore settled by precedence, documented,
not by a vocabulary guard. The startup duplicate-claim check goes with
it: with no minter minting a locality it could only fire on a false
positive, and its remedy was to drop a provider's whole model set.

Gates: ctest 86/86, app regression 136/136, cli2 73 OK/2 skip,
endpoints 171 OK/3 skip (mock-provider cases ran), llm/vulkan 31 OK/2 skip.

* step 15: json_catalog

* step 15b:  registry documents

* cleanup

* step 8a: update scan

* step 8b: model sync

* fix ci tests

* step 9a: delete plan

* 9b: artifact store

* 9c: download policy

* 9d: npu_cache

* 9e: ingest

* 16: labels

* merge fix

* step 17-i: delete shards

* step 17-ii: fix and enable tests

* step 10a-b: alias manager + resolve()

* step 10c: every surface resolves through the manager.

* step 10d: fixes

* step 11: ModelManagerConfig

* step 12a: docs

* step 12b: model catalogs

* step 18a: start build cache work

* step 18b: catalogsetdeps

* step 19: catalog_locator

* step 19b: http catalog locator

* step 19c: configurable model catalogs

* step 20a: read capability hints only from the keys that carry them

* step 20b: a rebuild stops re-fetching a catalog it just read

* step 20c: a fetched catalog has a size limit and its cache an owner

* step 21a: a read stops taking the model store lock

* step 21b: the store lock covers the commit, not the composition

* step 21b-i: a commit stops walking the filesystem

* step 21c-i: publishing derives the name tables

* step 21c-ii: a write seeds a draft and the publish moves it out

* step 22: a filter test states the machine it means

* step 23: the update flag a scan publishes gets a gate

* step 26+27: the machine probe and the name tables leave the facade

* remove excessive comment

* step 28: modelstore

* step 29: CloudRows

* step 30: move build_cache

* step 31: store patches

* step 31 followup

* port PR #3882

* probes

* P0: the facade-shape gate reads both include spellings and one-way budgets

* P1: the dependency graph points one way

Every file under src/cpp/server/models/ included the facade header, so the
DAG read bottom-up: the layer existed in directories but not in reality. The
reason was structural. ModelInfo — the value object that crosses the whole
server by value — lived in the facade header, so anything that took a
ModelInfo had to name the orchestrator to spell its arguments.

ModelInfo, ModelFileInfo, and GgufMetadata move to models/model_info.h;
UnknownModelError and InvalidModelDefinitionError move to
models/model_errors.h. The facade now includes the leaves, never the other
way: the ratchet pins the models layer's facade-header count at zero, and
the include-graph grep confirms it. Consumers of the moved types got the
explicit include they were borrowing through the facade, including auto_tune.h,
which named no model header at all and worked by accident.

The same inversion hid inside ArtifactRef. A ref is an address — repo,
revision, variant — and two refs that compare equal name the same bytes; but
it also carried `const ArtifactLayout* layout` and a sibling path, so the
resolver had to mutate the address before handing it to a repository, and
placement — which is a property of where the bytes land — became part of what
an address is. Placement moves out: the resolver answers a SourcePlacement
beside the ref, create_repository takes it, FetchableRepository holds it,
and ArtifactRef is back to a value that can travel alone. The
sibling-layout tests now assert the binding where it lives, on the source.

Three headers are public, and the spec's Source Layout section says so:
model_manager.h (behavior), model_info.h (the value object), store_snapshot.h
(the read-only set a consumer holds). A fourth consumer, server.cpp, reads only
the snapshot, so it left the escape whitelist; auto_tune.h joins the sanctioned
side by naming model_info.h. The line budget travels 1103 -> 1105 for the two
includes model_manager.cpp took on to stop borrowing them transitively.

Gate: cpp-ci 114/114; endpoints 178 OK / 3 skip; llm/vulkan 31 OK / 2 skip;
whisper 12 OK / 2 skip; cli2 73 OK / 2 skip; app 136. Mutation-checked: the
facade-header ratchet at zero, a private models header reaching a consumer in
both include spellings, a sanctioned include passing unflagged, and a retired
whitelist name demanding deletion.

* P2a: the token stops bytes, and credentials stay on their origin

Cancellation had no parameter. A download noticed a cancel only when a
progress report happened to return false, so a stalled transfer with no bytes
and no reports could not be cancelled at all, and every caller that wanted to
stop one had to smuggle the request through the reporting channel.
utils::RequestCancelToken already existed for inference; it lived in
utils/http_client.h, out of reach of a transfer seam that must not know about
HTTP. The token moves to its own leaf, utils/cancel_token.h, as
utils::CancelToken — the same currency for inference and for model transfers —
and download_file, download_attempt, ArtifactTransfer::execute and
FileTransfer::transfer all take it. ByteProgress returns void: it reports
bytes, nothing else. A DownloadProgressCallback that returns false now closes
the update channel instead of secretly cancelling, and the only message that
stops a plan is the token, checked before each file and on every curl tick.

The second owed defect was credential scope. Rule 2 of Transfer And Layout
says a repository's auth_headers() travel only while the origin still matches
the origin that minted them, at every hop. libcurl re-sends custom headers to
any host a Location names, so the download no longer lets libcurl follow: it
walks the hops one request at a time, drops the header list at a cross-origin
boundary and never restores it, enforces the policy's scheme set on every
target itself, and refuses a 3xx body into the partial file. Production
behavior is unchanged — ExternalHttpsOnly is still the default policy — and
HttpFileTransfer gained the policy seam the fixture has been asking for in a
comment since it was written.

The token is wired where cancels are born: the download job hands the worker a
flag its cancel endpoints set, so a cancel stops bytes on the next socket tick
rather than at the next progress report; the legacy streaming path answers from
socket death; the pull chain carries it from the facade through ingest and the
BackendOpsContext down to the transfer.

Gate: cpp-ci 115/115 including the new FileTransferTest (the spec's
test_file_transfer, 21 checks over two loopback origins: credential kept
direct and on a same-origin redirect, stripped cross-origin, never restored
after a strip, disallowed redirect scheme refused before bytes, one mixed
scheme plan one progress total, a file://-only plan, mid-transfer cancel with
the partial preserved); endpoints 178 OK / 3 skip; llm/vulkan 31 OK / 2 skip;
whisper 12 OK / 2 skip; cli2 73 OK / 2 skip; app 136; a real 174 MB Hugging
Face pull in 3.2 s through the manual-hop engine. Mutations by exit code:
token check removed, cancel dies mid-transfer; strip disabled, the cross-origin
check fails; strip unconditional, the same-origin check fails; progress-false
made cancel again, the mute test dies. M1 is what surfaced the redundancy the
mutation was meant to prove: two channels watched the token in the tick; the
wrapper's copy is gone and the HTTP client's is the one place. Restores
verified, grep MUT zero.

* P2b: the main pull plans through the repository seam

Every checkpoint of a pull is an ArtifactRef bound to one FetchableRepository;
the file set is registry_download_plan's, auth headers come from the source, and
no ModelRegistry survives in the download path. The reuse merge, manifest,
pinning and provenance stay where the spec puts them.

test_pull_registry drives the whole ModelManager against scripted sources:
exact URL plan, snapshot placement, pins, manifest lifecycle, refusal words,
and a pre-set cancel token that leaves no artifact.

Facade ceiling 1106 -> 1107 for the repository_for wiring line.

* P2c: the update scan asks sources, not registries

Each (source, repository) group opens a FetchableRepository, honors
can_go_stale() before opening its mouth, lists latest and previous through
list(), and takes its headers from the source. registry_for and its legacy
ModelRegistry& are gone from UpdateScanDeps and the facade config; the
artifact-aware refinement stays in registry_files, composed as before.

test_update_available ports to StubRepository and gains three checks for the
frozen-source rule: never listed, reports nothing, moves no flag.

Facade unchanged at 1107 lines.

* P2d: the registry class lives with its adapters, nowhere else

model_registry.h moved out of the public include path into src/cpp/server/,
and only model_registry.cpp and models/registry_repository.cpp may name it --
the facade-shape gate now enforces that named set. Wire facts (file trees,
search rows, provider names, cache-dir naming) moved to
lemon/models/registry_types.h, a public leaf: they persist on disk, so their
shape is public by design. RepoListing carries the host's raw_metadata.

Search became a source answer: FetchableRepository::search with the
supports_search() gate, exposed through ModelManager::search_registry so the
API layer keeps talking to the facade. hf_variants reads variants through
create_repository.

Standing acceptance rule: store, sync, ingest, scan and the facade pair carry
zero provider string literals; only the adapter pair names the legacy header.
Both mutation-proven this phase.

Facade 1107 -> 1124 lines for search_registry.

* P3: provenance learns which checkpoint landed where

v1 files read forever, verbatim. A v2 write keeps the v1 sentence in the main
repository's file and adds checkpoints[type] = {selection, snapshot_id}; an
auxiliary repository -- which v1 refused to let speak at all -- now records
only its own checkpoint under version 2, so a shared side cache can name every
model that filled it without any of them claiming the whole.

The pull commit loop names the slot per repository. RegistryProvenanceTest
pins v1 read, v2 shapes, the shared aux file and moved-snapshot bookkeeping;
PullRegistryTest pins them after a real pull.

Mutation-proven: the v1 answer, the aux guard and the slot routing each have
a check that dies without them.

* F4 trim: a locator reads, it does not probe

CatalogLocator::changed() had no production caller -- invalidation is event
driven (watcher, settings write, ingest) and fetched bodies are windowed
(fresh_for plus conditional GET), so a standalone HEAD round trip was dead
weight with a live cost. It, both implementations, and HttpClient::head are
gone; the spec's staleness rows now describe what the read observes rather
than a probe nobody runs.

CatalogState stays: it is what read() hands back so the next read asks
conditionally. CatalogLocatorTest keeps the read-side truth, minus the probe.

* P4a: the store owns its build and its patches

ensure_current holds the compose retry loop -- the facade's build_cache is one
line now. StorePatches is gone: patch_download, patch_removed and patch_options
are ModelStore methods, the artifacts store arriving per call so the store
keeps no dependency of its own. The bodies moved verbatim; the tests moved
with them and lost nothing.

Facade 1124 -> 1097: the one-way ceiling pays a refund this phase.
Mutation-proven by test_compose_retry (attempts 1 -> both retry checks die).

* the repository seam is explained once, where it is filled in

Three structs restated which source answers for a checkpoint. ModelManagerConfig
is the origin -- ingest and update scan take it by assignment -- so it keeps the
explanation and the plumbed copies just point at it.

* callback bags shrink where the collaborator was restyled, not tested around

UpdateScanDeps stops restyling the artifact cache as three lambdas - the
disk baseline and the processed-snapshot fast path now read the
ModelArtifactStore itself, and the registry-source rule collapses to the
one free function that already owned it. ModelIngest drops its pin and
patch_downloaded wrappers and calls the registries and store it already
holds.

Read paths stop copying the world to answer one question: the facade
publishes snapshot(), and model_get, model suggestions on a miss, the
register echo, and the two MCP 'find a local model' walks read rows
instead of cloning maps. The echo regains an assertion in
test_000a, which the mutation check proved it needed.

* the facade declares no test hooks and holds no override members

The four hooks existed because substitutions had nowhere else to live.
They have somewhere else now:

- test_extra_model_discovery drives ScanCatalog directly; the device
  rule for the operator's directory moved onto the catalog itself.
- test_model_sync_and_auto_update drives SyncService with its own deps
  - canned scan, download recorder, phase bus - so the queue state
  machine is tested at the queue, not through eight ModelManagers with
  their real behavior patched out. The stale-flag case now proves the
  stronger thing: a set flag never downloads a model on its own when
  the fresh check fails.
- the phase callback and both override members are deleted with their
  setters; FacadeShapeTest's four-name whitelist becomes two zero
  assertions - no _for_test anywhere under src/cpp, no *_override_
  member in the facade header - and a probe hook planted in an
  unrelated product file trips the gate by name.

Facade: 1088 -> 1076 lines; header sheds 33.

* options are a read and a write, named as the spec names them

The facade spoke about options in six verbs; the spec knows two. GET,
POST dry-run, DELETE, the load-time save and the load-time tombstone
layer now share one read - options(name[, changes]) returns the entry,
the layering beneath it, and what changes would resolve to - and two
writes: set_options merges, replace_options replaces. preview_saved was
the clearest smell: what-a-write-would-produce is a read, so it lives
in the read.

FacadeShape grows honest ceilings: facade lines 1082, header method
declarations 71, members 15 - all one-way, so shrinking owes no edit
and growing names itself. The counters earn their numbers: planted
declarations and members are counted and refused.

* the facade locks twice and waits never

Both direct locks are the options file's write ordering, documented
where they sit; publishing has exactly one road, StoreWrite. Ratcheted
so a third lock has to argue for itself.

* check_updates and sync_status, the names the spec uses

Two renames onto the facade surface the spec already spells; nothing
else moved. Live proof: update-models --check and the update/sync
endpoints pass against a fresh server.

* checkpoint_status[] on the wire, and the spec says what the code does

Every checkpoint of every listed model now answers for itself - type,
present, required, registry, path - from the same ArtifactSources a pull
would open. Building that read exposed a real seam gap: source_for
never threaded ModelManagerConfig.repository_for, so a fixture host was
obeyed by pull and scan but bypassed by status; it now reaches every
consumer, and test_pull_registry pins the whole answer, honest scripted
presence included.

The wire contract earns its pins: /v1/models rows carry a present,
required, path-bearing main entry for a downloaded model and a boolean
update_available; docs/api shows both fields with their entries; the
app refuses to export checkpoint_status into a portable file, because
its paths belong to one machine.

Spec reconciliation, the CODE->SPEC list closed: the facade section
describes the shipped surface - snapshot reads, the options read/write
pair, config-as-the-only-door with the zero-hook gate named - and says
outright there is no ModelView and no generated model-object pass, with
the drift guards that actually exist in its place. Source Layout lists
the four public models headers and the private registry header;
staleness item 5 reads as event-plus-window, CatalogLocator::changed()
dead; test_update_available names repository_for; ModelSyncServiceTest
is no longer an aspiration - the suite is renamed to it.

Facade ceiling 1109 with checkpoint_status; declaration ceiling 72.

* S1: the spec describes shipped code, not the design it preceded

docs/dev/specs/model-management.md had drifted from what the tree does in ten
places. Each was checked against the implementation before being rewritten:

- Catalogs are objects built per store build by `product_catalogs()`, not
  singletons; the six shipped ones are named with their rank, claim, and the
  three input shapes (pinned document, `CatalogLocator`, callable).
- Locators: `file_catalog_locator` and `http_catalog_locator` are the two that
  ship, with their read policy, cache pair (`<id>.json`, `<id>.json.validators`,
  body written first), and the 8 MB body cap. No resource locator: the built-in
  registry arrives already read via `RegistryDocuments`.
- Store: `resolve()` returns `ResolvedModel`; there is no `model_path()`, no
  `ModelView`. `StoreWrite` is the composition's write type; it is still public
  on the facade, which is recorded as a known gap rather than a rule.
- `checkpoint_status[]` reads presence from `ArtifactSource::present()`, so it
  can disagree with `downloaded` on an interrupted pull. Documented as shipped.
- SyncService is `src/cpp/server/models/sync_service.{h,cpp}` with the real
  enqueue/wait/cancel surface; `models_changed` carries a `reason` and a
  generation that changes on catalog mutations only.
- Docs section: the real descriptor structs (`RegistryDescriptor`, `DocEntry`,
  `CatalogDescriptor`), the real region markers and region names, and the
  host_specific rule that keeps a machine-dependent row out of a committed page.

Removed the probe-and-detector table row, which described a mechanism deleted
before this spec section was last touched.

No code changed; generators and cpp-ci are unaffected (119/119 re-verified).

* S2b: SyncService started its worker before stop_ existed, and no test had a bound

ModelSyncServiceTest hung often enough to be killed by hand. Tracing the
worker's transitions showed the cause in product code: sync_service.h declared
`std::thread worker_;` before `bool stop_ = false;`. Members initialize in
declaration order and constructing the thread starts it, so run_worker()'s
first act -- waiting on `stop_ || is_sync_running` -- read stop_ before its
initializer ran, with no synchronization. Memory that happens to read non-zero
makes the worker believe it was already asked to stop, so it returns at once:
the service is dead on arrival, is_sync_running stays true, and
wait_until_idle()/wait_for() block forever. That fits every observation --
intermittent, load-sensitive, and blocked at 0% CPU with every thread in
futex_wait.

Fix: move the stop flag into State, where it initializes with the rest of the
guarded state and lives under the mutex the worker waits on, and leave worker_
declared last so the invariant is visible at the declaration. Router and
JobManager use the same wait idiom in the correct order; SyncService was the
only instance. As a backstop, both waits now also wake when the worker has
exited and log a warning instead of waiting for a transition that can no longer
happen, so a future dead worker costs a wrong status rather than a hung request
thread.

test_model_sync_service.cpp also had a real use-after-free of its own: every
parking scenario declared the SyncService before the state the worker parked on,
so ~SyncService joined after those locals were freed, while bus.sink still
captured them by reference and was never cleared. One PhaseGate now owns the
park, is declared before the service, takes itself off the bus in its
destructor, and bounds both directions of the rendezvous, so a missed phase is a
named FAIL instead of a hang.

New regression test constructs 200 services in a row and requires each to run
its first generation within a deadline; forcing the worker to stop on entry
makes it fail on attempt 0 in all three runs.

Every test now carries a ctest TIMEOUT (default 120s, 300s for the two whose
runtime is defined by waiting on a timeout constant) so a stuck test is one red
line instead of an unattended run: 143 at 120s, 2 at 300s, measured against a
suite whose slowest test is 14s and 115 of 119 finish under 0.3s.

cpp-ci 119/119; 960 sync-test runs at 16-way concurrency with no stall and no
failure, against 5 stalls in the first 32 runs before the fix.

* S2: the shape gate now counts what it claims, and measures what was unmeasured

Four rules in test_facade_shape were reporting something other than the truth.

Members (G1): the count was lines ending `_;`, so `cloud_registry_ = nullptr;` and the
two-line `catalog_fetch_clock_ = std::make_shared<...>()` were invisible and a new member
written with an initializer would never trip the ceiling. Members are now counted by
declaration: comments stripped, statements split on `;`, class-body indentation, angle
depth tracked so `std::function<std::string()> x_;` is a member while `void f();` is not.
Honest count is 18 -- the review that opened this step said 17 and was itself one short,
missing `default_model_source_provider_`, whose type contains the `()` that hid it from the
grep the count was based on.

Substrings (G3): `find_in(file, "model_registry.h")` counted a sentence naming the header,
and an include someone commented out counted too. Includes are now parsed from lines whose
first non-blank character is `#`, over comment-stripped text.

Direct-only includes (G2): the escaping whitelist saw `#include <lemon/models/...>` but not
the relative spelling, and it missed the more serious fact that a whitelisted *header* hands
models types to everything that includes it. A new named set lists the headers allowed to
re-export the models layer -- five of them -- and a failure prints what each one drags in.
Whitelisting `backend_ops.h` for `ArtifactFetchService` really does reach every backend that
includes it, and that is now visible instead of implied.

Shrink-punishing ratchets (G4): every "at most" needle failed when the count went *down*
with "ceiling is stale", which is exactly the churn the refactor wants. They now fail only
over the ceiling and print a note asking for it to be tightened.

Three rules that did not exist, all needed by later steps: the facade header's reach
(29 product files, one-way -- three include spellings, and the bare `#include
"model_manager.h"` used by the backend tree accounts for 7 of them), `StoreWrite` confined
to the facade, and in-flight markers (`.download_manifest.json`, `.partial`) confined to the
eight files that can currently decide presence. That last one is the shape of D2/R1: presence
has two authorities today, and the list is what S5 has to shrink.

Eleven mutations, all as required. Two caught defects in the new code rather than confirming
the old: may_only_shrink reported "unexpected" and then still passed when every whitelisted
name happened to be present, and the member counter returned 1 until the statement splitter
was fixed. kRulesVersion prints with the results so a binary older than the tree is visible
in the output rather than inferred from an impossible failure.

cpp-ci 119/119.

* S2b: nothing any more stops a cpp test from dialing out or forking

The hermeticity audit came back clean -- no C++ test needs external HTTP or a
running lemond, so none was deleted -- and an audit is worth exactly as much as
the rule that keeps it true. Two checks, both seeded at the honest zero.

A non-loopback host *name* is not the thing to ban: test_model_registry.cpp,
test_cloud_provider_registry_config.cpp and test_config_default_source.cpp pass
huggingface.co, api.fireworks.ai and friends to pure functions to check URL
building and endpoint classification, and a blanket ban would tax the tests that
verify URL handling. The rule is a non-loopback host and a request on the same
line, over comment-stripped text.

Only the named test spawns a process, with test_process_manager.cpp on the list
because process management is its subject. A test that spawned lemond would also
make one test's server another test's interference: ctest runs these in parallel.

Three mutations: a real HttpClient against huggingface.co fails, the same line
commented out passes (so the rule reads code, not prose), and a popen added to
another test fails. The gate caught itself on the first run -- it holds the token
tables as data and matched its own patterns -- so it is excluded from the two
scans over test/cpp, which costs nothing since it neither dials out nor forks.

Why the count is zero is written in the gate's comment: every create_repository()
call in test/cpp stops at resolve()/acquisition(), a plan and a path with no
request, and test_update_available.cpp injects config.repository_for. A reader
can then tell a rule that holds from a rule nobody ever checked.

cpp-ci 119/119.

* S3: declaration order is initialization order, and the declaration ceiling was fiction

ModelManager declared registries_, recipe_options_, architecture_defaults_ above config_
while its init list wrote config_ first. Actual construction follows the declarations, so
alias_manager_(config_.cache_dir) ran after config_ only by luck of where the members
happened to sit: registries_ and recipe_options_ build from static helpers and read no
member. Give that file a member that reads config_ in its initializer, placed above
config_, and it reads an object that does not exist yet -- which is not a hypothetical, it
is how SyncService hung. Declarations now run config_, extra_models_dir_, alias_manager_,
registries_, recipe_options_, and the init list already matched.

Found by asking for -Wreorder explicitly, which the build never does: no -Wall anywhere,
so this defect class is invisible otherwise. The same warning fired on WrappedServer, whose
init list wrote last_backend_activity_ before instance_id_ while declaring them the other
way round; both initializers are independent, so it was cosmetic, and it is aligned too.

recipes_all_models_filtered_snapshot() had exactly one caller, a test, and differed from the
public recipes_with_all_models_filtered() by a build_cache(). Deleted: the concurrent reader
now uses manager.snapshot()->empty_recipes(), a public non-rebuilding const read that already
existed, so the side-table exposure goes away without weakening what the test stresses.

Also, the header declaration ceiling measured nothing. It counted `);` occurrences across the
whole file -- missing every method ending `) const;`, counting doc comments -- and reported 71
against a ceiling of 72 while ModelManager's own brace depth holds 87 function declarations.
It now counts declarations at class scope, nested type bodies excluded, and the ceiling says
87; adding one method fails, which the old counter could not do. S8's real starting surface is
87 declarations across 29 includers. The re-export detail dump printed on every run including
passes, where it read like a failure; it prints on failure now.

cpp-ci 119/119, cli2 73 tests OK, gate green, comment gate 0.

* S4: a recipe is policy, so it stops riding in an address

ArtifactRef carried `recipe` while operator== ignored it. That is a field which changes what
a plan contains and asserts nothing about identity: two refs equal as addresses produced
different downloads. It is what lets the shared plan builder reach for a recipe at all, since
the only way registry_download_plan could ask which files a model wants was through the ref
handed to it.

Moved to SourcePlacement, beside the layout and sibling it already travelled with, and read
back through repository.recipe() where the plan is built. Placement is resolver output, was
already threaded through create_repository, RepositoryFactory, both registration macros and
the FetchableRepository constructor, so this is a field move and a getter rather than a new
channel. The four mint sites stopped setting it; placement_for() and the host-scheme branch
set it; ingest builds one placement per pull, because every checkpoint of a pull belongs to
the same model and so to the same recipe; update_scan does the same for its probe.

checkpoint_type stays, and the header now says why the two are treated differently: which
checkpoint is a question about bytes, which recipe is a question about what to do with them.
The probes in hf_variants and search_registry needed no change -- they list and search and
never build a plan, so an empty recipe was already the right answer for them.

The new layout test asks the question the field used to make unanswerable: the same ref under
two placements yields plans that differ only in the files the policy selected and agree on the
destination. Moonshine was the natural second policy and throws when a listing has no folder
by that name; ThinkSound wants a fixed set of audio files and finds none in the fixture, which
says the same thing without an exception.

cpp-ci 119/119, whisper 12 OK (2 skipped), generators --check, comment gate 0. Whisper needs
XDG_RUNTIME_DIR pointing somewhere writable in the server's environment before it will load
anything; recorded because the error it produces otherwise reads like a model-load failure.

* S5: presence gets one implementation, and it takes a path rather than a source

downloaded and checkpoint_status[].present were computed twice, differently. The store
applied existence, in-flight markers and backend validation; LocalPathArtifactSource applied
existence plus validation; a registry checkpoint applied existence alone. An interrupted
download reported downloaded:false beside present:true, and a repository holding an HTML error
page named .gguf reported present:true.

The three checks now live in one function, checkpoint_bytes_present(path, validator), and the
marker half in models/download_markers.{h,cpp} -- interrupted_download() names
.download_manifest.json and .partial nowhere else. Both sources and the store's complete()
call it, so no caller can hold a different opinion about the same bytes. The registry source
validates with the ops of the recipe in its SourcePlacement, which is why S4 came first.

The plan said to make complete() a loop over sources. That was tried and it is wrong:
adopt_extra_cache() asks complete() whether a row would be whole, and the row it asks has no
provenance yet -- the resolver reads a bare org/repo checkpoint as a registry checkpoint, the
registry source looks only in the managed cache, and a model whose bytes sit complete in the
extra models directory is refused adoption and then loses its resolved path too, because
compose only resolves rows it believes are downloaded. The store decides which path a
checkpoint resolves to -- adopted caches, shard families resolved to the one file the engine
opens -- so the authority is a function over that path. Asking a source derives the location a
second time from provenance, which is the second opinion this step exists to remove.

Finding, from failing to see the bug first: checkpoint_status reports present:false with no
reason when a source cannot even be built, and the wire carries no reason field. Every
registry case in test_model_download_state was therefore false/false -- agreeing, vacuously.
A bare ModelManager wires no default model source, so no registry source can be built for an
org/repo checkpoint; production always does (RuntimeConfig::default_model_source). Five test
binaries now share one helper that takes the name from parse_remote_registry_source("")
instead of repeating the literal.

The characterization test was wrong too, and the mutation caught it. It asserted the two
answers agreed; deleting the marker check from the helper then broke just one of three marker
cases, because with no markers both authorities wrongly answer present and still agree. Each
case now pins the absolute answer. Re-run: M-A trips all three, M-B (registry stops
validating) trips the .gguf-of-HTML case alone, M-C (optional checkpoints ignored) trips the
whisper side cache alone.

One divergence is left and now documented rather than hidden: a row that adopted an
extra-directory cache reads downloaded:true beside present:false, because the registry source
answers for the managed cache only. Both fixes cost something -- reading the extra roots from
the source risks writing refs/main into a directory lemonade does not own, and recording the
adoption on the row changes the source the API reports and which rows the update scan visits.
That is a step of its own, not a smuggled-in extra.

cpp-ci 119/119, cli2 73 OK, endpoints 178 OK, whisper 12 OK, app regression 136, generators
--check, comment gate 0.

* S6: invalidation invalidates; it does not rebuild or publish

The write path published twice for every model change. `Write` publishes in its destructor,
and `invalidate_cache()` published a draft that is only a copy of what is already published --
so an invalidation announced a snapshot that says nothing changed, and the rebuild that follows
announces the change. Deleting the publish from the invalidation is the whole step, and it
needs the flag write to take the writer lock, since a reader can now hold the shared lock for
the whole read instead of a copy.

`invalidate_models_cache()`, `catalog_set_changed()`, the `DirectoryWatcher` callback and
`deps.persist_size` -- "content changed" and "the cache might be stale", the two ways a model
write used to end -- point at `ModelStore::invalidate()`. `persist_size` takes the size off the
published snapshot rather than opening a write to get a draft. `StoreWrite` scopes in the
facade 7 -> 3: two options patches and the download self-heal S7 renames. Live, one touch in
the extra models directory produces exactly one `Cache built`, and a burst of two produces one.

`test_generation_survives_a_rebuild` asserted the opposite -- "invalidating publishes, so a
lock-free reader sees it" -- which was the intended behavior written as a test of the old one.
It is replaced by `test_invalidation_publishes_nothing` in the store, and the notifier gains
`test_invalidation_marks_stale_without_publishing` and `test_an_invalidation_announces_nothing`.

Two things the plan had wrong: `Write::invalidate_cache()` has four callers left, not two; and
`StoreSnapshot::valid` is copied from `cache_valid_` at publish, so an invalidated store still
hands out a snapshot reading `valid: true`. Safe while `patch_download` is its only reader --
that path is guarded by `Write::cache_valid()` -- and worth reconciling if S7 touches either.

Verification: ctest -L cpp-ci 119/119; the comment gate is clean; both doc generators
report no drift; endpoints 178 tests OK (3 skipped) and whisper 12 OK (2 skipped). cli2 stops
at `test_092`, which fails the same way with this commit stashed and passes when run alone:
its shared repository is also `USER_MODEL_TE_CHECKPOINT`'s, and earlier cli2 tests register and
download the model that claims it. A fixture collision, not a delete regression.

* tests: the dummy model's text encoder gets a repository of its own

`test_092_delete_preserves_cross_repo_dependency` asserts the shared repository
directory is gone once the last model that uses it is deleted. `user.Dummy-Model`,
registered and pulled by earlier tests in the same persistent suite, resolved its
text encoder inside that same repository, so the delete correctly kept the bytes and
the assertion failed. The fixture already warns about this in two comments -- "only
holds while nothing else claims it" -- and the rule is stated for the main checkpoint
but was never applied to the text encoder.

Moved to a ~11 MB quant of `mradermacher/Tiny-LLM-GGUF`, a repository no other fixture
touches. Both consumers of the constant compare the checkpoint string, so nothing else
changes.

Why it hid: the repository held an unclaimed orphan file, and deleting a model whose
bytes nobody else claims removes the directory over it. Once the cache was cleared and
the suite re-downloaded Dummy-Model through the server, the ownership claim was written
and the collision became visible.

Verification: cli2 73 OK (2 skipped) -- previously 40 run, failfast at test_092 -- and
endpoints 178 OK (3 skipped), which exercises the constant in both directions.

* S7: the store answers reads, so collaborators stop reaching back into the facade

ModelStore took the read side the spec assigns it -- current(), resolve, exists, info,
resolve_name, public_name_for, rejection_reason, supported_models(), downloaded_models(),
resolved_paths_for, is_downloaded -- plus the one AliasManager resolution needs and the
composer its owner installs, because composing reads catalogs, registries, the machine
probe and saved options and none of that belongs to the store. A store with no composer
answers from what it published and never builds, which is what a test that patches rows
directly wants; the eleven sites that default-constructed one now name an in-memory
AliasManager.

ModelIngest::Deps lost seven read lambdas and three signal ones: models_changed and
model_updated became one ModelChangeNotifier*, persist_size moved into ingest (it needed
only the registries and the store it already held), and SyncService::Deps lost three and
gained a ModelStore*. Fields across the deps and hooks bags: 41 -> 27. make_ingest_deps()
is 34 lines, then 13. The facade's read verbs are one-line delegations; the file went
1096 lines -> 904 and its header 87 declarations -> 85, with both ceilings tightened.
wait_for_sync() was dead with no caller anywhere and is gone, and
remove_model_from_cache() -- a wrapper for one store call -- is inlined into the delete.

Three things the plan prescribed are not what shipped, and the spec now says why.
exists_unfiltered is not a store verb: it asks the registries about rows the host filter
removed, so the published set cannot answer it, and ModelIngest computes it from the
RegistryDocuments it holds -- a store method would be a second registry reader for one
caller. resolved_paths_for moved to ModelStore rather than ModelArtifactStore, because it
reads one published row's recorded paths, which is a snapshot question; the plan called it
the opposite. info() throws for a name nothing answers, since that is the contract the
facade's get_model_info has always had and every caller depended on; the nullable question
is read()->find(), and rule 6's wording distinguishes them.

A pinned contract caught a regression mid-step. Delegating resolved_paths_for through
current() turned a pure read into a compose-path call, which queues behind an in-flight
patch, and "a read answers while a writer holds the store" failed. Which verbs ensure and
which never wait is now written in the header, in the spec, and in that test.

Moving the self-heal changed behavior. The facade corrected a missing-bytes row with a
hand-rolled write that flipped that one row; the store verb routes through patch_download,
which also settles the collections routing through the model. A collection whose
component's bytes vanished no longer reports itself downloaded. Nothing pinned the old
narrow behavior, so this is a change to notice rather than one to assume.

Mutation checks. Dropping the alias fallback from ModelStore::resolve fails
NameResolutionTest, which covers the six steps end to end. test_model_alias does not catch
it and cannot: it exercises AliasManager alone, which is the point of the spec's rule that
aliases are consulted at resolution time and never folded into the snapshot. Dropping the
exists guard in ingest's pull fails PullRegistryTest, not the endpoints test_000a the plan
predicted.

Verification: ctest -L cpp-ci 119/119 after touching every source and rebuilding; app
regression 136 passed; both doc generators report no drift; the comment gate in CI form is
clean. Integration ran green against this code with comment-only edits still to come --
cli2 73 OK (2 skipped), whisper 12 OK (2 skipped), endpoints 178 OK (3 skipped) -- and the
repeat of that battery could not finish: this machine lost network egress partway (server
log full of "Could not resolve hostname", curl to huggingface.co returning 000), and the
one cli2 failure, test_044's config set, followed test_043 rebinding the listen host.
Re-run cli2, whisper and endpoints before relying on this commit end to end.

* S8: no header includes the facade header

A header that includes model_manager.h hands the whole models layer to
everyone behind it. Three of them did — backend_manager.h, wrapped_server.h
and backends/backend_ops.h, each included by 53-58 files — so editing the
facade recompiled 75 of the tree's product files. It now reaches 22, all of
them translation units that call it.

model_manager_types.h declares ModelManager and ModelInfo for the headers
that name the orchestrator without calling it; the alternative, writing the
pair out in each header, duplicates the struct/class kind MSVC warns about
and buys ~1 TU per header where the fan-out is small. Headers that read
models facts name the leaf for each fact instead: download_progress.h,
model_info.h, registry_types.h, artifact_fetch.h.

FacadeShapeTest now ratchets transitive reach rather than the direct-include
count, which a cosmetic edit could satisfy, and fails if any header includes
the facade at all. allowed_reexporters is compared as a set — it was failing
on ordering, not membership. download_progress.h joins the public read side.

Verified: cpp-ci 119/119, cli2 73 OK, endpoints 178 OK, whisper 12 OK, app
regression 136 passed, both doc generators --check clean.

* S9a: three facade helpers stop being public

forget_registered_model, save_model_options and start_directory_watcher were public, and every
product call to them comes from inside model_manager.cpp. The two tests that drove
save_model_options drive the public replace_options verb, which performs the same file-plus-cache
write, so no seam is lost by closing them.

download_from_huggingface_engine has no caller in the tree and stays: its comment says it is a
source-compatibility alias for integrations built against the original API, and an in-repo scan
cannot see those callers.

StoreWrite stays public for one reason - test_model_manager_shim holds a writer while a reader
runs, and with no read-only accessor for the facade's ModelStore that is the only way to express
the test. The comment names the blocker: give ModelManager a const store() seam and re-home the
writer hold, and the token becomes private.

FacadeShapeTest's direct-includer ceiling drops to its honest value of 22, so an added includer
fails instead of being absorbed by slack. cpp-ci 119/119.

* An invalidation landing mid-compose is no longer silently discarded

S6 moved invalidation off the write path: invalidate() takes the writer lock, clears
cache_valid_, and publishes nothing. That removed the only signal a compose in flight had.
Build::commit() refused a candidate by comparing generation_, which an invalidation no longer
moves, so a compose racing a persist would land a set built from catalogs enumerated before
that persist and set cache_valid_ = true on top of it. The stale set was then current: the
model that just finished downloading stayed missing until something else invalidated.

An invalidation now bumps invalidations_, a counter no client watches, and Build records it
beside the generation. Bumping generation itself was rejected: it is the signal that a set was
published, and an invalidation publishes nothing.

ComposeRetryTest caught this by accident. It had been simulating the racing writer with a raw
StoreWrite, whose destructor publishes, so it exercised the pre-S6 mechanism and passed; pointed
at the verb product code actually calls, it failed. test_store now pins the same case one level
down, where the store owns the race.

Also in this commit, the rest of S9b:
- ModelManager gains const store(), the read seam. A write scope needs a non-const ModelStore,
  so no caller of it can hold the facade's writer, which is what let StoreWrite go private.
- The reader-not-blocked-by-a-writer check moves from test_model_manager_shim to test_store,
  where the store is the thing under test; the shim test no longer needs write access.
- FacadeShapeTest gains "only the models layer and the facade open a store write scope": ingest,
  cloud_rows and update_scan write, gateways and backends cannot.

cpp-ci 119/119, cli2 73 OK, endpoints 178 OK.

* S9c: four facade verbs with no product caller go away

generation(), all_models(), has_alias() and checkpoints_complete() were one-line pass-throughs
that nothing in the product called. The store already answers the first two through the read
seam added last commit, so the tests now say manager.store().generation() and
store().read()->models -- which is also what the read migration will leave the gateways saying.

checkpoints_complete() asked ModelArtifactStore::complete() about a row, and the thirteen tests
that used it were handing it rows that are not in any store. complete() needs nothing from the
manager but the row, so test_model_download_state now holds its own artifact store: the checks
are about a row and the bytes on disk, and that is the pair they name.

has_alias() turned out to have no callers at all - the three hits the caller census counted are
AliasManager's own method, called on an AliasManager. A receiver type is part of a caller count.

FacadeShapeTest's budgets re-struck to their honest values: 86 -> 82 header declarations,
904 -> 889 lines. cpp-ci 119/119.

* S9c: resolved_paths_for leaves the facade

Nothing in the product called it. The two callers the caller census counted are inside ingest,
where they already go to the store directly - the same receiver-type mistake as has_alias last
commit. The store's own version is const, so the shim test reads it off the store seam.

Budgets: 879 lines, 81 header declarations.

* spec: the facade's read verbs stay, and why

Plan item 2b said to delete the one-line read delegations once the store answered reads. That
cannot be done: a facade read composes, composing publishes, and publishing takes the writer. A
ModelStore& handed to server.cpp to save a delegation is a store write scope waiting to happen in
a file that has no business holding one.

Rule 6b records the shape that is actually safe: the read verbs stay on the facade, and
ModelManager::store() is const, offering only what answers from the published snapshot without
waiting on a writer - read(), generation(), descriptors(), resolved_paths_for().

* spec: the facade sketch becomes the shipped surface

The sketch ended its alias group in "..." and stood for thirty-five verbs that ship. It now lists
them, grouped by what they are asked for, and the name-set diff between header and sketch is
empty in both directions.

Two corrections it forced. wait_for_sync() never shipped - the verb is wait_until_sync_idle().
resolve_model_name() was missing from the reads group. download_from_huggingface_engine() is
written down with the reason it survives an empty caller list: source compatibility for
integrations built against the original API, whose callers this repo cannot see.

* S10: the resolver mints refs and opens every repository

Pull and update scan each re-implemented selection: assembling ArtifactRefs from checkpoint
strings, filtering the lazy checkpoints, parsing repo_id and variant. Three copies of rules that
decide what a pull downloads, each able to drift from the others.

ArtifactSourceResolver gains refs_for(info) and repository_for(ref, placement).
download_from_registry takes both; the update scan, hf_variants' pull listing and
search_registry take repository_for. ingest and update_scan lose their repository_for Deps
lambda: the injected host now reaches them through the resolver's hook, which is where
ModelManager wires ModelManagerConfig::repository_for, so a stubbed pull stubs one thing.

The facade builds one resolver at construction. It used to build hooks and a resolver inside
every source_for() call, which is once per checkpoint.

FacadeShapeTest now refuses `create_repository(` anywhere but the resolver, the factory that
declares it, and the facade's one wiring line. That is "one site binds a checkpoint to a source"
taken literally.

Two divergences are deliberate and now written into spec rule 7: the pull keeps its own list() +
registry_download_plan() rather than acquisition() (one listing serves three decisions), and the
update check keeps group_aux_checkpoint_variants because a malformed auxiliary checkpoint is
skipped silently by a check and refused loudly by a pull.

test_update_scan had been reaching the real factory through an unset seam and relying on it to
throw; it now installs a stub that answers "can go stale" and fails on the tree, which is the
shape it was always pretending to test.

cpp-ci 119/119, cli2 73 OK, whisper 12 OK, endpoints 178 OK; /pull/variants returns 12 variants
for a live repo through the new seam.

* S11 (part): fold checkpoint_grammar and definition_labels into the headers that own them

checkpoint_grammar was two functions parsing a ref's own parts; they now sit with ArtifactRef,
which is what the grammar describes. definition_labels was row policy -- the label set a
registration derives -- and json_catalog is where a row is parsed, so it moved there and took its
backend-descriptor include with it. Two .cpp link units gone, two headers fewer.

The other six candidates in the S11 table do not survive the step's own rule, and each reason is
now written next to the row it refutes:

- catalog_fetch_clock: four owners (catalog_set deps, configured_catalog, model_manager member,
  the locator), not "its only user". Folding into any one makes three peers depend on a sibling
  for a type all four share.
- registry_documents: holds a mutex and publishes immutable snapshots. The step excludes anything
  with a mutex, and this row contradicts that.
- routing_parse_options: three parse sites build their tiers differently; that is the point of it.
  No host owns the concept.
- recipe_option_layers -> recipe_options_store.h: the store is one rung of the ladder the folder
  builds. Making the rung own the ladder inverts it, and the store has three mutexes.
- fetchable_repository.cpp -> registry_id.cpp: the registration table maps ids to repository
  factories. Inside registry_id.cpp the id type would depend on every repository, which is the
  dependency the factory exists to invert.

* S12: one StoreWrite binary for the store's write side; 3 CMake blocks become 1

test_store, test_store_build and test_store_patches all asked the same question of the same
object -- what a writer does to the published snapshot, and what a reader sees while it
happens -- so they are one process now, with each file's helpers kept in its own namespace
rather than renamed until they stopped colliding. 73 check() call sites in, 73 PASS lines out.

StorePatchesTest was listed here as "targets a class deleted in P4a". It does not: it exercises
patch_download and patch_removed, both live, so it merged on its actual surface instead of being
deleted. Deleting it would have dropped five checks over store writes that nothing else covers.

StoreSnapshot stays separate. It is the read side, and merging a read-side binary into a
write-side one would leave a binary named for half of what it tests.

Also removes a third copy of the saved-options rationale; composition.h owns that sentence.

* S13a: repository bookkeeping leaves artifact_store.cpp into its own unit

A repository cache's snapshot pointer and its processed-model ledger were six methods at the end
of a 1176-line file, beside download cleanup that has nothing to do with either. They move to
repository_provenance.{h,cpp} and the class forwards, so callers are untouched. The store is now
1055 lines; the extracted rules are 171, and RegistryProvenanceTest already covered them without
needing a new fixture.

* S13b: collections leave ingest.cpp into their own unit

Fetching a manifest, registering the components it names, deciding whether a collection may be
registered at all, and refilling a slim entry from a cached manifest: four methods plus three
helpers that only they used, 469 lines out of a 1471-line file. They share one input — the
manifest — which is why they belong together and not spread across the ingest.

ModelIngest keeps its public validate_collection() and populate_from_cached_manifest() and
forwards, so no caller changed; register_components and resolve_from_manifest were already private
and are now the collection unit's. The back-pointer to the ingest is there because a collection
pulls its components through the same path a plain model does rather than owning a second copy of
the download code. The destructor moves out-of-line for the unique_ptr.

ingest.cpp is 1058 lines. cli2 73 OK, endpoints 178 OK, whisper 12 OK, both doc generators
current, ctest 117/117.

* S14 items 1 and 2: delegated delete gets its fixture; a mistyped config value stops emptying the model set

Two carried defects, both about absence.

Delegated delete had no fixture. The path is real -- flm's descriptor declares self_manages_downloads,
so its source answers Deletion::Kind::Delegate, ownership_of records the recipe, and remove_self_managed_model
does the removal -- but nothing pinned it, so nothing said which side of that chain a change had broken.
The new case registers an flm row, deletes it, and requires the request to reach the backend: with no flm
executable the delegate refuses, and the refusal is the evidence. A CacheDir branch completes silently and
looks like success, which is why mutating `kind == Delegate` to false now fails two checks instead of none.
It needs disable_model_filtering for the same reason test_model_delete_shared_repo.cpp does -- flm is a
system package the test host will not have, and filtering would drop the row before the delete reached it.

backend_string/bool/int/double read config_[section][key].get<T>() after checking only that the key exists.
config.json is hand-edited, so a value of the wrong type throws type_error.302 out of recipe detection,
where it is caught and logged -- leaving `recipes` absent, which the router reads as "no recipe is
available" and filters every model on the machine. One bad key cost the whole set. All four now read
through one lookup that treats absence and mismatch alike, so a mistyped value costs at most the setting
it holds. Pinned by feeding build_recipes_info a document whose llamacpp.backend is a number: before, the
test binary aborted with the exception; after, the table survives with the recipe in it.

Top-level keys were already validated at construction, so they are untouched -- this was specific to the
per-backend readers, which had no validation behind them.

ctest 117/117.

* S15 (part): budgets struck to what they measure, and printed where a shrink will show

Three of the five facade budgets sat exactly at their ceiling with nothing saying so, which is the
same drift the ceilings exist to catch -- one line added somewhere else would have failed for a
reason unrelated to the line. All five now read the measured value: 876 lines, 82 declarations,
19 members, 22 direct and 22 transitive includers. The closure equaling the direct count is not a
coincidence to tidy; it holds because no header propagates the facade, and that has its own check.

Adds one summary line to FacadeShapeTest's output listing each budget against its ceiling. A
ceiling only says "not worse"; without the measured number a shrink is invisible unless someone
goes looking, and the reason to notice a shrink is to tighten the ceiling before something backfills it.

Also records S14 item 3 as investigated-and-left rather than open. validate_checkpoint_file() was
offered as the hook that already answers "may this file complete this checkpoint", and it does not:
it returns "" for a non-.gguf path, skipping magic-number validation rather than rejecting the file,
so routing the three literals through it refuses models that load today. Each site is written up
where the next reader will look instead of reopening the question.

* S15: the store's forwarding declarations point at the provenance rules instead of restating them

Splitting a unit copies its doc comments along with its signatures, and six of them ended up
describing the same behavior twice -- once where it is decided, once where it is forwarded. A pair
like that goes stale on the first change to either side. The header keeps one line saying what the
group is and where the rules live; the parameter note stays only where the default is not visible.

* S15: one sentence describes the provenance group, at its own header

The forwarding block restated in different words what repository_provenance.h already says about
the same five functions. A pointer is enough from a file that decides nothing.

* S15: registry_source_of moves to the header that owns registry names

It normalized ModelInfo::registry_source from artifact_store.h, where it sat beside the cache layout
it has nothing to do with. It is now declared next to parse_remote_registry_source() and
remote_registry_source_name(), the two calls it composes, and defined in the same file as them. The row type
does not take on registry parsing to get this: the function takes a row, which keeps the dependency one-way.

Ten call sites dropped their models:: qualifier, since lemon::models sees lemon:: by lookup -- the
qualified spellings were only ever correct because the declaration happened to be in the models layer.

Resolves the question S7 left open about this function's home. ctest 117/117, facade budgets unchanged.

* review: a store snapshot lives as long as the loop that reads it

* review: an NPU cache already on disk is not fetched again by an auto-load

* review: a planned name cannot place bytes outside its own directory

* review: load_optional_json looks for the UTF-8 path it was given

* review: the POSIX safe_* answer instead of throwing

* review: the snapshot golden compares one separator, not the native one

* review: the re-exporter diff compares the lists it prints

* review: the reader threads run before the writer stops them

* review: a re-pull proves it wrote no bytes; the empty if goes

* docs: a Hugging Face snapshot directory is the commit SHA

* gate: the directory-settings needles move with discovery into ScanCatalog

* build: test_auto_tune links json, and the gate asks reachability not naming

* models: a row borrowed from a published set outlives it; find() aliases the set

* api: checkpoint_status[].path is opt-in with ?include_paths=true

* aliases: a save holds the lock from snapshot through rename

* paths: one grammar for a component, and no writing through a symlink

* models: a delegate's checkpoint answers with the row's own fact

* comments: cut the essays this branch wrote

* comments: drop a same-pattern pointer in the collection ingest

* docs: the include_paths link names the heading that exists

* pull: a snapshot id the layout refuses throws instead of planning nothing

* transfer: a file name passes the grammar, not only containment

* docs: the spec names the consumers that exist after the merge

The merge moved every caller into route classes, so the spec's file names and its claim that the model-object field list is hand-kept both went stale in the same change. Records the merge in the plan: what moved where, the three silent losses the port recovered, the ceilings re-struck to measurement, and which suites did not run here.

* store: a collection's state settles under the writer lock

Two components of one collection finishing at once each computed the dependent
collection states from the set they had read, so each saw the other still
absent and both published the collection as not here with everything
installed. The recompute is a scan over rows and touches no filesystem, so
moving it inside the Write scope costs nothing it could not pay under a lock,
and the draft it reads is the one this writer just patched. A component the
draft no longer holds counts as absent rather than as just landed, so a delete
landing between the read and the commit cannot complete a collection on a row
that is gone.

The test starts both writers at once and repeats the round, because the window
they must both be inside is filesystem work wide: it fails on the ordering this
replaces and passes on this one.

* allow deleting models with all checkpoints shared

* relax symlink rules when they are within the repo

* address review comments

* address review feedback

* reduce test footprint

* fix shared-repository deletion with HF symlinks

* restore resume validation

* fix resume via proxy

* fix regressions

* address more review comments

---------

Co-authored-by: fl0rianr <[email protected]>
2026-10-27 19:57:39 +00:00
56cc349e74 Update llama.cpp to b11846 (#3964)
* Update llama.cpp to b11846, rocm-stable to b11836, rocm-nightly to b1353

* chore: strip unnecessary CRLF only

* chore(docs): update docs via gen_api_boilerplate.py

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Sreeram <[email protected]>
Co-authored-by: Florian Reinle <[email protected]>
2026-10-27 10:35:37 +00:00
Jeremy FowersandClaude Opus 5.5 49e637903f fix(docs): key recorded API examples on the recipe's Vulkan pin only (#3946)
pinned_backend() keyed each example on its recipe's whole backend_versions
entry, so bumping any of a recipe's pins (cuda, metal, a container digest)
invalidated examples recorded on Vulkan. Key on the Vulkan pin when the
recipe has one, and re-key the existing cache entries to match.


Claude-Session: https://claude.ai/code/session_01LcAshvLHhLPAw6Ka6CJXwC

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
2026-10-22 23:48:40 +00:00
9a9d43abc6 Fully refactor the HTTP server: route classes, core components, generated API docs (#3771)
* docs: add the server architecture spec

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* docs(spec): unpack multipart forms before ModelRoute resolves the model

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* docs(spec): require model on ModelRoute unless the route defaults to the loaded model

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* docs(spec): drop the startup shadow check in favor of per-folder registration order

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* docs(spec): keep WebSocketServer out of ServerContext since config changes replace it

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* docs(spec): declare each route's responses and request format

- RouteSpec::responses lists every format a route returns, with an inline JSON Schema and a recorded example for each; streaming is part of the format
- RequestFormat replaces the json_body and form_body flags
- Model name resolution is left to ModelManager

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* docs(spec): rename the server architecture spec to HTTP Server

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* docs(spec): fix four gaps found while implementing the HTTP server spec

- Require model on every ModelRoute; drop model_defaults_to_loaded, since the
  Router has rejected a missing model since multi-model support landed.
- Keep images/upscale on ApiRoute, since it runs its upscaler as a one-shot CLI.
- Add RouteSpec::experimental and a Partial support level so the existing docs
  badges survive generation.
- Shorten long strings and arrays in recorded examples, and redact the
  harness cache directory and home directory.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec the generated docs in main's API reference layout

Routes render as Parameters, Example request and Response format, with
Field Descriptions built from ordered_json response schemas. Summary tables
gain Modality and Status columns and keep hand-written rows.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Trim the spec's docs changes to what the layout requires

Keeps the ordered_json types, the modality and summary rules, and the new
route layout. Drops the field description rules, the tab label table and
the key order rule, and restores the original Complete Example, shown in
the new layout.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Revert spec edits the docs layout does not require

Restores the approved text everywhere except where it described the old
Response subsections and Schema tabs.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: let a route record several examples per response format (#3843)

RouteResponse keeps only the format and schema. A new RouteExample carries
each example's name, format, args and setup, and a setup ExampleStep either
runs another route's named example or sends an unpublished request.

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>

* Implement the HTTP server spec: route classes, core components, generated API docs

server.cpp becomes a composition root. Every endpoint is one route class under
routes/<page>/<section>/, registered by its folder's routes.cpp; HttpListener,
RequestMiddleware, RouteRegistry, ConfigEffects and WebUi own the shared
machinery, and ModelLoader, ModelJson, DownloadManager, JobOps and the gateway
and Omni services hold what several routes share. ModelRoute runs the common
resolve, validate, load and run pipeline.

docs/api is generated from the routes' RouteSpecs by gen_api_boilerplate.py,
with real request and response examples recorded in
docs/tools/api_examples_cache.json. Docs And Style runs --check, and the weekly
backend-bump workflows re-record the examples a new pin invalidates.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Ship the routing decision schema in the MSI and embeddable archive

Route registration reads resources/schemas/decision.schema.json, so every
package that lists its resources by hand must include it; the embeddable
smoke checks now require it. The registry search app test now finds the route
in its route file.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Drop model_defaults_to_loaded: every ModelRoute requires a model

The Router already rejects a request with no model, so the flag only kept
the four text routes' older error text. They now answer the same 400 as
every other model route.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Port main's image edit and backend label changes into the route classes

- images/edits accepts several image[] references, rejects mixing image and
  image[], and infers an omitted size from the first reference, capped by the
  model's image_defaults.soft_pixel_cap.
- ModelJson reports image_defaults.soft_pixel_cap.
- The system-info schema adds each backend's tier and format and each recipe's
  experimental flag; the Backend Tiers and Formats section moves over as a
  hand-written section, and the experimental model label row is dropped.
- Re-record the system-info example, which predates tier and format.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Keep main's API docs wording and layout in the generated pages

The generated docs now follow main's API reference layout: Parameters,
Example request, then Response format with a Field Descriptions list built
from the response schemas, which are ordered_json so fields keep their
written order. Route text, examples and hand-written sections use main's
wording, with small edits only where main's text no longer matches the code.

Summary tables keep main's columns and rows: a Modality column from the new
RouteSpec::modality, a Status column on pages with unsupported routes, and
hand-written rows the generator keeps for the WebSocket endpoints and the
llama.cpp slot actions.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Port main's per-GPU metrics into the route classes

- system-stats reports primary_gpu_id and a gpus list, and gpu_percent and
  vram_gb come from the primary GPU. The route and the job engine's
  system_stats op now build the reading in one place, services/system_stats.
- The Prometheus metrics route reads the primary GPU the same way.
- The system-stats schema documents the new fields, and main's GPU notes move
  over as a hand-written section.
- Re-record the system-stats example, and the examples whose llama.cpp ROCm and
  sd-cpp pins main bumped.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Trim comments to the ones that explain a why

Drop comments that restate the code, name their callers, or say what the
code does not do, and shorten the rest to their one non-obvious reason.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Re-record the stale /internal/config example and guard against recurrences

The internal.config example was recorded before #3775, when lemond still
merged /usr/share/lemonade/defaults.json from an older installed package,
so it carried openmoss.rocm_bin from before #3615. The cache key cannot see
lemond's own defaults, so the entry was never re-recorded and --check
passed.

- Re-record internal.config; it now matches internal.config_defaults.
- Compare the recorded internal.config and internal.config_defaults with
  the fresh lemond the generator already starts: --check fails on a
  mismatch, and a normal run re-records the entry.
- Strip LEMONADE_DEFAULTS_PATH and LEMONADE_ALLOWED_ORIGINS from the
  harness lemond's environment so the recording machine's settings
  cannot seed its config.
- Drop the OpenMOSS ROCm usage line from server_tts_openmoss.py.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01UGEQsXh31AhYdQ8C8Cjup4

* Revert the generator and test changes from the stale-example fix

Keeps only the re-recorded internal.config example.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01UGEQsXh31AhYdQ8C8Cjup4

* Make docs/api/internal.md the one reference for the internal endpoints

- getting-started.md drops its Internal Endpoints section. Its remote-access
  note and non-loopback warning move into internal.md's intro, and its
  simulate-vram-pressure behavior into that route's notes.
- runtime.md keeps a table of the settings and shutdown endpoints an
  embedding app uses, each linking to internal.md.
- internal.md states which apps may use these endpoints, and the hand-written
  lines that repeated the generated sections are gone; the alias delete 404
  moves into the route's notes.
- Guide mentions of internal endpoints link to internal.md.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Move hand-written API docs into the route specs

The hand-written text between generated regions either repeated the
generated sections or described a single route. Repeats are deleted, and
route facts (error statuses, behavior notes, examples that cannot be
recorded, and concept sections such as Backend Tiers and Server-side Tools)
move into each route's notes, keeping their anchors. What remains
hand-written is page intros, the WebSocket APIs, Model Labels, the routing
overview, MCP's shared tool behavior, and examples a single recorded
request cannot show.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Let a route record several examples per response format

RouteResponse keeps only a format and its schema. Each route lists its
examples in RouteSpec::examples, each with a name, the format its reply is
validated against, its args and its setup. A setup step runs another
route's named example, or sends an unpublished request. Cache keys hash a
named step the way they hashed the response it replaced, so every existing
recording stays valid, and example names reproduce the tab labels the
generator used to derive from formats.

The slots save and restore examples and the ACE-Step vocals example are now
recorded instead of hand-written. The docs harness runs lemond in its
temporary cache dir, so llama.cpp's relative --slot-save-path writes there.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Tighten every route's docs and keep main's page order

Route descriptions, notes, argument and field descriptions no longer repeat
the generated URL, alias and auth line, the page intro, the parameter
table or each other, and statements that disagreed now match the code.
lemonade.md and openai.md list their routes in main's order, and each
page's summary table follows its section order. A field list renders
once when a route's examples share a format, /v1/load's example is a plain
load, and the slots examples load with --slot-save-path and save a chat
capped by max_tokens, so save and restore report the same token count.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Fix what a final read of the rendered API pages turned up

- False claims: /health's --websocket-port flag (it is the websocket_port
  setting), /health's max_models missing classification, images/generations'
  n limited to 1, chat's max_tokens being exclusive with
  max_completion_tokens, route ids being docs anchors, and install
  registering only OpenAI-compatible providers.
- Repeats: Ollama's unload notes, MCP's shared tool behavior, the 501 in
  unsupported routes' summaries, the image options in Ollama generate's
  options row.
- Rendering: placeholders like <PROVIDER> and <recipe> are now in backticks,
  so Markdown no longer hides them.
- Wording: the routing decision description, sync status fields, summary
  styles, heading case, and em dashes in Model Labels and MCP tool text.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Fix the last issues from the final read of the API pages

Chat's logprobs is honored (a llama.cpp chat returns choices[].logprobs), so
its row is available again. Ollama pull's status values are in backticks so
<file> renders, MCP tool descriptions name their default model only in the
model row, and the cloud provider headings use title case.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Regenerate the API and MCP docs after syncing with main

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Keep decision.schema.json unchanged; describe x_lemonade_route at the field

decision.schema.json is under the frozen-major schema lock, so the
completion routes take their field description from
route_decision_field_schema() instead of editing the schema.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec a contract for route docs and lint it in the drift check

Each RouteSpec text field gets one job, URLs use only the /v1/ form, and
the drift check fails on the patterns that made the generated pages
repeat themselves. The generator documents a Quad route only at /v1/.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Apply the route docs contract to every route and lint it

gen_api_boilerplate.py --check now lints route text against the spec's
Route Documentation Contract: phrases the generator prints, prefixes other
than /v1/, em dashes, placeholders outside backticks, long summaries and
descriptions, and sentences repeated within a route's region. The
generator documents a Quad route only at /v1/, listing aliases in that
form, and every route's text was revised to the contract, correcting the
claims that disagreed with the code.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Fix the last contract issues a full read of the pages found

/health's update_check_done and the models page's cloud note now match
the code (registry-agnostic update check; anthropic-wire providers serve
only /v1/messages). Field descriptions no longer state types, values and
lemond are in backticks, headings use title case, and /internal/set's
rows say "Defaults to".

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Contract: who-uses only when not obvious; arguments may state conditional requirements

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Fix every route the per-route contract audit flagged

An evidence-backed checklist audit of all 85 routes found 71 rule failures
and 33 false claims; each fix was verified against the handler code and
re-audited until every route passed. Notable corrections: attach_if_running
was described backwards; Ollama chat's think and the Ollama/Anthropic
gateways' alias handling are documented as they actually behave; image
defaults come from each model before the server-wide fallback; system-info
no longer documents fields nothing sets. The generator now prefers a
described field when response shapes share a name.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Pin the sampling of the chat that the slots save example runs

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: close docs-generation gaps found reviewing the generated pages (#3848)

* Spec: close the docs-generation gaps found reviewing the generated pages

- Field Descriptions print a schema's own description, list each shape of a
  multi-shape format separately, and list shared schemas in full.
- The contract gains a row for schema-level descriptions.
- Each example runs against a freshly started lemond.
- Arrays of objects and data-keyed maps show their first 3 entries, and
  lemond's version is recorded as <version>.
- Examples built from lemond's own docs or route specs are recorded live.
- docs/api/README.md states how clients send the API keys.
- Drift Check fails on a shape with no example, an undescribed recorded
  field, a recorded JSON body over 100 lines, or a live example that loads
  a model.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0155DTqmffuXR2U3rhsFnb28

* Spec: drop live examples; recorded values may drift, only the shape must hold

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0155DTqmffuXR2U3rhsFnb28

* Spec: name RouteResponse::schema instead of an undefined 'schema'

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0155DTqmffuXR2U3rhsFnb28

* Spec: add a claim review step for route docs

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0155DTqmffuXR2U3rhsFnb28

---------

Co-authored-by: Claude <[email protected]>

* Generate docs per the updated spec: shapes, top-level descriptions, shortened lists, new checks

- Field Descriptions print the top-level description of a RouteResponse::schema,
  list each oneOf shape under its own description, and list $id schemas in full.
- Arrays of objects and maps keyed by data show their first 3 entries in the page.
- Drift Check fails on a format or shape with no example, a recorded field with
  no description, and a recorded JSON body over 100 lines in the page.
- docs/api/README.md says how clients send the API keys.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0155DTqmffuXR2U3rhsFnb28

* Drop all src/app changes from this PR

Removes the Playwright test-results output committed by accident and
restores tauriShim.ts to the base branch.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RrqRFa7Zrr517fcQb3ePKX

* Regenerate API docs with shapes, top-level descriptions and shortened lists; treat a described top-level schema without properties as opaque

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0155DTqmffuXR2U3rhsFnb28

* Describe every recorded field of the OpenAI text and image responses

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0155DTqmffuXR2U3rhsFnb28

* Describe model, load, download and classify responses; add pull, load and download-control examples for every shape

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0155DTqmffuXR2U3rhsFnb28

* Describe every recorded field of the remaining routes; add install and uninstall examples for every shape

Config routes model config.json as a map of settings. Examples that a
renamed setup step names now point at their new names.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0155DTqmffuXR2U3rhsFnb28

* Spec: drop validate_args, which no route needs

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RrqRFa7Zrr517fcQb3ePKX

* Show the first entry of arrays of objects and data-keyed maps, so system-info fits the page limit

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0155DTqmffuXR2U3rhsFnb28

* Spec: show the first entry of arrays of objects and data-keyed maps

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0155DTqmffuXR2U3rhsFnb28

* Remove validate_args: no route set it

The validation path in ApiRoute::serve() never ran, so drop the field
from the spec and RouteSpec, its /internal/routes output and schema,
and the McpTool::validate() wrapper that only it called.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RrqRFa7Zrr517fcQb3ePKX

* Record the missing examples; list each response shape in the tab whose response returns it

Recorded lemonade.pull non-streaming, lemonade.load collection,
lemonade.downloads_control remove, lemonade.install local and job, and
lemonade.uninstall local. A route whose examples span several formats
listed every shape of a format in each of its tabs, so two examples of
one oneOf format repeated the whole list.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Fix every claim the per-route claim review found false or missing

Each route's text was read beside its handler and the code it calls, and
changed claims were checked against a running lemond. Notable fixes:
routed responses always carry x_lemonade_route (route_trace only adds its
trace); pull's update-check note; Anthropic warnings and 404/409; Ollama
404/409/500, options marked partial, generate's two done lines; load's
merge_args, option layers and saved-option keys; error statuses on the
text, image, options, jobs and internal routes.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: a shape no recording machine can return names the reason in x-no-example

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Exempt install's manual-setup shape from the example requirement

No recording machine runs a Strix Halo kernel without the CWSR fix, so the
shape names that reason in x-no-example. Drift Check skips such a shape,
and the format's first tab still lists its fields.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Regenerate internal.md after validate_args removal

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Test that model-optional classify keeps a routing helper's residency

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: ModelRoute skips the load when validate() picked a loaded model

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: describe the routing decision inline instead of reading decision.schema.json

lemond never read decision.schema.json before; it is the routing engine's
frozen contract. Routes now describe the decision with a short inline
object that links to the router page, which links to the schema file.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Keep a routing helper's residency when classify fills in the model

ClassifyRoute::validate() picks the sole loaded classifier, and ModelRoute
then loaded it again with the default UserInference purpose, demoting a
routing helper to a standard model. validate() now marks the model as
already loaded and ModelRoute skips the load step.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Parse number form fields as double, as main did

std::stof rejected values outside float range that main's std::stod
accepted, such as a transcription temperature of 1e39. No test added.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Log models and system-info request lines again

quiet_log dropped these routes from the access log entirely. Main logged
their request line and left out only the response line, so they move back
to the is_quiet_get list.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Log global_timeout and download_rate_limit only when they change

Server::Server applied them through ConfigEffects, which logged them on
every startup. It now calls the HttpClient setters directly, as main did,
and the change log uses main's wording.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Restore which default model each MCP tool downloads

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Stop reading decision.schema.json at runtime

The file is the routing engine's frozen contract, and lemond never read
it before. x_lemonade_route and routing/validate's decision now use a
short inline schema that links to the router page, which links to the
schema file. This reverts the packaging added only for this file and
restores main's source lists for the two decision tests.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Regenerate MCP reference docs

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: leave the web app's window.api mock out of WebUi's responsibilities

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Keep injecting the web app's window.api mock from WebUi

Restores main's behavior: lemond inserts the mock into the web app's
index.html, and the web-app build is unchanged from main.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Keep main's MCP tool descriptions

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: drop the routing-context and CPU-state lines the implementation no longer follows

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Drop the WebSocket server mutex main never had

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Fill routing/validate's context directly, as main does

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Keep background syncs and CPU-usage state in Server, as main does

ModelManager and the platform metrics classes match main again.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Restore main's alias null checks, warmup guard and shutdown setter

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: give examples a description, and keep requests out of notes

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Record the chat and pull examples that notes hand-wrote

Examples get a description, printed at the top of their response tab, and a
fixture can follow a prefix such as a data URL. Chat's image and Omni
requests and pull's register and collection requests are now recorded
examples; their notes keep only the concepts.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: give each example its own subsection

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Give each API example its own subsection

Each example's request tabs, response and description now sit together
under its own heading, and each response format's Field Descriptions are
listed once after the examples.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: let an example's description cover a request shape only it uses

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Move chat's image input note into its example

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: put the recorded status on the Response label

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Show each recorded status on its Response label

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: link the API pages instead of naming their paths

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: declare each route's errors so handlers and docs share one source (#3869)

* Spec: declare each route's errors as RouteError values

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: reword the status-code compatibility note

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: declare route errors without changing the wire

Replace the fail()/ErrorFormat draft with RouteError values that the existing
writers take in place of a status. Move status changes to Appendix B.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: sync the errors example with the implementation

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: address review of the route errors section

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: list the missing-model 400 only for a required model

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: keep the route errors edit minimal

Drop the argument-validation proposal from Appendix B and the mid-stream
error event from the worked example, which the error design does not need.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: say plainly why each error declaration exists

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: drop the RouteError struct comment

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: drop comments that restate names

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: describe the error writers without reference to the old signatures

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: rewrite the Errors section in the spec's own style

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: routes list their base class's error responses explicitly

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: name the missing-model error instead of its step number

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: link the API reference instead of naming its path

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: validate request arguments in ApiRoute::serve()

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: serve() removes undeclared nulls; MCP may read its own body

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: Drift Check flags base-class errors a route can't get

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: serve() renames aliases, and the name wins

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: validate nested values; describe invalid_argument by what it checks

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: check Form args and range/length/pattern keywords; Anthropic errors carry code

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: head each response shape with its title; drop the Field Descriptions label

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Declare each route's errors as RouteError values (#3871)

* Spec: declare each route's errors as RouteError values

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: reword the status-code compatibility note

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Add RouteError and convert core error writers to it

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Generate each route's Errors table and lint error statuses

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Declare every route's errors as RouteError values

Each error status a route writes now comes from a RouteError listed in its
spec, and the generated docs list them in an Errors table. Nothing changes
on the wire.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: declare route errors without changing the wire

Replace the fail()/ErrorFormat draft with RouteError values that the existing
writers take in place of a status. Move status changes to Appendix B.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Fix route error declarations from review

Correct inaccurate when texts and codes, document the race 404s the llamacpp
routes pass through, drop a dead provider guard, keep error-shape facts the
removed notes carried, describe stream error events, and add errors to the
/internal/routes schema.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: sync the errors example with the implementation

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: address review of the route errors section

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Drop notes that restate the stream error event

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: list the missing-model 400 only for a required model

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* List the missing-model 400 only for routes that require a model

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: keep the route errors edit minimal

Drop the argument-validation proposal from Appendix B and the mid-stream
error event from the worked example, which the error design does not need.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: say plainly why each error declaration exists

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Say plainly why each error declaration exists

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: drop the RouteError struct comment

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Drop the RouteError struct comment

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: drop comments that restate names

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Drop comments that restate names; keep the base header's comments

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: describe the error writers without reference to the old signatures

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: rewrite the Errors section in the spec's own style

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: routes list their base class's error responses explicitly

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* List base-class error responses explicitly in each route

Replace the registry's inherited-error merge and the paired error-list overrides
with base-class constants that each route lists in spec(), and lint for them.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: name the missing-model error instead of its step number

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: link the API reference instead of naming its path

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: validate request arguments in ApiRoute::serve()

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Validate request arguments in ApiRoute::serve()

Each Json/OptionalJson route's JsonBody and Query args are checked against
their RouteArg before handle(), with aliases, forwarded args and a per-route
ErrorFormat. Self-parsing Raw routes move to Json/OptionalJson and drop their
hand-written checks.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: serve() removes undeclared nulls; MCP may read its own body

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Remove a null only when its argument's type excludes null

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: Drift Check flags base-class errors a route can't get

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Rename aliases in serve() so handlers read only the argument's name

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Check nested argument values; drop route checks their schemas now cover

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Consolidate redundant route errors

Shared checks now declare their errors once beside the function that writes them,
catch-all 500s share ApiRoute::kUnexpectedException, Form args and range, length
and pattern keywords are validated centrally, and Anthropic errors carry code.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Share kUnexpectedException for install, uninstall and unload catch-alls

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Share errors for malformed backend responses, unlisted fields and 3D failures

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Share one alias-store 500 across the alias routes

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Head each response shape with its title in the API docs

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>

* Spec: compatibility with v2026.42 and prior; Ollama argument reading (#3896)

Adds a Compatibility with v2026.42 and Prior subsection (public API, URL
prefixes, older names, empty bodies, Ollama clients), the RouteArg
drop_invalid flag, and the first-spelling-wins alias rule. Drops the
quad-prefix invariant from AGENTS.md, since the compatibility section now
covers which prefixes are served, and renumbers the disconnect invariant.


Claude-Session: https://claude.ai/code/session_014JszCEzPFtJywaaGgq7rFu

Co-authored-by: Claude <[email protected]>

* Spec: drop drop_invalid; Lemonade extensions on Ollama routes are checked like any other argument

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014JszCEzPFtJywaaGgq7rFu

* Spec: the alias rule only drops an empty spelling; trim the Ollama clients bullet

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014JszCEzPFtJywaaGgq7rFu

* Ollama client-compatibility tests (#3886)

* Spec: collect compatibility rules under "Compatibility with v2026.42 and Prior"

The spec's Scope gets a subsection that lists what lemond keeps for clients
built against v2026.42 and earlier: the public API, the /api/v0, /api/v1 and
/v0 prefixes (still served for pre-existing endpoints, no longer documented;
docs and examples use /v1 only), argument and path aliases, and OptionalJson's
null body. The Prefixes table and the backend guide point there.

AGENTS.md drops invariant 10 (quad-prefix registration); the disconnect
invariant becomes 10, and the references to it follow. Two comments that
cited invariant 11 for unrelated rules now cite the right one or none.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018UUSj8ww81MPozDgCc1Puq

* Test the Ollama gateway with the requests Ollama's clients send

Ollama's Go client (and so the `ollama` CLI) always sends both "model" and
"name" on show, pull and delete, leaving one empty, and Ollama reads
cmp.Or(model, name). New tests send those exact bodies for `ollama run`,
`ollama show`, `ollama pull` and `ollama rm`, plus think levels, a malformed
ctx_size (a field Ollama does not define, so it ignores it), /api/embeddings'
prompt next to an input, and options that are not an object.

Tests that need no model use an unknown model name and expect its 404, so
they fail when a request is rejected before the model lookup.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018UUSj8ww81MPozDgCc1Puq

* Move the spec and AGENTS.md edits to their own PR; drop invariant numbers from code

The compatibility section and the invariant renumbering now land with the
spec, so code comments no longer cite AGENTS.md invariants by number.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014JszCEzPFtJywaaGgq7rFu

* Expect 400 for a malformed ctx_size on the Ollama routes

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014JszCEzPFtJywaaGgq7rFu

* Drop the ctx_size and embeddings prompt/input tests

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014JszCEzPFtJywaaGgq7rFu

* Keep only the tests that send the ollama CLI's requests to a loaded model

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014JszCEzPFtJywaaGgq7rFu

* Ollama gateway: read model/name like Ollama, accept think levels (#3887)

* Read an argument's spellings the way Ollama reads model and name

ApiRoute::check_args now reads an argument sent under several spellings
from the first one with a value, the name and then each alias, checks only
that value, and drops the rest unchecked. An empty string is no value when
another spelling has one. This is Ollama's cmp.Or(model, name): its Go
client always sends both and leaves one empty, which the old rule rejected
because every spelling was checked against minLength.

RouteArg::drop_invalid ignores a value that fails its schema instead of
answering 400, for fields a gateway's clients expect to be ignored.

The spec's Argument Validation and Compatibility sections state both rules,
and test_route_args covers them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018UUSj8ww81MPozDgCc1Puq

* Ollama routes: accept think levels and ignore malformed Lemonade extensions

/api/chat's think takes a boolean or one of low, medium, high and max, the
levels Ollama accepts for models without their own; other strings answer
400 as in Ollama. ctx_size on chat, generate, embed and embeddings, and
generate's top-level width, height, steps, cfg_scale and seed, are Lemonade
extensions that Ollama does not define, so a malformed value is ignored as
Ollama ignores unknown fields. options keeps its object check, as in Ollama.

/api/tags' size is documented as the measured size of the model's files.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018UUSj8ww81MPozDgCc1Puq

* Drop the route-argument C++ unit test

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014JszCEzPFtJywaaGgq7rFu

* Drop drop_invalid: malformed Lemonade extensions on Ollama routes answer 400

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014JszCEzPFtJywaaGgq7rFu

* Narrow the alias change to dropping an empty spelling; drop the /api/tags doc change

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014JszCEzPFtJywaaGgq7rFu

---------

Co-authored-by: Claude <[email protected]>

---------

Co-authored-by: Claude <[email protected]>

* Spec: name each route argument by its RouteArg constant (#3888)

* Spec: collect compatibility rules under "Compatibility with v2026.42 and Prior"

The spec's Scope gets a subsection that lists what lemond keeps for clients
built against v2026.42 and earlier: the public API, the /api/v0, /api/v1 and
/v0 prefixes (still served for pre-existing endpoints, no longer documented;
docs and examples use /v1 only), argument and path aliases, and OptionalJson's
null body. The Prefixes table and the backend guide point there.

AGENTS.md drops invariant 10 (quad-prefix registration); the disconnect
invariant becomes 10, and the references to it follow. Two comments that
cited invariant 11 for unrelated rules now cite the right one or none.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018UUSj8ww81MPozDgCc1Puq

* Test the Ollama gateway with the requests Ollama's clients send

Ollama's Go client (and so the `ollama` CLI) always sends both "model" and
"name" on show, pull and delete, leaving one empty, and Ollama reads
cmp.Or(model, name). New tests send those exact bodies for `ollama run`,
`ollama show`, `ollama pull` and `ollama rm`, plus think levels, a malformed
ctx_size (a field Ollama does not define, so it ignores it), /api/embeddings'
prompt next to an input, and options that are not an object.

Tests that need no model use an unknown model name and expect its 404, so
they fail when a request is rejected before the model lookup.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018UUSj8ww81MPozDgCc1Puq

* Read an argument's spellings the way Ollama reads model and name

ApiRoute::check_args now reads an argument sent under several spellings
from the first one with a value, the name and then each alias, checks only
that value, and drops the rest unchecked. An empty string is no value when
another spelling has one. This is Ollama's cmp.Or(model, name): its Go
client always sends both and leaves one empty, which the old rule rejected
because every spelling was checked against minLength.

RouteArg::drop_invalid ignores a value that fails its schema instead of
answering 400, for fields a gateway's clients expect to be ignored.

The spec's Argument Validation and Compatibility sections state both rules,
and test_route_args covers them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018UUSj8ww81MPozDgCc1Puq

* Ollama routes: accept think levels and ignore malformed Lemonade extensions

/api/chat's think takes a boolean or one of low, medium, high and max, the
levels Ollama accepts for models without their own; other strings answer
400 as in Ollama. ctx_size on chat, generate, embed and embeddings, and
generate's top-level width, height, steps, cfg_scale and seed, are Lemonade
extensions that Ollama does not define, so a malformed value is ignored as
Ollama ignores unknown fields. options keeps its object check, as in Ollama.

/api/tags' size is documented as the measured size of the model's files.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018UUSj8ww81MPozDgCc1Puq

* Spec: name each argument by its RouteArg constant

Each argument becomes a RouteArg constant beside its handler that spec()
lists, as RouteErrors are. After serve() resolves aliases, route code reads
and changes an argument only through its constant (req.has, req.value,
req.arg, req.body[k.name]); query and path values are converted to the
schema's type. ModelRoute reads the model through model_arg() and
canonical_model_name(), which takes a name rather than a request body.
The drift check fails a route file that names an argument by a string
literal or reads a RouteArg its spec does not list.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018UUSj8ww81MPozDgCc1Puq

* Spec: write the RouteArg constant rules in the spec's style

Move Reading arguments after the other serve() bullets, keep the Aliases
sentence as it was, and give the argument example the same shape as the
RouteError example. Word the ModelRoute step, the helper row and the drift
check bullet like their neighbours.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018UUSj8ww81MPozDgCc1Puq

* Spec: state the shared-helper rule plainly

Drop the comparison to RouteError and say directly which helpers receive
values and which receive the body.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018UUSj8ww81MPozDgCc1Puq

* Spec: name another route's and shared arguments by constant

A route that builds another route's request, as the gateways do, names
that route's arguments through its constants, which openai_args.h
declares for the OpenAI routes. An argument several routes take alike is
one constant, such as ModelLoader::kCtxSize. The drift check flags a
literal key on a built request.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018UUSj8ww81MPozDgCc1Puq

* Spec: keep arguments that several routes take alike in shared_args.h

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018UUSj8ww81MPozDgCc1Puq

* Spec: take the example's stream argument from common::kStream

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018UUSj8ww81MPozDgCc1Puq

* Spec: the drift check fails a RouteArg that duplicates another

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018UUSj8ww81MPozDgCc1Puq

* Spec: path parameter rules, distinct arguments, helper reads, tagged model names

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0181gVXYv16yiMWExUzzEmvN

* Name every route argument by its RouteArg constant (#3890)

* Name every route argument by its RouteArg constant

Each route's arguments become file-scope RouteArg constants that spec()
lists. Route code reads and changes an argument only through its constant,
with new RouteRequest accessors: has(), arg(), value() and file(), and
req.body[k.name] for a value the route forwards. serve() collects Query
and Path arguments into req.params, converted to their schema types, and
RouteRegistry rejects a route whose paths order their parameters
differently or whose path pattern has its own capture group.

ModelRoute reads the model through each route's model_arg(), and
canonical_model_name() takes a name instead of a request body, so /unload
strips :latest and follows model aliases whichever spelling the client
used. Shared helpers that read arguments now take values:
gateway_load_options(), respond_with_model_options() and the local
backend recipe check.

The drift check fails a route file that declares an argument inline,
names an argument or alias by a string literal, or uses a RouteArg its
args do not list. registry/search now declares `q` as an alias of
`query`, which the generated docs list.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018UUSj8ww81MPozDgCc1Puq

* Name other routes' arguments and shared arguments by constant

The gateways write the OpenAI requests they build through the target
route's RouteArg constants, which openai_args.h declares and the OpenAI
route files define: openai_req[openai::chat::kMessages.name]. The
arguments chat/completions and completions take alike are one set of
constants both list. map_ollama_options() maps Ollama option names onto
those constants.

ctx_size, which ModelRoute reads for every model route, is one
ModelLoader::kCtxSize that the model routes list, and load_options()
takes its value. The speech and audio format helpers take
response_format, the image upload helper takes the route's image
constant, map_ollama_options() takes Ollama's options, and the Omni
helper reads stream through the chat constant.

chat/completions and completions forward tool_choice, response_format,
seed and frequency_penalty without declaring them; they are now declared
as forwarded arguments, so the docs list them. rerank's ctx_size gains
the sentence the other model routes carry. RouteArg moves to its own
header so model_loader.h and openai_args.h can use it.

The drift check flags a literal key on a request built for an OpenAI
route, and resolves constants that route files list but do not define.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018UUSj8ww81MPozDgCc1Puq

* Keep each argument that several routes take alike in shared_args

Arguments that several routes declared as separate, identical constants
(the text routes' sampling arguments, the Ollama model and ctx_size
arguments, the jobs and models path ids, the download stream arguments,
and so on) are now one constant each in lemon/server/shared_args.h, which
every route that takes the argument lists. Where the copies' descriptions
differed only in wording, the shared constant keeps one wording, which
the regenerated API docs show.

ModelLoader::kCtxSize becomes model_loading::kCtxSize, and the
openai::text constants and openai::chat::kTools move out of
openai_args.h. The drift check now tells shared constants apart by
namespace and flags a route that reads a shared constant it does not
list.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018UUSj8ww81MPozDgCc1Puq

* Share stream, max_tokens and provider where routes take them alike

The server-sent-events stream argument of the text routes and the
download routes is one constant, common::kStream, and Ollama's /api/pull
lists ollama::kStream with /api/chat and /api/generate. chat/completions
and completions share openai::text::kMaxTokens; the precedence over
max_completion_tokens is stated on max_completion_tokens, and
map_ollama_options no longer takes the max_tokens argument. install and
uninstall share backend_routes::kProvider.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018UUSj8ww81MPozDgCc1Puq

* Share model, steps, ctx_size, keep_alive and backend across routes

Every route that loads its model on first use lists model_loading::kModel,
or model_loading::kFormModel for a multipart form, in place of a
per-route model argument whose description only named the kind of model.
Ollama's /api/embed and /api/embeddings take gateway::kModel. Audio and
image generation share inference::kSteps, /v1/load and
/v1/models/{id}/options share model_options::kCtxSize, and Ollama's
/api/chat and /api/generate share ollama::kKeepAlive. The install dry run
lists backend_routes::kBackend, whose cloud value is now stated on
provider.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018UUSj8ww81MPozDgCc1Puq

* Share model_name between /internal/pin and /v1/delete

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018UUSj8ww81MPozDgCc1Puq

* Share dry_run between /internal/models/sync and /v1/models/{id}/options

How the options route's response reads after a dry run is stated in that
route's notes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018UUSj8ww81MPozDgCc1Puq

* Drift check: fail a RouteArg that duplicates another

Two RouteArg constants with the same spellings (name and aliases, under
any constant name), location, schema and flags fail the check, whatever
their descriptions say, so a copy of a shared argument has to use the
shared constant. A group whose routes treat the argument differently is
listed in DISTINCT_ARGUMENTS with how they differ, and an entry that no
longer matches fails too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018UUSj8ww81MPozDgCc1Puq

* State that max_tokens wins over max_completion_tokens

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0181gVXYv16yiMWExUzzEmvN

* Pass router_dispatch() the values it reads, and lint helpers that read arguments by name

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0181gVXYv16yiMWExUzzEmvN

* Give uninstall its own provider argument: the installed provider to remove

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0181gVXYv16yiMWExUzzEmvN

* Describe keep_alive's unload condition as an empty input

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0181gVXYv16yiMWExUzzEmvN

* Keep :latest on a registered model name that ends in it

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0181gVXYv16yiMWExUzzEmvN

---------

Co-authored-by: Claude <[email protected]>

---------

Co-authored-by: Claude <[email protected]>

* Fix the misleading docs and the null job name the #3771 audit flagged (#3897)

- POST /jobs reads `name` from the checked body, so `"name": null` counts as
  absent and creates the job instead of answering 500 with no body.
- max_completion_tokens: the backend picks when both limits are sent
  (llama.cpp uses max_tokens, vLLM max_completion_tokens).
- models/{id}/files: an alias's id is not accepted.
- install: name the cloud errors that carry an object; the rest carry a string.
- pull: top-level mmproj is a filename in the checkpoint repository, and
  checkpoints.mmproj takes repository:filename.
- simulate-vram-pressure: one evaluation unloads at most one model, the first
  past its idle timeout before any pressure candidate, and downsizes idle ones.
- internal.md: the admin key alone leaves every non-internal endpoint open.


Claude-Session: https://claude.ai/code/session_018UUSj8ww81MPozDgCc1Puq

Co-authored-by: Claude <[email protected]>

* Fix the five misleading docs statements the second audit found (#3902)

- models/sync status: a sync other than a dry run that found no models to
  check finishes `idle`.
- models/sync/status `sync_id`: a finished sync's answer is the status
  recorded when it finished, completed_sync_id and already_in_progress
  included.
- chat/completions streaming `usage`: vLLM models always send the usage chunk.
- chat/completions `tool_choice`: llama.cpp models treat the object form as
  `auto`, so the argument is Partial.
- install: name every cloud check that answers an `error` object, including
  missing fields and an `http://` base URL without allow_insecure_http.


Claude-Session: https://claude.ai/code/session_018UUSj8ww81MPozDgCc1Puq

Co-authored-by: Claude <[email protected]>

* Apply suggestion from @jeremyfowers

* Apply batched suggestions from code review

Co-authored-by: Jeremy Fowers <[email protected]>

* Spec: name each route argument by its RouteArg constant

Brings the spec changes from #3888, which merged into
jfowers/http-server-refactor, onto the spec branch so that every
spec change lives in the spec PR.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QCduCZnp6zXsBoSfy79Y7z

* Spec: drift check fails an API page missing from the nav or the API reference table

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QCduCZnp6zXsBoSfy79Y7z

* gen_api_boilerplate: fail when an API page is missing from the nav or the API reference table

--check now fails when a page that has routes has no entry in the
mkdocs.yml nav or no row in the page table in docs/api/README.md, or
when either one lists a docs/api page that has no routes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QCduCZnp6zXsBoSfy79Y7z

* Regenerate API docs for pull registry_unavailable error

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KsnZfUqJ2z9bTH2g2UK64K

* Pull docs: only the SSE error event reports registry_unavailable

Background download jobs (subscribe: false) still report a rate-limited
registry as a generic error, as on main.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KsnZfUqJ2z9bTH2g2UK64K

* Trim the main-merge port to the minimum the refactor requires

Drop the pull note rewording and the download event schema additions;
keep the registry_unavailable RouteError, which the route lint requires
for the 503 the pull route now writes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KsnZfUqJ2z9bTH2g2UK64K

* Check query args on Raw routes; fix alias regex backtracking; narrow 405 docs

- Raw routes now validate their query arguments against the schema, and a
  boolean query value must be "true" or "false". show_all=invalid and
  sync_id=12abc now answer 400 invalid_argument.
- ROUTE_ARG_ALIASES no longer backtracks exponentially (CodeQL #84); it
  matches the same text on every RouteArg in src/cpp.
- The 405 row names the prefixes that actually answer it.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Leave missing-argument errors on Raw routes to their handlers

pull/variants and registry/search report a missing required query argument
with their own message, which clients and test_030 match on.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* fix(docs): removed markdown sections by #3834

* test: align missing-model error with HTTP refactor

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Co-authored-by: Florian Reinle <[email protected]>
2026-10-22 11:51:42 +00:00