# kb
Personal knowledge base — typed AST with org-mode as projection, SQLite-backed
## Getting started
Toolchain, task execution, and hook tools are managed by mise.
The Rust toolchain is declared in `mise.toml`; rustup is an implementation
detail and `rust-toolchain.toml` is intentionally absent.
With direnv installed, entering the directory prepares the environment. Otherwise:
```sh
mise trust --quiet
mise install
mise run sync
```
## Tasks
```sh
mise run check # check-only hooks, as CI runs them
mise run lint # manual autofix hooks
mise run test # test suite
mise run ci # full CI gate
```
The generated Rust gate includes formatting, TOML formatting, shell linting,
spelling, clippy, nextest, docs, unused-dependency detection, advisory audit,
license/source policy, packaging, and line coverage. Coverage is held to a
repository-local floor of 90% (the generated default is 100%): kb is a
server/MCP/CLI application whose binary entry points and interactive CLI
dispatch are not reachable by in-process tests. See RS-007 in
`REPO_INVARIANTS.md`.
## Design notes
### Org-mode AST and parser
The typed org-mode AST (`Document`, `Block`, `Inline`, and friends) is re-used
from the companion [`tftio-org`](https://crates.io/crates/tftio-org) crate, which
was extracted from this crate. The AST types are byte-for-byte behaviour-identical
across the two crates, so deduplicating them costs nothing.
The **parser is deliberately kept in-crate** rather than taken from `tftio-org`.
`tftio-org` 0.1.0's `parser::parse_document` enters an infinite loop on pipe /
table input such as `"|\n"` — a defect this crate's own parser explicitly fixed
and guards with regression tests (`tests/v10_phase.rs`,
`parser_panic_free_pipe_returns_ok`). Because that defect ships in a published
dependency version that cannot be patched from here, adopting `tftio-org`'s parser
would reintroduce the hang. Keeping the proven in-crate parser preserves behaviour;
the AST dependency is still shared. Revisit this once a fixed `tftio-org` is
released.