sqry-db 9.0.11

Salsa-style incremental computation engine for sqry semantic code search
Documentation

sqry-db: Salsa-style incremental computation engine for sqry.

This crate provides a demand-driven memoized query engine with file-level dependency tracking, three-tier cache invalidation, and incremental indexing support. All analysis queries (callers, callees, dependency impact, unused detection, etc.) are expressed as [DerivedQuery] implementations whose results are cached in a 64-shard [ShardedCache] and automatically invalidated when their input dependencies change.

Architecture

┌─────────────┐      ┌──────────────────┐      ┌──────────────���─┐
│  MCP / CLI   │─────▶│     QueryDb      │─────▶│  GraphSnapshot │
│  handlers    │      │  (ShardedCache)   │      │  (immutable)   │
└─────────────┘      └──────────────────┘      └────���───────────┘
                            │                          │
                      ┌─────┴──────┐           ┌──────┴───────┐
                      │ FileInput  │           │  NodeArena   │
                      │   Store    │           │  EdgeStore   │
                      └────────────┘           └──────────────┘

Three-Tier Invalidation

  • Tier 1 — File-level deps: Every query records the FileId of every node it reads. Invalidated when any recorded file's revision bumps.
  • Tier 2 — Global edge revision: A single AtomicU64 that increments when any file's edges change. Reverse queries (callers_of, is_node_in_cycle) set TRACKS_EDGE_REVISION = true.
  • Tier 3 — Global metadata revision: A single AtomicU64 that increments when node metadata changes. find_unused sets TRACKS_METADATA_REVISION = true.

Usage

use sqry_db::{QueryDb, QueryDbConfig};

let config = QueryDbConfig::default();
let db = QueryDb::new(snapshot, config);
let result = db.get::<CallersQuery>(&node_id);