Documentation
¶
Overview ¶
Package dream implements opt-in background memory consolidation. Planning and application are deliberately separate: GeneratePlan only inspects memory and consults the model, while ApplyPlan is the mutation boundary. Consolidate keeps the original one-call entry point by running those phases serially.
Index ¶
- func SupportsReviewedPlan(store tool.MemoryStore) bool
- type Config
- type Consolidator
- func (c *Consolidator) ApplyPlan(ctx context.Context, plan Plan) (Report, error)
- func (c *Consolidator) ApplyReviewedPlan(ctx context.Context, plan Plan) (Report, error)
- func (c *Consolidator) Consolidate(ctx context.Context) (Report, error)
- func (c *Consolidator) GenerateManualPlan(ctx context.Context) (Plan, error)
- func (c *Consolidator) GeneratePlan(ctx context.Context) (Plan, error)
- func (c *Consolidator) RunPeriodically(ctx context.Context, interval time.Duration, onError func(error)) error
- func (c *Consolidator) RunPeriodicallyWithReport(ctx context.Context, interval time.Duration, onReport func(Report, error)) error
- type OperationKind
- type Plan
- type Report
- type ReviewOperation
- type ReviewParticipant
- type ReviewPlan
- type ReviewReplacement
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SupportsReviewedPlan ¶
func SupportsReviewedPlan(store tool.MemoryStore) bool
SupportsReviewedPlan reports whether store preserves both atomic capabilities required to apply every reviewed operation family. It does not inspect or mutate the store.
Types ¶
type Config ¶
type Config struct {
Model string
Prefix string
MaxEntries int
MinEntriesToRun int
// MaxInputBytes bounds the complete user message sent to the planner. Entries
// that do not fit are skipped; individual values are never truncated.
MaxInputBytes int
// MaxForgets caps admitted source retirements. Zero selects the historical
// default; a negative value disables application while still reporting the
// normalized proposals as skipped.
MaxForgets int
Timeout time.Duration
}
Config tunes the Consolidator. Zero values select package defaults.
type Consolidator ¶
type Consolidator struct {
// contains filtered or unexported fields
}
Consolidator owns the rotating selection cursor and a context-aware gate. The gate serializes GeneratePlan, ApplyPlan, and Consolidate for this instance.
func New ¶
func New(store tool.MemoryStore, llm port.LLMProvider, cfg Config) *Consolidator
New constructs a Consolidator using llm for plan generation.
func (*Consolidator) ApplyPlan ¶
ApplyPlan is the explicit mutation boundary. Only a store with atomic duplicate retirement can apply a version-bound plan; every other store reports normalized proposals as skipped without invoking any mutation method.
func (*Consolidator) ApplyReviewedPlan ¶
ApplyReviewedPlan applies the retained, instance-bound plan after explicit human approval. Synthesis operations are atomic per operation; independent operations continue after a conflict or failure.
func (*Consolidator) Consolidate ¶
func (c *Consolidator) Consolidate(ctx context.Context) (Report, error)
Consolidate preserves the original one-call API without recursively acquiring the instance gate.
func (*Consolidator) GenerateManualPlan ¶
func (c *Consolidator) GenerateManualPlan(ctx context.Context) (Plan, error)
GenerateManualPlan generates an operator-requested review when at least two entries are eligible. It shares GeneratePlan's gate, rotating selection, and planner while leaving the scheduled MinEntriesToRun threshold unchanged.
func (*Consolidator) GeneratePlan ¶
func (c *Consolidator) GeneratePlan(ctx context.Context) (Plan, error)
GeneratePlan selects a bounded rotating window, binds convergence-store candidates to their exact inspected revisions, and consults the planner when the configured scheduled threshold is met. It never mutates the store.
func (*Consolidator) RunPeriodically ¶
func (c *Consolidator) RunPeriodically(ctx context.Context, interval time.Duration, onError func(error)) error
RunPeriodically preserves the original error-only callback API.
func (*Consolidator) RunPeriodicallyWithReport ¶
func (c *Consolidator) RunPeriodicallyWithReport(ctx context.Context, interval time.Duration, onReport func(Report, error)) error
RunPeriodicallyWithReport drives Consolidate on a ticker and reports every completed attempt, including partial reports accompanied by an error.
type OperationKind ¶
type OperationKind string
OperationKind identifies one reviewed consolidation operation family.
const ( // OperationExactDuplicate retires byte-identical sources without rewriting the survivor. OperationExactDuplicate OperationKind = "exact_duplicate" // OperationSynthesizedReplacement revises the survivor and atomically retires its sources. OperationSynthesizedReplacement OperationKind = "synthesized_replacement" )
type Plan ¶
type Plan struct {
// contains filtered or unexported fields
}
Plan is an opaque, instance-bound consolidation plan. Its wire operations and inspected memory bindings remain private to avoid making model grammar a public package contract.
func (Plan) Review ¶
func (p Plan) Review() ReviewPlan
Review returns a version-free copy of the exact retained plan bytes. Model-authored text that canonicalization would alter is rejected before a Plan is retained.
type Report ¶
type Report struct {
Planned int
Applied int
Conflicted int
Skipped int
Failed int
// Legacy fields remain while callers migrate to operation accounting.
Kept int
Merged int
Forgotten int
}
Report summarises one consolidation run. The operation accounting fields are designed so Planned = Applied + Conflicted + Skipped + Failed.
type ReviewOperation ¶
type ReviewOperation struct {
Kind OperationKind
Survivor ReviewParticipant
Sources []ReviewParticipant
Replacement ReviewReplacement
Reason string
ExactDuplicateEligible bool
}
ReviewOperation is one ordered, detached operation shown for approval.
type ReviewParticipant ¶
ReviewParticipant contains a participant's reviewable content without its version.
type ReviewPlan ¶
type ReviewPlan struct {
Operations []ReviewOperation
}
ReviewPlan is a detached, version-free projection for human review. Review returns a fresh deep copy, so changing it cannot alter the retained Plan.
type ReviewReplacement ¶
ReviewReplacement contains the proposed reviewed survivor content.