DocsRunning cass
Index Resilience & Recovery
On this page
cass treats search indexes as derived assets. The SQLite archive is authoritative; lexical and semantic search data can be rebuilt from it.
Schema Version Tracking#
Every lexical generation stores a schema_hash.json file containing the schema fingerprint:
{"schema_hash":"quill-fslx-schema-v9-unicode-hyphen-cjk-bigrams-bounded-content-prefix-preview-stored-content-external"}
Automatic Recovery Scenarios#
| Scenario | Detection | Recovery |
|---|---|---|
| First run | No SQLite archive and no lexical index | cass index discovers sessions and creates both |
| Missing lexical index | No readable lexical asset | Rebuild from SQLite into scratch space, then publish |
| Schema mismatch | Hash differs from current | Rebuild derived lexical asset from SQLite |
| Corrupted metadata | Invalid or missing lexical metadata | Ignore the broken derivative and rebuild from SQLite |
| Semantic not ready | Model/vector assets absent or still backfilling | Continue lexical search and report semantic fallback/readiness |
Manual Recovery#
# Check the current truth surface first
cass triage --json
cass health --json
cass status --json
# If not ready, run the first targeted command from recommended_commands[].
# For a fresh data dir this is usually:
cass index --full --json --no-progress-events --data-dir <same-data-dir>
Manual rebuild commands are for first setup, explicit operator refresh, or cases where recommended_commands[] asks for them. A normal missing/stale lexical asset should be repaired as derived state from SQLite, not treated as lost user data.
Design Principles#
- Never lose source data:
cassonly reads agent files, never modifies them - SQLite is the source of truth: Derived lexical and semantic assets can be rebuilt
- Atomic publish: Rebuilt assets are prepared in scratch space and published only when complete
- Graceful degradation: Hybrid search continues as lexical when semantic enrichment is unavailable
Index Recovery & Self-Healing#
cass maintains multiple layers of redundancy to recover from corruption or schema changes:
Schema Hash Versioning:
Each lexical generation stores a schema_hash.json file containing a hash of the current schema definition. On startup:
- If hash matches → open existing index
- If hash differs → schema changed, trigger rebuild
- If file missing/corrupted → assume stale, trigger rebuild
This ensures that version upgrades with schema changes can rebuild the lexical derivative without user intervention.
Automatic Rebuild Triggers:
| Condition | Detection | Action |
|---|---|---|
| Schema version change | Hash mismatch in schema_hash.json |
Full rebuild |
| Missing Quill publication manifest | Quill can't open index | Rebuild and publish a fresh derivative |
| Corrupted index files | Lexical reader open fails | Rebuild and publish a fresh derivative |
| Explicit request | flag |
Rebuild derived search assets from the canonical SQLite archive |
SQLite as Ground Truth: The SQLite database serves as the authoritative data store. Lexical rebuilds reconstruct the Quill index from SQLite:
// Iterate all conversations from SQLite
// Re-index each message into a fresh Quill index
// Progress tracked via IndexingProgress for UI feedback
This means corrupted lexical data is a repairable derivative-state problem. Operators should start with cass triage for the exact next command, or read cass health / cass status for the narrower readiness snapshot.
Database Schema Migrations#
The SQLite database uses 23 versioned schema migrations, tracked in the _schema_migrations table (CURRENT_SCHEMA_VERSION = 23 and MIGRATION_NAMES in src/storage/sqlite.rs):
| Version | Migration | Version | Migration |
|---|---|---|---|
| 1 | core_tables |
12 | model_dimensions |
| 2 | fts_messages |
13 | plan_token_rollups |
| 3 | fts_messages_rebuild |
14 | fts_contentless |
| 4 | sources |
15 | conversation_tail_state_cache |
| 5 | provenance_columns |
16 | drop_redundant_message_conv_idx |
| 6 | source_path_index |
17 | drop_message_created_idx |
| 7 | msgpack_columns |
18 | conversation_tail_state_hot_table |
| 8 | daily_stats |
19 | conversation_external_lookup |
| 9 | embedding_jobs |
20 | conversation_external_tail_lookup |
| 10 | token_analytics |
21 | conversation_context_index |
| 11 | message_metrics |
22 | forgotten_sources |
| — | — | 23 | forgotten_conversations (current; durable shared-store session tombstones) |
Migration Process:
- On startup,
casschecks_schema_migrationsin the database (older databases that still recordschema_versionin themetatable are transitioned automatically) - If version < current, migrations run automatically
- Migrations are incremental and non-destructive
- User data (bookmarks, TUI state, sources.toml) is always preserved
Safe Files (never deleted during rebuild):
bookmarks.db- Your saved bookmarkstui_state.json- UI preferencessources.toml- Remote source configuration.env- Environment configuration
Backup and Retention Policy: Migration/rebuild backups preserve user data and are not treated as disposable source evidence. Derived lexical publish backups use the bounded retention policy documented above, while quarantined artifacts and repair candidates persist until an operator runs an explicit, fingerprinted cleanup flow.