Skip to content

State Persistence

Sheriff maintains persistent state to track your progress across sessions, context compaction, and agent switches.

State is stored in the .sheriff/ directory (relative to the working directory):

.sheriff/
├── sheriff.mv.db # H2 database with issues and progress
├── sheriff.log # Application logs
└── sheriff.*.log.gz # Rotated log archives
  • All issues from the loaded SARIF file
  • Fingerprints (unique identifiers)
  • Locations, messages, severities
  • Code snippets
  • Which issues are marked fixed (F)
  • Which issues are marked skipped (S)
  • Which issues are still pending (P)
  • Loaded SARIF filename
  • Content hash for change detection
  • Timestamp of last load

When your AI agent’s context compacts (truncates old messages), your progress is safe:

  1. Agent context compacts
  2. Agent calls sheriff load target="same.sarif"
  3. Sheriff detects same content hash
  4. Previous progress is restored
  5. Agent continues where it left off

When you restart Claude Code or your MCP client:

  1. Sheriff server restarts
  2. Agent calls sheriff load target="same.sarif"
  3. Previous progress is restored
  4. Agent continues from last checkpoint

When switching between AI agents:

  1. First agent makes progress
  2. Session ends
  3. Second agent starts, calls sheriff load
  4. First agent’s progress is preserved
  5. Second agent continues

Sheriff uses content hashing to detect SARIF changes:

qodana.sarif.json → SHA-256 hash → matches stored hash?
↓ ↓
Same content Different content
↓ ↓
Restore progress Clear old, start fresh

When a new SARIF file is loaded (different content):

  1. Prior progress counts are captured for the response
  2. Issues and progress tables are cleared
  3. New issues are loaded from the updated SARIF

Sheriff uses H2 embedded database with three tables:

Key-value store for session metadata and internal state (SARIF path, content hash, timestamps, schema version).

ColumnTypeDescription
keyVARCHAR(255)Primary key
valueVARCHAR(4096)Metadata value
ColumnTypeDescription
fpVARCHAR(64)Primary key (fingerprint)
ruleVARCHAR(255) NOT NULLRule that flagged issue
fileVARCHAR(4096) NOT NULLSource file path
lineINTLine number
colINTColumn number
msgTEXTIssue description
sevCHAR(1)Severity: H/M/L
snipTEXTCode snippet
ctxTEXTContext lines
ColumnTypeDescription
fpVARCHAR(64)Primary key (fingerprint)
statusCHAR(1) NOT NULLF (fixed), S (skipped)
tsTIMESTAMP DEFAULT CURRENT_TIMESTAMPWhen the status was set
noteTEXTOptional note
IndexTableColumn
idx_issues_ruleissuesrule
idx_issues_fileissuesfile
idx_issues_sevissuessev
idx_progress_statusprogressstatus

If state becomes corrupted:

Terminal window
rm -rf .sheriff/

Then reload the SARIF file to start fresh.

If wrong progress is restored (from old session):

  1. Check that SARIF content hasn’t changed
  2. If it has, the old progress won’t apply
  3. Delete .sheriff/ and reload

If you see “database locked” errors:

  1. Check for other Sheriff processes
  2. Kill any zombie Java processes holding the file lock
  3. If needed, delete .sheriff/ and reload