Context as a Living System — The WRITE Path: Ingestion, Decay, Archive #84
xg-gh-25
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Context as a Living System — The WRITE Path
The thing nobody writes about
Every "AI memory" post is about retrieval. Embeddings, rerankers, hybrid scoring,
RAG. That's the READ path — and it's the easy half. The hard half is the WRITE
path: what earns a place in memory, what loses it, and what gets swept out.
A memory system with a great retriever and no decay discipline becomes a landfill
with a good search bar. Within weeks every query returns 40 "relevant" hits, 35 of
which are stale, and the signal drowns.
We run a self-evolving agent OS 24/7. Its memory has grown for months. Here's the
WRITE path that keeps it from rotting.
Three stages: Ingestion → Decay → Archive
1. Ingestion — confident-only, never speculative
The first gate is what gets written at all. Our rule: knowledge is extracted
only from confident, verified outcomes — never from a "this might be a pattern"
hunch. A correction that recurred 3× is a pattern; a one-off is noise. The
extraction hook is biased toward False > Stale > Imperfect: we'd rather drop a
real insight than admit a fabricated one, because a wrong entry in long-term memory
poisons every downstream decision that trusts it.
Each entry is typed (one of 7: principle / correction / decision / guideline /
pitfall / process / model) and carries inline metadata as an HTML comment:
No database. The markdown file is the store. The metadata travels with the text.
2. Decay — Darwinian, per-section, automatic
Entries age.
ref_countbumps when an entry is actually referenced;days_idlegrows when it isn't. The decay state machine:
The subtlety we learned the hard way: decay rate must be per-section, not
global. MEMORY.md churns fast (session-to-session context) — it ages at 45
days. Domain knowledge churns slow — 90 days. One global threshold either
keeps MEMORY bloated or prematurely archives stable knowledge. (commit
2ece119d)Decay is weighting, not deletion. A dormant entry still exists; it just sinks
in recall ranking and stops competing for the context-window budget.
3. Archive — shrink, with proof
At 180d idle an entry moves to a dated archive file. The active document shrinks;
history is never lost, just relocated. We gate this with an E2E shrink proof —
a test that drives a real entry through decay→archive and asserts the active doc
actually got smaller (commit
35c73555). "It should shrink" is a hypothesis;"the test proves it shrank" is the contract. (We've been burned enough times by
recovery paths that looked wired but never executed.)
The plot twist: we deleted the vector database
Here's the part that'll be controversial. Last week we tore the vector embedding
leg out of recall entirely (commit
6540970e). Titan embeddings, sqlite-vec, the0.6·vector + 0.4·BM25hybrid — all gone. Recall is now pure keyword/FTS5 overmarkdown.
Why? Three reasons, all measured, not guessed:
latency was fine (~0.4s), but it added a Bedrock network dependency on the
cold-start critical path and a write-side cost (every entry embedded) — for a
corpus that fits in the context window.
tokens, full injection beats RAG. You don't retrieve-then-reason; you just
reason over everything. The vector index was solving a scale problem we don't
have.
and nobody noticed — the code comments still claimed
allow_embed=Trueand"both legs" long after they were inert (we killed that lying comment in
50024c79). Legibility decayed faster than anyone read it. Simpler is morehonest.
This is the WRITE-path lesson stated as a principle: every mechanism you add to
the write path is a mechanism you must keep honest. A vector index you're not
load-bearing on is not a feature — it's a second source of truth waiting to drift.
What this composes into
The WRITE path is what makes the READ path stay sharp over time. Retrieval quality
is a lagging indicator of write discipline. If recall feels noisy, don't tune the
retriever — audit what you let in and what you refuse to let go.
Takeaways
the one you have may be quietly lying to you.
All reactions