feat(model-proxy, bus, plugins, webui): the instance owner switches proxy models on or off per provider (state file models-offered.json) (#1873) #2022

Merged
jason.woltje merged 4 commits from models-offered into refactor 2026-11-20 21:10:31 +00:00
Owner

What changes

Lane models-offered, section 2 of the settings backend design (A9): the instance owner switches proxy models on or off per provider.

  • State file. <dataRoot>/state/models-offered.json, shaped { version: 1, providers: { <id>: { on: [...], seen: [...] } } }. It holds no harness and no key, and is written whole under the admin lock with a receipt. A damaged file turns every model off and never falls back to all on.
  • Catalogue. The cliproxy plugin's catalogue() takes the new offered input. An off or unseen model is unavailable with model-off, and an unseen one is marked New. Harnesses never change, so switching a model on never widens where it runs. The bus reads the file at every catalogue read.
  • Routes. Console GET /api/proxy/admin/models and POST /api/proxy/admin/models/set, instance owner only. The write refuses models-offered-conflict on a stale revision. It refuses models-in-use when a model being switched off is in use, naming each organization and agent, unless the owner confirms. An organization that does not answer counts as a possible user.
  • Settings. One list per provider, with a count, New and In use notes, and a search past eight models. Switching off a model in use asks in place.
  • First read seeds the file. The plugin has no rule for "current models", so the first read writes every model present as on and seen. It seeds only on a same-origin GET from a Console that can send, only when every riding organization answers, and only for a provider with 256 models or fewer.

The state file and the codes models-offered-conflict and models-in-use were approved on 2026-11-20. No other verb, code, grant, role, schema or config format.

What differs from the design

  • The control is in packages/model-proxy/src/models-offered.mjs, not admin.mjs.
  • usedBy lists {org, instance, fallback}, and the in-use reply adds unanswered.
  • In use counts the organization file and root agents as well as the model table.
  • No "Current models only" button, since there is no current rule to drive it. Labels are model ids.
  • The ask names who uses the model and has no move target.

Tests

  • Lane proof on 7b8451d1c: 454 files under model-proxy, bus, webui and plugins, 4551 pass, 0 fail, 10 skipped.
  • Rebased onto ccd85604c (account-remove). Two test files conflicted and both sides were kept: the import line and both new tests in model-provider-catalogue.test.mjs, and the route table test in proxy-admin-http.test.mjs. range-diff shows commits 2 to 4 unchanged.
  • Lead check in a clean environment on the rebased tip d752e7535: 486 files, 4956 pass, 0 fail, 10 skipped.

Review

Four rounds by fresh claude-opus-5-5 reviewers. Rounds one and two asked for changes. The largest was that root agent copies and project agents did not count as in use. Round three approved: it got past neither refusal, found no caller the change breaks, and 40 of 44 mutants were killed, with one survivor equivalent. Round four approved the test-only commit with one nit.

Left for later

  • Triage key usage is not counted in usedBy. Triage's admit refuses an off model, so it fails closed.
  • Recovery from a damaged file means deleting the file. A repair verb would need approval.
  • One confirm covers every model in use in the save.
  • Unanswered organizations are not shown before the first save.
  • An organization that rides but has no launch block reads as unanswered, so it blocks the seed and joins every ask.
  • The limit test's refused case totals 262, so a drift of the early check to 257 through 261 would pass. The write still refuses past 256.
  • CLIProxyAPI 8.0.79 has excluded-models in its config. Not built.
## What changes Lane models-offered, section 2 of the settings backend design (A9): the instance owner switches proxy models on or off per provider. - **State file.** `<dataRoot>/state/models-offered.json`, shaped `{ version: 1, providers: { <id>: { on: [...], seen: [...] } } }`. It holds no harness and no key, and is written whole under the admin lock with a receipt. A damaged file turns every model off and never falls back to all on. - **Catalogue.** The cliproxy plugin's `catalogue()` takes the new `offered` input. An off or unseen model is unavailable with `model-off`, and an unseen one is marked New. Harnesses never change, so switching a model on never widens where it runs. The bus reads the file at every catalogue read. - **Routes.** Console `GET /api/proxy/admin/models` and `POST /api/proxy/admin/models/set`, instance owner only. The write refuses `models-offered-conflict` on a stale revision. It refuses `models-in-use` when a model being switched off is in use, naming each organization and agent, unless the owner confirms. An organization that does not answer counts as a possible user. - **Settings.** One list per provider, with a count, New and In use notes, and a search past eight models. Switching off a model in use asks in place. - **First read seeds the file.** The plugin has no rule for "current models", so the first read writes every model present as on and seen. It seeds only on a same-origin GET from a Console that can send, only when every riding organization answers, and only for a provider with 256 models or fewer. The state file and the codes `models-offered-conflict` and `models-in-use` were approved on 2026-11-20. No other verb, code, grant, role, schema or config format. ## What differs from the design - The control is in `packages/model-proxy/src/models-offered.mjs`, not `admin.mjs`. - `usedBy` lists `{org, instance, fallback}`, and the in-use reply adds `unanswered`. - In use counts the organization file and root agents as well as the model table. - No "Current models only" button, since there is no current rule to drive it. Labels are model ids. - The ask names who uses the model and has no move target. ## Tests - Lane proof on 7b8451d1c: 454 files under model-proxy, bus, webui and plugins, 4551 pass, 0 fail, 10 skipped. - Rebased onto ccd85604c (account-remove). Two test files conflicted and both sides were kept: the import line and both new tests in `model-provider-catalogue.test.mjs`, and the route table test in `proxy-admin-http.test.mjs`. `range-diff` shows commits 2 to 4 unchanged. - Lead check in a clean environment on the rebased tip d752e7535: 486 files, 4956 pass, 0 fail, 10 skipped. ## Review Four rounds by fresh claude-opus-5-5 reviewers. Rounds one and two asked for changes. The largest was that root agent copies and project agents did not count as in use. Round three approved: it got past neither refusal, found no caller the change breaks, and 40 of 44 mutants were killed, with one survivor equivalent. Round four approved the test-only commit with one nit. ## Left for later - Triage key usage is not counted in `usedBy`. Triage's admit refuses an off model, so it fails closed. - Recovery from a damaged file means deleting the file. A repair verb would need approval. - One confirm covers every model in use in the save. - Unanswered organizations are not shown before the first save. - An organization that rides but has no launch block reads as unanswered, so it blocks the seed and joins every ask. - The limit test's refused case totals 262, so a drift of the early check to 257 through 261 would pass. The write still refuses past 256. - CLIProxyAPI 8.0.79 has `excluded-models` in its config. Not built.
jason.woltje added 4 commits 2026-11-20 21:10:24 +00:00
jason.woltje merged commit d752e75359 into refactor 2026-11-20 21:10:31 +00:00
Sign in to join this conversation.