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-- theUPathimplementation over thefile_storagetable, 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/purgeCLI commands, both thin layers overDBPath.
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
- Usage --
docs/usage/index.md - Design --
docs/design/index.md - Workspace --
../../docs/README.md
License
Apache 2.0 -- see LICENSE.md.
Metadata
Release files for sonnet-storage 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sonnet_storage-0.1.4.tar.gz | 19.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sonnet_storage-0.1.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 40.4 kB
Release files / sonnet_storage-0.1.4.tar.gz
| Download URL | sonnet_storage-0.1.4.tar.gz |
|---|---|
| Size | 19.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3364b67eb3d684d659391de3f7d2afc1038b4d6ac6201728dfe5de2e5befcde4
|
|
BLAKE2b-256 checksum How to use checksums |
3e01a1b8dd0162484e72bde9c43fcb5e6751e22a36b8c8d5a8a04cd546d74c56
|
| 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 23, 2026.
Transparency logRelease files / sonnet_storage-0.1.4-py3-none-any.whl
| Download URL | sonnet_storage-0.1.4-py3-none-any.whl |
|---|---|
| Size | 21.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bf4e92400bdeceaba0d42ae4588633b79b7ee4392b86dfeb5d070cebb9460609
|
|
BLAKE2b-256 checksum How to use checksums |
cb35e2fea96852a4488cf8f7936fe45ef625614cc964d4d836f4150703e3af6e
|
| 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 23, 2026.
Transparency log