Repository navigation
Adding an Object Store
Written against d5aad1f44 on 20 Nov 2026.
Conductor keeps three kinds of data, and S3 fits only one of them: the object store, which
holds the files that pass between processes. That seam is a five-method port,
ObjectStore, with one adapter today, LocalObjectStore. An S3 adapter is a new package that
implements the port, passes the shared conformance suite, and is built in one function of the
composition root.
The adapter itself is small. Most of the work is elsewhere:
-
Nothing selects an object store today.
build_object_storenamesLocalObjectStoredirectly, so how a deployment chooses S3 is a convention the owner must decide first. - A parquet read must seek, and DuckDB opens one object seven times to read it once. A remote adapter has to answer that without a network round trip each time.
- Each solve builds its own store in a child process, so the settings and the credentials must reach that child.
- Storing networks on S3 is a different and larger job. It is a new kind of warehouse, not an object store. The last section says why.
| Kind | Holds | Today | Is S3 a fit? |
|---|---|---|---|
| Warehouse | Projects, networks, every version, and the numbers a solve produced | Git, plain files, or PostgreSQL | Not through this port. See below |
| Stores | The bookkeeping of work: runs, jobs, imports, exports, workflow runs, and the durable checkpoints | SQLite under state/, or the PostgreSQL database |
No. They need transactions |
| Object store | Whole files handed between processes | A folder, objects/, under the storage root |
Yes. This page |
Storage describes all three.
| Key prefix | What | Written by | Deleted by |
|---|---|---|---|
handover/<job>/<attempt>/ |
A solve's input and output: the network document, the series parquet and the run values parquet | The API process (input) and the solve process (output) | The run's outcome, a cancel, and the start-up sweep |
exports/<id>/ |
An export's input handover and the file it wrote | The API process and the export process | The export's outcome and the start-up sweep |
upload/… |
A series upload, staged as parquet before it is written to a version | The API process | The call that staged it |
workflow-run/<run>/<step>/ |
The recorded output of each workflow step, and a workflow solve's handovers | The workflow engine | Nothing, today |
workflow-code/<hash>.py |
The generated module of a workflow run | Workflow.run |
Nothing, today |
Three things stay on local disk whatever the object store is: the warehouse, an import's staged file (a reader opens a path, which the object store never hands out), and each solve's scratch folder and logs.
flowchart LR
subgraph users["Who reads and writes objects"]
api["API process<br/>handover input, uploads, exports"]
solve["Solve process<br/>one per attempt"]
export["Export process"]
engine["Workflow engine<br/>step outputs, stored code"]
end
bridge["StoredObjectFileSystem<br/>DuckDB reads and writes parquet"]
port["ObjectStore port<br/>tz_ps_ports"]
local["LocalObjectStore<br/>objects/ under the storage root"]
remote["An S3 adapter<br/>tz_ps_s3_objectstore, to be written"]
root["build_object_store<br/>dependencies.py"]
api --> port
solve --> bridge
export --> bridge
engine --> port
bridge --> port
port --> local
port -.-> remote
root -->|"builds one, in each process"| port
The repository's rule is to ask before choosing a convention or a technology, and this work needs several.
| Decision | Why it is open | Options |
|---|---|---|
| How a deployment chooses the store |
build_object_store takes StorageConfig and returns LocalObjectStore(storage.object_store_path). No config key or entry point selects another |
A key in the storage section, as warehouse_kind selects a warehouse; or an entry-point group, as a kind of warehouse announces itself under tz_ps_datawarehouse.warehouses
|
| The client library | A new runtime dependency must be confirmed before pyproject.toml changes. No S3 library is in uv.lock today |
boto3, s3fs, or another |
| Where the credentials come from | No environment variable overrides a config key, by rule. The AWS libraries read their own environment and instance roles | The library's default chain, as the OTEL_* variables stay live for telemetry; or keys in the config document |
| How a read is served | A read must seek, and DuckDB asks for the size six times for each read | Stage the object to local disk as the stream opens, which the port's docstring allows; or range requests with the size cached |
Whether to add a size method to the port |
The design noted it as the fix for those six opens and did not add it | Add it with the adapter; or leave it and stage |
| Whether the wheel carries it | A new workspace member ships in the wheel by default, and its driver with it | Ship it; an extra of the root package, as postgresql is; or leave it out of the release |
| What CI tests it against | The conformance suite needs a real store to run on | An emulator in the test process, a container, or a bucket |
ObjectStore is in backend/libs/tz_ps_ports/src/tz_ps_ports/object_store.py, and its
docstrings are the contract. What each method must do, and what that means on S3:
| Method | Must | On S3 |
|---|---|---|
open_for_read_seekable(key) |
Answer a stream with read, seek, tell and close. Raise ObjectNotFoundError when nothing is at the key |
Staging to a temporary file gives a real seek and one download. Turn the client's "no such key" into ObjectNotFoundError
|
open_for_write(key) |
A context manager. The object changes only when the block exits cleanly. A block that raises leaves the object as it was. A write to a held key replaces it | A multipart upload: complete it on a clean exit, abort it on an exception. The stream needs no seek or tell, so parts can go up as they fill |
exists(key) |
Answer without any side effect | A head request |
discard(key) |
Raise nothing when the key is absent. Delete an unfinished write to the key as well | Delete the object, and abort any multipart upload still open for that key |
iterate_keys_under(prefix) |
Every key at or below the prefix, in lexical order, matching whole segments: run/21 is not under run/2
|
List with the prefix plus /, and include an object sitting at the prefix itself. Check the order the service lists in against the suite's case |
Four rules sit behind the table.
- No number becomes a Python object, and no object is held whole in memory. A year of hourly results is about 110 million numbers. A write that buffers the whole object before it uploads breaks the rule the port exists for.
- A retry writes the keys its predecessor wrote. So a write replaces, and never refuses.
-
A key is already safe.
ObjectKeyrefuses a backslash, a colon,..and an empty segment, so the adapter needs no path checks of its own, only its bucket and an optional prefix. -
The DuckDB bridge commits on close, whatever happened.
StoredObjectFileSystemcannot tell a finishedCOPYfrom a failed one, so a failedCOPYleaves an object, and every caller discards on failure. The adapter must make that discard work on a half-written object.
One distribution holds one object store backend, and names it: tz_ps_s3_objectstore, never
an extra of tz_ps_local_objectstore. Copy the shape of
backend/libs/tz_ps_local_objectstore:
backend/libs/tz_ps_s3_objectstore/
pyproject.toml # depends on tz-ps-models, tz-ps-ports and the client library
src/tz_ps_s3_objectstore/
__init__.py # exports the adapter
s3_object_store.py
tests/
test_s3_object_store.py
-
tz-ps-testinggoes in the package's own[dependency-groups] dev, so the wheel does not carry it. - The adapter raises its own typed errors and turns the client library's errors into them. A
missing driver should name what to install, as
PostgresqlDriverNotInstalledErrordoes. - The adapter takes its bucket, prefix and limits as constructor arguments. Nothing below the composition root reads config.
tz_ps_testing.object_store_contract.ObjectStoreContract holds what every adapter must do,
in 17 cases. An adapter's test class subclasses it and supplies one fixture:
class TestS3ObjectStore(ObjectStoreContract):
@pytest.fixture()
def object_store(self) -> ObjectStore:
return S3ObjectStore(...)The cases that a remote adapter is most likely to fail:
-
test_a_failed_write_leaves_no_objectandtest_a_failed_write_leaves_an_existing_object_alone. -
test_a_read_stream_seeks_to_the_end_and_back. -
test_iterate_keys_under_matches_a_whole_segmentand…_returns_lexical_order. -
test_duckdb_writes_and_reads_a_parquet_object_through_the_store, which drives a real DuckDBCOPYandread_parquetthrough the bridge.
Add the adapter's own tests for what the suite cannot see: an aborted upload leaves no parts
behind, discard removes an upload in flight, a missing bucket and refused credentials each
raise the typed error. Each test must be shown to fail against the one change that should
break it (Testing philosophy).
build_object_store in backend/src/tz_ps_conductor/dependencies.py is the only function
that may name an adapter. Three processes call it:
| Caller | Process |
|---|---|
get_object_store() |
The API process, and a notebook |
solve_process.py |
Each solve's child process |
export_process.py |
Each export's child process |
A child is started with spawn and is handed StorageConfig only. It reads the rest of the
config through the inherited TZ_PS_CONDUCTOR_CONFIG. So whatever selects and configures S3
must be in the config document or in StorageConfig, never held in the API process's memory,
and the credentials must be ones a child process can also resolve.
A new backend package has a place in each of these. backend/tests/test_import_contracts.py
names what is missing.
-
backend/pyproject.toml: the workspace dependency and source, the mypy path, the row in the import-linterlayerscontract (besidetz_ps_local_objectstore), andforbidden_modulesof the contract "only the composition root names an object store adapter". -
backend/mutation.toml: the package's entry. -
backend/release/pyproject.toml: regenerate withmake -C backend release-manifest, after the packaging decision above._NOT_RELEASEDingenerate_release_manifest.pyis the list of what stays out. -
uv.lock:uv lockinbackend/. -
deploy/and theDockerfile, if the image should offer it.
Adding a framework walks the same lists for a framework package.
make check at the root, and the backend gate in backend/CLAUDE.md. Then one real solve end
to end on the new store: run, read results, cancel a second run, and restart the server during
a third.
- One bucket prefix for one deployment. The start-up sweep deletes every handover whose job its own run store does not hold, or holds as ended. Two servers with separate run stores on one prefix would delete each other's handovers.
- The storage root is still local, and still owned by one process. The root lock, the warehouse (unless PostgreSQL), the scratch folders and the logs do not move.
-
Start-up lists keys.
discard_orphan_handoversanddiscard_ended_export_objectswalkhandover/andexports/at each start. -
Workflow objects are never deleted. Nothing removes
workflow-run/orworkflow-code/objects. On a local disk that is a slow leak; on S3 it is a bill. A lifecycle rule on those prefixes is the stopgap, and it must not touchhandover/: a handover is deleted by an action, never by a clock, because a timer would delete one from under a replay. -
Uploads that died. A killed process leaves a multipart upload open, which no listing of
objects shows.
discardreaches the ones whose key is known; a bucket rule that aborts old incomplete uploads covers the rest. - Time. A solve reads its input and writes its output once, so the cost is two transfers for each attempt, plus the six size checks for each parquet read if the adapter does not stage or cache.
It does not put networks on S3. The default warehouse is git, and every git operation is a subprocess against a local folder that needs real files, locks and an atomic rename. An object store offers keyed bytes and none of those.
It does not let two servers share one warehouse. The git adapter settles a concurrent write with a compare-and-swap on refs and a lock file, and both work because the writers share one disk. Staging a repository locally and uploading it turns both into decorations: the second upload overwrites the first without raising.
A warehouse on S3 would be a new kind of NetworkWarehouse that uses no git: a third
adapter beside the file-backed ones and PostgreSQL, announced under
tz_ps_datawarehouse.warehouses, and held to the warehouse contract suites and the memory
tests. For a deployment that wants no local state today, the route that exists is the
POSTGRESQL warehouse, which also holds the stores and the durable checkpoints.
Storage describes it.
- No object store but the local one has been built, so the port has been proved against one adapter and an in-memory test double.
- The port has no
sizemethod. - Nothing deletes workflow run objects.
The design is docs/specs/2026-09-10-object-store-port-design.md, with the handover designs
of 14 and 15 Sep 2026 beside it.
Using the app
Architecture
- Overview
- Python API
- Domain model
- Backend core
- Composition root and config
- Expression language internals
- Storage
- Execution
- Imports and exports
- Workflow engine
- HTTP API and contracts
- Frontend and desktop
- Build, CI and release
Contributing