Skip to content

feat: persist learnings as markdown files for backup and portability #50

Closed

Description

@jflowers

Problem

Learnings stored via store_learning exist only in graph.db (SQLite). If the database is deleted, corrupted, or the user moves to a new machine, all learnings are permanently lost. There is no export, backup, or version-controllable representation of stored learnings.

This is especially risky because learnings are the append-only event log that dewey compile uses to produce knowledge articles. Losing the learnings means losing the source of truth — compiled articles can be rebuilt, but only if the learnings exist.

Proposal

Persist each learning as a markdown file alongside the database entry. When store_learning is called, write a .md file to .uf/dewey/learnings/ with the learning content and metadata as YAML frontmatter:

.uf/dewey/learnings/
  authentication-1.md
  authentication-2.md
  vault-walker-1.md
  deployment-1.md

Each file:

---
tag: authentication
category: decision
created_at: 2026-04-19T15:04:26Z
identity: authentication-1
---

Team decided to switch from API keys to OAuth2.
Reason: API keys don't support scoping.
Timeout: 30 seconds.

Benefits

  1. Backup: Learnings survive graph.db deletion — dewey index can re-ingest them from the markdown files
  2. Version control: Learnings can be committed to git alongside sources.yaml and config.yaml (the .gitignore patterns only exclude graph.db, dewey.log, and dewey.lock — the learnings/ directory would be trackable)
  3. Portability: Copy .uf/dewey/ to a new machine and all learnings come along
  4. Human-readable audit trail: Developers can browse learnings without querying the database
  5. Team sharing: Committed learnings are shared via git — team members get each other's learnings automatically

Design Considerations

  • Dual-write: store_learning writes to both SQLite (for search/embedding) and markdown (for persistence/backup). The database is the primary store; markdown is the backup.
  • Re-ingestion: On dewey serve startup or dewey index, if learnings exist as .md files but not in the database (e.g., after graph.db deletion or on a new machine), they should be re-ingested automatically.
  • Filename: {tag}-{sequence}.md matches the learning identity scheme.
  • Idempotent: Writing the same learning twice produces the same file (no duplicates).
  • .gitignore compatibility: The existing granular patterns don't exclude .uf/dewey/learnings/ — learnings are trackable by default.

Related

Activity

  1. jflowers commented on Apr 23, 2026

    @jflowers
    ContributorAuthor

    Completed in PR #51 (spec 015-curated-knowledge-stores). File-backed learning persistence implemented as User Story 1:

    • store_learning dual-writes to SQLite + .uf/dewey/learnings/{tag}-{seq}.md
    • YAML frontmatter with tag, category, created_at, identity, tier
    • Auto re-ingestion on dewey serve startup when graph.db is missing
    • 14 new tests covering dual-write, format, graceful failure, and re-ingestion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions