Skip to content

fix: tolerate SQLite sidecars unlinked during permission checks - #693

Merged
aniketmaurya merged 1 commit into
mainfrom
fix/sqlite-journal-race-20261029
Oct 29, 2026
Merged

aniketmaurya merged 1 commit into
mainfrom
fix/sqlite-journal-race-20261029

Conversation

@aniketmaurya

@aniketmaurya aniketmaurya commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Concurrent SQLite commits can unlink a journal, WAL or SHM file after pathname lookup resolves its inode. The inventory permission guard then sees a legitimate zero-link inode and rejects the saved-data file, interrupting guest cleanup.

Re-resolve zero-link sidecars until the current pathname is present or absent. Any replacement must still pass the existing regular-file, ownership and single-link checks. The main database is never skipped, and the repair opens or closes no database descriptors.

Validation

  • Three deterministic integration cases reproduce native SQLite unlink during permission checks for journal, WAL and SHM: all fail before the fix and pass after it; committed data survives.
  • All 90 inventory/storage tests pass, including symlink and hardlink rejection for the main database and every sidecar.
  • Full suite: 3,029 passed, 17 skipped, 77 deselected. A final test typing correction was followed by rerunning all 90 owning tests and mypy.
  • Native Linux XFS probe: 106,629 checks, 2,676 writes and 17 actual zero-link observations over 30 seconds, with zero errors.
  • Ruff, formatting and commit hooks pass.

Review

Independent local adversarial review found no actionable issues. Optional external review was unavailable because automatic approval review rejected disclosure of private source.

This PR repairs the SDK race. Fleet dependency updates and live rollout qualification are separate.

Summary by CodeRabbit

  • Bug Fixes

    • Improved reliability when SQLite sidecar files are removed during inventory checks, allowing inventory reads to complete while preserving existing safety checks.
    • Strengthened checks for unsafe database and sidecar locations, including links and writable parent directories.
  • Tests

    • Added coverage for SQLite sidecar changes during active commits and for unsafe database and sidecar paths.

@aniketmaurya
aniketmaurya requested a review from a team October 29, 2026 20:07
@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Automatic approval policy

Commit: 3955f21ea082.

Setting Effective value Source
Automatic approvals Enabled Global configuration
Merge risk Moderate Global configuration
Security risk Not set Global configuration

Not set means no limit was configured after inheritance. Use @coderabbitai configuration to inspect the resolved settings and their sources.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: QUIET
  • Plan: Advanced
  • Run ID: bbf1ead0-3ae4-40ad-921b-48ae268f290a
Commits

Reviewing files that changed from the base of the PR and between 1caa254 and 3955f21.

Files selected for processing: 3
  • src/celesto/cli/_sqlite.py
  • tests/integration/test_private_runtime_state.py
  • tests/storage/test_storage.py

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

Walkthrough

The SQLite inventory guard now rechecks sidecars with zero links and skips further checks if a sidecar disappears during the recheck. Tests cover concurrent commits during inventory reads and unsafe links at database and sidecar paths.

Changes: SQLite sidecar inventory guard

Layer / File(s) Summary
Sidecar recheck and validation
src/celesto/cli/_sqlite.py, tests/integration/test_private_runtime_state.py, tests/storage/test_storage.py
The inventory guard repeats lstat() for a sidecar with zero links and skips it if it disappears during the lookup. Integration tests coordinate a commit with an inventory read. Storage tests cover symlink and hardlink cases for the database and SQLite sidecars.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

  • CelestoAI/celesto#692: Enables SQLite WAL and uses WAL/SHM sidecars; it also addresses sidecars disappearing during permission checks.
  • CelestoAI/celesto#687: Adds the SQLite inventory permission guard for database and sidecar paths that this change extends.

Suggested reviewers: yanurag-dev

Merge Risk: Minimal · up to 3955f

The change tolerates disappearing SQLite sidecars without weakening existing file validation. No actionable merge-blocking risk was identified; merge after normal checks pass.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the primary change: tolerating SQLite sidecars that are unlinked during permission checks.
Description check Passed The description provides a clear summary, rationale, implementation constraints, validation results, and review context. It omits the required Related Issues and Checklist sections and uses Validation…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description provides a clear summary, rationale, implementation constraints, validation results, and review context. It omits the required Related Issues and Checklist sections and uses Validation instead of Testing, but the available information is mostly complete and directly relevant.

Full details: Docstring Coverage

Explanation

Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 4 functions across 3 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@aniketmaurya
aniketmaurya merged commit 562b735 into main Oct 29, 2026
22 checks passed
@aniketmaurya
aniketmaurya deleted the fix/sqlite-journal-race-20261029 branch October 29, 2026 20:14
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.

1 participant