DocsFor agents
Agent Quickstart (Robot Mode)
⚠️ Never run bare cass in an agent context — it launches the interactive TUI. Always use or .
# 1) Check the installed interface once per version (recipe verified on 0.10.0).
cass --version
cass search --help
# Verify a newly installed executable without opening the configured archive.
cass selftest --json
# `health --binary-only` still reports (and therefore probes) archive readiness.
# 2) For a quick history question, start with scoped read-only lexical retrieval.
# Hybrid remains the product default; lexical is explicit for this workflow.
cass search "performance regression" --workspace /path/to/project --days 7 \
--mode lexical --no-maintenance --robot --robot-meta --fields minimal \
--limit 5 --max-tokens 2000 --timeout 2000
# 3) Find the current or recent session for this workspace
cass sessions --current --json
cass sessions --workspace "$(pwd)" --json --limit 5
# 4) View + expand a hit (use source_path/line_number from search output)
cass view /path/to/session.jsonl -n 42 -C 3 --json --timeout 2000
# 5) Discover the full machine API
cass capabilities --json
cass robot-docs guide
cass robot-docs schemas
# 6) Exclude a noisy agent harness from future indexing
cass sources agents list --json
cass sources agents exclude openclaw
cass sources agents include openclaw
The retrieval flags above are available in 0.8.0 and later. On older builds, check help;
if is absent, report the mismatch instead of dropping the
read-only constraint. is in milliseconds, while limits
approximate output size. Also set a caller-side deadline (for example, GNU
timeout 10s); an externally interrupted command may leave incomplete JSON.
Inspect budget.timed_out even after exit 0: timed-out empty hits are not proof
that no history exists. A response ends the retrieval
attempt; indexing or repair is a separate mutating task. Use triage/health/status
for readiness diagnosis, not as repeated prerequisites to a short summary.
Broaden scope deliberately, expand useful hits, and preserve source/line citations.
view bounds context lines, not bytes; check excerpt size before including
a long JSONL record in an agent prompt.
Output conventions
- stdout = data only
- stderr = diagnostics
- exit 0 = success
Search asset contract
- SQLite is the source of truth for indexed conversations and messages. All derived assets (lexical index, semantic vectors, analytics rollups, retention backups) can be rebuilt from SQLite; no derived asset is authoritative.
- Lexical search is the required fast path. Missing, stale, or incompatible lexical assets are treated as derived-state problems that cass should rebuild from SQLite instead of asking operators to perform routine manual repair.
- Hybrid is the default search intent. Robot metadata (
) reports the requested mode, realized mode, semantic refinement status, and any lexical fallback reason when semantic assets are not ready.--robot --robot-meta - Semantic assets are opportunistic background enrichment. Lexical-only results are expected during first indexing, semantic catch-up, disabled semantic policy, or unavailable local model/vector files.
- Semantic model acquisition is opt-in:
cass models installdownloads the default(aliasall-minilm-l6-v2 minilm, ~90 MB) only on explicit request;selects the larger multilingual MiniLM L12 model (~480 MB) for CJK/mixed-language archives. Cass never auto-downloads or auto-selects the multilingual space. Air-gapped installs use--model multilingual-minilm . While the selected model is absent, hybrid search uses lexical-only and reports--from-file <dir>fallback_mode="lexical"in health/status. cass triagecombines readiness,--json next_command,recommended_commands[], docs/schema pointers, starter workflows, and accepted recoveries for diagnosis. Review recommended mutations before executing them.cass healthand--json cass statusremain the narrower truth surfaces for readiness, active rebuilds, and recovery.--json
Lexical publish durability (atomic-swap)
- Every lexical publish is an atomic renameat2(RENAME_EXCHANGE) on Linux, or a parked-rename + restore-on-failure dance elsewhere. Readers never see a half-torn index — they see either the old or the new generation, never a mix. See
src/indexer/mod.rs::publish_staged_lexical_index. - The prior-live generation is retained under
<data_dir>/index/.lexical-publish-backups/<dated>/for a bounded retention window. Default cap is1(keep just the most-recent prior generation for one-step rollback); override via theCASS_LEXICAL_PUBLISH_BACKUP_RETENTIONenv var (0disables retention entirely, higher N keeps deeper history). Pruning runs after every successful publish and emits structuredtracing::info!events withfreed_bytes+retention_limitfor observability. - Crash recovery is automatic: a crash between the atomic swap and the retain-rename is handled by
recover_or_finalize_interrupted_lexical_publish_backupat the start of the next lexical publish or rebuild (not at process startup), which moves any orphaned canonical sidecar (.<name>.publish-in-progress.bak) into.lexical-publish-backups/before the next publish lands.
Quarantine, GC, and the doctor/diag surface
- Corrupt or failed-validation assets are quarantined rather than auto-deleted.
cass diagenumerates every quarantined derived artifact (failed seed bundles, retained publish backups, quarantined lexical generations; conversations excluded at ingest are listed by--json --quarantine cass quarantine list) with--json size_bytes,age_seconds,safe_to_gc, and a human-readablegc_reason. Thesafe_to_gcflag is advisory — it reflects retention policy + cleanup dry-run eligibility and is not wired to any automatic deletion path. cass doctorsurfaces the same quarantine summary plus--json checks[]status for every diagnostic the tool runs. Without, doctor is read-only (--fix auto_fix_applied=false,auto_fix_actions=[],issues_fixed=0); withit applies only the repairs whose dry-run plans are proven safe (currently: Track A analytics rebuild, Track B rollup rebuild via--fix rebuild_token_daily_statswhen thetoken_usageledger is intact).- Lexical generation cleanup uses a dispositions + inspection-required-first policy. Operators running
cass doctornever have a generation reclaimed silently — every quarantine stays on disk until an explicit derived-asset rebuild (--fix cass models backfillor an index refresh recommended bycass health) supersedes it.--json - A derived (SQLite fallback) FTS repair that fails identically on 5 consecutive
cass indexruns escalates from a warning to a non-zero exit (#434): the counter persists in<data_dir>/index/.fts-repair-failure-streak.json, watch daemons log the escalation instead of exiting, and any run whose repair succeeds — or fails differently — resets it. Canonical rows and the Tantivy index are unaffected; runcass doctorfor the explicit repair.--rebuild-canonical-fts --yes --json
Schema stability guarantees
- JSON contract surfaces are pinned by golden-file regression tests under
tests/golden/robot/:capabilities,selftest,health,status,diag,models status/verify/,check-update introspect,doctor,,api-version stats,search,,export-html onboarding, thequarantineanddedupcommands andanalytics incidents, plussessionsandpackon their missing-database and error paths only.swarm statusscenarios are pinned undertests/golden/swarm_status/.triage,swarmandwork-packet swarm linthave no golden files; their shape is covered only by assertion tests. A change to any field name, type, or nullability fails the golden test suite and requires a deliberate regeneration pass (UPDATE_GOLDENS=1 rch exec).-- env CARGO_TARGET_DIR=/data/tmp/cass-golden-target cargo test--test golden_robot_json--test golden_robot_docs cass introspect's--json response_schemasblock enumerates every schema in a stable alphabetical order (BTreeMap-backed — see bead coding_agent_session_search-8sl73).- Error envelopes (
{error: {code, kind, message, hint, retryable}}) have a fixed shape.kindvalues are kebab-case; branch onerr.kind, not on the numeric code, for codes ≥ 10 (see the Error Handling section below).