cass

DocsRunning cass

Integrity & Safety

On this page
  • Verified Install: The installer enforces SHA256 checksums.

  • Sandboxed Data: All indexes/DBs live in standard platform data directories (~/.local/share/coding-agent-search on Linux).

  • Read-Only Source: cass never modifies your agent log files. It only reads them.

Atomic File Operations#

cass uses crash-safe atomic write patterns throughout to prevent data corruption:

TUI State Persistence (tui_state.json):

1. Serialize state to JSON
2. Write to temporary file (tui_state.json.tmp)
3. Atomic rename: temp → final

If a crash occurs during step 2, the original file is untouched. The rename operation (step 3) is atomic on all modern filesystems—it either completes fully or not at all.

ML Model Installation (models/all-MiniLM-L6-v2/):

1. Download to temp directory (models/all-MiniLM-L6-v2.tmp/)
2. Verify all checksums
3. If existing model present: rename to backup (models/all-MiniLM-L6-v2.bak/)
4. Atomic rename: temp → final
5. On success: remove backup
6. On failure: restore from backup

This backup-rename-cleanup pattern ensures that either the old model or new model is always available—never a half-installed state.

Configuration Files (sources.toml, watch_state.json): All configuration writes follow the same temp-file-then-rename pattern, ensuring consistency even during power loss or unexpected termination.

Why This Matters:

  • System crashes mid-write won't corrupt your preferences
  • Network interruptions during model download won't leave broken installations
  • Concurrent processes won't see partially-written files

Secret Redaction at Index Time#

Agent transcripts are full of credentials: keys pasted into prompts, tokens echoed by tool output, .env files read into context. With the default CASS_INDEX_REDACTION=full, cass scrubs them from every persisted message, title, snippet and metadata blob before anything reaches SQLite or the lexical index, so search results, exports and robot output never repeat them. (The original session files and the raw-mirror blobs keep the raw text on the same disk; redaction protects the queryable surfaces, not disk-at-rest secrecy.)

Conversation exports apply the same credential redactor independently of ingest settings, before rendering titles, messages, tool data and metadata. This also protects a direct export of a readable source file or an archive indexed with CASS_INDEX_REDACTION=off. Both cass export and cass export-html accept --include-secrets for an intentional raw-fidelity export; it does not recover credentials already removed from an archived record. The effective policy is reported on stderr, and HTML export JSON (including dry runs and explain plans) includes privacy.{policy,redaction_applied,sensitive_output}. An encrypted export also redacts by default; encryption alone does not opt into raw credentials. TUI HTML and Markdown exports, including suggested filenames, use the default redaction policy; intentional raw-fidelity exports use the CLI option.

By default, conversation exports omit injected system reminders and replace recognized injected skill messages with a marker such as [Skill loaded: review]. On cass export and cass export-html, use --include-skills for full skill content and --include-system-reminders for hook reminders and their metadata. A record containing both requires both flags. These options are independent of credential redaction.

For searchable Pages bundles, the public and team profiles omit recognized skill and hook records, including their search entries, attachment references and code snippets. The bundle retains the IDs and positions of visible messages. When a conversation contains an omitted record, Pages also withholds its title and provider metadata because both can summarize the hidden text. The personal backup profile retains these records.

What is recognized. Thirteen pattern families: AWS access key IDs, AWS secret keys and session tokens in assignment context, GitHub tokens (classic and fine-grained), OpenAI and Anthropic API keys, Bearer tokens, JWTs, PEM/OpenSSH/PGP private-key blocks, database connection URLs (Postgres, MySQL, MongoDB, Redis, AMQP; the whole URL, since it may carry a password), generic password= / api_key: / secret= style assignments, Slack tokens, and Stripe live keys. JSON metadata is also redacted by field name: values under keys such as passphrase, authorization, cookie, or anything ending in password, token, secret or apikey are replaced whatever they look like.

How it runs. Redaction sits on the ingest hot path, since it touches every message, so it is built in three layers:

  1. One prefilter pass. All patterns are compiled into a single RegexSet. One scan per string reports which patterns could match; a string with no candidates (the vast majority) is returned untouched without allocating.
  2. Targeted replacement. Only the flagged patterns run their own replace_all pass, in a fixed order, replacing each match with [REDACTED].
  3. A content-addressed memo. Transcripts repeat themselves (boilerplate system prompts, replayed tool output, salvage re-imports), so candidate-bearing strings are memoized per worker, keyed by a BLAKE3 hash of the content plus a fingerprint of the pattern list. Changing any pattern changes the fingerprint, so a stale cached answer can never be reused. Clean strings bypass the cache entirely, and inputs over 64 KiB are never cached (CASS_REDACT_MEMO_CAPACITY sets the entry cap).

A frozen copy of the original algorithm lives in the test suite, and a 512-case property test requires the plain path and the memoized path (on both a cache miss and a cache hit) to produce byte-identical output to it. The memoized JSON path has its own equivalence test against the uncached one over nested shapes.

Why the patterns use ASCII word boundaries. Rust's regex crate runs a RegexSet on a fast lazy DFA, but a Unicode word boundary (\b) is something that DFA cannot evaluate once the haystack contains a non-ASCII byte. It then falls back to the PikeVM, a far slower NFA simulation. Real transcripts are full of non-ASCII text (emoji, CJK, box-drawing characters in tool output), so every such message paid the slow path. The patterns now use (?-u:\b), the ASCII word boundary, which the DFA handles.

This cannot weaken redaction. Every boundary in these patterns sits next to an ASCII word character, and ASCII word characters are a subset of Unicode word characters. So wherever a Unicode boundary exists, an ASCII boundary exists too, and the ASCII patterns match everything the Unicode ones did. The only difference is a token glued directly to a non-ASCII letter (凭据ghp_…): a Unicode boundary sees two word characters and no boundary, so the old patterns missed that token, while the ASCII form redacts it.

Measured on 593 MiB of real session text (3.1 million strings, 79,870 of them containing non-ASCII), with the same regex version cass ships:

Word boundary Prefilter throughput Pattern matches
Unicode \b 9.8-10.6 MiB/s baseline
ASCII (?-u:\b) 261-284 MiB/s identical on all 3.1M strings

In an A/B incremental index on two identical clones of a 2.1-million-message archive (10 minutes each, run one after the other), the ASCII build committed 53,155 new messages on 10.1 CPU-minutes, against 7,028 on 12.8 CPU-minutes for the Unicode build: about 9.5 times the ingest throughput per CPU second. A unit test rejects any secret pattern that reintroduces a Unicode \b, so the cliff cannot quietly come back.