Index Refresh and Cache Controls

Overview

sqry index creates the persistent graph snapshot under .sqry/graph/. If that snapshot already exists, sqry index . exits without rebuilding unless you pass --force or --no-incremental. To refresh an existing graph after source changes, run sqry update ..

When --cache-dir <DIR> is supplied, sqry also writes a hash snapshot to <DIR>/file_hashes.bin. Current releases use this as a cache side channel for update/rebuild workflows; it is safe to delete and should normally be treated as local build state rather than committed project content.

How it works

sqry index .          ──▶ create .sqry/graph when missing; otherwise exit
sqry index --force .  ──▶ rebuild .sqry/graph and .sqry/analysis
sqry update .         ──▶ refresh an existing graph snapshot
--cache-dir DIR       ──▶ also write DIR/file_hashes.bin for that run

For the CLI surface:

  1. sqry index . creates the graph if it is missing.
  2. sqry index --force . rebuilds the graph even when a snapshot exists.
  3. sqry index --no-incremental . also bypasses the existing-snapshot early exit and rebuilds.
  4. sqry update . refreshes an existing graph; it reports git-aware mode when a git HEAD is available and hash-based mode otherwise.
  5. --cache-dir <DIR> writes file_hashes.bin for the configured run.

The on-disk graph snapshot at .sqry/graph/snapshot.sqry is updated atomically. Concurrent reads (CLI/LSP/MCP queries) see a consistent view at all times.

Forcing a full rebuild

Two ways to bypass the existing-snapshot early exit:

sqry index --force .          # Rebuild even if .sqry/graph already exists
sqry index --no-incremental . # Rebuild and bypass the existing-snapshot early exit
FlagEffect
--force (-f)Rebuild even if .sqry/graph/ already exists. Use after a major sqry upgrade or when the snapshot version bumps.
--no-incrementalBypass the existing-snapshot early exit and run the rebuild path. Useful when comparing the normal early-exit behavior with a fresh build.
--add-to-gitignoreAppends the legacy .sqry-index/ ignore entry if missing. For current graph state, add .sqry/ and .sqry-cache/ yourself if you want those directories ignored.

Custom cache directory

By default, sqry uses <workspace>/.sqry-cache/ for project cache state. Override the hash-snapshot location for a command with --cache-dir:

sqry index . --cache-dir /tmp/sqry-cache

This is most useful in:

The --cache-dir path is created if it does not exist. Relative paths are resolved against the current working directory.

Metrics export

sqry index --status prints metadata about the existing index — age, symbol count, languages, validation health. Combine it with --metrics-format for machine-readable output:

# JSON (default)
sqry index --status --json

# Prometheus / OpenMetrics text
sqry index --status --json --metrics-format prometheus

The Prometheus output is OpenMetrics-compatible and exports the status fields available from sqry index --status:

MetricTypeDescription
sqry_index_existsgaugeWhether the graph index exists
sqry_index_supports_fuzzygaugeWhether fuzzy search is enabled
sqry_index_supports_relationsgaugeWhether relation queries are supported
sqry_index_age_secondsgaugeSeconds since the snapshot was last written
sqry_index_symbol_countgaugeTotal indexed symbols
sqry_index_file_countgaugeTotal files indexed
sqry_index_stalegaugeWhether sqry considers the index stale
sqry_index_cross_language_relation_countgaugeCross-language relation count when present

Pipe the output directly into a Prometheus push gateway, or scrape it from a CI job:

sqry index --status --json --metrics-format prometheus \
  | curl --data-binary @- "http://pushgateway:9091/metrics/job/sqry/instance/$(hostname)"

Validation modes

Independently of the cache, --validate <mode> on sqry search and sqry query controls how strict sqry is about source-file drift detected during a query:

ModeBehaviour
warn (default)Log a warning on drift, return results from the snapshot.
failExit with code 2 if more than 20% of indexed files are missing on disk.
offSkip validation entirely (fastest).
sqry search "test" --validate fail   # CI-friendly strict mode
sqry search "test" --validate off    # Hot-path performance mode

Inside the daemon

When sqry runs as a daemon (see Daemon (sqryd)), the file-system watcher debounces events over debounce_ms (default 2000 ms) and triggers the daemon rebuild path automatically for loaded workspaces. Use sqry daemon rebuild <path> when you want to request that refresh explicitly.

Troubleshooting