Skip to content

feat(db): per-transaction sync mode and chunk size: TxOptions and begin_write_with (#871) - #882

Merged
adityamukho merged 7 commits into
v3from
feat/871-tx-options
Nov 10, 2026
Merged

adityamukho merged 7 commits into
v3from
feat/871-tx-options

Conversation

@adityamukho

@adityamukho adityamukho commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Implements #871. Part of #862 (design: docs/superpowers/specs/2026-11-06-862-override-audit-design.md §6, PR 3).

What

  • TxOptions (#[non_exhaustive], Clone + Debug + Default + PartialEq + Eq; fields synchronous: Option<SyncMode>, chunk_facts: Option<usize>; builders new, synchronous, chunk_facts), exported from the crate root and minigraf::db.
  • Minigraf::begin_write_with(TxOptions). begin_write() is begin_write_with(TxOptions::default()); None means the database value. Same errors as begin_write (INT-001, API-014).
  • synchronous decides whether that transaction's WAL entry is synced. A Full commit syncs the whole WAL, so earlier Normal entries become durable too. No effect on a transaction that becomes large (it commits as a checkpoint; its WAL guard header is always synced: a deviation from Audit which OpenOptions settings should be overridable per query (and which already are) #862 §6, recorded there with a dated note) or on an in-memory database.
  • chunk_facts replaces transaction_chunk_facts for that transaction, with the same clamp (1..=1,000,000). The thread-local test hook still takes precedence.
  • WalWriter keeps no sync mode: each append_entry is given its transaction's, so a mode cannot leak into later transactions.

Tests

  • Test models: the lost-sync fault now cuts the WAL back to its last successful sync (before, unsynced Normal entries survived it), and a test-only Minigraf::power_loss ends a handle with the unsynced WAL tail cut off. Both are test-only code.
  • src/tx_options_tests.rs (17): API and errors; sync per database mode × transaction mode; no mode leak (commit, rollback, drop, a rolled-back large Normal transaction); Normal/Full sequences with a kill and a power loss after each, checked record by record via fact_log; large Normal transaction durable after power loss; auto-checkpoint unchanged; in-memory; chunk_facts behaviour, clamp, scope and test-hook precedence; committed data independent of the options.
  • src/fault_matrix.rs: three mixed-mode operations, every fault at every write and sync, prefix-guarantee reopen check.
  • tests/crash_kill_test.rs: a PerTxSync variant (no test-hooks needed), run per PR and in the nightly 100-round workflow without a workflow change.

Docs

docs/CONFIGURATION.md, docs/DURABILITY.md, README.md, CHANGELOG.md, docs/TEST_COVERAGE.md, CLAUDE.md. Docs site: project-minigraf/minigraf-docs#94.

Size

Dist binary −144 B versus v3 locally (nightly 1.101: 1,266,408 → 1,266,264 B); gate unchanged at 1,240 KiB.

🤖 Generated with Claude Code

https://claude.ai/code/session_01H2a7QouMzKp3tAWxgVsxRf

adityamukho and others added 7 commits November 10, 2026 09:41
…nc mode (#871)

WalWriter no longer stores a SyncMode: each append is given the mode of
the transaction that commits it, so a per-transaction mode cannot leak
into later transactions. The lost-sync test fault now cuts the WAL back
to its last successful sync, dropping unsynced Normal entries as a real
lost fsync would, and a test-only power-loss model ends a handle with the
unsynced WAL tail cut off.

Part of #862.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H2a7QouMzKp3tAWxgVsxRf
…nd power-loss models (#871)

Part of #862.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H2a7QouMzKp3tAWxgVsxRf
… modes (#871)

Part of #862.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H2a7QouMzKp3tAWxgVsxRf
…ction (#871)

Part of #862.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H2a7QouMzKp3tAWxgVsxRf
Configuration, durability and README text for the per-transaction
options, the CHANGELOG entry, the test-coverage section, and a dated note
in the #862 design recording that the WAL guard of a large transaction is
always synced.

Part of #862.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H2a7QouMzKp3tAWxgVsxRf
Part of #862.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H2a7QouMzKp3tAWxgVsxRf
…s in the mixed fault matrix (#871)

The begin_write_with example now runs in memory on every target, and the
TxOptions file example is compiled only off wasm32, as the other
file-database examples are. The mixed-mode fault matrix now requires a
lost sync of a Full commit to drop the unsynced entries before it, and a
Normal commit to make no sync at all.

Part of #862.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H2a7QouMzKp3tAWxgVsxRf
@codecov

codecov Bot commented Nov 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.16514% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/fault_matrix.rs 96.89% 0 Missing and 4 partials ⚠️
src/db.rs 96.87% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@adityamukho
adityamukho merged commit a60435c into v3 Nov 10, 2026
23 checks passed
@adityamukho
adityamukho deleted the feat/871-tx-options branch November 10, 2026 04:31
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