Skip to content

Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors

Rust

fix: scope the OKF pending exclusion to project roots

Yang Fan2fadb61bce74
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 48c56588..5c8b2e1d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -17,6 +17,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
now uses the import instead of a prose pointer (#680).
### Fixed
+- Limited the OKF migration's `_pending/` exclusion to project roots, so
+ ordinary nested pages such as `notes/_pending/legacy.md` still trigger a
+ safety backup and migrate. Project-root proposal sidecars remain excluded
+ (#695).
- The Docker wrapper (`bin/ai-memory`) now forwards `GEMINI_API_KEY` and
`GOOGLE_API_KEY` into the container. Every other provider credential was on
the `-e` forwarding allowlist, but these two were missing, so
diff --git a/crates/ai-memory-wiki/src/migrations/m2026_09_okf_conformance.rs b/crates/ai-memory-wiki/src/migrations/m2026_09_okf_conformance.rs
index 4ba6864c..2004f6ed 100644
--- a/crates/ai-memory-wiki/src/migrations/m2026_09_okf_conformance.rs
+++ b/crates/ai-memory-wiki/src/migrations/m2026_09_okf_conformance.rs
@@ -212,9 +212,14 @@ fn nonconformant_files(wiki_root: &Path) -> WikiResult<Vec<PathBuf>> {
// every boot, and since this scan feeds the pre-migration
// backup gate, that re-archives the whole data dir each time
// once the receipt's archive is gone (#695, same class as the
- // ledger skip for #669). Skip the subtree, matching the
- // watcher indexer's own `_pending/` exclusion.
- if path.file_name().is_some_and(|n| n == "_pending") {
+ // ledger skip for #669). Only the project-root subtree is
+ // reserved, matching the watcher indexer's `_pending/` rule;
+ // a nested path like notes/_pending still contains pages.
+ if path.file_name().is_some_and(|n| n == "_pending")
+ && path
+ .strip_prefix(wiki_root)
+ .is_ok_and(|relative| relative.components().count() == 3)
+ {
continue;
}
stack.push(path);
@@ -829,6 +834,26 @@ mod tests {
);
}
+ #[test]
+ fn a_nested_pending_directory_still_requires_a_migration_backup() {
+ let tmp = TempDir::new().unwrap();
+ let wiki_root = tmp.path().join("wiki");
+ let relative = PathBuf::from("w/p/notes/_pending/legacy.md");
+ let path = wiki_root.join(&relative);
+ std::fs::create_dir_all(path.parent().unwrap()).unwrap();
+ std::fs::write(path, "# Ordinary old page\n").unwrap();
+ let page = PagePath::new("notes/_pending/legacy.md").unwrap();
+ assert!(!crate::watcher::is_pending_path(&page));
+ assert_eq!(nonconformant_files(&wiki_root).unwrap(), vec![relative]);
+ let dest = TempDir::new().unwrap();
+ assert!(
+ snapshot_before_db_migration(tmp.path(), Some(dest.path()))
+ .unwrap()
+ .is_some(),
+ "ordinary legacy pages still require a pre-migration backup"
+ );
+ }
+
/// A conformant store whose only "nonconformant" files are auto-improve
/// staging sidecars under `_pending/` must not re-archive the data dir.
/// The sidecars carry no OKF frontmatter and are never migrated (SQLite
diff --git a/docs/auto-improvement-loop.md b/docs/auto-improvement-loop.md
index 4aebdd8c..1255c3c7 100644
--- a/docs/auto-improvement-loop.md
+++ b/docs/auto-improvement-loop.md
@@ -515,6 +515,10 @@ non-indexed sidecars plus SQLite rows, with list/diff/approve/reject commands
and audit rows. Approval applies through the existing wiki mutation boundaries
with the `auto_improve` actor preserved in proposal provenance.
+Only the project-root `_pending/` directory is reserved proposal storage and
+excluded from the OKF migration scan. A nested path such as
+`notes/_pending/legacy.md` remains an ordinary wiki page and must still migrate.
+
Tests:
1. Pending proposals survive restart.