mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Honor thread-level plugin exclusions across runtime capabilities (#44655)
## What changed - Apply `disabled_plugin_ids` to plugin skills, recommendations, hooks, and MCP servers without modifying shared plugin state. - Activate selection changes when the next task starts, keeping pending settings from changing the active runtime. - Hide app tools contributed only by disabled plugins from model tool catalogs and search. Preserve connectors shared with enabled plugins and existing direct Apps RPC behavior. - Include plugin identity in MCP approval keys and use that identity when persisting plugin tool approvals. ## Testing Add regression coverage for disabling and re-enabling plugin skills and tools, deferred activation of settings, shared connector ownership, selected plugin servers, executor hooks, and plugin-specific approval keys and persistence. GitOrigin-RevId: 1153ff6aa7ab6953d50e838da05203904ecd2956
This commit is contained in:
1 parent
5c94936b56
commit
8570091e14
27 files changed
+565
-171
No files matched your search
@@ -59,28 +59,43 @@ impl PluginConnectorSource {
|
||||
}
|
||||
}
|
||||
|
||||
/// Immutable connector declarations and their plugin provenance.
|
||||
impl From<&PluginCapabilitySummary> for PluginConnectorSource {
|
||||
fn from(summary: &PluginCapabilitySummary) -> Self {
|
||||
Self::from_connector_ids(
|
||||
summary.config_name.clone(),
|
||||
summary.display_name.clone(),
|
||||
summary.app_connector_ids.clone(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// Immutable connector selection and provenance after applying disabled plugins.
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq)]
|
||||
pub struct ConnectorSnapshot {
|
||||
sources: Vec<PluginConnectorSource>,
|
||||
connector_ids: Vec<AppConnectorId>,
|
||||
plugin_display_names_by_connector_id: HashMap<String, Vec<String>>,
|
||||
disabled_connector_ids: HashSet<String>,
|
||||
}
|
||||
|
||||
impl ConnectorSnapshot {
|
||||
/// Builds a connector snapshot from package-scoped declarations.
|
||||
pub fn from_plugin_sources(sources: impl IntoIterator<Item = PluginConnectorSource>) -> Self {
|
||||
let sources = sources
|
||||
.into_iter()
|
||||
.filter(|source| !source.connector_ids().is_empty())
|
||||
.collect::<Vec<_>>();
|
||||
/// Builds the final selection from all plugin sources, preserving contribution order.
|
||||
/// Pass host and selected sources together so any enabled shared owner keeps a connector.
|
||||
pub fn from_plugin_sources(
|
||||
sources: impl IntoIterator<Item = PluginConnectorSource>,
|
||||
disabled_plugin_ids: &[String],
|
||||
) -> Self {
|
||||
let mut connector_ids = Vec::new();
|
||||
let mut seen_connector_ids = HashSet::new();
|
||||
let mut plugin_display_names_by_connector_id: HashMap<String, Vec<String>> = HashMap::new();
|
||||
let mut disabled_connector_ids = HashSet::new();
|
||||
|
||||
for source in &sources {
|
||||
for source in sources {
|
||||
if disabled_plugin_ids.contains(&source.plugin_id) {
|
||||
disabled_connector_ids.extend(source.connector_ids.into_iter().map(|id| id.0));
|
||||
continue;
|
||||
}
|
||||
for connector_id in source.connector_ids() {
|
||||
if seen_connector_ids.insert(connector_id.clone()) {
|
||||
if seen_connector_ids.insert(connector_id.0.clone()) {
|
||||
connector_ids.push(connector_id.clone());
|
||||
}
|
||||
plugin_display_names_by_connector_id
|
||||
@@ -93,23 +108,18 @@ impl ConnectorSnapshot {
|
||||
plugin_names.sort_unstable();
|
||||
plugin_names.dedup();
|
||||
}
|
||||
disabled_connector_ids.retain(|id| !seen_connector_ids.contains(id));
|
||||
|
||||
Self {
|
||||
sources,
|
||||
connector_ids,
|
||||
plugin_display_names_by_connector_id,
|
||||
disabled_connector_ids,
|
||||
}
|
||||
}
|
||||
|
||||
/// Adapts the current host plugin summaries to the connector-owned snapshot.
|
||||
pub fn from_plugin_capability_summaries(summaries: &[PluginCapabilitySummary]) -> Self {
|
||||
Self::from_plugin_sources(summaries.iter().map(|summary| {
|
||||
PluginConnectorSource::from_connector_ids(
|
||||
summary.config_name.clone(),
|
||||
summary.display_name.clone(),
|
||||
summary.app_connector_ids.clone(),
|
||||
)
|
||||
}))
|
||||
Self::from_plugin_sources(summaries.iter().map(PluginConnectorSource::from), &[])
|
||||
}
|
||||
|
||||
/// Returns the connector IDs in source contribution order.
|
||||
@@ -117,6 +127,11 @@ impl ConnectorSnapshot {
|
||||
&self.connector_ids
|
||||
}
|
||||
|
||||
/// Connector tools excluded because no enabled plugin still contributes them.
|
||||
pub fn disabled_connector_ids(&self) -> &HashSet<String> {
|
||||
&self.disabled_connector_ids
|
||||
}
|
||||
|
||||
/// Returns the package display names associated with one connector.
|
||||
pub fn plugin_display_names_for_connector_id(&self, connector_id: &str) -> &[String] {
|
||||
self.plugin_display_names_by_connector_id
|
||||
@@ -124,11 +139,6 @@ impl ConnectorSnapshot {
|
||||
.map(Vec::as_slice)
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
/// Combines two snapshots while preserving source order and provenance.
|
||||
pub fn merged_with(&self, other: &Self) -> Self {
|
||||
Self::from_plugin_sources(self.sources.iter().chain(&other.sources).cloned())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -6,19 +6,17 @@ use super::PluginConnectorSource;
|
||||
|
||||
#[test]
|
||||
fn snapshot_merges_sources_in_order_and_dedupes_provenance() {
|
||||
let host_source = source("host", "Zulu", &["calendar", "calendar"]);
|
||||
let host = ConnectorSnapshot::from_plugin_sources([
|
||||
let host = [
|
||||
source("skills", "Skills only", &[]),
|
||||
host_source.clone(),
|
||||
]);
|
||||
let selected = ConnectorSnapshot::from_plugin_sources([
|
||||
source("host", "Zulu", &["calendar", "calendar"]),
|
||||
];
|
||||
let selected = [
|
||||
source("selected-a", "Alpha", &["drive", "calendar"]),
|
||||
source("selected-b", "Alpha", &["calendar"]),
|
||||
]);
|
||||
];
|
||||
|
||||
let merged = host.merged_with(&selected);
|
||||
let merged = ConnectorSnapshot::from_plugin_sources(host.into_iter().chain(selected), &[]);
|
||||
|
||||
assert_eq!(host.sources, vec![host_source]);
|
||||
assert_eq!(
|
||||
merged.connector_ids(),
|
||||
&[
|
||||
@@ -36,6 +34,42 @@ fn snapshot_merges_sources_in_order_and_dedupes_provenance() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn disabled_plugins_preserve_shared_connectors() {
|
||||
let sources = [
|
||||
source("alpha", "Alpha", &["exclusive", "shared"]),
|
||||
source("beta", "Beta", &["other", "shared"]),
|
||||
];
|
||||
let filtered = ConnectorSnapshot::from_plugin_sources(sources.clone(), &["alpha".to_string()]);
|
||||
|
||||
let expected = ConnectorSnapshot {
|
||||
disabled_connector_ids: std::collections::HashSet::from(["exclusive".to_string()]),
|
||||
..ConnectorSnapshot::from_plugin_sources(
|
||||
[source("beta", "Beta", &["other", "shared"])],
|
||||
&[],
|
||||
)
|
||||
};
|
||||
assert_eq!(filtered, expected);
|
||||
assert_eq!(
|
||||
ConnectorSnapshot::from_plugin_sources(
|
||||
sources.iter().rev().cloned(),
|
||||
&["alpha".to_string()],
|
||||
),
|
||||
expected
|
||||
);
|
||||
assert_eq!(
|
||||
ConnectorSnapshot::from_plugin_sources(sources, &["alpha".to_string(), "beta".to_string()],),
|
||||
ConnectorSnapshot {
|
||||
disabled_connector_ids: std::collections::HashSet::from([
|
||||
"exclusive".to_string(),
|
||||
"other".to_string(),
|
||||
"shared".to_string(),
|
||||
]),
|
||||
..ConnectorSnapshot::default()
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
fn source(id: &str, display_name: &str, connector_ids: &[&str]) -> PluginConnectorSource {
|
||||
PluginConnectorSource::from_connector_ids(
|
||||
id,
|
||||
|
||||
Reference in new issue
Block a user