feat(memory): make the ledger the default store — finish the M2 migration#106
Merged
Merged
Conversation
…tion Flips FORGE_LEDGER_ONLY on by default: the legacy files (.forge/lessons/*.md, recall/brain fact files) are no longer written, and every read materializes from the PCM ledger. The ledger has been the convergent dual-write store since P1, so existing memory is already present; `forge ledger import` back-fills pre-ledger history. FORGE_LEDGER_ONLY=0 is a one-release escape hatch. Closed the ledger-only read/write gaps the flip exposed (the real reason it couldn't ship before): - brain.remember (and the forge_remember MCP tool) now shadow the fact into the repo ledger, so a fact is not lost when no file is written. - cortex_features.featuresForEdit and cortex_hook_main's distill lesson lookup now read the merged ledger view instead of the empty legacy file store. (cortex.js's injection/summary/distillation read paths were already ledger-aware.) Tests: the legacy-store suites are pinned to the FORGE_LEDGER_ONLY=0 escape hatch (the file path they exercise); ledger_only.test.js gains a default-mode end-to-end test of the full create->confirm->promote learning loop plus explicit default-vs-escape-hatch assertions. docs/GUIDE.md updated for the new default. Verified: full suite 1072 pass / 0 fail / 2 skip, biome 0 errors, tsc clean, `docs check` green, and a live `forge remember` writes no legacy file and persists to the ledger. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01C7htTiesXKLvAUtv6ET2jz
…rktree-issues-il3uk9 # Conflicts: # CHANGELOG.md
CodeWithJuber
marked this pull request as ready for review
July 20, 2026 17:39
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.
What & why
Completes M2 — the last open finding from the deep review. The PCM ledger becomes the
default and only memory store; the legacy file stores are retired.
FORGE_LEDGER_ONLYnow defaults on..forge/lessons/*.mdand recall/brain fact files areno longer written, and every read (cortex injection/summary, routing,
recall/brain, thepre-edit advisory, doctor) materializes from the ledger. The ledger has been the convergent
dual-write store since P1, so existing memory is already present;
forge ledger importback-fills any pre-ledger history.
FORGE_LEDGER_ONLY=0is a one-release escape hatch thatrestores the legacy file store.
The real work: closing the ledger-only gaps
Piloting this flip earlier surfaced real gaps (which is why the earlier PR shipped only the
safe
reconcileFactsfix). This PR fixes them:brain.remember(and theforge_rememberMCP tool) now shadow the fact into the repoledger — previously the fact was simply lost when no file was written.
cortex_features.featuresForEditandcortex_hook_main's distill lesson lookupnow read the merged ledger view instead of the empty legacy file store.
cortex.js's injection / summary / distillation read paths were already ledger-aware; nochange needed there.
reconcileFactswas already guarded (shipped in the prior PR).Tests
FORGE_LEDGER_ONLY=0escape hatch — theylegitimately exercise the file path, which still works.
ledger_only.test.jsgains a default-mode end-to-end test of the fullcreate → confirm → promote learning loop through the ledger, plus explicit
default-vs-escape-hatch assertions and a no-data-loss reconcile test.
Scope note
The escape hatch is deliberately retained this release, so the legacy write code stays
(it backs the hatch). Deleting the legacy store code entirely is a follow-up for the
release after the escape hatch is removed.
Checklist
npm testpasses (1072 pass / 0 fail / 2 gated skips)npm run checkpasses (Biome — 0 errors)CHANGELOG.mdupdated under## [Unreleased]docs/GUIDE.md— the new default + escape hatch)Risk & rollback
means no data is orphaned, the destructive reconcile is already guarded, all read paths
are ledger-aware, and
FORGE_LEDGER_ONLY=0instantly restores prior behavior.FORGE_LEDGER_ONLY=0.Extra checks
npm run typecheckpassesnode src/cli.js docs checkgreenforge rememberwrites no legacy file and persists to the ledger🤖 Generated with Claude Code
https://claude.ai/code/session_01C7htTiesXKLvAUtv6ET2jz
Generated by Claude Code