Documentation
¶
Index ¶
- Constants
- Variables
- func ConsolidationLockPath(globalDir string) string
- func ConsolidationPrompt() string
- func FreshnessWarning(modTime time.Time, now time.Time) string
- func IsSystemManagedFilename(filename string) bool
- func MigrationStream() storepkg.MigrationStream
- func NewRecallAugmenter(store *Store) session.PromptInputAugmenter
- func ParseHeader(content []byte) (memcontract.Header, error)
- func RenderCheckpointSummaryPrompt(request CheckpointSummaryRequest) (string, error)
- func RenderRecallPromptSection(packaged memcontract.Packaged, opts RecallPromptOptions) string
- type Assembler
- func (a *Assembler) Assemble(ctx context.Context, agent compozyconfig.AgentDef, ...) (string, error)
- func (a *Assembler) PromptSection(ctx context.Context, workspace *workspacepkg.ResolvedWorkspace) (string, error)
- func (a *Assembler) PromptStartupSection(ctx context.Context, startup session.StartupPromptContext, ...) (string, error)
- func (a *Assembler) ResumeContextSection(ctx context.Context, startup session.StartupPromptContext) (string, error)
- type AssemblerOption
- type BatchAction
- type BatchApplyResult
- type BatchOperation
- type BatchOperationOutcome
- type BatchProposal
- type CheckpointCompactionResult
- type CheckpointSummarizer
- type CheckpointSummaryOption
- type CheckpointSummaryRequest
- type CheckpointSummaryService
- func (s *CheckpointSummaryService) Compact(ctx context.Context, request memcontract.PreCompressRequest) (CheckpointCompactionResult, error)
- func (s *CheckpointSummaryService) OnPreCompress(ctx context.Context, request memcontract.PreCompressRequest) (memcontract.PreCompressHint, error)
- func (s *CheckpointSummaryService) OnSessionEnd(ctx context.Context, record memcontract.SessionEndRecord) error
- func (s *CheckpointSummaryService) Update(ctx context.Context, record memcontract.SessionEndRecord) (DecisionApplyResult, error)
- type CheckpointWorkspaceResolver
- type ConsolidationLock
- type DailyLogListQuery
- type DailyLogRecord
- type DecisionApplyResult
- type DecisionControllerFactory
- type DecisionListQuery
- type DecisionRecord
- type DecisionRevertResult
- type DerivedResetResult
- type DreamCandidate
- type DreamGateConfig
- type DreamRunListQuery
- type DreamRunRecord
- type FrozenSnapshot
- type HeaderListPage
- type HeaderListQuery
- type Option
- func WithDreamGateConfig(config DreamGateConfig) Option
- func WithLockPath(path string) Option
- func WithLogger(logger *slog.Logger) Option
- func WithMemoryStore(store *Store) Option
- func WithMinHours(hours float64) Option
- func WithMinSessions(count int) Option
- func WithSessionsDir(path string) Option
- func WithWorkspaceResolver(resolver workspacepkg.RuntimeResolver) Option
- type PromptSnapshotRequest
- type RecallPromptOptions
- type ReplayResult
- type Service
- type SessionSpawner
- type SnapshotBlock
- type SnapshotControllerMode
- type SnapshotProvider
- type SnapshotService
- type SnapshotServiceOption
- type Store
- func (s *Store) ApplyDecision(ctx context.Context, decision memcontract.Decision) (DecisionApplyResult, error)
- func (s *Store) Candidates(ctx context.Context, query memcontract.Query, opts memcontract.RecallOptions) ([]memoryrecall.Candidate, error)
- func (s *Store) CatalogHeaders(ctx context.Context, scope memcontract.Scope) ([]memcontract.Header, error)
- func (s *Store) CloseCatalog(ctx context.Context) error
- func (s *Store) CloseRecallSignalRecorders(ctx context.Context) error
- func (s *Store) DecideCandidate(ctx context.Context, candidate memcontract.Candidate) (memcontract.Decision, error)
- func (s *Store) Delete(scope memcontract.Scope, filename string) error
- func (s *Store) EnsureDirs() error
- func (s *Store) Exists(scope memcontract.Scope, filename string) (bool, error)
- func (s *Store) ForAgent(workspaceID string, agentName string, tier memcontract.AgentTier) *Store
- func (s *Store) ForWorkspace(workspaceRoot string) *Store
- func (s *Store) HealthStats(ctx context.Context, workspaces []string) (memcontract.HealthStats, error)
- func (s *Store) History(ctx context.Context, query memcontract.OperationHistoryQuery) ([]memcontract.OperationRecord, error)
- func (s *Store) List(scope memcontract.Scope) ([]memcontract.Header, error)
- func (s *Store) ListDailyLogRecords(ctx context.Context, query DailyLogListQuery) ([]DailyLogRecord, error)
- func (s *Store) ListDecisionRecords(ctx context.Context, query DecisionListQuery) ([]DecisionRecord, error)
- func (s *Store) ListDreamRunRecords(ctx context.Context, query DreamRunListQuery) ([]DreamRunRecord, error)
- func (s *Store) ListMemoryEventSummaries(ctx context.Context, workspaces []string, query storepkg.EventSummaryQuery) ([]storepkg.EventSummary, error)
- func (s *Store) ListTargets(ctx context.Context, candidate memcontract.Candidate) ([]controller.Target, error)
- func (s *Store) LoadDecisionRecord(ctx context.Context, id string) (DecisionRecord, error)
- func (s *Store) LoadDreamRunRecord(ctx context.Context, id string) (DreamRunRecord, error)
- func (s *Store) LoadIndex(scope memcontract.Scope) (content string, truncated bool, err error)
- func (s *Store) LoadPromptIndex(scope memcontract.Scope) (content string, truncated bool, err error)
- func (s *Store) OpenCatalog(ctx context.Context) error
- func (s *Store) ProposeBatch(ctx context.Context, proposal BatchProposal) (BatchApplyResult, error)
- func (s *Store) ProposeCandidate(ctx context.Context, candidate memcontract.Candidate) (memcontract.Decision, error)
- func (s *Store) ProposeDelete(ctx context.Context, scope memcontract.Scope, filename string, ...) (DecisionApplyResult, error)
- func (s *Store) ProposeWrite(ctx context.Context, scope memcontract.Scope, filename string, content []byte, ...) (DecisionApplyResult, error)
- func (s *Store) Read(scope memcontract.Scope, filename string) ([]byte, error)
- func (s *Store) Recall(ctx context.Context, query memcontract.Query, opts memcontract.RecallOptions) (memcontract.Packaged, error)
- func (s *Store) RecallSignalRecorderStats(workspaceID string) memoryrecall.SignalRecorderStats
- func (s *Store) RecordExtractorEvent(ctx context.Context, event memoryextractor.Event) error
- func (s *Store) RecordMemoryWriteRejected(ctx context.Context, event WriteRejectedEvent) error
- func (s *Store) RecordRecall(ctx context.Context, signals []memoryrecall.Signal) error
- func (s *Store) RecordRecallExecuted(ctx context.Context, query memcontract.Query, resultCount int) error
- func (s *Store) RecordRecallSignalDropped(ctx context.Context, query memcontract.Query, signals []memoryrecall.Signal, ...) error
- func (s *Store) RecordRecallSignalFailed(ctx context.Context, query memcontract.Query, cause error) error
- func (s *Store) RecordRecallSkipped(ctx context.Context, query memcontract.Query, reason string) error
- func (s *Store) RecordShadow(ctx context.Context, shadow memoryrecall.Shadow) error
- func (s *Store) Reindex(ctx context.Context, opts memcontract.ReindexOptions) (memcontract.ReindexResult, error)
- func (s *Store) ReplayPendingDecisions(ctx context.Context) (ReplayResult, error)
- func (s *Store) ResetDerived(ctx context.Context, opts memcontract.ReindexOptions) (DerivedResetResult, error)
- func (s *Store) RevertDecision(ctx context.Context, id string) (DecisionRevertResult, error)
- func (s *Store) Scan(scope memcontract.Scope) ([]memcontract.Header, error)
- func (s *Store) Search(ctx context.Context, query string, opts memcontract.SearchOptions) ([]memcontract.SearchResult, error)
- func (s *Store) SetDecisionControllerFactory(factory DecisionControllerFactory)
- func (s *Store) SourceHeaderCount(scope memcontract.Scope) (int, error)
- func (s *Store) Write(scope memcontract.Scope, filename string, content []byte) error
- type StoreOption
- type WriteRejectedEvent
Constants ¶
const ( // HeaderListSortRecent orders memory headers from newest to oldest. HeaderListSortRecent = "recent" // HeaderListSortName orders memory headers by normalized display name. HeaderListSortName = "name" // DefaultHeaderListLimit bounds public memory catalog reads by default. DefaultHeaderListLimit = 50 // MaxHeaderListLimit caps one public memory catalog page. MaxHeaderListLimit = 200 )
const (
// CheckpointSummaryFilename is the stable workspace-scoped continuity artifact.
CheckpointSummaryFilename = "project_checkpoint_summary.md"
)
const ( // RecallAugmenterBudget is the declared daemon-side budget for durable // memory recall when it participates in the prompt augmentation composite. RecallAugmenterBudget = maxRecallCharacters + recallWrapperBytes )
Variables ¶
var ( ErrLockUnavailable = errors.New("memory: consolidation lock is unavailable") // ErrDreamRoleDisabled reports that no effective workspace route permits a dream run. ErrDreamRoleDisabled = errors.New("memory: dream role is disabled") )
var ( // ErrCheckpointSummaryDisabled reports that the effective workspace role disables checkpoint generation. ErrCheckpointSummaryDisabled = errors.New("memory: checkpoint summary role is disabled") )
var ( // ErrDreamGateNotSatisfied reports a lock-protected dream run skipped // because recall-signal promotion thresholds were not met. ErrDreamGateNotSatisfied = errors.New("memory: dream signal gate is not satisfied") )
var ( // ErrHeaderListCursorInvalid reports a malformed cursor or one reused with a different query. ErrHeaderListCursorInvalid = errors.New("memory: header list cursor is invalid") )
var ( // ErrValidation marks memory input and metadata validation failures. ErrValidation = errors.New("memory: validation error") )
Functions ¶
func ConsolidationLockPath ¶
ConsolidationLockPath returns the canonical lock path for a global memory directory.
func ConsolidationPrompt ¶
func ConsolidationPrompt() string
ConsolidationPrompt returns the embedded four-phase consolidation prompt.
func FreshnessWarning ¶
FreshnessWarning reports whether a memory should be treated as stale.
func IsSystemManagedFilename ¶
IsSystemManagedFilename reports whether a memory path belongs to the reserved system namespace.
func MigrationStream ¶
func MigrationStream() storepkg.MigrationStream
MigrationStream returns the embedded memory catalog migration stream.
func NewRecallAugmenter ¶
func NewRecallAugmenter(store *Store) session.PromptInputAugmenter
NewRecallAugmenter returns a bounded prompt augmenter that prepends durable memory recall ahead of the live user message.
func ParseHeader ¶
func ParseHeader(content []byte) (memcontract.Header, error)
ParseHeader decodes and validates memory frontmatter from a raw document.
func RenderCheckpointSummaryPrompt ¶
func RenderCheckpointSummaryPrompt(request CheckpointSummaryRequest) (string, error)
RenderCheckpointSummaryPrompt renders the versioned Hermes-style update prompt.
func RenderRecallPromptSection ¶
func RenderRecallPromptSection(packaged memcontract.Packaged, opts RecallPromptOptions) string
RenderRecallPromptSection renders deterministic Packaged recall output.
Types ¶
type Assembler ¶
type Assembler struct {
// contains filtered or unexported fields
}
Assembler loads prompt-safe memory indexes and prepends them to the agent prompt.
func NewAssembler ¶
func NewAssembler(store *Store, opts ...AssemblerOption) *Assembler
NewAssembler constructs a prompt assembler for the provided store.
func (*Assembler) Assemble ¶
func (a *Assembler) Assemble( ctx context.Context, agent compozyconfig.AgentDef, workspace *workspacepkg.ResolvedWorkspace, ) (string, error)
Assemble renders the dual-scope memory context ahead of the agent system prompt.
func (*Assembler) PromptSection ¶
func (a *Assembler) PromptSection(ctx context.Context, workspace *workspacepkg.ResolvedWorkspace) (string, error)
PromptSection renders the frozen memory context block without the base agent prompt so it can participate in composed prompt assembly.
func (*Assembler) PromptStartupSection ¶
func (a *Assembler) PromptStartupSection( ctx context.Context, startup session.StartupPromptContext, _ compozyconfig.AgentDef, workspace *workspacepkg.ResolvedWorkspace, ) (string, error)
PromptStartupSection renders memory using durable startup metadata.
func (*Assembler) ResumeContextSection ¶
func (a *Assembler) ResumeContextSection( ctx context.Context, startup session.StartupPromptContext, ) (string, error)
ResumeContextSection returns only the durable checkpoint needed beside a degraded transcript replay.
type AssemblerOption ¶
type AssemblerOption func(*Assembler)
AssemblerOption customizes memory startup prompt assembly.
func WithSnapshotProvider ¶
func WithSnapshotProvider(provider SnapshotProvider) AssemblerOption
WithSnapshotProvider lets the assembler source prompt blocks from an active provider.
func WithSnapshotService ¶
func WithSnapshotService(service *SnapshotService) AssemblerOption
WithSnapshotService installs the frozen-snapshot service used by the assembler.
type BatchAction ¶
type BatchAction string
BatchAction identifies one staged mutation of a Memory v2 document body.
const ( BatchActionAdd BatchAction = "add" BatchActionReplace BatchAction = "replace" BatchActionRemove BatchAction = "remove" )
type BatchApplyResult ¶
type BatchApplyResult struct {
Decision memcontract.Decision `json:"decision"`
Applied bool `json:"applied"`
Operations []BatchOperationOutcome `json:"operations"`
}
BatchApplyResult reports the single decision and its per-operation outcome.
type BatchOperation ¶
type BatchOperation struct {
Action BatchAction `json:"action"`
Content string `json:"content,omitempty"`
OldText string `json:"old_text,omitempty"`
}
BatchOperation is one closed add, replace, or remove step in a document batch.
type BatchOperationOutcome ¶
type BatchOperationOutcome struct {
Index int `json:"index"`
Action BatchAction `json:"action"`
Changed bool `json:"changed"`
Status string `json:"status"`
}
BatchOperationOutcome reports how one operation participated in the final commit.
type BatchProposal ¶
type BatchProposal struct {
Scope memcontract.Scope
Filename string
Header memcontract.Header
Operations []BatchOperation
Origin memcontract.Origin
}
BatchProposal describes one atomic transformation of a Memory v2 document.
type CheckpointCompactionResult ¶
type CheckpointCompactionResult struct {
Hint memcontract.PreCompressHint
Decision DecisionApplyResult
}
CheckpointCompactionResult reports the provider hint and decision-backed artifact update.
type CheckpointSummarizer ¶
type CheckpointSummarizer interface {
Summarize(ctx context.Context, request CheckpointSummaryRequest) (string, error)
}
CheckpointSummarizer produces one structured Hermes-style checkpoint body.
type CheckpointSummaryOption ¶
type CheckpointSummaryOption func(*CheckpointSummaryService)
CheckpointSummaryOption customizes checkpoint summary updates.
func WithCheckpointSummaryClock ¶
func WithCheckpointSummaryClock(now func() time.Time) CheckpointSummaryOption
WithCheckpointSummaryClock injects a deterministic checkpoint clock.
func WithCheckpointSummaryMaxBytes ¶
func WithCheckpointSummaryMaxBytes(maxBytes int) CheckpointSummaryOption
WithCheckpointSummaryMaxBytes overrides the complete artifact byte limit.
type CheckpointSummaryRequest ¶
type CheckpointSummaryRequest struct {
WorkspaceID string
WorkspaceRoot string
SessionID string
AgentName string
EndedAt time.Time
PreviousSummary string
Snapshot memcontract.TranscriptSnapshot
}
CheckpointSummaryRequest is the bounded input supplied to a checkpoint summarizer.
type CheckpointSummaryService ¶
type CheckpointSummaryService struct {
// contains filtered or unexported fields
}
CheckpointSummaryService updates one workspace checkpoint through the decision WAL.
func NewCheckpointSummaryService ¶
func NewCheckpointSummaryService( store *Store, resolver CheckpointWorkspaceResolver, summarizer CheckpointSummarizer, opts ...CheckpointSummaryOption, ) *CheckpointSummaryService
NewCheckpointSummaryService constructs a decision-backed checkpoint updater.
func (*CheckpointSummaryService) Compact ¶
func (s *CheckpointSummaryService) Compact( ctx context.Context, request memcontract.PreCompressRequest, ) (CheckpointCompactionResult, error)
Compact records summary coverage before the caller archives the named event range.
func (*CheckpointSummaryService) OnPreCompress ¶
func (s *CheckpointSummaryService) OnPreCompress( ctx context.Context, request memcontract.PreCompressRequest, ) (memcontract.PreCompressHint, error)
OnPreCompress updates durable checkpoint coverage for the exact persisted span.
func (*CheckpointSummaryService) OnSessionEnd ¶
func (s *CheckpointSummaryService) OnSessionEnd( ctx context.Context, record memcontract.SessionEndRecord, ) error
OnSessionEnd implements the bundled local provider lifecycle handler.
func (*CheckpointSummaryService) Update ¶
func (s *CheckpointSummaryService) Update( ctx context.Context, record memcontract.SessionEndRecord, ) (DecisionApplyResult, error)
Update incorporates one completed session into the stable workspace artifact.
type CheckpointWorkspaceResolver ¶
type CheckpointWorkspaceResolver interface {
Resolve(ctx context.Context, idOrPath string) (workspacepkg.ResolvedWorkspace, error)
}
CheckpointWorkspaceResolver resolves a stable workspace identity to its runtime root.
type ConsolidationLock ¶
type ConsolidationLock struct {
// contains filtered or unexported fields
}
ConsolidationLock coordinates cross-process consolidation runs via a PID file whose mtime doubles as the last successful consolidation timestamp.
func NewConsolidationLock ¶
func NewConsolidationLock(path string) *ConsolidationLock
NewConsolidationLock constructs a lock rooted at path with the default stale age.
func (*ConsolidationLock) LastConsolidatedAt ¶
func (l *ConsolidationLock) LastConsolidatedAt() (time.Time, error)
LastConsolidatedAt returns the lock file mtime, or the zero time when the lock file does not exist.
func (*ConsolidationLock) Release ¶
func (l *ConsolidationLock) Release() error
Release clears the lock PID and leaves the file mtime at the release time.
func (*ConsolidationLock) Rollback ¶
func (l *ConsolidationLock) Rollback(priorMtime time.Time) error
Rollback clears the lock PID and restores the mtime from before acquisition.
func (*ConsolidationLock) TryAcquire ¶
func (l *ConsolidationLock) TryAcquire() (priorMtime time.Time, acquired bool, err error)
TryAcquire attempts to acquire the consolidation lock and returns the prior mtime for rollback when acquisition succeeds.
type DailyLogListQuery ¶
type DailyLogListQuery struct {
Date string
Scope memcontract.Scope
WorkspaceID string
AgentName string
AgentTier memcontract.AgentTier
Limit int
}
DailyLogListQuery filters daily memory operation summaries.
type DailyLogRecord ¶
type DailyLogRecord struct {
Date string
Scope memcontract.Scope
WorkspaceID string
AgentName string
AgentTier memcontract.AgentTier
OperationCount int
}
DailyLogRecord summarizes memory event activity for one date and selector.
type DecisionApplyResult ¶
type DecisionApplyResult struct {
Decision memcontract.Decision
Applied bool
}
DecisionApplyResult reports one controller-backed mutation application.
type DecisionControllerFactory ¶
type DecisionControllerFactory func(controller.TargetIndex) memcontract.Controller
DecisionControllerFactory builds the effective write controller for one store view. Store clones share the live factory registration.
type DecisionListQuery ¶
type DecisionListQuery struct {
Scope memcontract.Scope
WorkspaceID string
AgentName string
AgentTier memcontract.AgentTier
Operation string
TargetFilename string
Since time.Time
Reason string
Limit int
}
DecisionListQuery filters persisted controller decisions.
type DecisionRecord ¶
type DecisionRecord struct {
Decision memcontract.Decision
WorkspaceID string
AgentName string
AgentTier memcontract.AgentTier
AppliedAt *time.Time
}
DecisionRecord is the redaction-safe query model for persisted decisions.
type DecisionRevertResult ¶
DecisionRevertResult reports one deterministic rollback from memory_decisions.
type DerivedResetResult ¶
DerivedResetResult reports derived-catalog reset work.
type DreamCandidate ¶
type DreamCandidate struct {
ChunkID string
EntryID string
WorkspaceID string
Scope memcontract.Scope
AgentName string
AgentTier memcontract.AgentTier
Type memcontract.Type
Slug string
Filename string
Title string
Body string
RecallCount int
SessionCount int
RecallScore float64
LastRecalledAt time.Time
FreshnessStartedAt time.Time
Score float64
}
DreamCandidate is one unpromoted recall-signal candidate eligible for dreaming.
type DreamGateConfig ¶
type DreamGateConfig struct {
MinCandidates int
MinRecallCount int
MinScore float64
CandidateLimit int
HalfLife time.Duration
FrequencyWeight float64
RelevanceWeight float64
RecencyWeight float64
FreshnessWeight float64
}
DreamGateConfig controls the recall-signal gate that precedes dreaming.
type DreamRunListQuery ¶
type DreamRunListQuery struct {
Scope memcontract.Scope
WorkspaceID string
AgentName string
AgentTier memcontract.AgentTier
Limit int
}
DreamRunListQuery filters dreaming run records.
type DreamRunRecord ¶
type DreamRunRecord struct {
ID string
WorkspaceID string
Scope memcontract.Scope
AgentName string
AgentTier memcontract.AgentTier
Status string
InputCount int
PromotedCount int
Error string
Metadata map[string]string
StartedAt time.Time
FinishedAt *time.Time
}
DreamRunRecord is a redaction-safe memory_consolidations query row.
type FrozenSnapshot ¶
type FrozenSnapshot struct {
ID string
SessionID string
WorkspaceID string
WorkspaceRoot string
AgentName string
CapturedAt time.Time
Generation uint64
ControllerMode SnapshotControllerMode
InheritedFrom string
Blocks []SnapshotBlock
Header memcontract.CacheStableHeader
Section string
}
FrozenSnapshot is immutable prompt memory captured at a session boot boundary.
func (FrozenSnapshot) Clone ¶
func (s FrozenSnapshot) Clone() FrozenSnapshot
Clone returns a deep copy of the frozen snapshot.
type HeaderListPage ¶
type HeaderListPage struct {
Headers []memcontract.Header
NextCursor string
HasMore bool
Total int
Limit int
}
HeaderListPage is one filtered, ordered, counted memory header page.
func BuildHeaderListPage ¶
func BuildHeaderListPage(headers []memcontract.Header, query HeaderListQuery) (HeaderListPage, error)
BuildHeaderListPage filters and orders the complete visible catalog before applying a stable cut.
type HeaderListQuery ¶
type HeaderListQuery struct {
Scope memcontract.Scope
WorkspaceID string
AgentName string
AgentTier memcontract.AgentTier
Type memcontract.Type
IncludeSystem bool
Sort string
Cursor string
Limit int
}
HeaderListQuery captures one canonical memory catalog page request.
type Option ¶
type Option func(*Service)
Option configures a consolidation Service.
func WithDreamGateConfig ¶
func WithDreamGateConfig(config DreamGateConfig) Option
WithDreamGateConfig overrides recall-signal promotion thresholds for dreaming.
func WithLockPath ¶
WithLockPath configures the path to the consolidation lock file.
func WithLogger ¶
WithLogger injects the logger used for gate evaluation and run lifecycle logs.
func WithMemoryStore ¶
WithMemoryStore wires the memory store used for consolidation-path setup.
func WithMinHours ¶
WithMinHours overrides the minimum age threshold for the time gate.
func WithMinSessions ¶
WithMinSessions overrides the completed-session threshold for the session gate.
func WithSessionsDir ¶
WithSessionsDir configures the root directory containing persisted sessions.
func WithWorkspaceResolver ¶
func WithWorkspaceResolver(resolver workspacepkg.RuntimeResolver) Option
WithWorkspaceResolver wires workspace resolution for consolidation runs that need a workspace root path.
type PromptSnapshotRequest ¶
type PromptSnapshotRequest struct {
SessionID string
WorkspaceID string
WorkspaceRoot string
AgentName string
SessionType session.Type
ParentSnapshot *FrozenSnapshot
}
PromptSnapshotRequest identifies the session boot boundary being captured.
type RecallPromptOptions ¶
RecallPromptOptions controls prompt rendering for Packaged recall output.
type ReplayResult ¶
ReplayResult reports boot-time recovery work applied from memory_decisions.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service evaluates consolidation gates and runs the dream worker when the lock and thresholds allow it.
func NewService ¶
NewService constructs a Service with default gate thresholds and prompt.
type SessionSpawner ¶
type SessionSpawner func(ctx context.Context, goal, prompt, workspaceID string, lastConsolidatedAt time.Time) error
SessionSpawner starts a one-shot consolidation session with the provided goal, prompt, and normalized workspace ID. A blank workspace ID lets the spawner derive the eligible workspaces itself using the supplied timestamp from the most recent successful consolidation.
type SnapshotBlock ¶
type SnapshotBlock struct {
Scope memcontract.Scope
AgentTier memcontract.AgentTier
Title string
Markdown string
AgeMs int64
Truncated bool
Hash string
}
SnapshotBlock is one prompt-safe memory block captured at session boot.
type SnapshotControllerMode ¶
type SnapshotControllerMode string
SnapshotControllerMode describes the write posture attached to a captured snapshot.
const ( // SnapshotControllerWritable allows root sessions to propose memory writes. SnapshotControllerWritable SnapshotControllerMode = "writable" // SnapshotControllerReadOnly marks inherited sub-agent snapshots as non-mutating. SnapshotControllerReadOnly SnapshotControllerMode = "read_only" )
type SnapshotProvider ¶
type SnapshotProvider interface {
SystemPromptBlock(ctx context.Context, req memcontract.SnapshotRequest) (memcontract.SnapshotResult, error)
}
SnapshotProvider supplies prompt-safe provider blocks for frozen snapshots.
type SnapshotService ¶
type SnapshotService struct {
// contains filtered or unexported fields
}
SnapshotService captures prompt-safe memory once per session generation.
func NewSnapshotService ¶
func NewSnapshotService(store *Store, opts ...SnapshotServiceOption) *SnapshotService
NewSnapshotService constructs a frozen memory snapshot service.
func (*SnapshotService) Capture ¶
func (s *SnapshotService) Capture(ctx context.Context, req PromptSnapshotRequest) (FrozenSnapshot, error)
Capture freezes prompt-safe memory for the supplied session boot request.
func (*SnapshotService) InheritForSubAgent ¶
func (s *SnapshotService) InheritForSubAgent(parent FrozenSnapshot, req PromptSnapshotRequest) FrozenSnapshot
InheritForSubAgent clones a parent snapshot without re-resolving memory state.
func (*SnapshotService) InvalidateNextBoot ¶
func (s *SnapshotService) InvalidateNextBoot() uint64
InvalidateNextBoot records that future session boots must recapture memory.
type SnapshotServiceOption ¶
type SnapshotServiceOption func(*SnapshotService)
SnapshotServiceOption customizes frozen snapshot capture.
func WithProviderSnapshotSource ¶
func WithProviderSnapshotSource(provider SnapshotProvider) SnapshotServiceOption
WithProviderSnapshotSource installs the active provider snapshot source.
func WithSnapshotClock ¶
func WithSnapshotClock(now func() time.Time) SnapshotServiceOption
WithSnapshotClock injects a deterministic capture clock.
func WithSnapshotMaxCharacters ¶
func WithSnapshotMaxCharacters(maxCharacters int) SnapshotServiceOption
WithSnapshotMaxCharacters caps the rendered memory prompt section.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store manages memory files for the global and workspace scopes.
func NewStore ¶
func NewStore(globalDir string, opts ...StoreOption) *Store
NewStore constructs a Store for the provided global memory directory.
func (*Store) ApplyDecision ¶
func (s *Store) ApplyDecision(ctx context.Context, decision memcontract.Decision) (DecisionApplyResult, error)
ApplyDecision persists the Decision WAL row before applying the corresponding file mutation.
func (*Store) Candidates ¶
func (s *Store) Candidates( ctx context.Context, query memcontract.Query, opts memcontract.RecallOptions, ) ([]memoryrecall.Candidate, error)
Candidates implements recall.Source on top of the derived chunk catalog.
func (*Store) CatalogHeaders ¶
func (s *Store) CatalogHeaders(ctx context.Context, scope memcontract.Scope) ([]memcontract.Header, error)
CatalogHeaders lists every header for one bound storage identity without the prompt scan cap.
func (*Store) CloseCatalog ¶
CloseCatalog checkpoints and closes the optional catalog database.
func (*Store) CloseRecallSignalRecorders ¶
CloseRecallSignalRecorders drains and stops every async recall-signal worker.
func (*Store) DecideCandidate ¶
func (s *Store) DecideCandidate( ctx context.Context, candidate memcontract.Candidate, ) (memcontract.Decision, error)
DecideCandidate computes a controller decision without applying it.
func (*Store) Delete ¶
func (s *Store) Delete(scope memcontract.Scope, filename string) error
Delete removes a memory file and strips any matching entry from the local MEMORY.md index.
func (*Store) EnsureDirs ¶
EnsureDirs creates the configured memory directories when missing.
func (*Store) ForWorkspace ¶
ForWorkspace returns a clone of the store bound to the supplied workspace root.
func (*Store) HealthStats ¶
func (s *Store) HealthStats(ctx context.Context, workspaces []string) (memcontract.HealthStats, error)
HealthStats returns derived-catalog stats for the visible scopes.
func (*Store) History ¶
func (s *Store) History( ctx context.Context, query memcontract.OperationHistoryQuery, ) ([]memcontract.OperationRecord, error)
History returns durable memory operation history ordered newest-first.
func (*Store) List ¶
func (s *Store) List(scope memcontract.Scope) ([]memcontract.Header, error)
List is the backend-aligned alias for Scan.
func (*Store) ListDailyLogRecords ¶
func (s *Store) ListDailyLogRecords(ctx context.Context, query DailyLogListQuery) ([]DailyLogRecord, error)
ListDailyLogRecords returns memory-event daily summaries ordered newest first.
func (*Store) ListDecisionRecords ¶
func (s *Store) ListDecisionRecords(ctx context.Context, query DecisionListQuery) ([]DecisionRecord, error)
ListDecisionRecords returns persisted controller decisions ordered newest first.
func (*Store) ListDreamRunRecords ¶
func (s *Store) ListDreamRunRecords(ctx context.Context, query DreamRunListQuery) ([]DreamRunRecord, error)
ListDreamRunRecords returns persisted dreaming runs ordered newest first.
func (*Store) ListMemoryEventSummaries ¶
func (s *Store) ListMemoryEventSummaries( ctx context.Context, workspaces []string, query storepkg.EventSummaryQuery, ) ([]storepkg.EventSummary, error)
ListMemoryEventSummaries returns canonical memory events from every visible memory authority, keeping workspace DB rows visible to observe adapters.
func (*Store) ListTargets ¶
func (s *Store) ListTargets(ctx context.Context, candidate memcontract.Candidate) ([]controller.Target, error)
func (*Store) LoadDecisionRecord ¶
LoadDecisionRecord returns one persisted controller decision.
func (*Store) LoadDreamRunRecord ¶
LoadDreamRunRecord returns one persisted dreaming run.
func (*Store) LoadIndex ¶
LoadIndex reads MEMORY.md for a scope and truncates it to the prompt-safe limits.
func (*Store) LoadPromptIndex ¶
func (s *Store) LoadPromptIndex(scope memcontract.Scope) (content string, truncated bool, err error)
LoadPromptIndex is the backend-aligned alias for LoadIndex.
func (*Store) OpenCatalog ¶
OpenCatalog opens and migrates the optional catalog database. Composition roots call this explicitly after acquiring their database lifecycle lock.
func (*Store) ProposeBatch ¶
func (s *Store) ProposeBatch(ctx context.Context, proposal BatchProposal) (BatchApplyResult, error)
ProposeBatch stages a document-body batch and publishes one controller decision.
func (*Store) ProposeCandidate ¶
func (s *Store) ProposeCandidate( ctx context.Context, candidate memcontract.Candidate, ) (memcontract.Decision, error)
ProposeCandidate decides and applies one already-structured memory candidate.
func (*Store) ProposeDelete ¶
func (s *Store) ProposeDelete( ctx context.Context, scope memcontract.Scope, filename string, origin memcontract.Origin, ) (DecisionApplyResult, error)
ProposeDelete decides and applies a controller-backed memory delete.
func (*Store) ProposeWrite ¶
func (s *Store) ProposeWrite( ctx context.Context, scope memcontract.Scope, filename string, content []byte, origin memcontract.Origin, ) (DecisionApplyResult, error)
ProposeWrite decides and applies a controller-backed memory write.
func (*Store) Recall ¶
func (s *Store) Recall( ctx context.Context, query memcontract.Query, opts memcontract.RecallOptions, ) (memcontract.Packaged, error)
Recall returns prompt-ready deterministic memory recall output.
func (*Store) RecallSignalRecorderStats ¶
func (s *Store) RecallSignalRecorderStats(workspaceID string) memoryrecall.SignalRecorderStats
RecallSignalRecorderStats returns per-workspace async signal recorder counters.
func (*Store) RecordExtractorEvent ¶
RecordExtractorEvent persists canonical extractor telemetry into memory_events.
func (*Store) RecordMemoryWriteRejected ¶
func (s *Store) RecordMemoryWriteRejected(ctx context.Context, event WriteRejectedEvent) error
RecordMemoryWriteRejected emits an audit event for denied direct write attempts.
func (*Store) RecordRecall ¶
RecordRecall persists live recall signals for later dreaming gates.
func (*Store) RecordRecallExecuted ¶
func (*Store) RecordRecallSignalDropped ¶
func (s *Store) RecordRecallSignalDropped( ctx context.Context, query memcontract.Query, signals []memoryrecall.Signal, queueDepth int, ) error
func (*Store) RecordRecallSignalFailed ¶
func (*Store) RecordRecallSkipped ¶
func (*Store) RecordShadow ¶
func (*Store) Reindex ¶
func (s *Store) Reindex(ctx context.Context, opts memcontract.ReindexOptions) (memcontract.ReindexResult, error)
Reindex rebuilds the derived catalog from the Markdown source of truth.
func (*Store) ReplayPendingDecisions ¶
func (s *Store) ReplayPendingDecisions(ctx context.Context) (ReplayResult, error)
ReplayPendingDecisions applies unapplied memory_decisions rows idempotently.
func (*Store) ResetDerived ¶
func (s *Store) ResetDerived(ctx context.Context, opts memcontract.ReindexOptions) (DerivedResetResult, error)
ResetDerived clears derived catalog rows and rebuilds them from Markdown sources.
func (*Store) RevertDecision ¶
RevertDecision restores curated Markdown from one previously applied Decision row.
func (*Store) Scan ¶
func (s *Store) Scan(scope memcontract.Scope) ([]memcontract.Header, error)
Scan lists memory headers for a scope, sorted newest-first and capped at 200 files.
func (*Store) Search ¶
func (s *Store) Search( ctx context.Context, query string, opts memcontract.SearchOptions, ) ([]memcontract.SearchResult, error)
Search performs bounded lexical memory search across the visible scopes.
func (*Store) SetDecisionControllerFactory ¶
func (s *Store) SetDecisionControllerFactory(factory DecisionControllerFactory)
SetDecisionControllerFactory installs the daemon-owned live controller composition used by writes, batches, and dry-run decisions.
func (*Store) SourceHeaderCount ¶
func (s *Store) SourceHeaderCount(scope memcontract.Scope) (int, error)
SourceHeaderCount returns the complete count of valid source headers in one scope.
type StoreOption ¶
type StoreOption func(*Store)
StoreOption customizes a Store instance.
func WithCatalogDatabasePath ¶
func WithCatalogDatabasePath(path string) StoreOption
WithCatalogDatabasePath enables the derived SQLite-backed memory catalog in the shared global database file.
func WithFileLimits ¶
func WithFileLimits(config compozyconfig.MemoryFileConfig) StoreOption
WithFileLimits configures both curated body limits and prompt-index caps.
func WithRecallSignalRecorderConfig ¶
func WithRecallSignalRecorderConfig(config compozyconfig.MemoryRecallSignalsConfig) StoreOption
WithRecallSignalRecorderConfig configures asynchronous recall-signal writes.
type WriteRejectedEvent ¶
type WriteRejectedEvent struct {
Scope memcontract.Scope
WorkspaceID string
AgentName string
AgentTier memcontract.AgentTier
SessionID string
ActorKind string
TargetID string
Reason string
ToolID string
}
WriteRejectedEvent captures denied direct memory-write attempts.
Source Files
¶
- assembler.go
- batch.go
- batch_plan.go
- catalog.go
- catalog_dirty_marker.go
- catalog_document.go
- catalog_event.go
- catalog_event_ops.go
- catalog_identity.go
- catalog_lifecycle.go
- catalog_operations.go
- catalog_query.go
- catalog_readiness.go
- catalog_scan.go
- catalog_state.go
- catalog_sync_failure.go
- checkpoint_summary.go
- checkpoint_summary_state.go
- checkpoint_summary_update.go
- controlled_write.go
- decision.go
- decision_apply.go
- decision_catalog_read.go
- decision_catalog_write.go
- decision_checkpoint_revert.go
- decision_controller.go
- decision_events.go
- decision_query.go
- decision_records.go
- decision_revert.go
- document.go
- dream.go
- dream_lock.go
- dream_run.go
- dream_v2.go
- dream_v2_artifact.go
- dream_v2_events.go
- dream_v2_promotion.go
- dream_v2_run.go
- dream_workspace.go
- extractor_events.go
- header_catalog.go
- header_count.go
- header_list.go
- lock.go
- migration_stream.go
- mutation_raw.go
- observability.go
- observability_api.go
- observability_sources.go
- prompt.go
- query_records.go
- recall.go
- recall_source.go
- recall_source_events.go
- replay.go
- snapshot.go
- snapshot_service.go
- staleness.go
- store.go
- store_catalog.go
- store_index.go
- store_options.go
- store_revision.go
- store_scope.go
- store_sync.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package contract defines the shared Memory v2 data contract.
|
Package contract defines the shared Memory v2 data contract. |
|
Package prompts provides explicit, versioned Memory v2 prompt assets.
|
Package prompts provides explicit, versioned Memory v2 prompt assets. |
|
provider
|
|
|
Package scan provides deterministic Memory v2 pre-write content checks.
|
Package scan provides deterministic Memory v2 pre-write content checks. |
|
Package schema embeds the memory catalog schema and migration directory.
|
Package schema embeds the memory catalog schema and migration directory. |