fix(check_config): report the source a connection actually came from - #193
Merged
Merged
Conversation
…192) check_config could not tell an explicitly pinned connection from a blind port scan. Both reported connection_source: auto_discovered and BOTH carried the fallback warning telling the operator to pin an instance that was already pinned. Measured, same binary and same instance, before: IRIS_HOST=localhost IRIS_WEB_PORT=43080 ... -> auto_discovered + warning no IRIS_* at all -> auto_discovered + warning byte-identical on both fields. After: IRIS_HOST=localhost IRIS_WEB_PORT=43080 ... -> explicit_flag + no warning no IRIS_* at all -> auto_discovered + warning CAUSE. ConnectionSource was chosen by config_path.is_some() alone, so everything without a .iris-agentic-dev.toml became AutoDiscovered, and ConnectionSource::EnvVars was assigned in exactly ONE place — new_disconnected — meaning no live connection could ever report it. The answer was not missing: discovery.rs stamps DiscoverySource on the connection. It was discarded at the mapping. ConnectionSource::for_connection now asks the connection, with a config file still winning as the narrowest statement of intent. WHY IT MATTERED. The #21 fallback warning exists to flag the one genuinely dangerous state: a blind scan can silently land on the wrong instance. Firing it on every env-registered setup — which is every workshop VM and every ~/.claude.json with an env block — buried the case it was built for. 0.18.0 widened it: a VS Code-resolved connection is explicit configuration too and got the same treatment. is_explicit() replaces a hand-written variant list at the call site, so the report and the predicate cannot drift apart again. Same shape as #169's write gate: one function, not two lists. The tool description documented "connection_source (http|docker|disconnected)" — three values the code cannot emit. It now names the real set and states the rule that carries the meaning: only auto_discovered is a GUESS, and it alone gets the warning. Hint text is model-facing contract, so a wrong value set there is the same defect as a wrong label. A LABEL I PREDICTED WRONG, chased rather than shipped. I expected env_vars for an env-pinned server and got explicit_flag: mcp.rs builds the connection from self.host, which clap fills from --host OR $IRIS_HOST, so the two are one value before the stamp and discovery's env-var step is effectively dead on the MCP path. is_explicit is correct either way, so the defect is fixed — but ExplicitFlag now documents that it covers the env var too, rather than letting the name imply otherwise. Deliberately NOT plumbing clap value_source() to separate them: more precise, not what this issue is about. Renamed my own test env_vars_is_reachable_for_a_live_connection -> env_var_discovery_maps_to_env_vars. The old name was true but would have been read as a stronger claim than it supports: it proves the mapping, not that the server emits it. Version 0.19.0 — connection_source's value set is consumer-facing contract. Refs #192 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
check_configcould not tell an explicitly pinned connection from a blind port scan. Both reportedconnection_source: auto_discoveredand both carried the fallback warning telling the operator to pin an instance that was already pinned.Same binary, same instance, same probe script:
IRIS_HOST=localhost IRIS_WEB_PORT=43080 …auto_discovered+ warningexplicit_flag, no warningIRIS_*at allauto_discovered+ warningauto_discovered+ warningCause
ConnectionSourcewas chosen byconfig_path.is_some()alone, so everything without a.iris-agentic-dev.tomlbecameAutoDiscovered— andConnectionSource::EnvVarswas assigned in exactly one place,new_disconnected, meaning no live connection could ever report it.The answer was never missing.
discovery.rsstampsDiscoverySourceon the connection; the mapping discarded it.ConnectionSource::for_connectionnow asks the connection, with a config file still winning as the narrowest statement of intent.Why it mattered
The #21 fallback warning exists to flag the one genuinely dangerous state — a blind scan can silently land on the wrong instance. Firing it on every env-registered setup (every workshop VM, every
~/.claude.jsonwith an env block) buried the case it was built for. 0.18.0 widened it: a VS Code-resolved connection is explicit configuration too and got the same treatment.is_explicit()replaces a hand-written variant list at the call site, so the reported value and the predicate cannot drift apart again — the #169 shape, one function rather than two lists.Tool description
It documented
connection_source (http|docker|disconnected)— three values the code cannot emit. It now names the real set and states the rule that carries the meaning: onlyauto_discoveredis a guess, and it alone gets the warning. Hint text is model-facing contract, so a wrong value set there is the same defect as a wrong label.A label I predicted wrong
I expected
env_varsfor an env-pinned server and gotexplicit_flag.mcp.rs:86builds the connection fromself.host, which clap fills from--hostor$IRIS_HOST— one value by the time it is stamped, so discovery's env-var step is effectively dead on the MCP path.is_explicitis correct either way, so the defect is fixed. But rather than ship a name that implies "flag, not env",ExplicitFlagnow documents that it covers both. Deliberately not plumbing clap'svalue_source()to separate them: more precise, not what this issue is about, and it touches the bin crate's arg handling.I also renamed my own test
env_vars_is_reachable_for_a_live_connection→env_var_discovery_maps_to_env_vars. The old name was true but would have been read as a stronger claim than it supports — it proves the mapping, not that the server emits it.Scope
Version 0.19.0 —
connection_source's value set is consumer-facing contract. 5 new unit tests; lib suite 595 → 600. Gate as one command: fmt,clippy -D warnings, full workspace → 47 suites green.Issue 192 is addressed by this change.
🤖 Generated with Claude Code