goosedump 0.12.36

Browse, search, compact, and learn from coding-agent sessions
// SPDX-License-Identifier: LGPL-2.1-or-later
// Copyright (C) Jarkko Sakkinen 2026

//! Auditable, project-scoped durable memory.
//!
//! Evidence is retained first; atomic claims are derived with provenance.
//! Recall ranks lexical, entity, relation, and semantic matches. Compaction
//! never writes this store.

mod entity;
mod extract;
mod store;
mod types;

pub use store::Memory;
// Public API surface for `memory::Type` paths and method return types.
#[allow(unused_imports)]
pub use types::{
    ClaimRelationship, EntityReference, ForgetReport, MatchKind, MatchReason, MemoryError,
    MemoryFilter, MemoryListItem, MemoryRecord, MemoryStats, MemoryStatus, MemoryType,
    MemoryTypeCounts, ParseMemoryStatusError, ParseMemoryTypeError, ParseRelationshipKindError,
    RecallHit, RelationshipDirection, RelationshipKind, RememberInput, RememberReport,
    RememberedMemory, SourceReference, SupersededMemory,
};

pub(super) const MAX_MEMORY_CHARS: usize = 2_000;
pub(super) const MAX_KEYWORDS: usize = 16;
pub(super) const MAX_KEYWORD_CHARS: usize = 80;
pub(super) const MAX_PROMPT_SOURCE_CHARS: usize = 3_000;
pub(super) const MAX_PROMPT_BATCH_CHARS: usize = 8_000;
pub(super) const EXTRACTION_MAX_TOKENS: usize = 1_200;
pub(super) const CONSOLIDATION_EVIDENCE_CHARS: usize = 500;
pub(super) const MAX_RELATION_RATIONALE_CHARS: usize = 500;
pub(super) const MAX_ENTITIES_PER_MEMORY: usize = 24;
pub(super) const MAX_ENTITY_CHARS: usize = 160;

pub(super) fn clipped_chars(value: &str, max_chars: usize) -> String {
    value.chars().take(max_chars).collect()
}

pub(super) fn external_id(id: &str) -> String {
    format!("mem_{id}")
}