Files
ruflo/v3/@claude-flow
Mr. MakandClaude Opus 5 7879ce7fa6 fix(memory): don't serve cached values another process has changed (#3360)
bridgeGetEntry() consults a per-process TieredCache before the database,
and each process only invalidated that cache on its own writes. Several
MCP servers routinely share one store (Claude Code, Codex and Grok each
run `mcp start` against the same .swarm/), so once server B had read a
key, an update or delete made by server A never reached B: B kept
returning the old value (found: true) until its cache entry expired
(5-minute TTL by default, not extended by reads).

Before a cached read, check SQLite's PRAGMA data_version (prepared once
per handle), which changes only when a different connection has
committed to the file, and clear the cache when it moved. Own writes
don't trip it, so hits stay cheap (~1 us added).

Native better-sqlite3 handles only: agentdb's sql.js fallback works on a
private image that never sees other processes' commits, so there is
nothing to detect and it is skipped (isWasm / no inTransaction) rather
than probed. A handle that can't prepare the check is not probed again. A check that
cannot validate the store on one read clears the cache for that read,
leaves the baseline alone and is retried — both when it throws (e.g.
SQLITE_BUSY) and when it answers without a usable number, since neither
is evidence the store is unchanged. The check is fail-open toward the
caller: it can never break the read it guards.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KTedGmPKpEdArVBMMn3JaP
2026-09-20 12:09:15 -04:00
..