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.5

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.5
File Size Uploaded Provenance Actions
sonnet_storage-0.1.5.tar.gz 19.0 kB With provenance Details for sonnet_storage-0.1.5.tar.gz

Built distribution (wheel)

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

Total release size: 40.5 kB

Release files / sonnet_storage-0.1.5.tar.gz

Download URL sonnet_storage-0.1.5.tar.gz
Size 19.0 kB
Tags Source
SHA-256 checksum
How to use checksums
d86ca090cf68264a637e31d2f1ca71ac27cbf917349aeaec3a147f4cafdd759f
BLAKE2b-256 checksum
How to use checksums
0726c734e259e8d065b23288e24c80c6fc189b7744317665dbdcd5bd6a7b1036
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 11, 2026.

Transparency log

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

Download URL sonnet_storage-0.1.5-py3-none-any.whl
Size 21.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b3e6132ae91cabbcebd58a5918ea750f42225fedd05d376053c99cf824f0a790
BLAKE2b-256 checksum
How to use checksums
9db095338550aa46d441c4665c79fec0b39f2bf262ef1296e71a0a12fe786ade
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 11, 2026.

Transparency log

Security for sonnet-storage 0.1.5

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 sonnet_storage-0.1.5.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 11, 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