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,
)
| 626 | /// Performs the full discovery flow (fetch → sync → re-fetch) over one |
| 627 | /// channel instead of establishing three separate connections. |
| 628 | pub 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 | /// |
no test coverage detected