MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / discover_and_sync_policy

Function discover_and_sync_policy

crates/openshell-core/src/grpc_client.rs:628–652  ·  view source on GitHub ↗

Discover and sync policy using a single gRPC connection. Performs the full discovery flow (fetch → sync → re-fetch) over one channel instead of establishing three separate connections.

(
    endpoint: &str,
    sandbox_id: &str,
    sandbox: &str,
    discovered_policy: &ProtoSandboxPolicy,
)

Source from the content-addressed store, hash-verified

626/// Performs the full discovery flow (fetch → sync → re-fetch) over one
627/// channel instead of establishing three separate connections.
628pub async fn discover_and_sync_policy(
629 endpoint: &str,
630 sandbox_id: &str,
631 sandbox: &str,
632 discovered_policy: &ProtoSandboxPolicy,
633) -> Result<ProtoSandboxPolicy> {
634 debug!(
635 endpoint = %endpoint,
636 sandbox_id = %sandbox_id,
637 sandbox = %sandbox,
638 "Syncing discovered policy and re-fetching canonical version"
639 );
640
641 let mut client = connect(endpoint).await?;
642
643 // Sync the discovered policy to the gateway.
644 sync_policy_with_client(&mut client, sandbox, discovered_policy).await?;
645
646 // Re-fetch from the gateway to get the canonical version/hash.
647 fetch_policy_with_client(&mut client, sandbox_id)
648 .await?
649 .ok_or_else(|| {
650 miette::miette!("Server still returned no policy after sync — this is a bug")
651 })
652}
653
654/// Sync an enriched policy back to the gateway.
655///

Callers 1

load_policyFunction · 0.85

Calls 3

connectFunction · 0.85
sync_policy_with_clientFunction · 0.85
fetch_policy_with_clientFunction · 0.85

Tested by

no test coverage detected