Skip to content

refactor(memory)!: rename <pai-memory*> context tags to <lifeos-memory*>#1594

Open
anikinsasha wants to merge 2 commits into
danielmiessler:mainfrom
anikinsasha:refactor/lifeos-memory-tag-rename
Open

refactor(memory)!: rename <pai-memory*> context tags to <lifeos-memory*>#1594
anikinsasha wants to merge 2 commits into
danielmiessler:mainfrom
anikinsasha:refactor/lifeos-memory-tag-rename

Conversation

@anikinsasha

Copy link
Copy Markdown

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-v1 frontmatter 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.

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant