Skip to main content

gnomon-postgres (Python)

Branches, time travel and merges for PostgreSQL apps on the gnomon extension: the SDK (runs for agents and tasks, review, the core), psycopg helpers, SQLAlchemy and Django, and pytest fixtures with snapshots. import gnomon.

from gnomon import Gnomon

gn = Gnomon(app="dbname=shop user=shop_app", runs="dbname=shop user=shop_runs")
with gn.start_run("Refund order 3", actor="support-bot") as run:   # a branch for this task
    run.sql("update orders set status = 'refunded' where id = 3")
    if run.summary()["checks"]["passed"]: run.merge()
    else: run.submit("Refund order 3")                               # a change request instead

Leaving the with block without merge() or submit() discards the branch. run.url(base) and run.connection(base) give a tool a connection string, or a psycopg connection, pinned to the run (a login of the run's own, confined to its branch, dropped when the run ends). With asyncpg: AsyncGnomon(app=asyncpg_source(pool), runs=asyncpg_source(runs_pool)) (from gnomon.asyncpg import asyncpg_source; the asyncpg extra). AsyncGnomon is the same API for psycopg.AsyncConnection (the sync client is generated from it, so they cannot drift). gn.requests, gn.branches, history, blame, revert, status() and doctor() are the review and core layers. Tools for agent frameworks bound to one run: gnomon.tools.anthropic_tools(run), openai_agents_tools(run), langchain_tools(run), mcp_handler(run). The two logins, the envelope and the errors are as in the TypeScript SDK (sdk/ts/README.md); both pass the same conformance scenarios (sdk/spec).

Helpers

import gnomon, psycopg
conn = psycopg.connect(gnomon.branch_dsn("dbname=shop", "feature"))   # sessions start on a branch
with gnomon.branch(conn, "feature"): ...                               # or switch one connection
opts = gnomon.connection_options(admin_conn, "feature")                # what the database says the
                                                                       # branch needs (schema versions, masks)

use, begin (one transaction, for poolers), create_branch, create_scratch, drop_branch, diff, merge. SQLAlchemy: gnomon.sqlalchemy.branch_engine(url, branch) and attach_branch(engine, get_branch) (each transaction on the branch a callable names). Django: gnomon.django.BranchMiddleware (a branch per request from X-Gnomon-Branch).

Tests on branches

def test_signup(gnomon_conn, gnomon_snapshot):     # a psycopg connection on a fresh scratch branch
    signup(gnomon_conn, "a@x.io")
    gnomon_snapshot.assert_match(gnomon_conn)      # the branch's diff against a stored file

GNOMON_TEST_DSN=... pytest (the plugin loads itself when the package is installed; --gnomon-update-snapshots records, --gnomon-keep keeps the branches). gnomon.testing.assert_no_changes and assert_changed check a branch's diff directly.

Install: pip install gnomon-postgres (extras: sqlalchemy, django, test).

Metadata

Release files for gnomon-postgres 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gnomon-postgres 1.0.0
File Size Uploaded Provenance Actions
gnomon_postgres-1.0.0.tar.gz 29.6 kB With provenance Details for gnomon_postgres-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gnomon-postgres 1.0.0
File Interpreter ABI Platform Actions
gnomon_postgres-1.0.0-py3-none-any.whl Python 3 none any Details for gnomon_postgres-1.0.0-py3-none-any.whl

Total release size: 58.0 kB

Release files / gnomon_postgres-1.0.0.tar.gz

Download URL gnomon_postgres-1.0.0.tar.gz
Size 29.6 kB
Tags Source
SHA-256 checksum
How to use checksums
44f69c9e10edc6403bd4c10fe7ec4f385cdef332c59777ab15d774111bb5aafb
BLAKE2b-256 checksum
How to use checksums
c179d21e1c1af011427ae64dc106d665d67d6ea83a7c54caa6c50f7db56d5bfd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Release files / gnomon_postgres-1.0.0-py3-none-any.whl

Download URL gnomon_postgres-1.0.0-py3-none-any.whl
Size 28.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
98e32988d4560ba5e8b1a0b357ecaae6de7ffa460e1d37fec3a96dd9e13ace2d
BLAKE2b-256 checksum
How to use checksums
fd51db4254a159e35d6c1ca88fd6f6dcbcbe572923e23872c215fa26cf4a982c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Security for gnomon-postgres 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for gnomon_postgres-1.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page