Models¶
Core data models using msgspec.Struct.
Enums¶
Grade ¶
Bases: int, Enum
Spike grade — maps to FSRS Rating.
Attributes:
| Name | Type | Description |
|---|---|---|
MISS |
Failed recall (FSRS Again). |
|
WEAK |
Uncertain recall (FSRS Hard). |
|
FIRE |
Correct recall (FSRS Good). |
|
STRONG |
Perfect recall (FSRS Easy). |
SynapseType ¶
Bases: str, Enum
Types of synaptic connections between Neurons.
Attributes:
| Name | Type | Description |
|---|---|---|
REQUIRES |
Directed — A requires understanding B. |
|
EXTENDS |
Directed — A extends B. |
|
CONTRASTS |
Bidirectional — A contrasts with B. |
|
RELATES_TO |
Bidirectional — general association. |
is_bidirectional
property
¶
Whether this synapse type creates edges in both directions.
ScaffoldLevel ¶
Bases: str, Enum
How much support the learner needs (ZPD-inspired).
Attributes:
| Name | Type | Description |
|---|---|---|
FULL |
New or struggling — max hints, context, easy questions. |
|
GUIDED |
Progressing — hints on request, some context. |
|
MINIMAL |
Competent — harder questions, less hand-holding. |
|
NONE |
Mastered — application / synthesis level. |
Data Models¶
Neuron ¶
Bases: Struct
A unit of knowledge — the fundamental node in a Circuit.
Content is stored as Markdown with optional YAML-style frontmatter. Only minimal metadata is extracted into fields for indexing.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
str
|
Unique identifier (auto-generated as |
content |
str
|
Markdown content, optionally with YAML frontmatter. |
type |
str | None
|
Category tag (e.g. |
domain |
str | None
|
Knowledge domain (e.g. |
source |
str | None
|
Origin URL or reference. |
created_at |
datetime
|
UTC timestamp, auto-set on creation. |
updated_at |
datetime
|
UTC timestamp, auto-set on creation and mutation. |
create
classmethod
¶
Create a Neuron from Markdown content, extracting frontmatter.
Generates a unique ID and parses YAML-style frontmatter for
type, domain, and source fields. Explicit overrides
take precedence over frontmatter values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
str
|
Markdown text, optionally starting with |
required |
**overrides
|
Any
|
Field overrides ( |
{}
|
Returns:
| Type | Description |
|---|---|
Neuron
|
A new Neuron instance. |
Synapse ¶
Bases: Struct
A directed connection between two Neurons.
Bidirectional types (contrasts, relates_to) are stored as two
Synapse objects — one in each direction. Weights may be asymmetric.
Attributes:
| Name | Type | Description |
|---|---|---|
pre |
str
|
Source neuron ID (pre-synaptic). |
post |
str
|
Target neuron ID (post-synaptic). |
type |
SynapseType
|
Connection semantics (see |
weight |
float
|
Edge strength, updated by STDP (range: |
co_fires |
int
|
Number of times both endpoints fired within |
last_co_fire |
datetime | None
|
Timestamp of the most recent co-fire event. |
created_at |
datetime
|
UTC timestamp, auto-set on creation. |
updated_at |
datetime
|
UTC timestamp, auto-set on creation and mutation. |
Spike ¶
Bases: Struct
A review event — an action potential in the Circuit.
Created by external layers (Quiz, CLI, etc.) and fed into
Circuit.fire() to trigger
FSRS update + propagation.
Attributes:
| Name | Type | Description |
|---|---|---|
neuron_id |
str
|
The neuron being reviewed. |
grade |
Grade
|
Review quality (see |
fired_at |
datetime
|
UTC timestamp, auto-set to now. |
session_id |
str | None
|
Optional session identifier for grouping spikes. |
notes |
str | None
|
Optional free-text feedback captured with the review. |
Plasticity ¶
Bases: Struct
Tunable learning parameters — configurable per Circuit. Immutable.
Controls how activation propagates, how edges strengthen/weaken, and how pressure accumulates and decays.
Attributes:
| Name | Type | Description |
|---|---|---|
alpha |
float
|
APPNP teleport probability (higher = more local). |
propagation_steps |
int
|
APPNP power-iteration steps. |
tau_stdp |
float
|
STDP time window in days. |
a_plus |
float
|
STDP LTP amplitude (pre-before-post strengthening). |
a_minus |
float
|
STDP LTD amplitude (post-before-pre weakening). |
tau_m |
float
|
LIF membrane time constant in days (pressure decay rate). |
pressure_threshold |
float
|
LIF pressure threshold for spontaneous review. |
pressure_rest |
float
|
LIF resting pressure. |
pressure_reset |
float
|
Pressure value after a neuron fires. |
theta_pro |
int
|
STC promotion threshold (co-fire count). |
schema_factor |
float
|
Bonus factor for schema-connected neurons. |
weight_floor |
float
|
Minimum allowed edge weight. |
weight_ceiling |
float
|
Maximum allowed edge weight. |
Scaffold ¶
Bases: Struct
Scaffolding state computed from Brain data.
Determines how much support a Learn session provides, based on FSRS state, graph context, and pressure.
Attributes:
| Name | Type | Description |
|---|---|---|
level |
ScaffoldLevel
|
Current support level. |
hints |
list[str]
|
Auto-generated hint strings. |
context |
list[str]
|
IDs of strong neighbors (scaffolding material). |
gaps |
list[str]
|
IDs of weak prerequisites (should study first). |
Quiz Models¶
QuizRequest ¶
Bases: Struct
Input for quiz generation — what to ask and how.
Attributes:
| Name | Type | Description |
|---|---|---|
primary |
str
|
Primary neuron ID to quiz on. |
supporting |
list[str]
|
Supporting neuron IDs for context. |
scaffold |
Scaffold
|
Scaffolding state for difficulty adaptation. |
quiz_type |
str | None
|
Question style — |
QuizItem ¶
Bases: Struct
A quiz question — generated by LLM or created manually.
Persisted in the quiz_items table with neuron associations
in quiz_item_neurons (M:N via neuron_ids).
Attributes:
| Name | Type | Description |
|---|---|---|
id |
str
|
Unique identifier (auto-generated as |
question |
str
|
The question text. |
answer |
str
|
The expected answer. |
hints |
list[str]
|
Progressive hints (reveal one at a time). |
grading_criteria |
str
|
Free-text criteria for LLM-based grading. |
scaffold_level |
ScaffoldLevel | None
|
The scaffold level this item was designed for. |
neuron_ids |
dict[str, QuizItemRole]
|
Mapping of neuron ID to role (primary/supporting). |
created_at |
datetime
|
UTC timestamp, auto-set on creation. |