Improve connector detection for migrated sessions (#36977)

## Why

Session IDs are derived from file stems and can repeat across projects. Keying
connector attribution only by session ID can therefore assign one session's
connectors to another session during a batched migration.

## What changed

- Preserve connector candidates by canonical source path until each imported
  session is annotated, then aggregate them for detection summaries.
- Resolve project-backed MCP tool calls from both `CallMcpTool` server IDs and
  `mcpDetails.serverName`, while requiring a match in project metadata.

## Testing

Add coverage for duplicate session stems, per-source connector results, and
both supported project-backed MCP tool-call formats.

GitOrigin-RevId: 10563d47c29673c07daa83be5f4e1a256740b901
This commit is contained in:
charlesgong-openai authored and copyberry committed 2026-08-04 21:45:28 +00:00
1 parent 1b90b1d16b
commit 1a5e152189
10 files changed
+546 -172

No files matched your search

@@ -3,7 +3,9 @@ use crate::CurSource;
use crate::RewriteProfile;
use crate::detect::plugins;
use crate::detect::sessions::detect_cla_session_connectors;
use crate::detect::sessions::detect_cla_session_connectors_by_source_path;
use crate::detect::sessions::detect_cur_session_connectors;
use crate::detect::sessions::detect_cur_session_connectors_by_source_path;
use crate::detect::sessions::detect_recent_cla_sessions_with_limits;
use crate::detect::sessions::detect_recent_cur_sessions_with_limits;
use crate::model::DetectedConnectorCandidate;
@@ -172,6 +174,22 @@ impl ExternalAgentSource {
}
}
pub(super) fn detect_session_connectors_by_source_path(
self,
sessions: &[ExternalAgentSessionMigration],
connector_metadata_roots: &[PathBuf],
external_agent_home: &Path,
) -> BTreeMap<PathBuf, Vec<DetectedConnectorCandidate>> {
match self {
Self::Cla => {
detect_cla_session_connectors_by_source_path(sessions, connector_metadata_roots)
}
Self::Cur => {
detect_cur_session_connectors_by_source_path(sessions, external_agent_home)
}
}
}
pub(super) fn marketplace_import_sources(
self,
external_agent_home: &Path,