Ruby's PStore transaction engine in pure Go — MRI-compatible, no cgo.
🌐 Website · 📚 Documentation
go-ruby-pstore is a pure-Go (no cgo) reimplementation of the transaction engine at the heart of Ruby's PStore — MRI 4.0.5's transactional, Marshal-backed object store (the pstore-0.2.1 gem). It runs the load → transaction-body → commit/abort state machine over a Hash "table" and serialises that table with go-ruby-marshal, so the on-disk bytes are byte-compatible with a file written by MRI's PStore: a real ruby -rpstore file loads here, and a file this engine commits is read back unchanged by MRI. It was extracted from rbgo's internals into a reusable standalone library: no dependency on the Ruby runtime, the dependency runs the other way. The file half — opening the store (O_CREAT), flock(LOCK_SH/LOCK_EX), the atomic-rename / rewind-truncate save strategies — is injected as a two-method Backend; rbgo wires the real os.File + syscall.Flock, tests use an in-memory backend. It is the PStore backend for go-embedded-ruby, bound by rbgo as a native module just like go-ruby-regexp and go-ruby-erb — differential-tested against MRI, 100% coverage, CI green across 6 arches and 3 OSes.
| Repo | What it is |
|---|---|
| pstore | the library: Ruby's PStore transaction engine in pure Go |
| docs | MkDocs Material documentation, versioned with mike, served at /docs/ |
| go-ruby-pstore.github.io | the Hugo landing page |
| brand | logos and brand assets |
- Pure Go, zero cgo. Cross-compiles and embeds anywhere; a static binary by default.
- Extracted from rbgo, reusable by anyone. A standalone library lifted from
rbgo's internals;
rbgobinds it as a native module, the same pattern as go-ruby-regexp and go-ruby-erb. - MRI byte-exact on disk. The table is
Marshal.dump/loaded through go-ruby-marshal, so a committed file is byte-compatible with one written by MRI'sPStore— validated by a differential oracle against therubybinary, round-tripped both directions (MRI→Go and Go→MRI). - The file seam is injected. Locking and the save strategy are the host's
job, supplied through a two-method
Backend: rbgo wires the realos.File+syscall.Flock, tests use an in-memory backend so the whole suite is deterministic and Ruby-free. - 100% test coverage is the target, enforced as a CI gate.
Complete — MRI byte-exact on disk. Faithful port of PStore's transaction semantics: commit on normal exit (skipping the write when nothing changed, MRI's checksum/size guard), Commit / Abort early exit, read-only transactions (writes raise PStore::Error), the full error taxonomy with MRI's exact messages, and the on-disk Marshal format via go-ruby-marshal — so files round-trip both directions with MRI's PStore. 100% coverage, gofmt + go vet clean, CI green across the six 64-bit Go targets (amd64, arm64, riscv64, loong64, ppc64le, s390x) and three operating systems. It is bound into the go-embedded-ruby (rbgo) ecosystem as a native module, where the file/locking layer lives.
BSD-3-Clause.
