Skip to content

Niraven/sigil-memory

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sigil v0.2.0

Sigil

An inscribed symbol believed to hold power.

In ancient practice, a sigil is a symbol charged with intent -- drawn to encode meaning that persists beyond the moment. Sigil the library does the same for AI agents: it inscribes memory, knowledge, and coordination into a single artifact that holds power long after the conversation ends.

147 Tests Sub-ms Zero Deps MIT Python 3.10+ 11 Modules 12 Personas


The cognitive backbone your AI agents are missing.

Sub-millisecond memory. Knowledge graphs. Multi-agent sync. Swarm orchestration. 27 personas. 147 tests. One SQLite file. Zero cloud. Zero subscriptions. Free forever.


Why "Sigil"?

A sigil is an inscribed symbol believed to hold power -- a glyph charged with intent, drawn to make the invisible persistent.

Your AI agents think brilliantly for one conversation, then forget everything. Every insight, every preference, every learned pattern -- gone. Sigil changes that. It inscribes your agents' knowledge into a single, persistent artifact that survives across sessions, across agents, across time.

One symbol. All the power.


The Problem

Every AI memory system makes you choose your poison:

System The Catch
Mem0 Cloud-only. $19-249/mo. Your data leaves your machine.
Zouroboros Requires Qdrant + Ollama. 5-layer architecture for what should be a library.
Mnemosyne Good locally, but no multi-agent sync. No orchestration. Plugin-only.
Honcho PostgreSQL + Redis + pgvector. Enterprise deployment for pip install.
Supermemory Cloud-only. Opaque internals. Vendor lock-in.
Mengram Cloud API dependency. Every operation is an HTTP round-trip. $19-249/mo.
OpenFang 137K LOC Rust binary. It's an entire OS, not a library.

Sigil: 11 modules. One import. One file. Zero cloud. Zero cost.


What Sigil Does (In 30 Seconds)

from sigil import Sigil

cx = Sigil("brain.db", agent_id="agent-1")

# 4-type memory system
cx.remember("User prefers dark mode", type="semantic", importance=0.9)
cx.remember("Deployed v2.1 successfully", type="episodic", outcome="success")
cx.remember("Deploy flow", type="procedural", steps=["build", "test", "push"])
cx.remember("Currently debugging auth", type="working")  # auto-expires

# 5-signal hybrid recall
results = cx.recall("deployment preferences", top_k=5)
# Combines: FTS5 + vector similarity + importance + recency + entity boost

# Knowledge graph with temporal triples
cx.learn("alice", "manages", "project-x")
cx.learn("alice", "worked_at", "old-corp", valid_until="2025-01-01")  # auto-invalidates
profile = cx.about("alice")  # full entity profile

# Proactive briefing (what your agent needs before you ask)
brief = cx.activate(persona="engineer", session_context="auth migration")

# Multi-agent sync (event-driven, sub-10s latency)
cx.sync.emit("decision_made", {"what": "use postgres for auth"})
events = cx.sync.pull()  # events from other agents

# Swarm orchestration with DAG execution
result = cx.orchestrate([
    {"id": "research", "prompt": "Find auth best practices"},
    {"id": "build", "prompt": "Implement it", "depends_on": ["research"]},
])
# 9-signal model routing, circuit breakers, budget awareness

# 12 composable personas
cx.set_persona("engineer")
prompt = cx.system_prompt(context="fixing auth bugs")

# Sleep consolidation (compress old memories)
cx.sleep()  # working memory -> episodic summaries

# Self-healing
health = cx.check_health(output="...", error="timeout")

Architecture

                    ┌────────────────────────────────┐
                    │          SIGIL API              │
                    │   remember() | recall()         │
                    │   activate() | orchestrate()    │
                    │   learn()    | set_persona()    │
                    └──────────────┬─────────────────┘
                                   │
     ┌──────────┬──────────┬───────┼───────┬──────────┬──────────┐
     │          │          │       │       │          │          │
