From 81d73905488d63ebe3790c3c29bd34b5e0b5d896 Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Thu, 22 Oct 2026 01:21:20 +0000 Subject: [PATCH 01/70] test(browser_egress): assert denied navigation never dials the allowed socket The live Chromium egress test now keeps the fixture listener open after the first response and counts any further connections, so a policy-denied navigation that still reaches the previously allowed socket is caught instead of passing silently. The fixture also serves a minimal HTML document and signals via a oneshot channel once its response is written, letting the test wait on the actual request rather than on the server task finishing. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- .../browser_egress_live_tests.rs | 37 ++++++++++++++++--- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs index 66c41916f..1036d4cf2 100644 --- a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs +++ b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs @@ -3,7 +3,7 @@ use std::sync::{ Arc, Mutex, - atomic::{AtomicBool, Ordering}, + atomic::{AtomicBool, AtomicUsize, Ordering}, }; use std::time::Duration; @@ -85,7 +85,12 @@ impl EgressHost { } } -async fn serve_fixture(listener: tokio::net::TcpListener, expected: &'static [u8]) { +async fn serve_fixture( + listener: tokio::net::TcpListener, + expected: &'static [u8], + extra_connections: Arc, + served: tokio::sync::oneshot::Sender<()>, +) { let (mut stream, _) = listener .accept() .await @@ -101,6 +106,11 @@ async fn serve_fixture(listener: tokio::net::TcpListener, expected: &'static [u8 ] .concat(); let _ = tokio::io::AsyncWriteExt::write_all(&mut stream, &response).await; + let _ = served.send(()); + while let Ok((stream, _)) = listener.accept().await { + extra_connections.fetch_add(1, Ordering::SeqCst); + drop(stream); + } } fn successful_data(reply: &DesktopResponse) -> &serde_json::Value { @@ -115,7 +125,14 @@ async fn live_chromium_module_dials_only_the_host_returned_socket_and_rejects_ch let port = allowed_listener.local_addr()?.port(); let denied_listener = tokio::net::TcpListener::bind(("127.0.0.2", port)).await?; let allowed_address = allowed_listener.local_addr()?.to_string(); - let allowed_server = tokio::spawn(serve_fixture(allowed_listener, b"allowed fixture")); + let extra_allowed_connections = Arc::new(AtomicUsize::new(0)); + let (served_tx, served_rx) = tokio::sync::oneshot::channel(); + let allowed_server = tokio::spawn(serve_fixture( + allowed_listener, + b"allowed fixture", + extra_allowed_connections.clone(), + served_tx, + )); let bus = MemoryBus::new(); let broker = Broker::new(); @@ -170,10 +187,10 @@ async fn live_chromium_module_dials_only_the_host_returned_socket_and_rejects_ch "authorized navigation failed: {:?}", navigated.error ); - tokio::time::timeout(Duration::from_secs(10), allowed_server) + tokio::time::timeout(Duration::from_secs(10), served_rx) .await - .expect("authorized fixture server completes within ten seconds") - .expect("fixture server task completes"); + .expect("authorized Chromium request reaches the fixture within ten seconds") + .expect("authorized fixture reports its response"); let authorizations_before_policy_change = observations .lock() @@ -181,6 +198,8 @@ async fn live_chromium_module_dials_only_the_host_returned_socket_and_rejects_ch .iter() .filter(|call| call.starts_with("authorize:fixture-policy:41:fixture.test:")) .count(); + let extra_connections_before_policy_change = + extra_allowed_connections.load(Ordering::SeqCst); // Simulate a policy refresh: the host changes from granting the fixture // socket to denying requests for the same hostname. allowed.store(false, Ordering::SeqCst); @@ -201,6 +220,11 @@ async fn live_chromium_module_dials_only_the_host_returned_socket_and_rejects_ch .is_err(), "denied policy-change socket received a connection" ); + assert_eq!( + extra_allowed_connections.load(Ordering::SeqCst), + extra_connections_before_policy_change, + "policy-denied navigation connected to the previously allowed socket" + ); let calls = observations.lock().unwrap(); assert!( @@ -225,5 +249,6 @@ async fn live_chromium_module_dials_only_the_host_returned_socket_and_rejects_ch "denied socket was consumed: {calls:?}" ); broker_task.abort(); + allowed_server.abort(); Ok(()) } From 2201c9a4b3a920c40ac546fafa7419c58901065f Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Thu, 22 Oct 2026 01:21:27 +0000 Subject: [PATCH 02/70] test(browser_egress): reflow an over-wrapped assertion binding Collapse a two-line let binding back onto a single line so the live chromium egress test matches the surrounding formatting. No behaviour change. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- .../src/tinybus_module/browser_egress_live_tests.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs index 1036d4cf2..e466eebbe 100644 --- a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs +++ b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs @@ -198,8 +198,7 @@ async fn live_chromium_module_dials_only_the_host_returned_socket_and_rejects_ch .iter() .filter(|call| call.starts_with("authorize:fixture-policy:41:fixture.test:")) .count(); - let extra_connections_before_policy_change = - extra_allowed_connections.load(Ordering::SeqCst); + let extra_connections_before_policy_change = extra_allowed_connections.load(Ordering::SeqCst); // Simulate a policy refresh: the host changes from granting the fixture // socket to denying requests for the same hostname. allowed.store(false, Ordering::SeqCst); From 202694680a20a0fd0ce196e0064e033bd27a279c Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Thu, 22 Oct 2026 01:29:38 +0000 Subject: [PATCH 03/70] docs(test): qualify live browser egress test filter Co-authored-by: Medulla --- .env.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.example b/.env.example index a8d5318e0..ae778e276 100644 --- a/.env.example +++ b/.env.example @@ -120,4 +120,4 @@ TINYCOMPUTER_LAB_SELF_EMAIL= # TINYCOMPUTER_LIVE_BROWSER_TESTS=1 # Compile and run TinyComputer's module-path egress test against installed Chromium # using only local fixture listeners: -# TINYCOMPUTER_LIVE_BROWSER_EGRESS_TESTS=1 cargo test --manifest-path crates/tinycomputer/Cargo.toml -p tinycomputer --lib --features static-link live_chromium_module_dials_only_the_host_returned_socket_and_rejects_changed_policy -- --exact --nocapture +# TINYCOMPUTER_LIVE_BROWSER_EGRESS_TESTS=1 cargo test --manifest-path crates/tinycomputer/Cargo.toml -p tinycomputer --lib --features static-link tinybus_module::browser_egress_live_tests::live_chromium_module_dials_only_the_host_returned_socket_and_rejects_changed_policy -- --exact --nocapture From d1cc1839024550e0225dee6492b529e8d0d1e379 Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Thu, 22 Oct 2026 13:06:58 +0000 Subject: [PATCH 04/70] feat: relay host context to consequence reviews Co-authored-by: Medulla --- crates/tinycomputer-bus/README.md | 6 ++++ .../tinycomputer-bus/src/agent/agent_tests.rs | 22 +++++++++++++ crates/tinycomputer-bus/src/agent/mod.rs | 4 +-- .../tinycomputer-bus/src/agent/types/mod.rs | 2 +- .../src/agent/types/request.rs | 31 +++++++++++++++++++ .../consequence_host_tests.rs | 17 +++++++++- .../src/consequence_host/mod.rs | 6 ++++ crates/tinycomputer-bus/src/version/mod.rs | 4 +-- .../src/version/version_tests.rs | 7 +++-- .../consequence_gate_tests.rs | 14 +++++++-- .../tinybus_module/consequence_gate/mod.rs | 21 +++++++++++-- crates/tinycomputer/tests/public_api_tests.rs | 2 +- docs/crates/tinycomputer-bus/versioning.md | 14 +++++---- 13 files changed, 129 insertions(+), 21 deletions(-) diff --git a/crates/tinycomputer-bus/README.md b/crates/tinycomputer-bus/README.md index 88bf0d96f..f97a3cc78 100644 --- a/crates/tinycomputer-bus/README.md +++ b/crates/tinycomputer-bus/README.md @@ -190,3 +190,9 @@ distinguish causal re-entry from unrelated concurrent work. Event and artifact acknowledgements are bounded by the engine's operation deadline; report calls have a ten-second transport timeout. A host that does not opt in keeps the existing desktop file/session trace behavior. + +Contract 2.27 adds an opaque host context to `ContinueTask` and relays it +unchanged to `ConsequenceHost.Review`. TinyComputer does not interpret the +context or grant it authority; hosts can use it to recover trusted caller +context while reviewing an approval. Hosts that depend on this relay must +reject modules older than 2.27. diff --git a/crates/tinycomputer-bus/src/agent/agent_tests.rs b/crates/tinycomputer-bus/src/agent/agent_tests.rs index fe2e40e21..1bbbf83e4 100644 --- a/crates/tinycomputer-bus/src/agent/agent_tests.rs +++ b/crates/tinycomputer-bus/src/agent/agent_tests.rs @@ -281,18 +281,40 @@ fn waiting_and_continuing_have_forgiving_defaults() { assert_eq!(resume.id.to_string(), "t-1"); assert_eq!(resume.inputs["date of birth"], "1990-04-02"); assert_eq!(resume.approve, None); + assert_eq!(resume.host_context, None); + assert!( + serde_json::to_value(&resume) + .unwrap() + .get("host_context") + .is_none() + ); let private: ContinueTaskRequest = serde_json::from_value(json!({ "id": "t-2", + "host_context": "opaque-context", "fact_handles": { "email": {"handle": "opaque-email", "mask": "‹email›", "kind": "asked_input"} } })) .unwrap(); assert_eq!(private.fact_handles["email"].handle, "opaque-email"); + assert_eq!( + private + .host_context + .as_ref() + .map(super::HostContext::as_str), + Some("opaque-context") + ); let wire = serde_json::to_value(private).unwrap(); assert_eq!(wire["fact_handles"]["email"]["mask"], "‹email›"); assert_eq!(wire["inputs"], json!({})); + assert_eq!(wire["host_context"], "opaque-context"); +} + +#[test] +fn host_context_debug_output_hides_the_opaque_value() { + let context = super::HostContext::new("secret-capability"); + assert!(!format!("{context:?}").contains("secret-capability")); } #[test] diff --git a/crates/tinycomputer-bus/src/agent/mod.rs b/crates/tinycomputer-bus/src/agent/mod.rs index 30329d65e..ab8c2e5e2 100644 --- a/crates/tinycomputer-bus/src/agent/mod.rs +++ b/crates/tinycomputer-bus/src/agent/mod.rs @@ -52,8 +52,8 @@ mod types; pub use types::{ AgentError, AgentResponse, AwaitTaskRequest, Capabilities, ContinueTaskRequest, Example, - InputField, InputKind, LanguageModelConfiguration, LanguageModelProvider, MemberDoc, - ModelUsage, PaymentMode, PlanTaskRequest, Rescue, RescueOutcome, SecretHandle, + HostContext, InputField, InputKind, LanguageModelConfiguration, LanguageModelProvider, + MemberDoc, ModelUsage, PaymentMode, PlanTaskRequest, Rescue, RescueOutcome, SecretHandle, StartTaskRequest, StepView, SurfaceAvailability, SurfaceKind, TaskBudget, TaskConstraints, TaskId, TaskOutput, TaskPlan, TaskRef, TaskReport, TaskReportRequest, TaskStatus, TaskUsage, TaskView, diff --git a/crates/tinycomputer-bus/src/agent/types/mod.rs b/crates/tinycomputer-bus/src/agent/types/mod.rs index a3c8f70e3..bcb920f2d 100644 --- a/crates/tinycomputer-bus/src/agent/types/mod.rs +++ b/crates/tinycomputer-bus/src/agent/types/mod.rs @@ -13,7 +13,7 @@ pub use models::{LanguageModelConfiguration, LanguageModelProvider}; pub use reply::{AgentError, AgentResponse}; pub use report::{Rescue, RescueOutcome, TaskReport}; pub use request::{ - AwaitTaskRequest, ContinueTaskRequest, PaymentMode, PlanTaskRequest, SecretHandle, + AwaitTaskRequest, ContinueTaskRequest, HostContext, PaymentMode, PlanTaskRequest, SecretHandle, StartTaskRequest, SurfaceKind, TaskBudget, TaskConstraints, TaskId, TaskOutput, TaskPlan, TaskRef, TaskReportRequest, }; diff --git a/crates/tinycomputer-bus/src/agent/types/request.rs b/crates/tinycomputer-bus/src/agent/types/request.rs index 83cd9d4a8..d6e5850e8 100644 --- a/crates/tinycomputer-bus/src/agent/types/request.rs +++ b/crates/tinycomputer-bus/src/agent/types/request.rs @@ -120,6 +120,33 @@ impl std::fmt::Debug for SecretHandle { } } +/// Opaque, host-issued context carried from a task continuation to a +/// `ConsequenceHost` review. The module must relay it unchanged and never +/// treat it as authorization. Debug output deliberately hides the value. +#[derive(Clone, Default, PartialEq, Eq, Serialize, Deserialize)] +#[serde(transparent)] +pub struct HostContext(String); + +impl HostContext { + /// Wraps a host-issued opaque context value. + #[must_use] + pub fn new(value: impl Into) -> Self { + Self(value.into()) + } + + /// Returns the opaque value for host-side lookup. + #[must_use] + pub fn as_str(&self) -> &str { + &self.0 + } +} + +impl std::fmt::Debug for HostContext { + fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + formatter.write_str("HostContext([opaque])") + } +} + /// What a finished task returns, beyond its raw records. /// /// The result is always a JSON object. `schema` is a JSON Schema it must @@ -251,6 +278,10 @@ pub struct ContinueTaskRequest { /// The decision on a `needs_approval` pause, or `true` to go past a /// non-payment `checkpoint`. pub approve: Option, + /// Opaque host-issued context for reviewing this continuation. The module + /// carries it to `ConsequenceHost` without interpreting or authorizing it. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub host_context: Option, /// A free-text answer, for a pause that asked a question — or, for /// `needs_human`, `"done"` once the person has finished. pub answer: Option, diff --git a/crates/tinycomputer-bus/src/consequence_host/consequence_host_tests.rs b/crates/tinycomputer-bus/src/consequence_host/consequence_host_tests.rs index 7a341a290..520cb819c 100644 --- a/crates/tinycomputer-bus/src/consequence_host/consequence_host_tests.rs +++ b/crates/tinycomputer-bus/src/consequence_host/consequence_host_tests.rs @@ -15,14 +15,29 @@ fn the_interface_is_its_own_not_the_desktop_or_site_memory_one() { #[test] fn a_review_request_keeps_its_wire_form() { let request: ReviewActionRequest = serde_json::from_value(serde_json::json!({ - "task": "t1", "action": "pay now", "target": "Pay", "kind": "payment" + "task": "t1", "action": "pay now", "target": "Pay", "kind": "payment", + "host_context": "opaque-context" })) .unwrap(); assert_eq!(request.kind, ConsequenceKind::Payment); + assert_eq!( + request + .host_context + .as_ref() + .map(crate::agent::HostContext::as_str), + Some("opaque-context") + ); let json = serde_json::to_value(&request).unwrap(); assert_eq!(json["kind"], "payment"); + assert_eq!(json["host_context"], "opaque-context"); let irreversible = serde_json::to_value(ConsequenceKind::Irreversible).unwrap(); assert_eq!(irreversible, "irreversible"); + + let legacy: ReviewActionRequest = serde_json::from_value(serde_json::json!({ + "task": "t2", "action": "send", "target": "Send", "kind": "irreversible" + })) + .unwrap(); + assert_eq!(legacy.host_context, None); } #[test] diff --git a/crates/tinycomputer-bus/src/consequence_host/mod.rs b/crates/tinycomputer-bus/src/consequence_host/mod.rs index ec2491e80..46aa9a6ef 100644 --- a/crates/tinycomputer-bus/src/consequence_host/mod.rs +++ b/crates/tinycomputer-bus/src/consequence_host/mod.rs @@ -21,6 +21,8 @@ use serde::{Deserialize, Serialize}; +use crate::agent::HostContext; + /// The interface the host serves consequence review on. pub const INTERFACE: &str = "ai.tinyhumans.tinycomputer.ConsequenceHost"; @@ -58,6 +60,10 @@ pub struct ReviewActionRequest { pub target: String, /// What the module classified the action as. pub kind: ConsequenceKind, + /// Opaque host-issued context from the `ContinueTask` request. The module + /// relays this value unchanged and grants it no authority. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub host_context: Option, } /// The reply to `Review`. diff --git a/crates/tinycomputer-bus/src/version/mod.rs b/crates/tinycomputer-bus/src/version/mod.rs index 841c92b62..bc21fef6a 100644 --- a/crates/tinycomputer-bus/src/version/mod.rs +++ b/crates/tinycomputer-bus/src/version/mod.rs @@ -8,7 +8,7 @@ //! release workflow bumps, which tracks the shipped artifact. /// The wire contract version this crate defines. -pub const CONTRACT_VERSION: (u32, u32) = (2, 26); +pub const CONTRACT_VERSION: (u32, u32) = (2, 27); /// Returns whether a host holding [`CONTRACT_VERSION`] can bind to a module /// reporting `module`. @@ -22,7 +22,7 @@ pub const CONTRACT_VERSION: (u32, u32) = (2, 26); /// ``` /// # use tinycomputer_bus::{is_compatible, CONTRACT_VERSION}; /// assert!(is_compatible(CONTRACT_VERSION)); -/// assert!(is_compatible((2, 26))); +/// assert!(is_compatible((2, 27))); /// assert!(!is_compatible((2, 11))); /// assert!(!is_compatible((1, 8))); /// ``` diff --git a/crates/tinycomputer-bus/src/version/version_tests.rs b/crates/tinycomputer-bus/src/version/version_tests.rs index e813ad574..529e2ab7e 100644 --- a/crates/tinycomputer-bus/src/version/version_tests.rs +++ b/crates/tinycomputer-bus/src/version/version_tests.rs @@ -6,7 +6,7 @@ use super::{CONTRACT_VERSION, binds, is_compatible}; #[test] fn the_shipped_contract_version_is_pinned() { - assert_eq!(CONTRACT_VERSION, (2, 26)); + assert_eq!(CONTRACT_VERSION, (2, 27)); } #[test] @@ -16,7 +16,7 @@ fn the_contract_binds_to_itself() { #[test] fn a_newer_minor_on_the_module_side_binds() { - assert!(is_compatible((2, 26))); + assert!(is_compatible((2, 27))); assert!(is_compatible((2, 97))); // 2.24 adds same-task flow-to-planner handoff to StartTask. // 2.22 adds optional host-held secret handles to StartTask and RunFlow. @@ -42,6 +42,9 @@ fn a_newer_minor_on_the_module_side_binds() { // 2.20 adds SessionOptions identity fields. // 2.25 adds BrowserEgressHost. // 2.26 adds TraceSinkHost, so a 2.25 module lacks that callback. + // 2.27 relays opaque host context to ConsequenceHost reviews. A 2.26 + // module would drop that context, so a host requiring it cannot bind. + assert!(!is_compatible((2, 26))); assert!(!is_compatible((2, 25))); assert!(!is_compatible((2, 24))); assert!(!is_compatible((2, 23))); diff --git a/crates/tinycomputer/src/tinybus_module/consequence_gate/consequence_gate_tests.rs b/crates/tinycomputer/src/tinybus_module/consequence_gate/consequence_gate_tests.rs index 32089e4b8..2b779c52d 100644 --- a/crates/tinycomputer/src/tinybus_module/consequence_gate/consequence_gate_tests.rs +++ b/crates/tinycomputer/src/tinybus_module/consequence_gate/consequence_gate_tests.rs @@ -6,7 +6,7 @@ use std::sync::{Arc, Mutex}; use tinybus::Connection; -use tinycomputer_bus::agent::{ContinueTaskRequest, TaskId}; +use tinycomputer_bus::agent::{ContinueTaskRequest, HostContext, TaskId}; use super::*; @@ -61,6 +61,7 @@ fn approval(approve: Option) -> ContinueTaskRequest { fact_handles: std::collections::BTreeMap::new(), approve, answer: None, + host_context: Some(HostContext::new("opaque-context")), } } @@ -103,6 +104,10 @@ async fn an_allowed_approval_goes_through() { assert_eq!(seen[0].task, "t1"); assert_eq!(seen[0].target, "Send"); assert_eq!(seen[0].kind, ConsequenceKind::Irreversible); + assert_eq!( + seen[0].host_context.as_ref().map(HostContext::as_str), + Some("opaque-context") + ); } #[tokio::test] @@ -175,7 +180,7 @@ async fn the_bus_port_reaches_the_hosts_interface() -> tinybus::Result<()> { let module = Connection::connect(bus.connect().await?).await?; let link = ConsequenceLink::new(Box::new(BusPort::new(module))); - let verdict = link.review("t1", "pay now", "Pay").await; + let verdict = link.review("t1", "pay now", "Pay", None).await; assert_eq!(verdict, Verdict::Denied("no".to_owned())); assert_eq!(fake.seen.lock().unwrap()[0].kind, ConsequenceKind::Payment); Ok(()) @@ -190,6 +195,9 @@ async fn the_bus_port_treats_a_host_that_serves_nothing_as_unreviewed() -> tinyb Broker::new().spawn(bus.clone()); let module = Connection::connect(bus.connect().await?).await?; let link = ConsequenceLink::new(Box::new(BusPort::new(module))); - assert_eq!(link.review("t1", "send", "Send").await, Verdict::Unreviewed); + assert_eq!( + link.review("t1", "send", "Send", None).await, + Verdict::Unreviewed + ); Ok(()) } diff --git a/crates/tinycomputer/src/tinybus_module/consequence_gate/mod.rs b/crates/tinycomputer/src/tinybus_module/consequence_gate/mod.rs index 93dd0e777..ba586f017 100644 --- a/crates/tinycomputer/src/tinybus_module/consequence_gate/mod.rs +++ b/crates/tinycomputer/src/tinybus_module/consequence_gate/mod.rs @@ -17,7 +17,7 @@ use std::future::Future; use std::pin::Pin; use tinybus::Connection; -use tinycomputer_bus::agent::ContinueTaskRequest; +use tinycomputer_bus::agent::{ContinueTaskRequest, HostContext}; use tinycomputer_bus::consequence_host::{ ConsequenceKind, INTERFACE, OBJECT_PATH, ReviewActionRequest, ReviewActionResponse, methods, }; @@ -129,13 +129,20 @@ impl ConsequenceLink { /// Asks the host whether task `task` may go ahead with `action` on /// `target`. - pub(crate) async fn review(&self, task: &str, action: &str, target: &str) -> Verdict { + pub(crate) async fn review( + &self, + task: &str, + action: &str, + target: &str, + host_context: Option, + ) -> Verdict { let kind = kind_of(action, target); let request = ReviewActionRequest { task: task.to_owned(), action: action.to_owned(), target: target.to_owned(), kind, + host_context, }; match self.port.review(request).await { Ok(reply) if reply.allow => Verdict::Allowed, @@ -169,7 +176,15 @@ impl ConsequenceLink { let Some((action, target)) = paused else { return; }; - if let Verdict::Denied(_) = self.review(&request.id.to_string(), &action, &target).await { + if let Verdict::Denied(_) = self + .review( + &request.id.to_string(), + &action, + &target, + request.host_context.clone(), + ) + .await + { request.approve = Some(false); } } diff --git a/crates/tinycomputer/tests/public_api_tests.rs b/crates/tinycomputer/tests/public_api_tests.rs index 9497a15c0..fa11ff982 100644 --- a/crates/tinycomputer/tests/public_api_tests.rs +++ b/crates/tinycomputer/tests/public_api_tests.rs @@ -34,7 +34,7 @@ fn the_crate_re_exports_the_contract_rather_than_redefining_it() { #[test] fn the_shipped_contract_binds_to_itself() { assert!(is_compatible(CONTRACT_VERSION)); - assert_eq!(CONTRACT_VERSION, (2, 26)); + assert_eq!(CONTRACT_VERSION, (2, 27)); assert!(!is_compatible((2, 25))); } diff --git a/docs/crates/tinycomputer-bus/versioning.md b/docs/crates/tinycomputer-bus/versioning.md index b4767f549..edf255cf1 100644 --- a/docs/crates/tinycomputer-bus/versioning.md +++ b/docs/crates/tinycomputer-bus/versioning.md @@ -9,7 +9,7 @@ code, so this page exists mostly to keep them apart. ## `CONTRACT_VERSION`: does this host understand this module ```rust,ignore -pub const CONTRACT_VERSION: (u32, u32) = (2, 26); +pub const CONTRACT_VERSION: (u32, u32) = (2, 27); ``` This describes the *vocabulary*: the member set and the payload shapes, @@ -45,17 +45,19 @@ Two conditions, both necessary: relies on changed shape or disappeared, so a mismatched major is refused outright, in either direction. 2. **The module must be at least as new, minor-wise, as the host.** A host - built against `(2, 26)` expects at least the members and fields that - existed at `(2, 26)`. A module reporting `(2, 25)` predates the + built against `(2, 27)` expects at least the members and fields that + existed at `(2, 27)`. A module reporting `(2, 26)` lacks host-context relay + for `ConsequenceHost`, so a 2.27 host rejects it. A module reporting + `(2, 25)` predates the `TraceSinkHost` callback added in 2.26, so a 2.26 host rejects it. It does include `BrowserEgressHost`, which was added in 2.25. A newer module with the same major is accepted. ```rust,ignore -assert!(is_compatible(CONTRACT_VERSION)); // (2, 26), the exact version this crate ships -assert!(is_compatible((2, 27))); // a newer, still-compatible module +assert!(is_compatible(CONTRACT_VERSION)); // (2, 27), the exact version this crate ships +assert!(is_compatible((2, 28))); // a newer, still-compatible module assert!(!is_compatible((2, 11))); // an older module, missing something -assert!(!is_compatible((2, 25))); // predates TraceSinkHost; includes BrowserEgressHost from 2.25 +assert!(!is_compatible((2, 26))); // predates ConsequenceHost host-context relay assert!(!is_compatible((1, 10))); // a different major, all bets off ``` From e022e1e9d894316fc5e55f4f64d4b957a1e90da0 Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Thu, 22 Oct 2026 14:27:18 +0000 Subject: [PATCH 05/70] chore(vendor): bump agent-browser, agent-desktop, tinybus and tinyinference Update the vendored submodule pointers for agent-browser, agent-desktop, tinybus and tinyinference to their latest revisions. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- vendor/agent-browser | 2 +- vendor/agent-desktop | 2 +- vendor/tinybus | 2 +- vendor/tinyinference | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/vendor/agent-browser b/vendor/agent-browser index 11303656a..f98d5fef6 160000 --- a/vendor/agent-browser +++ b/vendor/agent-browser @@ -1 +1 @@ -Subproject commit 11303656ac6121f56bceb9769339085ef004d339 +Subproject commit f98d5fef6a57b6067e6c5710e6f0ea6fb0b3bd47 diff --git a/vendor/agent-desktop b/vendor/agent-desktop index 72f8af2f2..9d7ba42a9 160000 --- a/vendor/agent-desktop +++ b/vendor/agent-desktop @@ -1 +1 @@ -Subproject commit 72f8af2f2bfb08a691fd374b6f2163061b83ea3c +Subproject commit 9d7ba42a94bc4ec018e624f3033602188f64af63 diff --git a/vendor/tinybus b/vendor/tinybus index aa36051e2..eb5cf7270 160000 --- a/vendor/tinybus +++ b/vendor/tinybus @@ -1 +1 @@ -Subproject commit aa36051e2d384b09a1fb7871758fcf22c2a7e709 +Subproject commit eb5cf727071a6eb12f9efa3db8ec59e54039f336 diff --git a/vendor/tinyinference b/vendor/tinyinference index 02c01b72f..abf90568a 160000 --- a/vendor/tinyinference +++ b/vendor/tinyinference @@ -1 +1 @@ -Subproject commit 02c01b72f70cd3747304b2a5a696b52a49fdd4fd +Subproject commit abf90568a24b826d49900150b20856ef166df3f8 From 826a885925aa3381da7a383a2a77369047ab688d Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Thu, 22 Oct 2026 14:28:15 +0000 Subject: [PATCH 06/70] docs(specs): document host context relay in desktop module contract Adds a 2.27 section describing the optional opaque host_context on ContinueTaskRequest, how it is copied unchanged into ReviewActionRequest during consequence review, and that the bus redacts it from Debug output. Notes that hosts using the relay must validate and bind the context themselves, and that omitting the field preserves prior behavior. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- docs/technical/specs/desktop-module-contract.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/technical/specs/desktop-module-contract.md b/docs/technical/specs/desktop-module-contract.md index 79d556918..4b36ca80e 100644 --- a/docs/technical/specs/desktop-module-contract.md +++ b/docs/technical/specs/desktop-module-contract.md @@ -89,6 +89,15 @@ serves the interface and fails to answer, turns the approval into a decline, so the task never takes the action. A host that serves nothing leaves the pause as the only gate. A payment checkpoint is never continuable and needs no review. +Host context relay (2.27): `ContinueTaskRequest` takes an optional opaque +`host_context`. When the module requests consequence review, it copies that +value unchanged into `ReviewActionRequest.host_context`; the module does not +interpret it or grant it authority. The bus type redacts the value from its +`Debug` output. Hosts that use the relay must validate the context themselves +and bind it to the task and action under review. Omitting the field preserves +the earlier continuation and consequence-review behavior; hosts that depend on +the relay require a compatible 2.27 module. + Browser egress (2.25): a host may serve the optional `ai.tinyhumans.tinycomputer.BrowserEgressHost` interface (`tinycomputer_bus::browser_egress`) with `Authorize`, `Consume`, and From b1b67c6a5e131fe0c11ac213870d2a82219320c2 Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Thu, 22 Oct 2026 14:28:52 +0000 Subject: [PATCH 07/70] chore(deps): refresh Cargo.lock Regenerate the lockfile, dropping unused transitive crates and consolidating duplicate dependency versions. The workspace crates are also pinned back to 0.9.4, matching the current manifests. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- Cargo.lock | 481 ++++++++++++----------------------------------------- 1 file changed, 103 insertions(+), 378 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fdfcf4461..f826e1601 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -82,14 +82,13 @@ dependencies = [ "url", "urlencoding", "uuid", - "webpki-roots", "windows-sys 0.52.0", - "zip", + "zip 8.6.0", ] [[package]] name = "agent-desktop-core" -version = "0.10.1" +version = "0.9.4" dependencies = [ "base64 0.23.1", "libc", @@ -103,7 +102,7 @@ dependencies = [ [[package]] name = "agent-desktop-linux" -version = "0.10.1" +version = "0.9.4" dependencies = [ "agent-desktop-core", "thiserror 2.0.20", @@ -111,7 +110,7 @@ dependencies = [ [[package]] name = "agent-desktop-macos" -version = "0.10.1" +version = "0.9.4" dependencies = [ "accessibility-sys", "agent-desktop-core", @@ -130,15 +129,10 @@ dependencies = [ [[package]] name = "agent-desktop-windows" -version = "0.10.1" +version = "0.9.4" dependencies = [ "agent-desktop-core", - "serde_json", "thiserror 2.0.20", - "tracing", - "uiautomation", - "windows 0.62.2", - "windows-sys 0.61.2", ] [[package]] @@ -157,7 +151,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "812947049edcd670a82cd5c73c3661d2e58468577ba8489de58e1a73c04cbd5d" dependencies = [ "alsa-sys", - "bitflags 2.13.1", + "bitflags", "cfg-if", "libc", ] @@ -187,6 +181,15 @@ version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470" +[[package]] +name = "arbitrary" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bc62ac97cc33321f50863d514c3bc38a453947a8f9e781137e47c7401020aed" +dependencies = [ + "derive_arbitrary", +] + [[package]] name = "arboard" version = "3.6.1" @@ -221,17 +224,6 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" -[[package]] -name = "atomicwrites" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ef1bb8d1b645fe38d51dfc331d720fb5fc2c94b440c76cc79c80ff265ca33e3" -dependencies = [ - "rustix 0.38.44", - "tempfile", - "windows-sys 0.52.0", -] - [[package]] name = "autocfg" version = "1.5.1" @@ -250,12 +242,6 @@ version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5" -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - [[package]] name = "bitflags" version = "2.13.1" @@ -335,8 +321,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d262e149917187838d5b42777c8253bcb64500067342904e7d429499a6f277e" dependencies = [ "find-msvc-tools", - "jobserver", - "libc", "shlex", ] @@ -352,17 +336,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527" -[[package]] -name = "chacha20" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818" -dependencies = [ - "cfg-if", - "cipher", - "cpufeatures 0.2.17", -] - [[package]] name = "chacha20" version = "0.10.2" @@ -374,19 +347,6 @@ dependencies = [ "rand_core 0.10.1", ] -[[package]] -name = "chacha20poly1305" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10cd79432192d1c0f4e1a0fef9527696cc039165d729fb41b3f4f4f354c2dc35" -dependencies = [ - "aead", - "chacha20 0.9.1", - "cipher", - "poly1305", - "zeroize", -] - [[package]] name = "chrono" version = "0.4.45" @@ -408,16 +368,6 @@ checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" dependencies = [ "crypto-common 0.1.7", "inout", - "zeroize", -] - -[[package]] -name = "clack-private-fs" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fcca21d8096fca7f1c3a22c3109e38927c9b587007c9c7a13b327e5a955baba" -dependencies = [ - "windows-sys 0.61.2", ] [[package]] @@ -445,7 +395,7 @@ version = "5.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a68fa787550392a9d58f44c21a3022cfb3ea3e2458b7f85d3b399d0ceeccf409" dependencies = [ - "nix 0.27.1", + "nix", "winapi", ] @@ -477,7 +427,7 @@ version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa95a34622365fa5bbf40b20b75dba8dfa8c94c734aea8ac9a5ca38af14316f1" dependencies = [ - "bitflags 2.13.1", + "bitflags", "core-foundation", "core-graphics-types", "foreign-types", @@ -490,7 +440,7 @@ version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "064badf302c3194842cf2c5d61f56cc88e54a759313879cdf03abdd27d0c3b97" dependencies = [ - "bitflags 2.13.1", + "bitflags", "core-foundation", "core-graphics-types", "foreign-types", @@ -503,7 +453,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d44a101f213f6c4cdc1853d4b78aef6db6bdfa3468798cc1d9912f4735013eb" dependencies = [ - "bitflags 2.13.1", + "bitflags", "core-foundation", "libc", ] @@ -514,7 +464,7 @@ version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d5d7dca3ebcf65a035582c9ad4385371a9d9ee6537474d2a278f4e1e475bb58" dependencies = [ - "bitflags 2.13.1", + "bitflags", "libc", "objc2-audio-toolbox", "objc2-core-audio", @@ -579,6 +529,12 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "crossbeam-utils" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6" + [[package]] name = "crypto-common" version = "0.1.7" @@ -626,6 +582,17 @@ version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c" +[[package]] +name = "derive_arbitrary" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b034bd7d5f032402a2479444dcc6f74e36a03f31854d41680fb240ef682a1ac" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + [[package]] name = "digest" version = "0.10.7" @@ -675,7 +642,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e0e367e4e7da84520dedcac1901e4da967309406d1e51017ae1abfb97adbd38" dependencies = [ - "bitflags 2.13.1", + "bitflags", "objc2 0.6.4", ] @@ -809,16 +776,6 @@ dependencies = [ "percent-encoding", ] -[[package]] -name = "fs4" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e72ed92b67c146290f88e9c89d60ca163ea417a446f61ffd7b72df3e7f1dfd5" -dependencies = [ - "rustix 1.1.4", - "windows-sys 0.61.2", -] - [[package]] name = "futures" version = "0.3.34" @@ -923,7 +880,7 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bd49230192a3797a9a4d6abe9b3eed6f7fa4c8a8a4947977c6f80025f92cbd8" dependencies = [ - "rustix 1.1.4", + "rustix", "windows-link", ] @@ -940,18 +897,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "getrandom" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" -dependencies = [ - "cfg-if", - "libc", - "r-efi 5.3.0", - "wasip2", -] - [[package]] name = "getrandom" version = "0.4.3" @@ -961,7 +906,7 @@ dependencies = [ "cfg-if", "js-sys", "libc", - "r-efi 6.0.0", + "r-efi", "rand_core 0.10.1", "wasm-bindgen", ] @@ -988,15 +933,6 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" -[[package]] -name = "hkdf" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" -dependencies = [ - "hmac", -] - [[package]] name = "hmac" version = "0.12.1" @@ -1093,7 +1029,7 @@ dependencies = [ "tokio", "tokio-rustls", "tower-service", - "webpki-roots", + "webpki-roots 1.0.10", ] [[package]] @@ -1362,16 +1298,6 @@ dependencies = [ "syn 2.0.119", ] -[[package]] -name = "jobserver" -version = "0.1.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c00acbd29eabad4a2392fa0e921c874934dbbf4194312ad20f04a0ed67a3cb3" -dependencies = [ - "getrandom 0.4.3", - "libc", -] - [[package]] name = "js-sys" version = "0.3.105" @@ -1398,12 +1324,6 @@ dependencies = [ "libc", ] -[[package]] -name = "linux-raw-sys" -version = "0.4.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" - [[package]] name = "linux-raw-sys" version = "0.12.1" @@ -1511,7 +1431,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3f42e7bbe13d351b6bead8286a43aac9534b82bd3cc43e47037f012ebfd62d4" dependencies = [ - "bitflags 2.13.1", + "bitflags", "jni-sys 0.3.1", "log", "ndk-sys", @@ -1540,23 +1460,11 @@ version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" dependencies = [ - "bitflags 2.13.1", + "bitflags", "cfg-if", "libc", ] -[[package]] -name = "nix" -version = "0.31.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf20d2fde8ff38632c426f1165ed7436270b44f199fc55284c38276f9db47c3d" -dependencies = [ - "bitflags 2.13.1", - "cfg-if", - "cfg_aliases", - "libc", -] - [[package]] name = "ntapi" version = "0.4.3" @@ -1645,7 +1553,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4e89ad9e3d7d297152b17d39ed92cd50ca8063a89a9fa569046d41568891eff" dependencies = [ - "bitflags 2.13.1", + "bitflags", "block2 0.5.1", "libc", "objc2 0.5.2", @@ -1661,7 +1569,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d49e936b501e5c5bf01fda3a9452ff86dc3ea98ad5f283e1455153142d97518c" dependencies = [ - "bitflags 2.13.1", + "bitflags", "objc2 0.6.4", "objc2-core-foundation", "objc2-core-graphics", @@ -1674,7 +1582,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6948501a91121d6399b79abaa33a8aa4ea7857fe019f341b8c23ad6e81b79b08" dependencies = [ - "bitflags 2.13.1", + "bitflags", "libc", "objc2 0.6.4", "objc2-core-audio", @@ -1689,7 +1597,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13a380031deed8e99db00065c45937da434ca987c034e13b87e4441f9e4090be" dependencies = [ - "bitflags 2.13.1", + "bitflags", "objc2 0.6.4", "objc2-foundation 0.3.2", ] @@ -1713,7 +1621,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a89f2ec274a0cf4a32642b2991e8b351a404d290da87bb6a9a9d8632490bd1c" dependencies = [ - "bitflags 2.13.1", + "bitflags", "objc2 0.6.4", ] @@ -1723,7 +1631,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "617fbf49e071c178c0b24c080767db52958f716d9eabdf0890523aeae54773ef" dependencies = [ - "bitflags 2.13.1", + "bitflags", "block2 0.5.1", "objc2 0.5.2", "objc2-foundation 0.2.2", @@ -1735,7 +1643,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536" dependencies = [ - "bitflags 2.13.1", + "bitflags", "block2 0.6.2", "dispatch2", "libc", @@ -1748,7 +1656,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e022c9d066895efa1345f8e33e584b9f958da2fd4cd116792e15e07e4720a807" dependencies = [ - "bitflags 2.13.1", + "bitflags", "dispatch2", "objc2 0.6.4", "objc2-core-foundation", @@ -1779,7 +1687,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ee638a5da3799329310ad4cfa62fbf045d5f56e3ef5ba4149e7452dcf89d5a8" dependencies = [ - "bitflags 2.13.1", + "bitflags", "block2 0.5.1", "libc", "objc2 0.5.2", @@ -1791,7 +1699,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3e0adef53c21f888deb4fa59fc59f7eb17404926ee8a6f59f5df0fd7f9f3272" dependencies = [ - "bitflags 2.13.1", + "bitflags", "block2 0.6.2", "libc", "objc2 0.6.4", @@ -1804,7 +1712,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "180788110936d59bab6bd83b6060ffdfffb3b922ba1396b312ae795e1de9d81d" dependencies = [ - "bitflags 2.13.1", + "bitflags", "objc2 0.6.4", "objc2-core-foundation", ] @@ -1815,7 +1723,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd0cba1276f6023976a406a14ffa85e1fdd19df6b0f737b063b95f6c8c7aadd6" dependencies = [ - "bitflags 2.13.1", + "bitflags", "block2 0.5.1", "objc2 0.5.2", "objc2-foundation 0.2.2", @@ -1827,7 +1735,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e42bee7bff906b14b167da2bac5efe6b6a07e6f7c0a21a7308d40c960242dc7a" dependencies = [ - "bitflags 2.13.1", + "bitflags", "block2 0.5.1", "objc2 0.5.2", "objc2-foundation 0.2.2", @@ -1899,24 +1807,13 @@ version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60769b8b31b2a9f263dae2776c37b1b28ae246943cf719eb6946a1db05128a61" dependencies = [ - "bitflags 2.13.1", + "bitflags", "crc32fast", "fdeflate", "flate2", "miniz_oxide", ] -[[package]] -name = "poly1305" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf" -dependencies = [ - "cpufeatures 0.2.17", - "opaque-debug", - "universal-hash", -] - [[package]] name = "polyval" version = "0.6.2" @@ -2048,12 +1945,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "r-efi" -version = "5.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" - [[package]] name = "r-efi" version = "6.0.0" @@ -2067,27 +1958,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e058c7de0b26af77780c769414d6257830bb240f3c38477dbc2c16e5f54d6d4c" dependencies = [ "libc", - "rand_chacha 0.3.1", + "rand_chacha", "rand_core 0.6.4", ] -[[package]] -name = "rand" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9ef1d0d795eb7d84685bca4f72f3649f064e6641543d3a8c415898726a57b41" -dependencies = [ - "rand_chacha 0.9.0", - "rand_core 0.9.5", -] - [[package]] name = "rand" version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "65c9fb96cbc91e3478eaae79a69fcd3f1ae4ad052e471fe6732fff548984b4af" dependencies = [ - "chacha20 0.10.2", + "chacha20", "getrandom 0.4.3", "rand_core 0.10.1", ] @@ -2102,16 +1983,6 @@ dependencies = [ "rand_core 0.6.4", ] -[[package]] -name = "rand_chacha" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" -dependencies = [ - "ppv-lite86", - "rand_core 0.9.5", -] - [[package]] name = "rand_core" version = "0.6.4" @@ -2121,15 +1992,6 @@ dependencies = [ "getrandom 0.2.17", ] -[[package]] -name = "rand_core" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c" -dependencies = [ - "getrandom 0.3.4", -] - [[package]] name = "rand_core" version = "0.10.1" @@ -2151,7 +2013,7 @@ version = "0.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" dependencies = [ - "bitflags 2.13.1", + "bitflags", ] [[package]] @@ -2232,7 +2094,7 @@ dependencies = [ "wasm-bindgen-futures", "wasm-streams", "web-sys", - "webpki-roots", + "webpki-roots 1.0.10", ] [[package]] @@ -2299,29 +2161,16 @@ dependencies = [ "semver", ] -[[package]] -name = "rustix" -version = "0.38.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" -dependencies = [ - "bitflags 2.13.1", - "errno", - "libc", - "linux-raw-sys 0.4.15", - "windows-sys 0.52.0", -] - [[package]] name = "rustix" version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" dependencies = [ - "bitflags 2.13.1", + "bitflags", "errno", "libc", - "linux-raw-sys 0.12.1", + "linux-raw-sys", "windows-sys 0.61.2", ] @@ -2647,7 +2496,7 @@ dependencies = [ "fastrand", "getrandom 0.4.3", "once_cell", - "rustix 1.1.4", + "rustix", "windows-sys 0.61.2", ] @@ -2723,7 +2572,7 @@ dependencies = [ [[package]] name = "tinybus" -version = "0.1.6" +version = "0.1.5" dependencies = [ "async-trait", "flate2", @@ -2739,12 +2588,12 @@ dependencies = [ "toml", "tracing", "ureq", - "zip", + "zip 2.6.1", ] [[package]] name = "tinybus-macros" -version = "0.1.6" +version = "0.1.5" dependencies = [ "proc-macro2", "quote", @@ -2753,7 +2602,7 @@ dependencies = [ [[package]] name = "tinybus-module" -version = "0.1.6" +version = "0.1.5" dependencies = [ "async-trait", "serde", @@ -2914,7 +2763,7 @@ dependencies = [ [[package]] name = "tinyinference-core" -version = "0.5.0" +version = "0.3.0" dependencies = [ "anyhow", "httpdate", @@ -2924,7 +2773,7 @@ dependencies = [ [[package]] name = "tinyinference-decisions" -version = "0.5.0" +version = "0.3.0" dependencies = [ "async-trait", "httpdate", @@ -2937,10 +2786,10 @@ dependencies = [ [[package]] name = "tinyinference-llm" -version = "0.5.0" +version = "0.3.0" dependencies = [ "async-trait", - "base64 0.23.1", + "base64 0.22.1", "bytes", "futures", "reqwest", @@ -2948,67 +2797,11 @@ dependencies = [ "serde_json", "thiserror 2.0.20", "tinyinference-core", - "tinyinference-providers", "tinytools-agent", "tokio", "tracing", ] -[[package]] -name = "tinyinference-providers" -version = "0.5.0" -dependencies = [ - "base64 0.23.1", - "rand 0.10.3", - "reqwest", - "serde", - "serde_json", - "sha2 0.11.0", - "tinystoragedrivers-secrets", - "tracing", - "url", - "zeroize", -] - -[[package]] -name = "tinystoragedrivers-core" -version = "1.0.0" -source = "git+https://github.com/tinyhumansai/tinystoragedrivers?tag=v1.0.0#141fd9ed0ad5d14a8fb5a1b3e837a719e81ac08d" -dependencies = [ - "async-trait", - "data-encoding", - "serde", - "serde_json", - "sha2 0.10.9", - "thiserror 2.0.20", - "tokio", - "ulid", - "zstd", -] - -[[package]] -name = "tinystoragedrivers-secrets" -version = "1.0.0" -source = "git+https://github.com/tinyhumansai/tinystoragedrivers?tag=v1.0.0#141fd9ed0ad5d14a8fb5a1b3e837a719e81ac08d" -dependencies = [ - "async-trait", - "atomicwrites", - "chacha20poly1305", - "clack-private-fs", - "fs4", - "hkdf", - "rustix 1.1.4", - "serde", - "serde_json", - "sha2 0.10.9", - "tinystoragedrivers-core", - "tokio", - "winapi-util", - "windows-permissions", - "winsafe", - "zeroize", -] - [[package]] name = "tinystr" version = "0.8.4" @@ -3097,6 +2890,7 @@ dependencies = [ "tokio", "tokio-rustls", "tungstenite", + "webpki-roots 0.26.11", ] [[package]] @@ -3184,7 +2978,7 @@ version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4cfcf7e2740e6fc6d4d688b4ef00650406bb94adf4731e43c096c3a19fe40840" dependencies = [ - "bitflags 2.13.1", + "bitflags", "bytes", "futures-util", "http", @@ -3277,39 +3071,6 @@ version = "1.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" -[[package]] -name = "uiautomation" -version = "0.25.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa2eacf9390a8491bc949b04230f40c12520c6423a2962a6087eea1ef14373af" -dependencies = [ - "chrono", - "uiautomation_derive", - "windows 0.62.2", - "windows-core 0.62.2", -] - -[[package]] -name = "uiautomation_derive" -version = "0.7.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c893ec96e05c3c81ba46f838f3190549ec185ef377d582ab3d44202b2dfacbd" -dependencies = [ - "proc-macro2", - "quote", - "syn 3.0.9", -] - -[[package]] -name = "ulid" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "470dbf6591da1b39d43c14523b2b469c86879a53e8b758c8e090a470fe7b1fbe" -dependencies = [ - "rand 0.9.5", - "web-time", -] - [[package]] name = "unicase" version = "2.9.0" @@ -3352,7 +3113,7 @@ dependencies = [ "rustls-pki-types", "ureq-proto", "utf8-zero", - "webpki-roots", + "webpki-roots 1.0.10", ] [[package]] @@ -3445,15 +3206,6 @@ version = "0.11.1+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" -[[package]] -name = "wasip2" -version = "1.0.4+wasi-0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b67efb37e106e55ce722a510d6b5f9c17f083e5fc79afc2badeb12cc313d9487" -dependencies = [ - "wit-bindgen", -] - [[package]] name = "wasm-bindgen" version = "0.2.128" @@ -3542,6 +3294,15 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "webpki-roots" +version = "0.26.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "521bc38abb08001b01866da9f51eb7c5d647a19260e00054a8c7fd5f9e57f7a9" +dependencies = [ + "webpki-roots 1.0.10", +] + [[package]] name = "webpki-roots" version = "1.0.10" @@ -3754,16 +3515,6 @@ dependencies = [ "windows-link", ] -[[package]] -name = "windows-permissions" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e2ccdc3c6bf4d4a094e031b63fadd08d8e42abd259940eb8aa5fdc09d4bf9be" -dependencies = [ - "bitflags 1.3.2", - "winapi", -] - [[package]] name = "windows-result" version = "0.1.2" @@ -3976,18 +3727,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "winsafe" -version = "0.0.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ef0ffc427f045c0cc9ebffd6f4f91153dcd2a1547b5c3c29ee3f541e16e95c6" - -[[package]] -name = "wit-bindgen" -version = "0.57.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" - [[package]] name = "writeable" version = "0.6.4" @@ -4001,7 +3740,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9993aa5be5a26815fe2c3eacfc1fde061fc1a1f094bf1ad2a18bf9c495dd7414" dependencies = [ "gethostname", - "rustix 1.1.4", + "rustix", "x11rb-protocol", ] @@ -4018,7 +3757,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32e45ad4206f6d2479085147f02bc2ef834ac85886624a23575ae137c8aa8156" dependencies = [ "libc", - "rustix 1.1.4", + "rustix", ] [[package]] @@ -4143,15 +3882,29 @@ dependencies = [ [[package]] name = "zip" -version = "9.0.5" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dcb24d0152526ae49b9b96c1dcf71850ca1e0b882e4e28ed898a93c41334744" +dependencies = [ + "arbitrary", + "crc32fast", + "crossbeam-utils", + "flate2", + "indexmap", + "memchr", + "zopfli", +] + +[[package]] +name = "zip" +version = "8.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e04976da629d3b04204ba8105b396a193af8ad2583b2c79bfb3ab8af580a11e" +checksum = "2d04a6b5381502aa6087c94c669499eb1602eb9c5e8198e534de571f7154809b" dependencies = [ "crc32fast", "flate2", "indexmap", "memchr", - "nix 0.31.3", "typed-path", "zopfli", ] @@ -4180,34 +3933,6 @@ dependencies = [ "simd-adler32", ] -[[package]] -name = "zstd" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91ee311a569c327171651566e07972200e76fcfe2242a4fa446149a3881c08a" -dependencies = [ - "zstd-safe", -] - -[[package]] -name = "zstd-safe" -version = "7.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64d80649ab6db9d9f6f9c80a40becd948eda4714a0a5ac8c4d157a32231c7882" -dependencies = [ - "zstd-sys", -] - -[[package]] -name = "zstd-sys" -version = "2.1.2+zstd.1.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "481ada9c543b2323cbb7bbdbb5249177fbf0188ed959ed2c15e4b22421c84ed3" -dependencies = [ - "cc", - "pkg-config", -] - [[package]] name = "zune-core" version = "0.5.3" From dc7729295ffb426ce43074cbea6c4a6b7dcde333 Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Thu, 22 Oct 2026 14:40:18 +0000 Subject: [PATCH 08/70] fix(deps): restore compatible vendor pins Co-authored-by: Medulla --- Cargo.lock | 481 ++++++++++++++++++++++++++++++++++--------- vendor/agent-browser | 2 +- vendor/agent-desktop | 2 +- vendor/tinybus | 2 +- vendor/tinyinference | 2 +- 5 files changed, 382 insertions(+), 107 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f826e1601..fdfcf4461 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -82,13 +82,14 @@ dependencies = [ "url", "urlencoding", "uuid", + "webpki-roots", "windows-sys 0.52.0", - "zip 8.6.0", + "zip", ] [[package]] name = "agent-desktop-core" -version = "0.9.4" +version = "0.10.1" dependencies = [ "base64 0.23.1", "libc", @@ -102,7 +103,7 @@ dependencies = [ [[package]] name = "agent-desktop-linux" -version = "0.9.4" +version = "0.10.1" dependencies = [ "agent-desktop-core", "thiserror 2.0.20", @@ -110,7 +111,7 @@ dependencies = [ [[package]] name = "agent-desktop-macos" -version = "0.9.4" +version = "0.10.1" dependencies = [ "accessibility-sys", "agent-desktop-core", @@ -129,10 +130,15 @@ dependencies = [ [[package]] name = "agent-desktop-windows" -version = "0.9.4" +version = "0.10.1" dependencies = [ "agent-desktop-core", + "serde_json", "thiserror 2.0.20", + "tracing", + "uiautomation", + "windows 0.62.2", + "windows-sys 0.61.2", ] [[package]] @@ -151,7 +157,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "812947049edcd670a82cd5c73c3661d2e58468577ba8489de58e1a73c04cbd5d" dependencies = [ "alsa-sys", - "bitflags", + "bitflags 2.13.1", "cfg-if", "libc", ] @@ -181,15 +187,6 @@ version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470" -[[package]] -name = "arbitrary" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bc62ac97cc33321f50863d514c3bc38a453947a8f9e781137e47c7401020aed" -dependencies = [ - "derive_arbitrary", -] - [[package]] name = "arboard" version = "3.6.1" @@ -224,6 +221,17 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" +[[package]] +name = "atomicwrites" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ef1bb8d1b645fe38d51dfc331d720fb5fc2c94b440c76cc79c80ff265ca33e3" +dependencies = [ + "rustix 0.38.44", + "tempfile", + "windows-sys 0.52.0", +] + [[package]] name = "autocfg" version = "1.5.1" @@ -242,6 +250,12 @@ version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5" +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + [[package]] name = "bitflags" version = "2.13.1" @@ -321,6 +335,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d262e149917187838d5b42777c8253bcb64500067342904e7d429499a6f277e" dependencies = [ "find-msvc-tools", + "jobserver", + "libc", "shlex", ] @@ -336,6 +352,17 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527" +[[package]] +name = "chacha20" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818" +dependencies = [ + "cfg-if", + "cipher", + "cpufeatures 0.2.17", +] + [[package]] name = "chacha20" version = "0.10.2" @@ -347,6 +374,19 @@ dependencies = [ "rand_core 0.10.1", ] +[[package]] +name = "chacha20poly1305" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10cd79432192d1c0f4e1a0fef9527696cc039165d729fb41b3f4f4f354c2dc35" +dependencies = [ + "aead", + "chacha20 0.9.1", + "cipher", + "poly1305", + "zeroize", +] + [[package]] name = "chrono" version = "0.4.45" @@ -368,6 +408,16 @@ checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" dependencies = [ "crypto-common 0.1.7", "inout", + "zeroize", +] + +[[package]] +name = "clack-private-fs" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fcca21d8096fca7f1c3a22c3109e38927c9b587007c9c7a13b327e5a955baba" +dependencies = [ + "windows-sys 0.61.2", ] [[package]] @@ -395,7 +445,7 @@ version = "5.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a68fa787550392a9d58f44c21a3022cfb3ea3e2458b7f85d3b399d0ceeccf409" dependencies = [ - "nix", + "nix 0.27.1", "winapi", ] @@ -427,7 +477,7 @@ version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa95a34622365fa5bbf40b20b75dba8dfa8c94c734aea8ac9a5ca38af14316f1" dependencies = [ - "bitflags", + "bitflags 2.13.1", "core-foundation", "core-graphics-types", "foreign-types", @@ -440,7 +490,7 @@ version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "064badf302c3194842cf2c5d61f56cc88e54a759313879cdf03abdd27d0c3b97" dependencies = [ - "bitflags", + "bitflags 2.13.1", "core-foundation", "core-graphics-types", "foreign-types", @@ -453,7 +503,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d44a101f213f6c4cdc1853d4b78aef6db6bdfa3468798cc1d9912f4735013eb" dependencies = [ - "bitflags", + "bitflags 2.13.1", "core-foundation", "libc", ] @@ -464,7 +514,7 @@ version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d5d7dca3ebcf65a035582c9ad4385371a9d9ee6537474d2a278f4e1e475bb58" dependencies = [ - "bitflags", + "bitflags 2.13.1", "libc", "objc2-audio-toolbox", "objc2-core-audio", @@ -529,12 +579,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "crossbeam-utils" -version = "0.8.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6" - [[package]] name = "crypto-common" version = "0.1.7" @@ -582,17 +626,6 @@ version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c" -[[package]] -name = "derive_arbitrary" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b034bd7d5f032402a2479444dcc6f74e36a03f31854d41680fb240ef682a1ac" -dependencies = [ - "proc-macro2", - "quote", - "syn 3.0.9", -] - [[package]] name = "digest" version = "0.10.7" @@ -642,7 +675,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e0e367e4e7da84520dedcac1901e4da967309406d1e51017ae1abfb97adbd38" dependencies = [ - "bitflags", + "bitflags 2.13.1", "objc2 0.6.4", ] @@ -776,6 +809,16 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "fs4" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e72ed92b67c146290f88e9c89d60ca163ea417a446f61ffd7b72df3e7f1dfd5" +dependencies = [ + "rustix 1.1.4", + "windows-sys 0.61.2", +] + [[package]] name = "futures" version = "0.3.34" @@ -880,7 +923,7 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bd49230192a3797a9a4d6abe9b3eed6f7fa4c8a8a4947977c6f80025f92cbd8" dependencies = [ - "rustix", + "rustix 1.1.4", "windows-link", ] @@ -897,6 +940,18 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "libc", + "r-efi 5.3.0", + "wasip2", +] + [[package]] name = "getrandom" version = "0.4.3" @@ -906,7 +961,7 @@ dependencies = [ "cfg-if", "js-sys", "libc", - "r-efi", + "r-efi 6.0.0", "rand_core 0.10.1", "wasm-bindgen", ] @@ -933,6 +988,15 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "hkdf" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" +dependencies = [ + "hmac", +] + [[package]] name = "hmac" version = "0.12.1" @@ -1029,7 +1093,7 @@ dependencies = [ "tokio", "tokio-rustls", "tower-service", - "webpki-roots 1.0.10", + "webpki-roots", ] [[package]] @@ -1298,6 +1362,16 @@ dependencies = [ "syn 2.0.119", ] +[[package]] +name = "jobserver" +version = "0.1.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c00acbd29eabad4a2392fa0e921c874934dbbf4194312ad20f04a0ed67a3cb3" +dependencies = [ + "getrandom 0.4.3", + "libc", +] + [[package]] name = "js-sys" version = "0.3.105" @@ -1324,6 +1398,12 @@ dependencies = [ "libc", ] +[[package]] +name = "linux-raw-sys" +version = "0.4.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" + [[package]] name = "linux-raw-sys" version = "0.12.1" @@ -1431,7 +1511,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3f42e7bbe13d351b6bead8286a43aac9534b82bd3cc43e47037f012ebfd62d4" dependencies = [ - "bitflags", + "bitflags 2.13.1", "jni-sys 0.3.1", "log", "ndk-sys", @@ -1460,11 +1540,23 @@ version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" dependencies = [ - "bitflags", + "bitflags 2.13.1", "cfg-if", "libc", ] +[[package]] +name = "nix" +version = "0.31.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf20d2fde8ff38632c426f1165ed7436270b44f199fc55284c38276f9db47c3d" +dependencies = [ + "bitflags 2.13.1", + "cfg-if", + "cfg_aliases", + "libc", +] + [[package]] name = "ntapi" version = "0.4.3" @@ -1553,7 +1645,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4e89ad9e3d7d297152b17d39ed92cd50ca8063a89a9fa569046d41568891eff" dependencies = [ - "bitflags", + "bitflags 2.13.1", "block2 0.5.1", "libc", "objc2 0.5.2", @@ -1569,7 +1661,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d49e936b501e5c5bf01fda3a9452ff86dc3ea98ad5f283e1455153142d97518c" dependencies = [ - "bitflags", + "bitflags 2.13.1", "objc2 0.6.4", "objc2-core-foundation", "objc2-core-graphics", @@ -1582,7 +1674,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6948501a91121d6399b79abaa33a8aa4ea7857fe019f341b8c23ad6e81b79b08" dependencies = [ - "bitflags", + "bitflags 2.13.1", "libc", "objc2 0.6.4", "objc2-core-audio", @@ -1597,7 +1689,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13a380031deed8e99db00065c45937da434ca987c034e13b87e4441f9e4090be" dependencies = [ - "bitflags", + "bitflags 2.13.1", "objc2 0.6.4", "objc2-foundation 0.3.2", ] @@ -1621,7 +1713,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a89f2ec274a0cf4a32642b2991e8b351a404d290da87bb6a9a9d8632490bd1c" dependencies = [ - "bitflags", + "bitflags 2.13.1", "objc2 0.6.4", ] @@ -1631,7 +1723,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "617fbf49e071c178c0b24c080767db52958f716d9eabdf0890523aeae54773ef" dependencies = [ - "bitflags", + "bitflags 2.13.1", "block2 0.5.1", "objc2 0.5.2", "objc2-foundation 0.2.2", @@ -1643,7 +1735,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536" dependencies = [ - "bitflags", + "bitflags 2.13.1", "block2 0.6.2", "dispatch2", "libc", @@ -1656,7 +1748,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e022c9d066895efa1345f8e33e584b9f958da2fd4cd116792e15e07e4720a807" dependencies = [ - "bitflags", + "bitflags 2.13.1", "dispatch2", "objc2 0.6.4", "objc2-core-foundation", @@ -1687,7 +1779,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ee638a5da3799329310ad4cfa62fbf045d5f56e3ef5ba4149e7452dcf89d5a8" dependencies = [ - "bitflags", + "bitflags 2.13.1", "block2 0.5.1", "libc", "objc2 0.5.2", @@ -1699,7 +1791,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3e0adef53c21f888deb4fa59fc59f7eb17404926ee8a6f59f5df0fd7f9f3272" dependencies = [ - "bitflags", + "bitflags 2.13.1", "block2 0.6.2", "libc", "objc2 0.6.4", @@ -1712,7 +1804,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "180788110936d59bab6bd83b6060ffdfffb3b922ba1396b312ae795e1de9d81d" dependencies = [ - "bitflags", + "bitflags 2.13.1", "objc2 0.6.4", "objc2-core-foundation", ] @@ -1723,7 +1815,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd0cba1276f6023976a406a14ffa85e1fdd19df6b0f737b063b95f6c8c7aadd6" dependencies = [ - "bitflags", + "bitflags 2.13.1", "block2 0.5.1", "objc2 0.5.2", "objc2-foundation 0.2.2", @@ -1735,7 +1827,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e42bee7bff906b14b167da2bac5efe6b6a07e6f7c0a21a7308d40c960242dc7a" dependencies = [ - "bitflags", + "bitflags 2.13.1", "block2 0.5.1", "objc2 0.5.2", "objc2-foundation 0.2.2", @@ -1807,13 +1899,24 @@ version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60769b8b31b2a9f263dae2776c37b1b28ae246943cf719eb6946a1db05128a61" dependencies = [ - "bitflags", + "bitflags 2.13.1", "crc32fast", "fdeflate", "flate2", "miniz_oxide", ] +[[package]] +name = "poly1305" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf" +dependencies = [ + "cpufeatures 0.2.17", + "opaque-debug", + "universal-hash", +] + [[package]] name = "polyval" version = "0.6.2" @@ -1945,6 +2048,12 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + [[package]] name = "r-efi" version = "6.0.0" @@ -1958,17 +2067,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e058c7de0b26af77780c769414d6257830bb240f3c38477dbc2c16e5f54d6d4c" dependencies = [ "libc", - "rand_chacha", + "rand_chacha 0.3.1", "rand_core 0.6.4", ] +[[package]] +name = "rand" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9ef1d0d795eb7d84685bca4f72f3649f064e6641543d3a8c415898726a57b41" +dependencies = [ + "rand_chacha 0.9.0", + "rand_core 0.9.5", +] + [[package]] name = "rand" version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "65c9fb96cbc91e3478eaae79a69fcd3f1ae4ad052e471fe6732fff548984b4af" dependencies = [ - "chacha20", + "chacha20 0.10.2", "getrandom 0.4.3", "rand_core 0.10.1", ] @@ -1983,6 +2102,16 @@ dependencies = [ "rand_core 0.6.4", ] +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core 0.9.5", +] + [[package]] name = "rand_core" version = "0.6.4" @@ -1992,6 +2121,15 @@ dependencies = [ "getrandom 0.2.17", ] +[[package]] +name = "rand_core" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c" +dependencies = [ + "getrandom 0.3.4", +] + [[package]] name = "rand_core" version = "0.10.1" @@ -2013,7 +2151,7 @@ version = "0.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" dependencies = [ - "bitflags", + "bitflags 2.13.1", ] [[package]] @@ -2094,7 +2232,7 @@ dependencies = [ "wasm-bindgen-futures", "wasm-streams", "web-sys", - "webpki-roots 1.0.10", + "webpki-roots", ] [[package]] @@ -2161,16 +2299,29 @@ dependencies = [ "semver", ] +[[package]] +name = "rustix" +version = "0.38.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" +dependencies = [ + "bitflags 2.13.1", + "errno", + "libc", + "linux-raw-sys 0.4.15", + "windows-sys 0.52.0", +] + [[package]] name = "rustix" version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" dependencies = [ - "bitflags", + "bitflags 2.13.1", "errno", "libc", - "linux-raw-sys", + "linux-raw-sys 0.12.1", "windows-sys 0.61.2", ] @@ -2496,7 +2647,7 @@ dependencies = [ "fastrand", "getrandom 0.4.3", "once_cell", - "rustix", + "rustix 1.1.4", "windows-sys 0.61.2", ] @@ -2572,7 +2723,7 @@ dependencies = [ [[package]] name = "tinybus" -version = "0.1.5" +version = "0.1.6" dependencies = [ "async-trait", "flate2", @@ -2588,12 +2739,12 @@ dependencies = [ "toml", "tracing", "ureq", - "zip 2.6.1", + "zip", ] [[package]] name = "tinybus-macros" -version = "0.1.5" +version = "0.1.6" dependencies = [ "proc-macro2", "quote", @@ -2602,7 +2753,7 @@ dependencies = [ [[package]] name = "tinybus-module" -version = "0.1.5" +version = "0.1.6" dependencies = [ "async-trait", "serde", @@ -2763,7 +2914,7 @@ dependencies = [ [[package]] name = "tinyinference-core" -version = "0.3.0" +version = "0.5.0" dependencies = [ "anyhow", "httpdate", @@ -2773,7 +2924,7 @@ dependencies = [ [[package]] name = "tinyinference-decisions" -version = "0.3.0" +version = "0.5.0" dependencies = [ "async-trait", "httpdate", @@ -2786,10 +2937,10 @@ dependencies = [ [[package]] name = "tinyinference-llm" -version = "0.3.0" +version = "0.5.0" dependencies = [ "async-trait", - "base64 0.22.1", + "base64 0.23.1", "bytes", "futures", "reqwest", @@ -2797,11 +2948,67 @@ dependencies = [ "serde_json", "thiserror 2.0.20", "tinyinference-core", + "tinyinference-providers", "tinytools-agent", "tokio", "tracing", ] +[[package]] +name = "tinyinference-providers" +version = "0.5.0" +dependencies = [ + "base64 0.23.1", + "rand 0.10.3", + "reqwest", + "serde", + "serde_json", + "sha2 0.11.0", + "tinystoragedrivers-secrets", + "tracing", + "url", + "zeroize", +] + +[[package]] +name = "tinystoragedrivers-core" +version = "1.0.0" +source = "git+https://github.com/tinyhumansai/tinystoragedrivers?tag=v1.0.0#141fd9ed0ad5d14a8fb5a1b3e837a719e81ac08d" +dependencies = [ + "async-trait", + "data-encoding", + "serde", + "serde_json", + "sha2 0.10.9", + "thiserror 2.0.20", + "tokio", + "ulid", + "zstd", +] + +[[package]] +name = "tinystoragedrivers-secrets" +version = "1.0.0" +source = "git+https://github.com/tinyhumansai/tinystoragedrivers?tag=v1.0.0#141fd9ed0ad5d14a8fb5a1b3e837a719e81ac08d" +dependencies = [ + "async-trait", + "atomicwrites", + "chacha20poly1305", + "clack-private-fs", + "fs4", + "hkdf", + "rustix 1.1.4", + "serde", + "serde_json", + "sha2 0.10.9", + "tinystoragedrivers-core", + "tokio", + "winapi-util", + "windows-permissions", + "winsafe", + "zeroize", +] + [[package]] name = "tinystr" version = "0.8.4" @@ -2890,7 +3097,6 @@ dependencies = [ "tokio", "tokio-rustls", "tungstenite", - "webpki-roots 0.26.11", ] [[package]] @@ -2978,7 +3184,7 @@ version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4cfcf7e2740e6fc6d4d688b4ef00650406bb94adf4731e43c096c3a19fe40840" dependencies = [ - "bitflags", + "bitflags 2.13.1", "bytes", "futures-util", "http", @@ -3071,6 +3277,39 @@ version = "1.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" +[[package]] +name = "uiautomation" +version = "0.25.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa2eacf9390a8491bc949b04230f40c12520c6423a2962a6087eea1ef14373af" +dependencies = [ + "chrono", + "uiautomation_derive", + "windows 0.62.2", + "windows-core 0.62.2", +] + +[[package]] +name = "uiautomation_derive" +version = "0.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c893ec96e05c3c81ba46f838f3190549ec185ef377d582ab3d44202b2dfacbd" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "ulid" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "470dbf6591da1b39d43c14523b2b469c86879a53e8b758c8e090a470fe7b1fbe" +dependencies = [ + "rand 0.9.5", + "web-time", +] + [[package]] name = "unicase" version = "2.9.0" @@ -3113,7 +3352,7 @@ dependencies = [ "rustls-pki-types", "ureq-proto", "utf8-zero", - "webpki-roots 1.0.10", + "webpki-roots", ] [[package]] @@ -3206,6 +3445,15 @@ version = "0.11.1+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" +[[package]] +name = "wasip2" +version = "1.0.4+wasi-0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b67efb37e106e55ce722a510d6b5f9c17f083e5fc79afc2badeb12cc313d9487" +dependencies = [ + "wit-bindgen", +] + [[package]] name = "wasm-bindgen" version = "0.2.128" @@ -3294,15 +3542,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "webpki-roots" -version = "0.26.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "521bc38abb08001b01866da9f51eb7c5d647a19260e00054a8c7fd5f9e57f7a9" -dependencies = [ - "webpki-roots 1.0.10", -] - [[package]] name = "webpki-roots" version = "1.0.10" @@ -3515,6 +3754,16 @@ dependencies = [ "windows-link", ] +[[package]] +name = "windows-permissions" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e2ccdc3c6bf4d4a094e031b63fadd08d8e42abd259940eb8aa5fdc09d4bf9be" +dependencies = [ + "bitflags 1.3.2", + "winapi", +] + [[package]] name = "windows-result" version = "0.1.2" @@ -3727,6 +3976,18 @@ dependencies = [ "memchr", ] +[[package]] +name = "winsafe" +version = "0.0.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ef0ffc427f045c0cc9ebffd6f4f91153dcd2a1547b5c3c29ee3f541e16e95c6" + +[[package]] +name = "wit-bindgen" +version = "0.57.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" + [[package]] name = "writeable" version = "0.6.4" @@ -3740,7 +4001,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9993aa5be5a26815fe2c3eacfc1fde061fc1a1f094bf1ad2a18bf9c495dd7414" dependencies = [ "gethostname", - "rustix", + "rustix 1.1.4", "x11rb-protocol", ] @@ -3757,7 +4018,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32e45ad4206f6d2479085147f02bc2ef834ac85886624a23575ae137c8aa8156" dependencies = [ "libc", - "rustix", + "rustix 1.1.4", ] [[package]] @@ -3882,29 +4143,15 @@ dependencies = [ [[package]] name = "zip" -version = "2.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dcb24d0152526ae49b9b96c1dcf71850ca1e0b882e4e28ed898a93c41334744" -dependencies = [ - "arbitrary", - "crc32fast", - "crossbeam-utils", - "flate2", - "indexmap", - "memchr", - "zopfli", -] - -[[package]] -name = "zip" -version = "8.6.0" +version = "9.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d04a6b5381502aa6087c94c669499eb1602eb9c5e8198e534de571f7154809b" +checksum = "6e04976da629d3b04204ba8105b396a193af8ad2583b2c79bfb3ab8af580a11e" dependencies = [ "crc32fast", "flate2", "indexmap", "memchr", + "nix 0.31.3", "typed-path", "zopfli", ] @@ -3933,6 +4180,34 @@ dependencies = [ "simd-adler32", ] +[[package]] +name = "zstd" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e91ee311a569c327171651566e07972200e76fcfe2242a4fa446149a3881c08a" +dependencies = [ + "zstd-safe", +] + +[[package]] +name = "zstd-safe" +version = "7.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64d80649ab6db9d9f6f9c80a40becd948eda4714a0a5ac8c4d157a32231c7882" +dependencies = [ + "zstd-sys", +] + +[[package]] +name = "zstd-sys" +version = "2.1.2+zstd.1.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "481ada9c543b2323cbb7bbdbb5249177fbf0188ed959ed2c15e4b22421c84ed3" +dependencies = [ + "cc", + "pkg-config", +] + [[package]] name = "zune-core" version = "0.5.3" diff --git a/vendor/agent-browser b/vendor/agent-browser index f98d5fef6..11303656a 160000 --- a/vendor/agent-browser +++ b/vendor/agent-browser @@ -1 +1 @@ -Subproject commit f98d5fef6a57b6067e6c5710e6f0ea6fb0b3bd47 +Subproject commit 11303656ac6121f56bceb9769339085ef004d339 diff --git a/vendor/agent-desktop b/vendor/agent-desktop index 9d7ba42a9..72f8af2f2 160000 --- a/vendor/agent-desktop +++ b/vendor/agent-desktop @@ -1 +1 @@ -Subproject commit 9d7ba42a94bc4ec018e624f3033602188f64af63 +Subproject commit 72f8af2f2bfb08a691fd374b6f2163061b83ea3c diff --git a/vendor/tinybus b/vendor/tinybus index eb5cf7270..aa36051e2 160000 --- a/vendor/tinybus +++ b/vendor/tinybus @@ -1 +1 @@ -Subproject commit eb5cf727071a6eb12f9efa3db8ec59e54039f336 +Subproject commit aa36051e2d384b09a1fb7871758fcf22c2a7e709 diff --git a/vendor/tinyinference b/vendor/tinyinference index abf90568a..02c01b72f 160000 --- a/vendor/tinyinference +++ b/vendor/tinyinference @@ -1 +1 @@ -Subproject commit abf90568a24b826d49900150b20856ef166df3f8 +Subproject commit 02c01b72f70cd3747304b2a5a696b52a49fdd4fd From 0897cd36e3d98162f2b37933d0b74389fd4916d6 Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Thu, 22 Oct 2026 14:41:44 +0000 Subject: [PATCH 09/70] test(consequence_gate): mark review interface as confidential The bus host test double now declares the review method confidential, and the bus port calls it through call_confidential so the request is routed over the confidential path. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- .../tinybus_module/consequence_gate/consequence_gate_tests.rs | 1 + crates/tinycomputer/src/tinybus_module/consequence_gate/mod.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/tinycomputer/src/tinybus_module/consequence_gate/consequence_gate_tests.rs b/crates/tinycomputer/src/tinybus_module/consequence_gate/consequence_gate_tests.rs index 2b779c52d..54c677c20 100644 --- a/crates/tinycomputer/src/tinybus_module/consequence_gate/consequence_gate_tests.rs +++ b/crates/tinycomputer/src/tinybus_module/consequence_gate/consequence_gate_tests.rs @@ -156,6 +156,7 @@ struct BusHost(FakeHost); #[tinybus::interface(name = "ai.tinyhumans.tinycomputer.ConsequenceHost")] impl BusHost { + #[tinybus(confidential)] async fn review(&self, request: ReviewActionRequest) -> tinybus::Result { self.0 .review(request) diff --git a/crates/tinycomputer/src/tinybus_module/consequence_gate/mod.rs b/crates/tinycomputer/src/tinybus_module/consequence_gate/mod.rs index ba586f017..befac4a19 100644 --- a/crates/tinycomputer/src/tinybus_module/consequence_gate/mod.rs +++ b/crates/tinycomputer/src/tinybus_module/consequence_gate/mod.rs @@ -79,7 +79,7 @@ impl ConsequencePort for BusPort { .map(|proxy| proxy.with_timeout(CALL_TIMEOUT)) .map_err(|error| PortError::Failed(error.to_string()))?; proxy - .call(methods::REVIEW, (request,)) + .call_confidential(methods::REVIEW, (request,)) .await .map_err(|error| { // Across the bus an error keeps its dotted name, not its From aacc7584cec4d4d5fb9e08b348f3269b88e70840 Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Thu, 22 Oct 2026 14:43:18 +0000 Subject: [PATCH 10/70] fix(consequence_gate): call review without confidential flag The review method is no longer marked confidential, so the bus port now invokes it through the plain call path instead of call_confidential. The test host's confidential attribute was dropped to match. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- .../tinybus_module/consequence_gate/consequence_gate_tests.rs | 1 - crates/tinycomputer/src/tinybus_module/consequence_gate/mod.rs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/tinycomputer/src/tinybus_module/consequence_gate/consequence_gate_tests.rs b/crates/tinycomputer/src/tinybus_module/consequence_gate/consequence_gate_tests.rs index 54c677c20..2b779c52d 100644 --- a/crates/tinycomputer/src/tinybus_module/consequence_gate/consequence_gate_tests.rs +++ b/crates/tinycomputer/src/tinybus_module/consequence_gate/consequence_gate_tests.rs @@ -156,7 +156,6 @@ struct BusHost(FakeHost); #[tinybus::interface(name = "ai.tinyhumans.tinycomputer.ConsequenceHost")] impl BusHost { - #[tinybus(confidential)] async fn review(&self, request: ReviewActionRequest) -> tinybus::Result { self.0 .review(request) diff --git a/crates/tinycomputer/src/tinybus_module/consequence_gate/mod.rs b/crates/tinycomputer/src/tinybus_module/consequence_gate/mod.rs index befac4a19..ba586f017 100644 --- a/crates/tinycomputer/src/tinybus_module/consequence_gate/mod.rs +++ b/crates/tinycomputer/src/tinybus_module/consequence_gate/mod.rs @@ -79,7 +79,7 @@ impl ConsequencePort for BusPort { .map(|proxy| proxy.with_timeout(CALL_TIMEOUT)) .map_err(|error| PortError::Failed(error.to_string()))?; proxy - .call_confidential(methods::REVIEW, (request,)) + .call(methods::REVIEW, (request,)) .await .map_err(|error| { // Across the bus an error keeps its dotted name, not its From 32d5b6e5e4b4be672cdbc3541e74cf65b1730d98 Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Thu, 22 Oct 2026 14:53:47 +0000 Subject: [PATCH 11/70] test(task): add host context to describe test fixture The continue_with_handle test helper now supplies a HostContext so the fixture matches the current task input shape. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- crates/tinycomputer-engine/src/task/task_tests/describe_tests.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/tinycomputer-engine/src/task/task_tests/describe_tests.rs b/crates/tinycomputer-engine/src/task/task_tests/describe_tests.rs index 6be80573c..d64f7b67d 100644 --- a/crates/tinycomputer-engine/src/task/task_tests/describe_tests.rs +++ b/crates/tinycomputer-engine/src/task/task_tests/describe_tests.rs @@ -15,6 +15,7 @@ fn continue_with_handle( id, approve: Some(true), answer: Some(String::new()), + host_context: Some(tinycomputer_bus::agent::HostContext::new("opaque-context")), fact_handles: std::collections::BTreeMap::from([( "email".to_owned(), tinycomputer_bus::agent::SecretHandle { From 89fd8d9074684277cabc7adc9264b81d67f208c6 Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Thu, 22 Oct 2026 14:54:15 +0000 Subject: [PATCH 12/70] feat(task): add host_context field to continue task schema The continue task schema now documents an optional host_context string marked x-host-only, so hosts can pass opaque context for consequence review without agents setting or modifying it. A test asserts the field is present and flagged as host supplied. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- crates/tinycomputer-engine/src/task/describe.rs | 5 +++++ .../src/task/task_tests/describe_tests.rs | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/crates/tinycomputer-engine/src/task/describe.rs b/crates/tinycomputer-engine/src/task/describe.rs index 21e97c635..df1781947 100644 --- a/crates/tinycomputer-engine/src/task/describe.rs +++ b/crates/tinycomputer-engine/src/task/describe.rs @@ -213,6 +213,11 @@ fn members() -> Vec { } }, "approve": {"type": "boolean"}, + "host_context": { + "type": "string", + "x-host-only": true, + "description": "Opaque context supplied by a trusted host for consequence review; never set or modified by an agent." + }, "answer": {"type": "string"} }), &["id"], diff --git a/crates/tinycomputer-engine/src/task/task_tests/describe_tests.rs b/crates/tinycomputer-engine/src/task/task_tests/describe_tests.rs index d64f7b67d..b67c94c75 100644 --- a/crates/tinycomputer-engine/src/task/task_tests/describe_tests.rs +++ b/crates/tinycomputer-engine/src/task/task_tests/describe_tests.rs @@ -287,6 +287,11 @@ async fn describe_schemas_name_every_request_field() { "{member}" ); } + assert_eq!( + schema("ContinueTask")["properties"]["host_context"]["x-host-only"], + true, + "host context is host supplied, not an agent argument" + ); // Every member with a request object is compared above; the rest take // no argument. for member in &described.members { From 611a56305bdd00b7935ae7ad339964efce5b383b Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Thu, 22 Oct 2026 14:55:58 +0000 Subject: [PATCH 13/70] test(consequence_gate): cover host context denial for unconfidential hosts Adds a test asserting that the bus port denies a review carrying host context when the host is not confidential, and that the host never sees the request. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- .../consequence_gate_tests.rs | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/crates/tinycomputer/src/tinybus_module/consequence_gate/consequence_gate_tests.rs b/crates/tinycomputer/src/tinybus_module/consequence_gate/consequence_gate_tests.rs index 2b779c52d..f1543dcc4 100644 --- a/crates/tinycomputer/src/tinybus_module/consequence_gate/consequence_gate_tests.rs +++ b/crates/tinycomputer/src/tinybus_module/consequence_gate/consequence_gate_tests.rs @@ -186,6 +186,36 @@ async fn the_bus_port_reaches_the_hosts_interface() -> tinybus::Result<()> { Ok(()) } +#[tokio::test] +async fn the_bus_port_never_sends_host_context_to_an_unconfidential_host() -> tinybus::Result<()> { + use tinybus::broker::Broker; + use tinybus::transport::memory::MemoryBus; + + let bus = MemoryBus::new(); + Broker::new().spawn(bus.clone()); + let host_connection = Connection::connect(bus.connect().await?).await?; + let fake = FakeHost::new(Answer::Allow); + host_connection + .serve_at(OBJECT_PATH.try_into()?, BusHost(fake.clone())) + .await?; + host_connection.request_name(INTERFACE).await?; + let module = Connection::connect(bus.connect().await?).await?; + + let link = ConsequenceLink::new(Box::new(BusPort::new(module))); + let verdict = link + .review( + "t1", + "send", + "Send", + Some(HostContext::new("opaque-context")), + ) + .await; + + assert!(matches!(verdict, Verdict::Denied(ref reason) if reason.contains("confidential"))); + assert!(fake.seen.lock().unwrap().is_empty()); + Ok(()) +} + #[tokio::test] async fn the_bus_port_treats_a_host_that_serves_nothing_as_unreviewed() -> tinybus::Result<()> { use tinybus::broker::Broker; From 3c41a8cec6be584a7586bb249e6d9a0523735c1a Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Thu, 22 Oct 2026 14:56:57 +0000 Subject: [PATCH 14/70] feat(tinybus_module): route consequence reviews to a confidential host The consequence gate now accepts an optional host callback destination from the `consequence_host` config field and sends reviews carrying host context over a confidential call to that unique name. Requests with host context are rejected when no confidential callback was configured, so sensitive context can no longer reach an unconfidential host. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- .../tinycomputer/src/tinybus_module/config.rs | 38 ++++++++++++++++++ .../consequence_gate_tests.rs | 4 +- .../tinybus_module/consequence_gate/mod.rs | 33 ++++++++++++---- .../src/tinybus_module/dispatch/service.rs | 6 +++ crates/tinycomputer/src/tinybus_module/mod.rs | 7 +++- .../tinybus_module_tests/config_tests.rs | 39 +++++++++++++++++++ 6 files changed, 117 insertions(+), 10 deletions(-) diff --git a/crates/tinycomputer/src/tinybus_module/config.rs b/crates/tinycomputer/src/tinybus_module/config.rs index 5521ae9f5..45560e8c1 100644 --- a/crates/tinycomputer/src/tinybus_module/config.rs +++ b/crates/tinycomputer/src/tinybus_module/config.rs @@ -225,6 +225,44 @@ pub(crate) fn trace_sink_destination( } } +/// Whether the host prepared a confidential consequence-review callback. +pub(crate) fn consequence_host_destination( + config: &serde_json::Value, +) -> Result> { + match config + .as_object() + .and_then(|object| object.get("consequence_host")) + { + None | Some(serde_json::Value::Bool(false)) => Ok(None), + Some(serde_json::Value::Object(options)) if options.len() == 1 => { + let destination = options + .get("destination") + .and_then(serde_json::Value::as_str) + .ok_or(crate::Error::ConfigFieldType { + field: "consequence_host.destination", + expected: "the unique name of the host callback prepared for this module", + })?; + tinybus::BusName::new(destination.to_owned()) + .map_err(|_| crate::Error::ConfigFieldType { + field: "consequence_host.destination", + expected: "the unique name of the host callback prepared for this module", + }) + .and_then(|name| { + name.is_unique() + .then_some(Some(name)) + .ok_or(crate::Error::ConfigFieldType { + field: "consequence_host.destination", + expected: "the unique name of the host callback prepared for this module", + }) + }) + } + Some(_) => Err(crate::Error::ConfigFieldType { + field: "consequence_host", + expected: "false or an object containing only the host callback `destination`", + }), + } +} + /// The `cursor` configuration: the agent's one on-screen cursor, shared by /// the desktop and every task's browser. Either a pace name, or an object /// with an optional `pace` and an optional `overlay` path to the diff --git a/crates/tinycomputer/src/tinybus_module/consequence_gate/consequence_gate_tests.rs b/crates/tinycomputer/src/tinybus_module/consequence_gate/consequence_gate_tests.rs index f1543dcc4..21a3587b0 100644 --- a/crates/tinycomputer/src/tinybus_module/consequence_gate/consequence_gate_tests.rs +++ b/crates/tinycomputer/src/tinybus_module/consequence_gate/consequence_gate_tests.rs @@ -179,7 +179,7 @@ async fn the_bus_port_reaches_the_hosts_interface() -> tinybus::Result<()> { host_connection.request_name(INTERFACE).await?; let module = Connection::connect(bus.connect().await?).await?; - let link = ConsequenceLink::new(Box::new(BusPort::new(module))); + let link = ConsequenceLink::new(Box::new(BusPort::new(module, None))); let verdict = link.review("t1", "pay now", "Pay", None).await; assert_eq!(verdict, Verdict::Denied("no".to_owned())); assert_eq!(fake.seen.lock().unwrap()[0].kind, ConsequenceKind::Payment); @@ -201,7 +201,7 @@ async fn the_bus_port_never_sends_host_context_to_an_unconfidential_host() -> ti host_connection.request_name(INTERFACE).await?; let module = Connection::connect(bus.connect().await?).await?; - let link = ConsequenceLink::new(Box::new(BusPort::new(module))); + let link = ConsequenceLink::new(Box::new(BusPort::new(module, None))); let verdict = link .review( "t1", diff --git a/crates/tinycomputer/src/tinybus_module/consequence_gate/mod.rs b/crates/tinycomputer/src/tinybus_module/consequence_gate/mod.rs index ba586f017..42a0efc53 100644 --- a/crates/tinycomputer/src/tinybus_module/consequence_gate/mod.rs +++ b/crates/tinycomputer/src/tinybus_module/consequence_gate/mod.rs @@ -56,6 +56,7 @@ pub(crate) trait ConsequencePort: Send + Sync + std::fmt::Debug { #[derive(Clone)] pub(crate) struct BusPort { connection: Connection, + destination: Option, } impl std::fmt::Debug for BusPort { @@ -65,23 +66,41 @@ impl std::fmt::Debug for BusPort { } impl BusPort { - pub(crate) fn new(connection: Connection) -> Self { - Self { connection } + pub(crate) fn new(connection: Connection, destination: Option) -> Self { + Self { + connection, + destination, + } } } impl ConsequencePort for BusPort { fn review(&self, request: ReviewActionRequest) -> PortFuture<'_, ReviewActionResponse> { + if request.host_context.is_some() && self.destination.is_none() { + return Box::pin(async { + Err(PortError::Failed( + "host context requires a confidential host callback".to_owned(), + )) + }); + } Box::pin(async move { let proxy = self .connection - .proxy(INTERFACE, OBJECT_PATH, INTERFACE) + .proxy( + self.destination + .as_ref() + .map_or(INTERFACE, tinybus::BusName::as_str), + OBJECT_PATH, + INTERFACE, + ) .map(|proxy| proxy.with_timeout(CALL_TIMEOUT)) .map_err(|error| PortError::Failed(error.to_string()))?; - proxy - .call(methods::REVIEW, (request,)) - .await - .map_err(|error| { + let reply = if self.destination.is_some() { + proxy.call_confidential(methods::REVIEW, (request,)).await + } else { + proxy.call(methods::REVIEW, (request,)).await + }; + reply.map_err(|error| { // Across the bus an error keeps its dotted name, not its // variant, so the name is what says nobody serves this. if NOT_SERVED.contains(&error.wire_name()) { diff --git a/crates/tinycomputer/src/tinybus_module/dispatch/service.rs b/crates/tinycomputer/src/tinybus_module/dispatch/service.rs index 4385e3081..3cfb9f04d 100644 --- a/crates/tinycomputer/src/tinybus_module/dispatch/service.rs +++ b/crates/tinycomputer/src/tinybus_module/dispatch/service.rs @@ -73,6 +73,12 @@ impl DesktopService { expected: "a module set up with its host callback connection", }); } + if super::super::config::consequence_host_destination(config)?.is_some() { + return Err(crate::Error::ConfigFieldType { + field: "consequence_host", + expected: "a module set up with its confidential host callback connection", + }); + } Self::with_browser_and_trace_sink(config, browser, None) } diff --git a/crates/tinycomputer/src/tinybus_module/mod.rs b/crates/tinycomputer/src/tinybus_module/mod.rs index 2fe7786a3..835e6a037 100644 --- a/crates/tinycomputer/src/tinybus_module/mod.rs +++ b/crates/tinycomputer/src/tinybus_module/mod.rs @@ -40,6 +40,8 @@ pub(crate) use dispatch::DesktopService; /// silently ignoring the session it was told to join would allocate refs /// nothing else can spend. async fn setup(connection: Connection, config: Value) -> TinyBusResult<()> { + let consequence_host = config::consequence_host_destination(&config) + .map_err(|error| tinybus::Error::failed(error.to_string()))?; let service = DesktopService::from_config_with_connection(&config, connection.clone()) .map_err(|error| tinybus::Error::failed(error.to_string()))?; // The host's per-site memory; a host that does not serve it only costs @@ -48,7 +50,10 @@ async fn setup(connection: Connection, config: Value) -> TinyBusResult<()> { // The host's consequence review; a host that does not serve it leaves a // task's own approval pause as the only gate. let service = service - .with_consequence_review(Box::new(consequence_gate::BusPort::new(connection.clone()))); + .with_consequence_review(Box::new(consequence_gate::BusPort::new( + connection.clone(), + consequence_host, + ))); #[cfg(test)] let service = service.with_native_fixture(); service.sweep_outputs(); diff --git a/crates/tinycomputer/src/tinybus_module/tinybus_module_tests/config_tests.rs b/crates/tinycomputer/src/tinybus_module/tinybus_module_tests/config_tests.rs index c81d44495..22d6b0f78 100644 --- a/crates/tinycomputer/src/tinybus_module/tinybus_module_tests/config_tests.rs +++ b/crates/tinycomputer/src/tinybus_module/tinybus_module_tests/config_tests.rs @@ -308,6 +308,45 @@ fn trace_sink_requires_the_host_prepared_unique_destination() { ); } +#[test] +fn consequence_host_requires_the_host_prepared_unique_destination() { + use crate::tinybus_module::config::consequence_host_destination; + + assert!(consequence_host_destination(&json!({})).unwrap().is_none()); + assert!( + consequence_host_destination(&json!({"consequence_host": false})) + .unwrap() + .is_none() + ); + for invalid in [ + json!({"consequence_host": true}), + json!({"consequence_host": {}}), + json!({"consequence_host": {"destination": "ai.tinyhumans.host"}}), + json!({"consequence_host": {"destination": ":1.42", "scope": "model"}}), + ] { + assert!(consequence_host_destination(&invalid).is_err(), "{invalid}"); + } + assert_eq!( + consequence_host_destination(&json!({ + "consequence_host": {"destination": ":1.42"} + })) + .unwrap() + .unwrap() + .as_str(), + ":1.42" + ); +} + +#[test] +fn connectionless_service_construction_rejects_consequence_host_configuration() { + let error = DesktopService::from_config(&json!({ + "consequence_host": {"destination": ":1.42"} + })) + .expect_err("a host callback needs the module's bus connection"); + + assert!(error.to_string().contains("consequence_host")); +} + #[test] fn connectionless_service_construction_rejects_trace_sink_configuration() { let error = DesktopService::from_config(&json!({ From 46e3f51fb0adff6e081d4cceb1d1c51c43e2ec0b Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Thu, 22 Oct 2026 14:57:25 +0000 Subject: [PATCH 15/70] docs(tinybus_module): document confidential consequence reviews The README now explains that setting consequence_host to the unique destination from ModuleHost::prepare_host_callbacks enables confidential consequence reviews, and that a ContinueTask carrying host context fails closed unless that callback is configured. The BusPort constructor call in the tests was updated to pass the new optional host argument, and two blocks were reindented. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- crates/tinycomputer/src/tinybus_module/README.md | 6 ++++++ .../consequence_gate/consequence_gate_tests.rs | 2 +- .../src/tinybus_module/consequence_gate/mod.rs | 16 ++++++++-------- crates/tinycomputer/src/tinybus_module/mod.rs | 9 ++++----- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/crates/tinycomputer/src/tinybus_module/README.md b/crates/tinycomputer/src/tinybus_module/README.md index a2af54e06..0a81d883b 100644 --- a/crates/tinycomputer/src/tinybus_module/README.md +++ b/crates/tinycomputer/src/tinybus_module/README.md @@ -75,6 +75,12 @@ TinyBus treats initial and replacement module configuration as sensitive host-control traffic. An unreadable configuration fails before replacing the served object rather than falling back to defaults. +Setting `consequence_host` to an object with the unique `destination` supplied +by `ModuleHost::prepare_host_callbacks` enables confidential consequence +reviews. A `ContinueTask` carrying host context fails closed unless this +callback is configured; without host context, the legacy well-known host +interface remains available. + ## The manifest `tinybus_module::module_export_optional_static!` emits (C exports by default; `linked_module()` under `static-link`) the descriptor, embedded manifest, and diff --git a/crates/tinycomputer/src/tinybus_module/consequence_gate/consequence_gate_tests.rs b/crates/tinycomputer/src/tinybus_module/consequence_gate/consequence_gate_tests.rs index 21a3587b0..7a97998d0 100644 --- a/crates/tinycomputer/src/tinybus_module/consequence_gate/consequence_gate_tests.rs +++ b/crates/tinycomputer/src/tinybus_module/consequence_gate/consequence_gate_tests.rs @@ -224,7 +224,7 @@ async fn the_bus_port_treats_a_host_that_serves_nothing_as_unreviewed() -> tinyb let bus = MemoryBus::new(); Broker::new().spawn(bus.clone()); let module = Connection::connect(bus.connect().await?).await?; - let link = ConsequenceLink::new(Box::new(BusPort::new(module))); + let link = ConsequenceLink::new(Box::new(BusPort::new(module, None))); assert_eq!( link.review("t1", "send", "Send", None).await, Verdict::Unreviewed diff --git a/crates/tinycomputer/src/tinybus_module/consequence_gate/mod.rs b/crates/tinycomputer/src/tinybus_module/consequence_gate/mod.rs index 42a0efc53..82503f080 100644 --- a/crates/tinycomputer/src/tinybus_module/consequence_gate/mod.rs +++ b/crates/tinycomputer/src/tinybus_module/consequence_gate/mod.rs @@ -101,14 +101,14 @@ impl ConsequencePort for BusPort { proxy.call(methods::REVIEW, (request,)).await }; reply.map_err(|error| { - // Across the bus an error keeps its dotted name, not its - // variant, so the name is what says nobody serves this. - if NOT_SERVED.contains(&error.wire_name()) { - PortError::NotServed - } else { - PortError::Failed(error.to_string()) - } - }) + // Across the bus an error keeps its dotted name, not its + // variant, so the name is what says nobody serves this. + if NOT_SERVED.contains(&error.wire_name()) { + PortError::NotServed + } else { + PortError::Failed(error.to_string()) + } + }) }) } } diff --git a/crates/tinycomputer/src/tinybus_module/mod.rs b/crates/tinycomputer/src/tinybus_module/mod.rs index 835e6a037..e7e3c93f6 100644 --- a/crates/tinycomputer/src/tinybus_module/mod.rs +++ b/crates/tinycomputer/src/tinybus_module/mod.rs @@ -49,11 +49,10 @@ async fn setup(connection: Connection, config: Value) -> TinyBusResult<()> { let service = service.with_site_memory(Box::new(site_memory::BusPort::new(connection.clone()))); // The host's consequence review; a host that does not serve it leaves a // task's own approval pause as the only gate. - let service = service - .with_consequence_review(Box::new(consequence_gate::BusPort::new( - connection.clone(), - consequence_host, - ))); + let service = service.with_consequence_review(Box::new(consequence_gate::BusPort::new( + connection.clone(), + consequence_host, + ))); #[cfg(test)] let service = service.with_native_fixture(); service.sweep_outputs(); From 3ca08659971a8af1352765bd8e1ba865cd03c7ad Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Thu, 22 Oct 2026 14:59:45 +0000 Subject: [PATCH 16/70] fix(task): omit host-only context from continue task schema The ContinueTask request schema no longer advertises host_context, since that field is injected by the trusted host and is not an agent-settable argument. The schema test now excludes it from the documented fields and asserts it is absent rather than checking its x-host-only marker. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- .../tinycomputer-engine/src/task/describe.rs | 9 ++------- .../src/task/task_tests/describe_tests.rs | 18 +++++++++++++----- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/crates/tinycomputer-engine/src/task/describe.rs b/crates/tinycomputer-engine/src/task/describe.rs index df1781947..ea2af843d 100644 --- a/crates/tinycomputer-engine/src/task/describe.rs +++ b/crates/tinycomputer-engine/src/task/describe.rs @@ -5,8 +5,8 @@ //! The schemas here are written by hand, so each field of a request type //! must be added here when it is added to the contract, save the host's //! own settings no model is offered (a task's browser binary and profile); -//! `task_tests/describe_tests.rs` checks the `StartTask` and `PlanTask` -//! schemas name every other field their types serialize. +//! `task_tests/describe_tests.rs` checks the request schemas name their +//! model-settable fields; host-only context is deliberately omitted. use serde_json::{Value, json}; use tinycomputer_bus::agent::names::{CONFIDENTIAL, methods}; @@ -213,11 +213,6 @@ fn members() -> Vec { } }, "approve": {"type": "boolean"}, - "host_context": { - "type": "string", - "x-host-only": true, - "description": "Opaque context supplied by a trusted host for consequence review; never set or modified by an agent." - }, "answer": {"type": "string"} }), &["id"], diff --git a/crates/tinycomputer-engine/src/task/task_tests/describe_tests.rs b/crates/tinycomputer-engine/src/task/task_tests/describe_tests.rs index b67c94c75..5becd7a1f 100644 --- a/crates/tinycomputer-engine/src/task/task_tests/describe_tests.rs +++ b/crates/tinycomputer-engine/src/task/task_tests/describe_tests.rs @@ -283,14 +283,22 @@ async fn describe_schemas_name_every_request_field() { for (member, request) in others { assert_eq!( documented(&schema(member)), - fields(&request.unwrap()), + if member == "ContinueTask" { + fields(&request.unwrap()) + .into_iter() + .filter(|field| field != "host_context") + .collect() + } else { + fields(&request.unwrap()) + }, "{member}" ); } - assert_eq!( - schema("ContinueTask")["properties"]["host_context"]["x-host-only"], - true, - "host context is host supplied, not an agent argument" + assert!( + schema("ContinueTask")["properties"] + .get("host_context") + .is_none(), + "host context is injected by the trusted host, not exposed to agents" ); // Every member with a request object is compared above; the rest take // no argument. From f05687a9e2fc6732a14431b68928589cd8a674aa Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Thu, 22 Oct 2026 15:11:42 +0000 Subject: [PATCH 17/70] test(task): cover continuation request fields in describe schemas Adds a test asserting that the describe schemas document every field of the continuation request, mirroring the existing coverage for plan requests. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- .../src/task/task_tests/describe_tests.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/crates/tinycomputer-engine/src/task/task_tests/describe_tests.rs b/crates/tinycomputer-engine/src/task/task_tests/describe_tests.rs index 5becd7a1f..69885b1a3 100644 --- a/crates/tinycomputer-engine/src/task/task_tests/describe_tests.rs +++ b/crates/tinycomputer-engine/src/task/task_tests/describe_tests.rs @@ -257,7 +257,20 @@ async fn describe_schemas_name_every_request_field() { let plan = serde_json::to_value(tinycomputer_bus::agent::PlanTaskRequest::default()).unwrap(); assert_eq!(documented(&schema("PlanTask")), fields(&plan)); +} +#[tokio::test] +async fn describe_schemas_name_continuation_request_fields() { + let (tasks, _) = controller(Vec::new()); + let described = capabilities(Vec::new(), Some(&jev()), &tasks); + let schema = |name: &str| { + described + .members + .iter() + .find(|member| member.name == name) + .map(|member| member.input.clone()) + .expect("the member is documented") + }; let id = tinycomputer_bus::agent::TaskId::new("t-1"); let others = [ ( From 18ab9ea3f32ba3a3e7ef62b8ec1631e496d6404d Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Thu, 22 Oct 2026 17:52:49 +0000 Subject: [PATCH 18/70] fix(consequence): fail closed for missing configured callback Co-authored-by: Medulla --- MODULE.md | 3 ++ .../consequence_gate_tests.rs | 45 +++++++++++++++++++ .../tinybus_module/consequence_gate/mod.rs | 23 +++++----- docs/technical/architecture.md | 1 + 4 files changed, 61 insertions(+), 11 deletions(-) diff --git a/MODULE.md b/MODULE.md index 5cc663bb4..c1532ccec 100644 --- a/MODULE.md +++ b/MODULE.md @@ -50,6 +50,9 @@ is optional: and requested task reports. Sink mode replaces local trace/session storage and does not fall back to `trace_path`; event errors follow `trace_strict`, and report write errors return a recoverable `TRACE_SINK_FAILED` response; +- `consequence_host`: an object containing only the unique destination prepared + for the confidential `ConsequenceHost` callback. When configured, a missing + object, interface, or failed callback declines the pending action; - `jev`: the decision model and its API key, needed by the Jev-driven and task members. `provider` picks it: Jev through `type_safe` (the default), `open_router`, or `tiny_humans_open_router`; `open_jev` (OpenJEV's diff --git a/crates/tinycomputer/src/tinybus_module/consequence_gate/consequence_gate_tests.rs b/crates/tinycomputer/src/tinybus_module/consequence_gate/consequence_gate_tests.rs index 7a97998d0..f2b7b562e 100644 --- a/crates/tinycomputer/src/tinybus_module/consequence_gate/consequence_gate_tests.rs +++ b/crates/tinycomputer/src/tinybus_module/consequence_gate/consequence_gate_tests.rs @@ -231,3 +231,48 @@ async fn the_bus_port_treats_a_host_that_serves_nothing_as_unreviewed() -> tinyb ); Ok(()) } + +#[tokio::test] +async fn a_missing_configured_callback_is_a_failure_not_an_unreviewed_action() -> tinybus::Result<()> +{ + use tinybus::broker::Broker; + use tinybus::transport::memory::MemoryBus; + + let bus = MemoryBus::new(); + Broker::new().spawn(bus.clone()); + let host = Connection::connect(bus.connect().await?).await?; + let destination = host + .unique_name() + .expect("connected host has a unique name"); + host.serve_at(OBJECT_PATH.try_into()?, UnrelatedObject) + .await?; + let module = Connection::connect(bus.connect().await?).await?; + let link = ConsequenceLink::new(Box::new(BusPort::new(module, Some(destination)))); + + assert!(matches!( + link.review("t1", "send", "Send", None).await, + Verdict::Denied(_) + )); + Ok(()) +} + +struct UnrelatedObject; + +#[tinybus::interface(name = "org.example.Unrelated")] +impl UnrelatedObject { + async fn ping(&self) -> tinybus::Result<()> { + Ok(()) + } +} + +#[test] +fn a_configured_callback_that_is_not_served_is_a_failure() { + let error = tinybus::Error::UnknownInterface { + path: OBJECT_PATH.parse().unwrap(), + interface: INTERFACE.parse().unwrap(), + }; + assert!(matches!( + BusPort::classify_error(true, error), + PortError::Failed(_) + )); +} diff --git a/crates/tinycomputer/src/tinybus_module/consequence_gate/mod.rs b/crates/tinycomputer/src/tinybus_module/consequence_gate/mod.rs index 82503f080..eae87328a 100644 --- a/crates/tinycomputer/src/tinybus_module/consequence_gate/mod.rs +++ b/crates/tinycomputer/src/tinybus_module/consequence_gate/mod.rs @@ -26,8 +26,9 @@ use tinycomputer_core::{Consequence, consequence}; /// The deadline for one call to the host. const CALL_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(30); -/// The bus errors that mean the host does not serve the interface at all, -/// rather than serving it and failing. +/// The bus errors that identify a missing service on the legacy well-known +/// lookup. An explicitly configured destination is expected to be served and +/// every failure from it denies the action. const NOT_SERVED: [&str; 3] = [ "ai.tinyhumans.tinybus.Error.NameHasNoOwner", "ai.tinyhumans.tinybus.Error.UnknownObject", @@ -72,6 +73,14 @@ impl BusPort { destination, } } + + fn classify_error(configured_destination: bool, error: tinybus::Error) -> PortError { + if !configured_destination && NOT_SERVED.contains(&error.wire_name()) { + PortError::NotServed + } else { + PortError::Failed(error.to_string()) + } + } } impl ConsequencePort for BusPort { @@ -100,15 +109,7 @@ impl ConsequencePort for BusPort { } else { proxy.call(methods::REVIEW, (request,)).await }; - reply.map_err(|error| { - // Across the bus an error keeps its dotted name, not its - // variant, so the name is what says nobody serves this. - if NOT_SERVED.contains(&error.wire_name()) { - PortError::NotServed - } else { - PortError::Failed(error.to_string()) - } - }) + reply.map_err(|error| Self::classify_error(self.destination.is_some(), error)) }) } } diff --git a/docs/technical/architecture.md b/docs/technical/architecture.md index 1f0ef1317..48f1826c5 100644 --- a/docs/technical/architecture.md +++ b/docs/technical/architecture.md @@ -222,6 +222,7 @@ configuration validates. | `trace_path` | string | where agent-desktop writes its trace | | `trace_strict` | bool | fail a call when its trace cannot be written | | `trace_sink` | object | optional host-owned persistence at the unique destination prepared by `ModuleHost::prepare_host_callbacks`; replaces local trace and session persistence | +| `consequence_host` | object | optional confidential consequence review callback at the unique destination prepared by `ModuleHost::prepare_host_callbacks`; a missing configured callback denies the action | | `headed` | bool | use real input instead of accessibility actions | | `jev` | object | decision provider (`type_safe`, `open_router`, `tiny_humans_open_router`, `open_jev`, `sage`), API key, optional model, approved endpoint, timeout, retries, `sdk_name` for the TinyHumans proxy, and `fast` for Sage | | `planner` | object | `api_key`, `provider` (`open_router` or `tiny_humans`), approved `endpoint_url`, `sdk_name`, and optional `model` for the planner, optional `rescue_route` giving the rescuer its own route and key, optional `rescue_model` for rescuing failed steps (`docs/technical/specs/task-rescue.md`), and optional `output_model` for shaping a finished task's answer (`docs/technical/specs/task-output.md`); absent means no planner, no rescues, and no output shapes | From 52e35966780655d25c32b1bc6df4086d2369deca Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Thu, 22 Oct 2026 18:07:45 +0000 Subject: [PATCH 19/70] docs(consequence): describe callback configuration and denial scope Co-authored-by: Medulla --- MODULE.md | 4 ++-- .../tinycomputer/src/tinybus_module/README.md | 8 +++++--- docs/crates/tinycomputer/configuration.md | 20 +++++++++++++++++++ docs/technical/architecture.md | 2 +- 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/MODULE.md b/MODULE.md index c1532ccec..918cba155 100644 --- a/MODULE.md +++ b/MODULE.md @@ -51,8 +51,8 @@ is optional: and does not fall back to `trace_path`; event errors follow `trace_strict`, and report write errors return a recoverable `TRACE_SINK_FAILED` response; - `consequence_host`: an object containing only the unique destination prepared - for the confidential `ConsequenceHost` callback. When configured, a missing - object, interface, or failed callback declines the pending action; + for the confidential `ConsequenceHost` callback. When reviewing an approved + pending action, a missing object, interface, or failed callback declines it; - `jev`: the decision model and its API key, needed by the Jev-driven and task members. `provider` picks it: Jev through `type_safe` (the default), `open_router`, or `tiny_humans_open_router`; `open_jev` (OpenJEV's diff --git a/crates/tinycomputer/src/tinybus_module/README.md b/crates/tinycomputer/src/tinybus_module/README.md index 0a81d883b..480af3ea0 100644 --- a/crates/tinycomputer/src/tinybus_module/README.md +++ b/crates/tinycomputer/src/tinybus_module/README.md @@ -77,9 +77,11 @@ served object rather than falling back to defaults. Setting `consequence_host` to an object with the unique `destination` supplied by `ModuleHost::prepare_host_callbacks` enables confidential consequence -reviews. A `ContinueTask` carrying host context fails closed unless this -callback is configured; without host context, the legacy well-known host -interface remains available. +reviews. When `ContinueTask` approves a pending action for host review, the +module declines it if the configured callback is absent or cannot answer. A +declined approval, an unanswered pause, or a continuation with no pending +action does not fail solely because this callback is absent. Without host +context, the legacy well-known host interface remains available. ## The manifest diff --git a/docs/crates/tinycomputer/configuration.md b/docs/crates/tinycomputer/configuration.md index 51717dbf1..561cd88cf 100644 --- a/docs/crates/tinycomputer/configuration.md +++ b/docs/crates/tinycomputer/configuration.md @@ -66,6 +66,26 @@ can retry `TaskReport`. Without this key, or with `false`, the existing `trace_path` behavior remains in effect. `true`, malformed objects, and well-known bus names are rejected. +## `consequence_host` + +```json +{ + "consequence_host": { + "destination": ":1.42" + } +} +``` + +Set `consequence_host` to an object containing only the unique callback +destination prepared for this module by `ModuleHost::prepare_host_callbacks`. +The module sends consequence reviews to the host through that confidential +callback. When a `ContinueTask` approves a pending action for host review, +failure to reach the configured callback declines the action. A declined +approval, unanswered pause, or continuation without a pending action does not +fail solely because this callback is absent. Without this key, or with +`false`, calls without host context keep using the legacy well-known host +interface. `true`, malformed objects, and well-known bus names are rejected. + ## `jev` ```json diff --git a/docs/technical/architecture.md b/docs/technical/architecture.md index 48f1826c5..5036b776a 100644 --- a/docs/technical/architecture.md +++ b/docs/technical/architecture.md @@ -222,7 +222,7 @@ configuration validates. | `trace_path` | string | where agent-desktop writes its trace | | `trace_strict` | bool | fail a call when its trace cannot be written | | `trace_sink` | object | optional host-owned persistence at the unique destination prepared by `ModuleHost::prepare_host_callbacks`; replaces local trace and session persistence | -| `consequence_host` | object | optional confidential consequence review callback at the unique destination prepared by `ModuleHost::prepare_host_callbacks`; a missing configured callback denies the action | +| `consequence_host` | object | optional confidential consequence review callback at the unique destination prepared by `ModuleHost::prepare_host_callbacks`; a missing callback denies an approved pending action under host review | | `headed` | bool | use real input instead of accessibility actions | | `jev` | object | decision provider (`type_safe`, `open_router`, `tiny_humans_open_router`, `open_jev`, `sage`), API key, optional model, approved endpoint, timeout, retries, `sdk_name` for the TinyHumans proxy, and `fast` for Sage | | `planner` | object | `api_key`, `provider` (`open_router` or `tiny_humans`), approved `endpoint_url`, `sdk_name`, and optional `model` for the planner, optional `rescue_route` giving the rescuer its own route and key, optional `rescue_model` for rescuing failed steps (`docs/technical/specs/task-rescue.md`), and optional `output_model` for shaping a finished task's answer (`docs/technical/specs/task-output.md`); absent means no planner, no rescues, and no output shapes | From e172609bdc7419ce0cc331c5e8d9d8dc056c2d67 Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Thu, 22 Oct 2026 18:14:36 +0000 Subject: [PATCH 20/70] fix(consequence): satisfy workspace clippy Co-authored-by: Medulla --- .../tinybus_module/consequence_gate/consequence_gate_tests.rs | 4 ++-- .../tinycomputer/src/tinybus_module/consequence_gate/mod.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/tinycomputer/src/tinybus_module/consequence_gate/consequence_gate_tests.rs b/crates/tinycomputer/src/tinybus_module/consequence_gate/consequence_gate_tests.rs index f2b7b562e..efb5806bd 100644 --- a/crates/tinycomputer/src/tinybus_module/consequence_gate/consequence_gate_tests.rs +++ b/crates/tinycomputer/src/tinybus_module/consequence_gate/consequence_gate_tests.rs @@ -261,7 +261,7 @@ struct UnrelatedObject; #[tinybus::interface(name = "org.example.Unrelated")] impl UnrelatedObject { async fn ping(&self) -> tinybus::Result<()> { - Ok(()) + std::future::ready(Ok(())).await } } @@ -272,7 +272,7 @@ fn a_configured_callback_that_is_not_served_is_a_failure() { interface: INTERFACE.parse().unwrap(), }; assert!(matches!( - BusPort::classify_error(true, error), + BusPort::classify_error(true, &error), PortError::Failed(_) )); } diff --git a/crates/tinycomputer/src/tinybus_module/consequence_gate/mod.rs b/crates/tinycomputer/src/tinybus_module/consequence_gate/mod.rs index eae87328a..01ee55650 100644 --- a/crates/tinycomputer/src/tinybus_module/consequence_gate/mod.rs +++ b/crates/tinycomputer/src/tinybus_module/consequence_gate/mod.rs @@ -74,7 +74,7 @@ impl BusPort { } } - fn classify_error(configured_destination: bool, error: tinybus::Error) -> PortError { + fn classify_error(configured_destination: bool, error: &tinybus::Error) -> PortError { if !configured_destination && NOT_SERVED.contains(&error.wire_name()) { PortError::NotServed } else { @@ -109,7 +109,7 @@ impl ConsequencePort for BusPort { } else { proxy.call(methods::REVIEW, (request,)).await }; - reply.map_err(|error| Self::classify_error(self.destination.is_some(), error)) + reply.map_err(|error| Self::classify_error(self.destination.is_some(), &error)) }) } } From 43817bdcb8b8cf39b81619b73089686bdce39f26 Mon Sep 17 00:00:00 2001 From: M3gA-Mind Date: Fri, 23 Oct 2026 02:38:03 +0530 Subject: [PATCH 21/70] fix(flow): gate posting, transferring, checkout, logout and signing; refuse Return before a stop A flow's click gate only knew a 12-word substring list, so "Post", "Transfer $500", "Checkout", "Log out" and "Sign" were pressed inside an ordinary step with no approval. They are now matched as whole words, with "Sign in" carved out. The confirm shortcut pressed Return on a window even when the flow stops before an irreversible step; in a composer Return sends. It is now refused outside a search box whenever the flow declares a stop_before. --- .../src/agentic/flow/act/mod.rs | 4 +- .../src/agentic/flow/act/moves.rs | 6 ++ .../agentic/flow/flow_tests/do_loop_tests.rs | 21 +++++++ .../src/agentic/flow/view/mod.rs | 57 +++++++++++++------ .../src/agentic/flow/view/view_tests.rs | 34 +++++++++++ 5 files changed, 105 insertions(+), 17 deletions(-) diff --git a/crates/tinycomputer-engine/src/agentic/flow/act/mod.rs b/crates/tinycomputer-engine/src/agentic/flow/act/mod.rs index 66e3db009..bbcf001d1 100644 --- a/crates/tinycomputer-engine/src/agentic/flow/act/mod.rs +++ b/crates/tinycomputer-engine/src/agentic/flow/act/mod.rs @@ -135,7 +135,9 @@ const MOVES: &[(&str, &str)] = &[ /// Standard macOS shortcuts that are safe to try: none sends, deletes, or /// quits. `confirm` (Return) commits text typed into a field; it is refused -/// while a sheet or alert is showing, where Return presses the default button. +/// while a sheet or alert is showing, where Return presses the default button, +/// and outside a search box in a flow with a `stop_before`, where Return may +/// send. pub(super) const SHORTCUTS: &[(&str, &str, &str)] = &[ ( "new_item", diff --git a/crates/tinycomputer-engine/src/agentic/flow/act/moves.rs b/crates/tinycomputer-engine/src/agentic/flow/act/moves.rs index 0ec2f604b..1f11d6d1f 100644 --- a/crates/tinycomputer-engine/src/agentic/flow/act/moves.rs +++ b/crates/tinycomputer-engine/src/agentic/flow/act/moves.rs @@ -85,6 +85,12 @@ impl FlowRun<'_, B> { )); return Ok(Move::Skipped); } + // In a composer Return sends: a flow that stops before an + // irreversible step must press a control, which is gated. + if combo == "return" && !searching && !self.stop_before.is_empty() { + self.history.push("refused return: this flow stops before an irreversible step, and Return may perform it; press the control instead".to_owned()); + return Ok(Move::Skipped); + } let app = self.app.clone(); let reply = self .act(log, &format!("press {combo}"), None, move |backend| { diff --git a/crates/tinycomputer-engine/src/agentic/flow/flow_tests/do_loop_tests.rs b/crates/tinycomputer-engine/src/agentic/flow/flow_tests/do_loop_tests.rs index ec7c33d29..6f2d1cbe6 100644 --- a/crates/tinycomputer-engine/src/agentic/flow/flow_tests/do_loop_tests.rs +++ b/crates/tinycomputer-engine/src/agentic/flow/flow_tests/do_loop_tests.rs @@ -1260,3 +1260,24 @@ fn a_pressed_controls_copies_are_only_on_the_other_items_of_its_list() { "the bar's own has none" ); } + +#[tokio::test] +async fn return_is_not_pressed_when_the_flow_stops_before_sending() { + // In a message composer Return sends. The flow declared it stops before + // sending, so the "confirm" shortcut must not press Return unasked. + let run = run_with( + App::default(), + json!({"app": "Mail", "steps": [ + "confirm the message text", + {"stop_before": "sending the message"} + ]}), + |request| request.max_actions = 2, + |id, question, _| match id { + "shortcut" => Some(pick(question, "confirm", 0.9)), + _ => None, + }, + ) + .await; + let presses = run.app.sim().presses.clone(); + assert!(!presses.iter().any(|key| key == "return"), "{presses:?}"); +} diff --git a/crates/tinycomputer-engine/src/agentic/flow/view/mod.rs b/crates/tinycomputer-engine/src/agentic/flow/view/mod.rs index 2c8224c88..cf79b3729 100644 --- a/crates/tinycomputer-engine/src/agentic/flow/view/mod.rs +++ b/crates/tinycomputer-engine/src/agentic/flow/view/mod.rs @@ -32,26 +32,51 @@ pub(in crate::agentic) fn is_banned( banned.contains(&signature(candidate)) || banned.contains(&press_key(candidate)) } +/// Words that commit to something wherever they sit in a label ("Post", +/// "Transfer $500", "Log out"). Matched as whole words, so "Postcode" and +/// "Design" stay pressable; "sign" counts unless it is signing in. +const COMMITTING_WORDS: &[&str] = &[ + "post", + "transfer", + "checkout", + "check out", + "log out", + "logout", + "sign", +]; + /// Whether a lower-cased label names an action that is hard to undo. A /// counter's minus button ("remove adult") is not: it only lowers a number. pub(in crate::agentic) fn destructive_label(evidence: &str) -> bool { + let words = format!( + " {} ", + evidence + .split(|character: char| !character.is_alphanumeric()) + .filter(|word| !word.is_empty()) + .collect::>() + .join(" ") + ) + .replace(" sign in ", " "); !tinycomputer_core::adjusts_a_count(evidence) - && [ - "delete", - "remove", - "send", - "purchase", - "buy", - "pay", - "submit", - "confirm", - "overwrite", - "quit without saving", - "empty trash", - "sign out", - ] - .iter() - .any(|term| evidence.contains(term)) + && (COMMITTING_WORDS + .iter() + .any(|word| words.contains(&format!(" {word} "))) + || [ + "delete", + "remove", + "send", + "purchase", + "buy", + "pay", + "submit", + "confirm", + "overwrite", + "quit without saving", + "empty trash", + "sign out", + ] + .iter() + .any(|term| evidence.contains(term))) } /// Whether `label` is named by a `stop_before` phrase the flow itself diff --git a/crates/tinycomputer-engine/src/agentic/flow/view/view_tests.rs b/crates/tinycomputer-engine/src/agentic/flow/view/view_tests.rs index 40d972850..379a0bc9c 100644 --- a/crates/tinycomputer-engine/src/agentic/flow/view/view_tests.rs +++ b/crates/tinycomputer-engine/src/agentic/flow/view/view_tests.rs @@ -224,3 +224,37 @@ fn the_elements_a_purpose_names_are_offered_first_in_their_own_order() { "filler names nothing" ); } + +#[test] +fn posting_transferring_checking_out_paying_deleting_logging_out_and_signing_are_destructive() { + let screen = clickable_screen(); + let pressable: Vec<&str> = [ + "Post", + "Transfer $500", + "Checkout", + "Check out", + "Pay", + "Delete", + "Log out", + "Sign", + "Sign up", + ] + .into_iter() + .filter(|name| !is_destructive(&button(name), &screen, &[])) + .collect(); + assert!( + pressable.is_empty(), + "pressed with no approval: {pressable:?}" + ); + // Signing in commits to nothing, and a word that only contains one of + // these is not one of them. + for name in [ + "Sign in", + "Sign-in with Google", + "Postcode", + "Design", + "Logo", + ] { + assert!(!is_destructive(&button(name), &screen, &[]), "{name}"); + } +} From de74cb674b21e2cde8bdc3c01b5db22a80bb740a Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Thu, 22 Oct 2026 21:19:06 +0000 Subject: [PATCH 22/70] build(deps): source tinyinference crates from git with a local patch The two tinyinference crates are now declared as git dependencies pinned to a revision instead of path dependencies, so an embedding workspace can redirect them to its own shared copy. A matching patch entry keeps standalone builds on the vendored submodule, and the vendored submodules are bumped to their latest commits. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- Cargo.toml | 13 ++++++++++--- vendor/agent-browser | 2 +- vendor/agent-desktop | 2 +- vendor/tinybus | 2 +- vendor/tinyinference | 2 +- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5fbbdf347..fd1bd9a3f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,10 +52,11 @@ tinycomputer-accessibility = { path = "crates/tinycomputer-accessibility" } # crate of the vendored `vendor/tinyinference` submodule, pinned by its gitlink # so provider validation and retry behavior are reproducible. Only this crate # of TinyInference is linked into the module. -tinyinference-decisions = { path = "vendor/tinyinference/crates/tinyinference-decisions" } +tinyinference-decisions = { git = "https://github.com/tinyhumansai/tinyinference", rev = "02c01b72f70cd3747304b2a5a696b52a49fdd4fd" } # The optional LLM planner's model client (engine `planner` feature) and the -# lab's author. -tinyinference-llm = { path = "vendor/tinyinference/crates/tinyinference-llm" } +# lab's author. Naming the shared source lets a host workspace redirect it to +# its single TinyInference copy; standalone builds use the local patch below. +tinyinference-llm = { git = "https://github.com/tinyhumansai/tinyinference", rev = "02c01b72f70cd3747304b2a5a696b52a49fdd4fd" } # The browser automation engine, linked as a library: `execute_command` over a # `DaemonState`. Vendored from the tinyhumansai fork until # vercel-labs/agent-browser#2008 lands upstream. @@ -121,6 +122,12 @@ tinybus = { path = "vendor/tinybus/crates/tinybus" } tinybus-macros = { path = "vendor/tinybus/crates/tinybus-macros" } tinybus-module = { path = "vendor/tinybus/crates/tinybus-module" } +[patch."https://github.com/tinyhumansai/tinyinference"] +# Keep standalone TinyComputer builds on the pinned submodule while allowing +# an embedding workspace's top-level patch to provide its shared copy. +tinyinference-decisions = { path = "vendor/tinyinference/crates/tinyinference-decisions" } +tinyinference-llm = { path = "vendor/tinyinference/crates/tinyinference-llm" } + [workspace.lints.rust] unsafe_code = "forbid" missing_docs = "warn" diff --git a/vendor/agent-browser b/vendor/agent-browser index 11303656a..9a749e47a 160000 --- a/vendor/agent-browser +++ b/vendor/agent-browser @@ -1 +1 @@ -Subproject commit 11303656ac6121f56bceb9769339085ef004d339 +Subproject commit 9a749e47aa872315db661cb00ff27e909bdce2e4 diff --git a/vendor/agent-desktop b/vendor/agent-desktop index 72f8af2f2..b8d538c03 160000 --- a/vendor/agent-desktop +++ b/vendor/agent-desktop @@ -1 +1 @@ -Subproject commit 72f8af2f2bfb08a691fd374b6f2163061b83ea3c +Subproject commit b8d538c038872c72dbf7ae42e002d6fa03a3e599 diff --git a/vendor/tinybus b/vendor/tinybus index aa36051e2..e5f1cd2d2 160000 --- a/vendor/tinybus +++ b/vendor/tinybus @@ -1 +1 @@ -Subproject commit aa36051e2d384b09a1fb7871758fcf22c2a7e709 +Subproject commit e5f1cd2d2a7b905ee82410a61219292ca8a85c1f diff --git a/vendor/tinyinference b/vendor/tinyinference index 02c01b72f..c29d5118e 160000 --- a/vendor/tinyinference +++ b/vendor/tinyinference @@ -1 +1 @@ -Subproject commit 02c01b72f70cd3747304b2a5a696b52a49fdd4fd +Subproject commit c29d5118eddfa12b83c266d7d5f07f6918dc3787 From b3d1fc7dcdac5dcc55c02b40fa86f103b1c18d0f Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Thu, 22 Oct 2026 21:20:59 +0000 Subject: [PATCH 23/70] chore: restore canonical TinyComputer submodule pins Co-authored-by: Medulla --- vendor/agent-browser | 2 +- vendor/agent-desktop | 2 +- vendor/tinybus | 2 +- vendor/tinyinference | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/vendor/agent-browser b/vendor/agent-browser index 9a749e47a..11303656a 160000 --- a/vendor/agent-browser +++ b/vendor/agent-browser @@ -1 +1 @@ -Subproject commit 9a749e47aa872315db661cb00ff27e909bdce2e4 +Subproject commit 11303656ac6121f56bceb9769339085ef004d339 diff --git a/vendor/agent-desktop b/vendor/agent-desktop index b8d538c03..72f8af2f2 160000 --- a/vendor/agent-desktop +++ b/vendor/agent-desktop @@ -1 +1 @@ -Subproject commit b8d538c038872c72dbf7ae42e002d6fa03a3e599 +Subproject commit 72f8af2f2bfb08a691fd374b6f2163061b83ea3c diff --git a/vendor/tinybus b/vendor/tinybus index e5f1cd2d2..aa36051e2 160000 --- a/vendor/tinybus +++ b/vendor/tinybus @@ -1 +1 @@ -Subproject commit e5f1cd2d2a7b905ee82410a61219292ca8a85c1f +Subproject commit aa36051e2d384b09a1fb7871758fcf22c2a7e709 diff --git a/vendor/tinyinference b/vendor/tinyinference index c29d5118e..02c01b72f 160000 --- a/vendor/tinyinference +++ b/vendor/tinyinference @@ -1 +1 @@ -Subproject commit c29d5118eddfa12b83c266d7d5f07f6918dc3787 +Subproject commit 02c01b72f70cd3747304b2a5a696b52a49fdd4fd From 8ac02a1a0356035b515c5d3fff26694769303029 Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Thu, 22 Oct 2026 22:22:29 +0000 Subject: [PATCH 24/70] test(browser): cover worker egress authorization Add a live Chromium test that loads a page spawning a worker which fetches a denied private address, asserting the request reaches the host egress authorizer and never connects directly. The fixture server now takes an owned body so the generated page HTML can be passed in. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- .../browser_egress_live_tests.rs | 122 +++++++++++++++++- 1 file changed, 119 insertions(+), 3 deletions(-) diff --git a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs index e466eebbe..58601bf09 100644 --- a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs +++ b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs @@ -87,7 +87,7 @@ impl EgressHost { async fn serve_fixture( listener: tokio::net::TcpListener, - expected: &'static [u8], + expected: Vec, extra_connections: Arc, served: tokio::sync::oneshot::Sender<()>, ) { @@ -102,7 +102,7 @@ async fn serve_fixture( b"HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length: ".as_slice(), expected.len().to_string().as_bytes(), b"\r\nConnection: close\r\n\r\n".as_slice(), - expected, + expected.as_slice(), ] .concat(); let _ = tokio::io::AsyncWriteExt::write_all(&mut stream, &response).await; @@ -129,7 +129,7 @@ async fn live_chromium_module_dials_only_the_host_returned_socket_and_rejects_ch let (served_tx, served_rx) = tokio::sync::oneshot::channel(); let allowed_server = tokio::spawn(serve_fixture( allowed_listener, - b"allowed fixture", + b"allowed fixture".to_vec(), extra_allowed_connections.clone(), served_tx, )); @@ -251,3 +251,119 @@ async fn live_chromium_module_dials_only_the_host_returned_socket_and_rejects_ch allowed_server.abort(); Ok(()) } + +#[tokio::test] +async fn live_chromium_module_routes_worker_egress_through_host_authorization() -> tinybus::Result<()> { + let allowed_listener = tokio::net::TcpListener::bind("127.0.0.1:0").await?; + let page_port = allowed_listener.local_addr()?.port(); + let denied_listener = tokio::net::TcpListener::bind("127.0.0.2:0").await?; + let denied_port = denied_listener.local_addr()?.port(); + let html = format!( + "" + ) + .into_bytes(); + let (served_tx, served_rx) = tokio::sync::oneshot::channel(); + let allowed_server = tokio::spawn(serve_fixture( + allowed_listener, + html, + Arc::new(AtomicUsize::new(0)), + served_tx, + )); + + let bus = MemoryBus::new(); + let broker = Broker::new(); + let broker_task = broker.spawn(bus.clone()); + let host_connection = Connection::connect(bus.connect().await?).await?; + let observations = Arc::new(Mutex::new(Vec::new())); + let allowed_address = format!("127.0.0.1:{page_port}"); + host_connection + .serve_at( + browser_egress::OBJECT_PATH.try_into()?, + EgressHost { + allowed: Arc::new(AtomicBool::new(true)), + allowed_address, + observations: observations.clone(), + }, + ) + .await?; + host_connection + .request_name(browser_egress::INTERFACE) + .await?; + + let module_host = ModuleHost::new(broker); + let module = crate::linked_module().expect("linked module manifest is valid"); + module_host + .attach_linked_with_config( + module, + serde_json::json!({ + "browser": {"egress": {"policy_id": "fixture-policy", "generation": 41}} + }), + ) + .expect("TinyComputer module loads through ModuleHost"); + let client = Connection::connect(bus.connect().await?).await?; + let proxy = client.proxy(names::INTERFACE, names::OBJECT_PATH, names::INTERFACE)?; + + let opened: DesktopResponse = proxy + .call( + browser_names::methods::OPEN_SESSION, + (serde_json::json!({}),), + ) + .await?; + let session = successful_data(&opened)["id"].clone(); + assert_eq!(successful_data(&opened)["launched"], true); + let url = format!("http://fixture.test:{page_port}/worker-fixture"); + let navigated: DesktopResponse = proxy + .call( + browser_names::methods::NAVIGATE, + (serde_json::json!({"session": session, "url": url}),), + ) + .await?; + assert!( + navigated.ok, + "authorized worker fixture navigation failed: {:?}", + navigated.error + ); + tokio::time::timeout(Duration::from_secs(10), served_rx) + .await + .expect("fixture page is served") + .expect("fixture server reports the response"); + + let worker_authorization = format!( + "authorize:fixture-policy:41:127.0.0.2:{denied_port}" + ); + tokio::time::timeout(Duration::from_secs(10), async { + loop { + if observations + .lock() + .unwrap() + .iter() + .any(|call| call == &worker_authorization) + { + break; + } + tokio::time::sleep(Duration::from_millis(10)).await; + } + }) + .await + .expect("worker request reaches the host egress authorizer"); + assert!( + tokio::time::timeout(Duration::from_millis(500), denied_listener.accept()) + .await + .is_err(), + "worker request connected directly to the denied private listener" + ); + + let closed: DesktopResponse = proxy + .call( + browser_names::methods::CLOSE_SESSION, + (serde_json::json!({"session": session}),), + ) + .await?; + assert!(closed.ok, "browser session did not close: {:?}", closed.error); + broker_task.abort(); + allowed_server.abort(); + Ok(()) +} From ed424f2aac08ebd856fb10616fe706fdb6498d15 Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Thu, 22 Oct 2026 22:23:06 +0000 Subject: [PATCH 25/70] style(tinycomputer): reformat browser egress live tests Reformatted the browser egress live tests to satisfy rustfmt, wrapping overlong lines and collapsing a multi-line format! call. No test behaviour changed. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- .../tinybus_module/browser_egress_live_tests.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs index 58601bf09..d78d0a431 100644 --- a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs +++ b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs @@ -129,7 +129,8 @@ async fn live_chromium_module_dials_only_the_host_returned_socket_and_rejects_ch let (served_tx, served_rx) = tokio::sync::oneshot::channel(); let allowed_server = tokio::spawn(serve_fixture( allowed_listener, - b"allowed fixture".to_vec(), + b"allowed fixture" + .to_vec(), extra_allowed_connections.clone(), served_tx, )); @@ -253,7 +254,8 @@ async fn live_chromium_module_dials_only_the_host_returned_socket_and_rejects_ch } #[tokio::test] -async fn live_chromium_module_routes_worker_egress_through_host_authorization() -> tinybus::Result<()> { +async fn live_chromium_module_routes_worker_egress_through_host_authorization() +-> tinybus::Result<()> { let allowed_listener = tokio::net::TcpListener::bind("127.0.0.1:0").await?; let page_port = allowed_listener.local_addr()?.port(); let denied_listener = tokio::net::TcpListener::bind("127.0.0.2:0").await?; @@ -331,9 +333,7 @@ async fn live_chromium_module_routes_worker_egress_through_host_authorization() .expect("fixture page is served") .expect("fixture server reports the response"); - let worker_authorization = format!( - "authorize:fixture-policy:41:127.0.0.2:{denied_port}" - ); + let worker_authorization = format!("authorize:fixture-policy:41:127.0.0.2:{denied_port}"); tokio::time::timeout(Duration::from_secs(10), async { loop { if observations @@ -362,7 +362,11 @@ async fn live_chromium_module_routes_worker_egress_through_host_authorization() (serde_json::json!({"session": session}),), ) .await?; - assert!(closed.ok, "browser session did not close: {:?}", closed.error); + assert!( + closed.ok, + "browser session did not close: {:?}", + closed.error + ); broker_task.abort(); allowed_server.abort(); Ok(()) From 10473e3c5fbe6bf31cc7db6e2d223ad9101fef3e Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Thu, 22 Oct 2026 22:24:13 +0000 Subject: [PATCH 26/70] test(browser_egress): allow extra clippy lints in live tests Expand the lint allowlist for the opt-in real-Chromium test module to cover too_many_lines and unused_async, and sort the existing entries. The module doc comment now wraps TinyComputer in backticks for consistency. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- .../src/tinybus_module/browser_egress_live_tests.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs index d78d0a431..2209a73d9 100644 --- a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs +++ b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs @@ -1,5 +1,11 @@ -//! Opt-in real-Chromium coverage through the loaded TinyComputer module. -#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)] +//! Opt-in real-Chromium coverage through the loaded `TinyComputer` module. +#![allow( + clippy::expect_used, + clippy::panic, + clippy::too_many_lines, + clippy::unwrap_used, + clippy::unused_async +)] use std::sync::{ Arc, Mutex, From 80b0975c775308c34a75efbdef107d2b974f1a64 Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Thu, 22 Oct 2026 22:25:12 +0000 Subject: [PATCH 27/70] test(tinycomputer): scope clippy allows to the items that need them Replace the file-level clippy allow list with per-item attributes so the unused_async and too_many_lines suppressions only cover the specific functions and tests that require them. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- .../src/tinybus_module/browser_egress_live_tests.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs index 2209a73d9..4ccb453f4 100644 --- a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs +++ b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs @@ -1,11 +1,5 @@ //! Opt-in real-Chromium coverage through the loaded `TinyComputer` module. -#![allow( - clippy::expect_used, - clippy::panic, - clippy::too_many_lines, - clippy::unwrap_used, - clippy::unused_async -)] +#![allow(clippy::expect_used, clippy::panic, clippy::unwrap_used)] use std::sync::{ Arc, Mutex, @@ -33,6 +27,7 @@ struct EgressHost { #[tinybus::interface(name = "ai.tinyhumans.tinycomputer.BrowserEgressHost")] impl EgressHost { + #[allow(clippy::unused_async)] async fn authorize(&self, request: BrowserEgressTarget) -> tinybus::Result { let allow = self.allowed.load(Ordering::SeqCst) && request.hostname == "fixture.test" @@ -63,6 +58,7 @@ impl EgressHost { }) } + #[allow(clippy::unused_async)] async fn consume( &self, request: BrowserEgressConsumeRequest, @@ -76,6 +72,7 @@ impl EgressHost { }) } + #[allow(clippy::unused_async)] async fn validate( &self, request: BrowserEgressValidateRequest, @@ -125,6 +122,7 @@ fn successful_data(reply: &DesktopResponse) -> &serde_json::Value { } #[tokio::test] +#[allow(clippy::too_many_lines)] async fn live_chromium_module_dials_only_the_host_returned_socket_and_rejects_changed_policy() -> tinybus::Result<()> { let allowed_listener = tokio::net::TcpListener::bind("127.0.0.1:0").await?; @@ -260,6 +258,7 @@ async fn live_chromium_module_dials_only_the_host_returned_socket_and_rejects_ch } #[tokio::test] +#[allow(clippy::too_many_lines)] async fn live_chromium_module_routes_worker_egress_through_host_authorization() -> tinybus::Result<()> { let allowed_listener = tokio::net::TcpListener::bind("127.0.0.1:0").await?; From a9427051f3be40af755c383d6e74c847e4c6f75b Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Thu, 22 Oct 2026 22:34:01 +0000 Subject: [PATCH 28/70] test(browser_egress): extract shared fixture host setup for live tests The live Chromium egress test now builds its browser session through a start_browser_with_fixture_host helper that returns a LiveBrowser handle, so additional live cases can reuse the same fixture wiring. The host methods also yield once before doing their work to keep the async signatures honest instead of suppressing the unused_async lint. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- .../browser_egress_live_tests.rs | 105 ++++++++++++------ 1 file changed, 73 insertions(+), 32 deletions(-) diff --git a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs index 4ccb453f4..666c711cd 100644 --- a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs +++ b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs @@ -27,8 +27,8 @@ struct EgressHost { #[tinybus::interface(name = "ai.tinyhumans.tinycomputer.BrowserEgressHost")] impl EgressHost { - #[allow(clippy::unused_async)] async fn authorize(&self, request: BrowserEgressTarget) -> tinybus::Result { + tokio::task::yield_now().await; let allow = self.allowed.load(Ordering::SeqCst) && request.hostname == "fixture.test" && request.port @@ -58,11 +58,11 @@ impl EgressHost { }) } - #[allow(clippy::unused_async)] async fn consume( &self, request: BrowserEgressConsumeRequest, ) -> tinybus::Result { + tokio::task::yield_now().await; self.observations .lock() .unwrap() @@ -72,11 +72,11 @@ impl EgressHost { }) } - #[allow(clippy::unused_async)] async fn validate( &self, request: BrowserEgressValidateRequest, ) -> tinybus::Result { + tokio::task::yield_now().await; self.observations .lock() .unwrap() @@ -121,24 +121,20 @@ fn successful_data(reply: &DesktopResponse) -> &serde_json::Value { reply.data.as_ref().expect("successful response has data") } -#[tokio::test] -#[allow(clippy::too_many_lines)] -async fn live_chromium_module_dials_only_the_host_returned_socket_and_rejects_changed_policy() --> tinybus::Result<()> { - let allowed_listener = tokio::net::TcpListener::bind("127.0.0.1:0").await?; - let port = allowed_listener.local_addr()?.port(); - let denied_listener = tokio::net::TcpListener::bind(("127.0.0.2", port)).await?; - let allowed_address = allowed_listener.local_addr()?.to_string(); - let extra_allowed_connections = Arc::new(AtomicUsize::new(0)); - let (served_tx, served_rx) = tokio::sync::oneshot::channel(); - let allowed_server = tokio::spawn(serve_fixture( - allowed_listener, - b"allowed fixture" - .to_vec(), - extra_allowed_connections.clone(), - served_tx, - )); +struct LiveBrowser { + proxy: tinybus::Proxy, + session: serde_json::Value, + allowed: Arc, + observations: Arc>>, + broker_task: tokio::task::JoinHandle<()>, +} +async fn start_browser_with_fixture_host( + allowed_address: String, + page_port: u16, + page_path: &str, + served: tokio::sync::oneshot::Receiver<()>, +) -> tinybus::Result { let bus = MemoryBus::new(); let broker = Broker::new(); let broker_task = broker.spawn(bus.clone()); @@ -150,7 +146,7 @@ async fn live_chromium_module_dials_only_the_host_returned_socket_and_rejects_ch browser_egress::OBJECT_PATH.try_into()?, EgressHost { allowed: allowed.clone(), - allowed_address: allowed_address.clone(), + allowed_address, observations: observations.clone(), }, ) @@ -180,7 +176,7 @@ async fn live_chromium_module_dials_only_the_host_returned_socket_and_rejects_ch .await?; let session = successful_data(&opened)["id"].clone(); assert_eq!(successful_data(&opened)["launched"], true); - let url = format!("http://fixture.test:{port}/allowed"); + let url = format!("http://fixture.test:{page_port}{page_path}"); let navigated: DesktopResponse = proxy .call( browser_names::methods::NAVIGATE, @@ -189,15 +185,51 @@ async fn live_chromium_module_dials_only_the_host_returned_socket_and_rejects_ch .await?; assert!( navigated.ok, - "authorized navigation failed: {:?}", + "authorized fixture navigation failed: {:?}", navigated.error ); - tokio::time::timeout(Duration::from_secs(10), served_rx) + tokio::time::timeout(Duration::from_secs(10), served) .await - .expect("authorized Chromium request reaches the fixture within ten seconds") - .expect("authorized fixture reports its response"); + .expect("fixture page is served") + .expect("fixture server reports the response"); - let authorizations_before_policy_change = observations + Ok(LiveBrowser { + proxy, + session, + allowed, + observations, + broker_task, + }) +} + +#[tokio::test] +async fn live_chromium_module_dials_only_the_host_returned_socket_and_rejects_changed_policy() +-> tinybus::Result<()> { + let allowed_listener = tokio::net::TcpListener::bind("127.0.0.1:0").await?; + let port = allowed_listener.local_addr()?.port(); + let denied_listener = tokio::net::TcpListener::bind(("127.0.0.2", port)).await?; + let allowed_address = allowed_listener.local_addr()?.to_string(); + let extra_allowed_connections = Arc::new(AtomicUsize::new(0)); + let (served_tx, served_rx) = tokio::sync::oneshot::channel(); + let allowed_server = tokio::spawn(serve_fixture( + allowed_listener, + b"allowed fixture" + .to_vec(), + extra_allowed_connections.clone(), + served_tx, + )); + + host_connection + let browser = start_browser_with_fixture_host( + allowed_address.clone(), + port, + "/allowed", + served_rx, + ) + .await?; + + let authorizations_before_policy_change = browser + .observations .lock() .unwrap() .iter() @@ -206,12 +238,13 @@ async fn live_chromium_module_dials_only_the_host_returned_socket_and_rejects_ch let extra_connections_before_policy_change = extra_allowed_connections.load(Ordering::SeqCst); // Simulate a policy refresh: the host changes from granting the fixture // socket to denying requests for the same hostname. - allowed.store(false, Ordering::SeqCst); + browser.allowed.store(false, Ordering::SeqCst); let denied_url = format!("http://fixture.test:{port}/after-policy-change"); - let denied: DesktopResponse = proxy + let denied: DesktopResponse = browser + .proxy .call( browser_names::methods::NAVIGATE, - (serde_json::json!({"session": session, "url": denied_url}),), + (serde_json::json!({"session": browser.session, "url": denied_url}),), ) .await?; assert!( @@ -230,7 +263,7 @@ async fn live_chromium_module_dials_only_the_host_returned_socket_and_rejects_ch "policy-denied navigation connected to the previously allowed socket" ); - let calls = observations.lock().unwrap(); + let calls = browser.observations.lock().unwrap(); assert!( calls .iter() @@ -252,7 +285,15 @@ async fn live_chromium_module_dials_only_the_host_returned_socket_and_rejects_ch .any(|call| call == &format!("consume:{denied_address}")), "denied socket was consumed: {calls:?}" ); - broker_task.abort(); + let closed: DesktopResponse = browser + .proxy + .call( + browser_names::methods::CLOSE_SESSION, + (serde_json::json!({"session": browser.session}),), + ) + .await?; + assert!(closed.ok, "browser session did not close: {:?}", closed.error); + browser.broker_task.abort(); allowed_server.abort(); Ok(()) } From 4dee0d516d3dd5bfc02744909bb86cc7cbf47634 Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Thu, 22 Oct 2026 22:34:24 +0000 Subject: [PATCH 29/70] test(browser_egress): reuse fixture host helper in worker egress test The worker egress live test now starts its browser through the shared start_browser_with_fixture_host helper instead of duplicating the bus, broker, and session setup inline, and it drops the now-unneeded too_many_lines allow. A stray leftover line in the neighbouring test was also removed. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- .../browser_egress_live_tests.rs | 87 ++++--------------- 1 file changed, 17 insertions(+), 70 deletions(-) diff --git a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs index 666c711cd..b4a9854bc 100644 --- a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs +++ b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs @@ -219,14 +219,9 @@ async fn live_chromium_module_dials_only_the_host_returned_socket_and_rejects_ch served_tx, )); - host_connection - let browser = start_browser_with_fixture_host( - allowed_address.clone(), - port, - "/allowed", - served_rx, - ) - .await?; + let browser = + start_browser_with_fixture_host(allowed_address.clone(), port, "/allowed", served_rx) + .await?; let authorizations_before_policy_change = browser .observations @@ -292,14 +287,17 @@ async fn live_chromium_module_dials_only_the_host_returned_socket_and_rejects_ch (serde_json::json!({"session": browser.session}),), ) .await?; - assert!(closed.ok, "browser session did not close: {:?}", closed.error); + assert!( + closed.ok, + "browser session did not close: {:?}", + closed.error + ); browser.broker_task.abort(); allowed_server.abort(); Ok(()) } #[tokio::test] -#[allow(clippy::too_many_lines)] async fn live_chromium_module_routes_worker_egress_through_host_authorization() -> tinybus::Result<()> { let allowed_listener = tokio::net::TcpListener::bind("127.0.0.1:0").await?; @@ -321,68 +319,16 @@ async fn live_chromium_module_routes_worker_egress_through_host_authorization() served_tx, )); - let bus = MemoryBus::new(); - let broker = Broker::new(); - let broker_task = broker.spawn(bus.clone()); - let host_connection = Connection::connect(bus.connect().await?).await?; - let observations = Arc::new(Mutex::new(Vec::new())); let allowed_address = format!("127.0.0.1:{page_port}"); - host_connection - .serve_at( - browser_egress::OBJECT_PATH.try_into()?, - EgressHost { - allowed: Arc::new(AtomicBool::new(true)), - allowed_address, - observations: observations.clone(), - }, - ) - .await?; - host_connection - .request_name(browser_egress::INTERFACE) - .await?; - - let module_host = ModuleHost::new(broker); - let module = crate::linked_module().expect("linked module manifest is valid"); - module_host - .attach_linked_with_config( - module, - serde_json::json!({ - "browser": {"egress": {"policy_id": "fixture-policy", "generation": 41}} - }), - ) - .expect("TinyComputer module loads through ModuleHost"); - let client = Connection::connect(bus.connect().await?).await?; - let proxy = client.proxy(names::INTERFACE, names::OBJECT_PATH, names::INTERFACE)?; - - let opened: DesktopResponse = proxy - .call( - browser_names::methods::OPEN_SESSION, - (serde_json::json!({}),), - ) - .await?; - let session = successful_data(&opened)["id"].clone(); - assert_eq!(successful_data(&opened)["launched"], true); - let url = format!("http://fixture.test:{page_port}/worker-fixture"); - let navigated: DesktopResponse = proxy - .call( - browser_names::methods::NAVIGATE, - (serde_json::json!({"session": session, "url": url}),), - ) - .await?; - assert!( - navigated.ok, - "authorized worker fixture navigation failed: {:?}", - navigated.error - ); - tokio::time::timeout(Duration::from_secs(10), served_rx) - .await - .expect("fixture page is served") - .expect("fixture server reports the response"); + let browser = + start_browser_with_fixture_host(allowed_address, page_port, "/worker-fixture", served_rx) + .await?; let worker_authorization = format!("authorize:fixture-policy:41:127.0.0.2:{denied_port}"); tokio::time::timeout(Duration::from_secs(10), async { loop { - if observations + if browser + .observations .lock() .unwrap() .iter() @@ -402,10 +348,11 @@ async fn live_chromium_module_routes_worker_egress_through_host_authorization() "worker request connected directly to the denied private listener" ); - let closed: DesktopResponse = proxy + let closed: DesktopResponse = browser + .proxy .call( browser_names::methods::CLOSE_SESSION, - (serde_json::json!({"session": session}),), + (serde_json::json!({"session": browser.session}),), ) .await?; assert!( @@ -413,7 +360,7 @@ async fn live_chromium_module_routes_worker_egress_through_host_authorization() "browser session did not close: {:?}", closed.error ); - broker_task.abort(); + browser.broker_task.abort(); allowed_server.abort(); Ok(()) } From 7060a52f0b3fef318f00add7550b90f8d6734ab3 Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Thu, 22 Oct 2026 22:34:56 +0000 Subject: [PATCH 30/70] test(browser_egress): align broker task handle type with tinybus result The live browser test fixture stored the broker task handle as a JoinHandle<()>, but the spawned task now returns a tinybus::Result<()>. Updating the field type keeps the fixture compiling against the current broker signature. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- .../src/tinybus_module/browser_egress_live_tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs index b4a9854bc..3bd8dc6ff 100644 --- a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs +++ b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs @@ -126,7 +126,7 @@ struct LiveBrowser { session: serde_json::Value, allowed: Arc, observations: Arc>>, - broker_task: tokio::task::JoinHandle<()>, + broker_task: tokio::task::JoinHandle>, } async fn start_browser_with_fixture_host( From ba7663fee4a3752cb7e535d1524841ffd3fbab43 Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Thu, 22 Oct 2026 22:35:53 +0000 Subject: [PATCH 31/70] test(browser): report observations when worker egress times out The live Chromium egress test now captures the timeout result and asserts on it separately, including the collected browser observations in the failure message. This makes a timeout diagnosable instead of surfacing only a bare panic from expect. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- .../src/tinybus_module/browser_egress_live_tests.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs index 3bd8dc6ff..21a389c49 100644 --- a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs +++ b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs @@ -325,7 +325,7 @@ async fn live_chromium_module_routes_worker_egress_through_host_authorization() .await?; let worker_authorization = format!("authorize:fixture-policy:41:127.0.0.2:{denied_port}"); - tokio::time::timeout(Duration::from_secs(10), async { + let worker_authorized = tokio::time::timeout(Duration::from_secs(10), async { loop { if browser .observations @@ -339,8 +339,12 @@ async fn live_chromium_module_routes_worker_egress_through_host_authorization() tokio::time::sleep(Duration::from_millis(10)).await; } }) - .await - .expect("worker request reaches the host egress authorizer"); + .await; + assert!( + worker_authorized.is_ok(), + "worker request reaches the host egress authorizer: {:?}", + browser.observations.lock().unwrap() + ); assert!( tokio::time::timeout(Duration::from_millis(500), denied_listener.accept()) .await From a32341a0f6043098df32d578dd519c29ce7f719c Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Thu, 22 Oct 2026 22:36:33 +0000 Subject: [PATCH 32/70] test(browser): distinguish bypass from unreached host authorization The live egress test previously failed with a single assertion when the worker request did not reach the host authorizer, which could not tell a direct connection bypass apart from the request simply never arriving. The failure path now first checks whether the denied listener accepted a connection and reports a bypass explicitly before panicking. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- .../tinybus_module/browser_egress_live_tests.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs index 21a389c49..7c24e29db 100644 --- a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs +++ b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs @@ -340,11 +340,18 @@ async fn live_chromium_module_routes_worker_egress_through_host_authorization() } }) .await; - assert!( - worker_authorized.is_ok(), - "worker request reaches the host egress authorizer: {:?}", - browser.observations.lock().unwrap() - ); + if worker_authorized.is_err() { + assert!( + tokio::time::timeout(Duration::from_millis(500), denied_listener.accept()) + .await + .is_err(), + "worker request bypassed host authorization and connected directly" + ); + panic!( + "worker request did not reach host authorization: {:?}", + browser.observations.lock().unwrap() + ); + } assert!( tokio::time::timeout(Duration::from_millis(500), denied_listener.accept()) .await From b8fb10e086c22fcf3c80ea858f39852651b41624 Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Thu, 22 Oct 2026 22:37:11 +0000 Subject: [PATCH 33/70] test(browser_egress): keep host connection and module host alive in live fixture The live browser test fixture now stores the host connection and module host alongside the broker task so they are not dropped while the test runs. Without holding these handles the fixture could tear down its host before the browser finished exercising egress, making the live tests flaky. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- .../src/tinybus_module/browser_egress_live_tests.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs index 7c24e29db..da022a32a 100644 --- a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs +++ b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs @@ -127,6 +127,8 @@ struct LiveBrowser { allowed: Arc, observations: Arc>>, broker_task: tokio::task::JoinHandle>, + _host_connection: Connection, + _module_host: ModuleHost, } async fn start_browser_with_fixture_host( @@ -199,6 +201,8 @@ async fn start_browser_with_fixture_host( allowed, observations, broker_task, + _host_connection: host_connection, + _module_host: module_host, }) } From 9080d6cdb3e517ebbd78247df2c886d60d1fb4fa Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Thu, 22 Oct 2026 22:37:49 +0000 Subject: [PATCH 34/70] test(browser_egress): scope observation lock to assertion block The observation mutex guard is now dropped before the subsequent proxy call, so the test no longer holds the lock across an await point. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- .../browser_egress_live_tests.rs | 44 ++++++++++--------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs index da022a32a..1dabed091 100644 --- a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs +++ b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs @@ -262,28 +262,30 @@ async fn live_chromium_module_dials_only_the_host_returned_socket_and_rejects_ch "policy-denied navigation connected to the previously allowed socket" ); - let calls = browser.observations.lock().unwrap(); - assert!( - calls - .iter() - .any(|call| call == &format!("consume:{allowed_address}")), - "host did not consume the exact returned socket: {calls:?}" - ); - let authorizations_after_policy_change = calls - .iter() - .filter(|call| call.starts_with("authorize:fixture-policy:41:fixture.test:")) - .count(); - assert!( - authorizations_after_policy_change > authorizations_before_policy_change, - "the post-change request did not reach the host authorizer: {calls:?}" - ); - let denied_address = denied_listener.local_addr()?.to_string(); - assert!( - !calls + { + let calls = browser.observations.lock().unwrap(); + assert!( + calls + .iter() + .any(|call| call == &format!("consume:{allowed_address}")), + "host did not consume the exact returned socket: {calls:?}" + ); + let authorizations_after_policy_change = calls .iter() - .any(|call| call == &format!("consume:{denied_address}")), - "denied socket was consumed: {calls:?}" - ); + .filter(|call| call.starts_with("authorize:fixture-policy:41:fixture.test:")) + .count(); + assert!( + authorizations_after_policy_change > authorizations_before_policy_change, + "the post-change request did not reach the host authorizer: {calls:?}" + ); + let denied_address = denied_listener.local_addr()?.to_string(); + assert!( + !calls + .iter() + .any(|call| call == &format!("consume:{denied_address}")), + "denied socket was consumed: {calls:?}" + ); + } let closed: DesktopResponse = browser .proxy .call( From 960447afab55263ebe0647ff8f0ff1e10a76750f Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Thu, 22 Oct 2026 22:41:55 +0000 Subject: [PATCH 35/70] test(browser): wait for worker completion before asserting egress The worker egress test now signals completion through a dedicated fixture request instead of relying on a fixed delay, so the assertion that the denied listener stays untouched runs after the worker has actually finished. The fixture also counts allowed connections to confirm only the completion request arrives after navigation. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- .../browser_egress_live_tests.rs | 45 ++++++++++++++++--- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs index 1dabed091..ae98f50ea 100644 --- a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs +++ b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs @@ -93,6 +93,7 @@ async fn serve_fixture( expected: Vec, extra_connections: Arc, served: tokio::sync::oneshot::Sender<()>, + worker_done: Option>, ) { let (mut stream, _) = listener .accept() @@ -110,9 +111,22 @@ async fn serve_fixture( .concat(); let _ = tokio::io::AsyncWriteExt::write_all(&mut stream, &response).await; let _ = served.send(()); - while let Ok((stream, _)) = listener.accept().await { + drop(stream); + let mut worker_done = worker_done; + while let Ok((mut stream, _)) = listener.accept().await { extra_connections.fetch_add(1, Ordering::SeqCst); - drop(stream); + let mut request = [0_u8; 4096]; + let _ = tokio::io::AsyncReadExt::read(&mut stream, &mut request).await; + if String::from_utf8_lossy(&request).contains("GET /worker-done ") { + let _ = tokio::io::AsyncWriteExt::write_all( + &mut stream, + b"HTTP/1.1 200 OK\r\nContent-Length: 0\r\nConnection: close\r\n\r\n", + ) + .await; + if let Some(done) = worker_done.take() { + let _ = done.send(()); + } + } } } @@ -221,6 +235,7 @@ async fn live_chromium_module_dials_only_the_host_returned_socket_and_rejects_ch .to_vec(), extra_allowed_connections.clone(), served_tx, + None, )); let browser = @@ -313,16 +328,19 @@ async fn live_chromium_module_routes_worker_egress_through_host_authorization() let html = format!( "" ) .into_bytes(); let (served_tx, served_rx) = tokio::sync::oneshot::channel(); + let (worker_done_tx, worker_done_rx) = tokio::sync::oneshot::channel(); + let extra_allowed_connections = Arc::new(AtomicUsize::new(0)); let allowed_server = tokio::spawn(serve_fixture( allowed_listener, html, - Arc::new(AtomicUsize::new(0)), + extra_allowed_connections.clone(), served_tx, + Some(worker_done_tx), )); let allowed_address = format!("127.0.0.1:{page_port}"); @@ -358,11 +376,28 @@ async fn live_chromium_module_routes_worker_egress_through_host_authorization() browser.observations.lock().unwrap() ); } + let connections_before_completion = extra_allowed_connections.load(Ordering::SeqCst); + tokio::select! { + done = tokio::time::timeout(Duration::from_secs(10), worker_done_rx) => { + done.expect("worker request completes within ten seconds") + .expect("worker completion fixture receives the done request"); + } + accepted = denied_listener.accept() => { + let (stream, _) = accepted.expect("denied listener remains open"); + drop(stream); + panic!("worker request connected directly to the denied private listener"); + } + } + assert_eq!( + extra_allowed_connections.load(Ordering::SeqCst), + connections_before_completion + 1, + "only the worker completion request reached the allowed fixture after navigation" + ); assert!( tokio::time::timeout(Duration::from_millis(500), denied_listener.accept()) .await .is_err(), - "worker request connected directly to the denied private listener" + "worker request connected directly to the denied private listener after completion" ); let closed: DesktopResponse = browser From c3f56dc2612b078231c640fea1a9ec80078095c6 Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Thu, 22 Oct 2026 22:42:59 +0000 Subject: [PATCH 36/70] test(browser_egress): assert exact allowed connection count The live egress test now asserts that exactly one extra connection reached the allowed fixture after navigation, instead of comparing against a count captured before the worker completed. The captured baseline was redundant and made the assertion harder to read. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- .../src/tinybus_module/browser_egress_live_tests.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs index ae98f50ea..da6dd14f9 100644 --- a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs +++ b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs @@ -376,7 +376,6 @@ async fn live_chromium_module_routes_worker_egress_through_host_authorization() browser.observations.lock().unwrap() ); } - let connections_before_completion = extra_allowed_connections.load(Ordering::SeqCst); tokio::select! { done = tokio::time::timeout(Duration::from_secs(10), worker_done_rx) => { done.expect("worker request completes within ten seconds") @@ -390,7 +389,7 @@ async fn live_chromium_module_routes_worker_egress_through_host_authorization() } assert_eq!( extra_allowed_connections.load(Ordering::SeqCst), - connections_before_completion + 1, + 1, "only the worker completion request reached the allowed fixture after navigation" ); assert!( From eab0940d5a39459d6d04fe933d617d291b9b97a6 Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Thu, 22 Oct 2026 22:47:16 +0000 Subject: [PATCH 37/70] test(browser_egress): split live tests into a module directory The opt-in real-Chromium egress tests were moved out of a single file into a browser_egress_live_tests module with a separate worker file, so the fixture host and worker helpers can be shared and the suite can grow without one oversized file. No test behaviour changes. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- .../mod.rs} | 99 +------------------ .../browser_egress_live_tests/worker.rs | 99 +++++++++++++++++++ crates/tinycomputer/src/tinybus_module/mod.rs | 1 - 3 files changed, 101 insertions(+), 98 deletions(-) rename crates/tinycomputer/src/tinybus_module/{browser_egress_live_tests.rs => browser_egress_live_tests/mod.rs} (75%) create mode 100644 crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/worker.rs diff --git a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/mod.rs similarity index 75% rename from crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs rename to crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/mod.rs index da6dd14f9..955c4ca44 100644 --- a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests.rs +++ b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/mod.rs @@ -1,6 +1,8 @@ //! Opt-in real-Chromium coverage through the loaded `TinyComputer` module. #![allow(clippy::expect_used, clippy::panic, clippy::unwrap_used)] +mod worker; + use std::sync::{ Arc, Mutex, atomic::{AtomicBool, AtomicUsize, Ordering}, @@ -318,100 +320,3 @@ async fn live_chromium_module_dials_only_the_host_returned_socket_and_rejects_ch Ok(()) } -#[tokio::test] -async fn live_chromium_module_routes_worker_egress_through_host_authorization() --> tinybus::Result<()> { - let allowed_listener = tokio::net::TcpListener::bind("127.0.0.1:0").await?; - let page_port = allowed_listener.local_addr()?.port(); - let denied_listener = tokio::net::TcpListener::bind("127.0.0.2:0").await?; - let denied_port = denied_listener.local_addr()?.port(); - let html = format!( - "" - ) - .into_bytes(); - let (served_tx, served_rx) = tokio::sync::oneshot::channel(); - let (worker_done_tx, worker_done_rx) = tokio::sync::oneshot::channel(); - let extra_allowed_connections = Arc::new(AtomicUsize::new(0)); - let allowed_server = tokio::spawn(serve_fixture( - allowed_listener, - html, - extra_allowed_connections.clone(), - served_tx, - Some(worker_done_tx), - )); - - let allowed_address = format!("127.0.0.1:{page_port}"); - let browser = - start_browser_with_fixture_host(allowed_address, page_port, "/worker-fixture", served_rx) - .await?; - - let worker_authorization = format!("authorize:fixture-policy:41:127.0.0.2:{denied_port}"); - let worker_authorized = tokio::time::timeout(Duration::from_secs(10), async { - loop { - if browser - .observations - .lock() - .unwrap() - .iter() - .any(|call| call == &worker_authorization) - { - break; - } - tokio::time::sleep(Duration::from_millis(10)).await; - } - }) - .await; - if worker_authorized.is_err() { - assert!( - tokio::time::timeout(Duration::from_millis(500), denied_listener.accept()) - .await - .is_err(), - "worker request bypassed host authorization and connected directly" - ); - panic!( - "worker request did not reach host authorization: {:?}", - browser.observations.lock().unwrap() - ); - } - tokio::select! { - done = tokio::time::timeout(Duration::from_secs(10), worker_done_rx) => { - done.expect("worker request completes within ten seconds") - .expect("worker completion fixture receives the done request"); - } - accepted = denied_listener.accept() => { - let (stream, _) = accepted.expect("denied listener remains open"); - drop(stream); - panic!("worker request connected directly to the denied private listener"); - } - } - assert_eq!( - extra_allowed_connections.load(Ordering::SeqCst), - 1, - "only the worker completion request reached the allowed fixture after navigation" - ); - assert!( - tokio::time::timeout(Duration::from_millis(500), denied_listener.accept()) - .await - .is_err(), - "worker request connected directly to the denied private listener after completion" - ); - - let closed: DesktopResponse = browser - .proxy - .call( - browser_names::methods::CLOSE_SESSION, - (serde_json::json!({"session": browser.session}),), - ) - .await?; - assert!( - closed.ok, - "browser session did not close: {:?}", - closed.error - ); - browser.broker_task.abort(); - allowed_server.abort(); - Ok(()) -} diff --git a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/worker.rs b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/worker.rs new file mode 100644 index 000000000..4d77c63e1 --- /dev/null +++ b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/worker.rs @@ -0,0 +1,99 @@ +use super::*; + +#[tokio::test] +async fn live_chromium_module_routes_worker_egress_through_host_authorization() +-> tinybus::Result<()> { + let allowed_listener = tokio::net::TcpListener::bind("127.0.0.1:0").await?; + let page_port = allowed_listener.local_addr()?.port(); + let denied_listener = tokio::net::TcpListener::bind("127.0.0.2:0").await?; + let denied_port = denied_listener.local_addr()?.port(); + let html = format!( + "" + ) + .into_bytes(); + let (served_tx, served_rx) = tokio::sync::oneshot::channel(); + let (worker_done_tx, worker_done_rx) = tokio::sync::oneshot::channel(); + let extra_allowed_connections = Arc::new(AtomicUsize::new(0)); + let allowed_server = tokio::spawn(serve_fixture( + allowed_listener, + html, + extra_allowed_connections.clone(), + served_tx, + Some(worker_done_tx), + )); + + let allowed_address = format!("127.0.0.1:{page_port}"); + let browser = + start_browser_with_fixture_host(allowed_address, page_port, "/worker-fixture", served_rx) + .await?; + + let worker_authorization = format!("authorize:fixture-policy:41:127.0.0.2:{denied_port}"); + let worker_authorized = tokio::time::timeout(Duration::from_secs(10), async { + loop { + if browser + .observations + .lock() + .unwrap() + .iter() + .any(|call| call == &worker_authorization) + { + break; + } + tokio::time::sleep(Duration::from_millis(10)).await; + } + }) + .await; + if worker_authorized.is_err() { + assert!( + tokio::time::timeout(Duration::from_millis(500), denied_listener.accept()) + .await + .is_err(), + "worker request bypassed host authorization and connected directly" + ); + panic!( + "worker request did not reach host authorization: {:?}", + browser.observations.lock().unwrap() + ); + } + tokio::select! { + done = tokio::time::timeout(Duration::from_secs(10), worker_done_rx) => { + done.expect("worker request completes within ten seconds") + .expect("worker completion fixture receives the done request"); + } + accepted = denied_listener.accept() => { + let (stream, _) = accepted.expect("denied listener remains open"); + drop(stream); + panic!("worker request connected directly to the denied private listener"); + } + } + assert_eq!( + extra_allowed_connections.load(Ordering::SeqCst), + 1, + "only the worker completion request reached the allowed fixture after navigation" + ); + assert!( + tokio::time::timeout(Duration::from_millis(500), denied_listener.accept()) + .await + .is_err(), + "worker request connected directly to the denied private listener after completion" + ); + + let closed: DesktopResponse = browser + .proxy + .call( + browser_names::methods::CLOSE_SESSION, + (serde_json::json!({"session": browser.session}),), + ) + .await?; + assert!( + closed.ok, + "browser session did not close: {:?}", + closed.error + ); + browser.broker_task.abort(); + allowed_server.abort(); + Ok(()) +} diff --git a/crates/tinycomputer/src/tinybus_module/mod.rs b/crates/tinycomputer/src/tinybus_module/mod.rs index e7e3c93f6..d38baacd2 100644 --- a/crates/tinycomputer/src/tinybus_module/mod.rs +++ b/crates/tinycomputer/src/tinybus_module/mod.rs @@ -111,7 +111,6 @@ tinybus_module::module_export_optional_static! { mod static_link_tests; #[cfg(all(test, feature = "static-link", live_module_browser_egress_tests))] -#[path = "browser_egress_live_tests.rs"] mod browser_egress_live_tests; #[cfg(test)] From b9aa8d6da2c2a72f456deffb8da3894f20747eea Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Thu, 22 Oct 2026 22:47:48 +0000 Subject: [PATCH 38/70] test(browser_egress): remove trailing blank line Drop a stray blank line at the end of the live egress test module so the file ends cleanly after the last test. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- .../src/tinybus_module/browser_egress_live_tests/mod.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/mod.rs b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/mod.rs index 955c4ca44..f6732792e 100644 --- a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/mod.rs +++ b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/mod.rs @@ -319,4 +319,3 @@ async fn live_chromium_module_dials_only_the_host_returned_socket_and_rejects_ch allowed_server.abort(); Ok(()) } - From 37cc9f4fbda57c93644f017f6f23549a9b1d6c29 Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Thu, 22 Oct 2026 22:48:23 +0000 Subject: [PATCH 39/70] test(browser): document opt-in worker egress coverage Co-authored-by: Medulla --- .env.example | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index ae778e276..bb65b9c98 100644 --- a/.env.example +++ b/.env.example @@ -118,6 +118,6 @@ TINYCOMPUTER_LAB_SELF_EMAIL= # TINYCOMPUTER_LIVE_BROWSER=1 # Compile and run the linked browser egress tests against installed Chromium. # TINYCOMPUTER_LIVE_BROWSER_TESTS=1 -# Compile and run TinyComputer's module-path egress test against installed Chromium +# Compile and run TinyComputer's module-path egress tests against installed Chromium # using only local fixture listeners: -# TINYCOMPUTER_LIVE_BROWSER_EGRESS_TESTS=1 cargo test --manifest-path crates/tinycomputer/Cargo.toml -p tinycomputer --lib --features static-link tinybus_module::browser_egress_live_tests::live_chromium_module_dials_only_the_host_returned_socket_and_rejects_changed_policy -- --exact --nocapture +# TINYCOMPUTER_LIVE_BROWSER_EGRESS_TESTS=1 cargo test --manifest-path crates/tinycomputer/Cargo.toml -p tinycomputer --lib --features static-link tinybus_module::browser_egress_live_tests -- --nocapture From 07a77946e34daf78b4a6bfb99a46f4694ef4bd37 Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Fri, 23 Oct 2026 00:14:28 +0000 Subject: [PATCH 40/70] test(browser): cover exact-socket egress pinning in live chromium Add a live test that grants a single authorized socket and asserts Chromium dials only that exact address, with a listener on the same port at a different host left untouched. A small authorizer fixture supplies the pinned grant so the check exercises the real dial path. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- .../src/linked/linked_tests/live_tests.rs | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/crates/tinycomputer-browser/src/linked/linked_tests/live_tests.rs b/crates/tinycomputer-browser/src/linked/linked_tests/live_tests.rs index 085f0214b..4b9486e12 100644 --- a/crates/tinycomputer-browser/src/linked/linked_tests/live_tests.rs +++ b/crates/tinycomputer-browser/src/linked/linked_tests/live_tests.rs @@ -65,6 +65,51 @@ async fn live_chromium_loopback_navigation_uses_the_authenticated_session_proxy( server.await.unwrap(); } +#[tokio::test] +#[cfg(live_browser_tests)] +async fn live_chromium_dials_only_the_exact_host_authorized_socket() { + let allowed = TcpListener::bind("127.0.0.2:0").await.unwrap(); + let allowed_address = allowed.local_addr().unwrap(); + let denied = std::net::TcpListener::bind(("127.0.0.1", allowed_address.port())).unwrap(); + denied.set_nonblocking(true).unwrap(); + + let allowed_server = tokio::spawn(async move { + let (mut socket, _) = allowed.accept().await.unwrap(); + let mut request = [0; 4096]; + let _ = socket.read(&mut request).await.unwrap(); + socket + .write_all( + b"HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length: 26\r\nConnection: close\r\n\r\n

pinned socket fixture

", + ) + .await + .unwrap(); + }); + let mut browser = EnforcedAgentBrowser::new(Arc::new(AuthorizeExactSocket(allowed_address))) + .open("live-egress-socket-pinning"); + let launch = browser + .execute(json!({"id":"launch","action":"launch","headless":true,"args":[]})) + .await; + assert_eq!(launch["success"], true, "{launch}"); + let navigation = browser + .execute(json!({ + "id":"navigate", + "action":"navigate", + "url":format!("http://127.0.0.1:{}/", allowed_address.port()) + })) + .await; + browser + .execute(json!({"id":"close","action":"close"})) + .await; + + assert_eq!(navigation["success"], true, "{navigation}"); + allowed_server.await.unwrap(); + assert_eq!( + denied.accept().unwrap_err().kind(), + io::ErrorKind::WouldBlock, + "Chromium must reach only the exact socket returned by the host grant" + ); +} + #[tokio::test] #[cfg(live_browser_tests)] async fn live_chromium_subresource_never_reaches_a_denied_destination() { @@ -243,6 +288,48 @@ struct RejectAllButFixture { denied_targets: Arc>>, } +#[cfg(live_browser_tests)] +#[derive(Debug)] +struct AuthorizeExactSocket(SocketAddr); + +#[cfg(live_browser_tests)] +impl EgressAuthorizer for AuthorizeExactSocket { + fn authorize( + &self, + _: BrowserDialTarget, + ) -> std::pin::Pin> + Send>> { + let address = self.0; + Box::pin(async move { + Ok(DialGrant { + lease: "live-pinned-socket-lease".into(), + addresses: vec![address], + }) + }) + } + + fn consume( + &self, + _: BrowserDialTarget, + grant: DialGrant, + address: SocketAddr, + ) -> std::pin::Pin> + Send>> { + Box::pin(async move { + if grant.addresses.contains(&address) { + Ok(()) + } else { + Err(io::Error::new(io::ErrorKind::PermissionDenied, "denied")) + } + }) + } + + fn validate( + &self, + _: String, + ) -> std::pin::Pin> + Send>> { + Box::pin(async { Ok(true) }) + } +} + #[cfg(live_browser_tests)] async fn wait_for_denied_target(denied_targets: &Arc>>, port: u16) { tokio::time::timeout(Duration::from_secs(3), async { From 6b0a3c8536cc41ef117bbcadb8deed75cc28965a Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Fri, 23 Oct 2026 00:15:45 +0000 Subject: [PATCH 41/70] test(browser): fix content-length in live socket fixture The fixture response declared a Content-Length of 26 while the body is 30 bytes, so the test server advertised a shorter body than it sent. The header now matches the actual body length. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- .../tinycomputer-browser/src/linked/linked_tests/live_tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/tinycomputer-browser/src/linked/linked_tests/live_tests.rs b/crates/tinycomputer-browser/src/linked/linked_tests/live_tests.rs index 4b9486e12..556a14328 100644 --- a/crates/tinycomputer-browser/src/linked/linked_tests/live_tests.rs +++ b/crates/tinycomputer-browser/src/linked/linked_tests/live_tests.rs @@ -79,7 +79,7 @@ async fn live_chromium_dials_only_the_exact_host_authorized_socket() { let _ = socket.read(&mut request).await.unwrap(); socket .write_all( - b"HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length: 26\r\nConnection: close\r\n\r\n

pinned socket fixture

", + b"HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length: 30\r\nConnection: close\r\n\r\n

pinned socket fixture

", ) .await .unwrap(); From b801cf2bc069416c0c5e9fc7915a761089758cd1 Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Fri, 23 Oct 2026 00:54:07 +0000 Subject: [PATCH 42/70] test(browser): cover proxied redirects and transport classes Co-authored-by: Medulla --- .../browser_egress_live_tests/mod.rs | 1 + .../transport_classes.rs | 151 ++++++++++++++++++ 2 files changed, 152 insertions(+) create mode 100644 crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/transport_classes.rs diff --git a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/mod.rs b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/mod.rs index f6732792e..cd4692c6a 100644 --- a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/mod.rs +++ b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/mod.rs @@ -1,6 +1,7 @@ //! Opt-in real-Chromium coverage through the loaded `TinyComputer` module. #![allow(clippy::expect_used, clippy::panic, clippy::unwrap_used)] +mod transport_classes; mod worker; use std::sync::{ diff --git a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/transport_classes.rs b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/transport_classes.rs new file mode 100644 index 000000000..50e494c07 --- /dev/null +++ b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/transport_classes.rs @@ -0,0 +1,151 @@ +use super::*; + +async fn serve_redirect_fixture( + listener: tokio::net::TcpListener, + port: u16, + served: tokio::sync::oneshot::Sender<()>, + complete: tokio::sync::oneshot::Sender>, +) { + let mut paths = Vec::new(); + let mut served = Some(served); + loop { + let Ok((mut stream, _)) = listener.accept().await else { + return; + }; + let mut request = Vec::new(); + let mut chunk = [0_u8; 1024]; + loop { + let Ok(Ok(read)) = tokio::time::timeout( + Duration::from_secs(5), + tokio::io::AsyncReadExt::read(&mut stream, &mut chunk), + ) + .await + else { + return; + }; + if read == 0 { + return; + } + request.extend_from_slice(&chunk[..read]); + if request.windows(4).any(|window| window == b"\r\n\r\n") { + break; + } + } + let request = String::from_utf8_lossy(&request); + let Some(target) = request + .lines() + .next() + .and_then(|line| line.split_ascii_whitespace().nth(1)) + else { + return; + }; + let path = url::Url::parse(target) + .map(|url| url.path().to_owned()) + .unwrap_or_else(|_| target.to_owned()); + paths.push(path.clone()); + let response = match path.as_str() { + "/redirect" => format!( + "HTTP/1.1 302 Found\r\nLocation: http://fixture.test:{port}/page\r\nConnection: close\r\nContent-Length: 0\r\n\r\n" + ), + "/page" => { + let html = format!( + "" + ); + format!( + "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length: {}\r\nConnection: close\r\n\r\n{html}", + html.len() + ) + } + "/pixel" => { + "HTTP/1.1 204 No Content\r\nConnection: close\r\nContent-Length: 0\r\n\r\n".into() + } + // The test only needs to prove that Chromium's websocket handshake + // reaches the upstream through the authorizing proxy. The fixture + // refuses the handshake after observing the request. + "/socket" => { + "HTTP/1.1 403 Forbidden\r\nConnection: close\r\nContent-Length: 0\r\n\r\n".into() + } + _ => "HTTP/1.1 404 Not Found\r\nConnection: close\r\nContent-Length: 0\r\n\r\n".into(), + }; + if tokio::io::AsyncWriteExt::write_all(&mut stream, response.as_bytes()) + .await + .is_err() + { + return; + } + if path == "/page" { + if let Some(served) = served.take() { + let _ = served.send(()); + } + } + if ["/redirect", "/page", "/pixel", "/socket"] + .iter() + .all(|expected| paths.iter().any(|path| path == expected)) + { + let _ = complete.send(paths); + return; + } + } +} + +#[tokio::test] +async fn live_chromium_redirect_subresource_and_websocket_requests_use_host_authorization() +-> tinybus::Result<()> { + let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await?; + let port = listener.local_addr()?.port(); + let allowed_address = listener.local_addr()?.to_string(); + let (complete_tx, complete_rx) = tokio::sync::oneshot::channel(); + let (served_tx, served_rx) = tokio::sync::oneshot::channel(); + let fixture = tokio::spawn(serve_redirect_fixture( + listener, + port, + served_tx, + complete_tx, + )); + let browser = + start_browser_with_fixture_host(allowed_address, port, "/redirect", served_rx).await?; + let paths = tokio::time::timeout(Duration::from_secs(10), complete_rx) + .await + .expect("redirect, page, subresource and websocket reach the fixture") + .expect("fixture reports observed browser requests"); + let observations = browser.observations.lock().unwrap(); + let authorize_count = observations + .iter() + .filter(|call| call.starts_with("authorize:fixture-policy:41:fixture.test:")) + .count(); + let consume_count = observations + .iter() + .filter(|call| call.starts_with("consume:")) + .count(); + assert!( + authorize_count >= 4, + "each redirect, document, subresource and websocket must be authorized: {observations:?}" + ); + assert!( + consume_count >= 4, + "each browser transport request must consume a socket grant: {observations:?}" + ); + for expected in ["/redirect", "/page", "/pixel", "/socket"] { + assert!( + paths.iter().any(|path| path == expected), + "missing {expected}: {paths:?}" + ); + } + drop(observations); + + let closed: DesktopResponse = browser + .proxy + .call( + browser_names::methods::CLOSE_SESSION, + (serde_json::json!({"session": browser.session}),), + ) + .await?; + assert!( + closed.ok, + "browser session did not close: {:?}", + closed.error + ); + browser.broker_task.abort(); + fixture.abort(); + Ok(()) +} From 20424fb8fb549285f855cc7bc3d78ddd13d54f97 Mon Sep 17 00:00:00 2001 From: M3gA-Mind Date: Fri, 23 Oct 2026 07:18:08 +0530 Subject: [PATCH 43/70] test(consequence): a host denial turns a service-level approval into a decline Pins review_approval at the service: a task paused at NeedsApproval, approved over ContinueTask, is declined when the host's consequence review denies it; the host is asked once and no run is allowed to act. --- .../tinybus_module/tinybus_module_tests.rs | 1 + .../consequence_review_tests.rs | 157 ++++++++++++++++++ 2 files changed, 158 insertions(+) create mode 100644 crates/tinycomputer/src/tinybus_module/tinybus_module_tests/consequence_review_tests.rs diff --git a/crates/tinycomputer/src/tinybus_module/tinybus_module_tests.rs b/crates/tinycomputer/src/tinybus_module/tinybus_module_tests.rs index a59f84a71..b2d4fda1b 100644 --- a/crates/tinycomputer/src/tinybus_module/tinybus_module_tests.rs +++ b/crates/tinycomputer/src/tinybus_module/tinybus_module_tests.rs @@ -12,6 +12,7 @@ use serde_json::json; mod browser_tests; mod config_tests; +mod consequence_review_tests; mod manifest_tests; mod tasks_tests; mod wire_tests; diff --git a/crates/tinycomputer/src/tinybus_module/tinybus_module_tests/consequence_review_tests.rs b/crates/tinycomputer/src/tinybus_module/tinybus_module_tests/consequence_review_tests.rs new file mode 100644 index 000000000..14139e5a1 --- /dev/null +++ b/crates/tinycomputer/src/tinybus_module/tinybus_module_tests/consequence_review_tests.rs @@ -0,0 +1,157 @@ +//! The host's consequence review, at the service: an approval the host +//! denies reaches the task as a decline. + +use std::collections::VecDeque; +use std::sync::{Arc, Mutex}; + +use serde_json::json; +use tinybus::Interface; +use tinycomputer_bus::agent::{AgentResponse, TaskConstraints, TaskId, TaskStatus, TaskView}; +use tinycomputer_bus::consequence_host::{ReviewActionRequest, ReviewActionResponse}; +use tinycomputer_bus::{ + DesktopResponse, FlowRunResult, FlowStopReason, JevMetrics, JevTarget, RunFlowRequest, + StepOutcome, StepReport, names, +}; +use tinycomputer_engine::{FlowFuture, FlowRunner, Tasks}; + +use super::service; +use crate::tinybus_module::consequence_gate::{ConsequencePort, PortFuture}; + +/// A runner whose first flow stops before pressing "Send", and every later +/// one completes. It records whether each run was allowed to act. +#[derive(Default)] +struct GatedOnce { + replies: Mutex>, + allowed: Mutex>, +} + +fn run(stop: FlowStopReason, steps: Vec, pending: Option<&str>) -> FlowRunResult { + FlowRunResult { + stop, + steps, + vars: Default::default(), + pending: pending.map(|name| JevTarget { + ref_id: "e9".to_owned(), + role: "button".to_owned(), + name: Some(name.to_owned()), + }), + learned: Vec::new(), + actions: 1, + metrics: JevMetrics::default(), + trace: Vec::new(), + dialog_left_open: false, + } +} + +impl FlowRunner for GatedOnce { + fn run(&self, _: &TaskId, _: &TaskConstraints, request: RunFlowRequest) -> FlowFuture { + self.allowed.lock().unwrap().push(request.allow_destructive); + let result = self + .replies + .lock() + .unwrap() + .pop_front() + .unwrap_or_else(|| run(FlowStopReason::Completed, Vec::new(), None)); + let reply = DesktopResponse::ok("run-flow", serde_json::to_value(result).unwrap()); + Box::pin(async move { reply }) + } +} + +#[derive(Debug, Default)] +struct DenyingHost { + seen: Mutex>, +} + +impl ConsequencePort for Arc { + fn review(&self, request: ReviewActionRequest) -> PortFuture<'_, ReviewActionResponse> { + self.seen.lock().unwrap().push(request); + Box::pin(async { + Ok(ReviewActionResponse { + allow: false, + reason: Some("not today".to_owned()), + }) + }) + } +} + +async fn awaited(service: &crate::tinybus_module::DesktopService, id: &TaskId) -> TaskView { + let settled = service + .call( + &names::methods::AWAIT_TASK.try_into().unwrap(), + json!([{"id": id, "timeout_ms": 5_000}]), + ) + .await + .unwrap(); + serde_json::from_value::>(settled) + .unwrap() + .data + .unwrap() +} + +#[tokio::test] +async fn a_host_denial_turns_an_approval_into_a_decline() { + let runner = Arc::new(GatedOnce::default()); + runner.replies.lock().unwrap().push_back(run( + FlowStopReason::StoppedBeforeDestructive, + vec![StepReport { + path: "1".to_owned(), + kind: "stop_before".to_owned(), + text: "sending the email".to_owned(), + outcome: StepOutcome::Gated, + turns: 1, + jev_calls: 1, + actions: Vec::new(), + loops: Vec::new(), + confidence: None, + note: "found it".to_owned(), + }], + Some("Send"), + )); + let host = Arc::new(DenyingHost::default()); + let mut service = service().with_consequence_review(Box::new(host.clone())); + service.tasks = Arc::new(Tasks::new(runner.clone())); + + let started = service + .call( + &names::methods::START_TASK.try_into().unwrap(), + json!([{"flow": {"app": "Mail", "steps": [ + {"stop_before": "sending the email"}, + "start another email message" + ]}}]), + ) + .await + .unwrap(); + let id = serde_json::from_value::>(started) + .unwrap() + .data + .unwrap() + .id; + let paused = awaited(&service, &id).await; + assert!( + matches!(paused.status, TaskStatus::NeedsApproval { ref target, .. } if target == "Send"), + "{:?}", + paused.status + ); + + service + .call( + &names::methods::CONTINUE_TASK.try_into().unwrap(), + json!([{"id": id, "approve": true}]), + ) + .await + .unwrap(); + + assert_eq!(awaited(&service, &id).await.status, TaskStatus::Cancelled); + let seen = host.seen.lock().unwrap(); + assert_eq!(seen.len(), 1, "the host is asked once"); + assert_eq!(seen[0].target, "Send"); + assert!( + !runner + .allowed + .lock() + .unwrap() + .iter() + .any(|allowed| *allowed), + "no run was allowed to take the denied action" + ); +} From afdf9be26189c16bd48c78730b60e9868fedba22 Mon Sep 17 00:00:00 2001 From: M3gA-Mind Date: Fri, 23 Oct 2026 07:18:08 +0530 Subject: [PATCH 44/70] fix(browser): classify page script errors before keyword matches An evaluation error's text comes from the page, so a script that throws "TimeoutError" or quotes the allowed-domains refusal was classified as a retryable timeout or a policy block. Check the evaluation-error prefix right after the stale-ref prefixes, before any substring match. --- crates/tinycomputer-browser/src/reply/mod.rs | 8 +++++--- .../src/reply/reply_tests.rs | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/crates/tinycomputer-browser/src/reply/mod.rs b/crates/tinycomputer-browser/src/reply/mod.rs index 2eaeb95c1..ba633429d 100644 --- a/crates/tinycomputer-browser/src/reply/mod.rs +++ b/crates/tinycomputer-browser/src/reply/mod.rs @@ -44,6 +44,11 @@ pub(crate) fn classify(message: &str) -> Error { reference: message.to_owned(), }; } + // A script error carries text the page controls, so it is classified + // before any keyword below can read that text as a timeout or a refusal. + if lower.starts_with("evaluation error") { + return Error::page(message); + } if lower.contains("is not in the allowed domains list") { return Error::BlockedByPolicy { url: quoted(message).unwrap_or(message).to_owned(), @@ -93,9 +98,6 @@ pub(crate) fn classify(message: &str) -> Error { if lower.contains("dialog is blocking the page") { return Error::not_actionable(message); } - if lower.starts_with("evaluation error") { - return Error::page(message); - } Error::failed(message) } diff --git a/crates/tinycomputer-browser/src/reply/reply_tests.rs b/crates/tinycomputer-browser/src/reply/reply_tests.rs index 60ee68164..acd6089b3 100644 --- a/crates/tinycomputer-browser/src/reply/reply_tests.rs +++ b/crates/tinycomputer-browser/src/reply/reply_tests.rs @@ -113,6 +113,23 @@ fn engine_messages_map_to_what_the_caller_should_do() { } } +#[test] +fn page_script_error_text_cannot_change_the_error_class() { + for message in [ + "Evaluation error: TimeoutError: slow", + "Evaluation error: Error: Domain 'x' is not in the allowed domains list", + "Evaluation error: Error: Element not found: #pay", + "Evaluation error: Error: Browser not launched", + "Evaluation error: Error: Invalid URL: nope", + ] { + let error = classify(message); + assert!( + matches!(error, Error::PageError { .. }), + "{message} became {error:?}" + ); + } +} + #[test] fn a_snapshot_lists_refs_in_document_order_and_caps_the_tree() { let reply = json!({ From 2fa02ac54003db80bc81f80deac673960000a894 Mon Sep 17 00:00:00 2001 From: M3gA-Mind Date: Fri, 23 Oct 2026 07:18:08 +0530 Subject: [PATCH 45/70] test(accessibility): helper cache dir and reply-id matching Split private_cache_dir into a wrapper over private_cache_dir_in(temp_dir) and the reply-wait loop into await_reply(rx, id, timeout), with no behaviour change, so both can be tested: a symlinked cache dir and a group-writable temp dir are refused, an existing dir is reused and made 0700, and only the line carrying the request id answers it. --- .../tinycomputer-accessibility/src/helper.rs | 15 ++++- .../src/helper/process.rs | 37 +++++++++--- .../src/helper/process_tests.rs | 54 +++++++++++++++++ .../src/helper_tests.rs | 59 ++++++++++++++++++- 4 files changed, 153 insertions(+), 12 deletions(-) create mode 100644 crates/tinycomputer-accessibility/src/helper/process_tests.rs diff --git a/crates/tinycomputer-accessibility/src/helper.rs b/crates/tinycomputer-accessibility/src/helper.rs index 5f712b4fb..f45da9950 100644 --- a/crates/tinycomputer-accessibility/src/helper.rs +++ b/crates/tinycomputer-accessibility/src/helper.rs @@ -32,11 +32,20 @@ mod swift_source; #[cfg(target_os = "macos")] pub(crate) fn private_cache_dir(name: &str) -> Result { - use std::os::unix::fs::{MetadataExt, PermissionsExt}; - let temp_dir = std::fs::canonicalize(std::env::temp_dir()) .map_err(|error| format!("failed to resolve temporary directory: {error}"))?; - let temp_metadata = std::fs::symlink_metadata(&temp_dir) + private_cache_dir_in(&temp_dir, name) +} + +/// [`private_cache_dir`] under `temp_dir`, an already-resolved directory. +#[cfg(target_os = "macos")] +fn private_cache_dir_in( + temp_dir: &std::path::Path, + name: &str, +) -> Result { + use std::os::unix::fs::{MetadataExt, PermissionsExt}; + + let temp_metadata = std::fs::symlink_metadata(temp_dir) .map_err(|error| format!("failed to inspect temporary directory: {error}"))?; if !temp_metadata.is_dir() || temp_metadata.mode() & 0o077 != 0 diff --git a/crates/tinycomputer-accessibility/src/helper/process.rs b/crates/tinycomputer-accessibility/src/helper/process.rs index 77caef784..cf1d05476 100644 --- a/crates/tinycomputer-accessibility/src/helper/process.rs +++ b/crates/tinycomputer-accessibility/src/helper/process.rs @@ -105,18 +105,35 @@ pub(crate) fn helper_send_receive( } // UNIFIED_HELPER released here — fire-and-forget callers can proceed // Read until the line matches `id` (discards stale lines after a timeout or reordering). - let deadline = Instant::now() + HELPER_RECV_TIMEOUT; + match await_reply(&RESPONSE_RX, &id_str, HELPER_RECV_TIMEOUT)? { + Some(value) => Ok(value), + None => { + reset_helper_process(); + Err(format!( + "helper response timed out waiting for id {id_str} (stale lines may follow)" + )) + } + } +} + +/// Reads lines from the helper's reply channel until one carries `id_str`, +/// discarding blank, stale, and unnumbered lines. `None` when `timeout` +/// passes first. +#[cfg(target_os = "macos")] +fn await_reply( + rx_slot: &StdMutex>>, + id_str: &str, + timeout: Duration, +) -> Result, String> { + let deadline = Instant::now() + timeout; loop { let remaining = deadline.saturating_duration_since(Instant::now()); if remaining.is_zero() { - reset_helper_process(); - return Err(format!( - "helper response timed out waiting for id {id_str} (stale lines may follow)" - )); + return Ok(None); } let chunk = remaining.min(Duration::from_millis(500)); let response_line = { - let rx_guard = RESPONSE_RX + let rx_guard = rx_slot .lock() .map_err(|_| "response rx lock poisoned".to_string())?; let rx = rx_guard @@ -148,9 +165,9 @@ pub(crate) fn helper_send_receive( let matches = value .get("id") .and_then(|v| v.as_str()) - .is_some_and(|rid| rid == id_str.as_str()); + .is_some_and(|rid| rid == id_str); if matches { - return Ok(value); + return Ok(Some(value)); } log::debug!( "[accessibility] discarding helper response with mismatched or missing id (want id={id_str})" @@ -397,3 +414,7 @@ fn ensure_helper_binary() -> Result { Ok(binary_path) } + +#[cfg(test)] +#[path = "process_tests.rs"] +mod tests; diff --git a/crates/tinycomputer-accessibility/src/helper/process_tests.rs b/crates/tinycomputer-accessibility/src/helper/process_tests.rs new file mode 100644 index 000000000..ad11dc099 --- /dev/null +++ b/crates/tinycomputer-accessibility/src/helper/process_tests.rs @@ -0,0 +1,54 @@ +//! The helper reply wait: only the line carrying the request's id answers it. + +#![cfg(target_os = "macos")] +#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)] + +use std::sync::{Mutex as StdMutex, mpsc}; +use std::time::Duration; + +use super::await_reply; + +/// A reply channel holding `lines`. Keep the sender alive so an empty +/// channel times out instead of disconnecting. +fn channel( + lines: &[&str], +) -> ( + mpsc::Sender, + StdMutex>>, +) { + let (tx, rx) = mpsc::channel(); + for line in lines { + tx.send((*line).to_owned()).unwrap(); + } + (tx, StdMutex::new(Some(rx))) +} + +#[test] +fn stale_blank_and_unnumbered_lines_are_skipped_until_the_id_matches() { + let (_tx, rx) = channel(&[ + r#"{"id":"6","ok":"stale"}"#, + " ", + r#"{"ok":"no id"}"#, + r#"{"id":"7","ok":"mine"}"#, + ]); + let reply = await_reply(&rx, "7", Duration::from_secs(1)) + .unwrap() + .unwrap(); + assert_eq!(reply["ok"], "mine"); +} + +#[test] +fn no_matching_reply_before_the_timeout_is_none() { + let (_tx, rx) = channel(&[r#"{"id":"6"}"#]); + assert!( + await_reply(&rx, "7", Duration::from_millis(50)) + .unwrap() + .is_none() + ); +} + +#[test] +fn a_reply_that_is_not_json_is_an_error() { + let (_tx, rx) = channel(&["not json"]); + assert!(await_reply(&rx, "7", Duration::from_secs(1)).is_err()); +} diff --git a/crates/tinycomputer-accessibility/src/helper_tests.rs b/crates/tinycomputer-accessibility/src/helper_tests.rs index 85556b863..05b050cc9 100644 --- a/crates/tinycomputer-accessibility/src/helper_tests.rs +++ b/crates/tinycomputer-accessibility/src/helper_tests.rs @@ -1,7 +1,64 @@ -//! Tests for the platform-independent entry points of the Swift helper module. +//! Tests for the platform-independent entry points of the Swift helper module, +//! and the macOS helper cache directory. #[cfg(not(target_os = "macos"))] #[test] fn precompile_entry_point_is_a_noop_off_macos() { super::precompile_helper_background(); } + +#[cfg(target_os = "macos")] +mod cache_dir { + #![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)] + + use std::os::unix::fs::PermissionsExt; + + use super::super::private_cache_dir_in; + + /// A resolved temporary directory private to its owner. + fn private_temp() -> (tempfile::TempDir, std::path::PathBuf) { + let temp = tempfile::tempdir().unwrap(); + let path = std::fs::canonicalize(temp.path()).unwrap(); + std::fs::set_permissions(&path, std::fs::Permissions::from_mode(0o700)).unwrap(); + (temp, path) + } + + fn mode(path: &std::path::Path) -> u32 { + std::fs::metadata(path).unwrap().permissions().mode() & 0o777 + } + + #[test] + fn a_new_cache_dir_is_created_owner_only() { + let (_temp, root) = private_temp(); + let dir = private_cache_dir_in(&root, "helper").unwrap(); + assert_eq!(dir, root.join("helper")); + assert_eq!(mode(&dir), 0o700); + } + + #[test] + fn an_existing_own_cache_dir_is_reused_and_made_owner_only() { + let (_temp, root) = private_temp(); + let existing = root.join("helper"); + std::fs::create_dir(&existing).unwrap(); + std::fs::set_permissions(&existing, std::fs::Permissions::from_mode(0o755)).unwrap(); + assert_eq!(private_cache_dir_in(&root, "helper").unwrap(), existing); + assert_eq!(mode(&existing), 0o700); + } + + #[test] + fn a_symlinked_cache_dir_is_refused() { + let (_temp, root) = private_temp(); + let elsewhere = root.join("elsewhere"); + std::fs::create_dir(&elsewhere).unwrap(); + std::os::unix::fs::symlink(&elsewhere, root.join("helper")).unwrap(); + assert!(private_cache_dir_in(&root, "helper").is_err()); + } + + #[test] + fn a_temp_dir_others_can_write_is_refused() { + let (_temp, root) = private_temp(); + std::fs::set_permissions(&root, std::fs::Permissions::from_mode(0o770)).unwrap(); + assert!(private_cache_dir_in(&root, "helper").is_err()); + assert!(!root.join("helper").exists(), "nothing is created there"); + } +} From 129fc448c69c5b903b46aca07f7138ad5965e93e Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Fri, 23 Oct 2026 02:00:09 +0000 Subject: [PATCH 46/70] test(browser): correlate each transport authorization Co-authored-by: Medulla --- .../browser_egress_live_tests/mod.rs | 35 ++-- .../transport_classes.rs | 151 --------------- .../transport_classes_tests.rs | 178 ++++++++++++++++++ 3 files changed, 201 insertions(+), 163 deletions(-) delete mode 100644 crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/transport_classes.rs create mode 100644 crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/transport_classes_tests.rs diff --git a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/mod.rs b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/mod.rs index cd4692c6a..efc61a821 100644 --- a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/mod.rs +++ b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/mod.rs @@ -1,7 +1,7 @@ //! Opt-in real-Chromium coverage through the loaded `TinyComputer` module. #![allow(clippy::expect_used, clippy::panic, clippy::unwrap_used)] -mod transport_classes; +mod transport_classes_tests; mod worker; use std::sync::{ @@ -24,7 +24,7 @@ use tinycomputer_bus::{ #[derive(Clone)] struct EgressHost { allowed: Arc, - allowed_address: String, + allowed_addresses: Vec, observations: Arc>>, } @@ -32,15 +32,16 @@ struct EgressHost { impl EgressHost { async fn authorize(&self, request: BrowserEgressTarget) -> tinybus::Result { tokio::task::yield_now().await; + let allowed_address = self.allowed_addresses.iter().find(|address| { + address + .rsplit(':') + .next() + .and_then(|port| port.parse::().ok()) + == Some(request.port) + }); let allow = self.allowed.load(Ordering::SeqCst) && request.hostname == "fixture.test" - && request.port - == self - .allowed_address - .rsplit(':') - .next() - .and_then(|port| port.parse::().ok()) - .unwrap_or_default(); + && allowed_address.is_some(); self.observations.lock().unwrap().push(format!( "authorize:{}:{}:{}:{}", request.policy_id, request.expected_generation, request.hostname, request.port @@ -54,7 +55,7 @@ impl EgressHost { } .into(), addresses: if allow { - vec![self.allowed_address.clone()] + allowed_address.cloned().into_iter().collect() } else { Vec::new() }, @@ -71,7 +72,8 @@ impl EgressHost { .unwrap() .push(format!("consume:{}", request.address)); Ok(BrowserEgressDecision { - allowed: self.allowed.load(Ordering::SeqCst) && request.address == self.allowed_address, + allowed: self.allowed.load(Ordering::SeqCst) + && self.allowed_addresses.contains(&request.address), }) } @@ -153,6 +155,15 @@ async fn start_browser_with_fixture_host( page_port: u16, page_path: &str, served: tokio::sync::oneshot::Receiver<()>, +) -> tinybus::Result { + start_browser_with_fixture_hosts(vec![allowed_address], page_port, page_path, served).await +} + +async fn start_browser_with_fixture_hosts( + allowed_addresses: Vec, + page_port: u16, + page_path: &str, + served: tokio::sync::oneshot::Receiver<()>, ) -> tinybus::Result { let bus = MemoryBus::new(); let broker = Broker::new(); @@ -165,7 +176,7 @@ async fn start_browser_with_fixture_host( browser_egress::OBJECT_PATH.try_into()?, EgressHost { allowed: allowed.clone(), - allowed_address, + allowed_addresses, observations: observations.clone(), }, ) diff --git a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/transport_classes.rs b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/transport_classes.rs deleted file mode 100644 index 50e494c07..000000000 --- a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/transport_classes.rs +++ /dev/null @@ -1,151 +0,0 @@ -use super::*; - -async fn serve_redirect_fixture( - listener: tokio::net::TcpListener, - port: u16, - served: tokio::sync::oneshot::Sender<()>, - complete: tokio::sync::oneshot::Sender>, -) { - let mut paths = Vec::new(); - let mut served = Some(served); - loop { - let Ok((mut stream, _)) = listener.accept().await else { - return; - }; - let mut request = Vec::new(); - let mut chunk = [0_u8; 1024]; - loop { - let Ok(Ok(read)) = tokio::time::timeout( - Duration::from_secs(5), - tokio::io::AsyncReadExt::read(&mut stream, &mut chunk), - ) - .await - else { - return; - }; - if read == 0 { - return; - } - request.extend_from_slice(&chunk[..read]); - if request.windows(4).any(|window| window == b"\r\n\r\n") { - break; - } - } - let request = String::from_utf8_lossy(&request); - let Some(target) = request - .lines() - .next() - .and_then(|line| line.split_ascii_whitespace().nth(1)) - else { - return; - }; - let path = url::Url::parse(target) - .map(|url| url.path().to_owned()) - .unwrap_or_else(|_| target.to_owned()); - paths.push(path.clone()); - let response = match path.as_str() { - "/redirect" => format!( - "HTTP/1.1 302 Found\r\nLocation: http://fixture.test:{port}/page\r\nConnection: close\r\nContent-Length: 0\r\n\r\n" - ), - "/page" => { - let html = format!( - "" - ); - format!( - "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length: {}\r\nConnection: close\r\n\r\n{html}", - html.len() - ) - } - "/pixel" => { - "HTTP/1.1 204 No Content\r\nConnection: close\r\nContent-Length: 0\r\n\r\n".into() - } - // The test only needs to prove that Chromium's websocket handshake - // reaches the upstream through the authorizing proxy. The fixture - // refuses the handshake after observing the request. - "/socket" => { - "HTTP/1.1 403 Forbidden\r\nConnection: close\r\nContent-Length: 0\r\n\r\n".into() - } - _ => "HTTP/1.1 404 Not Found\r\nConnection: close\r\nContent-Length: 0\r\n\r\n".into(), - }; - if tokio::io::AsyncWriteExt::write_all(&mut stream, response.as_bytes()) - .await - .is_err() - { - return; - } - if path == "/page" { - if let Some(served) = served.take() { - let _ = served.send(()); - } - } - if ["/redirect", "/page", "/pixel", "/socket"] - .iter() - .all(|expected| paths.iter().any(|path| path == expected)) - { - let _ = complete.send(paths); - return; - } - } -} - -#[tokio::test] -async fn live_chromium_redirect_subresource_and_websocket_requests_use_host_authorization() --> tinybus::Result<()> { - let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await?; - let port = listener.local_addr()?.port(); - let allowed_address = listener.local_addr()?.to_string(); - let (complete_tx, complete_rx) = tokio::sync::oneshot::channel(); - let (served_tx, served_rx) = tokio::sync::oneshot::channel(); - let fixture = tokio::spawn(serve_redirect_fixture( - listener, - port, - served_tx, - complete_tx, - )); - let browser = - start_browser_with_fixture_host(allowed_address, port, "/redirect", served_rx).await?; - let paths = tokio::time::timeout(Duration::from_secs(10), complete_rx) - .await - .expect("redirect, page, subresource and websocket reach the fixture") - .expect("fixture reports observed browser requests"); - let observations = browser.observations.lock().unwrap(); - let authorize_count = observations - .iter() - .filter(|call| call.starts_with("authorize:fixture-policy:41:fixture.test:")) - .count(); - let consume_count = observations - .iter() - .filter(|call| call.starts_with("consume:")) - .count(); - assert!( - authorize_count >= 4, - "each redirect, document, subresource and websocket must be authorized: {observations:?}" - ); - assert!( - consume_count >= 4, - "each browser transport request must consume a socket grant: {observations:?}" - ); - for expected in ["/redirect", "/page", "/pixel", "/socket"] { - assert!( - paths.iter().any(|path| path == expected), - "missing {expected}: {paths:?}" - ); - } - drop(observations); - - let closed: DesktopResponse = browser - .proxy - .call( - browser_names::methods::CLOSE_SESSION, - (serde_json::json!({"session": browser.session}),), - ) - .await?; - assert!( - closed.ok, - "browser session did not close: {:?}", - closed.error - ); - browser.broker_task.abort(); - fixture.abort(); - Ok(()) -} diff --git a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/transport_classes_tests.rs b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/transport_classes_tests.rs new file mode 100644 index 000000000..babfaadb7 --- /dev/null +++ b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/transport_classes_tests.rs @@ -0,0 +1,178 @@ +use super::*; + +async fn serve_once( + listener: tokio::net::TcpListener, + expected_path: &'static str, + response: String, + served: Option>, + completed: tokio::sync::mpsc::Sender<&'static str>, +) { + let (mut stream, _) = listener + .accept() + .await + .expect("authorized Chromium socket arrives"); + let mut request = Vec::new(); + let mut chunk = [0_u8; 1024]; + loop { + let Ok(Ok(read)) = tokio::time::timeout( + Duration::from_secs(5), + tokio::io::AsyncReadExt::read(&mut stream, &mut chunk), + ) + .await + else { + panic!("browser request timed out"); + }; + if read == 0 { + panic!("browser closed before sending a complete request"); + } + request.extend_from_slice(&chunk[..read]); + if request.windows(4).any(|window| window == b"\r\n\r\n") { + break; + } + } + let request = String::from_utf8_lossy(&request); + let target = request + .lines() + .next() + .and_then(|line| line.split_ascii_whitespace().nth(1)) + .expect("browser request has a target"); + let path = url::Url::parse(target) + .map(|url| url.path().to_owned()) + .unwrap_or_else(|_| target.to_owned()); + assert_eq!(path, expected_path); + tokio::io::AsyncWriteExt::write_all(&mut stream, response.as_bytes()) + .await + .expect("fixture response is written"); + if let Some(served) = served { + let _ = served.send(()); + } + let _ = completed.send(expected_path).await; +} + +fn fixture_response(status: &str, headers: &str, body: &str) -> String { + format!( + "HTTP/1.1 {status}\r\n{headers}Connection: close\r\nContent-Length: {}\r\n\r\n{body}", + body.len() + ) +} + +#[tokio::test] +async fn live_chromium_redirect_subresource_and_websocket_requests_use_host_authorization() +-> tinybus::Result<()> { + let redirect_listener = tokio::net::TcpListener::bind("127.0.0.1:0").await?; + let page_listener = tokio::net::TcpListener::bind("127.0.0.1:0").await?; + let pixel_listener = tokio::net::TcpListener::bind("127.0.0.1:0").await?; + let socket_listener = tokio::net::TcpListener::bind("127.0.0.1:0").await?; + let redirect_address = redirect_listener.local_addr()?.to_string(); + let page_address = page_listener.local_addr()?.to_string(); + let pixel_address = pixel_listener.local_addr()?.to_string(); + let socket_address = socket_listener.local_addr()?.to_string(); + let redirect_port = redirect_listener.local_addr()?.port(); + let page_port = page_listener.local_addr()?.port(); + let pixel_port = pixel_listener.local_addr()?.port(); + let socket_port = socket_listener.local_addr()?.port(); + + let (served_tx, served_rx) = tokio::sync::oneshot::channel(); + let (completed_tx, mut completed_rx) = tokio::sync::mpsc::channel(4); + let redirect = tokio::spawn(serve_once( + redirect_listener, + "/redirect", + fixture_response( + "302 Found", + &format!("Location: http://fixture.test:{page_port}/page\r\n"), + "", + ), + None, + completed_tx.clone(), + )); + let html = format!( + "" + ); + let page = tokio::spawn(serve_once( + page_listener, + "/page", + fixture_response("200 OK", "Content-Type: text/html\r\n", &html), + Some(served_tx), + completed_tx.clone(), + )); + let pixel = tokio::spawn(serve_once( + pixel_listener, + "/pixel", + fixture_response("204 No Content", "", ""), + None, + completed_tx.clone(), + )); + let socket = tokio::spawn(serve_once( + socket_listener, + "/socket", + fixture_response("403 Forbidden", "", ""), + None, + completed_tx.clone(), + )); + drop(completed_tx); + + let browser = start_browser_with_fixture_hosts( + vec![ + redirect_address.clone(), + page_address.clone(), + pixel_address.clone(), + socket_address.clone(), + ], + redirect_port, + "/redirect", + served_rx, + ) + .await?; + let mut paths = Vec::new(); + for _ in 0..4 { + paths.push( + tokio::time::timeout(Duration::from_secs(10), completed_rx.recv()) + .await + .expect("each transport request reaches its fixture listener") + .expect("fixture reports every observed request"), + ); + } + paths.sort_unstable(); + assert_eq!(paths, ["/page", "/pixel", "/redirect", "/socket"]); + + let observations = browser.observations.lock().unwrap(); + for port in [redirect_port, page_port, pixel_port, socket_port] { + let authorization = format!("authorize:fixture-policy:41:fixture.test:{port}"); + assert!( + observations.iter().any(|call| call == &authorization), + "transport destination on port {port} did not reach host authorization: {observations:?}" + ); + } + for address in [ + &redirect_address, + &page_address, + &pixel_address, + &socket_address, + ] { + let consumption = format!("consume:{address}"); + assert!( + observations.iter().any(|call| call == &consumption), + "transport destination {address} did not consume its one-use grant: {observations:?}" + ); + } + drop(observations); + + let closed: DesktopResponse = browser + .proxy + .call( + browser_names::methods::CLOSE_SESSION, + (serde_json::json!({"session": browser.session}),), + ) + .await?; + assert!( + closed.ok, + "browser session did not close: {:?}", + closed.error + ); + browser.broker_task.abort(); + redirect.abort(); + page.abort(); + pixel.abort(); + socket.abort(); + Ok(()) +} From ae8523619be43c70d516d1ae15b86c8138450431 Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Fri, 23 Oct 2026 02:07:48 +0000 Subject: [PATCH 47/70] test(browser_egress): assert websocket upgrade headers in socket fixture The socket fixture now verifies that incoming requests carry the Upgrade, Connection, and Sec-WebSocket-Key headers a real WebSocket handshake requires, so tests fail loudly when the client sends a plain HTTP request to the socket endpoint instead of silently passing. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- .../transport_classes_tests.rs | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/transport_classes_tests.rs b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/transport_classes_tests.rs index babfaadb7..ea6085fa2 100644 --- a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/transport_classes_tests.rs +++ b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/transport_classes_tests.rs @@ -40,6 +40,31 @@ async fn serve_once( .map(|url| url.path().to_owned()) .unwrap_or_else(|_| target.to_owned()); assert_eq!(path, expected_path); + if expected_path == "/socket" { + let header = |name: &str| { + request.lines().find_map(|line| { + let (key, value) = line.split_once(':')?; + key.eq_ignore_ascii_case(name).then(|| value.trim()) + }) + }; + assert_eq!( + header("Upgrade").map(str::to_ascii_lowercase).as_deref(), + Some("websocket"), + "socket fixture only accepts a WebSocket upgrade request: {request}" + ); + assert!( + header("Connection").is_some_and(|value| { + value + .split(',') + .any(|token| token.trim().eq_ignore_ascii_case("upgrade")) + }), + "socket fixture only accepts Connection: Upgrade: {request}" + ); + assert!( + header("Sec-WebSocket-Key").is_some_and(|value| !value.is_empty()), + "socket fixture only accepts a request with Sec-WebSocket-Key: {request}" + ); + } tokio::io::AsyncWriteExt::write_all(&mut stream, response.as_bytes()) .await .expect("fixture response is written"); From a3936d22f7d50f3a1b045bf9623cc30e693280a4 Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Fri, 23 Oct 2026 02:14:09 +0000 Subject: [PATCH 48/70] test(browser-egress): add module doc for transport class live tests Document that the live Chromium checks in this module verify browser transport classes use host authorization, so the file's purpose is clear without reading the test bodies. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- .../browser_egress_live_tests/transport_classes_tests.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/transport_classes_tests.rs b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/transport_classes_tests.rs index ea6085fa2..fae77297f 100644 --- a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/transport_classes_tests.rs +++ b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/transport_classes_tests.rs @@ -1,3 +1,5 @@ +//! Live Chromium checks that browser transport classes use host authorization. + use super::*; async fn serve_once( From 5a29fd0104782a0c460d192ed69552fa1a35daef Mon Sep 17 00:00:00 2001 From: M3gA-Mind Date: Fri, 23 Oct 2026 08:27:23 +0530 Subject: [PATCH 49/70] test(consequence): build the flow result's vars with BTreeMap::new clippy::default_trait_access under -D warnings. --- .../tinybus_module_tests/consequence_review_tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/tinycomputer/src/tinybus_module/tinybus_module_tests/consequence_review_tests.rs b/crates/tinycomputer/src/tinybus_module/tinybus_module_tests/consequence_review_tests.rs index 14139e5a1..d73214524 100644 --- a/crates/tinycomputer/src/tinybus_module/tinybus_module_tests/consequence_review_tests.rs +++ b/crates/tinycomputer/src/tinybus_module/tinybus_module_tests/consequence_review_tests.rs @@ -29,7 +29,7 @@ fn run(stop: FlowStopReason, steps: Vec, pending: Option<&str>) -> F FlowRunResult { stop, steps, - vars: Default::default(), + vars: std::collections::BTreeMap::new(), pending: pending.map(|name| JevTarget { ref_id: "e9".to_owned(), role: "button".to_owned(), From 23792433c86d168068c215d1656d295bfeccde95 Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Fri, 23 Oct 2026 03:19:59 +0000 Subject: [PATCH 50/70] test(browser_egress): add authority denial live tests Adds a new live test module covering authority denial, and lets the fixture egress host report a grant generation that differs from the requested one so those cases can be exercised. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- .../authority_denial_tests.rs | 158 ++++++++++++++++++ .../browser_egress_live_tests/mod.rs | 5 +- 2 files changed, 162 insertions(+), 1 deletion(-) create mode 100644 crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/authority_denial_tests.rs diff --git a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/authority_denial_tests.rs b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/authority_denial_tests.rs new file mode 100644 index 000000000..d3c28a6ec --- /dev/null +++ b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/authority_denial_tests.rs @@ -0,0 +1,158 @@ +//! Live Chromium checks that missing and stale host authority denies dialing. + +use super::*; + +struct DenialBrowser { + proxy: tinybus::Proxy, + session: serde_json::Value, + broker_task: tokio::task::JoinHandle>, + _host_connection: Option, + _module_host: ModuleHost, +} + +async fn start_denial_browser( + host: Option, + policy_id: &str, + generation: u64, +) -> tinybus::Result { + let bus = MemoryBus::new(); + let broker = Broker::new(); + let broker_task = broker.spawn(bus.clone()); + let host_connection = if let Some(host) = host { + let connection = Connection::connect(bus.connect().await?).await?; + connection + .serve_at(browser_egress::OBJECT_PATH.try_into()?, host) + .await?; + connection.request_name(browser_egress::INTERFACE).await?; + Some(connection) + } else { + None + }; + + let module_host = ModuleHost::new(broker); + let module = crate::linked_module().expect("linked module manifest is valid"); + module_host + .attach_linked_with_config( + module, + serde_json::json!({ + "browser": {"egress": {"policy_id": policy_id, "generation": generation}} + }), + ) + .expect("TinyComputer module loads through ModuleHost"); + let client = Connection::connect(bus.connect().await?).await?; + let proxy = client.proxy(names::INTERFACE, names::OBJECT_PATH, names::INTERFACE)?; + let opened: DesktopResponse = proxy + .call( + browser_names::methods::OPEN_SESSION, + (serde_json::json!({}),), + ) + .await?; + let session = successful_data(&opened)["id"].clone(); + assert_eq!(successful_data(&opened)["launched"], true); + + Ok(DenialBrowser { + proxy, + session, + broker_task, + _host_connection: host_connection, + _module_host: module_host, + }) +} + +async fn close_denial_browser(browser: DenialBrowser) -> tinybus::Result<()> { + let closed: DesktopResponse = browser + .proxy + .call( + browser_names::methods::CLOSE_SESSION, + (serde_json::json!({"session": browser.session}),), + ) + .await?; + assert!( + closed.ok, + "browser session did not close: {:?}", + closed.error + ); + browser.broker_task.abort(); + let _ = browser.broker_task.await; + Ok(()) +} + +#[tokio::test] +async fn live_chromium_denies_loopback_when_egress_authority_is_missing() -> tinybus::Result<()> { + let denied_listener = tokio::net::TcpListener::bind("127.0.0.1:0").await?; + let port = denied_listener.local_addr()?.port(); + let browser = start_denial_browser(None, "missing-authority", 7).await?; + let url = format!("http://127.0.0.1:{port}/must-not-connect"); + let denied: DesktopResponse = browser + .proxy + .call( + browser_names::methods::NAVIGATE, + (serde_json::json!({"session": browser.session, "url": url}),), + ) + .await?; + + assert!( + !denied.ok, + "navigation without an egress authority unexpectedly succeeded" + ); + assert!( + tokio::time::timeout(Duration::from_millis(500), denied_listener.accept()) + .await + .is_err(), + "loopback destination received a connection without an egress authority" + ); + close_denial_browser(browser).await?; + Ok(()) +} + +#[tokio::test] +async fn live_chromium_denies_stale_egress_generation_before_dialing() -> tinybus::Result<()> { + let denied_listener = tokio::net::TcpListener::bind("127.0.0.1:0").await?; + let allowed_address = denied_listener.local_addr()?.to_string(); + let port = denied_listener.local_addr()?.port(); + let observations = Arc::new(Mutex::new(Vec::new())); + let browser = start_denial_browser( + Some(EgressHost { + allowed: Arc::new(AtomicBool::new(true)), + allowed_addresses: vec![allowed_address], + grant_generation: Some(40), + observations: observations.clone(), + }), + "stale-generation", + 41, + ) + .await?; + let url = format!("http://fixture.test:{port}/stale-generation"); + let denied: DesktopResponse = browser + .proxy + .call( + browser_names::methods::NAVIGATE, + (serde_json::json!({"session": browser.session, "url": url}),), + ) + .await?; + + assert!( + !denied.ok, + "navigation with a stale egress generation unexpectedly succeeded" + ); + assert!( + tokio::time::timeout(Duration::from_millis(500), denied_listener.accept()) + .await + .is_err(), + "stale-generation socket received a connection" + ); + close_denial_browser(browser).await?; + + let calls = observations.lock().unwrap(); + assert!( + calls + .iter() + .any(|call| call.starts_with("authorize:stale-generation:41:fixture.test:")), + "the live module did not ask the host for authorization: {calls:?}" + ); + assert!( + !calls.iter().any(|call| call.starts_with("consume:")), + "stale grant reached socket consumption: {calls:?}" + ); + Ok(()) +} diff --git a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/mod.rs b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/mod.rs index efc61a821..b48fc4c31 100644 --- a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/mod.rs +++ b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/mod.rs @@ -1,6 +1,7 @@ //! Opt-in real-Chromium coverage through the loaded `TinyComputer` module. #![allow(clippy::expect_used, clippy::panic, clippy::unwrap_used)] +mod authority_denial_tests; mod transport_classes_tests; mod worker; @@ -25,6 +26,7 @@ use tinycomputer_bus::{ struct EgressHost { allowed: Arc, allowed_addresses: Vec, + grant_generation: Option, observations: Arc>>, } @@ -47,7 +49,7 @@ impl EgressHost { request.policy_id, request.expected_generation, request.hostname, request.port )); Ok(BrowserEgressGrant { - generation: request.expected_generation, + generation: self.grant_generation.unwrap_or(request.expected_generation), authorization: if allow { "fixture-lease" } else { @@ -177,6 +179,7 @@ async fn start_browser_with_fixture_hosts( EgressHost { allowed: allowed.clone(), allowed_addresses, + grant_generation: None, observations: observations.clone(), }, ) From 174f08ddacad75dcdb34996a5e641849117c8f1f Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Fri, 23 Oct 2026 03:21:51 +0000 Subject: [PATCH 51/70] test(browser_egress): tidy transport class live test assertions Replace the manual read check with an assert, use map_or_else for the URL path fallback, and scope the observations lock to a block so it drops before the proxy is closed. Add an allow for the long test function to keep clippy quiet. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- .../transport_classes_tests.rs | 54 ++++++++++--------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/transport_classes_tests.rs b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/transport_classes_tests.rs index fae77297f..94c83eb86 100644 --- a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/transport_classes_tests.rs +++ b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/transport_classes_tests.rs @@ -24,9 +24,10 @@ async fn serve_once( else { panic!("browser request timed out"); }; - if read == 0 { - panic!("browser closed before sending a complete request"); - } + assert!( + read != 0, + "browser closed before sending a complete request" + ); request.extend_from_slice(&chunk[..read]); if request.windows(4).any(|window| window == b"\r\n\r\n") { break; @@ -38,9 +39,8 @@ async fn serve_once( .next() .and_then(|line| line.split_ascii_whitespace().nth(1)) .expect("browser request has a target"); - let path = url::Url::parse(target) - .map(|url| url.path().to_owned()) - .unwrap_or_else(|_| target.to_owned()); + let path = + url::Url::parse(target).map_or_else(|_| target.to_owned(), |url| url.path().to_owned()); assert_eq!(path, expected_path); if expected_path == "/socket" { let header = |name: &str| { @@ -84,6 +84,7 @@ fn fixture_response(status: &str, headers: &str, body: &str) -> String { } #[tokio::test] +#[allow(clippy::too_many_lines)] async fn live_chromium_redirect_subresource_and_websocket_requests_use_host_authorization() -> tinybus::Result<()> { let redirect_listener = tokio::net::TcpListener::bind("127.0.0.1:0").await?; @@ -162,27 +163,28 @@ async fn live_chromium_redirect_subresource_and_websocket_requests_use_host_auth paths.sort_unstable(); assert_eq!(paths, ["/page", "/pixel", "/redirect", "/socket"]); - let observations = browser.observations.lock().unwrap(); - for port in [redirect_port, page_port, pixel_port, socket_port] { - let authorization = format!("authorize:fixture-policy:41:fixture.test:{port}"); - assert!( - observations.iter().any(|call| call == &authorization), - "transport destination on port {port} did not reach host authorization: {observations:?}" - ); - } - for address in [ - &redirect_address, - &page_address, - &pixel_address, - &socket_address, - ] { - let consumption = format!("consume:{address}"); - assert!( - observations.iter().any(|call| call == &consumption), - "transport destination {address} did not consume its one-use grant: {observations:?}" - ); + { + let observations = browser.observations.lock().unwrap(); + for port in [redirect_port, page_port, pixel_port, socket_port] { + let authorization = format!("authorize:fixture-policy:41:fixture.test:{port}"); + assert!( + observations.iter().any(|call| call == &authorization), + "transport destination on port {port} did not reach host authorization: {observations:?}" + ); + } + for address in [ + &redirect_address, + &page_address, + &pixel_address, + &socket_address, + ] { + let consumption = format!("consume:{address}"); + assert!( + observations.iter().any(|call| call == &consumption), + "transport destination {address} did not consume its one-use grant: {observations:?}" + ); + } } - drop(observations); let closed: DesktopResponse = browser .proxy From 4296ed9d194ecf55fabfd0054728c9c5b16dc582 Mon Sep 17 00:00:00 2001 From: shanu Date: Fri, 23 Oct 2026 10:45:50 +0530 Subject: [PATCH 52/70] Let a task set how many turns a do step may spend A `do` step had a fixed eight turns (`DO_TURNS`). On a shop's cart or checkout one step can need more moves than that, and the step then fails as not accomplished while it is still making progress. - `TaskBudget.max_do_turns` and `RunFlowRequest.max_do_turns`: optional, 8 when unset, capped by the module at 32 (`MAX_DO_TURNS`). - The task controller passes the budget's limit to every flow run. - Contract 2.28; the thresholds table, the task docs, the StartTask schema and the described budget list the field. --- .../tinycomputer-bus/src/agent/agent_tests.rs | 17 +++++++++ .../src/agent/types/request.rs | 3 ++ .../tinycomputer-bus/src/flow/flow_tests.rs | 18 +++++++++ .../src/flow/types/request.rs | 6 +++ crates/tinycomputer-bus/src/version/mod.rs | 4 +- .../src/version/version_tests.rs | 7 +++- .../agentic/flow/flow_tests/do_loop_tests.rs | 37 +++++++++++++++++++ .../src/agentic/flow/mod.rs | 5 +++ .../src/agentic/flow/run.rs | 5 ++- .../src/agentic/flow/steps/mod.rs | 7 ++-- crates/tinycomputer-engine/src/task/budget.rs | 1 + .../tinycomputer-engine/src/task/describe.rs | 6 +++ .../src/task/task_tests/describe_tests.rs | 1 + .../src/task/task_tests/start_tests.rs | 27 ++++++++++++++ .../schemas/start_task.schema.json | 1 + .../tinycomputer-bus/agent-and-tasks.md | 3 +- docs/technical/decision-thresholds.md | 2 +- .../specs/desktop-module-contract.md | 5 +++ docs/technical/tasks.md | 3 ++ 19 files changed, 148 insertions(+), 10 deletions(-) diff --git a/crates/tinycomputer-bus/src/agent/agent_tests.rs b/crates/tinycomputer-bus/src/agent/agent_tests.rs index 1bbbf83e4..a4d745c64 100644 --- a/crates/tinycomputer-bus/src/agent/agent_tests.rs +++ b/crates/tinycomputer-bus/src/agent/agent_tests.rs @@ -317,6 +317,23 @@ fn host_context_debug_output_hides_the_opaque_value() { assert!(!format!("{context:?}").contains("secret-capability")); } +#[test] +fn a_do_turn_limit_pins_its_wire_form() { + let request: StartTaskRequest = serde_json::from_value(json!({ + "task": "buy a pack of dried fruit", + "budget": {"max_do_turns": 16} + })) + .unwrap(); + assert_eq!(request.budget.max_do_turns, Some(16)); + assert_eq!( + serde_json::to_value(request.budget).unwrap()["max_do_turns"], + 16 + ); + let unset: StartTaskRequest = + serde_json::from_value(json!({"task": "buy a pack of dried fruit"})).unwrap(); + assert_eq!(unset.budget.max_do_turns, None); +} + #[test] fn rescues_pin_their_wire_form() { let request: StartTaskRequest = serde_json::from_value(json!({ diff --git a/crates/tinycomputer-bus/src/agent/types/request.rs b/crates/tinycomputer-bus/src/agent/types/request.rs index d6e5850e8..5daac815c 100644 --- a/crates/tinycomputer-bus/src/agent/types/request.rs +++ b/crates/tinycomputer-bus/src/agent/types/request.rs @@ -233,6 +233,9 @@ pub struct TaskBudget { /// How many ways each decision is asked before its answers are averaged; /// the module's default when unset. pub votes: Option, + /// Turns each `do` step may spend before it fails as not accomplished; + /// the module's default (8) when unset, at most 32. + pub max_do_turns: Option, /// How each flow run asks its decisions; the narrow strategy when unset. pub strategy: Option, /// How much each flow run deliberates before acting; the deep level diff --git a/crates/tinycomputer-bus/src/flow/flow_tests.rs b/crates/tinycomputer-bus/src/flow/flow_tests.rs index 4a13b3f19..a148f0603 100644 --- a/crates/tinycomputer-bus/src/flow/flow_tests.rs +++ b/crates/tinycomputer-bus/src/flow/flow_tests.rs @@ -204,6 +204,24 @@ fn a_brief_pins_its_wire_form_and_defaults_empty() { })) .unwrap(); assert_eq!((request.votes, request.brief.goal.as_str()), (3, "g")); + assert_eq!( + request.max_do_turns, None, + "unset keeps the module's default" + ); + assert!( + serde_json::to_value(&request) + .unwrap() + .get("max_do_turns") + .is_none(), + "an unset turn limit is left off the wire" + ); + let request: RunFlowRequest = serde_json::from_value(json!({ + "flow": {"app": "Mail", "steps": ["x"]}, + "max_do_turns": 12 + })) + .unwrap(); + assert_eq!(request.max_do_turns, Some(12)); + assert_eq!(serde_json::to_value(&request).unwrap()["max_do_turns"], 12); for (flow_loop, wire) in [ (FlowLoop::Vote, "vote"), (FlowLoop::PageKind, "page_kind"), diff --git a/crates/tinycomputer-bus/src/flow/types/request.rs b/crates/tinycomputer-bus/src/flow/types/request.rs index 2e24025ea..cfea954e1 100644 --- a/crates/tinycomputer-bus/src/flow/types/request.rs +++ b/crates/tinycomputer-bus/src/flow/types/request.rs @@ -196,6 +196,11 @@ pub struct RunFlowRequest { /// answers are averaged: 1 asks once. Jev calls are cheap, so accuracy /// is bought with more of them. Capped by the module at 9. pub votes: u32, + /// Turns a `do` step may spend before it fails as not accomplished; the + /// module's default (8) when unset, capped by the module at 32. A shop's + /// checkout can need more moves in one step than a desktop app does. + #[serde(skip_serializing_if = "Option::is_none")] + pub max_do_turns: Option, /// Who the run is for and what it is after, shown to Jev with every /// question so each small decision is made knowing the whole task. pub brief: FlowBrief, @@ -241,6 +246,7 @@ impl Default for RunFlowRequest { max_actions: 60, max_model_calls: 3000, votes: 7, + max_do_turns: None, brief: FlowBrief::default(), disabled_loops: Vec::new(), memory: Vec::new(), diff --git a/crates/tinycomputer-bus/src/version/mod.rs b/crates/tinycomputer-bus/src/version/mod.rs index bc21fef6a..cf33c202b 100644 --- a/crates/tinycomputer-bus/src/version/mod.rs +++ b/crates/tinycomputer-bus/src/version/mod.rs @@ -8,7 +8,7 @@ //! release workflow bumps, which tracks the shipped artifact. /// The wire contract version this crate defines. -pub const CONTRACT_VERSION: (u32, u32) = (2, 27); +pub const CONTRACT_VERSION: (u32, u32) = (2, 28); /// Returns whether a host holding [`CONTRACT_VERSION`] can bind to a module /// reporting `module`. @@ -22,7 +22,7 @@ pub const CONTRACT_VERSION: (u32, u32) = (2, 27); /// ``` /// # use tinycomputer_bus::{is_compatible, CONTRACT_VERSION}; /// assert!(is_compatible(CONTRACT_VERSION)); -/// assert!(is_compatible((2, 27))); +/// assert!(is_compatible((2, 28))); /// assert!(!is_compatible((2, 11))); /// assert!(!is_compatible((1, 8))); /// ``` diff --git a/crates/tinycomputer-bus/src/version/version_tests.rs b/crates/tinycomputer-bus/src/version/version_tests.rs index 529e2ab7e..e25ea5aca 100644 --- a/crates/tinycomputer-bus/src/version/version_tests.rs +++ b/crates/tinycomputer-bus/src/version/version_tests.rs @@ -6,7 +6,7 @@ use super::{CONTRACT_VERSION, binds, is_compatible}; #[test] fn the_shipped_contract_version_is_pinned() { - assert_eq!(CONTRACT_VERSION, (2, 27)); + assert_eq!(CONTRACT_VERSION, (2, 28)); } #[test] @@ -16,7 +16,7 @@ fn the_contract_binds_to_itself() { #[test] fn a_newer_minor_on_the_module_side_binds() { - assert!(is_compatible((2, 27))); + assert!(is_compatible((2, 28))); assert!(is_compatible((2, 97))); // 2.24 adds same-task flow-to-planner handoff to StartTask. // 2.22 adds optional host-held secret handles to StartTask and RunFlow. @@ -44,6 +44,9 @@ fn a_newer_minor_on_the_module_side_binds() { // 2.26 adds TraceSinkHost, so a 2.25 module lacks that callback. // 2.27 relays opaque host context to ConsequenceHost reviews. A 2.26 // module would drop that context, so a host requiring it cannot bind. + // 2.28 adds `max_do_turns` to TaskBudget and RunFlowRequest. A 2.27 + // module ignores it and keeps every `do` step at 8 turns. + assert!(!is_compatible((2, 27))); assert!(!is_compatible((2, 26))); assert!(!is_compatible((2, 25))); assert!(!is_compatible((2, 24))); diff --git a/crates/tinycomputer-engine/src/agentic/flow/flow_tests/do_loop_tests.rs b/crates/tinycomputer-engine/src/agentic/flow/flow_tests/do_loop_tests.rs index 6f2d1cbe6..5263d16aa 100644 --- a/crates/tinycomputer-engine/src/agentic/flow/flow_tests/do_loop_tests.rs +++ b/crates/tinycomputer-engine/src/agentic/flow/flow_tests/do_loop_tests.rs @@ -633,6 +633,43 @@ async fn an_action_judged_unhelpful_is_undone_and_not_tried_again() { assert_eq!(run.result.stop, FlowStopReason::Completed); } +#[tokio::test] +async fn a_do_step_spends_the_turns_its_run_allows() { + let ended_after = |max_do_turns: Option| async move { + let run = run_with( + App::quirky(Quirk::Frozen), + json!({"app": "Mail", "steps": ["open the search results"]}), + |request| { + request.max_do_turns = max_do_turns; + request.max_actions = 120; + }, + |id, question, _| (id == "move").then(|| pick(question, "wait", 0.9)), + ) + .await; + assert_eq!(run.result.stop, FlowStopReason::StepFailed); + let step = &run.result.steps[0]; + (step.turns, step.note.clone()) + }; + + let (turns, note) = ended_after(None).await; + assert_eq!(turns, 8, "the default is unchanged"); + assert!(note.contains("not accomplished after 8 turns"), "{note}"); + + let (turns, note) = ended_after(Some(3)).await; + assert_eq!(turns, 3); + assert!(note.contains("not accomplished after 3 turns"), "{note}"); + + let (turns, note) = ended_after(Some(12)).await; + assert_eq!(turns, 12); + assert!(note.contains("not accomplished after 12 turns"), "{note}"); + + let (_, note) = ended_after(Some(500)).await; + assert!( + note.contains("not accomplished after 32 turns"), + "capped by the module: {note}" + ); +} + #[tokio::test] async fn waits_that_change_nothing_are_not_a_stall_and_stop_being_offered() { let run = run_with( diff --git a/crates/tinycomputer-engine/src/agentic/flow/mod.rs b/crates/tinycomputer-engine/src/agentic/flow/mod.rs index 96e4635d1..44a2579d8 100644 --- a/crates/tinycomputer-engine/src/agentic/flow/mod.rs +++ b/crates/tinycomputer-engine/src/agentic/flow/mod.rs @@ -97,6 +97,9 @@ const MAX_ACTIONS: u32 = 120; /// Upper bound on [`RunFlowRequest::max_model_calls`]. Jev is cheap, and /// every framing of a voted decision is one evaluation. const MAX_CALLS: u32 = 10_000; +/// Upper bound on [`RunFlowRequest::max_do_turns`]: a step stuck past this +/// many turns is better rescued than tried again. +const MAX_DO_TURNS: u32 = 32; /// Choices, picks, and entries remembered for the brief's `so_far`. const MAX_SO_FAR: usize = 12; /// Longest goal the brief carries, in characters. @@ -272,6 +275,8 @@ pub(super) struct FlowRun<'r, B> { pub(super) page: Option, /// How many ways each decision is asked. votes: u32, + /// Turns a `do` step may spend. + pub(super) do_turns: u32, /// The secret values, to mask every request with. secrets: Facts, /// Opaque host handles, never substituted into flow text. diff --git a/crates/tinycomputer-engine/src/agentic/flow/run.rs b/crates/tinycomputer-engine/src/agentic/flow/run.rs index 8f7db8cf3..f0583df80 100644 --- a/crates/tinycomputer-engine/src/agentic/flow/run.rs +++ b/crates/tinycomputer-engine/src/agentic/flow/run.rs @@ -16,7 +16,7 @@ use tinycomputer_bus::{ use tinycomputer_core::Facts; use super::{ - Ended, FlowRun, Halt, MAX_ACTIONS, MAX_CALLS, StepLog, + Ended, FlowRun, Halt, MAX_ACTIONS, MAX_CALLS, MAX_DO_TURNS, StepLog, backend::AgentBackend, front::Front, ledger, steps, @@ -106,6 +106,9 @@ impl<'r, B: AgentBackend + Sync> FlowRun<'r, B> { so_far: Vec::new(), page: None, votes: request.votes.clamp(1, vote::MAX_VOTES), + do_turns: request + .max_do_turns + .map_or(steps::DO_TURNS, |turns| turns.clamp(1, MAX_DO_TURNS)), secrets, fact_handles: request.fact_handles.clone(), secret_host, diff --git a/crates/tinycomputer-engine/src/agentic/flow/steps/mod.rs b/crates/tinycomputer-engine/src/agentic/flow/steps/mod.rs index d191a7d81..68806985b 100644 --- a/crates/tinycomputer-engine/src/agentic/flow/steps/mod.rs +++ b/crates/tinycomputer-engine/src/agentic/flow/steps/mod.rs @@ -44,8 +44,9 @@ use tinycomputer_bus::FlowAction; use super::{Ended, FlowRun, Halt, StepLog, backend::AgentBackend}; -/// Turns a `do` step may spend. -const DO_TURNS: u32 = 8; +/// Turns a `do` step may spend when the run does not set +/// `RunFlowRequest::max_do_turns`. +pub(super) const DO_TURNS: u32 = 8; /// Turns spent opening the thing a `choose` step picks from. pub(super) const REVEAL_TURNS: u32 = 3; /// Times `open` checks for a readable window, waiting between checks. @@ -99,7 +100,7 @@ pub(super) async fn run( // then be typed as the caller's card number. FlowAction::Do(intent) => match typing::typing(intent) { Some(slot) => run.enter(log, &[slot]).await, - None => run.accomplish(log, text, DO_TURNS).await, + None => run.accomplish(log, text, run.do_turns).await, }, FlowAction::Enter(slots) => run.enter(log, &slots.0).await, FlowAction::Choose(choose) => run.choose(log, choose).await, diff --git a/crates/tinycomputer-engine/src/task/budget.rs b/crates/tinycomputer-engine/src/task/budget.rs index b1755721e..094b08bb5 100644 --- a/crates/tinycomputer-engine/src/task/budget.rs +++ b/crates/tinycomputer-engine/src/task/budget.rs @@ -363,6 +363,7 @@ pub(super) fn run_request( max_actions, max_model_calls, votes: state.budget.votes.unwrap_or(DEFAULT_VOTES), + max_do_turns: state.budget.max_do_turns, strategy: state.budget.strategy.unwrap_or_default(), deliberation: state.budget.deliberation.unwrap_or_default(), brief: brief(&state), diff --git a/crates/tinycomputer-engine/src/task/describe.rs b/crates/tinycomputer-engine/src/task/describe.rs index ea2af843d..c6f5445aa 100644 --- a/crates/tinycomputer-engine/src/task/describe.rs +++ b/crates/tinycomputer-engine/src/task/describe.rs @@ -115,6 +115,12 @@ fn start_task_input() -> Value { "max_actions": {"type": "integer"}, "max_model_calls": {"type": "integer"}, "votes": {"type": "integer"}, + "max_do_turns": { + "type": "integer", + "minimum": 1, + "maximum": 32, + "description": "turns each do step may spend before it fails as not accomplished; 8 when unset" + }, "strategy": {"enum": ["narrow", "wide"], "default": "narrow"}, "deliberation": {"enum": ["off", "standard", "deep"], "default": "deep"}, "max_elapsed_ms": {"type": "integer"}, diff --git a/crates/tinycomputer-engine/src/task/task_tests/describe_tests.rs b/crates/tinycomputer-engine/src/task/task_tests/describe_tests.rs index 69885b1a3..82a06906e 100644 --- a/crates/tinycomputer-engine/src/task/task_tests/describe_tests.rs +++ b/crates/tinycomputer-engine/src/task/task_tests/describe_tests.rs @@ -241,6 +241,7 @@ async fn describe_schemas_name_every_request_field() { max_actions: Some(1), max_model_calls: Some(1), votes: Some(1), + max_do_turns: Some(1), strategy: Some(tinycomputer_bus::FlowStrategy::default()), deliberation: Some(tinycomputer_bus::Deliberation::default()), max_elapsed_ms: Some(1), diff --git a/crates/tinycomputer-engine/src/task/task_tests/start_tests.rs b/crates/tinycomputer-engine/src/task/task_tests/start_tests.rs index a18de9c1e..e92ba1fbb 100644 --- a/crates/tinycomputer-engine/src/task/task_tests/start_tests.rs +++ b/crates/tinycomputer-engine/src/task/task_tests/start_tests.rs @@ -66,6 +66,7 @@ async fn a_finished_flow_is_done_with_its_reads_and_no_fact_values() { (request.max_actions, request.max_model_calls, request.votes), (120, 6000, 7) ); + assert_eq!(request.max_do_turns, None, "the module's own default"); assert!(request.facts.is_empty(), "an email is shared, not secret"); assert_eq!(request.brief.details["email"], "asha@example.com"); assert!( @@ -630,3 +631,29 @@ async fn a_run_gets_the_callers_values_and_the_flow_keeps_its_own_definitions() ); assert_eq!(request.flow.vars["first_name"], "${first name}"); } + +#[tokio::test] +async fn a_budget_turn_limit_reaches_every_run() { + let (tasks, script) = controller(vec![finished_run( + FlowStopReason::Completed, + vec![step("1", "do", "add it to the cart", StepOutcome::Done, "")], + &[], + None, + )]); + let view = tasks + .start(&StartTaskRequest { + flow: Some( + serde_json::from_value(json!({"app": "browser", "steps": ["add it to the cart"]})) + .unwrap(), + ), + budget: tinycomputer_bus::agent::TaskBudget { + max_do_turns: Some(16), + ..tinycomputer_bus::agent::TaskBudget::default() + }, + ..StartTaskRequest::default() + }) + .data + .unwrap(); + settle(&tasks, &view.id).await; + assert_eq!(script.requests.lock().unwrap()[0].max_do_turns, Some(16)); +} diff --git a/crates/tinycomputer-skills/schemas/start_task.schema.json b/crates/tinycomputer-skills/schemas/start_task.schema.json index f399c8905..d649e8c2d 100644 --- a/crates/tinycomputer-skills/schemas/start_task.schema.json +++ b/crates/tinycomputer-skills/schemas/start_task.schema.json @@ -34,6 +34,7 @@ "max_model_calls": {"type": "integer"}, "max_elapsed_ms": {"type": "integer"}, "votes": {"type": "integer", "description": "How many ways each decision is asked before its answers are averaged."}, + "max_do_turns": {"type": "integer", "minimum": 1, "maximum": 32, "description": "How many turns each do step may spend before it fails as not accomplished (default 8, at most 32)."}, "strategy": {"type": "string", "enum": ["narrow", "wide"], "description": "How each decision is asked: many small requests (narrow, the default), or one request per turn over a digest of the screen with a working memory (wide)."}, "deliberation": {"type": "string", "enum": ["off", "standard", "deep"], "description": "How much each decision is deliberated before acting: deep (the default) escalates close calls with more framings, pairwise duels, and contrasting questions, checks every action's effect, and undoes and retries mistakes; standard does less; off uses single thresholds."}, "max_rescues": {"type": "integer", "minimum": 0, "maximum": 5, "description": "How many failed steps a reasoning model may rescue with guidance before the task fails (default and most 5; 0 turns rescues off). Needs the module's planner configuration."} diff --git a/docs/crates/tinycomputer-bus/agent-and-tasks.md b/docs/crates/tinycomputer-bus/agent-and-tasks.md index 45648e410..2ef98445d 100644 --- a/docs/crates/tinycomputer-bus/agent-and-tasks.md +++ b/docs/crates/tinycomputer-bus/agent-and-tasks.md @@ -108,7 +108,8 @@ for the fuller picture of what does and does not get automated here. `TaskBudget` mirrors the levers `RunFlowRequest` exposes (see [Writing flows](flows.md)) but every field is `Option`, so an unset one takes the module's own default rather than the crate baking one in twice: -`max_actions`, `max_model_calls`, `votes`, `strategy`, `deliberation`, +`max_actions`, `max_model_calls`, `votes`, `max_do_turns` (turns each `do` +step may spend, 8 when unset, at most 32), `strategy`, `deliberation`, `max_elapsed_ms` (excludes time spent waiting on the caller), and `max_rescues`, how many times a failed step may be handed to a reasoning model for guidance before the task gives up on it. Absent means the module's diff --git a/docs/technical/decision-thresholds.md b/docs/technical/decision-thresholds.md index c65e94e10..b050e3d64 100644 --- a/docs/technical/decision-thresholds.md +++ b/docs/technical/decision-thresholds.md @@ -32,7 +32,7 @@ Change a constant and its row together. | `CAP` | 20 | `ask/mod.rs` | most options in one Choice | | `HEDGED` | 0.10 | `ask/answers.rs` | distance from an even chance within which a condition's calibrated yes/no says nothing either way, and defers to a crisp coverage | | `CRISP_TOP` | 0.85 | `ask/answers.rs` | probability on a condition's top coverage level at which it stands alone for a hedged yes/no | -| `DO_TURNS` | 8 | `steps/mod.rs` | turns a `do` step may spend | +| `DO_TURNS` / `MAX_DO_TURNS` | 8 / 32 | `steps/mod.rs`, `mod.rs` | turns a `do` step may spend when `max_do_turns` is unset, and the most a run may set | | `REFLECT_FLOOR` | 0.50 | `reflect.rs` | belief that a pressed `choose` left its choice, below which it is repaired, and failed if the repair does not take | | `REPAIR_TURNS` | 4 | `reflect.rs` | turns one reflection repair may spend | | `MAX_ACTIONS` / `MAX_CALLS` | 120 / 10000 | `mod.rs` | per-run caps on actions and Jev calls | diff --git a/docs/technical/specs/desktop-module-contract.md b/docs/technical/specs/desktop-module-contract.md index 4b36ca80e..098e16284 100644 --- a/docs/technical/specs/desktop-module-contract.md +++ b/docs/technical/specs/desktop-module-contract.md @@ -89,6 +89,11 @@ serves the interface and fails to answer, turns the approval into a decline, so the task never takes the action. A host that serves nothing leaves the pause as the only gate. A payment checkpoint is never continuable and needs no review. +Do-step turns (2.28): `TaskBudget` and `RunFlowRequest` take an optional +`max_do_turns`, the turns each `do` step may spend before it fails as not +accomplished. Unset keeps the module's default of 8; the module caps it at +32. A 2.27 module ignores the field. + Host context relay (2.27): `ContinueTaskRequest` takes an optional opaque `host_context`. When the module requests consequence review, it copies that value unchanged into `ReviewActionRequest.host_context`; the module does not diff --git a/docs/technical/tasks.md b/docs/technical/tasks.md index 134f3b4ee..b46f5b074 100644 --- a/docs/technical/tasks.md +++ b/docs/technical/tasks.md @@ -163,6 +163,9 @@ is acted on: `deep` (the default), `standard`, or `off` ([`specs/jev-deliberation.md`](specs/jev-deliberation.md)). Deliberation spends calls only where the evidence is thin, and degrades rung by rung when the budget runs short rather than failing the run. +`budget.max_do_turns` sets how many turns each `do` step may spend before it +fails as not accomplished: 8 when unset, at most 32. A long step on a busy +page, such as a shop's cart or checkout, may need more than 8 moves. `budget.max_rescues` caps how many failed steps are rescued (below). The flow runtime has no clock, so `max_elapsed_ms` is enforced by the controller, which times out a run that would go past what is left. Time From fe1874771f5f4fc8bf89790cfffbaad354f263ab Mon Sep 17 00:00:00 2001 From: shanu Date: Fri, 23 Oct 2026 11:01:00 +0530 Subject: [PATCH 53/70] Pin contract 2.28 in the public API test --- crates/tinycomputer/tests/public_api_tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/tinycomputer/tests/public_api_tests.rs b/crates/tinycomputer/tests/public_api_tests.rs index fa11ff982..b63bb8ddc 100644 --- a/crates/tinycomputer/tests/public_api_tests.rs +++ b/crates/tinycomputer/tests/public_api_tests.rs @@ -34,7 +34,7 @@ fn the_crate_re_exports_the_contract_rather_than_redefining_it() { #[test] fn the_shipped_contract_binds_to_itself() { assert!(is_compatible(CONTRACT_VERSION)); - assert_eq!(CONTRACT_VERSION, (2, 27)); + assert_eq!(CONTRACT_VERSION, (2, 28)); assert!(!is_compatible((2, 25))); } From 94ea3242e76234449a3a65bfc22f2675106429fb Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Fri, 23 Oct 2026 08:14:06 +0000 Subject: [PATCH 54/70] feat(egress): add test-connector seam for host integration tests Adds a feature-gated bind_with_test_connector entry point that lets host integration tests substitute the final TCP connector while keeping authorization, grant consumption, and proxy forwarding on the production path. The connector receives the socket address only after authorization and consumption, so tests can map approved public socket operations onto a local fixture listener without making real network connections. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- crates/tinycomputer-browser/Cargo.toml | 3 + crates/tinycomputer-browser/src/egress/mod.rs | 49 +++++- .../tinycomputer-browser/src/egress/serve.rs | 16 -- .../tests/test_connector_tests.rs | 142 ++++++++++++++++++ 4 files changed, 193 insertions(+), 17 deletions(-) create mode 100644 crates/tinycomputer-browser/tests/test_connector_tests.rs diff --git a/crates/tinycomputer-browser/Cargo.toml b/crates/tinycomputer-browser/Cargo.toml index 92e2e9ef6..0ea198919 100644 --- a/crates/tinycomputer-browser/Cargo.toml +++ b/crates/tinycomputer-browser/Cargo.toml @@ -50,6 +50,9 @@ agent-browser = { workspace = true, optional = true } default = [] # Link agent-browser in-process and provide `AgentBrowser`, its `Launcher`. agent-browser = ["dep:agent-browser"] +# Lets host integration tests substitute the final TCP connector while keeping +# authorization, grant consumption, and proxy forwarding on the production path. +test-connector = [] [dev-dependencies] tokio = { workspace = true, features = ["test-util"] } diff --git a/crates/tinycomputer-browser/src/egress/mod.rs b/crates/tinycomputer-browser/src/egress/mod.rs index fc7760fb3..ba7df75b4 100644 --- a/crates/tinycomputer-browser/src/egress/mod.rs +++ b/crates/tinycomputer-browser/src/egress/mod.rs @@ -95,6 +95,45 @@ impl EgressProxy { session_id: String, proxy_password: String, ) -> io::Result { + Self::bind_inner(authorizer, session_id, proxy_password, TcpStream::connect).await + } + + /// Bind the production proxy path with a fixture-only final socket connector. + /// + /// This feature-gated seam is for host integration tests that need to keep + /// policy authorization and one-use grant consumption real while mapping an + /// approved public socket operation onto a local fixture listener. The + /// connector receives the exact socket address after authorization and + /// consumption; it must not make public network connections. + /// + /// # Errors + /// + /// Returns an I/O error when the proxy listener cannot bind or its address + /// cannot be read. + #[cfg(feature = "test-connector")] + pub async fn bind_with_test_connector( + authorizer: Arc, + session_id: String, + proxy_password: String, + connector: C, + ) -> io::Result + where + C: Fn(SocketAddr) -> F + Clone + Send + Sync + 'static, + F: Future> + Send + 'static, + { + Self::bind_inner(authorizer, session_id, proxy_password, connector).await + } + + async fn bind_inner( + authorizer: Arc, + session_id: String, + proxy_password: String, + connector: C, + ) -> io::Result + where + C: Fn(SocketAddr) -> F + Clone + Send + Sync + 'static, + F: Future> + Send + 'static, + { let listener = TcpListener::bind(("127.0.0.1", 0)).await?; let address = listener.local_addr()?; let task = tokio::spawn(async move { @@ -106,8 +145,16 @@ impl EgressProxy { let auth = authorizer.clone(); let session = session_id.clone(); let password = proxy_password.clone(); + let connector = connector.clone(); connections.spawn(async move { - let _ = Box::pin(serve::serve(stream, auth, session, password)).await; + let _ = Box::pin(serve::serve_with_connector( + stream, + auth, + session, + password, + connector, + )) + .await; }); } _ = connections.join_next(), if !connections.is_empty() => {} diff --git a/crates/tinycomputer-browser/src/egress/serve.rs b/crates/tinycomputer-browser/src/egress/serve.rs index 21c718cac..9b33c83c9 100644 --- a/crates/tinycomputer-browser/src/egress/serve.rs +++ b/crates/tinycomputer-browser/src/egress/serve.rs @@ -13,22 +13,6 @@ use super::{ request::{has_valid_buffered_body, read_proxy_request}, }; -pub(super) async fn serve( - client: TcpStream, - auth: Arc, - session_id: String, - proxy_password: String, -) -> io::Result<()> { - Box::pin(serve_with_connector( - client, - auth, - session_id, - proxy_password, - TcpStream::connect, - )) - .await -} - pub(super) async fn serve_with_connector( mut client: TcpStream, auth: Arc, diff --git a/crates/tinycomputer-browser/tests/test_connector_tests.rs b/crates/tinycomputer-browser/tests/test_connector_tests.rs new file mode 100644 index 000000000..bf36cb850 --- /dev/null +++ b/crates/tinycomputer-browser/tests/test_connector_tests.rs @@ -0,0 +1,142 @@ +//! Feature-gated integration tests for host-provided fixture connectors. +#![cfg(feature = "test-connector")] + +use std::{ + future::Future, + io, + net::SocketAddr, + pin::Pin, + sync::{Arc, Mutex}, +}; + +use base64::Engine as _; +use tinycomputer_browser::{BrowserDialTarget, DialGrant, EgressAuthorizer, EgressProxy}; +use tokio::{ + io::{AsyncReadExt, AsyncWriteExt}, + net::{TcpListener, TcpStream}, +}; + +const SESSION: &str = "fixture-public-dial-session"; +const PASSWORD: &str = "fixture-password"; + +struct ExactPublicGrant { + address: SocketAddr, + calls: Arc>>, +} + +impl EgressAuthorizer for ExactPublicGrant { + fn authorize( + &self, + target: BrowserDialTarget, + ) -> Pin> + Send>> { + let address = self.address; + let calls = self.calls.clone(); + Box::pin(async move { + assert_eq!(target.hostname, "8.8.8.8"); + assert_eq!(target.port, address.port()); + calls.lock().unwrap().push(format!("authorize:{address}")); + Ok(DialGrant { + lease: "fixture-only-lease".into(), + addresses: vec![address], + }) + }) + } + + fn consume( + &self, + target: BrowserDialTarget, + grant: DialGrant, + address: SocketAddr, + ) -> Pin> + Send>> { + let expected = self.address; + let calls = self.calls.clone(); + Box::pin(async move { + assert_eq!(target.hostname, "8.8.8.8"); + assert_eq!(address, expected); + assert_eq!(grant.addresses, [expected]); + calls.lock().unwrap().push(format!("consume:{address}")); + Ok(()) + }) + } + + fn validate(&self, lease: String) -> Pin> + Send>> { + Box::pin(async move { Ok(lease == "fixture-only-lease") }) + } +} + +#[tokio::test] +async fn proxy_consumes_the_exact_public_grant_before_fixture_connector_mapping() { + let fixture_listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); + let fixture_address = fixture_listener.local_addr().unwrap(); + let granted_address = SocketAddr::from(([8, 8, 8, 8], fixture_address.port())); + let calls = Arc::new(Mutex::new(Vec::new())); + let connector_calls = calls.clone(); + let auth: Arc = Arc::new(ExactPublicGrant { + address: granted_address, + calls: calls.clone(), + }); + + let proxy = EgressProxy::bind_with_test_connector( + auth, + SESSION.into(), + PASSWORD.into(), + move |address| { + let fixture_address = fixture_address; + let calls = connector_calls.clone(); + Box::pin(async move { + // The fixture mapper observes the authorized public socket but + // deliberately connects only to its local listener. + assert_eq!(address, granted_address); + calls.lock().unwrap().push(format!("connect:{address}")); + TcpStream::connect(fixture_address).await + }) + }, + ) + .await + .unwrap(); + + let fixture = tokio::spawn(async move { + let (mut stream, _) = fixture_listener.accept().await.unwrap(); + let mut request = vec![0; 2048]; + let read = stream.read(&mut request).await.unwrap(); + let request = String::from_utf8_lossy(&request[..read]); + assert!(request.starts_with("GET /control HTTP/1.1\r\n")); + assert!(request.contains(&format!("Host: 8.8.8.8:{}\r\n", fixture_address.port()))); + stream + .write_all(b"HTTP/1.1 200 OK\r\nContent-Length: 7\r\nConnection: close\r\n\r\nfixture") + .await + .unwrap(); + }); + + let mut client = TcpStream::connect(proxy.url().replace("http://", "")) + .await + .unwrap(); + let auth = base64::engine::general_purpose::STANDARD.encode(format!("{SESSION}:{PASSWORD}")); + client + .write_all( + format!( + "GET http://8.8.8.8:{}/control HTTP/1.1\r\nHost: 8.8.8.8:{}\r\nProxy-Authorization: Basic {auth}\r\nConnection: close\r\n\r\n", + granted_address.port(), + granted_address.port(), + ) + .as_bytes(), + ) + .await + .unwrap(); + let mut response = Vec::new(); + client.read_to_end(&mut response).await.unwrap(); + fixture.await.unwrap(); + + let response = String::from_utf8_lossy(&response); + assert!(response.starts_with("HTTP/1.1 200 OK\r\n")); + assert!(response.ends_with("fixture")); + assert_eq!( + *calls.lock().unwrap(), + [ + format!("authorize:{granted_address}"), + format!("consume:{granted_address}"), + format!("connect:{granted_address}"), + ], + "authorization and one-use consumption must precede the fixture-only connector" + ); +} From 8e806845a48768672aef086a6af418bc16555f3c Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Fri, 23 Oct 2026 08:14:47 +0000 Subject: [PATCH 55/70] test(browser): bound connector test waits with timeouts Wrap the fixture listener accept and the client read in five second timeouts so a stalled proxy fails the test with a clear message instead of hanging indefinitely. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- .../tests/test_connector_tests.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/crates/tinycomputer-browser/tests/test_connector_tests.rs b/crates/tinycomputer-browser/tests/test_connector_tests.rs index bf36cb850..8047c763e 100644 --- a/crates/tinycomputer-browser/tests/test_connector_tests.rs +++ b/crates/tinycomputer-browser/tests/test_connector_tests.rs @@ -96,7 +96,13 @@ async fn proxy_consumes_the_exact_public_grant_before_fixture_connector_mapping( .unwrap(); let fixture = tokio::spawn(async move { - let (mut stream, _) = fixture_listener.accept().await.unwrap(); + let (mut stream, _) = tokio::time::timeout( + std::time::Duration::from_secs(5), + fixture_listener.accept(), + ) + .await + .expect("fixture connector reaches the local listener") + .unwrap(); let mut request = vec![0; 2048]; let read = stream.read(&mut request).await.unwrap(); let request = String::from_utf8_lossy(&request[..read]); @@ -124,7 +130,13 @@ async fn proxy_consumes_the_exact_public_grant_before_fixture_connector_mapping( .await .unwrap(); let mut response = Vec::new(); - client.read_to_end(&mut response).await.unwrap(); + tokio::time::timeout( + std::time::Duration::from_secs(5), + client.read_to_end(&mut response), + ) + .await + .expect("the proxy forwards and closes the fixture response") + .unwrap(); fixture.await.unwrap(); let response = String::from_utf8_lossy(&response); From 8e94ffbdd59c7dcd0ec0da1a7f93267c42a7342f Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Fri, 23 Oct 2026 08:14:59 +0000 Subject: [PATCH 56/70] test: improve proxy response assertion diagnostics Reorder the fixture await so the response is inspected before the fixture task is joined, and include the captured calls in the status assertion message to make failures easier to diagnose. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- .../tinycomputer-browser/tests/test_connector_tests.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/tinycomputer-browser/tests/test_connector_tests.rs b/crates/tinycomputer-browser/tests/test_connector_tests.rs index 8047c763e..f8da8d932 100644 --- a/crates/tinycomputer-browser/tests/test_connector_tests.rs +++ b/crates/tinycomputer-browser/tests/test_connector_tests.rs @@ -137,11 +137,14 @@ async fn proxy_consumes_the_exact_public_grant_before_fixture_connector_mapping( .await .expect("the proxy forwards and closes the fixture response") .unwrap(); - fixture.await.unwrap(); - let response = String::from_utf8_lossy(&response); - assert!(response.starts_with("HTTP/1.1 200 OK\r\n")); + assert!( + response.starts_with("HTTP/1.1 200 OK\r\n"), + "unexpected proxy response {response:?}; calls {:?}", + calls.lock().unwrap() + ); assert!(response.ends_with("fixture")); + fixture.await.unwrap(); assert_eq!( *calls.lock().unwrap(), [ From b540493e6ee305f861db4e6a723856d67464aed3 Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Fri, 23 Oct 2026 08:15:16 +0000 Subject: [PATCH 57/70] test(tinycomputer-browser): update proxy connector fixture credentials The fixture password constant and the proxy auth header now use the tinycomputer username and a renamed secret so the test matches the credentials the proxy actually expects. The listener accept call was also reflowed to satisfy formatting. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- .../tests/test_connector_tests.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/crates/tinycomputer-browser/tests/test_connector_tests.rs b/crates/tinycomputer-browser/tests/test_connector_tests.rs index f8da8d932..ca6a763db 100644 --- a/crates/tinycomputer-browser/tests/test_connector_tests.rs +++ b/crates/tinycomputer-browser/tests/test_connector_tests.rs @@ -17,7 +17,7 @@ use tokio::{ }; const SESSION: &str = "fixture-public-dial-session"; -const PASSWORD: &str = "fixture-password"; +const PASSWORD: &str = "fixture-proxy-secret"; struct ExactPublicGrant { address: SocketAddr, @@ -96,13 +96,11 @@ async fn proxy_consumes_the_exact_public_grant_before_fixture_connector_mapping( .unwrap(); let fixture = tokio::spawn(async move { - let (mut stream, _) = tokio::time::timeout( - std::time::Duration::from_secs(5), - fixture_listener.accept(), - ) - .await - .expect("fixture connector reaches the local listener") - .unwrap(); + let (mut stream, _) = + tokio::time::timeout(std::time::Duration::from_secs(5), fixture_listener.accept()) + .await + .expect("fixture connector reaches the local listener") + .unwrap(); let mut request = vec![0; 2048]; let read = stream.read(&mut request).await.unwrap(); let request = String::from_utf8_lossy(&request[..read]); @@ -117,7 +115,7 @@ async fn proxy_consumes_the_exact_public_grant_before_fixture_connector_mapping( let mut client = TcpStream::connect(proxy.url().replace("http://", "")) .await .unwrap(); - let auth = base64::engine::general_purpose::STANDARD.encode(format!("{SESSION}:{PASSWORD}")); + let auth = base64::engine::general_purpose::STANDARD.encode(format!("tinycomputer:{PASSWORD}")); client .write_all( format!( From 04453a7e2c455e529c85205909fc8bcdcddbb830 Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Fri, 23 Oct 2026 08:16:24 +0000 Subject: [PATCH 58/70] test: allow panics and unwraps in connector tests Add a crate-level allow for clippy's expect_used, panic, and unwrap_used lints in the feature-gated connector integration tests, since panicking assertions are the intended style there. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- crates/tinycomputer-browser/tests/test_connector_tests.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/tinycomputer-browser/tests/test_connector_tests.rs b/crates/tinycomputer-browser/tests/test_connector_tests.rs index ca6a763db..cbc83dd55 100644 --- a/crates/tinycomputer-browser/tests/test_connector_tests.rs +++ b/crates/tinycomputer-browser/tests/test_connector_tests.rs @@ -1,5 +1,6 @@ //! Feature-gated integration tests for host-provided fixture connectors. #![cfg(feature = "test-connector")] +#![allow(clippy::expect_used, clippy::panic, clippy::unwrap_used)] use std::{ future::Future, From 9e67cbb704f0af41ff4a70fb5d752d5eb90dafc0 Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Fri, 23 Oct 2026 08:17:29 +0000 Subject: [PATCH 59/70] feat(browser): add test connector hook for egress integration tests Adds a test-connector feature that lets host integration tests replace only the final TCP connect in the egress proxy, so authorization, grant consumption, and proxy forwarding still run on their normal paths. The fixture connector receives the exact approved socket and maps it to a local listener, keeping live tests off the public network. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- crates/tinycomputer-browser/src/egress/mod.rs | 9 ++ crates/tinycomputer-browser/src/lib.rs | 2 + crates/tinycomputer-browser/src/linked/mod.rs | 62 +++++++++++-- crates/tinycomputer/Cargo.toml | 2 + crates/tinycomputer/src/lib.rs | 4 + crates/tinycomputer/src/test_support.rs | 52 +++++++++++ .../browser_egress_live_tests/mod.rs | 2 + .../public_connector_tests.rs | 89 +++++++++++++++++++ .../src/tinybus_module/dispatch/service.rs | 14 ++- 9 files changed, 225 insertions(+), 11 deletions(-) create mode 100644 crates/tinycomputer/src/test_support.rs create mode 100644 crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/public_connector_tests.rs diff --git a/crates/tinycomputer-browser/src/egress/mod.rs b/crates/tinycomputer-browser/src/egress/mod.rs index ba7df75b4..391c914f1 100644 --- a/crates/tinycomputer-browser/src/egress/mod.rs +++ b/crates/tinycomputer-browser/src/egress/mod.rs @@ -15,6 +15,15 @@ mod forward; mod request; mod serve; +/// Fixture-only replacement for the final TCP connect in host integration tests. +/// +/// The callback receives the exact socket selected by authorization and grant +/// consumption. Test connectors should map it to a local fixture only. +#[cfg(feature = "test-connector")] +pub type TestConnector = Arc< + dyn Fn(SocketAddr) -> Pin> + Send>> + Send + Sync, +>; + #[cfg(test)] pub(crate) use serve::connect_approved_addresses; diff --git a/crates/tinycomputer-browser/src/lib.rs b/crates/tinycomputer-browser/src/lib.rs index 4786da69a..da43d7a3a 100644 --- a/crates/tinycomputer-browser/src/lib.rs +++ b/crates/tinycomputer-browser/src/lib.rs @@ -57,6 +57,8 @@ pub use action_gate::{ ActionContext, ActionGate, ActionRequest, ActionTarget, ActionVerdict, AllowAllActions, ObservationKind, }; +#[cfg(feature = "test-connector")] +pub use egress::TestConnector; pub use egress::{BrowserDialTarget, DialGrant, EgressAuthorizer, EgressProxy}; pub use engine::{Engine, Launcher, Reply}; pub use error::{Error, Result}; diff --git a/crates/tinycomputer-browser/src/linked/mod.rs b/crates/tinycomputer-browser/src/linked/mod.rs index 191ec8419..ee1d0920d 100644 --- a/crates/tinycomputer-browser/src/linked/mod.rs +++ b/crates/tinycomputer-browser/src/linked/mod.rs @@ -30,6 +30,8 @@ pub struct AgentBrowser; #[derive(Clone)] pub struct EnforcedAgentBrowser { authorizer: Arc, + #[cfg(feature = "test-connector")] + test_connector: Option, } impl std::fmt::Debug for EnforcedAgentBrowser { @@ -42,7 +44,23 @@ impl EnforcedAgentBrowser { /// Use the authenticated host callback for every launched session. #[must_use] pub fn new(authorizer: Arc) -> Self { - Self { authorizer } + Self { + authorizer, + #[cfg(feature = "test-connector")] + test_connector: None, + } + } + + /// Replace only the final TCP connect for a fixture-backed host test. + /// + /// Authorization, grant consumption, and proxy forwarding remain on their + /// normal paths. The fixture connector receives the exact approved socket + /// and must map it to a local listener rather than public network access. + #[cfg(feature = "test-connector")] + #[must_use] + pub fn with_test_connector(mut self, connector: crate::egress::TestConnector) -> Self { + self.test_connector = Some(connector); + self } } @@ -54,6 +72,8 @@ impl Launcher for AgentBrowser { proxy: None, proxy_session_id: String::new(), enforced_launch: false, + #[cfg(feature = "test-connector")] + test_connector: None, }) } } @@ -66,6 +86,8 @@ impl Launcher for EnforcedAgentBrowser { proxy: None, proxy_session_id: private_session_id(), enforced_launch: false, + #[cfg(feature = "test-connector")] + test_connector: self.test_connector.clone(), }) } } @@ -76,6 +98,8 @@ struct Linked { proxy: Option, proxy_session_id: String, enforced_launch: bool, + #[cfg(feature = "test-connector")] + test_connector: Option, } impl Engine for Linked { @@ -97,13 +121,35 @@ impl Engine for Linked { return failure_reply(&command, "network policy has no host authorizer"); }; if self.proxy.is_none() { - match EgressProxy::bind( - authorizer, - self.proxy_session_id.clone(), - self.proxy_session_id.clone(), - ) - .await - { + let proxy = { + #[cfg(feature = "test-connector")] + if let Some(connector) = self.test_connector.clone() { + EgressProxy::bind_with_test_connector( + authorizer, + self.proxy_session_id.clone(), + self.proxy_session_id.clone(), + move |address| connector(address), + ) + .await + } else { + EgressProxy::bind( + authorizer, + self.proxy_session_id.clone(), + self.proxy_session_id.clone(), + ) + .await + } + #[cfg(not(feature = "test-connector"))] + { + EgressProxy::bind( + authorizer, + self.proxy_session_id.clone(), + self.proxy_session_id.clone(), + ) + .await + } + }; + match proxy { Ok(proxy) => self.proxy = Some(proxy), Err(_) => { return failure_reply(&command, "network policy proxy could not start"); diff --git a/crates/tinycomputer/Cargo.toml b/crates/tinycomputer/Cargo.toml index 10aefe96b..fa836aca8 100644 --- a/crates/tinycomputer/Cargo.toml +++ b/crates/tinycomputer/Cargo.toml @@ -64,6 +64,8 @@ default = [] # process and is only touched on macOS/Windows, so co-linking is safe. static-link = [] linked = ["static-link"] +# Exposes a fixture-only TCP connector override for host/module integration tests. +test-connector = ["tinycomputer-browser/test-connector"] [lints] workspace = true diff --git a/crates/tinycomputer/src/lib.rs b/crates/tinycomputer/src/lib.rs index 67954253f..782f91f81 100644 --- a/crates/tinycomputer/src/lib.rs +++ b/crates/tinycomputer/src/lib.rs @@ -92,6 +92,10 @@ mod tinybus_module; +/// Test-only controls for host/module integration fixtures. +#[cfg(feature = "test-connector")] +pub mod test_support; + /// Constructs this module for registration with an in-process `TinyBus` host. /// /// Only present under the `static-link` feature, which replaces the C exports diff --git a/crates/tinycomputer/src/test_support.rs b/crates/tinycomputer/src/test_support.rs new file mode 100644 index 000000000..34cd2cd28 --- /dev/null +++ b/crates/tinycomputer/src/test_support.rs @@ -0,0 +1,52 @@ +//! Feature-gated controls used only by host/module integration tests. + +use std::sync::{Mutex, OnceLock}; + +use tinycomputer_browser::TestConnector; + +static BROWSER_EGRESS_CONNECTOR: OnceLock>> = OnceLock::new(); + +/// Installs a fixture-only replacement for the browser proxy's final TCP connect. +/// +/// The normal TinyComputer module setup still constructs its authenticated +/// `BusAuthorizer` and `EnforcedAgentBrowser`; only the final connector changes. +/// The connector receives the exact address selected and consumed by the +/// authorizer and must map it to a local fixture listener. The returned guard +/// clears the override when dropped. +/// +/// # Errors +/// +/// Returns an error if another fixture already installed an override or the +/// process-local test hook was poisoned. +pub fn install_browser_egress_connector( + connector: TestConnector, +) -> Result { + let mut installed = connector_slot() + .lock() + .map_err(|_| "browser egress connector test hook was poisoned")?; + if installed.is_some() { + return Err("a browser egress connector override is already installed"); + } + *installed = Some(connector); + Ok(BrowserEgressConnectorGuard) +} + +/// Guard that removes a previously installed fixture connector. +#[derive(Debug)] +pub struct BrowserEgressConnectorGuard; + +impl Drop for BrowserEgressConnectorGuard { + fn drop(&mut self) { + if let Ok(mut installed) = connector_slot().lock() { + installed.take(); + } + } +} + +pub(crate) fn browser_egress_connector() -> Option { + connector_slot().lock().ok()?.clone() +} + +fn connector_slot() -> &'static Mutex> { + BROWSER_EGRESS_CONNECTOR.get_or_init(|| Mutex::new(None)) +} diff --git a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/mod.rs b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/mod.rs index b48fc4c31..d5edadc21 100644 --- a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/mod.rs +++ b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/mod.rs @@ -2,6 +2,8 @@ #![allow(clippy::expect_used, clippy::panic, clippy::unwrap_used)] mod authority_denial_tests; +#[cfg(feature = "test-connector")] +mod public_connector_tests; mod transport_classes_tests; mod worker; diff --git a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/public_connector_tests.rs b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/public_connector_tests.rs new file mode 100644 index 000000000..d151edf60 --- /dev/null +++ b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/public_connector_tests.rs @@ -0,0 +1,89 @@ +//! Live module test for the fixture-only public-address connector override. +#![allow(clippy::expect_used, clippy::panic, clippy::unwrap_used)] + +use super::*; +use std::{future::Future, io, net::SocketAddr, pin::Pin}; +use tinycomputer_browser::TestConnector; +use tokio::net::TcpStream; + +#[tokio::test] +async fn loaded_module_consumes_public_socket_before_fixture_mapping() -> tinybus::Result<()> { + let local_listener = tokio::net::TcpListener::bind("127.0.0.1:0").await?; + let page_port = local_listener.local_addr()?.port(); + let public_socket = SocketAddr::from(([8, 8, 8, 8], page_port)); + let calls = Arc::new(Mutex::new(Vec::::new())); + let connector_calls = calls.clone(); + let fixture_address = local_listener.local_addr()?; + let connector: TestConnector = Arc::new(move |address| { + let calls = connector_calls.clone(); + Box::pin(async move { + assert_eq!(address, public_socket); + calls.lock().unwrap().push(format!("connect:{address}")); + // Test-only mapping: the proxy authorized 8.8.8.8, but this closure + // makes no public connection and reaches only the local fixture. + TcpStream::connect(fixture_address).await + }) as Pin> + Send>> + }); + let _connector_guard = tinycomputer::test_support::install_browser_egress_connector(connector) + .expect("fixture connector installs once"); + + let body = b"public fixture"; + let extra_connections = Arc::new(AtomicUsize::new(0)); + let (served_tx, served_rx) = tokio::sync::oneshot::channel(); + let fixture = tokio::spawn(serve_fixture( + local_listener, + body.to_vec(), + extra_connections, + served_tx, + None, + )); + let browser = start_browser_with_fixture_host( + public_socket.to_string(), + page_port, + "/public-control", + served_rx, + ) + .await?; + + let expected_authorize = format!("authorize:fixture-policy:41:fixture.test:{page_port}"); + let expected_consume = format!("consume:{public_socket}"); + let observed = browser.observations.lock().unwrap().clone(); + assert!(observed.iter().any(|call| call == &expected_authorize)); + assert!(observed.iter().any(|call| call == &expected_consume)); + assert_eq!( + calls.lock().unwrap().as_slice(), + [format!("connect:{public_socket}")], + "the connector receives precisely the socket consumed through the TinyBus authorizer" + ); + assert!( + browser + .observations + .lock() + .unwrap() + .iter() + .position(|call| call == &expected_consume) + < browser + .observations + .lock() + .unwrap() + .iter() + .position(|call| call.starts_with("validate:")), + "the TinyBus host consumed the grant before proxy lease validation and forwarding" + ); + + let closed: DesktopResponse = browser + .proxy + .call( + browser_names::methods::CLOSE_SESSION, + (serde_json::json!({"session": browser.session}),), + ) + .await?; + assert!( + closed.ok, + "browser session did not close: {:?}", + closed.error + ); + browser.broker_task.abort(); + fixture.abort(); + Ok(()) +} diff --git a/crates/tinycomputer/src/tinybus_module/dispatch/service.rs b/crates/tinycomputer/src/tinybus_module/dispatch/service.rs index 3cfb9f04d..0ffa3473b 100644 --- a/crates/tinycomputer/src/tinybus_module/dispatch/service.rs +++ b/crates/tinycomputer/src/tinybus_module/dispatch/service.rs @@ -42,9 +42,17 @@ impl DesktopService { let defaults = BrowserDefaults::from_config(config) .map_err(|error| TinyBusError::failed(error.to_string()))?; let browser = if let Some(egress) = defaults.egress { - Arc::new(Browser::new(Arc::new(EnforcedAgentBrowser::new(Arc::new( - BusAuthorizer::new(connection.clone(), egress.policy_id, egress.generation), - ))))) + let launcher = EnforcedAgentBrowser::new(Arc::new(BusAuthorizer::new( + connection.clone(), + egress.policy_id, + egress.generation, + ))); + #[cfg(feature = "test-connector")] + let launcher = crate::test_support::browser_egress_connector() + .map_or(launcher.clone(), |connector| { + launcher.with_test_connector(connector) + }); + Arc::new(Browser::new(Arc::new(launcher))) } else { Arc::new(Browser::new(Arc::new(AgentBrowser))) }; From 2b8ea53dfe33d25e94ad5cd62270b78ce6082e72 Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Fri, 23 Oct 2026 08:19:07 +0000 Subject: [PATCH 60/70] test(browser_egress): use crate-relative path for connector helper The live test referenced the connector install helper through the tinycomputer crate name, which does not resolve from within the crate's own test module. Switching to a crate-relative path keeps the test compiling without changing what it exercises. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- .../browser_egress_live_tests/public_connector_tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/public_connector_tests.rs b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/public_connector_tests.rs index d151edf60..c0d41381f 100644 --- a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/public_connector_tests.rs +++ b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/public_connector_tests.rs @@ -24,7 +24,7 @@ async fn loaded_module_consumes_public_socket_before_fixture_mapping() -> tinybu TcpStream::connect(fixture_address).await }) as Pin> + Send>> }); - let _connector_guard = tinycomputer::test_support::install_browser_egress_connector(connector) + let _connector_guard = crate::test_support::install_browser_egress_connector(connector) .expect("fixture connector installs once"); let body = b"public fixture"; From ee8415276cd0957110191c99ebeae52c313d96b2 Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Fri, 23 Oct 2026 08:20:47 +0000 Subject: [PATCH 61/70] test(browser_egress): scope connector overrides by policy and generation The test connector override now records the policy id and generation it was installed for, and lookups only return it when both match, so a fixture can no longer leak into a differently scoped egress policy. The live test helpers were extended to start browsers under an explicit policy and generation and to share observations across sessions, which lets the new scoping behaviour be exercised. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- crates/tinycomputer/src/test_support.rs | 29 +++++++++--- .../browser_egress_live_tests/mod.rs | 39 ++++++++++++++-- .../public_connector_tests.rs | 45 ++++++++++--------- .../src/tinybus_module/dispatch/service.rs | 10 +++-- 4 files changed, 91 insertions(+), 32 deletions(-) diff --git a/crates/tinycomputer/src/test_support.rs b/crates/tinycomputer/src/test_support.rs index 34cd2cd28..aa5a20a07 100644 --- a/crates/tinycomputer/src/test_support.rs +++ b/crates/tinycomputer/src/test_support.rs @@ -4,7 +4,13 @@ use std::sync::{Mutex, OnceLock}; use tinycomputer_browser::TestConnector; -static BROWSER_EGRESS_CONNECTOR: OnceLock>> = OnceLock::new(); +static BROWSER_EGRESS_CONNECTOR: OnceLock>> = OnceLock::new(); + +struct ScopedConnector { + policy_id: String, + generation: u64, + connector: TestConnector, +} /// Installs a fixture-only replacement for the browser proxy's final TCP connect. /// @@ -19,15 +25,24 @@ static BROWSER_EGRESS_CONNECTOR: OnceLock>> = OnceLo /// Returns an error if another fixture already installed an override or the /// process-local test hook was poisoned. pub fn install_browser_egress_connector( + policy_id: String, + generation: u64, connector: TestConnector, ) -> Result { + if policy_id.is_empty() { + return Err("browser egress connector scope requires a policy id"); + } let mut installed = connector_slot() .lock() .map_err(|_| "browser egress connector test hook was poisoned")?; if installed.is_some() { return Err("a browser egress connector override is already installed"); } - *installed = Some(connector); + *installed = Some(ScopedConnector { + policy_id, + generation, + connector, + }); Ok(BrowserEgressConnectorGuard) } @@ -43,10 +58,14 @@ impl Drop for BrowserEgressConnectorGuard { } } -pub(crate) fn browser_egress_connector() -> Option { - connector_slot().lock().ok()?.clone() +pub(crate) fn browser_egress_connector(policy_id: &str, generation: u64) -> Option { + let installed = connector_slot().lock().ok()?; + installed.as_ref().and_then(|scoped| { + (scoped.policy_id == policy_id && scoped.generation == generation) + .then(|| scoped.connector.clone()) + }) } -fn connector_slot() -> &'static Mutex> { +fn connector_slot() -> &'static Mutex> { BROWSER_EGRESS_CONNECTOR.get_or_init(|| Mutex::new(None)) } diff --git a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/mod.rs b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/mod.rs index d5edadc21..8f76258aa 100644 --- a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/mod.rs +++ b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/mod.rs @@ -147,6 +147,7 @@ fn successful_data(reply: &DesktopResponse) -> &serde_json::Value { struct LiveBrowser { proxy: tinybus::Proxy, session: serde_json::Value, + navigation: serde_json::Value, allowed: Arc, observations: Arc>>, broker_task: tokio::task::JoinHandle>, @@ -160,7 +161,16 @@ async fn start_browser_with_fixture_host( page_path: &str, served: tokio::sync::oneshot::Receiver<()>, ) -> tinybus::Result { - start_browser_with_fixture_hosts(vec![allowed_address], page_port, page_path, served).await + start_browser_with_fixture_hosts_for_policy( + vec![allowed_address], + page_port, + page_path, + served, + "fixture-policy", + 41, + None, + ) + .await } async fn start_browser_with_fixture_hosts( @@ -168,13 +178,34 @@ async fn start_browser_with_fixture_hosts( page_port: u16, page_path: &str, served: tokio::sync::oneshot::Receiver<()>, +) -> tinybus::Result { + start_browser_with_fixture_hosts_for_policy( + allowed_addresses, + page_port, + page_path, + served, + "fixture-policy", + 41, + None, + ) + .await +} + +async fn start_browser_with_fixture_hosts_for_policy( + allowed_addresses: Vec, + page_port: u16, + page_path: &str, + served: tokio::sync::oneshot::Receiver<()>, + policy_id: &str, + generation: u64, + shared_observations: Option>>>, ) -> tinybus::Result { let bus = MemoryBus::new(); let broker = Broker::new(); let broker_task = broker.spawn(bus.clone()); let host_connection = Connection::connect(bus.connect().await?).await?; let allowed = Arc::new(AtomicBool::new(true)); - let observations = Arc::new(Mutex::new(Vec::new())); + let observations = shared_observations.unwrap_or_else(|| Arc::new(Mutex::new(Vec::new()))); host_connection .serve_at( browser_egress::OBJECT_PATH.try_into()?, @@ -196,7 +227,7 @@ async fn start_browser_with_fixture_hosts( .attach_linked_with_config( module, serde_json::json!({ - "browser": {"egress": {"policy_id": "fixture-policy", "generation": 41}} + "browser": {"egress": {"policy_id": policy_id, "generation": generation}} }), ) .expect("TinyComputer module loads through ModuleHost"); @@ -223,6 +254,7 @@ async fn start_browser_with_fixture_hosts( "authorized fixture navigation failed: {:?}", navigated.error ); + let navigation = successful_data(&navigated).clone(); tokio::time::timeout(Duration::from_secs(10), served) .await .expect("fixture page is served") @@ -231,6 +263,7 @@ async fn start_browser_with_fixture_hosts( Ok(LiveBrowser { proxy, session, + navigation, allowed, observations, broker_task, diff --git a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/public_connector_tests.rs b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/public_connector_tests.rs index c0d41381f..ed79baea3 100644 --- a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/public_connector_tests.rs +++ b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/public_connector_tests.rs @@ -24,8 +24,14 @@ async fn loaded_module_consumes_public_socket_before_fixture_mapping() -> tinybu TcpStream::connect(fixture_address).await }) as Pin> + Send>> }); - let _connector_guard = crate::test_support::install_browser_egress_connector(connector) - .expect("fixture connector installs once"); + let policy_id = "fixture-public-control"; + let generation = 973; + let _connector_guard = crate::test_support::install_browser_egress_connector( + policy_id.into(), + generation, + connector, + ) + .expect("fixture connector installs once"); let body = b"public fixture"; let extra_connections = Arc::new(AtomicUsize::new(0)); @@ -37,38 +43,37 @@ async fn loaded_module_consumes_public_socket_before_fixture_mapping() -> tinybu served_tx, None, )); - let browser = start_browser_with_fixture_host( - public_socket.to_string(), + let browser = start_browser_with_fixture_hosts_for_policy( + vec![public_socket.to_string()], page_port, "/public-control", served_rx, + policy_id, + generation, + Some(calls.clone()), ) .await?; - let expected_authorize = format!("authorize:fixture-policy:41:fixture.test:{page_port}"); + assert_eq!(browser.navigation["title"], "public fixture"); + let expected_authorize = format!("authorize:{policy_id}:{generation}:fixture.test:{page_port}"); let expected_consume = format!("consume:{public_socket}"); let observed = browser.observations.lock().unwrap().clone(); assert!(observed.iter().any(|call| call == &expected_authorize)); assert!(observed.iter().any(|call| call == &expected_consume)); + let observed_calls = calls.lock().unwrap().clone(); assert_eq!( - calls.lock().unwrap().as_slice(), - [format!("connect:{public_socket}")], - "the connector receives precisely the socket consumed through the TinyBus authorizer" + &observed_calls[..3], + [ + expected_authorize, + expected_consume, + format!("connect:{public_socket}"), + ], + "the exact TinyBus-consumed socket is passed to the fixture connector after authorization" ); assert!( - browser - .observations - .lock() - .unwrap() + observed_calls[3..] .iter() - .position(|call| call == &expected_consume) - < browser - .observations - .lock() - .unwrap() - .iter() - .position(|call| call.starts_with("validate:")), - "the TinyBus host consumed the grant before proxy lease validation and forwarding" + .all(|call| call.starts_with("validate:")) ); let closed: DesktopResponse = browser diff --git a/crates/tinycomputer/src/tinybus_module/dispatch/service.rs b/crates/tinycomputer/src/tinybus_module/dispatch/service.rs index 0ffa3473b..8a5f8933b 100644 --- a/crates/tinycomputer/src/tinybus_module/dispatch/service.rs +++ b/crates/tinycomputer/src/tinybus_module/dispatch/service.rs @@ -42,16 +42,18 @@ impl DesktopService { let defaults = BrowserDefaults::from_config(config) .map_err(|error| TinyBusError::failed(error.to_string()))?; let browser = if let Some(egress) = defaults.egress { + #[cfg(feature = "test-connector")] + let test_connector = + crate::test_support::browser_egress_connector(&egress.policy_id, egress.generation); let launcher = EnforcedAgentBrowser::new(Arc::new(BusAuthorizer::new( connection.clone(), egress.policy_id, egress.generation, ))); #[cfg(feature = "test-connector")] - let launcher = crate::test_support::browser_egress_connector() - .map_or(launcher.clone(), |connector| { - launcher.with_test_connector(connector) - }); + let launcher = test_connector.map_or(launcher.clone(), |connector| { + launcher.with_test_connector(connector) + }); Arc::new(Browser::new(Arc::new(launcher))) } else { Arc::new(Browser::new(Arc::new(AgentBrowser))) From 71840080be2067d80d3aecf7b961ff394a420aa9 Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Fri, 23 Oct 2026 08:21:22 +0000 Subject: [PATCH 62/70] test(browser_egress): add failure message to callback order assertion The assertion that all calls after the third start with "validate:" now includes a message printing the observed calls, so a failure shows the actual callback and connector event order instead of a bare panic. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- .../browser_egress_live_tests/public_connector_tests.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/public_connector_tests.rs b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/public_connector_tests.rs index ed79baea3..b7c8d0ed2 100644 --- a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/public_connector_tests.rs +++ b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/public_connector_tests.rs @@ -73,7 +73,8 @@ async fn loaded_module_consumes_public_socket_before_fixture_mapping() -> tinybu assert!( observed_calls[3..] .iter() - .all(|call| call.starts_with("validate:")) + .all(|call| call.starts_with("validate:")), + "unexpected callback or connector event order: {observed_calls:?}" ); let closed: DesktopResponse = browser From 4e33cd04147902e181164806c8144e164093ef77 Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Fri, 23 Oct 2026 08:21:51 +0000 Subject: [PATCH 63/70] test(browser_egress): assert lease validation precedes background requests The live public connector test now expects the fixture lease validation call to appear immediately after the socket connect, and checks that any remaining calls are background public requests that stop at authorization rather than reaching the connector. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- .../public_connector_tests.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/public_connector_tests.rs b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/public_connector_tests.rs index b7c8d0ed2..17bf63971 100644 --- a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/public_connector_tests.rs +++ b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/public_connector_tests.rs @@ -62,19 +62,20 @@ async fn loaded_module_consumes_public_socket_before_fixture_mapping() -> tinybu assert!(observed.iter().any(|call| call == &expected_consume)); let observed_calls = calls.lock().unwrap().clone(); assert_eq!( - &observed_calls[..3], + &observed_calls[..4], [ expected_authorize, expected_consume, format!("connect:{public_socket}"), + "validate:fixture-lease".into(), ], - "the exact TinyBus-consumed socket is passed to the fixture connector after authorization" + "the exact TinyBus-consumed socket is passed to the fixture connector before lease validation" ); assert!( - observed_calls[3..] + observed_calls[4..] .iter() - .all(|call| call.starts_with("validate:")), - "unexpected callback or connector event order: {observed_calls:?}" + .all(|call| call.starts_with("authorize:") && call.contains(":www.google.com:443")), + "background public requests must stop at authorization without consume or connector: {observed_calls:?}" ); let closed: DesktopResponse = browser From 415bdba3184b9e707c784c929ebbf3414abdd3ec Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Fri, 23 Oct 2026 08:22:45 +0000 Subject: [PATCH 64/70] refactor(tinycomputer): move test connector override into browser config The feature-gated test_support module and its process-global connector slot are gone; the test-connector override now lives on BrowserDefaults as an exact public-to-loopback socket mapping, so fixtures no longer need a global install step and the connector is scoped to the configuration that created it. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- crates/tinycomputer/src/lib.rs | 4 - crates/tinycomputer/src/test_support.rs | 71 ------------------ .../tinycomputer/src/tinybus_module/config.rs | 74 ++++++++++++++++++- .../src/tinybus_module/dispatch/service.rs | 12 +-- 4 files changed, 79 insertions(+), 82 deletions(-) delete mode 100644 crates/tinycomputer/src/test_support.rs diff --git a/crates/tinycomputer/src/lib.rs b/crates/tinycomputer/src/lib.rs index 782f91f81..67954253f 100644 --- a/crates/tinycomputer/src/lib.rs +++ b/crates/tinycomputer/src/lib.rs @@ -92,10 +92,6 @@ mod tinybus_module; -/// Test-only controls for host/module integration fixtures. -#[cfg(feature = "test-connector")] -pub mod test_support; - /// Constructs this module for registration with an in-process `TinyBus` host. /// /// Only present under the `static-link` feature, which replaces the C exports diff --git a/crates/tinycomputer/src/test_support.rs b/crates/tinycomputer/src/test_support.rs deleted file mode 100644 index aa5a20a07..000000000 --- a/crates/tinycomputer/src/test_support.rs +++ /dev/null @@ -1,71 +0,0 @@ -//! Feature-gated controls used only by host/module integration tests. - -use std::sync::{Mutex, OnceLock}; - -use tinycomputer_browser::TestConnector; - -static BROWSER_EGRESS_CONNECTOR: OnceLock>> = OnceLock::new(); - -struct ScopedConnector { - policy_id: String, - generation: u64, - connector: TestConnector, -} - -/// Installs a fixture-only replacement for the browser proxy's final TCP connect. -/// -/// The normal TinyComputer module setup still constructs its authenticated -/// `BusAuthorizer` and `EnforcedAgentBrowser`; only the final connector changes. -/// The connector receives the exact address selected and consumed by the -/// authorizer and must map it to a local fixture listener. The returned guard -/// clears the override when dropped. -/// -/// # Errors -/// -/// Returns an error if another fixture already installed an override or the -/// process-local test hook was poisoned. -pub fn install_browser_egress_connector( - policy_id: String, - generation: u64, - connector: TestConnector, -) -> Result { - if policy_id.is_empty() { - return Err("browser egress connector scope requires a policy id"); - } - let mut installed = connector_slot() - .lock() - .map_err(|_| "browser egress connector test hook was poisoned")?; - if installed.is_some() { - return Err("a browser egress connector override is already installed"); - } - *installed = Some(ScopedConnector { - policy_id, - generation, - connector, - }); - Ok(BrowserEgressConnectorGuard) -} - -/// Guard that removes a previously installed fixture connector. -#[derive(Debug)] -pub struct BrowserEgressConnectorGuard; - -impl Drop for BrowserEgressConnectorGuard { - fn drop(&mut self) { - if let Ok(mut installed) = connector_slot().lock() { - installed.take(); - } - } -} - -pub(crate) fn browser_egress_connector(policy_id: &str, generation: u64) -> Option { - let installed = connector_slot().lock().ok()?; - installed.as_ref().and_then(|scoped| { - (scoped.policy_id == policy_id && scoped.generation == generation) - .then(|| scoped.connector.clone()) - }) -} - -fn connector_slot() -> &'static Mutex> { - BROWSER_EGRESS_CONNECTOR.get_or_init(|| Mutex::new(None)) -} diff --git a/crates/tinycomputer/src/tinybus_module/config.rs b/crates/tinycomputer/src/tinybus_module/config.rs index 45560e8c1..48198ca55 100644 --- a/crates/tinycomputer/src/tinybus_module/config.rs +++ b/crates/tinycomputer/src/tinybus_module/config.rs @@ -7,6 +7,8 @@ //! request. use tinycomputer_browser::{CursorPace, Perception, ScreenCursor, SessionOptions, Settle}; +#[cfg(feature = "test-connector")] +use std::{future::Future, io, net::SocketAddr, pin::Pin, sync::Arc}; use crate::Result; @@ -31,6 +33,9 @@ pub(crate) struct BrowserDefaults { pub(crate) prelaunch: bool, /// Immutable `TinySecurity` scope captured from host-private configuration. pub(crate) egress: Option, + /// Exact public-to-local mapping available only in test-connector builds. + #[cfg(feature = "test-connector")] + pub(crate) test_connector_map: Option, } /// Host-selected policy identity and generation; never an agent argument. @@ -40,6 +45,33 @@ pub(crate) struct BrowserEgressConfig { pub(crate) generation: u64, } +/// A single exact public socket mapped to a loopback fixture by test builds. +#[cfg(feature = "test-connector")] +#[derive(Debug, Clone, PartialEq, Eq)] +pub(crate) struct TestConnectorMap { + approved: SocketAddr, + fixture: SocketAddr, +} + +#[cfg(feature = "test-connector")] +impl TestConnectorMap { + fn connector(&self) -> tinycomputer_browser::TestConnector { + let approved = self.approved; + let fixture = self.fixture; + Arc::new(move |address| { + Box::pin(async move { + if address != approved { + return Err(io::Error::new( + io::ErrorKind::PermissionDenied, + "test connector refused an address outside its exact mapping", + )); + } + tokio::net::TcpStream::connect(fixture).await + }) as Pin> + Send>> + }) + } +} + impl std::fmt::Debug for BrowserEgressConfig { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.write_str("BrowserEgressConfig([REDACTED])") @@ -56,6 +88,8 @@ impl Default for BrowserDefaults { settle: Settle::default(), prelaunch: true, egress: None, + #[cfg(feature = "test-connector")] + test_connector_map: None, } } } @@ -128,7 +162,14 @@ impl BrowserDefaults { .and_then(serde_json::Value::as_u64) .filter(|generation| *generation > 0) .ok_or_else(invalid)?; - if egress.len() != 2 + #[cfg(feature = "test-connector")] + { + defaults.test_connector_map = test_connector_map(egress.get("test_connector_map"), &invalid)?; + } + let expected_egress_keys = 2 + usize::from( + cfg!(feature = "test-connector") && egress.contains_key("test_connector_map"), + ); + if egress.len() != expected_egress_keys || browser.contains_key("args") || browser.contains_key("executable") { @@ -177,6 +218,37 @@ impl BrowserDefaults { } } +#[cfg(feature = "test-connector")] +fn test_connector_map( + value: Option<&serde_json::Value>, + invalid: &impl Fn() -> crate::Error, +) -> Result> { + let Some(value) = value else { + return Ok(None); + }; + let object = value.as_object().ok_or_else(invalid)?; + if object.len() != 2 { + return Err(invalid()); + } + let parse = |name: &str| -> Result { + object + .get(name) + .and_then(serde_json::Value::as_str) + .and_then(|value| value.parse().ok()) + .ok_or_else(invalid) + }; + let approved = parse("approved")?; + let fixture = parse("fixture")?; + if approved.ip().to_string() != "8.8.8.8" + || !fixture.ip().is_loopback() + || approved.port() != fixture.port() + || object.keys().any(|key| !["approved", "fixture"].contains(&key.as_str())) + { + return Err(invalid()); + } + Ok(Some(TestConnectorMap { approved, fixture })) +} + /// Whether the host explicitly selected the trace/report callback. pub(crate) fn trace_sink_destination( config: &serde_json::Value, diff --git a/crates/tinycomputer/src/tinybus_module/dispatch/service.rs b/crates/tinycomputer/src/tinybus_module/dispatch/service.rs index 8a5f8933b..64081bf70 100644 --- a/crates/tinycomputer/src/tinybus_module/dispatch/service.rs +++ b/crates/tinycomputer/src/tinybus_module/dispatch/service.rs @@ -42,18 +42,18 @@ impl DesktopService { let defaults = BrowserDefaults::from_config(config) .map_err(|error| TinyBusError::failed(error.to_string()))?; let browser = if let Some(egress) = defaults.egress { - #[cfg(feature = "test-connector")] - let test_connector = - crate::test_support::browser_egress_connector(&egress.policy_id, egress.generation); let launcher = EnforcedAgentBrowser::new(Arc::new(BusAuthorizer::new( connection.clone(), egress.policy_id, egress.generation, ))); #[cfg(feature = "test-connector")] - let launcher = test_connector.map_or(launcher.clone(), |connector| { - launcher.with_test_connector(connector) - }); + let launcher = defaults + .test_connector_map + .as_ref() + .map_or(launcher.clone(), |mapping| { + launcher.with_test_connector(mapping.connector()) + }); Arc::new(Browser::new(Arc::new(launcher))) } else { Arc::new(Browser::new(Arc::new(AgentBrowser))) From 2546d05b3cef0821a68def6346fb4828c1b4b3a6 Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Fri, 23 Oct 2026 08:23:28 +0000 Subject: [PATCH 65/70] feat(browser): add module-config test connector mapping Host integration tests can now supply a single approved-to-fixture socket mapping through the TinyComputer module config instead of installing a process-wide connector, so the live egress tests exercise the same grant-consumption path as production. The egress README documents the test-only field and the stricter module-config mapping, and config tests cover its parsing. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- .../tinycomputer-browser/src/egress/README.md | 9 ++++ .../browser_egress_live_tests/mod.rs | 19 +++++--- .../public_connector_tests.rs | 39 ++++------------ .../tinycomputer/src/tinybus_module/config.rs | 12 +++-- .../tinybus_module_tests/config_tests.rs | 44 +++++++++++++++++++ 5 files changed, 82 insertions(+), 41 deletions(-) diff --git a/crates/tinycomputer-browser/src/egress/README.md b/crates/tinycomputer-browser/src/egress/README.md index ecdb599b0..7b60a2fbb 100644 --- a/crates/tinycomputer-browser/src/egress/README.md +++ b/crates/tinycomputer-browser/src/egress/README.md @@ -6,6 +6,15 @@ the engine adapter (`EgressAuthorizer`) small: the host authorizes the parsed destination, returns a one-use grant and exact socket addresses, consumes a grant before each dial, and revalidates active leases. +Host integration tests can enable the `test-connector` feature and provide +`EgressProxy::bind_with_test_connector` (or the corresponding +`EnforcedAgentBrowser` builder) to replace only the final TCP operation. The +connector receives the exact approved socket after grant consumption. The +TinyComputer module exposes a stricter module-config mapping for dynamic test +artifacts; it accepts one `8.8.8.8:port` to loopback `127.0.0.1:port` mapping +and denies all other sockets. Production builds do not parse that test-only +field. + ## Structure - `mod.rs` defines the public `BrowserDialTarget`, `DialGrant`, diff --git a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/mod.rs b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/mod.rs index 8f76258aa..c43100aaa 100644 --- a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/mod.rs +++ b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/mod.rs @@ -169,6 +169,7 @@ async fn start_browser_with_fixture_host( "fixture-policy", 41, None, + None, ) .await } @@ -187,6 +188,7 @@ async fn start_browser_with_fixture_hosts( "fixture-policy", 41, None, + None, ) .await } @@ -199,6 +201,7 @@ async fn start_browser_with_fixture_hosts_for_policy( policy_id: &str, generation: u64, shared_observations: Option>>>, + test_connector_map: Option<(String, String)>, ) -> tinybus::Result { let bus = MemoryBus::new(); let broker = Broker::new(); @@ -223,13 +226,17 @@ async fn start_browser_with_fixture_hosts_for_policy( let module_host = ModuleHost::new(broker); let module = crate::linked_module().expect("linked module manifest is valid"); + let mut module_config = serde_json::json!({ + "browser": {"egress": {"policy_id": policy_id, "generation": generation}} + }); + if let Some((approved, fixture)) = test_connector_map { + module_config["browser"]["egress"]["test_connector_map"] = serde_json::json!({ + "approved": approved, + "fixture": fixture, + }); + } module_host - .attach_linked_with_config( - module, - serde_json::json!({ - "browser": {"egress": {"policy_id": policy_id, "generation": generation}} - }), - ) + .attach_linked_with_config(module, module_config) .expect("TinyComputer module loads through ModuleHost"); let client = Connection::connect(bus.connect().await?).await?; let proxy = client.proxy(names::INTERFACE, names::OBJECT_PATH, names::INTERFACE)?; diff --git a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/public_connector_tests.rs b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/public_connector_tests.rs index 17bf63971..979aee4e1 100644 --- a/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/public_connector_tests.rs +++ b/crates/tinycomputer/src/tinybus_module/browser_egress_live_tests/public_connector_tests.rs @@ -2,36 +2,16 @@ #![allow(clippy::expect_used, clippy::panic, clippy::unwrap_used)] use super::*; -use std::{future::Future, io, net::SocketAddr, pin::Pin}; -use tinycomputer_browser::TestConnector; -use tokio::net::TcpStream; +use std::net::SocketAddr; #[tokio::test] async fn loaded_module_consumes_public_socket_before_fixture_mapping() -> tinybus::Result<()> { let local_listener = tokio::net::TcpListener::bind("127.0.0.1:0").await?; let page_port = local_listener.local_addr()?.port(); let public_socket = SocketAddr::from(([8, 8, 8, 8], page_port)); - let calls = Arc::new(Mutex::new(Vec::::new())); - let connector_calls = calls.clone(); let fixture_address = local_listener.local_addr()?; - let connector: TestConnector = Arc::new(move |address| { - let calls = connector_calls.clone(); - Box::pin(async move { - assert_eq!(address, public_socket); - calls.lock().unwrap().push(format!("connect:{address}")); - // Test-only mapping: the proxy authorized 8.8.8.8, but this closure - // makes no public connection and reaches only the local fixture. - TcpStream::connect(fixture_address).await - }) as Pin> + Send>> - }); let policy_id = "fixture-public-control"; let generation = 973; - let _connector_guard = crate::test_support::install_browser_egress_connector( - policy_id.into(), - generation, - connector, - ) - .expect("fixture connector installs once"); let body = b"public fixture"; let extra_connections = Arc::new(AtomicUsize::new(0)); @@ -50,7 +30,8 @@ async fn loaded_module_consumes_public_socket_before_fixture_mapping() -> tinybu served_rx, policy_id, generation, - Some(calls.clone()), + None, + Some((public_socket.to_string(), fixture_address.to_string())), ) .await?; @@ -58,24 +39,20 @@ async fn loaded_module_consumes_public_socket_before_fixture_mapping() -> tinybu let expected_authorize = format!("authorize:{policy_id}:{generation}:fixture.test:{page_port}"); let expected_consume = format!("consume:{public_socket}"); let observed = browser.observations.lock().unwrap().clone(); - assert!(observed.iter().any(|call| call == &expected_authorize)); - assert!(observed.iter().any(|call| call == &expected_consume)); - let observed_calls = calls.lock().unwrap().clone(); assert_eq!( - &observed_calls[..4], + &observed[..3], [ expected_authorize, expected_consume, - format!("connect:{public_socket}"), - "validate:fixture-lease".into(), + "validate:fixture-lease".into() ], - "the exact TinyBus-consumed socket is passed to the fixture connector before lease validation" + "TinyComputer's BusAuthorizer consumes exactly the granted public socket before forwarding" ); assert!( - observed_calls[4..] + observed[3..] .iter() .all(|call| call.starts_with("authorize:") && call.contains(":www.google.com:443")), - "background public requests must stop at authorization without consume or connector: {observed_calls:?}" + "background public requests must stop at authorization without a grant or connector: {observed:?}" ); let closed: DesktopResponse = browser diff --git a/crates/tinycomputer/src/tinybus_module/config.rs b/crates/tinycomputer/src/tinybus_module/config.rs index 48198ca55..1d6b9c29f 100644 --- a/crates/tinycomputer/src/tinybus_module/config.rs +++ b/crates/tinycomputer/src/tinybus_module/config.rs @@ -6,9 +6,9 @@ //! a desktop `user_agent` and launch `args` once here rather than on every //! request. -use tinycomputer_browser::{CursorPace, Perception, ScreenCursor, SessionOptions, Settle}; #[cfg(feature = "test-connector")] use std::{future::Future, io, net::SocketAddr, pin::Pin, sync::Arc}; +use tinycomputer_browser::{CursorPace, Perception, ScreenCursor, SessionOptions, Settle}; use crate::Result; @@ -67,7 +67,8 @@ impl TestConnectorMap { )); } tokio::net::TcpStream::connect(fixture).await - }) as Pin> + Send>> + }) + as Pin> + Send>> }) } } @@ -164,7 +165,8 @@ impl BrowserDefaults { .ok_or_else(invalid)?; #[cfg(feature = "test-connector")] { - defaults.test_connector_map = test_connector_map(egress.get("test_connector_map"), &invalid)?; + defaults.test_connector_map = + test_connector_map(egress.get("test_connector_map"), &invalid)?; } let expected_egress_keys = 2 + usize::from( cfg!(feature = "test-connector") && egress.contains_key("test_connector_map"), @@ -242,7 +244,9 @@ fn test_connector_map( if approved.ip().to_string() != "8.8.8.8" || !fixture.ip().is_loopback() || approved.port() != fixture.port() - || object.keys().any(|key| !["approved", "fixture"].contains(&key.as_str())) + || object + .keys() + .any(|key| !["approved", "fixture"].contains(&key.as_str())) { return Err(invalid()); } diff --git a/crates/tinycomputer/src/tinybus_module/tinybus_module_tests/config_tests.rs b/crates/tinycomputer/src/tinybus_module/tinybus_module_tests/config_tests.rs index 22d6b0f78..ce57f7910 100644 --- a/crates/tinycomputer/src/tinybus_module/tinybus_module_tests/config_tests.rs +++ b/crates/tinycomputer/src/tinybus_module/tinybus_module_tests/config_tests.rs @@ -211,6 +211,50 @@ fn the_browser_configuration_is_read_or_refused() { } } +#[test] +fn browser_test_connector_map_is_available_only_in_test_connector_builds() { + use crate::tinybus_module::config::BrowserDefaults; + + let config = json!({"browser": {"egress": { + "policy_id": "host-policy", + "generation": 7, + "test_connector_map": { + "approved": "8.8.8.8:443", + "fixture": "127.0.0.1:443" + } + }}}); + #[cfg(feature = "test-connector")] + { + let defaults = BrowserDefaults::from_config(&config).unwrap(); + let mapping = defaults.test_connector_map.unwrap(); + assert_eq!(mapping.approved.to_string(), "8.8.8.8:443"); + assert_eq!(mapping.fixture.to_string(), "127.0.0.1:443"); + + for invalid in [ + json!({"browser": {"egress": { + "policy_id": "p", "generation": 1, + "test_connector_map": {"approved": "8.8.4.4:443", "fixture": "127.0.0.1:443"} + }}}), + json!({"browser": {"egress": { + "policy_id": "p", "generation": 1, + "test_connector_map": {"approved": "8.8.8.8:443", "fixture": "192.168.1.1:443"} + }}}), + json!({"browser": {"egress": { + "policy_id": "p", "generation": 1, + "test_connector_map": {"approved": "8.8.8.8:443", "fixture": "127.0.0.1:80"} + }}}), + json!({"browser": {"egress": { + "policy_id": "p", "generation": 1, + "test_connector_map": {"approved": "8.8.8.8:443", "fixture": "127.0.0.1:443", "extra": true} + }}}), + ] { + assert!(BrowserDefaults::from_config(&invalid).is_err(), "{invalid}"); + } + } + #[cfg(not(feature = "test-connector"))] + assert!(BrowserDefaults::from_config(&config).is_err()); +} + #[test] fn browser_defaults_fill_only_what_the_caller_left_unset() { use crate::tinybus_module::config::BrowserDefaults; From cda3b6f9e66d4d29af3f0c98e3182f253b54bdef Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Fri, 23 Oct 2026 08:23:46 +0000 Subject: [PATCH 66/70] refactor(tinybus_module): widen test connector map visibility The TestConnectorMap fields and its connector method are now pub(crate) so other modules in the crate can build and inspect the map under the test-connector feature. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- crates/tinycomputer/src/tinybus_module/config.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/tinycomputer/src/tinybus_module/config.rs b/crates/tinycomputer/src/tinybus_module/config.rs index 1d6b9c29f..588c72d49 100644 --- a/crates/tinycomputer/src/tinybus_module/config.rs +++ b/crates/tinycomputer/src/tinybus_module/config.rs @@ -49,13 +49,13 @@ pub(crate) struct BrowserEgressConfig { #[cfg(feature = "test-connector")] #[derive(Debug, Clone, PartialEq, Eq)] pub(crate) struct TestConnectorMap { - approved: SocketAddr, - fixture: SocketAddr, + pub(crate) approved: SocketAddr, + pub(crate) fixture: SocketAddr, } #[cfg(feature = "test-connector")] impl TestConnectorMap { - fn connector(&self) -> tinycomputer_browser::TestConnector { + pub(crate) fn connector(&self) -> tinycomputer_browser::TestConnector { let approved = self.approved; let fixture = self.fixture; Arc::new(move |address| { From 1c32bcd6ec19b2c50047b6d8743fab0435ef4264 Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Fri, 23 Oct 2026 08:24:37 +0000 Subject: [PATCH 67/70] refactor(linked): extract egress proxy binding into a helper Move the egress proxy construction out of the navigate handler into a bind_egress_proxy method on Linked, so the test-connector and default paths share one place. The existing tests now set the test_connector field to None under the test-connector feature to match the struct. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- .../src/linked/linked_tests.rs | 8 +++ crates/tinycomputer-browser/src/linked/mod.rs | 54 +++++++++---------- 2 files changed, 33 insertions(+), 29 deletions(-) diff --git a/crates/tinycomputer-browser/src/linked/linked_tests.rs b/crates/tinycomputer-browser/src/linked/linked_tests.rs index f5197bde4..f111f6a3f 100644 --- a/crates/tinycomputer-browser/src/linked/linked_tests.rs +++ b/crates/tinycomputer-browser/src/linked/linked_tests.rs @@ -93,6 +93,8 @@ async fn a_closed_or_lost_browser_cannot_implicitly_launch_without_the_proxy() { proxy: None, proxy_session_id: "private-session-id".into(), enforced_launch: true, + #[cfg(feature = "test-connector")] + test_connector: None, }; let reply = engine .execute(json!({"id":"navigate","action":"navigate","url":"http://public.example/"})) @@ -114,6 +116,8 @@ async fn an_exited_enforced_browser_can_still_be_closed() { proxy: None, proxy_session_id: "private-session-id".into(), enforced_launch: true, + #[cfg(feature = "test-connector")] + test_connector: None, }; let reply = engine.execute(json!({"id":"close","action":"close"})).await; @@ -131,6 +135,8 @@ async fn enforced_browser_refuses_process_side_reads_with_a_url() { proxy: None, proxy_session_id: "private-session-id".into(), enforced_launch: true, + #[cfg(feature = "test-connector")] + test_connector: None, }; let reply = engine .execute(json!({ @@ -156,6 +162,8 @@ async fn enforced_browser_rechecks_liveness_after_waiting_for_engine_lock() { proxy: None, proxy_session_id: "private-session-id".into(), enforced_launch: true, + #[cfg(feature = "test-connector")] + test_connector: None, }; let serialized = ENGINE.lock().await; let pending = tokio::spawn(async move { diff --git a/crates/tinycomputer-browser/src/linked/mod.rs b/crates/tinycomputer-browser/src/linked/mod.rs index ee1d0920d..9502fa2c5 100644 --- a/crates/tinycomputer-browser/src/linked/mod.rs +++ b/crates/tinycomputer-browser/src/linked/mod.rs @@ -102,6 +102,30 @@ struct Linked { test_connector: Option, } +impl Linked { + async fn bind_egress_proxy( + &self, + authorizer: Arc, + ) -> std::io::Result { + #[cfg(feature = "test-connector")] + if let Some(connector) = self.test_connector.clone() { + return EgressProxy::bind_with_test_connector( + authorizer, + self.proxy_session_id.clone(), + self.proxy_session_id.clone(), + move |address| connector(address), + ) + .await; + } + EgressProxy::bind( + authorizer, + self.proxy_session_id.clone(), + self.proxy_session_id.clone(), + ) + .await + } +} + impl Engine for Linked { fn execute(&mut self, command: Value) -> Reply<'_> { let action = command @@ -121,35 +145,7 @@ impl Engine for Linked { return failure_reply(&command, "network policy has no host authorizer"); }; if self.proxy.is_none() { - let proxy = { - #[cfg(feature = "test-connector")] - if let Some(connector) = self.test_connector.clone() { - EgressProxy::bind_with_test_connector( - authorizer, - self.proxy_session_id.clone(), - self.proxy_session_id.clone(), - move |address| connector(address), - ) - .await - } else { - EgressProxy::bind( - authorizer, - self.proxy_session_id.clone(), - self.proxy_session_id.clone(), - ) - .await - } - #[cfg(not(feature = "test-connector"))] - { - EgressProxy::bind( - authorizer, - self.proxy_session_id.clone(), - self.proxy_session_id.clone(), - ) - .await - } - }; - match proxy { + match self.bind_egress_proxy(authorizer).await { Ok(proxy) => self.proxy = Some(proxy), Err(_) => { return failure_reply(&command, "network policy proxy could not start"); From ae2dc3adf68031f17c24fa5333f2c1b516d6a84b Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Fri, 23 Oct 2026 08:26:54 +0000 Subject: [PATCH 68/70] docs(egress): document opt-in loaded-module Chromium test Explain that the loaded-module Chromium test is opt-in and excluded from hosted CI, and add the local command for running it with Chromium installed. Also note the test's use of a local HTTP listener and the fixture callback host, with real policy composition covered by the OpenHuman fixture. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- crates/tinycomputer-browser/src/egress/README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/crates/tinycomputer-browser/src/egress/README.md b/crates/tinycomputer-browser/src/egress/README.md index 7b60a2fbb..6d958ea1c 100644 --- a/crates/tinycomputer-browser/src/egress/README.md +++ b/crates/tinycomputer-browser/src/egress/README.md @@ -15,6 +15,21 @@ artifacts; it accepts one `8.8.8.8:port` to loopback `127.0.0.1:port` mapping and denies all other sockets. Production builds do not parse that test-only field. +The loaded-module Chromium test is opt-in and is not part of hosted CI, whose +module-e2e lane packages and verifies the artifact without launching Chromium. +With Chromium installed, run the focused test locally with: + +```sh +TINYCOMPUTER_LIVE_BROWSER_EGRESS_TESTS=1 cargo test -p tinycomputer \ + --features static-link,test-connector \ + browser_egress_live_tests::public_connector_tests::loaded_module_consumes_public_socket_before_fixture_mapping \ + -- --nocapture +``` + +It uses a local HTTP listener and the TinyComputer fixture callback host; the +host's real TinySecurity policy composition is covered by the separate +OpenHuman fixture. + ## Structure - `mod.rs` defines the public `BrowserDialTarget`, `DialGrant`, From 31e312039e956fa9e15cd7ad267b248057e683fa Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Fri, 23 Oct 2026 08:27:15 +0000 Subject: [PATCH 69/70] docs(egress): document test-connector host fixture mapping The egress README now spells out how a test-connector build supplies the test-only module-config mapping, naming the browser.egress.test_connector_map key and its approved/fixture JSON shape so the fixture is discoverable without reading the parser. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- crates/tinycomputer-browser/src/egress/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/tinycomputer-browser/src/egress/README.md b/crates/tinycomputer-browser/src/egress/README.md index 6d958ea1c..2b4d7e4b3 100644 --- a/crates/tinycomputer-browser/src/egress/README.md +++ b/crates/tinycomputer-browser/src/egress/README.md @@ -13,7 +13,9 @@ connector receives the exact approved socket after grant consumption. The TinyComputer module exposes a stricter module-config mapping for dynamic test artifacts; it accepts one `8.8.8.8:port` to loopback `127.0.0.1:port` mapping and denies all other sockets. Production builds do not parse that test-only -field. +field. In a `test-connector` build, a host fixture supplies it at +`browser.egress.test_connector_map` as +`{"approved":"8.8.8.8:","fixture":"127.0.0.1:"}`. The loaded-module Chromium test is opt-in and is not part of hosted CI, whose module-e2e lane packages and verifies the artifact without launching Chromium. From 81c158fd167b0ab6c57713922c2c135960cdc956 Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Fri, 23 Oct 2026 08:39:33 +0000 Subject: [PATCH 70/70] test(linked): cover loopback proxy binding before launch Add a test asserting that the enforced launcher binds its egress proxy on 127.0.0.1 before any browser is opened, so the local-only binding guarantee is exercised directly. Auto-committed-on: cuttlefish Co-authored-by: Medulla --- .../src/linked/linked_tests.rs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/crates/tinycomputer-browser/src/linked/linked_tests.rs b/crates/tinycomputer-browser/src/linked/linked_tests.rs index f111f6a3f..833f2b27f 100644 --- a/crates/tinycomputer-browser/src/linked/linked_tests.rs +++ b/crates/tinycomputer-browser/src/linked/linked_tests.rs @@ -75,6 +75,26 @@ async fn enforced_launcher_creates_a_private_session_without_implicit_launch() { ); } +#[tokio::test] +async fn enforced_launcher_binds_its_proxy_on_loopback_before_launch() { + let linked = Linked { + state: DaemonState::with_options(state_options("proxy-bind")), + egress_authorizer: Some(Arc::new(RejectAll)), + proxy: None, + proxy_session_id: "private-session-id".into(), + enforced_launch: false, + #[cfg(feature = "test-connector")] + test_connector: None, + }; + + let proxy = linked + .bind_egress_proxy(Arc::new(RejectAll)) + .await + .expect("the local egress proxy binds without opening a browser"); + + assert!(proxy.url().starts_with("http://127.0.0.1:")); +} + #[tokio::test] async fn enforced_browser_refuses_implicit_launch_before_any_request() { let mut engine = EnforcedAgentBrowser::new(Arc::new(RejectAll)).open("unit");