Skip to content

Add searchable per-user memory and nightly dreaming - #2

Merged
Brendan O'Leary (olearycrew) merged 8 commits into
mainfrom
feat/searchable-memory
Nov 24, 2026
Merged

Brendan O'Leary (olearycrew) merged 8 commits into
mainfrom
feat/searchable-memory

Conversation

@olearycrew

@olearycrew Brendan O'Leary (olearycrew) commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Written by an AI agent on behalf of Brendan O'Leary (@olearycrew). Brendan O'Leary (@olearycrew) has not reviewed it yet.

Pidge previously forgot information between conversations. This adds per-user searchable notes, recalled long-term facts, a nightly consolidation pass (“dreaming”), and an authenticated /memory page for reviewing, confirming, correcting, and forgetting memories.

Behavior

  • PostgreSQL keyword search supplies up to 40 facts and five related notes before a turn. Reads and writes use the trusted Pidge principal and fail closed on a scope mismatch.
  • Automatic memory__save calls always create unconfirmed inferred notes. Dreamed facts remain inferred; model input cannot grant explicit provenance. Explicit facts and corrections come from authenticated /memory actions. Tool-driven forgetting requires Eve approval. Scheduled reports receive search only; notify hand-offs disable the slot.
  • Recall keeps operation-scoped references in Eve durable state, separately for turn start and compaction. A crash replay returns its original items after other memory is added. Forgetting or correcting a referenced item fails that replay closed; a new turn sees current memory. The replay cache holds no plaintext. Eve history and provider logs retain their existing copies.
  • Forgetting transactionally erases the entire connected provenance component in that user's partition. Explicit confirmation of a duplicate inferred fact detaches its sources. Corrections roll back if replacement fails. Per-user mutation locks and an active-text unique index protect capacity and deduplication.
  • Dreaming claims a five-minute lease before model work. Production calls have a two-minute timeout, zero automatic retries, a 4,000-token output cap, and at most 20 bounded facts. Apply rechecks the lease and every input; changed or forgotten input invalidates the entire proposal. Rejected source notes remain pending, and replacements work at the fact cap.
  • /memory shows the real pending count, pages through notes, and allows forgetting search results. Secret checks cover common key/card/password patterns, including Google and Stripe shapes, but remain heuristic.

Example automatic tool input: {"text":"May prefer aisle seats."} creates an inferred note. A person adds or confirms an explicit fact on /memory.

Evidence

All data and provider results were synthetic. No model, messaging, email, or live subscription calls were made.

$ TEST_DATABASE_URL=<isolated PostgreSQL 17> pnpm check
 Test Files  23 passed (23)
      Tests  151 passed (151)

$ TEST_DATABASE_URL=<isolated PostgreSQL 17> pnpm exec vitest run db/services/memory.test.ts db/migrations.test.ts agent/lib/memory/replay.test.ts agent/lib/memory/provider.test.ts
 Test Files  4 passed (4)
      Tests  25 passed (25)

The focused run includes two additional checks added after the full run: migration upgrades and bounded/stale dreaming output. Final typecheck, lint, build, and release privacy check passed (172 tracked paths). The release check initially rejected a synthetic address using example.test; the fixture now uses its accepted example.com domain.

Pinned Eve lifecycle regressions restore JSON-serialized durable state into a fresh context and exercise both turn-start and compaction recall after mutation. Other regressions cover complete provenance erasure, atomic capacity failures, explicit duplicate confirmation, concurrent saves, one model-stub call across eight simultaneous dreams, expired leases, forgotten dependencies, pending-note pagination, and secret-shaped inputs.

The migration test compares empty and original-memory-0005 upgrade paths, runs migrations twice, preserves synthetic preexisting rows, resolves old duplicate active rows without dropping their provenance, and compares resulting columns and indexes.

Migration and remaining verification

Apply 0005_memory then 0006_memory_safety via pnpm db:migrate. No new environment variables. PR #3 depends on this branch and adds the next trigger migration; merge #2 first, then #3. Neither PR is deployed by this work.

Live model capture quality, real dreaming, /memory browser interaction, and channel delivery remain unverified. Capture remains model-driven; ordinary user turns can still save an incorrect unconfirmed observation. Search is keyword-based. Exact normalized tombstones do not prevent semantic paraphrases of forgotten content, and forgetting does not erase conversation history, provider logs, or backups. Downtime during the local 3 a.m. hour skips that night's pass.

ELI5

Pidge keeps a searchable notebook for each person. It can suggest notes and summarize them overnight, but only the person can mark a fact as confirmed. The person can correct or erase the notebook at /memory.

Postgres-backed Eve memory slot: long-term facts and matching notes are
recalled before each model call; memory__save/search/forget tools; an
hourly schedule consolidates notes into facts at 3 a.m. local time; and a
/memory page to inspect, search, correct, and forget.
@wiz-1ca76d5187

Copy link
Copy Markdown

Wiz Scan Summary

Scanner Findings
Vulnerability Finding Vulnerabilities -
Data Finding Sensitive Data -
Secret Finding Secrets 1 Low
IaC Misconfiguration IaC Misconfigurations -
SAST Finding SAST Findings -
Software Management Finding Software Management Findings -
Total 1 Low

View scan details in Wiz

To detect these findings earlier in the dev lifecycle, try the Wiz Code extension for VS Code, JetBrains, or Visual Studio.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant