An OpenClaw skill that replaces file-based memory ingestion with SQL-backed storage, while preserving full dreaming pipeline compatibility.
OpenClaw's native memory-core dreaming system reads from memory/YYYY-MM-DD.md files — flat text logs that contain everything: debug noise, error traces, real decisions, and meaningful insights all mixed together. The dreamer can't distinguish signal from noise without a priority filter.
This skill solves that by:
- Feeding the dreamer from SQL — queries your database for high-importance memories (configurable threshold) and writes a clean daily memory file before the dream cycle runs.
- Archiving dream outputs back to SQL — after each dream cycle, structured dream data (light/REM/deep phases) is stored durably in SQL instead of living only as files.
- Keeping the filesystem lean — dream output files older than N days are pruned automatically.
- Providing a stable foundation for future wiki-to-Confluence publishing.
The OpenClaw dreamer still runs exactly as designed. This skill is a wrapper around it, not a replacement.
┌─────────────────────────────────┐
│ SQL Database │
│ memory.Memories (importance) │
│ dreams.DreamCorpus │
│ dreams.DreamLight │
│ dreams.DreamREM │
│ dreams.DreamDeep │
└────────┬─────────────┬────────────┘
│ │
[3:00 AM]│ │[4:00 AM]
pre_dream│ │post_dream
sql_feed │ │archiver
▼ │
memory/YYYY-MM-DD.md │
(clean, curated) │
│ │
[3:30 AM]│ │
┌────────▼─────────┐ │
│ OpenClaw native │ │
│ dream cycle │ │
│ (unchanged) │ │
└────────┬─────────┘ │
│ │
memory/dreaming/ │
├── light/YYYY-MM-DD.md │
├── rem/YYYY-MM-DD.md │
└── deep/YYYY-MM-DD.md │
└─────────────┘
│
[4:30 AM]│ (optional)
confluence_publisher
│
▼
Confluence Memory Palace
- OpenClaw installed and configured
- SQL Connector skill (v2.0.0+, required) — the secure SQL Server bridge this skill depends on
- Install via:
clawhub install sql-connector(recommended) orpip install clawbot-sql-connector
- Install via:
- SQL Memory skill (recommended) — provides the
memory.Memoriestable structure this skill reads from- Install via:
clawhub install sql-memory - Without it, you'll need to create
memory.Memoriesmanually or populate via another method
- Install via:
- SQL Server (on-prem, cloud Azure SQL, site4now, etc.) — accessible from your network
- Python 3.10+
.envfile with database credentials (see Configuration)
Note: memory-core is OpenClaw's native dreaming system (built-in to OpenClaw). This skill wraps it — no separate install needed.
# Install this skill and its dependencies
clawhub install sql-dreamer
clawhub install sql-connector # required — SQL Server bridge
clawhub install sql-memory # recommended — SQL-backed memory tables# 1. Clone the repo
git clone https://github.com/High-Falootin/openclaw-SQL-dreamer.git
cd openclaw-SQL-dreamer
# 2. Install dependencies (skip if running inside OpenClaw — already installed)
pip install -r requirements.txt
# 3. Copy and fill in config
cp config/example.yml config/config.yml
# Edit config/config.yml with your SQL credentials and settings
# 4. Run schema migration
python sql/migrate.py
# 5. Test the pre-dream feed
python scripts/pre_dream_sql_feed.py --dry-run
# 6. Add to crontab (adjust for your timezone)
# See: Crontab Integration section belowCopy config/example.yml and fill in your values. Never commit config/config.yml — it's in .gitignore.
# config/example.yml — copy to config/config.yml and fill in values
sql:
server: "your-sql-server-hostname" # e.g. 10.0.0.110 or sql.example.com
database: "Oblio_Memories" # your database name
username: "your_sql_username" # SQL auth username
password: "" # leave blank, set via env SQL_PASSWORD
# Alternatively, use a full connection string:
# connection_string: "DRIVER={ODBC Driver 17 for SQL Server};SERVER=...;"
corpus:
importance_threshold: 7 # Min importance score to include in dream corpus (1-10)
lookback_days: 2 # How many days back to pull memories
dreaming:
workspace_dir: "/path/to/.openclaw/workspace" # OpenClaw workspace root
phases:
light:
enabled: true
rem:
enabled: true
deep:
enabled: true
archive_after_days: 7 # Delete dream .md files older than this
confluence:
enabled: false # Set true to enable Confluence publishing
domain: "" # e.g. yourorg.atlassian.net
email: "" # Atlassian account email
api_token: "" # leave blank, set via env CONFLUENCE_API_TOKEN
space_key: "" # Confluence space key
parent_page_id: "" # Parent page ID for Memory PalaceEnvironment variables (override config, never commit values):
SQL_PASSWORD=your_sql_password
CONFLUENCE_API_TOKEN=your_tokenAdd these entries to your crontab (crontab -e). Adjust timezone as needed (shown in EDT = UTC-4):
# Pre-dream SQL feed: populate clean memory file from SQL (30 min before dream cycle)
0 7 * * * /path/to/python /path/to/openclaw-SQL-dreamer/scripts/pre_dream_sql_feed.py >> /var/log/oblio/pre_dream.log 2>&1
# OpenClaw native dream cycle: 3:30 AM EDT (07:30 UTC) — configured in openclaw.json
# This runs automatically via OpenClaw's memory-core cron. No crontab entry needed.
# Post-dream archiver: archive outputs to SQL + cleanup (1 hr after dream cycle)
0 8 * * * /path/to/python /path/to/openclaw-SQL-dreamer/scripts/post_dream_archiver.py >> /var/log/oblio/post_dream.log 2>&1
# Confluence publisher (optional, runs after archiver)
30 8 * * * /path/to/python /path/to/openclaw-SQL-dreamer/scripts/confluence_dream_publisher.py >> /var/log/oblio/confluence.log 2>&1All tables live in the dreams schema. Run sql/migrate.py to create them.
| Table | Purpose |
|---|---|
dreams.DreamCorpus |
Curated memories queued for each dream cycle (filtered from memory.Memories) |
dreams.DreamLight |
Light sleep candidates and phase signal equivalents |
dreams.DreamREM |
REM sleep themes and pattern reflections |
dreams.DreamDeep |
Deep sleep promotions — durable recall entries |
OpenClaw's dreaming system runs three sequential phases each night:
Ingests recent daily memory files and session transcripts. Ranks entries by recency + recall frequency. Writes top N candidates as "Imported Insights" — things that surfaced recently and deserve attention.
SQL mapping: dreams.DreamLight stores each candidate with its confidence score, evidence source, recall count, and status (staged → promoted).
Processes short-term recall store. Finds patterns and themes across multiple sessions. Reflects on recurring concepts (what kept surfacing?). Synthesizes "Possible Lasting Truths."
SQL mapping: dreams.DreamREM stores theme entries with frequency counts, supporting evidence, and confidence levels.
Promotes high-scoring short-term memories to durable (MEMORY.md / long-term). Uses weighted scoring: recall frequency × recency × query diversity. Only entries meeting minimum score + recall thresholds are promoted.
SQL mapping: dreams.DreamDeep stores promotions with scoring breakdown and promotion timestamp.
Test individual components in isolation:
pytest tests/test_sql_connector.py
pytest tests/test_pre_dream_sql_feed.py
pytest tests/test_post_dream_archiver.py
pytest tests/test_phase_signal_reconciler.py
pytest tests/test_light_sleep_synthesizer.pyOr run all unit tests:
pytest tests/ -vTest the complete pipeline from empty state:
pytest tests/test_integration_pipeline.py -vWhat these tests verify:
- Empty-state initialization — skill can start from zero (no files, no DB state)
- Memory file creation — pre_dream_sql_feed.py correctly creates memory/YYYY-MM-DD.md
- Full pipeline — complete workflow: pre-feed → native dreamer → post-archiver
- Dream output validation — dream files have correct structure (light/REM/deep phases)
- Noise filtering — low-importance items excluded, high-importance preserved
- Confluence compatibility — outputs ready for wiki publishing
These tests use a mock dreamer (tests/mock_dreamer.py) that simulates OpenClaw's native dreaming without requiring the actual dreamer to run. This allows us to test the full pipeline deterministically.
pytest tests/ -v # All 81 tests (71 unit + 10 integration)Expected output: 81 passed, 8 skipped (skipped tests require live DB connection)
- Phase 1 (Scripts): SQL connector, pre-dream feed, post-dream archiver, phase signal reconciler
- Phase 2 (Synthesis): Light sleep scoring, theme extraction, deep sleep promotion
- Phase 3 (Integration): Full pipeline from empty state, empty-state initialization, noise filtering, wiki compatibility
- Fork the repo
- Create a feature branch:
git checkout -b feature/your-feature - Make changes with tests
- Run
pytest tests/— all tests must pass - Open a PR against
developmentbranch
Never commit secrets, credentials, or personal data. This is a public repository.
Published to: clawhub.ai as sql-dreamer
Install: clawhub install sql-dreamer
Current version: 0.1.0
Version policy: Stable releases only. We run this in production nightly and publish after thorough validation.
Compatibility:
- Python 3.10+
- OpenClaw (memory-core dreaming enabled)
- SQL Server 2019+ (including Azure SQL)
- Requires:
sql-connectorskill v2.0.0+ - Recommends:
sql-memoryskill formemory.Memoriestable
MIT — see LICENSE
- OpenClaw — the AI assistant platform this skill extends
- ClawHub — the OpenClaw skill registry
- sql-connector — required — sealed SQL Server bridge (
clawhub install sql-connector) - sql-memory — recommended — SQL-backed memory tables (
clawhub install sql-memory)