
transaction-correctness
How WAL mechanics, checkpointing, concurrency rules, recovery work in tursodb
- Installs
- 1.2K
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/tursodatabase/turso --skill transaction-correctness- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads transaction-correctness automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Transaction Correctness Guide
Turso uses WAL (Write-Ahead Logging) mode exclusively.
Files: .db, .db-wal (no .db-shm - Turso uses in-memory WAL index)
WAL Mechanics
Write Path
- Writer appends frames (page data) to WAL file (sequential I/O)
- COMMIT = frame with non-zero db_size in header (marks transaction end)
- Original DB unchanged until checkpoint
Read Path
- Reader acquires read mark (mxFrame = last valid commit frame)
- For each page: check WAL up to mxFrame, fall back to main DB
- Reader sees consistent snapshot at its read mark
Checkpointing
Transfers WAL content back to main DB.
WAL grows → checkpoint triggered (default: 1000 pages) → pages copied to DB → WAL reused
Checkpoint types:
- PASSIVE: Non-blocking, stops at pages needed by active readers
- FULL: Waits for readers, checkpoints everything
- RESTART: Like FULL, also resets WAL to beginning
- TRUNCATE: Like RESTART, also truncates WAL file to zero length
WAL-Index
SQLite uses a shared memory file (-shm) for WAL index. Turso does not - it uses in-memory data structures (frame_cache hashmap, atomic read marks) since multi-process access is not supported.
Concurrency Rules
- One writer at a time
- Readers don't block writer, writer doesn't block readers
- Checkpoint must stop at pages needed by active readers
Recovery
On crash:
- First connection acquires exclusive lock
- Replays valid commits from WAL
- Releases lock, normal operation resumes
Turso Implementation
Key files:
- WAL implementation - WAL implementation
- Page management, transactions
Connection-Private vs Shared
Per-Connection (private):
Pager- page cache, dirty pages, savepoints, commit stateWalFile- connection's snapshot view:max_frame/min_frame- frame range for this connection's snapshotmax_frame_read_lock_index- which read lock slot this connection holdslast_checksum- rolling checksum state
Shared across connections:
WalFileShared- global WAL state:frame_cache- page-to-frame index (replaces.shmfile)max_frame/nbackfills- global WAL progressread_locks[5]- read mark slots (TursoRwLock with embedded frame values)write_lock- exclusive writer lockcheckpoint_lock- checkpoint serializationfile- WAL file handle
DatabaseStorage- main.dbfileBufferPool- shared memory allocation
Correctness Invariants
- Durability: COMMIT record must be fsynced before returning success
- Atomicity: Partial transactions never visible to readers
- Isolation: Each reader sees consistent snapshot
- No lost updates: Checkpoint can't overwrite uncommitted changes
References
FAQ
What does the transaction-correctness skill do?
How WAL mechanics, checkpointing, concurrency rules, recovery work in tursodb
How do I install transaction-correctness?
Run npx skills add https://github.com/tursodatabase/turso --skill transaction-correctness in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/transaction-correctness/ (personal) or .claude/skills/transaction-correctness/ (project).
Which AI agents can use transaction-correctness?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is transaction-correctness safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains transaction-correctness?
It is published by tursodatabase in tursodatabase/turso. It has 1,239 recorded installs.
More from tursodatabase/turso
code-quality
tursodatabase/turso
General Correctness rules, Rust patterns, comments, avoiding over-engineering. When writing code always take these into account
index-knowledge
tursodatabase/turso
Generate hierarchical AGENTS.md knowledge base for a codebase. Creates root + complexity-scored subdirectory documentation.
debugging
tursodatabase/turso
How to debug tursodb using Bytecode comparison, logging, ThreadSanitizer, deterministic simulation, and corruption analysis tools
async-io-model
tursodatabase/turso
Explanations of common asynchronous patterns used in tursodb. Involves IOResult, state machines, re-entrancy pitfalls, CompletionGroup. Always use these patterns in core when doing anything IO
testing
tursodatabase/turso
How to write tests, when to use each type of test, and how to run them. Contains information about conversion of .test to .sqltest, and how to write .sqltest and rust tests
storage-format
tursodatabase/turso
SQLite file format, B-trees, pages, cells, overflow, freelist that is used in tursodb
Popular other skills
hyperframes-cli
heygen-com/hyperframes
The HyperFrames CLI by job - scaffold, check, look at frames, edit the timeline, preview, render locally or in the cloud, publish, project history - plus reading its JSON and recovering from build or render failures.
triage
mattpocock/skills
Move issues and external PRs through a state machine of triage roles, categorise, verify, grill if needed, and write agent-ready briefs.
ask-matt
mattpocock/skills
Ask which skill or flow fits your situation. A router over the skills in this repo.
to-questionnaire
mattpocock/skills
Turn a decision you can't fully answer into a questionnaire for someone else to fill in.
loop-me
mattpocock/skills
Grill me about specs for the workflows I want to build, within this workspace.