Skip redirected external-agent migration destinations (#39221)

## Why

Repository-scoped imports must not follow redirected Codex paths and write
generated configuration outside the repository.

## What changed

- Reject repository migration scopes when generated configuration paths are
  symlinks or, on Windows, reparse points.
- Recheck hook and subagent destinations during import, skipping redirected
  directories, files, and dangling links without reporting them as imported.

## Testing

Add service and app-server coverage for redirected generated destinations,
including a repository path replaced with a symlink after detection.

GitOrigin-RevId: 3afb521ead9d76250f0e967eccfdd1dc194f027a
This commit is contained in:
jif authored and copyberry committed 2026-08-18 16:05:51 +00:00
1 parent 76ceaddb29
commit 2a30972fcb
5 files changed
+202 -5

No files matched your search

@@ -1,5 +1,6 @@
use crate::RewriteProfile;
use crate::invalid_data_error;
use crate::scope::is_redirected_destination;
use serde_yaml::Value as YamlValue;
use std::collections::BTreeMap;
use std::fs;
@@ -46,7 +47,7 @@ pub fn missing_subagent_names(
let Some(target) = subagent_target_file(&source_file, target_agents) else {
continue;
};
if !target.exists() {
if !target.exists() && !is_redirected_destination(&target)? {
names.push(metadata.name);
}
}
@@ -68,7 +69,7 @@ pub fn import_subagents_with_rewrite_profile(
let Some(target) = subagent_target_file(&source_file, target_agents) else {
continue;
};
if target.exists() {
if target.exists() || is_redirected_destination(&target)? {
continue;
}
let document = parse_document(&source_file)?;