┌────▼────┐ ┌──▼────┐ ┌───▼──┐ ┌─▼────┐ ┌▼─────┐ ┌──▼───┐ ┌───▼──┐
│ MEMORY  │ │ GRAPH │ │ PKA  │ │SWARM │ │ A2A  │ │ PROJ │ │ SOUL │
│ ENGINE  │ │       │ │      │ │      │ │BRIDGE│ │ MGMT │ │      │
│         │ │Tempo- │ │Proac-│ │DAG   │ │      │ │      │ │12+   │
│4 types  │ │ral    │ │tive  │ │exec  │ │Event │ │Tasks │ │built │
│Hybrid   │ │triples│ │brief-│ │Model │ │bus   │ │Miles-│ │-in   │
│recall   │ │Entity │ │ings  │ │route │ │JSONL │ │tones │ │roles │
│FTS5+vec │ │auto-  │ │Open  │ │Circ. │ │<10s  │ │Deps  │ │Compo-│
│Sleep    │ │inval  │ │loops │ │break │ │Sync  │ │Block │ │sable │
│Entity   │ │Boost  │ │Cross-│ │Budget│ │      │ │-ers  │ │Adapt │
│linking  │ │score  │ │domain│ │aware │ │      │ │      │ │-ive  │
└─────────┘ └───────┘ └──────┘ └──────┘ └──────┘ └──────┘ └──────┘
     │          │          │       │        │         │         │
     └──────────┴──────────┴───────┼────────┴─────────┴─────────┘
                                   │
                     ┌─────────────▼───────────────┐
                     │     SQLite (WAL mode)        │
                     │  FTS5 + sqlite-vec + JSONL   │
                     │     One file. Done.          │
                     └─────────────────────────────┘

11 Modules

# Module What It Does Lines Inspired By
1 memory.engine 4-type memory (semantic, episodic, procedural, working) with 5-signal hybrid retrieval ~800 Mnemosyne BEAM
2 memory.consolidation Sleep consolidation, contradiction detection, surprise scoring ~200 Neuroscience
3 memory.entity_linking Auto-extract entities, cross-link in knowledge graph, dedup ~250 Mem0 v3
4 graph.knowledge Temporal triples with auto-invalidation, boost scoring ~400 Zouroboros
5 activation.pka Proactive Knowledge Activation: briefings before you ask ~300 Zouroboros PKA
6 orchestration.swarm DAG execution, 9-signal model routing, circuit breakers, budgets ~500 Zouroboros + OpenFang
7 orchestration.selfheal Stagnation detection, capability gap tracking, fix suggestions ~200 Zouroboros Health Council
8 bridge.a2a Event-driven multi-agent sync (SQLite + JSONL fallback) ~250 Custom
9 project.manager Tasks, milestones, dependencies, blockers, progress tracking ~350 Custom
10 persona.soul 12 built-in personas, composable, adaptive effectiveness scoring ~400 Zouroboros SOUL
11 compression.aaak Token compression for context injection (20-35% reduction) ~150 Custom

Total: ~6,800 lines. 147 tests. 0 dependencies.


Benchmarks

Write Performance

Operation Sigil Mnemosyne Zouroboros Cloud APIs (Mem0, etc.)
Semantic write <0.5ms 0.81ms ~5ms 45-85ms
Working memory write 0.16ms 17.4ms ~5ms 45-85ms
Triple write (graph) 0.20ms N/A N/A N/A
Event emit (A2A sync) 0.12ms N/A N/A N/A

Read Performance

Operation Sigil Mnemosyne Zouroboros Cloud APIs
Direct read 0.010ms 0.076ms ~2ms 38-62ms
Hybrid recall (500 docs) 28ms 5.1ms ~15ms 52-78ms
Graph query 0.029ms N/A N/A N/A
Cold start 0ms 0ms ~500ms N/A

Compression

Method Token Reduction
Sigil AAK 20-35%
Mnemosyne AAAK 14.9%
Mem0 (claimed) 80% (unverified)

Test Suite

147 passed in 28.65s

Head-to-Head: Sigil vs Everyone

