Skip to content

kb knowledge base

throndir edited this page Nov 14, 2026 · 1 revision

Repository knowledge base

Status: Implemented Last Updated: 2026-11-14 Audience: Developers and coding agents Last verified: 2026-11-14 against 86e5f8c37 Code: .github/mcp.json, scripts/kb/check_kb.py, scripts/kb/test_check_kb.py

The knowledge base (KB) is the Markdown documentation in docs/. It describes the current code. The top-level map gives the main areas. The decision map names the rule owners. The glossary gives the names to use.

Search before reading source

Use the local repo-kb MCP server to find a topic. Call kb_search, then open its cited sections with kb_read_section. Read the page's **Code:** line to find the source. Read only the source that the task needs. Use an exact-name search when the page names a symbol but not its file.

If a page is missing or wrong, inspect the relevant code and correct the page in the same pull request. Search results are a route to evidence, not proof that a claim is true.

.github/mcp.json starts the existing tool with npx. It needs Node.js 20 or later and Git. It does not need a repository package install. The first run downloads the tool and the local embedding model. The index stays outside the checkout. The tool selects the index from the repository's Git remote. Searches combine keywords with local embeddings when the embeddings are ready. All indexing and search run on this computer.

The default file selection includes docs/**/*.md, the root agent and contributor guides, and the checked-in assistant instructions. Martlet uses these paths, so it does not need a .repo-kb.json override. scripts/MartletDev.ps1 supplies developer helper functions; it is not an installer and has no install option.

Page contract

Each authored KB page starts with an H1 title and these fields:

# Page title

**Status:** Implemented
**Last Updated:** YYYY-MM-DD
**Audience:** Developers and coding agents
**Last verified:** YYYY-MM-DD against <short sha>
**Code:** `src/Area/Owner.cs`, `scripts/Some-Command.ps1`

Use repository-relative paths in Code. Name the main files or source folders that implement the page. A folder covers its descendants. Do not use wildcards, absolute paths, symbols, or missing paths. Use forward slashes in Markdown paths so links work on all platforms. Use Windows paths in PowerShell commands.

Status Meaning
Implemented The described behavior exists in the named code.
Partial Some described behavior exists. Put unbuilt work in a Planned section.
Planned The page describes unbuilt work, not current behavior.
Superseded Another linked page replaces this page.

Put intended behavior only under a heading that contains Planned. Put past evidence and provenance under clearly named history sections. Do not describe a past test or a fixture as current product qualification.

Last Updated is the date of a content change. Last verified records the code revision inspected for the page's claims. Do not update verification fields without checking the code. A source-map check alone does not verify behavior. Documentation-only indexes name the revision used to check their links. Pages that describe built code must have a Code line.

Folder indexes and generated pages

Each documentation folder has a README.md index. List each immediate page and each immediate subfolder. Give one line that states the question each page answers. Keep the root map's code areas and folder links current. Do not require a page to list itself.

Scripts regenerate generated pages. Do not edit their output by hand. Each generated page names its generator. Generated image folders and wiki navigation fragments are not authored KB pages. The current wiki's Markdown source lives in docs/wiki/. scripts/Publish-Wiki.ps1 publishes that source; the browser copy is not another source of truth.

Pull request completion

A change to code, configuration, scripts, commands, or behavior also updates the matching page, its Code and verification fields, and its folder index. A new feature gets a page or a section. Remove a deleted feature's page or mark it Superseded and link its replacement.

If no page needs a change, write KB: no change needed in the pull request body and give the reason.

Local checks

Run python scripts\kb\check_kb.py --diff origin/main before merging a change. The command checks committed branch changes, not uncommitted edits. It returns a failing exit code for a missing Code path, a missing folder index, or an index that does not list a page or subfolder. It ignores fenced examples, image folders, build output, and wiki navigation fragments. Extensionless links in the wiki source are valid.

The diff check warns about changed non-document files without Code coverage. A named folder covers its descendants, but not a folder with a similar name. Deletion or rename of a named path produces a warning and a missing-path error if the page still names it. Warnings do not cause a failing exit code. Fix every error. Review warnings and update the matching page when needed.

Run the disposable checker fixtures with python -m unittest discover -s scripts\kb -p test_check_kb.py. The script uses only the Python standard library and Git. There is no checked-in local hook setup. Do not install a hook in another developer's checkout.

These checks do not prove that a behavioral claim is correct.

Search evaluation

The evaluation file contains 30 real repository questions and their expected documentation paths. Run npx -y github:throndir2/repo-kb eval docs\kb\repo-kb-eval.json --json. Keep the questions fixed when comparing documentation changes.

The local hybrid evaluation on 2026-11-14 against 86e5f8c37 produced:

Measure Result
Expected page first (hit@1) 25/30, 83.3%
Expected page in the first three (hit@3) 30/30, 100%
Expected page in the first five (hit@5) 30/30, 100%
Mean reciprocal rank 0.911
Median search time 20 ms

These results measure retrieval, not the truth of each page's claims. The root and MCP audits retain explicit limits for untraced prose and hardware-dependent claims. Do not treat their metadata as full qualification.

Historical discovery comparison

Five past tasks were replayed with documentation from before each task. Documentation added by those tasks and the current audit was excluded. Recorded discovery contained 148 file reads and 111 repository searches. The replay kept all 113 source reads and replaced documentation reads with five KB searches and ten section reads.

Keeping every original repository search gives an estimate of 239 calls, against 259 recorded calls: 7.7% fewer calls and 9.1% fewer output tokens. Replacing all repository searches gives an optimistic estimate of 128 calls: 50.6% fewer calls and 30.1% fewer output tokens.

Token estimates use four output characters per token. They are not measured model input or billing totals. Shell reads, later implementation, tests, reasoning, repeated context, and cached input are excluded. The optimistic result assumes that no exact-symbol searches remain. The conservative skill-browser replay costs slightly more than its baseline. Do not promise the same savings for every task.

Martlet documentation

Clone this wiki locally