Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

fix(tools): make self-move regressions filesystem-aware

cauliflower5bb56226a41d
diff --git a/crates/host-core/src/tools/mod.rs b/crates/host-core/src/tools/mod.rs
index 424dc26ae..4e12c6ba6 100644
--- a/crates/host-core/src/tools/mod.rs
+++ b/crates/host-core/src/tools/mod.rs
@@ -4885,22 +4885,27 @@ mod tests {
#[tokio::test]
async fn edit_move_to_self_preserves_source_bytes() {
let dir = tempfile::tempdir().unwrap();
- let target = dir.path().join("source.txt");
+ // macOS temp roots may spell /private/var as /var. Use the same
+ // canonical spelling for the workspace and its absolute destination.
+ let root = crate::workspace::simple_canonicalize(dir.path()).unwrap();
+ let target = root.join("source.txt");
let input = b"original\r\n";
+ std::fs::write(&target, input).unwrap();
let mut destinations = vec![
"source.txt".to_string(),
"./source.txt".to_string(),
"sub/../source.txt".to_string(),
target.to_string_lossy().into_owned(),
];
- if cfg!(windows) {
+ // Probe this directory rather than assuming case sensitivity by OS.
+ if root.join("SOURCE.TXT").try_exists().unwrap() {
destinations.push("SOURCE.TXT".to_string());
}
let mut failures = Vec::new();
for dest in destinations {
std::fs::write(&target, input).unwrap();
let read = execute_tool(
- Some(dir.path()),
+ Some(&root),
None,
"Read",
&json!({"path": "source.txt"}),
@@ -4910,7 +4915,7 @@ mod tests {
assert!(read.ok, "Read failed: {:?}", read.content);
// A mixed call must reject the move before even the PUT bytes land.
let result = execute_tool(
- Some(dir.path()),
+ Some(&root),
None,
"Edit",
&json!({"path": "source.txt", "tag": read.content["tag"],
diff --git a/docs/spec/03-runtime/18-line-anchored-edit-contract.md b/docs/spec/03-runtime/18-line-anchored-edit-contract.md
index 44a2e620d..0b32a3f8e 100644
--- a/docs/spec/03-runtime/18-line-anchored-edit-contract.md
+++ b/docs/spec/03-runtime/18-line-anchored-edit-contract.md
@@ -272,6 +272,9 @@ covers relative/absolute aliases, `.` and `..`, symlinks, and case-only spelling
on case-insensitive filesystems. `MV` does not support case-only renaming there;
use a distinct destination instead. Case-sensitive filesystems retain their
normal distinction between different files whose names differ only in case.
+This rejection applies after path resolution and permission checks succeed;
+an alias rejected by those checks keeps their error (for example,
+`PATH_OUTSIDE_WORKSPACE`) and does not reach the self-move comparison.
### 7.3 Anchoring rules
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index 2976ffd6c..d8733c857 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -11197,7 +11197,8 @@ This test plan spec is accepted when:
7. Repeat step 6 with two recorded candidates sharing that basename and tag.
8. Emit `MV` to the source itself, `./source`, `sub/../source`, and its
absolute path, plus a directory symlink (Windows junction) pointing back
- to its directory; on Windows also use a case-only alias. Repeat with a
+ to its directory; on a case-insensitive filesystem also use a case-only
+ alias. Repeat with a
content-changing `PUT` in the same call, then use the original Read tag
for a valid content edit.
- **Expected**: Step 1 records a source deletion and a destination creation under