Repository navigation
Description
Problem
A fresh Herdr-launched jcode pane that explicitly requests a provider could silently attach to an already-running daemon serving a different provider. The running daemon's identity won unconditionally, so the explicit --provider flag was discarded and the TUI header showed the wrong provider — long after the flags were gone.
Concrete failure mode: a daemon launched with --provider auto resolves to cursor/GPT-5. A later pane launched with --provider openai-compatible --model MiniMax-M3.1-Flash attaches to that daemon and is served by Cursor instead.
Root cause
There was no source-level concept of a daemon's runtime provider identity. The client had nothing canonical to compare against, so "the daemon exists" was treated as "the daemon serves what I asked for".
Fix
Introduce an explicit, canonical provider-identity contract:
- The daemon publishes the identity it actually resolved to (never the flag it was launched with) into a sidecar file beside its socket.
- The client derives the same canonical runtime key from its
--providervalue by going throughlogin_provider_for_choice— the same target the daemon uses to build its provider — so both sides agree by construction rather than by string luck. - The two vocabularies genuinely diverge (
ProviderChoice::ClaudeApiKeyspellsanthropic-apiwhile the runtime key isclaude-api;ProviderChoice::Azurespellsazurewhile the runtime key isazure-openai), which is why the derivation goes through the shared mapping instead of comparing raw CLI spellings.
Decision matrix
| Client request | Daemon publishes | Result |
|---|---|---|
openai-compatible |
openai-compatible |
attach to shared daemon |
openai-compatible |
cursor |
isolate onto a private daemon |
openai-compatible |
auto |
isolate (cannot prove agreement) |
openai-compatible |
(nothing / older daemon) | isolate (cannot prove agreement) |
auto |
anything | attach (nothing was claimed) |
| model mismatch | same provider | attach, advisory note only |
The model is deliberately advisory: a mismatch is surfaced as a note but never causes isolation, because we have not established that the daemon always honors --model over its profile default, and isolating on an unverified axis would spawn a private daemon on every launch.
Implementation
src/cli/daemon_identity.rs— new module:canonical_provider_key,attach_plan,model_advisory,running_daemon_identity,private_client_socket.crates/jcode-app-core/src/server.rs—publish_socket_identitywrites the resolved identity beside the socket.crates/jcode-app-core/src/server/socket.rs—read_socket_identity/write_socket_identity/identity_file_for_socket.
Known limitation
ProviderChoice carries ~40 vendor spellings (lmstudio, chutes, cerebras, meta-muse, ...) that all resolve to the single runtime key openrouter. A client asking for one vendor and a daemon serving another therefore compare equal. This is an accepted imprecision at runtime-key granularity, not an oversight. Publishing the resolved vendor name is the follow-up that would close it.
Acceptance
- Matching provider identities attach to the shared daemon.
- Provider mismatch isolates onto a private daemon.
-
autoon either side isolates (never a false match). - Unknown daemon identity isolates.
- Model mismatch is advisory and does not isolate.
- Unit tests cover all five decision branches plus the pinned canonical key mapping.
Activity
fix(cli): make provider isolation actually bind a private daemon
fix(server): create the shared socket's parent at the bind site
fix(cli): clear the clippy lints the CI gate caught
docs(acceptance): record the provider-identity acceptance matrix
docs(acceptance): record that the app-core test deadlock is pre-existing
fix(server): take the shared environment lock in the socket identity …
docs(acceptance): re-record the matrix against the final binary
fix(cli): restore the Windows build after the module split
fix(cli): make provider isolation actually bind a private daemon
fix(server): create the shared socket's parent at the bind site
fix(cli): clear the clippy lints the CI gate caught
docs(acceptance): record the provider-identity acceptance matrix
docs(acceptance): record that the app-core test deadlock is pre-existing
fix(server): take the shared environment lock in the socket identity …
docs(acceptance): re-record the matrix against the final binary
fix(cli): restore the Windows build after the module split
fix(ci): refresh the size baselines that master outgrew