Skip to content

Serve links networks as S3-compatible object storage - #217

Open
konard wants to merge 19 commits into
mainfrom
issue-216-d3f2008c3951
Open

konard wants to merge 19 commits into
mainfrom
issue-216-d3f2008c3951

Conversation

@konard

@konard konard commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

Fixes #216

Summary

clink --serve ADDR --s3 now serves a links network over the Amazon S3 REST API, in the Rust, C# and JavaScript clink. The bucket, object, metadata and multipart catalog is kept as links. The bytes go to a folder of files, to RAM, or (Rust) to a links file system (LFS) volume. Any write can be replicated to other S3 nodes, either synchronously in the same request or asynchronously.

User guide: docs/OBJECT-STORAGE.md. Case study, with the requirements, the MinIO/Garage/SeaweedFS/versitygw/Ceph survey, the solution for each requirement and its evidence: docs/case-studies/issue-216.

What the issue asked for and where it is

Issue asks for Done by
S3-compatible associative storage The S3 API covers buckets, objects, Range, conditional requests, copy, ListObjects v1/v2, batch delete, multipart, checksums, aws-chunked bodies, and Signature V4/V2 in both headers and presigned URLs. The AWS CLI, boto3 and the hasura-storage calls Deep makes all work with their default settings.
Links + files together as LFS --s3-volume IMAGE: the catalog and the bytes share one LFS volume, with one journal commit per request. --s3-blobs lfs:IMAGE keeps only the bytes in LFS. Both are Rust only, because links-fs has no .NET or Node.js bindings.
Testable on RAM disks --s3-blobs memory and --s3-volume memory, or any mode on a tmpfs. Includes the compose.ram.yml and k8s memory overlays.
Process + links data file + folder of files The default mode: --db s3.links, with the bytes in s3.links.objects/ (--s3-blobs dir:PATH moves them).
In Docker and without A Debian trixie image (examples/object-storage/deploy/Dockerfile) runs the same binary as a plain process.
Docker Swarm, minikube, k8s stack.yml, plus kustomize bases and overlays in deploy/k8s (base, memory, replicated).
Distributed, sync (one transaction) and async --s3-replica URL with --s3-replication sync (every replica or none; a failed write is undone), sync:N (quorum) or async (background catch-up). Missed writes are retried, and a restarted primary reconciles. The replica can be any S3 node, including another implementation.
Everything deep-foundation needs The hasura-storage call set (PutObject, ranged GetObject, presigned GET, DeleteObject, ListObjects v1, path style, region no-region) is in the smoke test.
Configurable, optional, decorators ObjectStore (links catalog, LFS volume, S3 client, replicated) and BlobStore (dir, memory, LFS) are decorators behind one interface. Every setting is a flag or an environment variable.
Rust/C#/JS parity Recorded in parity/features.json: implemented in all three. The LFS options are refused in C#/JS with a message that names the Rust clink.

Reproduce and verify

Every mode, driven with boto3 and the AWS CLI (Rust primary with a JavaScript replica here; any clink command works):

cargo build --manifest-path rust/Cargo.toml
(cd js/server && npm ci)
python -m pip install -r examples/object-storage/requirements.txt
REPLICA_CLINK="node js/server/bin/clink.js" examples/object-storage/smoke-all-modes.sh rust/target/debug/clink python
# C# or JavaScript primary (no LFS):
S3_LFS=0 REPLICA_CLINK=rust/target/debug/clink examples/object-storage/smoke-all-modes.sh "node js/server/bin/clink.js" python

Deployments (image, Compose with a restart, RAM, replicated, Swarm, and Kubernetes on kind):

examples/object-storage/deploy/smoke-deploy.sh compose   # also ram, replicated, swarm, k8s-base, k8s-memory, k8s-replicated

Tests:

cargo test --manifest-path rust/Cargo.toml --lib object_storage
dotnet test csharp --filter "FullyQualifiedName~S3|FullyQualifiedName~ObjectStorage|FullyQualifiedName~CliS3"
(cd js/server && npm ci && npm run test:coverage)
node parity/check-parity.mjs --base origin/main

CI runs all of this. .github/workflows/object-storage.yml has these jobs:

  • modes: every Rust mode, with boto3 and the AWS CLI.
  • ports: the C# clink with a JavaScript replica, and the JavaScript clink with a C# replica.
  • The image deployments.
  • Swarm.
  • Kubernetes on a kind cluster.

