DocsRunning cass
Watch Mode Internals
On this page
The flag enables real-time index updates as agent files change.
Debouncing Strategy#
File change detected
↓
[2 second debounce window] ← Accumulate more changes
↓
[5 second max wait] ← Force flush if changes keep coming
↓
Re-index affected files
- Debounce: 2 seconds (wait for burst of changes to settle)
- Max wait: 5 seconds (don't wait forever during continuous activity)
The debounce only batches events. On Unix, regular Codex
files, primary Claude Code JSONL logs, and local Pi Agent / Oh My Pi .jsonl
logs can publish a bounded prefix while a writer continues appending, including
a writer that keeps its writable descriptor open. Admission fixes a byte limit
and captures only records ending in a newline within that limit. The parser
and enrichment read the same private immutable view; file identity and a
content hash bind it to the original source. Later appends wait for another
pass. A trailing partial record, even valid JSON without its newline, is not
admitted by this live-prefix path. Pi/OMP retain the pinned parser's 100 MiB
source limit and preserve native session IDs, branch order, and OMP profiles.
Prefix publication does not certify EOF. Its durable receipt retains the byte boundary and normalized-message overlap, and the source stays queued for retry without advancing a complete-source watermark. Each retry reparses a bounded prefix through the pinned parser and validates the earlier projection before canonical message insertion. Truncation, replacement, in-place edits, or changes to already published message indices fail closed and require source reconciliation. Raw-mirror capture, when enabled, retains the same admitted bytes. An advisory lock still defers the source. Settled EOF and abandoned-tail recovery retain their existing inactivity checks.
Compressed Codex rollouts, Claude Desktop sidecars, Pi/OMP SQLite stores and
remote mirrors, non-Unix systems, and other formats retain their existing
admission behavior. For sources that remain deferred,
recent writes wait for CASS_ACTIVE_SESSION_RECENT_WRITE_WINDOW_SECS (default
120 seconds), and open-writer or advisory-lock evidence can defer them longer.
For the earlier conservative Claude Code path, 123 s, 139 s and 189 s were
measured on a synthetic appended session. Lowering the window shortens that
wait, at the cost of parsing files
that may still be changing. No sub-ten-second end-to-end latency is guaranteed
by the debounce settings.
These prefix paths do not qualify the broader multi-provider stable-prefix bead or establish a measured watch-to-search latency. See the Codex implementation and qualification notes for the byte/receipt contract, regression matrix, and remaining boundaries.
Path Classification#
Each file system event is routed to the appropriate connector:
~/.claude/projects/foo.jsonl → ClaudeCodeConnector
~/.codex/sessions/rollout-*.jsonl[.zst] → CodexConnector
~/.aider.chat.history.md → AiderConnector
State Tracking#
Watch mode maintains watch_state.json, one scan watermark (ms) per connector under a short connector code (cd Claude, cx Codex, gm Gemini, ...):
{"v":1,"m":{"cd":1699900000000,"cx":1699900000000}}
The global last_scan_ts and last_indexed_at watermarks live in the SQLite meta table, not in this file.
Incremental Safety#
-
File-level filtering only: When a file is modified, the entire file is re-scanned
-
1-second mtime slack: Accounts for filesystem timestamp granularity
-
No per-message filtering: Prevents data loss when new messages are appended
-
Completed-source reuse is a build-time property: a source that was fully ingested and has not changed is skipped, but only in builds whose
Cargo.lockresolves every dependency from a registry or git source. A build with a local path dependency or[patch]reparses every source on every incremental run.cass capabilitiesreports which applies as--json source_ingest_reuse.{enabled,disabled_by}(GH #426). Release binaries have it on. -
SSH mirrors have independent root receipts: each configured path keeps its own successful-scan fingerprint, including when several paths belong to the same SSH source. Unchanged roots require a filesystem metadata walk instead of transcript parsing. The receipt also tracks parser, connector-selection, path-mapping and exclusion-policy changes. Legacy receipts are refreshed on the first successful scan after upgrading (GH #574). Explicit
cass sources reingeststill rereads its selected roots and saves successful-scan receipts for the next ordinary index. -
Pi/OMP reuse completed transcripts individually: when a mirror changes, only new or changed JSONL files are parsed. Adding a sibling does not invalidate completed transcripts; SQLite stores retain directory and WAL checks. Newly synced files remain discoverable even when rsync preserves an old mtime. A scan error in an earlier root does not revoke a later transcript's independent completion receipt. The failed run still reports its error, holds its scan watermark and does not certify a new root receipt.
cass indexbypasses both root and file reuse.--full -
SSH sync retains pending indexing across retries: an interrupted, failed, or incomplete index leaves durable work for the next
cass sources sync, even when that retry transfers zero files.leaves that work pending;--no-index does not change it. A source without a matching completion record receives one ordinary incremental index before clean zero-transfer syncs can skip indexing. Completion records follow the selected archive, source configuration and ingest policy, and are invalidated when history or source/agent configuration is removed or changed.--dry-run
Source operations use the archive you select: sources sync, sources reingest, and sources setup honor global and accept for an explicit mirror and derived-index location. With alone, mirrors, locks and derived assets follow the selected database's directory. For example, cass reads the mirrors in into /archives/work.db.
Codex Token Backfill#
Codex event_msg token_count usage is attached to the nearest preceding assistant turn during indexing.
If you indexed Codex sessions before this behavior existed, backfill usage coverage with:
cass index --full
cass analytics rebuild --track a
Rebuilding Analytics Rollups#
cass analytics rebuild re-derives the Track A rollups (message_metrics,
usage_hourly, usage_daily, usage_models_daily) from messages already in
the archive; it never re-parses raw session files.
An unwindowed Track A rebuild (including unwindowed ) also
refreshes the daily_stats session-count cache from canonical conversations
and messages. This adds a complete, paginated pass over those rows. Windowed
rebuilds and Track-B-only rebuilds leave this cache unchanged.
On a large archive a full rebuild is a long single-core job, so daily refreshes should be windowed:
# Full rebuild (every rollup row dropped and recomputed)
cass analytics rebuild
# Only recompute the last two UTC days; older rollups are left untouched
cass analytics rebuild --days 2
cass analytics rebuild --since -2d # same window, relative syntax
cass analytics rebuild --since 2026-08-20 # from a date
The window is widened to the start of the UTC day containing the cutoff,
because rollups are bucketed by day and hour. Progress is logged per 10k
messages (analytics_rebuild_progress). Across analytics commands,
and are mutually exclusive, and malformed or reversed time bounds
return a usage error instead of silently running an unfiltered query.
, ,
and are query-time filters and are rejected here rather than
silently ignored. also rejects /; with , the window applies to Track A while Track B still rebuilds the complete
token_usage ledger. cass analytics validate likewise rejects every query
filter because its invariant checks always cover the complete analytics
database.
The TUI analytics dashboard never rebuilds rollups in-process: when rollups are
missing it spawns a detached cass analytics rebuild child, logs it to
<data_dir>/analytics-rebuild.log, and reports the pid in the status line;
reopen the dashboard once the rebuild finishes.