Repository navigation
0.1.0-alpha.3: Postgres store
Pre-release
Pre-release
·
131 commits
to main
since this release
[0.1.0-alpha.3] - 2026-10-28
The first release with the Postgres store.
Breaking
- A write inside your own transaction returns a
PendingRevisioninstead of a
Revision(ADR-015): Pythonengine.write(..., conn=)and RustEngine::write_in.
Native writes still returnRevision. On SQLite it is resolved at once.
Migration: pass it asat_least=pending, or callpending.revision()after commit
(Python); in Rust,tx.commit()?thenengine.resolve(&pending)?.
int(pending)andoperator.index(pending)keep working for one release with a
DeprecationWarning; comparisons and arithmetic do not. Rust has no transition aid. - For store implementers only:
pemba_core::write::delete_matchingreturnsDeletedand
pemba_core::write::write_schemareturnsSchemaWritten, which carry anApplied
(a revision, or a batch a commit trigger maps to one). Migration for stores that
allocate revisions inside the write:.into_result()and.into_stored(source, hash).
SqlDialectgainsschema_lock, defaulting to none. PendingRevision::resolved()is no longer aconst fn.WritableStoregains
resolve_batch, with a default for stores that number writes inside them.
Added
- Postgres store (
pemba-store-postgres, Postgres 15+): relationships in a schema of
your database, revisions assigned at commit so concurrent writers stay in commit order,
writes that join your transaction (Engine::write_inwithPgTxn), GC that compacts
and prunes, TLS through rustls. Wheels include it. See the README's Postgres section;
benchmarks inbenches/RESULTS.md. PendingRevision(Rust and Python) andEngine::resolve. Python'sat_least=
accepts aPendingRevision.- Error codes
REVISION_PENDINGandWRITE_ROLLED_BACK, fromEngine::resolveon a
store that assigns revisions at commit (Python:RevisionPendingand
WriteRolledBack, bothConsistencyErrors). - Python:
Engine.postgres(dsn, *, schema=None, pool_size=8, auto_migrate=False), whose
calls release the GIL;write(conn=)on it joins a psycopg 3 or psycopg2 transaction,
a SQLAlchemySession/Connection, ordjango.db.connection, and works from async
code throughAsyncSession.run_sync.pemba.PembaWarning.Engine::store()in Rust. - Postgres: a prepared-statement cache per pooled connection (up to 256 statements,
least recently used evicted and closed on the server). It is emptied on reconnect,
after a schema write, and on every connection when the server reports a stale plan
after DDL. It is not used inside your own transaction. - Postgres: batched writes. A write sends one statement per kind of operation (creates,
touches, deletes), however many tuples it holds. If a create hits an existing tuple, the
write is undone to pemba's savepoint and rerun one operation at a time, so
AlreadyExistsnames the same tuple as before and your transaction stays usable. For
store implementers:SqlDialectgainsbulk_rows, defaulting to none (one statement
per operation, as before; SQLite keeps that). pemba check --color <auto|always|never>.auto, the default, is the previous
behaviour: colour only on a terminal, and not whenNO_COLORis set.alwayscolours
even a pipe and overridesNO_COLOR(forless -R);neverturns colour off.
Changed
--explainandCheckTrace::render(): when an exclusion denies because its subtracted
side removed a granted base, both sides are now on the granting path, so the tree shows
where the permission was granted and where it was removed. The base line is no longer
marked(not needed).--explaincolour (CheckTrace::render_ansi()): evaluated nodes off the granting path,
falseones included, are drawn in the terminal's normal colour instead of dimmed. Only
skipped nodes and memo references are dimmed.(not needed)is printed in colour too,
so the coloured text is the plain text plus styling.--explaincolour: a line on the granting path is coloured as a whole, not just its
✓/✗mark: green where it granted, red where it denied (so the root of a denial is
red), still bold. Thedenied:header is red.--color neveroutput is unchanged.- Test-only: the
cycle_passestests readcheck_bulkstats from one global, always-on
span recorder filtered to the calling thread, instead of a per-call scoped subscriber,
the same capture as thelookuptests (#42, #43). - The README is written for newcomers: no internal task or decision numbers, the
specification linked once under "Design documents", and a diagram comparing a separate
authorisation service (two databases, dual writes) with pemba (one transaction).
Performance
- On Postgres, latency is round trips. A direct check costs about 5 round trips. Each
level of hierarchy it walks adds about 3, so a document 30 folders deep costs 99. A
write costs 10 whatever its size. On a Linux CI runner where one round trip took about
150 µs, p50 was 0.76 ms for a direct check (1.58 ms without the statement cache),
16 ms for 30 folders (47 ms) and 19 ms for a 1,000-tuple write (407 ms). Full figures,
with round trips for every scenario:benches/RESULTS.md. Fewer round trips for deep
hierarchies is planned.
Fixed
- Postgres: paging
read_relationshipsat an older revision no longer sorts every tuple
of the type for each page. The first 500-tuple page over 100,000 tuples went from
106 ms to under 1 ms, because the planner had misjudged how many rows the
older-revision filter keeps. Answers are unchanged.