Note: corpus
Context
The corpus layer provides pluggable loaders for retrieval content. CorpusProtocol defines the interface; DirectoryCorpus loads markdown files from disk; AttuneHelpCorpus wraps the bundled attune-help templates.
Content
Any object that satisfies CorpusProtocol exposes three things: an iterable of RetrievalEntry values via entries(), a lookup by path via get(), and name and version properties that identify the corpus.
The two built-in implementations differ in where they source content:
-
DirectoryCorpus(src/attune_rag/corpus/directory.py) scans a directory tree for markdown files using a configurable glob pattern (default:**/*.md). It maintains apath_indexkeyed by relative path and analias_indexkeyed by alias string. Theversionproperty is a stable SHA-256 fingerprint of the loaded content. Optionalsummaries_fileandcross_links_filearguments enrich entries at load time; results are cached by default. -
AttuneHelpCorpus(src/attune_rag/corpus/attune_help.py) is a thin adapter over aHelpCorpusAdapterand is the standard way to load the bundled attune-help templates. Use thefrom_attune_help()class method for the default configuration.
Each loaded template is represented as a RetrievalEntry dataclass (src/attune_rag/corpus/base.py) with the following fields:
| Field | Type | Notes |
|---|---|---|
path |
str |
Corpus-relative path used as the lookup key |
category |
str |
Template category |
content |
str |
Full template text |
summary |
str | None |
Optional short description |
related |
tuple[str, ...] |
Paths of related entries |
aliases |
tuple[str, ...] |
Alternative lookup keys |
metadata |
dict[str, Any] |
Arbitrary extra data |
Aliases are indexed globally across the corpus. If two templates declare the same alias string, DirectoryCorpus raises DuplicateAliasError, which carries the alias and both conflicting paths.
Source files
src/attune_rag/corpus/__init__.pysrc/attune_rag/corpus/base.pysrc/attune_rag/corpus/directory.pysrc/attune_rag/corpus/attune_help.py
Tags: corpus, loader, markdown, attune-help