Skip to main content

Crate zagens_topic_memory

Crate zagens_topic_memory 

Source
Expand description

Topic memory graph — incremental conversation topic map for prompt injection (B2).

Port of topic-memory-graph; reference TS: docs/topic-memory-graph-main/src/.

Structs§

BlockedPoint
CognitiveTrail
GenerateMemorySectionOptions
MemorySectionMarkers
PheromoneEdge
PheromoneGraph
PheromoneNode
TopicMemoryEvalComparison
Compare current metrics to a baseline file; used by scripts/topic-memory-eval.ps1.
TopicMemoryEvalReport
B2.5 — derived rates for evaluation scripts and HTTP /v1/topic-memory.
TopicMemoryMetrics
Sidecar metrics file: metrics.json in the same directory as the graph file.

Enums§

EmotionMode

Constants§

DEFAULT_INJECT_INTERVAL_RUNS
Default: inject after this many completed runs.
DEFAULT_MARKERS
DEFAULT_RETRIEVE_K_HOPS
Default BFS depth from seed topics (UNDERLYING §2.3).
GRAPH_SCHEMA_VERSION

Functions§

apply_decay
Apply time-based decay (at most once per calendar day).
as_system_block
Wrap markdown in <topic_memory> for system prompt assembly.
compare_eval
detect_blocked_topics
Topics where the user expressed confusion / knowledge gaps.
detect_emotion
Detect dominant emotion from user text (≥2 signal hits for A/B/C, else N).
empty_graph
eval_report
extract_topics
Extract topic tokens from text (Chinese 2–6 char segments + English words ≥3).
generate_memory_section
Markdown section for system prompt injection.
induced_subgraph
Build a subgraph containing only nodes and edges between them.
inject_memory_section
Insert or replace a bounded memory section in markdown.
load_graph
Load graph from JSON path; returns empty graph when missing or invalid.
load_metrics
metrics_path_for_graph
record_inject
record_turn_update
Record a turn update; bumps clarification counters when topics repeat across turns.
retrieve_for_query
Extract seeds from query text and return a k-hop subgraph.
retrieve_k_hop_subgraph
BFS k-hop neighborhood around seeds (undirected over edge endpoints).
save_graph
Persist graph atomically (best-effort).
save_metrics
Persist metrics atomically (best-effort).
should_inject_memory
Whether enough runs have passed to inject memory into the prompt.
today_str
update_graph
Update graph after one conversation turn.