feat(call): add ScopedPeerEnv peer-pinned reachability (ADR-029 §4, call/scoped-peer-env)
This commit is contained in:
1 parent
5c4feff468
commit
bfd1621b9b
10 files changed
+397
-99
No files matched your search
@@ -164,7 +164,7 @@ mod tests {
|
||||
use crate::protocol::wire::{
|
||||
CallError, EventEnvelope, EVENT_COMPLETED, EVENT_ERROR, EVENT_RESPONDED,
|
||||
};
|
||||
use crate::registry::context::{AbortPolicy, OperationContext, ScopedOperationEnv};
|
||||
use crate::registry::context::{AbortPolicy, OperationContext, ScopedPeerEnv};
|
||||
use crate::registry::env::OperationEnv;
|
||||
use crate::registry::registration::{make_handler, HandlerRegistration, OperationProvenance};
|
||||
use crate::registry::spec::{AccessControl, OperationSpec, OperationType, Visibility};
|
||||
@@ -419,7 +419,7 @@ mod tests {
|
||||
#[tokio::test]
|
||||
async fn build_root_context_carries_capabilities_and_scoped_env() {
|
||||
let mut registry = OperationRegistry::new();
|
||||
let scoped = ScopedOperationEnv::new(["fs/readFile"]);
|
||||
let scoped = ScopedPeerEnv::new(["fs/readFile"]);
|
||||
let caps = Capabilities::new().with_api_key("google", "k".to_string());
|
||||
registry.register(HandlerRegistration::new(
|
||||
external_spec("agent/run", AccessControl::default()),
|
||||
@@ -562,7 +562,7 @@ mod tests {
|
||||
let context =
|
||||
adapter.build_root_context("req-5".to_string(), "fs/readFile", None, None, &conn);
|
||||
|
||||
let scoped = ScopedOperationEnv::new(["worker/exec"]);
|
||||
let scoped = ScopedPeerEnv::new(["worker/exec"]);
|
||||
let invoke_ctx = OperationContext {
|
||||
request_id: "req-5".to_string(),
|
||||
parent_request_id: None,
|
||||
@@ -620,7 +620,7 @@ mod tests {
|
||||
let context =
|
||||
adapter.build_root_context("req-6".to_string(), "fs/readFile", None, None, &conn);
|
||||
|
||||
let scoped = ScopedOperationEnv::new(["worker/exec"]);
|
||||
let scoped = ScopedPeerEnv::new(["worker/exec"]);
|
||||
let invoke_ctx = OperationContext {
|
||||
request_id: "req-6".to_string(),
|
||||
parent_request_id: None,
|
||||
|
||||
@@ -23,9 +23,7 @@ use super::wire::{
|
||||
EVENT_ERROR, EVENT_RESPONDED,
|
||||
};
|
||||
use crate::protocol::wire::ResponseEnvelope;
|
||||
use crate::registry::context::{
|
||||
generate_request_id, AbortPolicy, OperationContext, ScopedOperationEnv,
|
||||
};
|
||||
use crate::registry::context::{generate_request_id, AbortPolicy, OperationContext, ScopedPeerEnv};
|
||||
use crate::registry::env::OperationEnv;
|
||||
use crate::registry::registration::{Handler, HandlerRegistration};
|
||||
|
||||
@@ -280,7 +278,7 @@ impl OperationEnv for OverlayOperationEnv {
|
||||
scoped_env = registration
|
||||
.scoped_env
|
||||
.clone()
|
||||
.unwrap_or_else(ScopedOperationEnv::empty);
|
||||
.unwrap_or_else(ScopedPeerEnv::empty);
|
||||
}
|
||||
|
||||
let context = OperationContext {
|
||||
@@ -432,7 +430,7 @@ mod tests {
|
||||
|
||||
fn root_context(
|
||||
request_id: &str,
|
||||
scoped_env: ScopedOperationEnv,
|
||||
scoped_env: ScopedPeerEnv,
|
||||
env: Arc<dyn OperationEnv + Send + Sync>,
|
||||
) -> OperationContext {
|
||||
OperationContext {
|
||||
@@ -487,7 +485,7 @@ mod tests {
|
||||
conn.register_imported(imported_registration("worker/exec"));
|
||||
let env = conn.overlay_env();
|
||||
|
||||
let scoped = ScopedOperationEnv::new(["worker/exec"]);
|
||||
let scoped = ScopedPeerEnv::new(["worker/exec"]);
|
||||
let ctx = root_context("root-1", scoped, env.clone());
|
||||
|
||||
let response = env
|
||||
@@ -506,7 +504,7 @@ mod tests {
|
||||
|
||||
assert!(!env.contains("worker/missing"));
|
||||
|
||||
let scoped = ScopedOperationEnv::new(["worker/missing"]);
|
||||
let scoped = ScopedPeerEnv::new(["worker/missing"]);
|
||||
let ctx = root_context("root-2", scoped, env.clone());
|
||||
|
||||
let response = env
|
||||
@@ -525,7 +523,7 @@ mod tests {
|
||||
conn.register_imported(imported_registration("worker/exec"));
|
||||
let env = conn.overlay_env();
|
||||
|
||||
let scoped = ScopedOperationEnv::empty();
|
||||
let scoped = ScopedPeerEnv::empty();
|
||||
let ctx = root_context("root-3", scoped, env.clone());
|
||||
|
||||
let response = env
|
||||
@@ -562,7 +560,7 @@ mod tests {
|
||||
));
|
||||
let env = conn.overlay_env();
|
||||
|
||||
let scoped = ScopedOperationEnv::new(["worker/exec"]);
|
||||
let scoped = ScopedPeerEnv::new(["worker/exec"]);
|
||||
let ctx = root_context("root-4", scoped, env.clone());
|
||||
|
||||
let response = env
|
||||
|
||||
@@ -28,7 +28,7 @@ use super::wire::{
|
||||
EVENT_ABORTED, EVENT_REQUESTED,
|
||||
};
|
||||
use crate::protocol::adapter::SessionOverlaySource;
|
||||
use crate::registry::context::{AbortPolicy, OperationContext, ScopedOperationEnv};
|
||||
use crate::registry::context::{AbortPolicy, OperationContext, ScopedPeerEnv};
|
||||
use crate::registry::env::{LocalOperationEnv, OperationEnv, PeerCompositeEnv};
|
||||
use crate::registry::registration::OperationRegistry;
|
||||
|
||||
@@ -135,14 +135,12 @@ impl Dispatcher {
|
||||
Some(r) => (
|
||||
r.composition_authority.clone(),
|
||||
r.capabilities.clone(),
|
||||
r.scoped_env
|
||||
.clone()
|
||||
.unwrap_or_else(ScopedOperationEnv::empty),
|
||||
r.scoped_env.clone().unwrap_or_else(ScopedPeerEnv::empty),
|
||||
),
|
||||
None => (
|
||||
None,
|
||||
alknet_core::types::Capabilities::new(),
|
||||
ScopedOperationEnv::empty(),
|
||||
ScopedPeerEnv::empty(),
|
||||
),
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user