Repository navigation
Description
Version
LifeOS 8.761.0 · attestation: 5 system file(s) differ from danielmiessler/LifeOS@v8.761.0:
- hooks/SatisfactionCapture.hook.ts
- LIFEOS/TOOLS/MemoryWriter.ts
- LIFEOS/TOOLS/models.ts
- LIFEOS/TOOLS/model-pricing.json
- LIFEOS/PULSE/VoiceServer/voice.ts
What is broken
Once the Cortex ledger holds any row, a fold-owned memory file that has no event of its own can never be anchored. CortexLedger.ts verify reports it no-events and MemoryHealthCheck turns CRITICAL, and the remedy that health line prints (CortexLedger.ts adopt) answers "matches the ledger, nothing to adopt" and records nothing, so the CRITICAL line repeats on every turn. genesis cannot help either: it refuses once the ledger has rows. This is easy to reach after an upgrade that introduces the ledger: the first curation write lands in PRINCIPAL_MEMORY.md, and DA_MEMORY.md, untouched since, stays unanchored. The memory data itself is intact; the two tools disagree about what a missing head means.
Where (file:line)
LIFEOS/TOOLS/MemoryWriter.ts:786
Repro on a clean tree
1. In an isolated root (CLAUDE_CONFIG_DIR, CORTEX_LEDGER_ROOT, LIFEOS_CONFIG_DIR pointing at a temp dir with LIFEOS/USER symlinked to config/USER), write a synthetic PRINCIPAL_MEMORY.md and DA_MEMORY.md (one RULE entry each).
2. Append one `memory/set` event for PRINCIPAL_MEMORY.md only (the ledger now has rows; DA_MEMORY.md has none).
3. Call `adoptLive(<root>/LIFEOS/USER/DIGITAL_ASSISTANT/DA_MEMORY.md)`, then `verifyAll()`.
Expected: adopt records DA_MEMORY.md (lost 0) and verify reads ok.
Actual: adopt returns adopted=false, verify stays critical with DA_MEMORY.md `no-events`.
The probe script that does this exits 1 on v8.761.0 and 0 with the fix. It touches no real memory files.
probe.ts (run as: CODE=<a LifeOS checkout> bun probe.ts; exit 1 = bug, 0 = fixed):
// Negative control: in a ledger that already has rows, a fold-owned memory file with no event of its own.
// adopt must anchor it and verify must then read ok. Synthetic memory files only; CODE picks the code root.
import { mkdtempSync, mkdirSync, writeFileSync, symlinkSync } from "node:fs";
import { join } from "node:path";
import { tmpdir } from "node:os";
const code = process.env.CODE!;
const base = mkdtempSync(join(tmpdir(), "ledger-probe-"));
const root = join(base, "claude"), cfg = join(base, "config");
mkdirSync(join(root, "LIFEOS"), { recursive: true }); mkdirSync(join(cfg, "USER"), { recursive: true });
symlinkSync(join(cfg, "USER"), join(root, "LIFEOS", "USER"));
process.env.CLAUDE_CONFIG_DIR = root; process.env.CORTEX_LEDGER_ROOT = root; process.env.LIFEOS_CONFIG_DIR = cfg;
const P = "LIFEOS/USER/PRINCIPAL/PRINCIPAL_MEMORY.md", D = "LIFEOS/USER/DIGITAL_ASSISTANT/DA_MEMORY.md";
const file = (rule: string) => `---\nschema_version: 1\ncap_entries: 48\ncap_chars_per_entry: 256\n---\n\n# Memory\n\n<!-- BEGIN ENTRIES -->\nRULE: ${rule} ~explicit\n<!-- END ENTRIES -->\n`;
mkdirSync(join(root, P, ".."), { recursive: true }); writeFileSync(join(root, P), file("prefers short answers"));
mkdirSync(join(root, D, ".."), { recursive: true }); writeFileSync(join(root, D), file("asks before deleting files"));
const core = await import(join(code, "LIFEOS/TOOLS/lib/CortexLedgerCore.ts"));
const seed = core.appendEvent({ kind: "memory/set", ts: new Date().toISOString(), file: P, updated_by: "probe", content: file("prefers short answers") });
if (!seed.ok) { console.log("seed failed: " + seed.message); process.exit(2); }
const { adoptLive } = await import(join(code, "LIFEOS/TOOLS/MemoryWriter.ts"));
const { verifyAll } = await import(join(code, "LIFEOS/TOOLS/CortexLedger.ts"));
const a: any = adoptLive(join(root, D), { updatedBy: "probe" });
const v = verifyAll();
const da = v.files.find((f: any) => f.file === D)?.status;
console.log(`adopt: ok=${a.ok} adopted=${a.adopted} verify: ${v.status} DA_MEMORY: ${da}`);
process.exit(v.status === "ok" && da === "ok" ? 0 : 1);Negative control
Probe: CODE=/tmp/lifeos-ledger-probe/unpatched bun /tmp/lifeos-ledger-probe/probe.ts · exit 1 · captured 2026-11-13T22:50:17.319Z
Red looks like: adopted=false verify: critical DA_MEMORY: no-events
adopt: ok=true adopted=false verify: critical DA_MEMORY: no-events
Suggested fix
In inspectDrift, a missing head is "nothing to drift from" only before genesis (foldState().lastSeq === 0). When the ledger already has rows, a missing head is drift from an empty head: folded = [], so every live entry is gained, lost is always 0, and autoAdoptable accepts it without --force. The fold already handles a memory/adopt event for a file it has not seen. Empty-ledger behaviour is unchanged (checked: adopt still returns adopted=false and verify stays unverified).
diff --git a/LIFEOS/TOOLS/MemoryWriter.ts b/LIFEOS/TOOLS/MemoryWriter.ts
index 52c79f5..8b7f208 100755
--- a/LIFEOS/TOOLS/MemoryWriter.ts
+++ b/LIFEOS/TOOLS/MemoryWriter.ts
@@ -779,14 +779,19 @@ export interface LedgerDrift {
gitHead: string | null;
}
-/** Compare a file's live entries with the ledger head. Null when the ledger has no head for it or they agree. */
+/**
+ * Compare a file's live entries with the ledger head. Null before genesis (an empty ledger) or
+ * when they agree. A file with no event in a ledger that already has rows is drift from an empty
+ * head: verify reports it `no-events` (critical), and genesis refuses once rows exist, so adopt
+ * is the only way to anchor it. Nothing can be lost (the head holds no entries).
+ */
function inspectDrift(rel: string, content: string, live: string[]): LedgerDrift | null {
const ledger = foldState();
const head = ledger.files.get(rel);
- if (head === undefined) return null; // pre-genesis: nothing to drift from
+ if (head === undefined && ledger.lastSeq === 0) return null; // pre-genesis: nothing to drift from
// Same render as CortexLedger verify: redact tombstones filter the head's entries.
- const folded = parseMemoryContent(head).entries.filter((e) => !ledger.redacted.has(sha256(e)));
- if (entriesHash(folded) === entriesHash(live)) return null;
+ const folded = head === undefined ? [] : parseMemoryContent(head).entries.filter((e) => !ledger.redacted.has(sha256(e)));
+ if (head !== undefined && entriesHash(folded) === entriesHash(live)) return null;
const git = gitHeadContent(pathResolve(CLAUDE_ROOT, rel));
const headTs = ledgerHeadTs(rel);
const committed = git !== nullEnvironment
- OS: macOS 15.7.9 (arm64)
- Harness: claude-code
- bun: 1.4.4 · git: 2.50.1
- Doctor broken: none
Activity