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/1562'
AkitaOnRails1f75296333f2
diff --cc CHANGELOG.mdindex 56e87132,2e13ba4d..83a54d6d--- a/CHANGELOG.md+++ b/CHANGELOG.md@@@ -285,196 -223,14 +285,204 @@@ 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))++- Kept a literal `<mark>` tag from a page's own text out of a search snippet's+ markup, so it no longer renders as an unbalanced opening tag that highlights+ the rest of the excerpt as if it were a query match.+ ([#1540](https://github.com/akitaonrails/ai-memory/pull/1540))+- `install.ps1` now refuses a plain-http GitHub release base. The scheme check+ sat inside a condition whose arms already implied https, so it could never+ fire, and an `http://github.com/...` base matched neither arm and skipped it+ entirely — while the archive and its checksum are fetched from that same+ origin, so the checksum proved nothing against an on-path rewrite.+ ([#1541](https://github.com/akitaonrails/ai-memory/pull/1541))+- An unspaced-CJK search carrying `AND`, `NOT` or `NEAR` no longer returns the+ pages the operator excluded. The auxiliary CJK stream discarded every boolean+ operator and `OR`-joined the CJK runs it found, and because that stream is+ unioned into the primary one, `東京 NOT 大阪` fused the 大阪-only pages back in+ and ranked them as if they had been asked for. The stream now declines such a+ query, so unspaced-CJK recall narrows to the pre-feature answer for it instead+ of inverting; `OR` queries are unaffected.+ ([#1542](https://github.com/akitaonrails/ai-memory/pull/1542))+- An `openai-oauth` answer the Codex backend stopped at its output-token+ budget is now a terminal truncation instead of a retryable `502`. The+ streaming parser read `response.incomplete` as a provider fault, so the+ fallback chain advanced to the next candidate and opened a circuit, and the+ SessionEnd consolidation job kept re-sending the same prompt on its backoff+ schedule, each attempt truncating again at the same budget.+ ([#1543](https://github.com/akitaonrails/ai-memory/pull/1543))++- `memory_read_page` now answers a missing read target with `invalid params`+ (-32602) instead of an internal error (-32603). A page absent under the+ resolved scope, and a query that matched nothing, are caller-fixable: the+ store answered, there is simply nothing there, and a client reads -32603 as+ "retry". `memory_status` and `memory_read_session_observations` already+ answer -32602 for an unknown project or session. The messages and the+ auto-resolved-scope hint are unchanged, and a genuine disk or store failure+ on the same path still answers -32603.+ ([#1544](https://github.com/akitaonrails/ai-memory/pull/1544))+- An OpenCode subagent session's end no longer hands the next session a+ sub-task baton. The generated plugin forwarded the session's `parentID` as+ the `agent_id` subagent marker on `session.created` but not on+ `session.deleted`, so the `session-end` request carried no marker, the+ router did not recognize a child session, and it published a summary page+ and an open handoff that the next root session in that checkout consumed.+ ([#1546](https://github.com/akitaonrails/ai-memory/pull/1546))+- `install-mcp --client opencode --flavor <dialect>` now writes the flavored+ URL into the OpenCode entry. Both OpenCode entry builders read the server+ URL directly instead of the flavored one, so the flag was silently dropped+ for a client its own documentation names: a Vertex-routed install got a bare+ URL and 400'd every `tools/list`. OpenCode installs that do not pass+ `--flavor` are unchanged.+ ([#1547](https://github.com/akitaonrails/ai-memory/pull/1547))++- A `title:` or `body:` filter on an unspaced-CJK search now narrows the+ auxiliary CJK stream too. The stream read `:` as a plain run separator and+ dropped the qualifier, so its MATCH searched every indexed column including+ the path, and because that stream is unioned into the primary one,+ `title:支付服务` returned pages holding the term only in their body or path.+ ([#1548](https://github.com/akitaonrails/ai-memory/pull/1548))+- An Anthropic structured answer the model stopped at `max_tokens` is now a+ terminal truncation instead of a successful result. The provider did not read+ `stop_reason`, so a `tool_use` block holding only the JSON produced before the+ budget ran out was returned as a complete answer: a consolidation or bootstrap+ chunk could write a fraction of its pages and report success. On models that+ reject a forced `tool_choice` the same stop reported "no tool_use block"+ instead. Non-structured completions are unchanged — prose cut at the budget is+ still returned.+ ([#1549](https://github.com/akitaonrails/ai-memory/pull/1549))+- Counted a page needing only an L0 abstract embedding in `ai-memory embed+ --dry-run` and `/admin/embed`. A page whose body vector was already current+ appeared in neither the would-embed nor the up-to-date total, so the dry run+ reported no work for a scope where a live run writes abstract embeddings.+ ([#1550](https://github.com/akitaonrails/ai-memory/pull/1550))++- The PowerShell `session-start` hooks for Claude Code, Command Code and Devin+ now wrap the handoff in the same `hookSpecificOutput` envelope their POSIX+ peers emit. On Windows the baton was written as bare text, so the harness+ logged "Hook output does not start with {, treating as plain text" on every+ start and the handoff arrived unstructured instead of as `additionalContext`.+ ([#1551](https://github.com/akitaonrails/ai-memory/pull/1551))+- The Japanese iteration mark 々 (and the other letters of CJK Symbols and+ Punctuation) now stay inside a CJK run. They terminated one, so a word like+ 日々 was indexed as two single characters and searching it emitted a bare+ `"日"` that matched every page containing 日 while 日々 itself was unfindable+ as a unit. Indexing changes with this, so existing rows keep their old terms+ until they are rewritten or the index is rebuilt by a compaction.+ ([#1552](https://github.com/akitaonrails/ai-memory/pull/1552))+- `memory_write_page` now refuses a relation target whose `project:` or+ `workspace/project:` scope holds a character the link reader cannot parse,+ such as a space in `my project:notes/x`. The write boundary used a looser+ character class than the reader, so the colon stayed inside the page path on+ read and the write created an edge to a path no page write can ever produce —+ a `links` row that could never be resolved.+ ([#1553](https://github.com/akitaonrails/ai-memory/pull/1553))++- `memory_handoff_cancel` now answers a well-formed `handoff_id` that resolves+ to nothing in scope with `invalid params` (-32602) instead of an internal+ error (-32603). The lookup succeeded and found no row, so the id is the+ caller's to fix, and a client reads -32603 as "retry". The same function+ already answered a malformed id with -32602, and `memory_handoff_accept`+ reports an unknown id as `{"handoff": null}`. The message is unchanged and+ still identical for an absent id and for another operator's, so cancelling+ reveals no more than before.+ ([#1554](https://github.com/akitaonrails/ai-memory/pull/1554))+- `ai-memory run` no longer loses a native session selector that sits behind a+ non-UTF-8 argument. The scan over the forwarded arguments ended at the first+ argument that was not valid UTF-8 instead of skipping it, so a run pinned with+ an explicit `--session`/`--resume` kept no expected session id and fell back+ to post-exit transcript discovery.+ ([#1555](https://github.com/akitaonrails/ai-memory/pull/1555))+- Dropped the merged-away page's `summary:` and `abstract:` from the merge+ stub left behind by cold-cluster dedup and the dream pass. Retrieval+ prefers a frontmatter summary over the body, so the brief and the+ non-keyword hit lists described the stub as if it still held content that+ had moved to the survivor. The pre-merge frontmatter stays reachable+ through the supersession chain; compaction is unchanged.+ ([#1556](https://github.com/akitaonrails/ai-memory/pull/1556))++- The OKF migration now conforms a page nested under a project bundle whose+ file is named `index.md`. Only the bundle root's own `index.md` is reserved,+ but the skip matched on the basename at any depth, so the database row was+ conformed while its file kept pre-OKF frontmatter — and markdown being the+ source of truth, the next reindex de-conformed the page again.+ ([#1557](https://github.com/akitaonrails/ai-memory/pull/1557))+- A root Grok session no longer loses its handoff because a tool used one of+ the subagent marker key names. The shell `post-tool-use` hook matched+ `agent_id` and its siblings as substrings of the whole raw payload, so a key+ of that name nested in `tool_input` or in a structured tool result, or a+ blank top-level value, suppressed the fetch. The gate now reads top-level+ keys with a non-empty string value, like the native router and the+ PowerShell bundle already did.+ ([#1558](https://github.com/akitaonrails/ai-memory/pull/1558))+- `ai-memory list-projects` now sizes its columns by terminal display width+ rather than bytes. Accented names no longer add phantom padding, and+ double-width CJK project or workspace names no longer shift later columns.+ ([#1559](https://github.com/akitaonrails/ai-memory/pull/1559))++ - A byte size just under a unit boundary now carries to the next unit instead+ of printing a magnitude that unit cannot hold. The scaling loop stopped at+ `value < 1024.0` while the result is rendered with one decimal, so a+ database of 1 MiB minus six bytes made `ai-memory status` report+ `1024.0 KiB on disk` rather than `1.0 MiB`; `reclaim-ledger-versions` could+ likewise print `1024.0 KiB -> 1.0 MiB` for a six-byte difference.+ ([#1562](https://github.com/akitaonrails/ai-memory/pull/1562))+- 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 survives