computer reinvention / 01 · trie · pre-alpha

Self-hosted context infrastructure
for coding agents.

The host is your git repo.

Agents start every session from zero: they re-derive your codebase by grep and guesswork, then record nothing for the next session. trie fixes both with a meaning + intent index committed next to your code. What every symbol does. Why it is that way. Fresh by sync. Honest by a commit gate. No services.

$ uv tool install git+https://github.com/computer-reinvention/trie
Read the docs
The whole loop: an agent investigates, fixes, and is gated until the discovered cause is recorded. Without trie, that knowledge evaporates. Six months later, another agent answers the why-question in two tool calls.

meaning + intent

One record, two halves. Both live in triefacts/, both are plain Markdown, both are gated at commit. Here is the same symbol on both sides:

meaning

What the symbol does.

One section per symbol, one triefact per source file. Regenerated when the source changes. Drifted prose blocks the commit.

triefacts/src/auth/middleware.md
source: src/auth/middleware.py

## `require_auth(handler) -> handler`

Wraps a route handler with a session check.
Requests with a missing or expired token are
rejected with 401 before the handler runs.

Called by: routes/admin · routes/api
intent

Why it is that way.

One note per changed symbol, recorded at edit time. A missing note blocks the commit. Archived per commit as a digest.

triefacts/triediffs/20260725T1149Z-….md
## Expired sessions must fail closed
   2026-07-25 · commit fade5436

~ src/auth/middleware:require_auth
  "expired tokens must 401, not 500 (see #241)"

~ tests/test_auth:test_expired_token_401
  "pins the fail-closed contract"

trie read src/auth/middleware:require_auth answers what. Add --history and it answers why: every note ever recorded against the symbol, in commit order.

The loop.

Each session writes the context the next session reads. Enforced, not hoped for.

  1. 1

    The agent edits source.

    Normal tools. trie never generates or edits code.

  2. 2

    The agent records intent. One note per changed symbol.

    $ trie patch create src/auth:require_auth \
        -n "expired tokens must 401, not 500 (see #241)"
  3. 3

    The gate blocks dishonest commits.

    git commit
      └─ trie gate
          ├─ verify   prose ↔ source, both directions   offline
          ├─ intent   every changed symbol has a note   offline
          └─ diff --write   the commit's digest, staged with it
  4. 4

    The digest ships with the commit.

    Same push, same PR, same merge. One file per commit in triefacts/triediffs/.

  5. 5

    Sync regenerates exactly what drifted.

    An end-of-turn hook runs it automatically. The graph the next query hits reflects the edit that just happened.

$ trie read src/auth:require_auth --history

Current prose plus every intent note ever recorded against the symbol, in commit order. Why the code is the way it is, answered from the repo.

What the agent sees.

trie setup overrides the agent's grep and read and adds the graph tools. A dozen speculative file reads become two or three round-trips of prose.

grep

Searches symbols, not bytes. Hits carry qname, signature, one-liner, and inbound count. Relevance is decided in the result row, not by opening files.

read

One call returns a symbol's prose plus one-liners for every caller and callee. --history appends the intent trail.

trace

Blast radius before a change. Call paths between two symbols. Structural questions, answered structurally.

trie is built with itself: every commit in its repository passes the gate it ships, and its triefacts/ tree is generated and enforced by its own loop.

No product. No service. Just files in git.

If you can clone the repo, you have all of it.

your repository
your-project/
├── src/                    ← your code, untouched
├── triefacts/              ← meaning (Markdown)
│   ├── src/
│   │   ├── auth/middleware.md
│   │   └── slugify.md
│   └── triediffs/          ← intent (one digest per commit)
│       └── 20260725T114949Z-fade5436….md
├── TRIE_DIFF.md            ← symlink to the latest digest
├── trie.toml               ← config, committed
└── .trie/                  ← local cache, gitignored,
                              delete anytime
  • Versioned like code. Branch, diff, blame, revert. A branch's indexes describe that branch.
  • Reviewed like code. Prose and digests appear in the PR diff, next to the code they explain.
  • Merged like code. Markdown merges with git's merge.
  • Gated like tests. verify and intent run offline: pre-commit hook or any CI runner, no API key.
  • Readable with nothing installed. GitHub renders it. cat renders it.

Install.

Python 3.11+, uv, ripgrep. An Anthropic key for prose generation; the gates run offline. Optionally, a language server per language (pyright, gopls, rust-analyzer, clangd, …) for type-aware reference precision — trie falls back to tree-sitter without one.

$ uv tool install git+https://github.com/computer-reinvention/trie

$ cd your-project
$ trie init                  # config + symbol graph + pre-commit hook
$ trie setup                 # wire the agent: tools + turn hook
$ trie plan                  # cost preview, free
$ trie sync --limit 10       # bootstrap; sample quality first

$ trie sync                  # day-to-day: only what drifted
$ git commit                 # the gate takes it from here