SqliteSaver has no tamper evidence on the checkpoint store; measured with a reproducible suite, would an optional integrity mode be welcome?

langgraph-checkpoint-sqlite 3.1.1 (with langgraph-checkpoint 4.2.0) loads a checkpoint store that has been edited directly in SQLite without any indication that it changed. I measured this with a small open source conformance suite, agmi, that seeds through SqliteSaver.put(), edits the checkpoints table behind the library’s back, reopens, and reads through get() and list().

Results

edit made to the store what SqliteSaver does on reload
change one checkpoint’s channel value inside the msgpack blob loads it, no error
delete the newest two checkpoints resumes from the older tip, no error
delete one checkpoint from the middle loads, parent link now dangles, no error
swap the content of two checkpoints loads, no error
insert a fabricated checkpoint after the tip with a later UUID and valid parent resumes from the fabricated one, no error

Reproduce

git clone https://github.com/tech4biz-yasha/agmi && cd agmi
python3 -m venv .venv && source .venv/bin/activate
pip install -e ".[dev,langgraph]"
PYTHONPATH=. python3 -m pytest tests/test_langgraph_sqlite.py -q

The adapter is agmi/adapters/langgraph_sqlite.py. The test pins the version, so it will fail the day this changes.

Why I am raising it

I understand this is by design. The checkpointer trusts its store the way any database trusts its disk, and nothing in the docs claims otherwise. I am raising it because LangGraph checkpoints are increasingly used as the record of what an agent did, in places where the SQLite file or Postgres rows are reachable by more than the agent process (shared volumes, multi tenant hosts, backup and migration jobs). In those deployments “the store loaded fine” and “the store is what was written” are different questions, and only the first one is answered today.

Two questions

  1. Would an optional integrity mode be acceptable upstream? The cheapest version is a hash chain: each checkpoint’s metadata carries a hash over its own content plus the parent’s hash, and get() and list() verify the chain when the mode is on. Off by default, zero cost for anyone who does not turn it on.
  2. If yes, would you prefer it in the serializer layer (so every checkpointer gets it) or per checkpointer? I am happy to open a PR either way.

Yasha Khandelwal

Nice write-up, and the repro is really useful. You’re right that this is by design: a checkpointer is a persistence layer for resuming state, not an audit log, so it trusts its backing store the same way Postgres trusts its disk.

If you need tamper evidence today, you can do it without forking the library:

  1. Wrap the saver. Subclass SqliteSaver (or BaseCheckpointSaver) and override put/put_writes to compute an HMAC over the serialized checkpoint plus its parent_checkpoint_id. Store it in the checkpoint metadata, or in a side table. In get_tuple/list, recompute the HMAC and raise on mismatch. If you chain each HMAC over the parent’s HMAC, you also catch deletions in the middle, swaps, and inserted “tip” checkpoints. Truncating the newest N checkpoints still needs an external anchor, such as the latest head hash kept somewhere the DB writer can’t touch.
  2. Use a custom serializer. serde= accepts any SerializerProtocol, so you can sign or encrypt blobs there. Note that this covers blob contents but not the ordering or lineage of rows, so pair it with option 1.
  3. Keep a separate append-only audit log. For compliance-style “what did the agent do,” many teams emit events (via LangSmith tracing or their own sink) to WORM storage and treat checkpoints as disposable resume state.

For the feature request, I’d suggest opening a GitHub issue/discussion on langchain-ai/langgraph with your table. An opt-in integrity mode at the BaseCheckpointSaver level would benefit every backend (Postgres too), not just SQLite.

really like the repro. this matches something i hit building a guardrail where the agent’s action record has to be trustworthy, and i went the route in memorysync’s option 3, a separate append-only log rather than trusting the checkpoint store, since the checkpoint is resume state, not an audit record.

one thing that complemented the hash chain nicely: sqlite triggers that reject UPDATE and DELETE on the log table outright, plus the agent process getting no write handle, only the guardrail appends. the hash chain catches edits, swaps and mid-deletes on read, and the triggers stop the delete and truncate case at the db level, which is the gap you’d otherwise need an external anchor for. it only holds if the role writing the log can’t drop the trigger, so there’s still a trust boundary, but it closes the “truncate the newest N” hole in single-writer deployments. i’ve got a small reproducible tamper suite for it (edit a row, delete one, and an edit where the attacker recomputes that row’s own hash so only the chain breaks) if it’s useful to compare against agmi: https://github.com/rayyanmaan/agent-guardrail

