Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
confine the pin-membership tolerances so they cannot over-accept (#7327)
[._.]/ Adam Eivydec7c0ecc375
diff --git a/client/src/utils/providerModels.js b/client/src/utils/providerModels.jsindex 22556ab877..9e182350b8 100644--- a/client/src/utils/providerModels.js+++ b/client/src/utils/providerModels.js@@ -199,16 +199,16 @@ export const MODEL_SOURCE = Object.freeze({* existing task template renders what it actually holds instead of silently* changing model — and the picker can say so.*- * The shipped branch asks `modelPinIsOffered` (server/lib/modelPinMembership.js),+ * The shipped branch's FLAG asks `modelPinIsOffered` (server/lib/modelPinMembership.js),* the SAME rule the spawner and the retired-pin audit use, rather than a bare* `includes`. That rule is what makes the flag honest here instead of noisy:- * it passes a configured-default sentinel, an empty catalog, and a- * local-daemon provider (whose `models` is a cached snapshot while the daemon- * is the authority) — and it tolerates the two same-model-spelled-differently- * forms, so a legacy agy `-high` pin whose BASE is still listed reads as- * offered and only a genuinely retired one is flagged. Until #7327 this branch- * hardcoded `false`, so the flag only ever fired for a Codex account catalog- * and every OTHER picker rendered a rotted pin as a perfectly normal option.+ * it passes an empty catalog and a local-daemon provider (whose `models` is a+ * cached snapshot while the daemon is the authority), and it tolerates the two+ * same-model-spelled-differently forms, so a legacy agy `-high` pin whose BASE+ * is still listed reads as offered and only a genuinely retired one is+ * flagged. Until #7327 this branch hardcoded `false`, so the flag only ever+ * fired for a Codex account catalog and every OTHER picker rendered a rotted+ * pin as a perfectly normal option.** The ACCOUNT branch deliberately keeps its own bare membership test: a* successfully-read EMPTY account catalog means the account really exposes no@@ -228,15 +228,20 @@ export const resolveProviderModelOptions = (provider, selectedModel) => {);const catalog = codexCatalogModelIds(provider);if (!catalog) {- // `withStaleAntigravityPin` may already have kept the pin selectable; this- // appends the cases it deliberately does not cover (a bare retired id on- // any provider). Selectable and flagged are complementary — never let one- // drop the other.- const unlisted = !!selectedModel && !modelPinIsOffered(provider, selectedModel);+ // SELECTABLE and FLAGGED are decided separately, because they answer+ // different questions. Anything stored and not already an option has to+ // become one or the select renders BLANK and reads as "no model" — that+ // covers a retired pin, and equally a pin the rule ACCEPTS that the list+ // still lacks (an installed Ollama model absent from the record's cached+ // snapshot, a bare OpenCode pin against a namespaced catalog). Only the+ // flag asks whether the pin is dead. Coupling the two would have hidden+ // every working-but-unlisted pin, which is the failure+ // `withStaleAntigravityPin` already exists to prevent for one narrow case.+ const stored = !!selectedModel && !isConfiguredDefaultModel(selectedModel);return {- models: unlisted && !shipped.includes(selectedModel) ? [...shipped, selectedModel] : shipped,+ models: stored && !shipped.includes(selectedModel) ? [...shipped, selectedModel] : shipped,source: MODEL_SOURCE.shipped,- unlistedSelection: unlisted,+ unlistedSelection: stored && !modelPinIsOffered(provider, selectedModel),};}const models = filterSelectableModels(catalog);diff --git a/client/src/utils/providers.test.js b/client/src/utils/providers.test.jsindex b20229282c..aac5eea847 100644--- a/client/src/utils/providers.test.js+++ b/client/src/utils/providers.test.js@@ -470,7 +470,22 @@ describe('Antigravity base-model split', () => {it('never flags an empty catalog or a configured-default sentinel', () => {// "We have no catalog" must not read as "the model is gone".expect(resolveProviderModelOptions({ id: 'custom', models: [] }, 'anything').unlistedSelection).toBe(false);- expect(resolveProviderModelOptions(agy(AGY_CATALOG), ANTIGRAVITY_CONFIGURED_DEFAULT).unlistedSelection).toBe(false);+ const sentinel = resolveProviderModelOptions(agy(AGY_CATALOG), ANTIGRAVITY_CONFIGURED_DEFAULT);+ expect(sentinel.unlistedSelection).toBe(false);+ // ...and it is not appended either: `filterSelectableModels` exists to+ // keep the sentinel OUT of a task's model picker.+ expect(sentinel.models).not.toContain(ANTIGRAVITY_CONFIGURED_DEFAULT);+ });++ it('keeps a working-but-unlisted pin selectable WITHOUT flagging it', () => {+ // Selectable and flagged answer different questions. A local daemon's+ // `models` is a cached snapshot, so an installed model missing from it+ // is neither retired nor renderable — coupling the append to the flag+ // left the select blank and the pin was lost on the next save.+ const ollama = { id: 'opencode-ollama', command: 'opencode', ollamaBacked: true, models: ['ollama/qwen3:8b'] };+ const result = resolveProviderModelOptions(ollama, 'qwen3:32b');+ expect(result.unlistedSelection).toBe(false);+ expect(result.models).toContain('qwen3:32b');});it('appends a retired BARE pin that withStaleAntigravityPin deliberately skips', () => {diff --git a/server/lib/modelPinMembership.js b/server/lib/modelPinMembership.jsindex 1224cc66b1..bdfda363c6 100644--- a/server/lib/modelPinMembership.js+++ b/server/lib/modelPinMembership.js@@ -15,7 +15,7 @@* The endpoint half stayed behind in `localProviderRuntime.js`.*/-import { localRuntimeNamespace, isAntigravityProvider, antigravityCatalogListsModel, filterSelectableModels, isConfiguredDefaultModel } from './providerModels.js';+import { localRuntimeNamespace, isAntigravityProvider, isOpencodeProvider, antigravityCatalogListsModel, filterSelectableModels } from './providerModels.js';import { PORTS } from './ports.js';import { isLocalInstanceHost, localEndpointPort } from './localEndpoint.js';@@ -90,12 +90,9 @@ const bareOpencodeModel = (value) => value.slice(value.indexOf('/') + 1);* Whether a provider may be handed `model` — the ONE rule for validating a* stored model pin against a provider record.*- * Three pins pass through unconditionally, for three different reasons:+ * Two providers are pass-throughs, for opposite reasons:*- * - a CONFIGURED-DEFAULT SENTINEL is not a model at all, it is "use the CLI's- * own default". `resolveCliModel` turns it into no `--model` flag, so every- * provider can be handed it whatever its catalog says;- * - a provider that enumerates NO models has nothing to validate against, so+ * - one that enumerates NO models has nothing to validate against, so* any id is its caller's to choose;* - one backed by a LOCAL daemon has a `models` array that is only a cached* snapshot, while the daemon on this machine is the authority. Every model@@ -126,7 +123,15 @@ const bareOpencodeModel = (value) => value.slice(value.indexOf('/') + 1);* would have spawned it.* - **OpenCode addresses models as `namespace/model`.** A pin is stored BARE* and namespaced at spawn (`prefixOpencodeModel`), so a catalog holding the- * qualified form — or a pin hand-written that way — is the same model.+ * qualified form — or a pin hand-written that way — is the same model. Gated+ * on the provider being OpenCode: ungated, the reduction would match any+ * slash-bearing pin against a bare catalog on ANY vendor.+ *+ * A configured-default sentinel is deliberately NOT a pass-through here. It is+ * a posture rather than a model, but only a CLI that HAS its own default can be+ * handed one, so the question "is this provider's catalog missing it?" is the+ * wrong one to ask about it — `providerCatalogListsModel` answers it for the+ * retired-pin audit, and the pickers guard it with `isConfiguredDefaultModel`.** Anything else enumerates its own catalog, and a pin outside it reaches the* CLI as a model it cannot serve.@@ -137,7 +142,6 @@ const bareOpencodeModel = (value) => value.slice(value.indexOf('/') + 1);*/export function modelPinIsOffered(provider, model) {const offered = Array.isArray(provider?.models) ? provider.models : [];- if (isConfiguredDefaultModel(model)) return true;if (offered.length === 0 || localRuntimeKind(provider)) return true;if (offered.includes(model)) return true;if (typeof model !== 'string' || model.trim() === '') return false;@@ -148,5 +152,12 @@ export function modelPinIsOffered(provider, model) {// base list as "no catalog", which is the same pass-through as above.const ids = filterSelectableModels(offered.filter((m) => typeof m === 'string'));if (isAntigravityProvider(provider)) return antigravityCatalogListsModel(id, ids);+ // Gated on the provider actually BEING OpenCode. Ungated, the namespace+ // reduction matches any slash-bearing pin against a bare catalog on any+ // vendor — `custom/gpt-4o` would read as offered by an OpenAI record listing+ // `gpt-4o`, and the three spawn-time callers would hand that id straight to a+ // CLI/API that rejects it. Harmless while this rule only fed the audit (a+ // missed warning); a real over-permission now that it gates spawns.+ if (!isOpencodeProvider(provider)) return false;return ids.some((listed) => bareOpencodeModel(listed) === bareOpencodeModel(id));}diff --git a/server/lib/modelPinMembership.test.js b/server/lib/modelPinMembership.test.jsindex b42ab71907..418d1f45ad 100644--- a/server/lib/modelPinMembership.test.js+++ b/server/lib/modelPinMembership.test.js@@ -171,6 +171,16 @@ describe('modelPinIsOffered — same model, spelled differently', () => {expect(modelPinIsOffered(AGY, 'gemini-3.5-flash-low')).toBe(false);});+ it('confines the namespace tolerance to OpenCode providers', () => {+ // Ungated, `bare()` reduces any slash-bearing pin and matches it against a+ // bare catalog on ANY vendor, so these would read as offered and the three+ // spawn-time callers would hand the id to a CLI/API that rejects it. That+ // was harmless while this rule only fed the retired-pin audit — a missed+ // warning — and is a real over-permission now that it gates spawns.+ expect(modelPinIsOffered({ id: 'openai', models: ['gpt-4o'] }, 'custom/gpt-4o')).toBe(false);+ expect(modelPinIsOffered({ id: 'codex', command: 'codex', models: ['gpt-5'] }, 'openrouter/gpt-5')).toBe(false);+ });+it('matches an OpenCode `namespace/model` catalog against a bare pin', () => {// Pins are stored BARE and namespaced at spawn by `prefixOpencodeModel`.// A gateway-backed OpenCode provider is NOT a local daemon, so it reaches@@ -186,11 +196,14 @@ describe('modelPinIsOffered — same model, spelled differently', () => {expect(modelPinIsOffered(gateway, 'claude-opus-4')).toBe(false);});- it('accepts a configured-default sentinel against any catalog', () => {- // The sentinel is a posture ("use the CLI's own default"), not a model:- // `resolveCliModel` turns it into no `--model` flag at all, so no catalog- // can retire it. Rejecting it 400'd a legitimate brain-settings save.- expect(modelPinIsOffered({ id: 'codex', models: ['gpt-5'] }, CODEX_CONFIGURED_DEFAULT)).toBe(true);+ it('does NOT pass a configured-default sentinel through', () => {+ // A sentinel is a posture, but only a CLI that HAS its own default can be+ // handed one — so "is this catalog missing it?" is the wrong question here,+ // and answering it `true` would let an API provider store a sentinel its+ // endpoint would reject as a model id. The retired-pin audit answers it one+ // level up (`providerCatalogListsModel`), and the pickers guard it with+ // `isConfiguredDefaultModel`.+ expect(modelPinIsOffered({ id: 'codex', models: ['gpt-5'] }, CODEX_CONFIGURED_DEFAULT)).toBe(false);});it('rejects a blank or non-string pin against a real catalog', () => {diff --git a/server/lib/modelPinReconcile.js b/server/lib/modelPinReconcile.jsindex e878fbb9c1..da91adbd72 100644--- a/server/lib/modelPinReconcile.js+++ b/server/lib/modelPinReconcile.js@@ -32,6 +32,7 @@ import {antigravityBaseModels,filterSelectableModels,isAntigravityProvider,+ isConfiguredDefaultModel,} from './providerModels.js';/**@@ -66,18 +67,22 @@ export function catalogOfferings(provider) {** THE membership rule, `modelPinIsOffered`, verbatim — plus the one case a* RETIREMENT check answers differently from a spawn-time check: nothing is- * pinned at all. This wrapper exists only to name that case and to give the- * audit a signature in its own vocabulary (`(provider, modelId)`, the pin's- * side of the question).+ * pinned at all, and a configured-default SENTINEL, which is a posture ("use+ * the CLI's own default") rather than a model and so can never be retired. The+ * rule itself declines the sentinel deliberately — only a CLI that has its own+ * default can be handed one, so "is it missing from this catalog?" is the wrong+ * question there, and answering it `true` would let an API provider store one.+ * This wrapper also gives the audit a signature in its own vocabulary+ * (`(provider, modelId)`, the pin's side of the question).** The rule's posture is what makes this safe to surface in a UI: every case* where the answer is genuinely UNKNOWN answers `true`. A false "your pin is* gone" tells the user to change a setting that works, which is strictly worse- * than missing one. `modelPinIsOffered` supplies the configured-default- * sentinel, an empty catalog, a local-daemon provider, and the two- * same-model-spelled-differently tolerances (agy base ids, OpenCode's- * `namespace/model` form); this function adds the last two — nothing is- * pinned, and no provider record could be resolved to compare against.+ * than missing one. `modelPinIsOffered` supplies an empty catalog, a+ * local-daemon provider, and the two same-model-spelled-differently tolerances+ * (agy base ids, OpenCode's `namespace/model` form); this function adds three+ * more — nothing is pinned, the sentinel above, and no provider record could be+ * resolved to compare against.** Those tolerances used to be layered HERE, above a stricter* `modelPinIsOffered`, which meant the audit and the three spawn-time callers@@ -92,8 +97,10 @@ export function catalogOfferings(provider) {*/export function providerCatalogListsModel(provider, modelId) {if (typeof modelId !== 'string' || modelId.trim() === '') return true;+ const id = modelId.trim();+ if (isConfiguredDefaultModel(id)) return true;if (!provider) return true;- return modelPinIsOffered(provider, modelId.trim());+ return modelPinIsOffered(provider, id);}/**diff --git a/server/lib/modelPinReconcile.test.js b/server/lib/modelPinReconcile.test.jsindex c9a7ae75b3..6ec0f2b2b4 100644--- a/server/lib/modelPinReconcile.test.js+++ b/server/lib/modelPinReconcile.test.js@@ -42,6 +42,13 @@ describe('providerCatalogListsModel', () => {expect(providerCatalogListsModel(opencode, 'qwen3:14b')).toBe(false);});+ it('confines the namespace tolerance to OpenCode providers', () => {+ // The bare-id reduction must not match a slash-bearing pin against another+ // vendor's bare catalog: the same rule now gates SPAWNS, not just this+ // audit, so an over-permissive answer hands a CLI a model it cannot serve.+ expect(providerCatalogListsModel(CODEX, 'openrouter/gpt-5')).toBe(false);+ });+it('never reports a LOCAL-daemon pin as retired, even when the record omits it', () => {// A local-backed provider's `models` is a stale cached snapshot while the// daemon is the authority, so judging a pin against the record would report