Plan, apply and roll back changes to a production ontology, with a blast radius report and a proof an auditor can re-check.
Rust ai-nativedescription-logicsformal-verificationinfrastructure-as-codeisabelle-languageknowledge-graphleanlean4mcpmcp-serverontologyowlowl2reasoningrustshaclsparqltheorem-proving
fix(studio): cover the real mcp endpoint call site and note port-default sync
FABIOTESS23db08b60be6
diff --git a/studio/src-tauri/sidecars/agent/index.ts b/studio/src-tauri/sidecars/agent/index.tsindex 9a00e3cd..1535ac65 100644--- a/studio/src-tauri/sidecars/agent/index.ts+++ b/studio/src-tauri/sidecars/agent/index.ts@@ -3,6 +3,11 @@ import { tokeniseInbound } from './tokenise.js';import type { Query } from '@anthropic-ai/claude-agent-sdk';import * as readline from 'readline';+// Kept in sync by hand with the matching DEFAULT_ENGINE_PORT constant in+// src/engine.rs. That Rust constant is the actual source of truth: it always+// sets OPEN_ONTOLOGIES_STUDIO_PORT before spawning this sidecar, so this+// fallback only matters when the sidecar runs standalone outside that host,+// and the two constants only need to agree in source, not at runtime.const DEFAULT_ENGINE_PORT = 8137;// Set by chat::spawn_agent_sidecar in the Rust host, which is the singlediff --git a/studio/src-tauri/src/engine.rs b/studio/src-tauri/src/engine.rsindex a4c40ef6..ea1a2e4f 100644--- a/studio/src-tauri/src/engine.rs+++ b/studio/src-tauri/src/engine.rs@@ -118,6 +118,11 @@ fn clear_stale_port(port: u16) {}}+// Kept in sync by hand with the matching DEFAULT_ENGINE_PORT constant in+// sidecars/agent/index.ts. That copy is a fallback for running the sidecar+// standalone; in the normal path this Rust value always wins because+// spawn_agent_sidecar sets OPEN_ONTOLOGIES_STUDIO_PORT before the sidecar+// ever reads it, so the two never need to agree at runtime, only in source.const DEFAULT_ENGINE_PORT: u16 = 8137;fn parse_port(raw: Option<&str>) -> u16 {diff --git a/studio/src-tauri/src/mcp.rs b/studio/src-tauri/src/mcp.rsindex c947f4b4..69d4357d 100644--- a/studio/src-tauri/src/mcp.rs+++ b/studio/src-tauri/src/mcp.rs@@ -159,4 +159,40 @@ mod tests {// changed away from 8080, but this call site kept the old literal.assert_ne!(mcp_endpoint(8137), "http://127.0.0.1:8080/mcp");}++ // Rust runs unit tests in parallel threads within one process, so a test+ // that mutates a process environment variable races every other test+ // that reads or writes the environment concurrently (std::env::set_var+ // and remove_var are `unsafe` for exactly this reason). This lock+ // serializes the one test below that needs to do it, so it never+ // overlaps another env mutation in this crate.+ static ENV_LOCK: Mutex<()> = Mutex::new(());++ #[test]+ fn mcp_call_site_builds_its_url_from_the_configured_port_resolver() {+ const VAR: &str = "OPEN_ONTOLOGIES_STUDIO_PORT";+ const DISTINCTIVE_PORT: &str = "48213";++ let _guard = ENV_LOCK.lock().unwrap_or_else(|poisoned| poisoned.into_inner());+ let previous = std::env::var(VAR).ok();++ // SAFETY: ENV_LOCK above guarantees no other test in this process is+ // reading or writing the environment while this section runs.+ unsafe {+ std::env::set_var(VAR, DISTINCTIVE_PORT);+ }+ let endpoint = mcp_endpoint(engine::engine_port());+ unsafe {+ match &previous {+ Some(value) => std::env::set_var(VAR, value),+ None => std::env::remove_var(VAR),+ }+ }++ // This exercises the actual call site in do_mcp_call+ // (`.post(mcp_endpoint(engine::engine_port()))`), not just the pure+ // helper: it proves the URL is built from the real port resolver, so+ // re-inlining a literal at that call site would fail this test.+ assert_eq!(endpoint, "http://127.0.0.1:48213/mcp");+ }}