Code and mixed corpora
Knowledge Graph processing is not one universal extractor. The generic document path (parse to markdown, chunk, match ontology keywords, recognise entities, optional review) is the default module. Content types with usable structure get their own extractor module that builds the graph from that structure, so the review step often has nothing left to add.
The module contract
Section titled “The module contract”Every extractor module declares the same four things, so retrieval, citations, merges and the evaluation harness work the same way whichever module produced the graph:
| Contract element | What it declares |
|---|---|
| Selector | Which files the module claims, by format or content signature and namespace preferences. The document module is always the fallback |
| Steps fulfilled | Which processing steps the module delivers, and how. A module can extract entities and relationships during Index, with no model call and no separate step |
| Ontology pack | An optional versioned ontology the module publishes into the namespace when it first activates, in the same JSON format as a schema you write yourself |
| Cost profile | The per-step cost class (free or embed), so the cost estimator prices a mixed corpus correctly. A repository of source code forecasts near-zero cost, because that module builds its graph without a model |
Module selection is automatic by file signature. You can force a module at the namespace or folder level when you want a particular one.
Document module (default)
Section titled “Document module (default)”Any file without a more specific module runs the generic document path: parse to markdown, deterministic chunking, outline building, ontology keyword matching, entity recognition, and optional review against your published schema. JSON and JSONL files take this path too: a nested JSON object becomes a heading outline from its keys, and JSON may be UTF-8 or UTF-16 (including a byte-order mark). An xlsx workbook is parsed as a document, one heading plus a table per sheet.
Tabular module
Section titled “Tabular module”csv and tsv files get column-aware chunking. Headers feed the ontology miner as candidate entity types and attributes, and the file’s graph has a rows branch (one leaf per data row) and a columns branch (one leaf per header). In chat and MCP, the same file can be queried with SQL through Fontana Files (Read or query a file).
Code module
Section titled “Code module”Source code gets a dedicated module built on Tree-sitter grammars, covering Python, JavaScript and TypeScript, Go, Java and Rust:
- Selection: file extensions identify source files; binary assets are skipped.
- Parsing: per-language grammars extract definitions, imports, calls and class hierarchies.
- Graph mapping: a code ontology pack maps that syntax tree onto
package,module,class,functionandtypeentities, connected byimports,calls,definesandextendsrelationships, each with mention evidence pinned to a file and line span. - Outline: the structural overlay becomes your module, class and function hierarchy.
Because parsing is syntactic and deterministic, the code module builds its entity and relationship graph at index time, with no model spend.
Mixed corpora
Section titled “Mixed corpora”A single namespace can hold documents, spreadsheets and source code side by side. Fontana routes each file to its matching module independently, so a code repository with a docs/ folder gets typed code relationships from the code module and a governed document graph from the document module, both in the same graph with the same node and edge vocabulary, and both reachable through the same retrieval lanes.