Repository navigation
feat: read-only open — OpenOptions::read_only (#429) - #464
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015GgLEs8YozJjYhwPEYgTUn
A read-only handle writes nothing to the .graph file or its WAL and shows the same data a read-write open would: the WAL is applied in memory but neither checkpointed nor deleted, a v7 file is read into memory instead of migrated, an empty file is an empty database, and a torn page 0 after migration is read through the backup meta without being restored. A missing file is the new STG-042. The file is locked in shared mode (try_lock_shared), so read-only handles coexist in one process or several, and exclude a read-write open (and are excluded by one) with the existing STG-025/STG-026. The in-process registry now records one writer or a count of readers. transact, retract, begin_write, checkpoint and rebuild_indexes fail with the new API-014 before a tx count is taken; queries, cursors, fact_log, verify and rule registration work, and drop does not checkpoint. As a backstop, the shared-mode backend refuses page writes and syncs with the new INT-056. Bindings (open_with_options with read_only, page_cache_size and allow_unlocked) live in the binding repositories and follow separately. Design: docs/superpowers/specs/2026-10-07-read-only-open-design.md Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015GgLEs8YozJjYhwPEYgTUn
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
7 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #429 (Rust API; exposing
open_with_optionswithread_only,page_cache_sizeandallow_unlockedin the bindings is #465).What
OpenOptions::read_only(true)opens a database so that nothing done through the handle writes to the.graphfile or its WAL.try_lock_shared, so any number of read-only handles can hold it, in this process or in others. A read-only handle and a read-write handle refuse each other with the existing STG-025 or STG-026, with the same retry budget. While a reader is open, no writer can change the file or the WAL under it. The in-process registry (OPEN_PATHS) now records either one writer or a count of readers, so STG-025 still means "this process holds a conflicting handle".allow_unlockedadmits many readers or one writer, never both.transact,retract,begin_write,checkpointandrebuild_indexesfail with the new API-014 before a tx count is taken. Queries, cursors,fact_log,verify,prepare, UDFs and rule registration (memory only) work. Dropping the handle does not checkpoint. The same refusals apply toread_onlyon an in-memory database.write_pageandsyncwith the new INT-056. If a check is ever missed, the call fails rather than writing.page_cache_sizealready serves every committed page read, so it applies unchanged. The docs now say how to keep the whole file in memory (file_size / 4096pages).Design:
docs/superpowers/specs/2026-10-07-read-only-open-design.mdTests
1329 total (1320 passing, 9 ignored), up 20.
tests/read_only_open_test.rs(13 tests):tx_countand fact log as a read-write one.tests/golden_corpus_test.rsopens every golden file (v7 and v8, with pending and stale WALs) read-only first. It checks the manifest'stx_countand queries, and that neither the file nor its WAL changes.Docs updated: CHANGELOG, ROADMAP, README, CLAUDE.md, TEST_COVERAGE, ERROR_REFERENCE (STG-042, API-014, INT-056, plus notes on STG-025/026). The wiki is left for the v3.0.0 doc sync, as with the earlier v3 PRs.
🤖 Generated with Claude Code
https://claude.ai/code/session_015GgLEs8YozJjYhwPEYgTUn