loader
loader
¶
Specification corpus loader.
Loads spec fragments from a project's spec directory. Supports YAML spec files (structured fragments with name/tags/content/data) and markdown files (text fragments with name derived from filename).
The loader is the first stage of the spec corpus pipeline:
spec_dir/*.yaml → SpecCorpusLoader.load() → list[SpecFragment]
spec_dir/*.md → ↓
CLAUDE.md (opt) → SpecCorpusConfig.fragments
Classes¶
SpecCorpusError
¶
Bases: Exception
Error loading the specification corpus.
SpecCorpusLoader
¶
Loads specification fragments from a directory.
The loader reads all recognized files from the spec directory and produces SpecFragment instances. YAML files are parsed for structured content (name, tags, kind, content, data). Markdown files become text fragments with the filename stem as the name.
Binary files and unrecognized extensions are silently skipped.
Functions¶
load
staticmethod
¶
Load all spec fragments from a directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec_dir
|
str | Path
|
Path to the specification directory. Must exist. |
required |
Returns:
| Type | Description |
|---|---|
list[SpecFragment]
|
List of loaded SpecFragment instances, sorted by name for |
list[SpecFragment]
|
deterministic ordering. |
Raises:
| Type | Description |
|---|---|
SpecCorpusError
|
If the directory does not exist or cannot be read. |
Source code in src/marianne/spec/loader.py
load_claude_md
staticmethod
¶
Load CLAUDE.md as a spec fragment if it exists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_root
|
str | Path
|
Path to the project root directory. |
required |
Returns:
| Type | Description |
|---|---|
SpecFragment | None
|
SpecFragment with name='claude_md' and kind='text', or None |
SpecFragment | None
|
if CLAUDE.md does not exist. |