Skip to content

feat(object-store): shared store factory crate (SEQ-5) - #18

Open
Qard wants to merge 3 commits into
mainfrom
feat/shared-object-store-factory
Open

Qard wants to merge 3 commits into
mainfrom
feat/shared-object-store-factory

Conversation

@Qard

@Qard Qard commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Implements SEQ-5 — first item on the critical path for the Git Forge & S3 Repository Engine project.

What changed

ColdTier::create_store was a private method holding all object-store construction (local/S3/GCS/Azure). The forge needs the same logic for its own bucket, but depending on sequins-cold-tier would drag in Vortex, DataFusion, and arrow just to open a store.

New sequins-object-store crate — object_store, serde, url, thiserror and nothing else:

  • build(uri, &ObjectStoreConfig) -> Arc<dyn ObjectStore>
  • ObjectStoreConfig moves here, re-exported from sequins-cold-tier so sequins_cold_tier::ObjectStoreConfig still resolves
  • conditional_write_support(uri) -> ConditionalWriteSupport { create, update }

create_store delegates. Store-construction errors flatten onto the cold tier's existing Config/Storage variants, so messages callers match on are unchanged. Also drops the now-unused url dep from sequins-cold-tier.

Conditional write capability

Checked against object_store 0.13.2 rather than trusting the docs:

Backend PutMode::Create PutMode::Update
S3 / MinIO / R2 yes yes — If-Match on ETag
GCS yes yes — x-goog-if-generation-match
Azure yes yes
LocalFileSystem yes — via link(2) no — Error::NotImplemented

The split matters only for mutable pointers. Immutable content-addressed writes use Create on every backend and need no fallback.

For a mutable pointer, Update is the correct mechanism and is what production runs: one conditional write advances it, one read returns it. conditional_write_support exists so a caller can select an implementation — never to reject a store. Where update is false, the caller supplies its own serialisation for file:// and accepts weaker concurrency guarantees on a single-node, low-traffic backend where that is fine. file:// has to keep working; it does not have to be fast or multi-writer safe.

When using Update, carry both e_tag and version into UpdateVersion: S3 matches the ETag, GCS requires version and fails with MissingVersion without it.

Tests

Unit (6): URI/bucket parsing, unsupported-scheme rejection, file:// directory creation, the local Update gap (pinned so it fails loudly if object_store ever implements it), and a 32-way concurrent create race asserting exactly one winner, every loser seeing AlreadyExists, and the winner's bytes persisting.

Integration (2, tests/conditional_put_s3.rs, skipped unless SEQUINS_TEST_S3_URI is set): ETag CAS round trip including stale-version rejection and superseded-version replay rejection, plus a 16-way create race mirroring the local one.

cargo test -p sequins-object-store   # 6 unit + 2 integration, all pass
cargo test -p sequins-cold-tier      # 48 passed, no regressions
cargo clippy --all-targets           # clean
cargo fmt --check                    # clean

Integration suite run green against MinIO in Docker (setup is in the test file's module docs). Not run against real AWS S3 — no credentials here, so that's worth one manual pass before relying on it in production.

🤖 Generated with Claude Code

Qard and others added 3 commits July 30, 2026 20:55
Extract object-store construction out of `ColdTier::create_store` into a new
`sequins-object-store` crate so other subsystems can open their own bucket or
prefix without depending on the cold tier — which pulls in Vortex, DataFusion,
and arrow. The new crate depends only on `object_store`, `serde`, `url`, and
`thiserror`.

`ObjectStoreConfig` moves there and is re-exported from `sequins-cold-tier` so
the existing public path still resolves. Store-construction errors flatten onto
the cold tier's existing `Config`/`Storage` variants, so error messages callers
match on are unchanged. `create_store` now delegates; behaviour is identical.

Adds `supports_conditional_put(uri)` for callers whose correctness rests on
compare-and-swap. Verified against object_store 0.13.2 rather than assumed:

- S3 (`If-Match` on the ETag), GCS (`x-goog-if-generation-match`), and Azure
  all support `PutMode::Update`.
- `LocalFileSystem` does NOT — it returns `Error::NotImplemented`, though it
  does support `PutMode::Create`. A subsystem needing CAS must therefore reject
  a `file://` URI at configuration time.

Callers must carry both `e_tag` and `version` into `UpdateVersion`: S3 matches
on the ETag while GCS requires `version` and fails with `MissingVersion`.

Tests: unit coverage for URI parsing, scheme rejection, directory creation, and
the local Create-yes/Update-no behaviour; an env-gated integration test
exercising Create conflict, stale-ETag rejection, successful CAS, and
superseded-version replay rejection. Run green against MinIO via
`SEQUINS_TEST_S3_URI`; not yet run against AWS S3.

Also drops the now-unused `url` dependency from `sequins-cold-tier`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Requiring `PutMode::Update` for compare-and-swap would have forced every local
deployment onto MinIO, since `LocalFileSystem` returns `NotImplemented` for it.
That is not an acceptable constraint: `file://` must stay a first-class backend.

`PutMode::Create` is atomic on every backend — `LocalFileSystem` implements it
with `link(2)` — so linearizable state transitions should be built on it
instead. Rather than mutating one pointer object under an ETag CAS, write an
immutable `.../{next_generation}` key with `Create`: exactly one writer wins and
the losers get `AlreadyExists` and retry. One code path, identical behaviour on
a laptop and in production. The cost is a probe on the read path instead of a
single pointer read, which is irrelevant locally and cheap remotely.

Replaces `supports_conditional_put(uri) -> bool` — which invited callers to
reject a store — with `conditional_write_support(uri) -> ConditionalWriteSupport
{ create, update }`, which invites them to pick a strategy. `create` is true
everywhere; `update` is false only for local, and is now positioned as an
optimisation nothing may depend on.

Evidence, not assumption: a 32-way concurrent race on the local backend and a
16-way race against MinIO both confirm exactly one winner, every loser seeing
`AlreadyExists`, and the winner's bytes being the ones that persist.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…tion

Corrects the guidance from the previous commit. Unifying everything onto
`PutMode::Create` traded a real cost in production — a mutable pointer becomes a
probe forward instead of a single read — to avoid a second code path. That is
the wrong trade for a read-heavy service.

Deployments that have `PutMode::Update` should use it: one conditional write
advances the pointer, one read returns it. Callers needing a mutable pointer
supply their own serialisation only for `file://`, where single-node,
low-traffic use makes the weaker guarantee acceptable. `file://` has to keep
working; it does not have to be fast or multi-writer safe.

No API or behaviour change — `conditional_write_support` already reports exactly
what a caller needs to choose. This is documentation and test framing only.
Also clarifies that the Create/Update split concerns mutable pointers alone:
immutable content-addressed writes use `Create` on every backend, which is what
the concurrent-race tests actually cover.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant