Documentation
¶
Overview ¶
Package dream is the nightly consolidation pass — logos sleeping on the day.
It runs in two phases. NREM (cheap, deterministic, first) stabilises the memory store: it replays the day's salient experience, extracts gist from recurring structure, and counts what disuse has faded (decay itself is applied at read time, never stored). REM (expensive, model-driven, last) recombines the cleaned store into candidate connections — the engine behind the mirror.
The house rules hold throughout. Compute, then narrate: what to replay and bridge is chosen by arithmetic; the model only phrases a connection. Propose, don't assert: NREM's structural maintenance is the same deterministic upkeep already trusted to run headless, but every REM inference is an Insight in this queue — never a silent write.
Index ¶
- Constants
- func Accept(db *sql.DB, p *provider.Provider, embedModel string, in Insight) (bool, error)
- func Enqueue(db *sql.DB, in *Insight) error
- func Import(db *sql.DB, dir string) (int, error)
- func InitQueue(db *sql.DB) error
- func InsightsPath(dir string) string
- func PendingCount(db *sql.DB) (int, error)
- func Reconcile(db *sql.DB) (restored, removed int, err error)
- func SetStatus(db *sql.DB, id int64, s Status) error
- func SetVault(db *sql.DB, dir string)
- type Insight
- type Kind
- type Result
- type Status
Constants ¶
const ( PhaseNREM = "nrem" PhaseREM = "rem" PhaseAll = "all" )
Phase selects which half of the night to run. NREM stabilises; REM recombines. REM always runs after NREM so it works over the cleaned, compressed store.
const InsightsFile = "dream-insights.md"
InsightsFile is the queue's name at the vault root.
const MaxInsights = 3
MaxInsights caps how many connections a single night may propose. A review queue flooded with speculation is a queue the user stops reading, and an unread queue is the same as no confirmation gate at all.
const QueueSchema = `` /* 435-byte string literal not displayed */
Variables ¶
This section is empty.
Functions ¶
func Accept ¶
Accept turns a reviewed insight into a memory. It enters the store at the "dream" confidence (0.5) and a modest salience: a hypothesis that must earn belief through corroboration on the ordinary reinforcement path, never one that outranks a fact the user stated. The insight itself is marked accepted, not deleted, so the decision stays on the record.
func Import ¶
Import restores dreamed insights from the vault, and is what makes deleting the cache survivable for them.
dir is the caller's rather than vaultFor's: `logos index` imports a vault it has not bound to a store yet.
Returns how many insights it had to put back — a row already in the cache was never lost and is not announced as recovered.
func InsightsPath ¶
InsightsPath is where the queue lives inside dir. Exported because index.Sync has to know which file in the vault root it must not index.
func Reconcile ¶ added in v0.5.1
Reconcile adopts hand edits to the queue file now, and reports how many insights the file put back and how many it discarded.
Exported for `logos dream review` and its accept/reject: only writes used to reconcile, so the review listed an insight the user had deleted from the file, and a write that did adopt the deletion said nothing about it.
Types ¶
type Insight ¶
type Insight struct {
ID int64
Kind Kind
Text string // the synthesised observation, one or two sentences
EndpointA int64 // memory id it bridges from
EndpointB int64 // memory id it bridges to
Conf float64
Model string
Created int64
Status Status
}
Insight is a REM proposal awaiting review. It is modelled on rollup.Proposal, but its terminal is the memory store, not the vault: accepting one stores a low-confidence memory that then lives or fades in the ordinary decay loop.
Both endpoints are mandatory and enforced at write time — this is the hallucination filter. A connection that cannot name the two real memories it bridges is a fabrication with good manners, and it must be impossible to queue.
type Kind ¶
type Kind string
Kind is what a dreamed insight would become if accepted.
const ( // Connection: a non-obvious link between two things the assistant already // knows — a shared theme, a tension, or an idea one suggests about the other. Connection Kind = "connection" // Thread: a candidate line of work the day's activity hints at, synthesised // from more than one memory. Thread Kind = "thread" )
type Result ¶
type Result struct {
Date string
Replayed int // memories re-affirmed by consolidation (merged + superseded)
Merged int // near-duplicates folded
Superseded int // stale facts replaced
Faded int // memories disuse has ranked well below their stored salience
Insights int // REM connections proposed for review
REMSkipped bool // REM could not run (no reasoning model)
// ReplaySkipped is true when consolidation could not run because no model
// was reachable. Distinct from "nothing to consolidate", which is what a
// swallowed error used to look like.
ReplaySkipped bool
}
Result is what a night's sleep did (or, under dry run, would do).
func Run ¶
func Run(db *sql.DB, vaultDir string, rt *router.Router, date time.Time, phase string, dryRun bool) (Result, error)
Run executes the consolidation pass for one day. NREM's structural edits are deterministic maintenance and run headless; REM's inferences become Insights in the review queue. Under dryRun nothing is written — the Result reports what the pass would change, so a night of sleep is auditable before it is trusted.
date and embedModel are accepted for compatibility with a per-night result (the Date field) and were formerly also used to scope gist extraction over a window of captured events; that step was cut in 0.3.0 along with the rest of ambient capture, so both nrem and rem now work purely over the memory store.