Skip to content

fix(state): make SQLite side-file hardening race-safe - #312

Draft
munezaclovis wants to merge 3 commits into
mainfrom
agent/fix-sqlite-aux-hardening-race
Draft

fix(state): make SQLite side-file hardening race-safe#312
munezaclovis wants to merge 3 commits into
mainfrom
agent/fix-sqlite-aux-hardening-race

Conversation

@munezaclovis

Copy link
Copy Markdown
Contributor

What changed

  • Harden the persistent pv.db file unconditionally.
  • Treat NotFound as benign only when SQLite removes pv.db-wal or pv.db-shm during hardening.
  • Preserve typed failures for a missing persistent database, unsafe permissions, wrong ownership, and other filesystem errors.
  • Add deterministic state coverage for side-file disappearance and daemon integration coverage for watcher liveness and job state.

Why

SQLite may remove its WAL and shared-memory files between discovery and the permission/ownership checks. The resulting NotFound escaped through the project config watcher and could stop the daemon.

The persistent database is not ephemeral, so its disappearance remains an error. No retries or ownership checks were weakened.

Review commits

  1. fix(state): require persistent database hardening
  2. fix(state): tolerate disappearing SQLite side files
  3. test(daemon): cover disappearing SQLite side files

Checks

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
  • cargo nextest run -p state (87 passed)
  • cargo test -p daemon --test daemon_foundation (31 passed)

Closes #309

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f0e9e940-1b86-4c00-b0b3-af72eadbb767

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codspeed-hq

codspeed-hq Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 7 untouched benchmarks


Comparing agent/fix-sqlite-aux-hardening-race (05230cd) with main (058373c)

Open in CodSpeed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Database permission hardening races with SQLite WAL removal

1 participant