vs. Zouroboros (Closest Competitor)

Dimension Zouroboros Sigil Winner
Dependencies Qdrant + Ollama Zero Sigil
Install Multi-service deploy pip install Sigil
Memory types 3 4 (+ working memory with TTL) Sigil
Retrieval signals Vector only 5-signal hybrid (FTS5 + vector + importance + recency + entity) Sigil
Multi-agent sync Batch/daily Event-driven (<10s) Sigil
Orchestration DAG + 6-signal routing DAG + 9-signal + circuit breakers Sigil
Entity linking No Yes (auto-extract + dedup) Sigil
Sleep consolidation No Yes Sigil
Self-healing 3 signals 5 signals (stagnation + capability gaps) Sigil
Cold start ~500ms 0ms Sigil
Test suite 757 tests 147 tests Zouroboros
Persona system 57 static roles 12 composable + adaptive scoring Sigil
Language TypeScript (9 npm packages) Python (1 package, zero deps) Sigil
Write latency ~5ms <0.5ms (10x faster) Sigil
Read latency ~2ms 0.010ms (200x faster) Sigil
Storage Qdrant vector DB + config files One SQLite file Sigil

vs. Mem0 / Supermemory / Mengram

  • 100% local. Your data never leaves your machine.
  • 0.010ms reads vs 38-62ms cloud round-trips. That's 3,800x faster.
  • Free forever. No tiers. No subscriptions. MIT license.
  • Knowledge graph. Temporal triples with auto-invalidation. They don't have this.
  • Multi-agent sync. Event-driven A2A bridge. They don't have this either.

vs. Mnemosyne

  • Multi-agent sync (Mnemosyne has zero A2A capability)
  • Knowledge graph with temporal triples and auto-invalidation
  • Procedural memory that self-improves from failures
  • Orchestration + project management built-in
  • Not locked to a single agent framework

vs. Honcho

  • pip install, not docker-compose with PostgreSQL + Redis + pgvector
  • Same dialectic modeling via knowledge graph entity representations

vs. OpenFang

  • Library, not a 137K LOC runtime. Sigil plugs into YOUR agent.
  • Python-native. Not a 32MB Rust binary.
  • 0 dependencies vs. an entire operating system.

Multi-Agent Setup

Sigil was built for systems where multiple AI agents share context:

# Agent 1 (cloud)
zo = Sigil("shared.db", agent_id="zo", event_file="events.jsonl")

# Agent 2 (desktop)
hermes = Sigil("shared.db", agent_id="hermes", event_file="events.jsonl")

# They share one database, sync via events
zo.sync.emit("research_complete", {"topic": "JWT best practices", "findings": "..."})
hermes_events = hermes.sync.pull()  # Gets it in <10 seconds

# Each agent has its own persona context
zo.set_persona("researcher")
hermes.set_persona("engineer")

# Orchestrate across both
zo.orchestrate([
    {"id": "research", "prompt": "Find solutions", "executor": "zo"},
    {"id": "implement", "prompt": "Build it", "executor": "hermes", "depends_on": ["research"]},
])

Offline resilience: When one agent is down, the other buffers events. On reconnect, sync is automatic.


Persona System

12 built-in personas, composable, with adaptive effectiveness scoring:

# Use a single persona
cx.set_persona("engineer")
prompt = cx.system_prompt(context="fixing auth bugs")

# Compose multiple personas for complex tasks
hybrid = cx.persona.compose(["engineer", "security"], name="secure-engineer")
# Merges traits, rules, and tool preferences

# Personas learn from outcomes
cx.persona.record_effectiveness("engineer", score=0.9)

# Get recommendations for a task
recs = cx.persona.recommend("implement JWT refresh with security audit")
# Returns: [security (0.8), engineer (0.7), critic (0.5)]

Built-in personas: engineer researcher writer strategist operator assistant critic teacher data_analyst security coordinator creative


CLI

# Memory
sigil remember "Prefers dark mode" --type semantic -i 0.9
sigil recall "interface preferences" -k 5

