Slice 2: SQLite Read Model
Date: 2026-06-29
Scope#
Build the local read path for repo-owned .almanac/ pages:
- parse markdown pages and YAML frontmatter
- classify
[[...]]links into page, file, folder, and cross-wiki refs - maintain
.almanac/index.dbwith SQLite + FTS5 - implicitly refresh the index before read commands
- add
codealmanac searchandcodealmanac show
Out Of Scope#
- no hosted commands or remote sync
- no AI lifecycle work
- no
ingest,sync,garden,jobs,health, ortopicscommand - no semantic/vector search
- no compatibility aliases
Architecture#
app.index.ensure_fresh(workspace_id)
app.search.search(workspace_id, SearchPagesRequest(...))
app.pages.show(workspace_id, ShowPageRequest(...))wiki owns markdown parsing, frontmatter, path normalization, and wikilink
classification. index owns SQLite schema, freshness, FTS, and read queries.
CLI resolves the workspace and renders service results.
This follows the Cosmic Python repository pressure without adding a Unit of Work yet. There is one durable store in this slice, and each operation is a single SQLite transaction.
Files#
src/codealmanac/services/wiki/: page parser, wikilinks, page modelssrc/codealmanac/services/index/: schema, store, service, requestssrc/codealmanac/services/search/: search request/result servicesrc/codealmanac/services/pages/: show request/result servicesrc/codealmanac/cli/main.py:searchandshowadapterstests/: parser, index/search, show, and CLI tests
Compatibility To Preserve#
- commands run inside a repo resolve the nearest
.almanac/ --wiki <name>selects another registered local wikisearchprints slugs by default- empty search prints no stdout and
# 0 resultsto stderr show <slug>prints body by defaultshow --meta,--body,--lead,--links,--backlinks,--files,--topics, and--jsonare read-only views--mentionsuses normalized paths and SQLiteGLOB, notLIKE
Verification#
uv run pytestuv run ruff check .- live temp repo:
codealmanac init- create pages with topics, file refs, links
codealmanac searchcodealmanac search --mentionscodealmanac show