# Provider descriptor + Pass Readiness — provider facts as data, one credential resolution > **Date:** 2026-11-10 > **Type:** issue > **Reference:** https://git.babylondreams.de/AlexKucera/museion/issues/181 ## Goal Issue #181 (from the 2026-11-09 architecture review, settings cluster): per-provider facts become **data on the provider enum** instead of five switches across Settings, the probe, and the pane; **one credential-resolution function** (provider key, else the shared Portal session key for keyless providers) serves Test Connection and pass readiness; **pass readiness leaves the session model** into its own module; the probe's **dialect selector keys off the descriptor** (SSE decoders stay separate functions); rider: **runPass and blindRead share one guard helper**. Red line (ADR-0014): provider metadata only — no app-side model-settings store. Blocked by #178 (closed — verified before work started). ## What Was Done - `ModelProvider` is now the provider-descriptor table: existing facts (label, effort ladder, flagship, default endpoint, env var) joined by `dialect` (`Dialect` enum: chat/models paths + the SSE decoder selector), `authMode` (`AuthMode`: Bearer vs Anthropic's `x-api-key` + pinned version), `keyless` (nous rides the Portal login), and `trimmedEndpoint(_:)` — the ONE trailing-slash normalization shared by the probe's URL builders and the credential gate. - `ProviderCredential.resolve` (SettingsModel.swift) — the ONE credential rail: pasted key wins; keyless providers fall back to the Portal session key **only on the official default endpoint**; refusals name the paste-a-key path or `hermes auth add nous`. Settings' `testConnection` and pass readiness both call it (the twice-implemented #175 fallback is now one function). - `Museion/PassReadiness.swift` (new) — the readiness module: reads each pass surface's provider + `.env` key through the `SettingsWriting` seam, resolves credentials through `ProviderCredential`, answers `[PassKind: PassReadiness]`. `MentorSessionModel.refreshPassReadiness` is a thin delegate; the model reads no keys and no auth files. - `ProviderProbe` — `chatURL`/`modelsURL`/`applyAuth`/`decodeChat` select by `provider.dialect` / `provider.authMode`; the per-dialect request bodies and stream decoders stay separate functions. - `PostsModelPasses.guardOpenPieceRun` — the ONE guard rail behind `runPass` and `blindRead` (nothing running, mentor not mid-turn, engine ready, open saved piece); returns `(id, session)`; refusal strings byte-identical to the old per-runner messages except the busy message now names the actual blocker. - `ProviderCredentialTests` (new, 5 pins) — the shared credential suite; `ScriptedEngine.hasHeldPrompt` + a poll in the #179 repoint pin de-flake the spawn-window race; PassRunTests' open-piece pin tightened to the exact interpolated message. - DOX pass: `Museion/AGENTS.md` (Settings bullet rewritten as the descriptor table + credential rail + PassReadiness file; PostsModel runPass chain + MentorSessionModel readiness bullets updated), `MuseionTests/AGENTS.md` (suite map + the hasHeldPrompt note). ## Decisions & Rationale | Decision | Rationale | |----------|-----------| | Readiness gained the official-endpoint gate (behavior delta) | The unified rail carries the #175 exfiltration posture: a nous pass profile on a user-set `base_url` with no pasted key now reads `.missingKey` (was `.ready` — the old session-model fallback had NO endpoint gate). Both finish-audit reviewers rate this the correct tightening; the remedy (paste a key) is consistent. | | missingKey guard moved AFTER the shared open-piece rail | The rail owns the common grammar; the kind-specific readiness check stays caller-side. "No piece open + no key" now shows "Open a saved post" (was the key message). The load-bearing invariant — key guard before anything touches disk — holds; no test pinned the old order. Flagged to the maintainer. | | z.ai branches stay provider-keyed | Key-type UI toggle, endpoint families, thinking knobs, and the 1113 error decode are zai-specific config, not provider metadata; the ticket blesses "genuinely different code, not switch clothing". | | `refreshPassReadiness` stays as a thin delegate | Museion/AGENTS.md pins the model as the pane's observable; the module computes, the model stores. | | `PassKind`-keyed refresh return, surfaces baked in | One caller, constant `[.pass1, .pass2]` — the parameter was a dead degree of freedom (finish-audit ponytail trim). | | De-flaked the #179 repoint pin instead of re-running | `runningPass` flips before the one-shot engine parks its prompt; `endHeldPrompt()` fired into that window false-fails under parallel-suite load — the #30/#147 green-by-luck family. Fix the test's timing assumption, not the schedule. | ## Gotchas & Fixes | Problem | Root Cause | Fix | |---------|------------|-----| | Full-suite run 1: `home repoint mid-pass refuses the advance` failed (`endHeldPrompt()` → false) | The pin polled `runningPass`, which flips BEFORE the one-shot engine spawns and parks its prompt — the poll passed, the park hadn't happened; parallel-suite load widened the window | Added `ScriptedEngine.hasHeldPrompt`; the pin now polls for the PARK, then requires the release (`#require` still fails loudly on a genuine timeout) | | `-only-testing:MuseionTests/` filters silently matched subsets (12 of 71 expected tests) | Several suites are free functions / differently-named structs — the known #31 trap; verified against per-file `@Test` counts | Ran the whole MuseionTests suite and verified by the xcresult EXECUTED count (668), never the SUCCEEDED banner | | A patch intended as `provider.keyless` mangled a newline in SettingsPagesView instead | old_string/new_string differed only by trailing newline | Re-read the region, restored the newline, applied the real change | | detect-changes listed serif-writing files this session never touched | Index-staleness relative to a pre-#180 index state; `git status` showed them unmodified | Trusted `git status` as the commit's file list; analyze rebuilt the index | ## Files Changed | File | Change Summary | |------|---------------| | `Museion/SettingsModel.swift` | Descriptor additions (dialect, authMode, keyless, trimmedEndpoint), `ProviderCredential`, `testConnection` through the rail | | `Museion/PassReadiness.swift` | NEW — the readiness module over the descriptor + credential rail | | `Museion/MentorSessionModel.swift` | Nested `PassReadiness` + refresh body removed; thin delegate remains (−~65 lines) | | `Museion/ProviderProbe.swift` | URL/auth/SSE selectors key off the descriptor | | `Museion/PostsModelPasses.swift` | `guardOpenPieceRun` shared rail; both runners rewritten onto it | | `Museion/SettingsPagesView.swift` | Keyless branch keys off `provider.keyless` | | `MuseionTests/ProviderCredentialTests.swift` | NEW — the shared credential suite (5 pins) | | `MuseionTests/ScriptedEngine.swift` | `hasHeldPrompt` park observable | | `MuseionTests/PostsModelTests.swift` | Repoint pin polls the park first | | `MuseionTests/PassRunTests.swift` | Open-piece pin tightened to the exact message | | `Museion/AGENTS.md`, `MuseionTests/AGENTS.md`, `AGENTS.md` | DOX pass (+ gitnexus stats bump) | ## Open Items & Next Steps - [x] All six acceptance criteria met; full suite green - [ ] Deferred (audit): cross-repo coupling — `defaultEndpoint` assumes hermes' unset-`base_url` default matches the app's constant (comment names it; revisit only if the portal URL moves) - [ ] Deferred (audit): `auth.json` read once per surface (twice when both passes ride nous) — local JSON, off-main, pane-entry only; cache when it ever shows - [ ] #182 ProfileLayout + config-set rail is the next ticket in the architecture batch --- *Log written by write-log skill*