Skip to main content

Why LeanCTX Became My Single Source of Truth

Several partial memories competing for authority is not a memory system, and the cost arrives as friction rather than failure.

Lovell Felix 7 min read

I did not decide to make LeanCTX the single source of truth because I wanted one more architecture acronym in my notes. I did it because I had reached the point where my agent tooling could remember things in three different places, and none of those places had a clear claim on what counted as current.

That sounds manageable when written as a list. In practice it was a quiet tax on almost every multi-step task.

One surface held runtime session state and project knowledge. Another held handoff artifacts on disk. A third held human-readable wiki notes and playbooks under ~/llm-wiki. Each one had a reasonable purpose on its own. Together they created the sort of ambiguity that wastes time in small increments. An agent could finish a task and leave a useful handoff in one place, while a different part of the stack resumed later from another. Documentation would describe the archive as though it were the active runtime layer. A tracked config would accidentally grow around a machine-local assumption because that path happened to exist on the machine where I was testing.

None of those failures were dramatic. That was part of the problem. They showed up as friction instead of outages.

By early June, the pattern was obvious enough that I wrote the decision down as an ADR. The short version was simple: LeanCTX would become the canonical layer for runtime context, reusable project facts, workflow state, and the compatibility facades already exposed through Pi. If an agent needed to know what was true right now, or needed to persist something so another session could pick it up later, LeanCTX would be the first place to read and the first place to write.

The best argument for that decision wasn't elegance; it was operational clarity.

I had already been moving toward a LeanCTX-backed runtime. The problem was that the surrounding documentation and habits had not caught up. That left me with a system that behaved one way and described itself another way. Those mismatches matter more in agent tooling than they do in ordinary application code because the whole point of the system is to preserve context across time. If you cannot answer where that context lives, you do not really have a memory system. You have several partial memories competing for authority.

The ADR tried to remove that ambiguity by mapping each need to one primary surface.

Live session context belonged to LeanCTX through ctx_session and ctx_knowledge. Reusable project facts also belonged to LeanCTX through ctx_knowledge. Task tracking stayed visible through the workflow_tasks facade because that matched the Pi user experience, but the backend authority moved underneath to LeanCTX. Durable workflows and evidence landed on the LeanCTX workflow layer as well. Human-readable archives stayed in ~/llm-wiki, and raw handoff artifacts stayed available on disk as a fallback reader when something had not yet been indexed.

The intent was straightforward. I wanted a clean answer to a very practical question: when one agent finishes work and another agent resumes it 6 hours later, where should they both look first?

Before that change, the honest answer was, "it depends." Sometimes the right answer was a session-memory surface. Sometimes it was a file under ~/.agents/memory/. Sometimes it was a wiki page that a human would understand more easily than the runtime would. Every "it depends" carried a cost. You either encoded that ambiguity into prompts and docs, or you paid it back later in repeated discovery.

LeanCTX solved the most important part of that by letting the runtime treat context as data instead of prose first. An agent did not need to scan a handoff note and infer what was authoritative. It could ask the context system for project facts, active workflow state, previous findings, or user preferences through one consistent layer. That mattered across harnesses too. Pi, Claude-oriented workflows, and OpenCode all had slightly different UX surfaces, but they benefited from the same backend simplification. I did not want each harness to grow its own local theology about where memory lived.

Portability was the other half of the decision.

I keep most of this setup in dotfiles, which means every time I let a tracked config lean too hard on one machine's absolute paths or one harness's local conventions, I am borrowing trouble from the next machine. The ADR explicitly called that out. Tracked repo config should prefer lean-ctx on PATH. Machine-local paths should live in local overlays or generated runtime config, not in the base files that claim to be portable. Validation should include regressions for path portability and documentation hierarchy.

Once a personal setup spans multiple harnesses and multiple hosts, that level of strictness stops feeling optional. The whole point of version-controlling this kind of environment is being able to move it, inspect it, and recover it without remembering undocumented assumptions.

The positive effects were immediate, even though the underlying tools had already been partially in place.

Resume and handoff behavior became easier to reason about because tasks, workflows, and project facts shared one runtime backend instead of being spread across adjacent systems with overlapping responsibilities. The portable LeanCTX skill could become the actual runtime guide, while the shorter harness docs focused on setup and usage instead of restating the whole architecture in slightly different words.

Just as important, the decision made certain kinds of drift easier to detect. If a smoke check caught docs describing the wiki or handoff artifacts as the primary runtime store, that was clearly wrong under the new model. If a tracked config introduced a machine-specific path where a portable reference should have been enough, that was also clearly wrong. A system with one runtime center gives you sharper failure modes, and sharp failure modes are usually easier to fix than vague ones.

I accepted a few tradeoffs to get that clarity.

The first was that the archive layers did not disappear. ~/llm-wiki still had value because human-readable notes, decisions, and playbooks are useful in a way that indexed runtime context is not. LeanCTX becoming the source of truth for runtime behavior did not erase the need for those other surfaces. It meant I had to be more precise about their role.

The second tradeoff was ongoing maintenance. Once you say one system is authoritative, you take on the work of keeping the docs, validations, and habits aligned with that statement as the system evolves. An architecture decision does not stay true by force of declaration. In this case, that meant regression checks for wording, portability reviews for tracked config, and discipline about keeping harness-local guidance thin instead of letting each runtime restate the whole memory model in its own style.

The third tradeoff was more subtle. A single source of truth is a useful design pressure, but it can also become a misleading slogan if you use it too literally. I ended up amending the ADR on 2026-06-28 because the ecosystem around it kept proving that memory was better understood as a layered model. LeanCTX and session-memory remained the primary runtime layers on the hub. ~/llm-wiki remained the canonical human-readable archive. ~/.agents/memory/ remained archival provenance. The amendment did not mean the original decision was a mistake. It meant the phrase had done its cleanup work and then started to overstate reality.

At the time of the ADR, I needed to correct a real anti-pattern: too many partially authoritative places for runtime context to live. Calling LeanCTX the single source of truth was the clearest way to force a decision and stop the drift. A few weeks later, after the boundaries were cleaner, it made more sense to say something more precise: LeanCTX is the primary runtime authority, while the wiki is the durable human-readable archive.

I still think the original move was the right one.

Without it, I would have kept paying the small but constant cost of context ambiguity. Agents would keep resuming from whichever artifact happened to be easiest to reach. Docs would keep blurring runtime state with archival notes. Portability would keep losing ground to convenience. Those are the kinds of issues that make an agent stack feel clever in demos and messy in daily use.

What I wanted instead was a system where the answer to "where do I look first" was boring. Boring is good here. Boring means a resumed session spends less time reconstructing state. Boring means a portability check can fail for a concrete reason instead of a vibe.

The later amendment changed the wording, but not the lesson. When context is scattered across files that all look important, the runtime becomes harder to trust. Picking a primary authority was how I got that trust back.

About the author

Lovell Felix

Infrastructure and reliability engineer working on Linux platforms, configuration delivery, and deployment safety at fleet scale.

More notes