Skip to content

feat: bridge per-agent SQLite memories to local memu (#38) - #41

Merged
mfethe1 merged 1 commit into
sandcastle/openclaw-memory-prd-basefrom
sandcastle/issue-38-feat-bridge-per-agent-sqlite-memories-to-local-memu
May 6, 2026
Merged

feat: bridge per-agent SQLite memories to local memu (#38)#41
mfethe1 merged 1 commit into
sandcastle/openclaw-memory-prd-basefrom
sandcastle/issue-38-feat-bridge-per-agent-sqlite-memories-to-local-memu

Conversation

@mfethe1

@mfethe1 mfethe1 commented May 6, 2026

Copy link
Copy Markdown
Owner

Closes #38

Changes

  • tools/sqlite_bridge.py (427 lines) — scans ~/.openclaw/memory/*.sqlite, runtime schema detection, read-only SQLite opens, POSTs to memu with idempotency_key=sqlite:<agent>:<rowid>, --once / --watch modes
  • tools/__init__.py — package marker
  • tests/test_sqlite_bridge.py (553 lines) — 46 tests: column detection, type mapping, dedup, state persistence, mocked HTTP, multi-file sweep; 46 passed in 0.96s

Usage on mack

python3 tools/sqlite_bridge.py --dir ~/.openclaw/memory --url http://localhost:8000
# ongoing sync:
python3 tools/sqlite_bridge.py --dir ~/.openclaw/memory --watch --interval 60

Schema verification on mack pending — bridge uses runtime inspection + fallback, so it handles unknown schemas gracefully.

🤖 Sandcastle agent

Implements tools/sqlite_bridge.py — a bridge script that scans
~/.openclaw/memory/*.sqlite, converts each row to a memu MemoryRecord,
and POSTs to localhost:8000/memories with agent_id set to the source
agent name.

Key design decisions:
- memory_kind=evidence + idempotency_key=sqlite:<agent>:<rowid> for
  reliable dedup: same key + same content returns the existing record
- Local state file tracks last imported rowid per SQLite file so only
  new rows are forwarded on incremental runs
- Schema inspection at runtime: picks common column names (value/content,
  type/memory_type, created_at/timestamp) and falls back to serialising
  all non-null fields
- Opens SQLite read-only via URI to avoid accidental writes
- Identifier validation guards against unsafe table names
- Supports --once (default) and --watch (continuous polling) modes

Tests in tests/test_sqlite_bridge.py cover column detection, type
mapping, row-to-payload conversion, SQLite reading, state persistence,
mocked memu HTTP calls, single-file sync with dedup, and multi-file sweep.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@mfethe1
mfethe1 merged commit 16dcf4e into sandcastle/openclaw-memory-prd-base May 6, 2026
1 check failed
@mfethe1
mfethe1 deleted the sandcastle/issue-38-feat-bridge-per-agent-sqlite-memories-to-local-memu branch May 6, 2026 17:37
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