Local checks

  • Rust:
    • cargo fmt --check is clean.
    • cargo clippy --all-targets --all-features -D warnings is clean.
    • The 50 object_storage lib tests pass.
    • cargo check --target wasm32-unknown-unknown passes.
  • C#: the Release build has 0 errors, and the 63 S3 tests pass.
  • JavaScript server:
    • 1,881 tests pass with 100% coverage on Node.
    • The full suite also passes on Bun 1.4.5 (bun test) and Deno 2.9.7 (deno test).
    • The differential CLI test against the Rust help passes, 49/49.
  • npm run test:differential against the Rust clink and the unit_store_trace driver: 139 pass, 0 skipped.
  • check-latest-dependencies.mjs exits 0, with two dependencies held back by open issues (Port platform-trees 0.3.6 tree balancing to the JavaScript unit store #218 and minicov 0.3.9 is blocked by wasm-bindgen-test pinning =0.3.8 #219).
  • node --test .github/scripts/*.test.mjs js/test/*.test.mjs csharp/scripts/*.test.mjs passes 438 tests, including the workflow policy, repository layout and parity tests.
  • The JavaScript quality check passes, as do the secrets scan, the Python quality check (ruff and mypy) and zizmor on the workflows.
  • smoke-all-modes.sh exits 0 for four combinations:
    • C# primary with a Rust replica;
    • C# primary with a JavaScript replica;
    • JavaScript primary with a C# replica;
    • Rust primary in all five modes with a JavaScript replica.
  • The swarm deployment passed inside docker:dind. The sandbox's Docker daemon runs with --live-restore, which Swarm refuses.
  • Kubernetes was not run locally: kind and k3s cannot start nested here. The overlays were rendered with kubectl kustomize, and the real deployment runs in CI on kind (the Container image (k8s) job).

pre-commit is not installed in this environment, so the hooks did not run. Before each commit I ran their checks by hand instead: cargo fmt, cargo clippy, dotnet format, the node tests, the JavaScript quality check, the secrets scan and the Python quality check. Commits used standard Git invocations, with no hook bypass flags.

dotnet format csharp --verify-no-changes ran only on the changed C# files, using --include, and they are clean. The local SDK is 10.0.112, while CI pins 10.0.403, and the older SDK reports 273 style complaints in 21 files this PR does not touch. CI's dotnet format runs on the pinned SDK.

Not done

These go beyond what the issue asks for. The "Limits" section of docs/OBJECT-STORAGE.md lists them:

  • Active-active (multi-primary) replication and erasure coding. Replication runs from a primary to its replicas.
  • S3 versioning, bucket policies, CORS, lifecycle and tagging. Requests for them get 501 NotImplemented, as in Swift s3api and Garage.
  • TLS. Put a reverse proxy or an ingress in front of the server.
  • LFS in C# and JavaScript. This is not applicable, because links-fs has no bindings for them. The manifest records it, and both CLIs point to the Rust clink.

Other changes

The PR also refreshes a few dependencies that the Security and Dependencies audits flagged on this branch:

  • sha2 0.11.3, replacing a yanked version.
  • cross-spawn 7.1.2, for an advisory.
  • lucide-react.
  • globals 17.15.0 and taiki-e/install-action v2.90.12, which the Dependencies audit flagged as outdated.

Fixes for problems that CI found on other runtimes and platforms:

  • CodeQL flagged two js/polynomial-redos regexes, one trimming quotes and one trimming trailing slashes. Both are now linear scans, with tests on 100,000-character inputs.
  • On Bun, node:http does not see an idle socket until a request arrives on it. The idle-connection test now sends a request first. Two experiments in experiments/issue-216/ (bun-http-idle-close.mjs and bun-http-keepalive-close.mjs) show this behaviour.
  • Deno drops a request whose socket is half-closed with socket.end(bytes). The network tests now send with socket.write.
  • On Windows, --s3-blobs C:\data was split at the drive colon and rejected as the kind C. A one-letter kind is now read as a drive letter in all three clink implementations, with a test in each.
  • On Windows, the test that sends SIGTERM and SIGINT is skipped, because Node kills the child there instead of signalling it.
  • smoke-all-modes.sh stops its servers before it removes their folder.

Dependency pins, each linked to an issue it depends on:

  • platform-trees stays at 0.3.5, the version main uses: platform-trees = "=0.3.5" # held back: #218. An earlier commit here updated it to 0.3.6, which rebalances the doublets trees differently. The Rust clink then wrote database files that the JavaScript unit store (a port of 0.3.5) no longer matched, and 12 of the 19 tests in test/differential/doublets-storage.test.mjs failed. They all pass on 0.3.5. Port platform-trees 0.3.6 tree balancing to the JavaScript unit store #218 tracks porting the new balancing to JavaScript.
  • check-latest-dependencies.mjs read an exact = requirement as no version at all, so it skipped such pins without saying so. It now compares them; this is covered by a test. That also surfaced minicov = "=0.3.8" in rust/wasm/Cargo.toml: every wasm-bindgen-test release up to 0.3.80 requires exactly 0.3.8, so it is held back by minicov 0.3.9 is blocked by wasm-bindgen-test pinning =0.3.8 #219.

The version bumps:

  • The JavaScript server goes to 0.3.0.
  • C# has a minor changeset.
  • Rust has a changelog fragment.

Adding .gitkeep for PR creation (default mode).
This file will be removed when the task is complete.

Issue: #216
@konard konard self-assigned this Dec 1, 2026
clink --serve ADDR --s3 speaks the S3 REST API: buckets, objects, ranges,
conditional requests, copies, listings v1/v2, batch deletes, multipart
uploads, SigV4 and SigV2 header and presigned authentication, aws-chunked
bodies and CRC/SHA checksums.

The store is assembled from optional decorators:
- a links catalog in --db (with every links decorator) and the bytes in a
  folder (--s3-blobs dir:PATH, the default), in RAM (memory) or in an LFS
  journalled volume (lfs:IMAGE);
- or one LFS volume (link-foundation/lfs) holding catalog and bytes
  (--s3-volume IMAGE|memory);
- replication to other S3 nodes (--s3-replica URL, --s3-replication
  sync|sync:N|async) with quorum writes, rollback, catch-up, reconcile
  and read failover.

Refs #216
…ed in CI

Adds the container image, Compose files (one node, RAM disks, replicated),
a Swarm stack and Kustomize overlays (PVC, RAM emptyDir, replicated), and
smoke-deploy.sh, which deploys each one and drives it with boto3. The new
Object storage workflow runs every storage mode of clink and every
deployment (Kubernetes on kind) on each pull request.
…ifest

object-storage is implemented in Rust and tracked as missing in C# and
JavaScript until their ports land in this pull request; object-storage-lfs
is Rust only, because links-fs has no bindings. Removes the .gitkeep that
created the pull request.
…ompiles

5 GiB does not fit a 32-bit usize, which failed the wasm32 build of the
library (Docs, JS client, crash tests). MAX_BODY is 5 GiB on 64-bit targets
and usize::MAX on 32-bit ones; the server default and the client both use it.
sha2 0.11.2 was yanked (cargo audit), cross-spawn 7.0.6 has a critical
advisory (GHSA-ghv9-86vm-4v8m, fixed in 7.1.2) and platform-trees 0.3.6 and
lucide-react 1.85.0 were released, which the dependency check requires.
clink --serve ADDR --s3 in C# serves the same S3 REST API over the same links
catalog layout as the Rust clink: buckets, objects, ranges, conditional
requests, copies, listings v1/v2, batch deletes, multipart uploads,
checksums, aws-chunked bodies and Signature V4/V2 (headers and presigned
URLs). Bytes live in a content-addressed folder (--s3-blobs dir:PATH, the
default) or in RAM (memory); --s3-replica and --s3-replication sync|sync:N|
async replicate every write to other S3 nodes of any implementation. The
LFS options are refused with a message naming the Rust clink, since LFS has
no .NET binding.

63 tests cover the store contract, the API, both signatures, the network
server and client, replication and the CLI end to end.
…ting to the other

smoke-all-modes.sh takes any clink command; S3_LFS=0 checks that the LFS
modes are refused instead of running them, and REPLICA_CLINK puts the
replica in another implementation. The new ports job runs the C# clink with
a JavaScript replica and the JavaScript clink with a C# replica.
clink --serve ADDR --s3 in js/server serves the same S3 REST API over the
same links catalog layout as the Rust and C# clinks: buckets, objects,
ranges, conditional requests, copies, listings v1/v2, batch deletes,
multipart uploads, checksums, aws-chunked bodies and Signature V4/V2
(headers and presigned URLs). Bytes live in a content-addressed folder
(--s3-blobs dir:PATH, the default) or in RAM (memory); --s3-replica and
--s3-replication sync|sync:N|async replicate every write to other S3 nodes
of any implementation. The LFS options are refused with a message naming
the Rust clink, since LFS has no Node.js binding.

The tests keep js/server at 100% coverage and run the shared store
contract against every store. The parity manifest now lists S3 as
implemented in all three clinks.
…ion limits

OBJECT-STORAGE.md and the issue-216 case study now say how CI checks the
three clinks against each other, that each CLI words its own argument
errors, that C# and WebAssembly cap the body at their address space, and
that missed replica writes are held in the primary's memory.
@konard konard changed the title [WIP] Ensure we fully support associative storage as S3 storage compatible storage Serve links networks as S3-compatible object storage Dec 1, 2026
Comment thread js/server/src/s3-client.js Fixed
Comment thread js/server/src/s3-store.js Fixed
…Bun and Deno

CodeQL flagged the two regular expressions that trimmed ETag quotes and
endpoint slashes as polynomial on long runs of the same character; both
are now a linear scan, tested on 100,000-character inputs.

Bun's node:http gives the server a socket only once a request arrives on
it, so the idle-connection test now idles a kept-alive client after one
request. Deno drops a half-closed request, so the raw requests are written
without ending the socket; they ask for connection: close.
The EXIT trap killed the servers and removed the work folder at once, so a
replica still writing put files back and rm failed with "Directory not
empty" after every check had passed (the JavaScript-primary ports job).
The trap now stops each server and waits for it first.
bun-http-idle-close.mjs shows that a socket which has sent no request never
reaches the server's connection event under Bun, so shutdown cannot close it;
bun-http-keepalive-close.mjs shows that one which has sent a request can be.
`--s3-blobs C:\data` was split at the drive colon and rejected as an
unknown blob kind "C". A one-letter kind is now read as a drive letter,
so the whole value is a folder path, in the Rust, C# and JavaScript clink.
The JavaScript process test that sends SIGTERM and SIGINT is skipped on
Windows, where Node kills the child instead of signalling it.
…te-identical

platform-trees 0.3.6 rebalances its size-balanced trees differently, so the
Rust clink wrote database files the JavaScript unit store (a port of 0.3.5)
no longer matched, and 12 of the 19 differential tests failed. The version
is pinned with a held-back comment linking #218, which tracks porting the
new balancing.

The dependency audit read an exact `=` requirement as no version at all
and skipped it silently. It now compares it, so the pin is reported as
held back. That also surfaced minicov =0.3.8, which wasm-bindgen-test
0.3.80 still requires exactly; it is held back by #219.
@konard
konard marked this pull request as ready for review December 1, 2026 16:24
@konard

konard commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $61.465185
  • Calculated by Anthropic: $67.657395
  • Difference: $6.192210 (+10.07%)

📊 Context and tokens usage:

Claude Opus 5.5: (13 sub-sessions)

  1. 116.5K / 1M (12%) input tokens, 26.6K / 128K (21%) output tokens
  2. 107.2K / 1M (11%) input tokens, 51.7K / 128K (40%) output tokens
  3. 94.5K / 1M (9%) input tokens, 47.4K / 128K (37%) output tokens
  4. 116.7K / 1M (12%) input tokens, 36.0K / 128K (28%) output tokens
  5. 113.3K / 1M (11%) input tokens, 40.3K / 128K (32%) output tokens
  6. 116.2K / 1M (12%) input tokens, 31.3K / 128K (24%) output tokens
  7. 116.1K / 1M (12%) input tokens, 34.3K / 128K (27%) output tokens
  8. 115.7K / 1M (12%) input tokens, 29.2K / 128K (23%) output tokens
  9. 114.8K / 1M (11%) input tokens, 27.8K / 128K (22%) output tokens
  10. 116.3K / 1M (12%) input tokens, 24.4K / 128K (19%) output tokens
  11. 116.9K / 1M (12%) input tokens, 31.8K / 128K (25%) output tokens
  12. 117.0K / 1M (12%) input tokens, 33.9K / 128K (26%) output tokens
  13. 116.4K / 1M (12%) input tokens, 33.7K / 128K (26%) output tokens

Total: (133.2K new + 3.3M cache writes + 85.2M cache reads) input tokens, 1.2M output tokens, $61.345109 cost

Claude Haiku 5.5:

  • 401.6K / 1M (40%) input tokens, 39.8K / 128K (31%) output tokens

Total: 401.6K input tokens, 39.8K output tokens, $0.120075 cost

🤖 Models used:

  • Tool: Anthropic Claude Code
  • Requested: opus (claude-opus-5-5)
  • Thinking level: high (~23999 tokens)
  • Main model: Claude Opus 5.5 (claude-opus-5-5)
  • Additional models:
    • Claude Haiku 5.5 (claude-haiku-5-5)

📎 Log file uploaded as Repository (34940KB)


This AI session has ended. Monitoring of this pull request continues. Feel free to review and add feedback while checks are running.

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.

Ensure we fully support associative storage as S3 storage compatible storage

3 participants