Data model¶
Spongram keeps two kinds of state. PostgreSQL holds the control data: brains, keys, the ingestion queue, settings, personas and usage. Neo4j holds the memory itself: the knowledge graph Graphiti builds, and the properties and nodes Spongram adds to it. This page describes both, and the rule that keeps brains apart.
Tenancy¶
One brain is one row of spongram_instances and one group_id, assigned when the brain is created and never changed.
| Edition | group_id |
|---|---|
| Server | sb_ followed by the first 16 hexadecimal characters of the SHA-256 digest of the owner's e-mail address. The column is unique, so one owner e-mail address maps to one brain. |
| Server with the Cloud control plane | sb_ followed by a random identifier. An owner can have several brains. |
| Desktop edition | local, the single brain |
Every node and every relationship of the graph carries the group_id of its brain. spongram resolves the brain from the caller's key and injects the group_id server-side into every memory call; a client cannot choose it. See the security model for the checks built on this rule.
PostgreSQL¶
All tables are prefixed spongram_. The database is owned by Spongram and reachable only from the spongram service.
Core tables¶
| Table | Purpose |
|---|---|
spongram_instances |
One row per brain |
spongram_api_keys |
Brain keys, stored as hashes |
spongram_stats |
Per-brain counters |
spongram_usage_records |
One row per MCP request, for the usage dashboard |
spongram_pending_episodes |
Durable ingestion queue |
spongram_runtime_config |
Key-value settings changed at run time |
spongram_wiki_pages |
Compiled wiki pages |
spongram_personas, spongram_skills |
Personas and their skills |
spongram_project_aliases |
Project alias table |
spongram_bundle_versions |
Published versions of the client bundles |
spongram_schema_migrations |
Migration journal |
spongram_instances¶
| Column | Meaning |
|---|---|
id |
Numeric instance id used by the admin API |
owner_email, display_name |
Identification shown in the admin UI |
group_id |
Graph namespace of the brain, unique |
api_key_id |
The brain's current key (spongram_api_keys.id) |
llm_model_slug, embedder_slug |
Models recorded when the brain was created. The model actually used for extraction is read from spongram_runtime_config. |
embedding_dim |
Dimension of the embedding vectors, default 1024. Fixed for the life of the brain. |
language |
Language chosen at creation, default fr. Used as the locale of compiled wiki pages and written into generated bundles. |
status |
active, suspended or purged. Only an active brain accepts its key. |
wiki_enabled |
Whether the Sleeper compiles wiki pages for this brain, default true |
metadata |
Free JSON |
created_at, updated_at, last_used_at |
Timestamps |
spongram_api_keys¶
| Column | Meaning |
|---|---|
key_prefix |
First 18 characters of the key (spt_brain_ plus 8 characters), indexed for lookup |
key_hash |
SHA-256 hexadecimal digest of the full key, unique. The clear key is never stored. |
name |
Label of the key |
is_active, revoked_at, expires_at |
Validity. Regenerating a key inserts a new row and marks the previous one inactive and revoked. |
rate_limit_rpm |
Not read by the service. Rate limiting is set for the whole deployment with SPONGRAM_RATE_LIMIT_PER_MIN. |
spongram_stats¶
One row per brain. tokens_used_in, tokens_used_out and last_episode_at are maintained by the service. The episodes_count, nodes_count and edges_count columns are not updated by background extraction: the API and the admin UI read those three counters live from Neo4j instead.
spongram_usage_records¶
One row per MCP request: instance_id, api_key_id, method, tool_name, bytes_in, bytes_out, latency_ms, status, created_at. Rows older than 90 days are pruned by a background task.
spongram_pending_episodes¶
Every add_memory call is written here before anything is sent to Graphiti, which is what lets an accepted episode survive a restart or an outage of the extraction model. See ingestion.
| Column | Meaning |
|---|---|
instance_id, group_id |
The brain |
payload |
The complete tool call to forward |
episode_name |
Name of the episode, used to match the row with the graph |
status |
pending, processing or completed. The value failed is still accepted by the column constraint but is never written: a row that fails goes back to pending. |
retry_count, next_attempt_at |
Retry bookkeeping. The delay grows with each failure: 30 s, 2 min, 10 min, 30 min, 1 h, then 6 h. |
last_error |
Last failure, or the reason given when a row was retired |
forward_status, forward_latency_ms |
Result of the last forward to Graphiti |
content_hash |
SHA-256 over the brain, name, body, source description and uuid of the episode. A recent identical submission is acknowledged without being queued twice. |
retired_at |
Set when the row is withdrawn on purpose (the episode was deleted, the graph was cleared, or an operator retired it). A retired row is never claimed, replayed or counted. |
enqueued_at, started_at, completed_at |
Timestamps |
Two states shown in the admin UI are derived, not stored: a row is retrying when it is pending with a future next_attempt_at, and parked when, in addition, retry_count has reached 6.
spongram_runtime_config¶
A flat key-value table (key, value, encrypted, updated_at, updated_by) read at request time, so a change applies without restart.
| Key | Content |
|---|---|
inference.provider, inference.base_url |
The inference endpoint |
inference.api_key |
Its API key, stored encrypted with Fernet (encrypted = true) |
inference.graphiti_model, inference.sleeper_model |
Chat models for extraction and for the Sleeper |
inference.embedder_model, inference.embedder_dim |
Embedding model and dimension |
inference.sleeper_max_per_tick, inference.sleeper_interval_sec |
Sleeper tuning |
worker.dream.last_tick_at |
Time of the last successful Dream pass, used to resume the schedule after a restart |
spongram_wiki_pages¶
One page per entity and brain: entity_uuid, slug, title, body_markdown, version, sources, project_tags, updated_at. Pages are written by the Sleeper and deleted when the brain is purged.
spongram_personas and spongram_skills¶
| Table | Key columns |
|---|---|
spongram_personas |
slug (unique per brain), name, role, voice, intent, rules, scope (voice or full), skills (list of skill slugs), active, activated_at, activated_count, summary, summary_version, avatar_url |
spongram_skills |
slug (unique per brain), name, description, body (the SKILL.md text), source (authored, import: followed by a URL, or a marketplace reference) |
A partial unique index allows at most one row with active = true per brain. See personas.
spongram_project_aliases¶
alias and project per brain, with alias unique per brain and a constraint that an alias differs from its project. Aliases are applied when reading; no episode is rewritten. See project aliases.
spongram_bundle_versions¶
bundle_kind (desktop_mcpb or claude_code_plugin), semver, template_path, changelog, is_current. The row marked current gives the version stamped into a generated bundle.
spongram_schema_migrations¶
The journal of applied migration files: name, digest (checksum of the file) and applied_at. Each file runs once. A file whose checksum no longer matches the journal stops the start-up, which is why a released migration is never edited. See upgrades and migrations.
Cloud control plane tables¶
These tables are created by the same migration set but are only used when SPONGRAM_CLOUD_CONTROL_ENABLED=true. The same migrations add columns to the core tables: spongram_instances gains public_id (the UUID used by the console API), organization_id, access_mode (legacy, observe or enforce; per-key permissions apply only to a brain in enforce), brain_kind, memory_mode (chat or workflow), acl_version and lifecycle columns; spongram_api_keys gains principal_id, instance_id, permissions, created_by, last_used_at and replaces_key_id.
| Table | Purpose |
|---|---|
spongram_deployment |
Single row identifying the installation |
spongram_organizations |
Organisations, with status and capacity allocations |
spongram_users |
User accounts, with is_platform_admin and status |
spongram_password_credentials, spongram_login_attempts |
Password hashes (Argon2), the forced-change flag, and sign-in throttling |
spongram_oidc_identities, spongram_oidc_flows |
OpenID Connect identities and in-progress sign-ins |
spongram_sessions |
Console sessions: hash of the token, hash of the CSRF token, expiry, revocation |
spongram_principals |
Members of an organisation: kind (human, service, legacy), role (member, admin, owner), status |
spongram_brain_grants |
Permissions of a principal on a brain |
spongram_license_activations |
Activated licence tokens and their claims |
spongram_capacity_reservations |
Capacity accounting per resource and organisation |
spongram_audit_events |
Audit log: actor, action, target, detail |
spongram_migration_runs |
Record of migrations of existing brains to the control plane's access control |
spongram_sources, spongram_source_revisions |
Business sources submitted through the workflow API and their revisions, with approval state |
spongram_memory_schemas |
Schemas registered for a brain |
spongram_operations |
Ingestion operations and their stage, from accepted to available |
spongram_job_access, spongram_job_attempts, spongram_job_repairs |
Authorisation and execution records of queued jobs |
spongram_direct_ingestions, spongram_stored_objects |
Queued skill and code-map ingests and their stored payloads |
spongram_graph_withdrawals, spongram_tombstones, spongram_episode_tombstones |
Withdrawal of sources and episodes from the graph |
spongram_inference_calls |
One row per model call, with tokens and cost, for usage reporting |
Desktop edition¶
The desktop edition replaces PostgreSQL with a SQLite file and Neo4j with an embedded FalkorDB graph, both under the user's data directory. It has its own, smaller migration set covering the core tables above; the Cloud control plane tables do not exist there.
Neo4j¶
The graph Graphiti writes¶
Graphiti turns each episode into entities and facts.
| Element | Kind | Key properties |
|---|---|---|
Episodic |
Node | uuid, name, content (the text that was stored), source, source_description (carries the tags such as project= and client=), created_at, valid_at, group_id |
Entity |
Node | uuid, name, summary, name_embedding, group_id. An entity also carries a type label, for example Person or Service. |
MENTIONS |
Relationship Episodic → Entity |
Links an episode to the entities it mentions |
RELATES_TO |
Relationship Entity → Entity |
A fact: uuid, name, fact (the sentence), fact_embedding, episodes (uuids of the episodes that support it), valid_at, invalid_at, expired_at, group_id |
The three time properties of a fact have distinct meanings: valid_at is when the fact became true, invalid_at when it stopped being true, and expired_at when Graphiti recorded that newer information superseded it. By default, search leaves out facts whose expired_at or invalid_at is in the past. See search.
What Spongram adds¶
| Element | Written by | Meaning |
|---|---|---|
confidence on RELATES_TO |
Dream | Corroboration score between 0.5 and 1.0: 0.5 plus 0.15 for each additional distinct project among the episodes that support the fact. Recomputed identically at every pass. |
confidence_episodes on RELATES_TO |
Dream | Number of supporting episodes when confidence was computed. Search only uses a confidence that has this marker. |
last_confidence_update on RELATES_TO |
Dream | When the evidence of the fact last changed |
decayed_score on RELATES_TO |
Dream | confidence reduced exponentially with the age of the fact |
forgotten_at on RELATES_TO |
Dream | Set when decayed_score falls below a floor. Written only when SPONGRAM_DREAM_FORGETTING_ENABLED is on, which is off by default. |
SAME_AS |
Dream | Non-destructive link between two entities judged to be the same, when entity resolution is enabled |
Summary node and SUMMARIZES relationship |
Sleeper | One summary per entity: entity_uuid, body, version, source_count, based_on_until, updated_at, group_id |
importance on Entity |
Sleeper | Score derived from the number of sources, the degree of the entity and its recency |
community_id on Entity |
Dream (community detection) | Cluster identifier behind the wiki themes |
Code node |
Code-map ingest | A file, class, function or other code element: gid_uuid, uuid, repo, label, kind, source_file, source_location, updated_at, group_id |
CODE_EDGE |
Code-map ingest | Relationship between two Code nodes, with relation (for example an import or a call) and confidence |
REFERENCES |
Code-map ingest | Link from an Entity to a Code node of the same brain |
Skill node, Project node, USED_FOR |
record_skill |
A recorded procedure (name, body, intent, language) and the project it was recorded for |
ForgottenFact node |
Admin forget-fact route | Audit record of a fact forgotten by an operator. The fact itself receives valid_to, tombstoned_by and tombstoned_at. |
Code nodes are merged on the single property gid_uuid, built as group_id::repo::id. One indexed key makes re-ingesting a repository an update instead of a duplication; ingests of the same repository into the same brain are additionally serialised by a lock. See code map, Sleeper and Dream.
Note
Dream's confidence, decay and forgetting passes only read RELATES_TO relationships. Code-map relationships are never touched by them.
Purge and deletion¶
Purging a brain deletes every node that carries its group_id, then every remaining relationship that carries it. That covers episodes, entities, facts, summaries, code-map nodes, recorded skills and forgotten-fact audit nodes. In PostgreSQL the purge resets the brain's counters and deletes its wiki pages; the instance row, its key and its personas remain. On a server without the Cloud control plane the purge leaves the brain's ingestion-queue rows untouched, which lets the reconciler queue recent episodes again; see the purge note in the HTTP API. Deleting a brain removes the instance row as well, and the rows of the other tables follow through ON DELETE CASCADE.
Embeddings¶
Entity names and facts are embedded for semantic search. The vector dimension is recorded per brain in embedding_dim (default 1024, the dimension of the default embedding model) and is fixed once the brain exists: vectors of two dimensions cannot be compared, and the vector index is built for one of them.
Changing the embedding model or its dimension therefore requires purging the existing memory and ingesting it again. The inference settings refuse such a change until the operator confirms the purge, and a brain export records the dimension so that an import into a brain with another dimension is rejected. See inference providers and backup and restore.