1. Executive Summary
Sigil is persistent memory for coding agents: a local Node daemon
that turns the user's messages in Claude Code, Codex, Cursor and Hermes
into short third-person facts, stores them in Postgres with pgvector,
and injects the relevant ones into the next prompt. Notable: a fact that
a later one contradicts is retired to superseded or
contradicted and never served again, and a fact
addressed to one agent ("call me sir") is kept out of every
other agent's prompt, with populated tests against the
production query in CI. Weak: that scoping holds on the hook and MCP
paths and is lifted on the CLI path that Hermes and the agent
instructions use; and forget is a bare DELETE that leaves
no record and can be refused by the schema.
Which store runs. Postgres in every configuration.
sigil init offers PGlite first, labelled "Built-in database
(recommended)": Postgres with pgvector compiled to WASM, running inside
the daemon at ~/.sigil/db
(src/cli-handlers/init.js:104-105). Local Postgres, Docker
and an external URL are the alternatives. knex builds every
query and pg is the driver for the three external modes.
There is no implicit default: selectDriver throws
not_configured until setup has chosen
(src/db/drivers/index.js:25-60), and PGlite is an optional
dependency.
The rest:
- The retirement is model-judged. A new fact whose
nearest active neighbour scores between 0.78 and 0.88 goes to one model
call that answers ADD, UPDATE or CONTRADICT, and the prompt says "Err on
the side of UPDATE" (
prompts/audm-decision.md:5). At 0.88 or above the new fact is dropped as a duplicate with no model call. - Scope has two bypasses in the product's own paths.
sigil searchpassesvisibility: 'any'and global pods (src/cli.js:1991,:1998), and the entity-first arm reads an entity's facts by status alone. - Forget is a hard delete. It writes no history row,
fails on the foreign keys of a fact that retired another or anchors a
relation, and a later
rememberof the same text is reported as already known and stored nowhere.
Licence. MIT in LICENSE and
package.json.
Four marks: trust_state, scope_enforced,
audit_log and negative_eval. Section 9 gives the reason
for each of the three withheld.
2. Mental Model
A memory is a sentence about the user. When a Claude
Code turn ends, the Stop hook takes the last user message, asks a model
for third-person facts of under 25 words that would still be true later,
and skips instructions aimed at the assistant itself
(src/hooks/stop-classify.js). An explicit
remember and the MCP remember and
ingest tools write the same unit.
A fact becomes a belief by passing two gates. The first is an
admission document keyed
thought:<sha256 of the text>: a text whose document
already yielded facts is skipped and reported as already known
(src/ingestion/pipeline.js:436-448). The second is a
comparison with the active facts of the same namespace: near-identical
is dropped, ambiguous goes to the model, distant is added
(src/memory/facts/store.js:48-128).
A belief stops being one in three ways. A later fact the model judges
an UPDATE or CONTRADICT sets the old row to superseded or
contradicted, points it at its replacement, closes its
valid_until and writes a history row. Re-ingesting a
changed document supersedes the facts it no longer produces.
forget deletes the row.
Two keys decide who sees a belief. Visibility is
shared by default and narrows to agent when a
preference reads as an instruction to the assistant, or to
device on request. Pods group facts by
kind — directive, Claude session, project, person, playbook, Hermes
profile, vital — and the active pods for the working directory decide
what is injected.
Diagram source
%% caption: a fact is admitted once per text, judged against its neighbours, retired by a later one, and read through scope filters that two paths lift
flowchart TD
IN["Stop hook, remember<br/>or MCP ingest"]
IN --> ADM{"thought:sha256 doc<br/>already has facts?"}
ADM -->|"yes"| KNOWN["reported already<br/>known, not stored"]
ADM -->|"no"| NB["embed; find active<br/>facts in namespace"]
NB --> SIM{"top similarity"}
SIM -->|"0.88 or more"| DUP["dropped as<br/>duplicate"]
SIM -->|"0.78 to 0.88"| LLM["one model call:<br/>ADD, UPDATE,<br/>CONTRADICT"]
SIM -->|"below 0.78"| NEW["insert active fact<br/>valid_from = now"]
LLM --> NEW
LLM -->|"UPDATE or<br/>CONTRADICT"| RET["old fact superseded<br/>or contradicted"]
RET --> HIS["history row:<br/>old and new text"]
NEW --> READ{"read path"}
READ -->|"hook, MCP,<br/>hot context"| SCOPED["active, namespace,<br/>visibility, pods"]
READ -->|"sigil search CLI"| WIDE["active, namespace;<br/>visibility any,<br/>pods global"]
READ -->|"entity-first arm"| ENT["active only"]
SCOPED --> FORGET["forget: DELETE row,<br/>no history"]3. Architecture
One daemon, sigild, owns the database and serves every
client. It listens on a Unix socket for the CLI and hooks and on HTTP at
127.0.0.1:7777 for the GUI and MCP over HTTP, with a bearer
or cookie token on everything but /healthz
(src/daemon/http-server.js:1-15, :142). Each
socket request carries an agent field, which the daemon
binds to the request in AsyncLocalStorage
(src/daemon/socket-server.js:116-126,
src/daemon/request-context.js:49-57).
Storage is Postgres through a lazily created knex pool. Under PGlite
the database lives in the daemon's process and the pool waits up to 120
seconds for a connection (src/db/cortex.js:45). Startup
keeps three rolling dumps of the cluster and can move a corrupt data
directory aside or restore a dump (src/db/snapshots.js:27,
src/setup/db/embedded.js). The schema is 47 knex
migrations. Embeddings are 1024-dimensional and stored as
halfvec behind an HNSW index; CI pulls
mxbai-embed-large through Ollama.
Fact writes run under a write lock inside one transaction per batch
(src/ingestion/pipeline.js:208-227, :321-330);
document ingestion and entity enrichment are queued jobs. Devices pair
over Iroh, and each RPC method needs a role, with
forgetFact and setFactVisibility requiring
writer (src/net/auth.js).
Deployment and ergonomics
Install is an npm package with committed dist/ bundles.
sigil init picks the database, embedding and model
providers, writes hooks into each client's settings, and adds an
@~/.sigil/CLAUDE.md import to
~/.claude/CLAUDE.md
(src/lib/clients/claude-code.js:83-90). The default needs
nothing installed beyond Node and a model provider. Its cost is one
process: nothing else can open the PGlite directory while the daemon
holds it. An optional reranker, Jev, calls api.typesafe.ai
and is off by default
(src/setup/config-store.js:90-97).
4. Essential Implementation Paths
- Turn capture.
src/hooks/stop.jsreads the last user message of 15 to 8,000 characters, deduplicates by cursor, spools on failure, and hands Cursor and Codex turns to a detached copy (:35-36,:47-76).src/hooks/stop-classify.jsmakes the model call and callsingestAtomicFacts. - Admission and comparison.
ingestAtomicFactsinsrc/ingestion/pipeline.js:403-541;prepareFactBatchandapplyPreparedFactBatchinsrc/memory/facts/store.js:48-209; the verdict callaskAudmBatchat:234-294. - Retirement.
markContradictedandmarkSupersededatsrc/memory/facts/store.js:406-416;supersedeStaleDocFactsat:434-476. - Forget.
src/daemon/handlers/forget-fact.jsmatches by id or uid prefix and callsdeleteFact(src/memory/facts/store.js:635-646). - Recall.
searchinsrc/memory/search/hybrid.js, the SQL insrc/memory/search/hybrid-sql.js:44-243, filters insrc/memory/search/filters.js, the daemon handler insrc/daemon/handlers/search.js. - Injection.
src/hooks/user-prompt-submit.jsper prompt, andsrc/memory/facts/hot-context.jsfor the snapshot in~/.sigil/CLAUDE.md. - Visibility.
src/memory/visibility.jsand migration20260811130000.
5. Memory Data Model
fact holds uid, content,
category, confidence, namespace,
status (default active),
superseded_by_id and contradicted_by_id as
foreign keys to fact with no delete action,
source_document_ids, an embedding, a tsvector,
valid_from and valid_until,
importance and importance_score,
created_by_device_id, created_by_agent and
visibility
(src/db/migrations/20260310120002_create-cortex-fact-table.cjs:11-12).
The visibility column is
NOT NULL DEFAULT 'shared' with a check for
shared, agent and device.
fact_lifecycle holds access count, last access and a
stage of fresh, stable or
editing. history holds target type and id,
event, old and new content and a trigger. trace_event
records searches and ingests with agent and session.
relation links two entities and names its
source_fact_id, again with no delete action
(src/db/migrations/20260310120004_create-cortex-relation-table.cjs:17).
Pods and pod_membership are polymorphic over facts and
documents, and the membership has no foreign key to
fact.
Two declared pieces have no producer. superseded_at and
superseded_by_fact_uid are added by migration
20260514023428 and written by nothing in src.
Each pod kind declares ttlDays (90 for Claude sessions),
and the only readers print it (src/cli.js:2664,
:2694).
Both times are record time. insertFact stamps
valid_from with new Date()
(src/memory/facts/store.js:352), and retirement sets
valid_until to now.
6. Retrieval Mechanics
hybridSearchFacts runs two CTEs over fact:
halfvec cosine distance and a tsvector keyword match. Each
carries namespace = ANY(?), status = 'active'
and the confidence, time, category, visibility and pod clauses
(src/memory/search/hybrid-sql.js:135-142,
:158-165). The two ranks are fused by weighted RRF with K
of 20, vector weight 1.0 and keyword weight 0.7, then scaled by an ACT-R
activation term softplus(ln(n+1) - 0.5 ln(age)) at weight
0.10, a vital multiplier and a confidence multiplier
(src/memory/search/scoring-constants.js:9-45).
Pod scope auto resolves the active pods for the working
directory. A requested scope also admits facts with no pod membership,
so a fact filed under another project stays out and an unfiled one does
not (src/memory/search/hybrid-sql.js:50-83). With no pod
active, the scope falls back to global only while no pods exist
(src/memory/search/hybrid.js:325-360).
Three arms sit beside the core search:
- Entity-first. A query that matches an entity name
runs
getFactsForEntity, which readsfact_entityjoined tofactwithstatus = 'active'and nothing else (src/memory/facts/entity-linker.js:72-80,src/memory/search/hybrid.js:391-397). Those facts skip the relevance floor (:96). - Graph expansion.
applyFactScopere-applies namespace, status, confidence, time, visibility and pods to every fact a traversal reaches (src/memory/search/graph-enhancement.js:15-46). - Routing and rerank. An optional model router, and Jev when enabled.
The prompt hook searches with pods auto, a 0.6
similarity floor, at most 20 facts and 4,800 characters, and gives up
after nine seconds (src/hooks/user-prompt-submit.js:44-52,
:119-129). The hot-context snapshot blends each kind's
facts in registration order and falls back to recent facts only when the
blend is empty (src/memory/facts/hot-context.js:60-95).
7. Write Mechanics
Thresholds default to skip 0.88, ambiguous 0.78, supersede floor 0.72
and a scan of eight candidates
(src/setup/config-store.js:79-80). Candidates include
earlier facts in the same batch, so a batch deduplicates against itself.
When the top match clears 0.78, the model sees every candidate below the
skip threshold down to the floor; a missing verdict is re-asked, and an
incomplete answer throws (src/memory/facts/store.js:96-98,
:280-294).
An insert sets status: 'active', confidence
medium unless given (atomic facts are high), the request's
agent and device, and a visibility that is explicit or inferred by regex
from the text (src/memory/visibility.js:105-131). A
retirement and its history row commit in the same transaction as the
insert.
The Claude Code Stop hook waits for the classifier call and the save;
Cursor and Codex hand off to a detached process. A fact is retrievable
as soon as the transaction commits, and the snapshot file is rewritten
after each save. No background pass rewrites the store: stage promotion
runs only from a maintenance CLI command
(src/cli.js:2396-2404), and nothing on the write or read
path reads stage.
The 0.88 skip has no model in the loop. "The API listens on port 8080" and the same sentence with 8081 can clear it, and the correction is then dropped as a duplicate while the stale value stays active.
Operational cost
Each captured turn costs one classifier call and one embedding per fact. A verdict call is added only for a batch with a neighbour between 0.78 and 0.88, one call per batch. Each search embeds the query and optionally calls the router, and writes access counts and Hebbian edge weights fire-and-forget. Entity enrichment runs as a queued job.
8. Agent Integration
- Claude Code. UserPromptSubmit injects and Stop
captures. The imported
~/.sigil/CLAUDE.mdcarries the hot-context block and instructions to runsigil searchandsigil remember --bgfrom the shell (src/lib/clients/instructions.js). - Codex and Cursor. The same hook scripts with
--agent=; Cursor gets no prompt-time injection. The agent comes from the hook's command line (src/hooks/env-loader.js:12). - Hermes. A Python plugin shells out to
sigil search ... --no-graph --no-route --no-synthesizewithSIGIL_AGENT=hermes(integrations/hermes/plugin/__init__.py:88-97). - MCP.
prime,search,search_entity,traverse_graph,get_fact_context,get_entity_context,get_pod,list_pods, document list and get,status,ingestandremember(src/mcp/tools/). There is no forget or visibility tool.searchaccepts namespaces,podScope(global allowed) andpointInTime, not visibility. - GUI and CLI. Browse, search, forget and change visibility.
9. Reliability, Safety, and Trust
Scope holds on two doors of four
The visibility filter is in the SQL of both search CTEs, in hot context, in directives and in graph expansion, and its tests run the production clause. Four reads do not apply it as intended:
sigil search.runSearchsetspodScopeto global unless--scopeis passed, andvisibility: 'any'always (src/cli.js:1991,:1998). Hermes uses this command, so a Hermes agent reads every other agent's agent-scoped facts, and so does any agent following the instructions file.- The entity-first arm.
getFactsForEntityignores viewer, pods, namespace, confidence and time, and its results skip the floor. A query naming an entity can put another agent's or another namespace's fact into an injected prompt. get_entity_contextover MCP, which calls the same function (src/daemon/handlers/get-entity-context.js:27).- The snapshot file.
getHotFactsresolves the viewer of whichever agent triggered the save. After a Codex turn, the block Claude Code imports holds Codex's agent-scoped directives and not its own.
Two inputs are the caller's. The agent is SIGIL_AGENT,
set by the CLI to cli when unset
(src/cli.js:21) and sent in the request envelope, so a fact
written through sigil remember from Claude Code's shell is
scoped to cli. And the neighbour search behind a verdict
filters by namespace and status only
(src/memory/facts/store.js:478-506), so one agent's fact
can retire another agent's scoped fact.
Forget
deleteFact deletes the fact_entity rows and
the fact. It writes no history row, and leaves
pod_membership rows and the source document's
fact_count behind. Because superseded_by_id,
contradicted_by_id and relation.source_fact_id
have no delete action, forgetting a fact that retired another or anchors
a relation is refused by Postgres; this follows from the schema and was
not run. A forgotten fact survives in up to three rolling dumps.
The model decides what is stale
A verdict is a model's judgement of two sentences, and the newer one
always wins. Nothing returns a retired row to active, and
get_fact_context returns a fact in any status, so a retired
fact stays reachable by id.
Privacy
Secrets are masked before embedding and storage
(src/memory/facts/store.js:54). Everything else stays local
unless Jev is enabled, which sends the query and candidates to a
third-party API.
Marks withheld
tombstone: no. Thethought:<sha256>admission document does block a verbatim re-remember after forget or retirement, and it is an idempotency record, not a rejection: it was written when the fact was accepted, it refuses the person as well as the extractor, a paraphrase passes, and document ingest does not consult it. Mnemosyne OS has the same accident.bitemporal: no.valid_fromis the insert time andvalid_untilthe retirement time, sopointInTimeis an as-of over record time. Relations takevalid_atas today.human_review: no. No state waits for a person. Forget and visibility changes in the GUI and CLI are edits after the fact, and the verdict is a model's.
10. Tests, Evals, and Benchmarks
The suite is 95 Vitest files with about 667 cases. CI runs two jobs
(.github/workflows/reliability.yml):
npx vitest run over the unit and integration tests, and a
reliability job that installs Ollama, pulls
mxbai-embed-large with three retries and runs
npm run test:reliability. The reliability suites open with
ready ? describe : describe.skip
(test/reliability/audm.test.js:14), so a failed pull leaves
them green with nothing asserted.
The negative cases that hold are on visibility.
src/memory/pods/kinds/directive.test.js:148-163 runs the
production fetchFacts on PGlite and requires "User prefers
tabs" present and the Hermes-scoped "User wants to be called sir" absent
for claude-code.
src/memory/multi-device.integration.test.js applies the
real migration, checks agent, device and namespace cases, and checks
that the knex and raw-SQL filters agree (:243-264).
Weaker cases:
- The fact half of
src/memory/search/pod-scope.integration.test.jscopies the SQL clause rather than calling it; the chunk half callsbuildChunkPodFilter(:98-104). test/reliability/lifecycle.test.js:23-32asserts a superseded fact is absent from a search seeded with that one fact, which an empty result also passes.- The AUDM path is unit-tested with a mocked database and model
(
src/memory/facts/store.test.js:152-181). - No test calls
deleteFactorforgetFact.
LongMemEval.
eval/longmemeval/RESULTS.md reports recall@1, @3 and @10 of
100% and 43% answer correctness on 100 questions of the oracle split,
run with SIGIL_EAGER_EXTRACT=false, so chunks were searched
and no facts were extracted. Recall counts a hit when any retrieved item
comes from an answer session
(eval/longmemeval/run-eval.js:126-158); the oracle haystack
holds only answer sessions, so any retrieval scores. No per-question
output is committed.
Paper. None: no arXiv, BibTeX or DOI reference and
no CITATION.cff in the tree.
11. For Your Own Build
Steal
- Visibility as a column the read path filters, keyed to the
writer. An instruction to one agent narrows to that agent;
everything else stays shared. The check constraint and
NOT NULL DEFAULT 'shared'make an upgrade lose nothing (src/memory/visibility.js,src/memory/search/filters.js:29-37). - A test that two implementations of one filter
agree. The knex and raw-SQL visibility paths are compared row
for row
(
src/memory/multi-device.integration.test.js:243-264). - One verdict call per batch, with within-batch candidates. Pairs from a whole turn go to the model together, and a missing verdict is re-asked rather than defaulted.
- Graph expansion that re-applies the caller's scope
to every node it reaches
(
src/memory/search/graph-enhancement.js:15-46).
Avoid
- A scope parameter with a permissive value on a shipped
path. One
visibility: 'any'in the CLI undoes the filter for every agent that reads through the CLI. Derive scope from the caller, not from an argument. - A fast path that bypasses the filter. The entity-first arm is the cheapest read and the one with no scope.
- Content-hash admission as dedup when forget exists: it becomes an undeclared tombstone that refuses the user.
- A skip threshold with no model behind it on short facts whose meaning is a number.
Fit
Sigil suits one developer moving between Claude Code, Codex and Cursor on a machine or two, who wants preferences and decisions carried across tools with no server to run. PGlite makes that a single install, and Postgres leaves room to grow. Walk away if agent separation is a security property rather than a courtesy: the agent is self-declared and two shipped reads ignore it. Walk away too if forgetting must be provable, since deletion is unrecorded and can fail.
12. Open Questions
- Does forgetting a fact that superseded another fail in practice, or
does a path not visible in
deleteFactclear the references first? - How often does the 0.88 skip drop a real correction with the configured embedding model?
- Is the CLI's
visibility: 'any'meant for a human at the terminal only, and if so, should Hermes and the instructions file use another command? - With what agent identity does an MCP client over HTTP read, given
that the daemon scrubs
SIGIL_AGENTfrom its own environment?
Appendix: File Index
- Store:
src/memory/facts/store.js,entity-linker.js,hot-context.js,src/memory/visibility.js - Search:
src/memory/search/hybrid.js,hybrid-sql.js,filters.js,graph-enhancement.js,scoring-constants.js - Ingestion:
src/ingestion/pipeline.js,prompts/audm-decision.md - Hooks:
src/hooks/stop.js,stop-classify.js,user-prompt-submit.js,env-loader.js,host.js - Daemon:
src/daemon/handlers/search.js,remember.js,forget-fact.js,ingest-turn.js,end-session.js,get-entity-context.js,request-context.js,http-server.js,mcp-http.js - Database:
src/db/drivers/index.js,cortex.js,snapshots.js,src/setup/db/embedded.js,src/db/migrations/ - Pods:
src/memory/pods/kinds/,src/memory/lifecycle/stage-manager.js - Surfaces:
src/cli.js,src/mcp/build-server.js,src/mcp/tools/,integrations/hermes/plugin/__init__.py,src/lib/clients/ - Tests:
src/memory/multi-device.integration.test.js,src/memory/pods/kinds/directive.test.js,src/memory/search/pod-scope.integration.test.js,src/memory/facts/store.test.js,test/reliability/,eval/longmemeval/
Recorded searches
Run from the repository root at the pinned commit with
/usr/bin/git grep.
valid_fromis only ever now.git grep -n -E 'validFrom|valid_from' -- src ':!src/db/migrations'returns the insert atstore.js:352and two read clauses.superseded_athas no writer.git grep -n -E 'supersededAt|superseded_at|supersededByFactUid|superseded_by_fact_uid' -- srcreturns only the migration.- No test exercises forget.
git grep -n -E 'deleteFact|forgetFact' -- '*.test.js' testreturns nothing; onsrcit matches five files. ttlDaysis only printed.git grep -n -w ttlDays -- srcreturns the kind declarations, a registry comment and twoconsole.loglines.- History is insert-only.
git grep -n -E "'history'|recordHistory" -- srcreturns the migration, three inserts and the helper;git grep -n -E "from\('history'\)|table\('history'\)" -- srcreturns nothing. - No delete action on the fact references.
git grep -n -E 'source_fact_id|superseded_by_id|contradicted_by_id' -- src/db/migrationsreturns three bare.references(...);git grep -n -i -E 'onDelete' -- src/db/migrationslists the cascades, none on these columns. - The CLI lifts visibility.
git grep -n "visibility: 'any'" -- srcreturnssrc/cli.js:1998only. - Entity facts are read in two places.
git grep -n getFactsForEntity -- srcreturns the definition,hybrid.js:397andget-entity-context.js:27. - No paper.
git grep -n -i -E 'arxiv|bibtex|doi\.org' -- .returns nothing;git grep -c -i -E 'https://' -- README.mdreturns 7.CITATION.cffis absent. - No submodules.
.gitmodulesis absent.
History
2026-12-02 — 5105c543….
First reading at the pin, read at the user's request from the 2026-12-02
triage shortlist, from a full clone at the head of master,
read only. Screened before reading: one auto-run surface,
.mcp.json, which declares no servers; no build-time
execution; nothing inside the cooldown; one unpinned surface, 23
floating ranges in package.json beside its lockfile;
CLAUDE.md read as data. The memory, search, ingestion,
hooks, daemon handlers, migrations and their tests were read; the GUI
and most of research/ were not. Nothing was installed,
built or run, and no test was run. Four marks: trust_state,
scope_enforced, audit_log,
negative_eval.