Files
lemonade/docs/dev/web-ui.md
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

5.3 KiB

Web App Build Directory

This directory contains a web-only build configuration for the Lemonade React app, optimized for browser deployment without the Tauri host or Rust toolchain.

Structure

The shared React source lives once in ../app/src/. This directory only contains the web-app's own build configuration:

  • package.json - Web-only dependencies (no Tauri, no Rust crates)
  • webpack.config.js - Browser-targeted webpack config; entry and HtmlWebpackPlugin.template point at ../app/src/... directly
  • tsconfig.json - TypeScript configuration; include covers ../app/src/**/*
  • tauri-stub.js - No-op stub aliased in for the @tauri-apps/* specifiers used by the shared renderer's tauriShim.ts
  • BuildWebApp.cmake - Stages both src/app/ and src/web-app/ side-by-side under build/web-app-staging/ and runs webpack from there
  • node_modules/ - Separate build dependency tree (created on demand by npm install, only in non-system-packages mode)
  • dist/renderer/ - Local build output (the CMake target writes to build/resources/web-app/ instead)

Why no symlinks? Earlier revisions used OS-level symlinks (src/ → ../app/src) to share source. Those broke Windows checkouts unless core.symlinks=true AND developer mode were both enabled. Webpack's relative entry/template paths achieve the same result with no checkout-time hazard.

Why This Approach?

The separation exists because of a hard invariant: the native Debian package for lemond must build using only npm modules that ship in Debian's repositories (resolved from /usr/share/nodejs, /usr/lib/nodejs, /usr/share/javascript). The old Electron desktop app pulled in dependencies Debian does not package, which made it impossible to build the browser UI from the same package.json under distro rules.

This directory's package.json is therefore curated to contain only dependencies Debian provides, and webpack.config.js honors USE_SYSTEM_NODEJS_MODULES=true to resolve everything from system module paths when built inside a Debian source package. The @tauri-apps/* specifiers the shared renderer imports (for tauriShim.ts) are aliased to the no-op tauri-stub.js at build time so the web build doesn't require the Tauri CLI or a Rust toolchain either.

This split is an invariant, not an accident to be tidied up. src/web-app/package.json must not be consolidated with src/app/package.json — doing so would break reproducible distro packaging. Additions to the shared renderer that introduce new npm dependencies must either (a) pick a module already in Debian or (b) be placed behind a runtime check and excluded from the web-app code path.

Secondary benefits of the split:

  • CI jobs that only need the browser UI don't install the Tauri CLI or Rust
  • lemond can serve /app from any build host without requiring the desktop build
  • The .deb and .rpm server packages ship the browser UI without dragging in Rust

Building

cmake --build --preset default --target web-app

Key Differences from the Tauri Desktop App

Feature web-app app (Tauri)
Webpack target web web (Tauri uses a standard webview)
Dependencies Node.js + webpack Node.js + webpack + Rust + webkit2gtk (Linux)
Output web-app/dist/renderer/ app/dist/renderer/ (renderer) + app/src-tauri/target/release/lemonade-app (binary)
Purpose Browser via /app endpoint Desktop application
window.api Mock injected by lemond (src/cpp/server/core/web_ui.cpp) Installed by tauriShim.ts → Tauri invoke()

Both builds share the same 55+ React files under src/app/src/renderer/. The renderer checks window.api?.isWebApp to differentiate the two modes at runtime.

Webpack Configuration

The webpack.config.js here differs from the Tauri app's in a few ways, all of which serve the Debian-packaging constraint:

  • resolve.modules optionally resolves from /usr/share/nodejs, /usr/lib/nodejs, and /usr/share/javascript when USE_SYSTEM_NODEJS_MODULES=true
  • A KaTeX system-overlay code path is wired in for Debian's packaged katex (which does not include the bundled fonts/CSS the shared renderer expects)
  • buffer and process/browser polyfills are resolved lazily (try { require.resolve(...) }) because Debian may not ship them
  • resolve.alias rewrites every @tauri-apps/* specifier to tauri-stub.js so the web build works without the Tauri packages installed
  • transpileOnly: true for faster builds (skips type checking)

Since Tauri v2 uses a normal webview (not an Electron renderer), both the Tauri app and the web app now use webpack target: 'web'.

Maintenance

When adding new source files or changing the React app:

  • Edit files in src/app/src/ - both builds pick up the change because webpack's entry/template resolve to that directory directly, and the CMake web-app target tracks both trees in its WEB_APP_SOURCES glob.
  • Update dependencies in both src/app/package.json and src/web-app/package.json as needed (the split is required for Debian native packaging — see "Why This Approach?" above).
  • Tauri-specific features (settings persistence, UDP discovery, window controls) should be gated with if (window.api && !window.api.isWebApp) or similar runtime checks.