test(desktop): pin AGENTS.md migration guard against template drift

The legacy-nest migration's copy_file_over_generated_default detects an
untouched default AGENTS.md by byte-equality against the embedded AGENTS_MD
template. That comparison only succeeds while ensure_nest_at writes the
template verbatim on a fresh file; a future template or refresh change that
breaks the identity would make the guard silently fail closed and re-strand
the user's legacy AGENTS.md. This test pins the byte-equality invariant so
such drift trips a loud failure instead of regressing the migration.

Co-authored-by: Will Pfleger <pfleger.will@gmail.com>
Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
This commit is contained in:
npub1mn7jgtj4w2pd0g0zeuhxsa6jy6p0rewxz4kujt98my82ahfmp72sxjexk7
2026-06-23 18:41:11 -04:00
parent 6ad68a6b09
commit e49f54ac8e

View File

@@ -981,3 +981,19 @@ fn migrate_legacy_nest_preserves_user_edited_agents_md() {
"a user-edited live AGENTS.md must never be clobbered"
);
}
#[test]
fn ensure_nest_writes_agents_md_byte_equal_to_template() {
// Guard for the legacy-AGENTS.md migration: copy_file_over_generated_default
// detects an untouched default by byte-equality against AGENTS_MD; that holds only
// while ensure_nest_at stays an identity on a fresh file. Drift would silently
// re-strand the legacy file, so pin the invariant here.
let dir = tempfile::tempdir().unwrap();
let current = dir.path().join(".buzz");
crate::managed_agents::ensure_nest_at(&current).unwrap();
assert_eq!(
std::fs::read_to_string(current.join("AGENTS.md")).unwrap(),
crate::managed_agents::AGENTS_MD,
"ensure_nest_at must write AGENTS.md byte-equal to the embedded template"
);
}