Indexion: The Codebase Map That Refuses to Drift

How a MoonBit tool uses KGF, semantic grep, and an embedded wiki to turn source code into a living system of search, documentation, and repair.

8 min read • View on GitHub • More from trkbt10

A wide hand-drawn map of a codebase spread across a table, with separate regions for source files, documentation, search, and planning. A thin survey line connects a README island to a code canyon, where a small flag marks a mismatch. It explains that indexion treats a repository as one connected terrain rather than separate tools.
Indexion’s core idea is not just search. It is a map of the repo that can notice when the map and the territory diverge.
Key Takeaways

Indexion looks like a search tool until you notice what it is really optimizing for. It wants the repository to stay legible as it changes, which means code, docs, and AI context all need to be compared against the same internal map. That makes it less of a finder and more of a truth-maintenance layer for a fast-moving codebase.

The Repo as a Living Map

The simplest way to understand indexion is to stop thinking about search as an end in itself. Here, code files, wiki pages, semantic matches, and reconcile plans all live inside one shared model of the repo. The point is not to answer, “Where is this symbol?” The point is to answer, “What does the repository believe about itself, and is that belief still true?”

That is why the project feels unusually opinionated. It assumes a repository is not just a pile of files. It is a system with claims, and those claims can drift.

Why KGF Matters

KGF is the abstraction that makes the whole thing work across languages. Instead of building a bespoke parser strategy for every syntax, indexion normalizes source into shared structural features. The result is a common vocabulary for functions, declarations, comments, wrappers, and other code shapes that matter to search and documentation checks.

indexion grep "pub fn *"
indexion semantic undocumented
indexion semantic proxy
DimensionTraditional grepIndexion with KGF
What it matchesStrings and regex patternsStructural tokens and code features
Cross-language useWeak unless syntax happens to alignStrong because language-specific surface forms normalize into shared kinds
Useful for docsNot reallyYes, because code shape and comment coverage can be queried together
Main failure modeToo literalDepends on the quality of the KGF mapping, not just the query

That last row matters. Indexion is not magic. It trades the old problem of brittle text matching for a new problem: maintaining a good structural model. But once that model exists, the search surface gets much sharper.

A close-up mechanism translates different language snippets into shared structural blocks. On the left, several distinct code fragments are broken into parts. In the center, a stamping press normalizes them into the same token vocabulary. On the right, one query matches across all of them and marks an undocumented public function. It explains how KGF turns polyglot source into one searchable structure.
KGF lets indexion search for structure instead of raw syntax. That is what makes one query span multiple languages.

Searching for Structure, Not Strings

The project’s grep and semantic layers are the practical payoff of KGF. Standard grep asks whether a pattern appears in text. Indexion asks whether a pattern appears in the shape of the code. That distinction is what lets it detect public declarations without comments, wrapper functions that merely delegate, and other repo smells that a text search would miss or bury in noise.

# Conceptually:
TokenMatcher::Kind("pub")
TokenMatcher::Text("fn")
TokenMatcher::Ellipsis
SemanticQuery::Undocumented
SemanticQuery::Proxy

This is also where the tool starts to feel useful to an AI assistant, not just a human. A language model can hallucinate structure if it only sees raw text. A structural index gives it a better frame of reference: symbols, relationships, and the difference between a definition and a dead wrapper.

The Embedded Wiki Is the Other Half of the System

The embedded wiki is not an appendix. It is part of the corpus. By keeping documentation inside .indexion/wiki and indexing it alongside source code, the project puts prose and implementation under the same roof. That is the trick that makes drift visible. A README claim can be compared against actual symbols, not just against memory.

This matters because many repos fail in a boring way. The code moves, the docs lag behind, and the mismatch becomes normalized. Indexion is designed to make that mismatch uncomfortable.

Plan Reconcile: The Part That Fights Drift

Plan reconcile is the operational climax. It turns a structural mismatch into an action list. A changed function signature, a stale README reference, or a missing explanation in the wiki becomes a visible discrepancy instead of a quiet source of confusion.

The reconcile loop is the real product idea. A code change flows into the map, the map checks the docs, and the mismatch becomes a task.

StageWhat happensWhat the user sees
Code changeA file or symbol shiftsA new version enters the index
Map updateKGF and corpus layers rebuild relationshipsSearch and semantic views refresh
Drift checkDocs are compared with source structureWarnings appear where claims no longer match
ReconcileSuggested repairs are producedREADME or wiki updates become explicit work

The important shift is psychological as much as technical. Indexion does not wait for a human to notice that the docs are stale. It turns staleness into a first-class output.

Why MoonBit Is Not Just a Footnote

MoonBit is easy to treat as a novelty, but here it reads like a strategic choice. A repo exploration engine needs fast parsing, modular code, and a disciplined build story. MoonBit gives the project a language that seems unusually aligned with those needs, which helps explain why the codebase can stay so structured even while it spans search, similarity, wiki indexing, and planning.

That said, the language is a means, not the message. The message is the product shape: a tool that wants to keep meaning attached to source as the repository evolves.

What Indexion Is Really Optimizing For

Indexion is built for large, multilingual repos where human memory is weak and documentation ages fast. It is also built for a world where AI assistants need more than raw text to stay honest. The project’s real ambition is to make the repo itself a reliable interlocutor. Code changes. The map updates. The docs either keep up or get called out.

That is why the name feels right. It is not just indexing. It is trying to keep the index worthy of trust.