Expand description
Business logic services.
Services orchestrate storage backends and provide high-level operations.
§Examples
Create a service container and capture a memory:
ⓘ
use subcog::services::ServiceContainer;
use subcog::models::{CaptureRequest, Namespace, Domain};
let container = ServiceContainer::from_current_dir_or_user()?;
let request = CaptureRequest {
content: "Use PostgreSQL for production storage".to_string(),
namespace: Namespace::Decisions,
domain: Domain::default(),
tags: vec!["database".to_string(), "architecture".to_string()],
source: Some("ARCHITECTURE.md".to_string()),
skip_security_check: false,
};
let result = container.capture().capture(request)?;
println!("Captured: {}", result.urn);Search for memories with the recall service:
ⓘ
use subcog::services::ServiceContainer;
use subcog::models::{SearchFilter, SearchMode};
let container = ServiceContainer::from_current_dir_or_user()?;
let recall = container.recall()?;
let filter = SearchFilter::new().with_namespace(subcog::models::Namespace::Decisions);
let results = recall.search("database storage", SearchMode::Hybrid, &filter, 10)?;
for hit in &results.memories {
println!("{}: {:.2}", hit.memory.id.as_str(), hit.score);
}§Clippy Lints
The following lints are allowed at module level due to their pervasive nature in service code. Each has a documented rationale:
| Lint | Rationale |
|---|---|
cast_precision_loss | Metrics/score calculations don’t require exact precision |
unused_self | Methods retained for API consistency or future extension |
option_if_let_else | If-let chains often clearer than nested map_or_else |
manual_let_else | Match patterns with logging clearer than let...else |
unnecessary_wraps | Result types for API consistency across trait impls |
or_fun_call | Entry API with closures for lazy initialization |
significant_drop_tightening | Drop timing not critical for correctness |
Re-exports§
pub use auth::AuthContext;pub use auth::AuthContextBuilder;pub use auth::Permission;pub use deduplication::DeduplicationConfig;pub use deduplication::DeduplicationService;pub use deduplication::Deduplicator;pub use deduplication::DuplicateCheckResult;pub use deduplication::DuplicateReason;pub use group::GroupService;
Modules§
- auth
- Service-layer authorization (CRIT-006).
- backend_
factory 🔒 - Backend factory for storage layer initialization.
- capture 🔒
- Memory capture service.
- consolidation 🔒
- Memory consolidation service.
- context 🔒
- Context builder service.
- context_
template 🔒 - Context template storage, management, and rendering service.
- data_
subject 🔒 - GDPR Data Subject Rights Service.
- deduplication
- Deduplication service for pre-compact hook.
- enrichment 🔒
- Memory enrichment service.
- entity_
extraction 🔒 - Entity extraction service for extracting entities from text using LLM.
- graph 🔒
- Graph service for high-level knowledge graph operations.
- graph_
rag 🔒 - Graph RAG (Retrieval-Augmented Generation) Service.
- group
- Group management service.
- migration
- Migration service.
- path_
manager 🔒 - Centralized path management for subcog storage locations.
- prompt 🔒
- Prompt template storage and management service.
- prompt_
enrichment 🔒 - Prompt enrichment service.
- prompt_
parser 🔒 - Prompt file parsing service.
- query_
parser 🔒 - Filter query parser for memory search.
- recall 🔒
- Memory recall (search) service.
- sync 🔒
- Memory synchronization service.
- tombstone 🔒
- Tombstone operations for soft-delete functionality (ADR-0053).
- topic_
index 🔒 - Topic index service for memory organization.
Structs§
- Backend
Factory - Factory for creating storage backends.
- Backend
Set - Result of backend initialization with optional components.
- Capture
Service - Service for capturing memories.
- Consent
Record - A record of consent granted or revoked.
- Consent
Status - Current consent status for all purposes.
- Consolidation
Service - Service for consolidating and managing memory lifecycle.
- Consolidation
Stats - Statistics from a consolidation operation.
- Context
Builder Service - Service for building context for AI assistants.
- Context
Template Filter - Filter for listing context templates.
- Context
Template Service - Service for context template CRUD operations and rendering.
- Data
Subject Service - Service for GDPR data subject rights operations.
- Deletion
Result - Result of a user data deletion operation.
- Enrichment
Request - Request for prompt enrichment.
- Enrichment
Result - Result of enriching a single memory.
- Enrichment
Service - Service for enriching memories with LLM-generated tags and metadata.
- Enrichment
Stats - Statistics from a batch enrichment operation.
- Entity
Extraction Stats - Statistics from entity extraction during capture.
- Entity
Extractor Service - Service for extracting entities from text content.
- Expansion
Config - Configuration for a specific expansion operation.
- Export
Metadata - Metadata about the export operation.
- Exported
Memory - A single memory in the export format.
- Extracted
Entity - An entity extracted from text.
- Extracted
Relationship - A relationship extracted from text.
- Extraction
Result - Result of entity extraction from text.
- GraphRAG
Config - Configuration for Graph RAG service.
- GraphRAG
Service - Service for hybrid search combining semantic search with graph expansion.
- Graph
Search Hit - A search result with provenance information.
- Graph
Search Results - Results from a Graph RAG search.
- Graph
Service - High-level service for knowledge graph operations.
- Inference
Result - Result of relationship inference between entities.
- Inferred
Relationship - A relationship inferred between existing entities.
- Memory
Statistics - Statistics about memories in the system.
- Partial
Metadata - Partial metadata provided by the user.
- Path
Manager - Manages storage paths for subcog backends.
- Prompt
Enrichment Result - Result of prompt enrichment.
- Prompt
Enrichment Service - Service for enriching prompt templates with LLM-generated metadata.
- Prompt
Filter - Filter for listing prompts.
- Prompt
Parser - Parser for prompt template files.
- Prompt
Service - Service for prompt template CRUD operations.
- Recall
Service - Service for searching and retrieving memories.
- Render
Result - Result of a render operation.
- Save
Options - Options for saving a prompt with enrichment.
- Save
Result - Result of a save operation with enrichment.
- Service
Container - Container for initialized services with configured backends.
- Sync
Service - Service for synchronizing memories with remote storage.
- Tombstone
Service - Service for tombstone operations (soft deletes).
- Topic
Index Service - Service for maintaining topic → memory mappings.
- Topic
Info - Information about a topic in the index.
- User
Data Export - Result of a user data export operation.
- Validation
Issue - A validation issue found in a template.
- Validation
Result - Result of template validation.
Enums§
- Consent
Purpose - Purpose for which consent is granted.
- Enrichment
Status - Status of the enrichment operation.
- Prompt
Format - Supported prompt file formats.
- Search
Provenance - Indicates how a memory was discovered.
- Validation
Severity - Validation severity level.
Constants§
- ENRICHMENT_
TIMEOUT - Default timeout for LLM enrichment calls.
- GRAPH_
DB_ NAME - Name of the graph
SQLitedatabase file. - INDEX_
DB_ NAME - Name of the
SQLiteindex database file. - PROMPT_
ENRICHMENT_ SYSTEM_ PROMPT - System prompt for prompt template enrichment.
- SUBCOG_
DIR_ NAME - Legacy name for the repo-local subcog directory (project storage no longer uses it).
- VECTOR_
INDEX_ NAME - Name of the vector index file.
Functions§
- parse_
filter_ query - Parses a filter query string into a
SearchFilter. - prompt_
service_ for_ cwd - Creates a
PromptServicefor the current working directory. - prompt_
service_ for_ repo - Creates a
PromptServicefor the given repository path.
Type Aliases§
- Entity
Extraction Callback - Callback type for post-capture entity extraction.