Skip to main content

sonnet-storage

Virtual file storage backed by a single PostgreSQL table, presented as a filesystem. Consumers use ordinary pathlib operations -- read_text(), write_text(), iterdir(), glob() -- and the backend is transparent.

Version 0.1.2. The public API is a UPath subclass plus two factory functions; there is no service class and no repository to learn. Resources that would otherwise be baked into a Python package -- SQL fragments, rule files, templates, prompts, config -- become rows you can change without a redeploy.

What it provides

  • DBPath -- the UPath implementation over the file_storage table, with virtual directories, soft delete and recovery.
  • Content types -- text, JSON stored as native JSONB, and binary.
  • Versioning -- a monotonic write counter per file.
  • Seeding -- loading local directories or bundled package data into storage.
  • Configurable protocol -- db:// by default, renameable for applications that already use another scheme.
  • StorageExtension -- registers the protocol and mounts the router in a sonnet-server application.
  • Adapters -- a REST router factory and ls / cat / rm / tree / purge CLI commands, both thin layers over DBPath.

The shipped router is unauthenticated: DBPath has no notion of a caller, so authorization belongs in front of it.

Install

uv add sonnet-storage

Depends on sonnet-server, universal-pathlib, loguru, typer and rich. PostgreSQL only -- json_content and tags use PostgreSQL types and there is no portability layer. The only extra is dev.

Usage

register_protocol() must be called once at startup, before any db:// URL is resolved. StorageExtension does it in on_startup; a CLI, a worker, an Alembic hook or a test must call it itself.

from sonnet_core.database import borrow_db_session
from sonnet_storage import get_storage_root_db, register_protocol

register_protocol()

root = get_storage_root_db()

for path in (root / "rules").iterdir():
    print(path.read_text())

with borrow_db_session():
    (root / "config.yaml").write_text("debug: true")

Nothing in this package commits. Writes need a transaction boundary around them, or they are lost. See the usage guides for the full filesystem surface, seeding, and the REST and CLI adapters.

Database

The package ships the FileStorage model and the schema reference, but no migration -- the consumer owns its Alembic chain, per ADR-0002. The authoritative schema is docs/design/data-model.md.

Documentation

License

Apache 2.0 -- see LICENSE.md.

Metadata

Release files for sonnet-storage 0.1.3

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

Source distribution (sdist)

Source distribution for sonnet-storage 0.1.3
File Size Uploaded
sonnet_storage-0.1.3.tar.gz 18.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sonnet-storage 0.1.3
File Interpreter ABI Platform
sonnet_storage-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 40.2 kB

Release files / sonnet_storage-0.1.3.tar.gz

Download URL sonnet_storage-0.1.3.tar.gz
Size 18.9 kB
Tags Source
SHA-256 checksum
How to use checksums
7d57c019d2979d9b402527b6c67c4f242e30aaef756282ac96e4ba34b420ab60
BLAKE2b-256 checksum
How to use checksums
905819195f104650e6c5c2cd1355ce3749547992c67700f3eee601e0f6d716b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Aug 22, 2026.

Transparency log

Release files / sonnet_storage-0.1.3-py3-none-any.whl

Download URL sonnet_storage-0.1.3-py3-none-any.whl
Size 21.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
239b0422142d2ecf0af8a969c914ca72c7b0c2aec7799f87e25aeb85884b2652
BLAKE2b-256 checksum
How to use checksums
fac81ee9c5c72c4a61a0807b292e0c76712d0fe82e9a441d0a9fb1218bd7ac2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Aug 22, 2026.

Transparency log

Release history Release notifications | RSS feed

0.1.4

2 release files

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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