Context as Topology: Why Your Agent's Memory Forgets, and How Structure Escapes It

@elpresidank
INGLÊShá 1 mês · 02/06/2026
3.8M
669
45
19
126

TL;DR

Analyzing the 'Price of Meaning' theorem, this post argues that embedding-based RAG is fundamentally flawed. It introduces 'Context as Topology,' leveraging Effect Schema to create deterministic, hallucination-resistant AI agents.

Most AI agent memory is built on embeddings. And there's now a proof that this entire class of system is going to forget what you stored in it — and confidently make up things you never stored at all.

"The Price of Meaning" (arXiv:2603.27116) formalizes the class: any memory whose retrieval score is a function of proximity in an embedding space. Vector databases, RAG pipelines, GraphRAG over embedding similarity — all inside it. And it proves the uncomfortable part: the very geometry that lets these systems generalize is what forces them to forget (retention decays toward zero as the store grows) and fabricate (false recall you can't tune away without also throwing out true results). Scaling up doesn't fix it. It makes it worse — precisely when you need the memory most.

I don't think the answer is a better embedding. I think it's to stop storing meaning as geometry.

A codebase has two kinds of meaning

There's the meaning you get from proximity — "what is this near?" — which is what an embedding captures, and what the theorem dooms.

And there's a second kind: where a symbol sits. In the AST. In the type lattice. In the module graph. In the schema. This meaning is structural, not geometric. It's exact and discrete, and you recover it by navigating — following an edge, resolving a type, reading a path — not by nearest-neighbor search. There's no crowding, no decay, no false recall, because adjacency in a graph isn't approximate. It either connects or it doesn't.

The paper's own escape routes point straight here: exact records, symbolic verifiers, and structures with no continuous semantic space to bottleneck. Source code is the rare corpus where all of that exact structure is just lying around, free for the taking. The repo I build in even keeps this as doctrine — a section of its architecture standard is literally titled "Topology Is Compressed Context."

The keystone: one schema, three jobs

The piece that makes this practical is @EffectTS_ Schema, and specifically its annotation model.

Normally, metadata about a thing gets duplicated into every instance of that thing. Schema annotations let you do the opposite: store the meaning once, on the schema itself, and recover it on demand. The metadata becomes a property of the structure, not a payload riding along with the data.

(The category-theory crowd has a precise name for this shape — it's a fibration — but you don't need the machinery to use the fact: recovery is finite, exact, keyed lookup. No competitor mass, because there are no competitors — just the one entry the key names. Zero false recall, by construction.)

That one move lets a single schema serve three roles at once, with zero possibility of drift between them:

  • It's the index you retrieve from — the structure you navigate to find the right thing.
  • It's the mold you hand an agent — the exact shape it has to fill.
  • It's the contract you validate output against — the same schema that shaped the request decodes the response.

One source of truth. Three jobs. They can't fall out of sync because they are the same object.

This isn't hypothetical — it's the load-bearing trick in a JSDoc/TSDoc engine I'm building. A tag definition is built by JSDocTagDefinition.make(...), which validates the full metadata, strips each occurrence down to a lean { _tag, value }, and lifts the constant meaning onto the schema as an annotation. A display map reads it straight back off the schema. The 113 tag shapes are one discriminated union you index by key, not search. And the same construction runs one level up: the repo's own architectural ontology — an element's Effect analog, its layer, its purity — is stored the same way.

Steering an agent by shrinking what it can invent

Once meaning is exact structure, you stop prompting an agent and start constraining it. Open-ended generation collapses into bounded fill-in-the-blanks:

  • Context is projected from structure — the 2-hop neighborhood around the target symbol, the things it's actually connected to — not retrieved by "what embeds near this."
  • Output shape is fixed by the schema — structurally invalid output isn't unlikely, it's unrepresentable.
  • Known facts are pre-filled as anchors — parameter names, types, signatures are passed as given, not as things to generate. The agent can't hallucinate structure because structure was never on the table. (This is the lesson the deterministic-grounding research keeps landing on — FORGE corrects structural claims at near-100% precision with plain AST analysis, arXiv:2601.19106. Structural facts should never be left to a probabilistic generator.)
  • Output is decoded and checked against ground truth before it commits — malformed output rejected for free; claims that can be verified against the graph are; the rest is flagged.

The honest version matters: the harness is deterministic, not the model. You don't make the model deterministic. You shrink the surface it's allowed to be creative on — exact context in, exact shape out, deterministic anchors locked — until the only thing left for it to author is the part that genuinely requires understanding. The smallest possible creative residual, fenced behind a checker.

Two honesty notes, before anyone clones the repo expecting magic. The representation layer — schema-as-fibration — is real, and you can read it at the links above. The reasoning amplifier and the closed verification loop are where I'm taking this, not what's running today. The pieces are real; the system is still mostly an argument. I'm sharing the idea because I'm convinced it's right, not because it's finished.

Where this goes

I'm calling the larger pattern Context as Topology: a codebase whose deterministic structure is rich enough to store meaning, project it as minimal context, constrain generation by construction, and verify generation by checking it against the structure itself — a loop where every edge is either exact or flagged for review.

Credit where it's due

None of this clicked for me until I sat with @GiulioCanti's work on Schema. "Meaning recoverable from the base instead of duplicated in the data" is the entire unlock — and it's the through-line of everything he's built. fp-ts → io-ts → Effect Schema v3 → v4. This whole idea is standing on giant shoulders.

If you're building agent tooling on Effect, or you've watched your RAG or graph memory quietly rot as it grew, I'd love to compare notes. The code's open: github.com/kriegcloud/beep-effect

Sources

Guardar com um clique

Faça leitura aprofundada de artigos virais com IA no YouMind

Guarde a fonte, faça perguntas específicas, resuma o argumento e transforme um artigo viral em notas reutilizáveis num único espaço de trabalho com IA.

Explorar o YouMind
Para criadores

Transforme o seu Markdown num artigo 𝕏 impecável

Quando publica os seus próprios textos longos, formatar imagens, tabelas e blocos de código para o 𝕏 é uma dor de cabeça. O YouMind transforma um rascunho completo em Markdown num artigo 𝕏 impecável e pronto a publicar.

Experimente Markdown para 𝕏

Mais padrões para decifrar

Artigos virais recentes

Explorar mais artigos virais