Skip to main content

Module reflection

Module reflection 

Source
Expand description

Reflection pass — Auto-Dream-compatible semantic housekeeping.

run_reflection_pass walks a single agent’s memories and applies four normalising sweeps in order:

  1. Date absolutization (Task 10) — rewrite relative temporal phrases ("yesterday", "last week", "N days ago", "tomorrow") into ISO-8601 dates anchored on each record’s created_at.
  2. Semantic dedup — any two memories whose embeddings have cosine similarity ≥ 0.92 collapse into a single record that unions their tags and sums their access_count. The older record is moved to the Consolidated state and a consolidated_from relation is inserted.
  3. Low-importance conflict resolution — run detect_conflicts and, for any conflict where both sides have importance < 0.3, apply ResolutionStrategy::KeepNewest.
  4. Stale archival — mark records Archived when their effective_importance < 0.2, their access_count == 0, and their age exceeds the configured threshold (default 7 days).

The pass is exposed as MnemoEngine::run_reflection_pass and is safe to schedule on a periodic tick (default cadence 24h, driven from the CLI).

Structs§

DreamReport
Auto Dream organization-report trailer. Parser is permissive — matches whichever of these three keys appears: consolidated, removed, reindexed (case-insensitive, values are base-10 integers after a colon or equals sign). Missing keys default to zero.
ReflectionReport
Result of a single reflection pass.

Enums§

ReflectionMode
Controls when the reflection pass runs its expensive phases.
SkipReason
Why a Coordinated pass decided to skip, when it did.

Constants§

MIN_HOURS_BETWEEN_COORDINATED_RUNS
Minimum interval (in hours) between Coordinated passes for one agent. Matches Auto Dream’s 24h cadence.
MIN_NEW_RECORDS_FOR_COORDINATED_RUN
Minimum number of newly-written records (since last_reflection_at) that must exist before a Coordinated pass runs. Matches Auto Dream’s floor.

Functions§

absolutize_dates
Absolutize relative temporal expressions in content. Returns Some when the content was modified.
parse_organization_report
Parse an Auto Dream organization-report trailer from free text. Returns None when no ## Organization Report header is present.
run_reflection_pass
Back-compat entry point — runs the reflection pass unconditionally (equivalent to run_reflection_pass_with_mode(_, _, Always, true)).
run_reflection_pass_with_mode
Run a reflection pass honouring mode.