Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
fix(upgrade): update release archive allowlist to include packaging, docs, and crates directories
Testa36e9d1e846d
diff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex b33e7ae1..639cb097 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -104,7 +104,7 @@ jobs:mkdir -p "dist/$artifact/docs"cp README.md LICENSE "dist/$artifact/"cp docs/install.md "dist/$artifact/docs/install.md"- tar -C "dist/$artifact" -czf "$artifact.tar.gz" .+ COPYFILE_DISABLE=1 tar -C "dist/$artifact" -czf "$artifact.tar.gz" .sha256sum "$artifact.tar.gz" > "$artifact.tar.gz.sha256"- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1@@ -163,7 +163,7 @@ jobs:cp README.md LICENSE "dist/$artifact/"cp docs/install.md "dist/$artifact/docs/install.md"cp docs/macos.md "dist/$artifact/docs/macos.md"- tar -C "dist/$artifact" -czf "$artifact.tar.gz" .+ COPYFILE_DISABLE=1 tar -C "dist/$artifact" -czf "$artifact.tar.gz" .shasum -a 256 "$artifact.tar.gz" > "$artifact.tar.gz.sha256"- name: Smoke test release tarballdiff --git a/crates/ai-memory-cli/tests/suite/packaging.rs b/crates/ai-memory-cli/tests/suite/packaging.rsindex 773da066..b5d44ac2 100644--- a/crates/ai-memory-cli/tests/suite/packaging.rs+++ b/crates/ai-memory-cli/tests/suite/packaging.rs@@ -195,6 +195,103 @@ fn macos_release_tarball_ships_the_launchd_agent_plist() {);}+/// Source lock: Unix release packing must disable macOS AppleDouble sidecars+/// (`._*`) so Linux runners and macOS producers emit the same archive layout+/// upgrade's allowlist expects (see `extracts_archive_built_like_release_yml`).+#[test]+fn unix_release_tarball_packing_disables_appledouble_sidecars() {+ let release = read_repo(".github/workflows/release.yml");+ let pack = "COPYFILE_DISABLE=1 tar -C \"dist/$artifact\" -czf \"$artifact.tar.gz\" .";+ assert!(+ release.matches(pack).count() >= 2,+ "Linux and macOS release pack steps must set COPYFILE_DISABLE=1"+ );+}++/// Drift lock for #1025: every top-level name staged into a release archive+/// by `release.yml` must be extractable or listed in upgrade's exact support+/// consts (`RELEASE_SUPPORT_*`). Direction is release → allowlist (Windows+/// correctly omits `packaging/`). Catching a new `dist/$artifact/share`+/// without an allowlist update keeps CI red before a live tarball upgrade+/// fails after checksum.+#[test]+fn release_yml_staged_top_levels_are_upgrade_allowlisted() {+ let release = read_repo(".github/workflows/release.yml");+ let staged = release_yml_staged_top_levels(&release);+ assert!(+ staged.contains("hooks") && staged.contains("docs") && staged.contains("crates"),+ "sanity: release.yml must still stage shared top-levels; got {staged:?}"+ );++ let upgrade = read_repo("crates/ai-memory-cli/src/commands/upgrade.rs");+ let dirs = const_str_slice_body(&upgrade, "RELEASE_SUPPORT_DIRS");+ let files = const_str_slice_body(&upgrade, "RELEASE_SUPPORT_FILES");+ for name in &staged {+ // Runtime extract targets live outside the support consts.+ if matches!(name.as_str(), "hooks" | "ai-memory" | "ai-memory.exe") {+ continue;+ }+ let quoted = format!("\"{name}\"");+ assert!(+ dirs.contains("ed) || files.contains("ed),+ "release.yml stages top-level `{name}` but it is missing from \+ RELEASE_SUPPORT_DIRS/FILES in upgrade.rs"+ );+ }+}++/// First path components under `dist/$artifact/…` and `$stage/…`, plus+/// README.md/LICENSE when the workflow copies them onto the stage root.+fn release_yml_staged_top_levels(release: &str) -> std::collections::BTreeSet<String> {+ let mut tops = std::collections::BTreeSet::new();+ for prefix in ["dist/$artifact/", "$stage/"] {+ let mut search = release;+ while let Some(idx) = search.find(prefix) {+ let after = &search[idx + prefix.len()..];+ let end = after+ .find(|c: char| c == '"' || c == '\'' || c == '`' || c == '\\' || c.is_whitespace())+ .unwrap_or(after.len());+ let rel = &after[..end];+ if let Some(top) = rel+ .split('/')+ .next()+ .filter(|s| is_release_top_level_name(s))+ {+ tops.insert(top.to_string());+ }+ // Always advance so an empty relative path cannot spin forever.+ search = &search[idx + 1..];+ }+ }+ if release.contains("cp README.md LICENSE \"dist/$artifact/\"")+ || release.contains("Copy-Item README.md, LICENSE $stage")+ {+ tops.insert("README.md".to_string());+ tops.insert("LICENSE".to_string());+ }+ tops+}++/// Reject globs / comment noise (e.g. `"$stage/*"` in release.yml prose).+fn is_release_top_level_name(name: &str) -> bool {+ !name.is_empty()+ && name+ .chars()+ .all(|c| c.is_ascii_alphanumeric() || matches!(c, '-' | '_' | '.'))+}++fn const_str_slice_body<'a>(src: &'a str, name: &str) -> &'a str {+ let marker = format!("const {name}:");+ let start = src+ .find(&marker)+ .unwrap_or_else(|| panic!("upgrade.rs must declare {name}"));+ let from = &src[start..];+ let end = from+ .find(';')+ .unwrap_or_else(|| panic!("{name} const must end with ';'"));+ &from[..end]+}+#[test]fn aur_packages_install_all_native_assets() {for path in ["packaging/aur/PKGBUILD", "packaging/aur/PKGBUILD-bin"] {diff --git a/crates/ai-memory-cli/tests/suite/upgrade_e2e.rs b/crates/ai-memory-cli/tests/suite/upgrade_e2e.rsindex 5ddfd478..9348556b 100644--- a/crates/ai-memory-cli/tests/suite/upgrade_e2e.rs+++ b/crates/ai-memory-cli/tests/suite/upgrade_e2e.rs@@ -78,6 +78,27 @@ mod slow {let mut builder = tar::Builder::new(&mut tar_bytes);append_regular(&mut builder, "ai-memory", NEW_BINARY, 0o755);append_regular(&mut builder, "hooks/claude-code/new.sh", NEW_HOOK, 0o755);+ // Match release.yml Unix layout (exact support paths) so hermetic+ // upgrade still exercises the #1025 support-file allowlist.+ append_dir(&mut builder, "packaging");+ append_dir(&mut builder, "packaging/launchd");+ append_regular(+ &mut builder,+ "packaging/launchd/com.github.akitaonrails.ai-memory.plist",+ b"plist",+ 0o644,+ );+ append_dir(&mut builder, "docs");+ append_regular(&mut builder, "docs/install.md", b"# install", 0o644);+ append_dir(&mut builder, "crates");+ append_regular(+ &mut builder,+ "crates/ai-memory-cli/templates/config.default.toml",+ b"# config",+ 0o644,+ );+ append_regular(&mut builder, "README.md", b"# ai-memory", 0o644);+ append_regular(&mut builder, "LICENSE", b"MIT", 0o644);builder.finish().expect("finish tar");}let mut gz_bytes = Vec::new();@@ -101,11 +122,40 @@ mod slow {zip.start_file("hooks/claude-code/new.sh", options).expect("start hook");zip.write_all(NEW_HOOK).expect("write hook");+ // Windows release.yml ships docs/crates/README/LICENSE (no+ // packaging/); include them so zip allowlist drift is caught.+ zip.add_directory("docs/", options).expect("docs dir");+ zip.start_file("docs/install.md", options)+ .expect("start docs");+ zip.write_all(b"# install").expect("write docs");+ zip.add_directory("crates/", options).expect("crates dir");+ zip.start_file(+ "crates/ai-memory-cli/templates/config.default.toml",+ options,+ )+ .expect("start crates");+ zip.write_all(b"# config").expect("write crates");+ zip.start_file("README.md", options).expect("start readme");+ zip.write_all(b"# ai-memory").expect("write readme");+ zip.start_file("LICENSE", options).expect("start license");+ zip.write_all(b"MIT").expect("write license");zip.finish().expect("finish zip");}cursor.into_inner()}+ fn append_dir(builder: &mut tar::Builder<&mut Vec<u8>>, path: &str) {+ let mut header = Header::new_gnu();+ header.set_entry_type(tar::EntryType::Directory);+ header.set_path(path).expect("set dir path");+ header.set_size(0);+ header.set_mode(0o755);+ header.set_cksum();+ builder+ .append(&header, std::io::empty())+ .expect("append tar dir");+ }+fn append_regular(builder: &mut tar::Builder<&mut Vec<u8>>,path: &str,