fix(discovery): merge all three VS Code scopes, and let $IRIS_NAMESPACE outrank the editor - #191
Merged
Merged
Conversation
…CE outrank the editor (#187) 0.17.0 moved the VS Code reader ahead of the blind scans, and it still could not read the shape people actually have. GENAI-Course supplied the real file and it is split across THREE scopes, not one: Alumno/Alumno.code-workspace intersystems.servers: { "workshop-iris": {...} } Alumno/Ejercicios/Hospital/.vscode/ objectscript.conn: { server: "workshop-iris", settings.json ns: "HOSPITAL" } Each file alone resolves to NotConfigured. A reader that checks paths one at a time therefore finds nothing however many paths it checks — which is why this merges the scopes before resolving once, narrower winning as VS Code itself resolves a setting: user dirs::config_dir()/{Code, Code - Insiders, VSCodium}/User/settings.json workspace nearest *.code-workspace at or above the cwd (its `settings` block) folder ./.vscode/settings.json The walk-up mirrors what workspace_config already does for .iris-agentic-dev.toml. $IRIS_NAMESPACE NOW OVERRIDES THE ns FROM SETTINGS, and this is the part that matters most. Reading the .code-workspace resolves the connection WITH the editor's namespace, which would have handed the model a working default and silently deleted the IRIS_NAMESPACE=DONOTUSE guardrail — a read-only namespace pinned on purpose so a write that forgets to name its namespace fails at once instead of landing somewhere real. GENAI-Course measures 95% of namespace-omitted calls failing loudly today; that is the intended behaviour, not noise. Operator scope is the wider promise, so it wins over editor scope, exactly as $IRIS_PASSWORD supplies what the editor will not. Evidence, each at its own confidence: - 25 unit tests (12 new) — the three-scope overlay, workspace-wins-per-key, user entries surviving, a workspace opt-out user scope cannot undo, the .code-workspace `settings` nesting parsed off the real workshop file, and the namespace override. - .code-workspace reading proven AT THE WIRE: from the Hospital folder the binary walks up two levels and reaches http://198.51.100.7:59999/irishealth/... — a host, port and pathPrefix that exist only in that file. Removing it falls back to the scans and compiles. A Web Gateway on port 80 with a path prefix is not something a scan of 52773 could ever have found. - namespace override proven at the wire ON THE MCP PATH, which is the one that uses conn.namespace: with the .code-workspace present, no IRIS_NAMESPACE -> namespace=APP (the editor's), IRIS_NAMESPACE=USER -> namespace=USER. Control with the file removed: APP never appears. My first attempt to prove the override went through the CLI `compile` and was a FALSE POSITIVE: it printed /v1/DONOTUSE/ from clap's #[arg(env = "IRIS_NAMESPACE")], not from this code, and that subcommand never consults the discovered connection at all. Hence the MCP-driven test above. Still open in #187: no OS-keychain reader, and unlikely to gain one — VS Code keeps secrets in an encrypted store rather than as per-server items an outside process can read. For the workshop it is moot: their .code-workspace carries the password already. Version 0.18.0 — behaviour change, see the header of discovery.rs. Refs #187 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.
0.17.0 moved the VS Code reader ahead of the blind scans — and it still could not read the shape people actually have. GENAI-Course supplied the real workshop file, and it is split across three scopes:
Each file alone resolves to
NotConfigured. A reader that checks paths one at a time finds nothing however many paths it checks — which is the trap this shape sets, and why the fix merges the scopes and resolves once, narrower winning as VS Code itself resolves a setting:dirs::config_dir()/{Code, Code - Insiders, VSCodium}/User/settings.json*.code-workspaceat or above the cwd — itssettingsblock./.vscode/settings.jsonThe walk-up mirrors what
workspace_configalready does for.iris-agentic-dev.toml.$IRIS_NAMESPACEnow outranks the editor'snsThis is the part that matters most, and it came from GENAI-Course pushing back rather than from me.
Reading the
.code-workspaceresolves the connection with the editor's namespace — which would have handed the model a working default and silently deleted theIRIS_NAMESPACE=DONOTUSEguardrail. That default points at a read-only namespace on purpose, so a write that forgets to name its namespace fails at once instead of landing somewhere real. They measure 95% of namespace-omitted calls failing loudly today; that is the intended behaviour, not noise.So operator scope beats editor scope, exactly as
$IRIS_PASSWORDsupplies what the editor will not. Shipping the scope merge without this would have made their most valuable failure mode disappear.Evidence
25 unit tests, 12 new — three-scope overlay, workspace-wins-per-key, user entries surviving, a workspace
"active": falsethat user scope cannot undo, the.code-workspacesettingsnesting parsed off the real workshop file, and the namespace override..code-workspacereading, at the wire. From the Hospital folder the binary walks up two levels and reacheshttp://198.51.100.7:59999/irishealth/…— host, port andpathPrefixthat exist only in that file. Remove the file and it falls back to the scans and compiles. A Web Gateway on port 80 behind a path prefix is not something a scan of 52773 could ever have found.Namespace override, at the wire, on the MCP path — the one that actually uses
conn.namespace:.code-workspaceIRIS_NAMESPACEAPP(editor's ns)USERIRIS_NAMESPACE=USERUSER(override wins)USERAPPappears only when resolution succeeds and no operator override — so both effects are caused, not coincidental.One test of mine was a false positive, and it is worth recording. My first attempt to prove the override went through the CLI
compileand printed/v1/DONOTUSE/, which looked like confirmation. It came from clap's#[arg(env = "IRIS_NAMESPACE")], not from this code — that subcommand never consults the discovered connection at all. Hence the MCP-driven test above.Scope
Version 0.18.0 — behaviour change, documented at the top of
discovery.rs. Gate run as one command: fmt,clippy -D warnings, full workspace → 47 suites green.Issue 187 stays open for the OS-keychain reader, which is unlikely ever to land: VS Code keeps secrets in an encrypted store, not as per-server items an outside process can read. For this workshop it is moot — their
.code-workspacealready carries the password.🤖 Generated with Claude Code