on the truncation point, are you keeping the head hash outside the db as the external anchor, or treating the trigger plus permissions as enough for single-writer setups? that’s the boundary i’m least sure about.

Triggers plus permissions close the truncate hole only while the process that can write the log cannot also drop the trigger, alter the table, or replace the DB file. In a single-writer setup where you control that role end-to-end, that trust boundary is often enough and you can treat the trigger wall as your truncate defense.

For adversarial or multi-tenant hosts (shared volume, backup job, or any other role that can reach the SQLite file), keep the latest head hash outside the DB: a separate store the DB writer cannot touch, or a periodic signed export of the tip. On resume, compare the tip you load against that external anchor before you trust the chain. That is what catches “delete the newest N and rewrite history” when the writer can also drop triggers.

So: triggers for the honest single-writer case; external head hash when the store is reachable by more than the agent process.

Disclosure: I build MemorySync, a hosted memory layer for AI apps.

@memorysync fair correction, the trigger wall only holds while the writer role can’t touch the schema or the file, and i’d been assuming single-writer without saying so. an external head hash is the next thing i want to add, i haven’t built it yet. the part i’m stuck on is the gap between anchors. if the tip is exported every n appends, someone who can drop the triggers can still cut whatever was written since the last export and the chain still matches the anchor. so it’s either anchor on every append, which puts a second write on the hot path, or accept a window of n entries. in setups you’ve seen, do people anchor per append, per run, or on a timer?

@rayyanmaan right, that window is inherent. I don’t have deployment data to say what’s most common, so I’ll frame it as a tradeoff rather than a survey.

What the anchor buys you. The local hash chain gives you internal consistency: edits, swaps and mid-deletes break verification unless the affected hashes are recomputed. A writer who controls the store can recompute them; the external anchor is what constrains rewriting the anchored prefix. The local chain alone provides no external commitment; a trusted durable anchor commits the anchored prefix. Everything after the last anchored head is consistent with itself but not committed anywhere the writer can’t reach. So someone who can rewrite the store can drop that unanchored suffix, or replace it and recompute its hashes, and still pass verification against the anchored prefix. That doesn’t mean unanchored entries are corrupt. They’re just not protected against wholesale suffix rewrite or truncation yet.

Cadence is integrity window vs cost. Anchoring per append gives the smallest window, but it puts a second durable write on the hot path, and that write has to succeed before you treat the entry as committed. Anything coarser accepts a window. Roughly:

  • Per run or turn boundary. This is a natural commit point. The window is “the current run”.
  • A timer as a backstop. This targets an elapsed-time interval, not an entry-count bound, and is not a hard time bound unless scheduling and successful anchor completion are enforced. A burst can put many entries inside one interval, and if the exporter stalls, the window keeps growing until it recovers.
  • A max-entry count (anchor every N), if bounding N matters to you. Trigger on whichever comes first, but a hard count bound requires stopping further accepted writes until the anchor succeeds when the threshold is reached.

A reasonable starting policy is run/turn boundaries + a timer + an optional max-N. Its limits are the ones above: the open suffix between anchors is exposed, and a stalled anchor sink silently widens the window unless you alert on anchor lag.

Before irreversible tools. If an entry precedes an irreversible action, anchoring right before it helps only if you record the effect intent and get a durable, acknowledged anchor from the trusted sink before acting. Fire-and-forget doesn’t count. Even then, it only commits that the intent was logged. It doesn’t make the external effect exactly-once, and it doesn’t attest the effect’s outcome.

Where the anchor lives matters as much as how often. It has to be somewhere the store’s writer role can’t rewrite: a separate service or account, or append-only/WORM storage. Include a monotonic sequence number (and ideally a timestamp) with each anchored head. On resume or verify, retrieve the freshest anchor through a trusted anti-rollback path and require its sequence to be non-decreasing against a trusted previously observed value. A sequence number inside a potentially stale response alone does not establish freshness. Otherwise an attacker can roll you back to an older anchor that their truncated chain matches.

Disclosure: I build MemorySync, a hosted memory layer for AI apps.