refactor(memory)!: rename <pai-memory*> context tags to <lifeos-memory*>#1594
Open
anikinsasha wants to merge 2 commits into
Open
refactor(memory)!: rename <pai-memory*> context tags to <lifeos-memory*>#1594anikinsasha wants to merge 2 commits into
anikinsasha wants to merge 2 commits into
Conversation
…nient parser for all readers The BEGIN/END ENTRIES marker handling had three compounding defects: 1. parseFile located END via first-indexOf over the whole body, so a stray END before BEGIN sent every write into the recovery branch forever. 2. serializeFile's self-heal appended a missing BEGIN at the END of the body (after any stray END), manufacturing a permanent END-before-BEGIN inversion, and re-emitted one fresh END per write: files grew a stack of duplicate END markers, +1 per curation write, never compacted. 3. Every read-side parser (LoadMemory hook, Pulse memory module, MemoryHealthCheck, MemoryRestore) used strict first-indexOf/lazy-regex logic that bails to zero entries on marker disorder - memory silently stopped loading into sessions while the writer kept curating, and the health check reported the corrupted file as healthy headroom (0/48). Files scaffolded by pre-7.0.0 templates (which shipped without the marker pair) are corrupted this way in the wild; install/copyMissing never re-templates an existing file, so they never recover on their own. Fix: - MemoryWriter parse is now line-based and uniformly lenient: markers count only as whole trimmed lines (an entry mentioning a marker can no longer truncate the block); entries = every valid-prefix line anywhere after frontmatter; invalid-prefix orphans stay in body verbatim; CRLF tolerated. - serialize always emits the canonical shape (frontmatter, body, BEGIN, entries, END, trailing newline): one write converges any corrupted file, repeated writes are byte-identical. - parseMemoryContent is exported and every reader imports it - reader and writer can never diverge again. - MemoryHealthCheck gains CHECK 7.5: marker structural sanity goes CRITICAL on corruption instead of false-green. - validateAndDedup rejects submitted entries containing marker substrings (counted as dropped_malformed). - The inline smoke test no longer touches the LIVE principal memory file (it previously wiped it down to its fixture entries on a populated install); it now runs against .memtest.md fixtures confined to the OS temp dir, and covers the corrupted shapes: END-before-BEGIN + END stack, marker-substring entries, CRLF, frontmatter-less, invalid-prefix orphans, idempotency.
BREAKING CHANGE: the memory context-block tags emitted into prompts are renamed from the pre-rename PAI era to match the LifeOS naming: <pai-memory> -> <lifeos-memory> <pai-memory-delta> -> <lifeos-memory-delta> <pai-memory-health> -> <lifeos-memory-health> All emitters (LoadMemory, MemoryDeltaSurface), the MemoryTurnStart dispatcher docs, FormatGate's detection, and the system prompt's MEMORY-line contract change in this one commit - these surfaces string-match each other and must never be renamed separately (a COUPLING comment now marks the FormatGate site). FormatGate keeps accepting the legacy pai- tag so sessions started before the rename still register their deltas. Anyone with downstream prompt customizations referencing the old tag names must update them. The pai-freshness-v1 frontmatter convention is data, not a tag, and is deliberately NOT renamed here. Stacked on fix/memory-marker-canonical-rebuild.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Breaking change — PAI→LifeOS naming leftover
The memory context-block tags injected into prompts still carry the pre-rename PAI naming. This renames them to match LifeOS:
<pai-memory>→<lifeos-memory><pai-memory-delta>→<lifeos-memory-delta><pai-memory-health>→<lifeos-memory-health>All coupled surfaces change in this one commit — the emitters (LoadMemory, MemoryDeltaSurface), the MemoryTurnStart dispatcher docs, FormatGate's detection, and the system prompt's 🧠 MEMORY-line contract. These string-match each other and must never be renamed separately; a COUPLING comment now marks the FormatGate site. FormatGate keeps accepting the legacy
pai-tag so sessions started before the rename still register their deltas.Anyone with downstream prompt customizations referencing the old tag names must update them — hence the breaking-change label. The
pai-freshness-v1frontmatter convention is a data-format value stamped across user files, not a tag, and is deliberately NOT renamed here.Stacked on #1593 (
fix/memory-marker-canonical-rebuild) — the diff shown includes that PR until it merges; this PR's own change is the tag rename commit only.