# Knowledge graph
sigil learn niam works_on sigil
sigil about niam

# Personas
sigil persona list
sigil persona set engineer
sigil persona prompt engineer --context "auth migration"

# Activation briefing
sigil activate --persona engineer --context "morning standup"

# Projects
sigil project create auth-migration --description "JWT migration"
sigil project add-task <id> "Implement refresh" --priority high
sigil project status <id>

# Health + maintenance
sigil health --output "building auth" --error "timeout on DB"
sigil health --report
sigil sleep --max-age 24

# System
sigil stats
sigil export backup.json
sigil import backup.json

Install

pip install niam-sigil

With vector embeddings (recommended for production):

pip install niam-sigil[embeddings]

From source:

git clone https://github.com/Niraven/sigil-memory.git
cd sigil-memory
pip install -e ".[all]"
pytest  # 147 tests, ~29 seconds

Project Structure

sigil/
  memory/
    engine.py           # 4-type memory with hybrid retrieval
    consolidation.py    # Sleep consolidation + contradiction detection
    entity_linking.py   # Auto-extract and cross-link entities
    embeddings.py       # fastembed integration (optional)
    schema.py           # SQLite schema migrations
  graph/
    knowledge.py        # Temporal triples + auto-invalidation
  activation/
    pka.py              # Proactive Knowledge Activation
  orchestration/
    swarm.py            # DAG execution + model routing
    selfheal.py         # Stagnation detection + capability gaps
  bridge/
    a2a.py              # Agent-to-Agent event sync
  project/
    manager.py          # Tasks, milestones, dependencies
  persona/
    soul.py             # 12+ personas, composable, adaptive
  compression/
    aaak.py             # Token compression (20-35% reduction)
  core.py               # Unified API surface
  cli.py                # Command-line interface
tests/
  test_sigil.py         # 147 tests
benchmarks/
  bench_memory.py       # Performance benchmarks
  run_benchmarks.py     # Competitive benchmark suite
examples/
  quickstart.py         # Full demo in ~50 lines
  zo_hermes_setup.py    # Multi-agent configuration

Roadmap

  • Core memory engine (4 types, hybrid retrieval)
  • Knowledge graph with temporal triples
  • Proactive Knowledge Activation (PKA)
  • Swarm orchestrator with model routing
  • A2A bridge (event-driven sync)
  • Project manager
  • 12 built-in personas (composable, adaptive)
  • Sleep consolidation
  • Entity linking
  • Self-healing
  • AAK compression (20-35%)
  • CLI tool
  • 147 tests passing
  • MCP server (expose Sigil as Model Context Protocol server)
  • REST API server
  • LoCoMo benchmark suite
  • Selective forgetting
  • Entropy gating (Prism paper inspired)
  • PyPI publish
  • Web dashboard

Research

See FINDINGS.md for the full competitive analysis of 8 memory/orchestration systems that informed Sigil's design, including Zouroboros, Mnemosyne, Mengram, Supermemory, Mem0, Honcho, OpenFang, and Hermes Agent.


Built By

Niam Amor -- AI systems engineer building cognitive infrastructure for autonomous agents. Currently working on multi-agent architectures at the intersection of memory, orchestration, and knowledge representation.


Contributing

Contributions welcome. Sigil is MIT licensed.

  1. Fork the repo
  2. Create a feature branch (git checkout -b feature/your-feature)
  3. Write tests for your changes
  4. Run the test suite (pytest)
  5. Submit a PR

Priority areas: MCP server integration, additional benchmark suites, REST API, selective forgetting algorithms.


License

MIT -- Free forever. No tiers. No subscriptions. Your data stays yours.


If your AI agents don't remember, they can't learn. If they can't sync, they can't collaborate. If they can't orchestrate, they can't scale. Sigil solves all three.

About

The cognitive backbone for multi-agent AI systems. Sub-millisecond memory, knowledge graphs, multi-agent sync, swarm orchestration. One SQLite file. Zero cloud. Zero subscriptions. 147 tests.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages