Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
Merge remote-tracking branch 'refs/remotes/audit-open/1539'
AkitaOnRailsb73b25317cd7
diff --cc CHANGELOG.mdindex 8df19dd5,89f7324f..ba0d3fbe--- a/CHANGELOG.md+++ b/CHANGELOG.md@@@ -285,55 -223,13 +285,62 @@@ version in [`docs/changelog/`](docs/charelay and wiki sync companions take the same `rustls-webpki` bump.### Fixed+- An empty structured answer from a Responses-API model is now reported as+ empty content rather than a JSON parse error. The `opencode`, `openai-oauth`+ and `codex` paths defaulted a missing `output_text` to an empty string and+ handed it to the parser, so the operator saw `serde: EOF while parsing a+ value at line 1 column 0`, naming neither the model nor the cause.+ ([#1529](https://github.com/akitaonrails/ai-memory/pull/1529))+- Detected `core.hooksPath` when a git config set it on the same physical+ line as the `[core]` section header, so `ai-memory-wikisync install-hook`+ no longer writes a `.git/hooks/post-merge` that git would never run.+ ([#1530](https://github.com/akitaonrails/ai-memory/pull/1530))+- Counted a file's final line in `ai-memory-wikisync` diff summaries when it+ does not end in a newline, so the `bytes/lines` figures no longer contradict+ the `first difference at line N` printed beside them.+ ([#1531](https://github.com/akitaonrails/ai-memory/pull/1531))+- `ai-memory run` now refuses an `--env`/`--env-file` entry whose key carries+ whitespace. `--env-file` lines are trimmed as a whole, not per half, so the+ common dotenv spelling `KEY = value` produced a key with a trailing space —+ an entry no shell or harness can read, so the override silently did nothing.+ ([#1532](https://github.com/akitaonrails/ai-memory/pull/1532))+- Discovered a repository page whose `--include` family names a bare top-level+ page (`README.md`), which `ai-memory-wikisync sync` previously left out of the+ repository side entirely, so a newly created one was never imported.+ ([#1533](https://github.com/akitaonrails/ai-memory/pull/1533))+- A Copilot `/responses` answer stopped by `max_output_tokens` is now reported+ as a truncated response naming the model and its output-token count, instead+ of an unexpected response shape reading "no error detail" — `error` is null+ on an incomplete answer, so nothing explained the stop and the class implied+ an unparseable reply rather than a `max_tokens` to raise.+ ([#1534](https://github.com/akitaonrails/ai-memory/pull/1534))+- Omitted TTL-expired pages from the page count in `memory_briefing` and+ `memory_explore`. Every page list in a briefing already hid them, and the+ project cards have since 3.1.x, so a project with an expired page reported+ more latest pages than any list in the same response could show. The+ all-versions total is unchanged, as is `ai-memory status`.+ ([#1535](https://github.com/akitaonrails/ai-memory/pull/1535))+++- `memory_read_page` now reads a blank `path` or `query` as omitted, as its+ sibling arguments already do. An empty or whitespace-only `query` searched+ for an empty FTS expression and reported the inevitable miss as an internal+ error (-32603), which a looping client reads as "retry"; an empty `path`+ failed as "invalid path: empty path" and never tried the `query` passed+ beside it. Both now reach the instructive "exactly one of `path` or `query`"+ refusal, and a blank `path` beside a real `query` runs the search.+ ([#1536](https://github.com/akitaonrails/ai-memory/pull/1536))+- Reported a wiki page renamed away with an external tool, which arrives as a+ rename event rather than a removal, so the next auto-commit drops it from the+ tree instead of leaving a checkpoint naming a page that no longer exists.+ ([#1537](https://github.com/akitaonrails/ai-memory/pull/1537))+ - Omitted TTL-expired pages from the 7- and 30-day activity counters in+ `memory_briefing`. A page written with a short TTL made a project look+ active while the brief's own recent-page list was empty, which is the+ signal an agent uses to decide how much context to pull. Session and+ observation counters have no TTL and are unchanged.+ ([#1539](https://github.com/akitaonrails/ai-memory/pull/1539))+- Memory health no longer counts a link from a superseded or TTL-expired pageversion as a reference. A page whose only inbound link was removed by a lateredit was reported as linked, because the old version's `links` row survivesdiff --cc crates/ai-memory-store/tests/suite/multi_session.rsindex f0bf8bc1,6da980ba..a52fe1e8--- a/crates/ai-memory-store/tests/suite/multi_session.rs+++ b/crates/ai-memory-store/tests/suite/multi_session.rs@@@ -4537,66 -4537,75 +4537,139 @@@ async fn memory_health_ignores_expired_assert_eq!(p_detail.orphans.len(), 2);}+/// The briefing's `pages_latest` must agree with the page lists in the same+/// snapshot: an expired page is hidden from every one of them, so counting it+/// in the headline makes the brief advertise a page the agent cannot reach.+#[tokio::test]+async fn briefing_pages_latest_ignores_expired_pages() {+ let tmp = tempfile::tempdir().unwrap();+ let store = Store::open(tmp.path()).unwrap();+ let (ws, proj) = scope(&store).await;++ store+ .writer+ .upsert_page(page(ws, proj, "notes/live.md", "Live", "content"))+ .await+ .unwrap();+ let mut expired = page(ws, proj, "notes/expired.md", "Expired", "content");+ expired.expires_at = Some(jiff::Timestamp::from_second(1).unwrap());+ store.writer.upsert_page(expired).await.unwrap();++ let live_pages = store+ .reader+ .list_unexpired_pages("acme", "shared-app")+ .await+ .unwrap();+ assert_eq!(live_pages.len(), 1, "one of the two pages is expired");++ let project = store+ .reader+ .briefing_for_project(ws, proj, 5, ai_memory_core::OwnerFilter::Any, false)+ .await+ .unwrap();+ assert_eq!(+ project.counts.pages_latest,+ live_pages.len() as u64,+ "project pages_latest counts only the unexpired latest page"+ );+ assert_eq!(+ project.recent_pages.len(),+ 1,+ "control: the list the count is supposed to agree with holds one page"+ );+ // Control: the all-versions total is deliberately TTL-blind, so a fix that+ // merely broke both counts the same way cannot satisfy this test.+ assert_eq!(+ project.counts.pages_all, 2,+ "control: pages_all stays the raw all-versions total"+ );++ let workspace = store+ .reader+ .briefing_for_workspace(ws, 5, ai_memory_core::OwnerFilter::Any, None)+ .await+ .unwrap();+ assert_eq!(workspace.counts.pages_latest, 1);+ assert_eq!(workspace.counts.pages_all, 2);++ let global = store+ .reader+ .briefing(5, ai_memory_core::OwnerFilter::Any)+ .await+ .unwrap();+ assert_eq!(global.counts.pages_latest, 1);+ assert_eq!(global.counts.pages_all, 2);+}+++ /// The briefing's activity windows are what an agent calibrates verbosity+ /// against, and `recent_pages` in the same snapshot already hides TTL-expired+ /// pages. A page written today with an expiry an hour ago must not make the+ /// project look active.+ #[tokio::test]+ async fn briefing_activity_windows_ignore_expired_pages() {+ let tmp = tempfile::tempdir().unwrap();+ let store = Store::open(tmp.path()).unwrap();+ let (ws, proj) = scope(&store).await;++ let mut expired = page(ws, proj, "notes/expired.md", "Expired", "content");+ expired.expires_at = Some(jiff::Timestamp::from_second(1).unwrap());+ store.writer.upsert_page(expired).await.unwrap();++ let project = store+ .reader+ .briefing_for_project(ws, proj, 5, ai_memory_core::OwnerFilter::Any, false)+ .await+ .unwrap();+ assert!(+ project.recent_pages.is_empty(),+ "control: the only page in the window is already hidden from the list"+ );+ assert_eq!(+ project.activity_7d.pages_updated, 0,+ "the expired page does not count as 7-day project activity"+ );+ assert_eq!(project.activity_30d.pages_updated, 0);++ let workspace = store+ .reader+ .briefing_for_workspace(ws, 5, ai_memory_core::OwnerFilter::Any, None)+ .await+ .unwrap();+ assert_eq!(workspace.activity_7d.pages_updated, 0);+ assert_eq!(workspace.activity_30d.pages_updated, 0);++ let global = store+ .reader+ .briefing(5, ai_memory_core::OwnerFilter::Any)+ .await+ .unwrap();+ assert_eq!(global.activity_7d.pages_updated, 0);+ assert_eq!(global.activity_30d.pages_updated, 0);++ // Control: a live page written in the same window still counts, so the+ // guard cannot pass by zeroing the counter outright.+ store+ .writer+ .upsert_page(page(ws, proj, "notes/live.md", "Live", "content"))+ .await+ .unwrap();+ let project = store+ .reader+ .briefing_for_project(ws, proj, 5, ai_memory_core::OwnerFilter::Any, false)+ .await+ .unwrap();+ assert_eq!(project.activity_7d.pages_updated, 1);+ assert_eq!(project.activity_30d.pages_updated, 1);+ let workspace = store+ .reader+ .briefing_for_workspace(ws, 5, ai_memory_core::OwnerFilter::Any, None)+ .await+ .unwrap();+ assert_eq!(workspace.activity_7d.pages_updated, 1);+ let global = store+ .reader+ .briefing(5, ai_memory_core::OwnerFilter::Any)+ .await+ .unwrap();+ assert_eq!(global.activity_7d.pages_updated, 1);+ }