Skip to main content

Module services

Module services 

Source
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:

LintRationale
cast_precision_lossMetrics/score calculations don’t require exact precision
unused_selfMethods retained for API consistency or future extension
option_if_let_elseIf-let chains often clearer than nested map_or_else
manual_let_elseMatch patterns with logging clearer than let...else
unnecessary_wrapsResult types for API consistency across trait impls
or_fun_callEntry API with closures for lazy initialization
significant_drop_tighteningDrop 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§

BackendFactory
Factory for creating storage backends.
BackendSet
Result of backend initialization with optional components.
CaptureService
Service for capturing memories.
ConsentRecord
A record of consent granted or revoked.
ConsentStatus
Current consent status for all purposes.
ConsolidationService
Service for consolidating and managing memory lifecycle.
ConsolidationStats
Statistics from a consolidation operation.
ContextBuilderService
Service for building context for AI assistants.
ContextTemplateFilter
Filter for listing context templates.
ContextTemplateService
Service for context template CRUD operations and rendering.
DataSubjectService
Service for GDPR data subject rights operations.
DeletionResult
Result of a user data deletion operation.
EnrichmentRequest
Request for prompt enrichment.
EnrichmentResult
Result of enriching a single memory.
EnrichmentService
Service for enriching memories with LLM-generated tags and metadata.
EnrichmentStats
Statistics from a batch enrichment operation.
EntityExtractionStats
Statistics from entity extraction during capture.
EntityExtractorService
Service for extracting entities from text content.
ExpansionConfig
Configuration for a specific expansion operation.
ExportMetadata
Metadata about the export operation.
ExportedMemory
A single memory in the export format.
ExtractedEntity
An entity extracted from text.
ExtractedRelationship
A relationship extracted from text.
ExtractionResult
Result of entity extraction from text.
GraphRAGConfig
Configuration for Graph RAG service.
GraphRAGService
Service for hybrid search combining semantic search with graph expansion.
GraphSearchHit
A search result with provenance information.
GraphSearchResults
Results from a Graph RAG search.
GraphService
High-level service for knowledge graph operations.
InferenceResult
Result of relationship inference between entities.
InferredRelationship
A relationship inferred between existing entities.
MemoryStatistics
Statistics about memories in the system.
PartialMetadata
Partial metadata provided by the user.
PathManager
Manages storage paths for subcog backends.
PromptEnrichmentResult
Result of prompt enrichment.
PromptEnrichmentService
Service for enriching prompt templates with LLM-generated metadata.
PromptFilter
Filter for listing prompts.
PromptParser
Parser for prompt template files.
PromptService
Service for prompt template CRUD operations.
RecallService
Service for searching and retrieving memories.
RenderResult
Result of a render operation.
SaveOptions
Options for saving a prompt with enrichment.
SaveResult
Result of a save operation with enrichment.
ServiceContainer
Container for initialized services with configured backends.
SyncService
Service for synchronizing memories with remote storage.
TombstoneService
Service for tombstone operations (soft deletes).
TopicIndexService
Service for maintaining topic → memory mappings.
TopicInfo
Information about a topic in the index.
UserDataExport
Result of a user data export operation.
ValidationIssue
A validation issue found in a template.
ValidationResult
Result of template validation.

Enums§

ConsentPurpose
Purpose for which consent is granted.
EnrichmentStatus
Status of the enrichment operation.
PromptFormat
Supported prompt file formats.
SearchProvenance
Indicates how a memory was discovered.
ValidationSeverity
Validation severity level.

Constants§

ENRICHMENT_TIMEOUT
Default timeout for LLM enrichment calls.
GRAPH_DB_NAME
Name of the graph SQLite database file.
INDEX_DB_NAME
Name of the SQLite index 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 PromptService for the current working directory.
prompt_service_for_repo
Creates a PromptService for the given repository path.

Type Aliases§

EntityExtractionCallback
Callback type for post-capture entity extraction.