Repository navigation
test(desktop): qualify the supervisor against a real isolated Core #6727
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
loopx-agent
merged 3 commits into
main
from
codex/desktop-startup-qualification-20261017
Oct 17, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
6507f1b
test(desktop): qualify supervisor against an isolated installed Core
loopx-agent a1303b8
test(desktop): require telemetry opt-out for synthetic Core qualifica…
loopx-agent 4864b67
Merge branch 'main' into codex/desktop-startup-qualification-20261017
loopx-agent File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
127 changes: 127 additions & 0 deletions
127
apps/desktop/loopx-control-plane/src-tauri/src/services_real_runtime_tests.rs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| //! Opt-in production supervisor + installed Core. Never use an active registry. | ||
| use super::*; | ||
| use std::os::unix::fs::PermissionsExt; | ||
|
|
||
| fn response_body(port: u16, path: &str) -> String { | ||
| let mut stream = TcpStream::connect(("127.0.0.1", port)).unwrap(); | ||
| stream | ||
| .set_read_timeout(Some(Duration::from_secs(5))) | ||
| .unwrap(); | ||
| write!( | ||
| stream, | ||
| "GET {path} HTTP/1.1\r\nHost: 127.0.0.1:{port}\r\nConnection: close\r\n\r\n" | ||
| ) | ||
| .unwrap(); | ||
| let mut raw = String::new(); | ||
| stream | ||
| .take(MAX_PROBE_RESPONSE_BYTES + 1) | ||
| .read_to_string(&mut raw) | ||
| .unwrap(); | ||
| assert!(raw.len() as u64 <= MAX_PROBE_RESPONSE_BYTES); | ||
| let (headers, body) = raw.split_once("\r\n\r\n").unwrap(); | ||
| assert!(headers.starts_with("HTTP/1.0 200 ") || headers.starts_with("HTTP/1.1 200 ")); | ||
| body.to_owned() | ||
| } | ||
|
|
||
| fn assert_stopped(endpoints: ServiceEndpoints) { | ||
| for kind in SERVICE_KINDS { | ||
| assert_eq!( | ||
| probe_on_port(kind, endpoints.port(kind), None), | ||
| Probe::Unavailable | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| #[test] | ||
| #[ignore = "requires a disposable Core install and empty isolated registry; see Desktop README"] | ||
| fn real_private_runtime_serves_and_rejects_stale_identity() { | ||
| assert_eq!( | ||
| env::var("LOOPX_USAGE_PING").as_deref(), | ||
| Ok("0"), | ||
| "synthetic Core qualification requires LOOPX_USAGE_PING=0" | ||
| ); | ||
| let root = PathBuf::from(env::var("LOOPX_TEST_PRIVATE_RUNTIME").unwrap()); | ||
| // A caller's empty registry can still share a runtime with bound private | ||
| // conversations. Own a fresh data root rather than trusting that shortcut. | ||
| let data = tempfile::tempdir().unwrap(); | ||
| let state = fs::canonicalize(data.path()).unwrap(); | ||
| let registry = state.join("registry.global.json"); | ||
| fs::write(®istry, b"{\"goals\":[]}").unwrap(); | ||
| let executable = fs::canonicalize(root.join("bin/loopx")).unwrap(); | ||
| let identity = runtime_identity_for_executable(executable.to_str().unwrap()).unwrap(); | ||
|
|
||
| // The production service commands use --global-registry. An explicit local | ||
| // launch pin supplies their real CLI route, not a second identity/provider. | ||
| // Use shell quoting for paths, including spaces, quotes and dollar signs. | ||
| let quoted = |path: &Path| format!("'{}'", path.to_str().unwrap().replace('\'', "'\"'\"'")); | ||
| let wrapper = tempfile::tempdir().unwrap(); | ||
| let pin = wrapper.path().join("isolated-core"); | ||
| fs::write( | ||
| &pin, | ||
| format!( | ||
| "#!/bin/sh\nexec {} --registry {} --runtime-root {} \"$@\"\n", | ||
| quoted(&executable), | ||
| quoted(®istry), | ||
| quoted(&state) | ||
| ), | ||
| ) | ||
| .unwrap(); | ||
| fs::set_permissions(&pin, fs::Permissions::from_mode(0o700)).unwrap(); | ||
| let runtime = SelectedRuntime { | ||
| executable: pin.to_string_lossy().into_owned(), | ||
| identity: Some(identity.clone()), | ||
| }; | ||
| let mut origins = Vec::new(); | ||
| for _ in 0..2 { | ||
| let endpoints = ServiceEndpoints::allocate(true).unwrap(); | ||
| let mut services = ServiceSet::start(&runtime, &endpoints, |_| {}).unwrap(); | ||
| for kind in SERVICE_KINDS { | ||
| assert_eq!( | ||
| probe_on_port(kind, endpoints.port(kind), Some(&identity)), | ||
| Probe::Matching | ||
| ); | ||
| } | ||
| let status: serde_json::Value = serde_json::from_str(&response_body( | ||
| endpoints.port(ServiceKind::Status), | ||
| "/status.json", | ||
| )) | ||
| .unwrap(); | ||
| assert_eq!(status["goal_count"], 0); | ||
| assert_eq!( | ||
| status["registry"].as_str(), | ||
| registry.to_str(), | ||
| "the real backend must use only this disposable registry" | ||
| ); | ||
| let sessions: serde_json::Value = serde_json::from_str(&response_body( | ||
| endpoints.port(ServiceKind::Chat), | ||
| "/api/chat/sessions", | ||
| )) | ||
| .unwrap(); | ||
| assert!(sessions["sessions"].as_array().is_some_and(Vec::is_empty)); | ||
| assert!(response_body(endpoints.port(ServiceKind::Chat), "/chat/") | ||
| .to_ascii_lowercase() | ||
| .contains("<!doctype html>")); | ||
| origins.push(endpoints.workspace_origin()); | ||
| services.stop(); | ||
| assert_stopped(endpoints); | ||
| } | ||
|
|
||
| // The production owner must reject an actual backend from the wrong frozen | ||
| // artifact and clean up both children, including a successful peer start. | ||
| let mut mismatched = identity.clone(); | ||
| mismatched["source_revision"] = serde_json::json!("0000000000000000000000000000000000000000"); | ||
| let invalid = SelectedRuntime { | ||
| executable: runtime.executable.clone(), | ||
| identity: Some(mismatched), | ||
| }; | ||
| let endpoints = ServiceEndpoints::allocate(true).unwrap(); | ||
| let error = ServiceSet::start(&invalid, &endpoints, |_| {}) | ||
| .err() | ||
| .expect("a stale artifact must fail readiness"); | ||
| assert!(error.to_string().contains("unexpected listener")); | ||
| assert_stopped(endpoints); | ||
| println!( | ||
| "{}", | ||
| serde_json::json!({"private_service_reopens":origins.len(), "workspace_origins":origins, "runtime_identity":identity, "goals":0, "sessions":0, "stale_identity_rejected":true, "owned_children_stopped":true}) | ||
| ); | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.