Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aien-sovereign-core-mv/patches/daa6f998c8c8bfbd # aien-sovereign-core-mv AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers ## GitHub aien-dev/aien-sovereign-core-mv#207 (code only) closed derived `daa6f998c8c8bfbd` #207 Imported from GitHub aien-dev/aien-sovereign-core-mv#207 (code only) GitHub's metadata for this pull request is unavailable: its state is DERIVED from the commits (merged: the head is reachable from this project's main; open: GitHub kept a merge ref; else closed). Base `6c285246b7acab4fc98a829ddfefc8e178bc91b0` · Head `2bfb12237fe7561c1e9d72a68330aa69368eba5d` greptile-apps[bot] reviewed (COMMENTED) on 2026-10-05 01:45 UTC `aien-dev` has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan . ### Apply it ``` git checkout -b patch-daa6f998c8c8bfbd 6c285246b7acab4fc98a829ddfefc8e178bc91b0 curl -fsSL https://interplane.io/drakestapleton/aien-sovereign-core-mv/patches/daa6f998c8c8bfbd.patch | git am ``` Raw patch (mbox) · Diff ### Provenance This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record: ``` github-import 1 aien-dev/aien-sovereign-core-mv 207 2bfb12237fe7561c1e9d72a68330aa69368eba5d ``` ``` {"kind":"github-import","owner":"aien-dev","repo":"aien-sovereign-core-mv","number":207,"url":"https://github.com/aien-dev/aien-sovereign-core-mv/pull/207","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:36:17Z","metadata":"unavailable","state_derived":true} ``` ### Changes ``` diff --git a/crates/aien-mcp/src/authority.rs b/crates/aien-mcp/src/authority.rs index 004779b7..cc8319d8 100644 --- a/crates/aien-mcp/src/authority.rs +++ b/crates/aien-mcp/src/authority.rs @@ -40,12 +40,52 @@ pub struct EffectScope { pub idempotency_key: EffectId, } +/// How far the runtime trusts a piece of context. Mirrors INTERPLANE Crossveil `TrustLevel`. +/// The derived order is least to most trusted: +/// `ExternalUntrusted < WorkspaceUntrusted < UserSupplied < TrustedRuntime`. +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub enum TrustLevel { + ExternalUntrusted, + WorkspaceUntrusted, + UserSupplied, + TrustedRuntime, +} + +impl TrustLevel { + /// Parse the wire name. `unknown` and any unrecognized value count as `ExternalUntrusted`: + /// inability to determine trust is never converted into trust. + pub fn from_wire(s: &str) -> Self { + match s { + "trusted_runtime" => Self::TrustedRuntime, + "user_supplied" => Self::UserSupplied, + "workspace_untrusted" => Self::WorkspaceUntrusted, + _ => Self::ExternalUntrusted, + } + } +} + +/// What the model could see when it produced the turn: `{inputs: [input_id...], floor}`, where +/// `floor` is the least trusted level among `inputs`. Host/runtime input only: the lane takes it +/// from [`crate::EffectLane::with_exposure`], never from an intent, so nothing the model writes can set it. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct Exposure { + pub inputs: Vec, + pub floor: TrustLevel, +} + +impl Exposure { + pub fn new(inputs: Vec, floor: TrustLevel) -> Self { + Self { inputs, floor } + } +} + /// What an authority sees. Built by the lane from the live session, never by the caller. #[derive(Clone, Debug)] pub struct AuthorityContext { scope: EffectScope, descriptor: Option, live_catalog_digest: Digest32, + exposure: Option, } impl AuthorityContext { @@ -53,11 +93,13 @@ impl AuthorityContext { scope: EffectScope, descriptor: Option, live_catalog_digest: Digest32, + exposure: Option, ) -> Self { Self { scope, descriptor, live_catalog_digest, + exposure, } } @@ -73,6 +115,12 @@ impl AuthorityContext { pub fn live_catalog_digest(&self) -> Digest32 { self.live_catalog_digest } + + /// Exposure the host attached to the lane, or `None` if it attached none. + /// `None` means unknown and is never read as trusted. + pub fn exposure(&self) -> Option<&Exposure> { + self.exposure.as_ref() + } } /// Decides whether an intent may become an `AuthorizedEffect`. @@ -117,6 +165,7 @@ pub fn intent_digest(intent: &EffectIntent) -> Digest32 { /// | `EXTERNAL_IRREVERSIBLE` | `Deny` (irreversible effects stay intents, ADR 0005/0007) | /// | `EXTERNAL_WRITE`, `WORLD_MUTATION`, `SECRET_BEARING`, `SPAWN_PROCESS` | `RequireApproval` | /// | `PURE`, `READ_FILESYSTEM`, `READ_NETWORK`, `LOCAL_EPHEMERAL` | `Allow` | +/// | effect-class bits (the four `RequireApproval` rows) while exposure floor < `UserSupplied`, or exposure absent | `RequireApproval` (never `Allow`; reason names exposure) | /// | unknown tool, unknown effect bits | `Deny` | #[derive(Clone, Copy, Debug, Default)] pub struct EffectClassAuthority; @@ -140,6 +189,29 @@ impl EffectAuthority for EffectClassAuthority { "irreversible external effects are intents only".into(), ); } + let effectful = e.intersects( + ToolEffects::EXTERNAL_WRITE + | ToolEffects::WORLD_MUTATION + | ToolEffects::SECRET_BEARING + | ToolEffects::SPAWN_PROCESS, + ); + if effectful { + // Absent exposure is treated as external_untrusted: fail closed. + let floor = ctx + .exposure() + .map_or(TrustLevel::ExternalUntrusted, |x| x.floor); + if floor < TrustLevel::UserSupplied { + return AuthorityDecision::RequireApproval(format!( + "tool `{}` is an effect under untrusted exposure ({})", + intent.tool_name, + if ctx.exposure().is_some() { + "floor below user_supplied" + } else { + "exposure absent" + } + )); + } + } if e.intersects( ToolEffects::EXTERNAL_WRITE | ToolEffects::WORLD_MUTATION diff --git a/crates/aien-mcp/src/broker.rs b/crates/aien-mcp/src/broker.rs index e55baa89..558a6370 100644 --- a/crates/aien-mcp/src/broker.rs +++ b/crates/aien-mcp/src/broker.rs @@ -10,7 +10,7 @@ use serde_json::Value; use crate::approval::{ApprovalError, ApprovalGrant, ApprovalRecord}; use crate::authority::{ intent_digest, AuthorityContext, AuthorityDecision, AuthorityOutcome, EffectAuthority, - EffectScope, + EffectScope, Exposure, }; use crate::effect::mint; use crate::{ @@ -227,11 +227,25 @@ pub struct SpeculativeToolCall { #[derive(Clone)] pub struct EffectLane { broker: McpBroker, + exposure: Option, } impl EffectLane { pub fn new(broker: McpBroker) -> Self { - Self { broker } + Self { + broker, + exposure: None, + } + } + + /// A lane that tells authorities what the model was exposed to. Host/runtime call only: + /// an intent cannot carry exposure. A lane built with [`Self::new`] has no exposure, which + /// [`crate::EffectClassAuthority`] treats as `external_untrusted` for effect classes (fail closed). + pub fn with_exposure(&self, exposure: Exposure) -> Self { + Self { + broker: self.broker.clone(), + exposure: Some(exposure), + } } /// Ask `authority` whether `intent` may run, and mint an `AuthorizedEffect` only on @@ -290,7 +304,7 @@ impl EffectLane { "intent was staged against a stale catalog".into(), )); } - let ctx = AuthorityContext::new(scope, descriptor, live); + let ctx = AuthorityContext::new(scope, descriptor, live, self.exposure.clone()); let decision = authority.authorize(&intent, &ctx); let policy_digest = { let mut bytes = format!("{decision:?}|{}|", intent.tool_name).into_bytes(); diff --git a/crates/aien-mcp/src/lib.rs b/crates/aien-mcp/src/lib.rs index dd2d890a..fbfbfba9 100644 --- a/crates/aien-mcp/src/lib.rs +++ b/crates/aien-mcp/src/lib.rs @@ -27,7 +27,7 @@ pub(crate) use effect::authorize_for_test; pub use approval::{ApprovalDesk, ApprovalError, ApprovalGrant}; pub use authority::{ intent_digest, AuthorityContext, AuthorityDecision, AuthorityOutcome, EffectAuthority, - EffectClassAuthority, EffectScope, + EffectClassAuthority, EffectScope, Exposure, TrustLevel, }; pub use broker::{EffectLane, McpBroker, SpeculativeLane, SpeculativeToolCall}; pub use effect::{AuthorizedEffect, EffectIntent, EffectReceipt, ToolResult}; diff --git a/crates/aien-mcp/tests/approval.rs b/crates/aien-mcp/tests/approval.rs index c7bad812..6ec88a59 100644 --- a/crates/aien-mcp/tests/approval.rs +++ b/crates/aien-mcp/tests/approval.rs @@ -9,7 +9,7 @@ use aien_mcp::memory::MemoryWire; use aien_mcp::{ ApprovalDesk, ApprovalError, AuthorityContext, AuthorityDecision, AuthorityOutcome, CallOutcome, EffectAuthority, EffectClassAuthority, EffectIntent, EffectLane, EffectScope, - McpBroker, SpeculativeLane, + Exposure, McpBroker, SpeculativeLane, TrustLevel, }; use serde_json::json; @@ -279,3 +279,25 @@ async fn unapproved_request_is_still_pending() { .unwrap_err(); assert!(matches!(e, AuthorityOutcome::Pending { .. })); } + +#[tokio::test] +async fn approved_grant_authorizes_effect_pending_on_untrusted_exposure() { + // E3: an effect held back by untrusted exposure is still released by an approval grant. + let h = harness().await; + let lane = h.lane.with_exposure(Exposure::new( + vec!["web-1".into()], + TrustLevel::ExternalUntrusted, + )); + let a = EffectClassAuthority; + assert!(matches!( + lane.authorize(h.intent.clone(), scope("ex"), &a), + Err(AuthorityOutcome::Pending { .. }) + )); + let g = h.desk.issue(&h.intent, scope("ex"), 100); + let r = lane + .authorize_and_execute_approved(h.intent.clone(), scope("ex"), &a, &g, 1) + .await + .unwrap(); + assert_eq!(r.output, json!({"done": true})); + assert_eq!(h.calls.load(Ordering::SeqCst), 1); +} diff --git a/crates/aien-mcp/tests/authority.rs b/crates/aien-mcp/tests/authority.rs index 4e309854..b5955c89 100644 --- a/crates/aien-mcp/tests/authority.rs +++ b/crates/aien-mcp/tests/authority.rs @@ -10,7 +10,7 @@ use aien_capability::{ use aien_mcp::memory::MemoryWire; use aien_mcp::{ AuthorityContext, AuthorityDecision, AuthorityOutcome, CallOutcome, EffectAuthority, - EffectClassAuthority, EffectIntent, EffectLane, EffectScope, McpBroker, + EffectClassAuthority, EffectIntent, EffectLane, EffectScope, Exposure, McpBroker, TrustLevel, }; use serde_json::json; @@ -183,3 +183,133 @@ async fn effect_class_table() { } let _ = D::Allow; } + +// ---- E3: exposure input (INTERPLANE 0.3 cut E3) ---- + +fn exposure(floor: TrustLevel) -> Exposure { + Exposure::new(vec!["in-1".into()], floor) +} + +const EFFECT_BITS: [ToolEffects; 4] = [ + ToolEffects::EXTERNAL_WRITE, + ToolEffects::WORLD_MUTATION, + ToolEffects::SECRET_BEARING, + ToolEffects::SPAWN_PROCESS, +]; + +#[test] +fn trust_order_and_unknown_wire_value() { + assert!(TrustLevel::TrustedRuntime > TrustLevel::UserSupplied); + assert!(TrustLevel::UserSupplied > TrustLevel::WorkspaceUntrusted); + assert!(TrustLevel::WorkspaceUntrusted > TrustLevel::ExternalUntrusted); + assert_eq!( + TrustLevel::from_wire("user_supplied"), + TrustLevel::UserSupplied + ); + assert_eq!( + TrustLevel::from_wire("unknown"), + TrustLevel::ExternalUntrusted + ); + assert_eq!( + TrustLevel::from_wire("garbage"), + TrustLevel::ExternalUntrusted + ); +} + +#[tokio::test] +async fn untrusted_exposure_makes_effects_pending_never_allow() { + for floor in [ + TrustLevel::WorkspaceUntrusted, + TrustLevel::ExternalUntrusted, + ] { + for fx in EFFECT_BITS { + let h = harness(fx).await; + let r = h + .lane + .with_exposure(exposure(floor)) + .authorize_and_execute(h.intent, scope("x"), &EffectClassAuthority) + .await; + match r { + Err(AuthorityOutcome::Pending { reason, .. }) => { + assert!(reason.contains("exposure"), "{reason}") + } + other => panic!("expected Pending, got {other:?}"), + } + assert_eq!(h.calls.load(Ordering::SeqCst), 0); + } + } +} + +#[tokio::test] +async fn read_class_is_unaffected_by_exposure() { + for fx in [ + ToolEffects::PURE, + ToolEffects::READ_FILESYSTEM, + ToolEffects::READ_NETWORK, + ] { + let h = harness(fx).await; + let r = h + .lane + .with_exposure(exposure(TrustLevel::ExternalUntrusted)) + .authorize_and_execute(h.intent, scope("r"), &EffectClassAuthority) + .await; + assert!(r.is_ok()); + assert_eq!(h.calls.load(Ordering::SeqCst), 1); + } +} + +#[tokio::test] +async fn absent_exposure_fails_closed_for_effects_only() { + let h = harness(ToolEffects::EXTERNAL_WRITE).await; + let r = h + .lane + .authorize(h.intent.clone(), scope("n"), &EffectClassAuthority); + match r { + Err(AuthorityOutcome::Pending { reason, .. }) => assert!(reason.contains("exposure")), + other => panic!("expected Pending, got {other:?}"), + } + let h = harness(ToolEffects::PURE).await; + assert!(h + .lane + .authorize(h.intent.clone(), scope("n2"), &EffectClassAuthority) + .is_ok()); +} + +#[tokio::test] +async fn context_exposes_only_what_the_host_set() { + struct Probe(std::sync::Mutex>>); + impl EffectAuthority for Probe { + fn authorize(&self, _: &EffectIntent, c: &AuthorityContext) -> AuthorityDecision { + *self.0.lock().unwrap() = Some(c.exposure().cloned()); + AuthorityDecision::Allow + } + } + let h = harness(ToolEffects::PURE).await; + let p = Probe(Default::default()); + h.lane.authorize(h.intent.clone(), scope("p1"), &p).unwrap(); + assert_eq!(p.0.lock().unwrap().take(), Some(None)); + let e = exposure(TrustLevel::UserSupplied); + h.lane + .with_exposure(e.clone()) + .authorize(h.intent.clone(), scope("p2"), &p) + .unwrap(); + assert_eq!(p.0.lock().unwrap().take(), Some(Some(e))); +} + +#[tokio::test] +async fn user_supplied_or_better_keeps_the_existing_effect_table() { + for floor in [TrustLevel::UserSupplied, TrustLevel::TrustedRuntime] { + let h = harness(ToolEffects::EXTERNAL_WRITE).await; + let r = h.lane.with_exposure(exposure(floor)).authorize( + h.intent.clone(), + scope("t"), + &EffectClassAuthority, + ); + match r { + Err(AuthorityOutcome::Pending { reason, .. }) => { + assert!(!reason.contains("exposure"), "{reason}") + } + other => panic!("expected Pending, got {other:?}"), + } + } +} ```