systemprompt_models/services/bridge_policy.rs
1//! Instance-level policy the bridge enforces on managed client installations.
2//!
3//! Configured as a top-level `bridge_policy:` section in a services YAML and
4//! carried to clients inside the signed bridge manifest. Two knobs today:
5//! whether Claude Code's managed-MCP policy re-allows claude.ai first-party
6//! connectors (`allowAllClaudeAiMcps`) alongside the managed server set —
7//! without it, writing `managed-mcp.json` suppresses every connector the user
8//! linked on claude.ai — and whether bridges keep themselves current.
9//!
10//! Copyright (c) systemprompt.io — Business Source License 1.1.
11//! See <https://systemprompt.io> for licensing details.
12
13use serde::{Deserialize, Serialize};
14
15#[derive(Debug, Clone, Copy, Default, Serialize, Deserialize)]
16#[serde(deny_unknown_fields)]
17pub struct BridgePolicyConfig {
18 #[serde(default)]
19 pub allow_claude_ai_connectors: bool,
20 #[serde(default)]
21 pub auto_update: AutoUpdatePolicy,
22}
23
24/// Whether a bridge updates itself, and how far it is allowed to go on its own.
25///
26/// `Staged` downloads, verifies and swaps the on-disk binary but never restarts
27/// the running process: the next natural launch runs the new version. There is
28/// deliberately no variant that restarts unattended — the fleet-wide brake for
29/// a bad release is `pinned_version` on the release feed, not a client toggle.
30#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
31#[serde(rename_all = "snake_case")]
32pub enum AutoUpdatePolicy {
33 Disabled,
34 #[default]
35 Staged,
36}
37
38impl AutoUpdatePolicy {
39 #[must_use]
40 pub const fn stages(self) -> bool {
41 matches!(self, Self::Staged)
42 }
43}