Skip to content

longshore_s3_cache: a transparent S3 cache, groups 1–5 of add-s3-cache, merged with #70 - #73

Merged
marvin-hansen merged 40 commits into
carverauto:mainfrom
marvin-hansen:main
Dec 3, 2026
Merged

marvin-hansen merged 40 commits into
carverauto:mainfrom
marvin-hansen:main

Conversation

@marvin-hansen

@marvin-hansen marvin-hansen commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

What

add-s3-cache, task groups 1 to 5: longshore_s3_cache, a transparent cache for S3 on the shared I/O backend. Its program, longshore-cached, is a binary of the same crate. This replaces #72, which had the cache split into two crates.

  • One crate, not released: the crate has publish = false, and the longshore facade does not re-export it, until the change is done. The packaging check skips crates that are not published.
  • Store (group 1): an index, a memory tier and a disk tier with its log (format 2 keeps each object's header lines), the save at a planned stop and the restore after it, and the log rewritten while the store runs.
  • Fills (group 2): a block fetched into the chunk it is served from, one fetch per block, capped fetches, and a slow fetch raced, all tested against an origin that stalls, resets and changes an object mid-fill.
  • Serving and consistency (groups 3 and 4): every S3 call either served or relayed. Headers and metadata are never dropped (a call that cannot be cached whole is relayed uncached), every default can be set, and each consistency mode is explored with writes going through the cache and around it.
  • Cluster and client (group 5): shards with relays between cores (Unix-domain sockets) and between nodes (TCP), membership by DNS name, leaving before a stop, and a client that routes each key to the shard that owns it, falls back to the origin, and tells a shard about writes it missed. Measured on OrbStack Kubernetes while scaling and rolling, with zero failed reads (bench/results/cache-k8s-orbstack.md).

Groups 6 (real-hardware benchmarks) and 7 are not in this PR, and the OpenSpec change stays open.

Issues

Merged with #70

main (PR #70) is merged in, all of both sides kept, plus:

  • Client::copy on a client with a cache is a write of its destination: it goes to the shard that owns the destination, and one sent around that shard is reported to it afterwards. Without this, a read after a copy could get the shard's old object.
  • A write that reached the origin but lost its answer may still have happened, so the shard that owns its key is told as well.
  • The copy-answer XML reader moved out of multipart.rs into multipart/answer.rs (tokenizer in answer/scan.rs). It also reads the result's ETag, and S3::said reads a copy's error code and ETag through it, so text inside an XML comment is never taken for either.
  • The object-operations copy requirement is written out again as requirements with scenarios.

Fuzz and CI

  • multipart_response builds again with the reader moved, and also fuzzes copy_answer. cache_request, which CI does not fuzz, builds again too. Both ran 30 s (about 8 million inputs each) with no crash.
  • The Explorations job's limit goes from 30 to 60 minutes. The cache is linted with each TLS provider directly, which the facade did for it before.

Verified

  • Every step of CI's "Format, lint, docs" job passes locally: fmt, clippy with every feature set, the dependency-tree checks, the packaging check and the docs.
  • Tests pass: the cache's 1,034 (the program's 12 included), longshore_s3's 435 and the facade's 311.
  • Explorations and every deliberate bug pass on macOS and in the Linux container: the cache's before the merge, the S3 store's after it.
  • The client and cache loom models pass.

Not done: group 5's mutation run left 153 mutants that no test catches and 3 that time out (task 5.7). They are deferred to a later PR.

🤖 Generated with Claude Code

marvin-hansen and others added 30 commits November 30, 2026 15:21
A proposal, not yet approved: a Cache set written against Io beside Net
and Files, a memory tier that is the aligned pool and a disk tier of
direct-I/O files, blocks fetched once into the chunk they are served
from, an S3 endpoint verified with SigV4 against the cache's own keys,
a stated consistency mode a prefix, one owner a key over shards that are
cores, membership from a list or a headless service's name, and a client
that routes to the owner and falls back to the origin for reads and
writes. 38 requirements over five new capabilities and one added to
high-level-client.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The simulator with faults, stateright explorations of the real code with
a deliberate bug each, loom models of everything a second thread can
reach, and mutation testing with cargo-mutants, each in place before the
code it checks: a new capability cache-verification, a requirement
"Cache explored" added to model-checking, a group 0 of tasks that builds
the four harnesses, and a clean run of all four at the end of every
group. cargo-mutants stays a tool: its settings and exclusions are
.cargo/mutants.toml, no manifest or source names it, and a mutant that
survives or hangs fails the run.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ilt under

Group 0 of add-s3-cache. A new crate, re-exported as longshore::cache: a
Cache set planned and driven like Net and Files, so that it shares one
backend with the files of a disk tier and the store of an origin. It
holds nothing yet: it listens, accepts into slots of its own, reads
request heads in place and answers each request 503 SlowDown in S3's
form (400 for what is not a request), one answer a request, and stops
when asked, from its own thread or through a Stopper from any other. A
Cache is neither Send nor Sync, checked when it is compiled.

The checks, each in place before any tier exists:
- simulation: every transition on a backend that does nothing, hand-driven
  clients on SimIo under 800 seeds of faults, one ring shared with Files,
  the store and an origin, the allocation guard, and the cache's own
  books (Cache::audit) checked after every step;
- exploration with stateright (scripts/test-explore.sh): 1,129, 27,769
  and 160,385 states, the same on macOS and Linux, and a deliberate bug
  (cache_short_send_starts_over) that must be found;
- loom (scripts/test-model.sh): the stop flag, judged against a flag
  raised once;
- mutation with cargo-mutants (scripts/test-mutants.sh, configured in
  .cargo/mutants.toml, a job in CI for the changed lines): 273 mutants,
  228 caught, 45 that do not build, none surviving, none hung.

What they found on the way is in the change's design.md: bytes behind a
request head that told apart states which behave alike, a poll that may
miss a stop for a moment, and two branches no test could tell from
their absence, now gone.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
An opt-in setting: a cache told to stop writes its memory tier to the
disk tier, most recently hit first and within a bound, and the next
start serves from those blocks at once and moves them back into memory.
The disk tier keeps a reserve as large as the memory tier, so a stop
drops nothing. A planned stop ends with a sync and a mark and so
survives a reboot; the next start retracts the mark before it writes.
Three requirements added to cache-storage, scenarios to cache-cluster,
cache-consistency and model-checking, and five tasks.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The storage half of the cache as a set of its own, `store::Store`: a path
table and a block table of fixed capacity, versions never numbered twice,
a memory tier over the caller's `Extents` of the block-aligned class, and
eviction in batches at insertion by a `Placement` policy, CLOCK unless
set. It does no I/O and allocates nothing after it is built; its check at
rest runs after every step of its tests.

Tasks 1.2 to 1.4 of add-s3-cache. The full mutation run is clean: 613
mutants, 538 caught, 75 that do not build, none surviving, none hung. Its
first run found a fault: a block number past the highest an object can
have named a block of the next version.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A store planned with a disk tier keeps a set of cache files of its own,
one a drive, opened for direct I/O and reserved, with chunks striped over
them. A memory victim the policy sends to disk is written from its chunk
at the next poll, a bounded number at once, and one past the bound is
dropped, so that no fill waits for a drive; with a disk tier the store
evicts a batch ahead. A block on disk is read with one read into a memory
chunk, which becomes the block's own when the policy promotes it.

Every block written has a CRC-32C, checked when it is read: a write torn,
lost or misdirected without an error, and a bit a drive flips, end as a
failed read does, the entry removed and the block fetched again. A cache
file that cannot be opened or reserved turns the tier off, not the store.
A chunk the files are still reading into or writing from takes no block.

Task 1.5 of add-s3-cache. 223 tests, on macOS and in the Linux container,
the tier's on the simulated drives under each kind of fault they have. A
full mutation run of 874 mutants caught 784, with 89 that do not build,
none hung, and one survivor, a field written twice; it is removed and a
test pins what it set, and that fix was not run against the mutants
again. From here the mutation run is made once a group, at its end.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A store planned with a log says to it, as it runs, which chunk of the
disk tier holds which block, so that the store built on the same files
after the process has ended, in the same boot, has the tier as the last
one left it. Nothing is synced: after a reboot the tier starts cold.

The log names a chunk only after its block's write has ended well, and a
chunk it names is written again only after the entry that frees it has
been appended. Each start writes a new log that holds what the tier
keeps and renames it over the old one; each cache file starts with the
name of the start that claimed it, and a log is taken back only for the
boot, the shape and the files it was written for. Replay refuses every
entry that cannot be so. Entries name path slots, not versions: the next
store numbers what it takes back anew. An append that fails leaves the
tier read-only.

`SimIo::process_exit` ends a process in the simulator: what was in
flight is dropped, every file closed, and all that was written kept.

Task 1.6 of add-s3-cache. 272 tests, 273 in the Linux container: the
process killed at every tick of a run, of the start that follows and of
a first start, each operation of a start and each append failed in
turn, and logs of another boot, shape or set of files, damaged, cut and
longer than a block. No mutation run was made for this task.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
`Store::counts` gives what a store counted since it was built: hits in
memory, blocks kept, times no chunk was to be had, victims by what became
of them, reads of the disk tier started and by how each ended, promotions,
blocks dropped from a full disk tier and with their object, versions
named, paths given up, blocks taken back from a log, and appends to it.
Bytes a drive gave back that were not the ones written are counted apart
from a read that failed.

Each count is pinned by a test to the one thing it is of, and the
allocation guard's test of a store with a disk tier and a log says that
hits, fills, demotions, promotions, evictions and appends each happened
under the seal.

Task 1.7 of add-s3-cache; and task 1.13 added, the log rewritten while
the cache runs. 285 tests, on macOS and in the Linux container. No
mutation run was made for this task.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Marvin Hansen <marvin.hansen@gmail.com>
The store's index, both tiers and the log are explored with stateright:
a driver that plays the cache learns, fetches, asks again, changes and
forgets two objects, the chooser saying at every step whether the driver
acts or the backend completes what is in flight, and the process killed
at any step and started again on the same files. After every start and
at the end every block the store names must be there. 585 states with no
kill, 9,410 with one, 42,747 with two, 24,167 with one kill and an
operation held back; the same on macOS and in the Linux container.

A tick of the simulator completes all that is in flight, so a kill
between ticks never parts two operations started together: with the
backend holding one back among the faults placed, it does. Two deliberate
bugs are found, each by the property it breaks: a write to disk believed
after its block was dropped, and a block said to the log before its
write has ended.

`board` carries a shard's counts to another thread: a post takes no lock
and never waits, and a read gives the numbers of one post, whole. Two
loom models check it, and fail when the board is broken on purpose.

Task 1.8 of add-s3-cache. 290 tests. No mutation run was made.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A store planned `with_save` caches, in both tiers together, no more
blocks than its disk tier has chunks, so that every block in memory has a
chunk on disk to go to and a stop never has to choose what to drop. The
rule is kept where a block is added: one that would be one too many
first costs a batch of the policy's victims on disk, and is not cached
if the policy gives none up. A block that moves between the tiers
changes nothing. The plan refuses the setting without a log, and with a
disk tier smaller than the memory tier; the check at rest has the rule.

Task 1.9 of add-s3-cache. 298 tests, on macOS and in the Linux
container. No mutation run was made.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
`Store::save` writes what is in memory to the disk tier and leaves the
tier marked, for a store that kept room for it. The policy names the
blocks, the most worth having back first; CLOCK goes three rounds over
its marks. They go through the tier's own writes, each said to the log
with its place in the order, and no block on disk is given up for them.
The caller owns the clock: `end_save` starts no more writes.

Then each cache file is synced, the log, and the directory each lies in,
and a mark is appended to the log and synced. A stopped tier still gives
back what it keeps and writes nothing. A sync or the mark that fails
ends the stop with no mark and the tier read-only.

Task 1.10 of add-s3-cache. 312 tests, on macOS and in the Linux
container: a stop killed at every tick and each of its operations failed
in turn; after a power loss the files, their names and every saved block
are there, and without a stop they are not. The explorations, their
deliberate bugs and the loom models pass as before. No mutation run was
made.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A log that ends in the mark of a planned stop is taken back after a
reboot. The start that takes it back writes a record over the mark and
syncs the old log before it writes anything else, so that no later
start finds a mark that is no longer true. A start that takes no log
back syncs its claim of each cache file before it writes a chunk: a
marked log that a power loss brings back names files that are another
start's.

The store brings the saved blocks back to memory itself, in the stop's
order, with reads of its own that begin only while fewer than half the
tier's reads are in flight and while chunks are free beyond a fill's
batch. A request for a block being read joins the read; a request's
read of a saved block moves it to memory. A stop that begins tells the
log so (a Saving entry) and ends the order of the stop before it.

Found on the way: a store whose tier went off with entries still owed
to its log never came to rest.

Tests: power lost at every tick of the start after a stop and each of
its operations failed in turn (every saved block or none), kills,
a second stop, a stop during the restore, a log of another format, and
the allocation guard over such a start. 328 tests; the explorations,
their deliberate bugs and the loom models pass on macOS and in the
Linux container. No mutation run (once per task group).

boot.rs, disk.rs, format.rs and two test files are split by subject to
stay under 400 lines.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Sweeps over every point of a planned stop and of the start after it
(power lost, the process killed, an operation failed; across a reboot
and within one boot), a campaign of lives ended six ways on drives
that work and on drives that fail, and an exploration of a stop, the
start after it in either boot and the stop's chunks written again,
with the process ended anywhere and all, none or a part of each
unsynced write left by a power loss. Its deliberate bug,
cache_mark_not_retracted, is found.

Four defects they found, each fixed with a test:

- A stop with nothing in memory and no chunk free on disk never
  ended: it waited for a chunk before it asked whether there was a
  block to write.
- A log that named an object, freed its blocks and named it again in
  another slot of the path table was refused whole, and the store
  started cold.
- A tier that went off while it wrote its new log renamed it,
  unfinished, over the old one, and came back ready with no file to
  append to.
- After a reboot, a start killed between writing over the mark and
  putting its own log in place left the next start cold, though no
  chunk had been touched. The record written over a mark now names
  the boot it is written in (17 bytes for 1), and a start in that boot
  takes the log back.

The two explorations of the store stand on one stage
(tests/explore/stage.rs); the state counts of the earlier one are
unchanged. 337 tests; the explorations, four deliberate bugs and the
loom models pass on macOS and in the Linux container. No mutation run
(once per task group).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Past a bound on its length (StoreSizes::with_log_most: sixteen blocks
unset, never for 0) the disk tier's log is rewritten: a new one, of
what the tier keeps, is written under the temporary name and renamed
over the old. After a rewrite the next is due when the new log has
grown to twice its length, and past the bound.

The old log stays the true one until the rename: it hears everything
as before, so no read, demotion or freeing of a chunk waits. The new
one is written beside it from a cursor over the chunk table, 256
chunks a poll at most, and is told what the old log is told of the
chunks the cursor has passed; when the two say the same of every
chunk, every record goes to both, the same bytes, and is appended when
both writes have ended. Then the rename. Killed at any point the next
start finds the old log or the new, each whole and true. A step that
fails leaves the old log in use, counted, and the rewrite is tried
again when the log has grown some more; a write that fails while the
rename is in flight is judged when the rename has ended, by which log
is in place. A path is named in a log by the log's number, so no table
is cleared when a rewrite begins or ends.

It costs the plan a third chunk of the memory tier's class and two
more file operations. New counts: log_rewrites, log_rewrites_failed.
New accessor: Store::log_rewriting.

Tests: a store that rewrites its log does the same work tick for tick
as one that does not; a kill at every tick of a rewrite; every
operation of a rewrite under load failed in turn; a planned stop begun
at every tick; the campaign of lives with a log short enough to be
rewritten all through it; the allocation guard; and an exploration
with the log rewritten whenever it has doubled and a kill anywhere
(44,853 states). No deliberate bug of its own: the one tried is not
reached by the exploration's run. 344 tests; explorations, deliberate
bugs and loom models pass on macOS and in the Linux container, the
earlier explorations with the state counts they had.

Task 0.6, continuous integration, is moved to the end as 7.4 (the
user, 2026-11-30). Task 1.13's box waits for the group's mutation run.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Marvin Hansen <marvin.hansen@gmail.com>
The full mutation run of group 1 (cargo-mutants 27.1.0): 1,801 mutants
in 49 minutes, 1,496 caught, 179 that do not build, 100 surviving and
26 hung. Each is answered with a test or a change, none with an
exclusion. The re-checks were of the mutants on the changed lines and
of the survivors and hangs only, about 250 a pass: none is left.

What the run showed, and what changed for it:

- The digest the explorations merge states by had no test of its own:
  each part is pinned now, and the bytes a log will read again.
- A rewrite's base had never taken more than one poll in a test. The
  chunks a rewrite says a poll is a setting (with_log_scan, 256 unset)
  and every rewrite test runs with a chunk a poll too. That showed a
  rewrite that could sit with nothing in flight: a chunk it has nothing
  to say of is now passed as it is met.
- Loops a wrong policy or number could make endless are bounded: what
  a stop asks its policy for, what a start looks at to bring back, the
  entries of one fill of the log, a run of the block table, the rounds
  of CLOCK's save order.
- A rewrite given up is over when its file's close has ended; the
  count of operations in flight on the file is gone.
- The check at rest holds a planned stop not to sync while a block is
  on its way, and a new log to append one record of its own at a time.
- at_rest says what a poll leaves true; a directory asked for a file
  there is not answers nothing.
- New tests: log names, the rewrite's cursor and its chunk, where
  entries go to the byte, when a rewrite begins and is tried again, a
  cache file that is another's, records at the length a chunk takes, a
  mark with bytes behind it, a stop that waits for chunks being freed,
  a start with saved blocks still to look at.
- The rigs no longer hang where a store would: a deck gives a store
  twenty thousand ticks, a read of a board five seconds. A long sweep
  is six tests side by side, since every mutant runs every test.

Task 1.13 is ticked and group 1 closed. 387 tests; lints on three
builds; the explorations with the state counts they had, their four
deliberate bugs and the loom models pass on macOS and in the Linux
container.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
fill::Claims, the first piece of the filling half: a table of fixed
size that does no I/O. The first request for a block no tier holds is
told to fetch it; whoever needs it while that fetch runs waits. When
the fetch ends each of them is answered once, in the order it came,
with the block or with why there is none, and the block is claimed no
more, so that the next request fetches anew. A request that goes away
leaves and is not answered; the fetch goes on.

Every request waits, the one that fetches too, so that serving has one
path for both. A claim that ended keeps its waiters as they are in a
list of the ended, and its place is free when its last answer is
taken. A claim and a place carry a generation: one kept past its end
names nothing.

Tests: the behaviour, a property test against a model, the table's own
check shown each kind of broken books, and the allocation guard. 407
tests on macOS and in the Linux container; lints on three builds. No
mutation run (once per task group). Its digest comes with the
exploration of fills, task 2.5.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Task 2.2 of add-s3-cache. `fill::Fills` are the fetches in flight, a
table of fixed size beside the claims. A block is one GET through the
origin's store, of exactly its bytes and with If-Match on its version's
ETag, into a memory chunk taken from the cache's store, and is entered
only when the answer is that block: the status, the range, the length,
the ETag, and the checksum where one came (`fill/judge.rs`). A block
that is the whole object is asked for without a range, so that its
CRC-64/NVME comes with it.

The first sight of a path is one HEAD however many requests name it: a
claim with no key (`Claims::open`, `Claims::join`). A 412, an answer of
another ETag or a 404 makes the cache forget the path, if it still
knows it at the fetch's version; a block that came for a version the
path has left is entered under neither.

`S3::buffer_size` is added to longshore_s3: the store is told no length
of the buffer it receives into, so a fetch through one that takes more
than a block is refused before anything is sent.

517 tests: the judge on answers of every kind, the fetches against the
in-tree origin on the simulator through the real S3 store
(`tests/common/origin.rs`), every refusal, the tables' own checks shown
each kind of broken books, and the allocation guard with and without
network faults. Explorations, their deliberate bugs and the loom models
pass on macOS and in the Linux container. No mutation run.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Task 2.3 of add-s3-cache. A fetch is a place in the fills' table with
up to two requests to its origin. As many are in flight as the fills
are planned for; one more waits its turn in a bounded room, in the
order it came, takes no chunk and sends nothing until `Fills::poll`
starts it, and past the room a request is refused. None overtakes one
that waits.

A block that has run for the p90 of the cache's latest 64 fetches, or
half a second until 64 were measured, is asked a second time into a
second chunk, beside the bound and within one of its own. The first of
the two to end well is the block; one that says the object changed or
is gone ends the fetch too; one that fails otherwise leaves the other
as the fetch. The request that lost runs to its end with nobody
waiting and is judged like any other. Stragglers are found without a
search: blocks asked for once are a list in the order they were sent,
and `Fills::race_due_ns` says when the first is due.

The origins' stores are handed over as a slice, a path's origin naming
its store, so that what waits is started through its own.

560 tests: bursts at the bound and through the room, requests that
hang and requests that are merely slow, two origins on one backend,
the table's check shown each kind of broken books, the delay from
times of every shape, and the allocation guard with fetches that wait
and that race. Explorations, their deliberate bugs and the loom models
pass on macOS and in the Linux container. No mutation run.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Task 2.4 of add-s3-cache. The in-tree server, the origin of every test
of the fills, learned what a fetch of a range still had to be shown:
`TruncateBody` now cuts the body of a range short as it did an
object's, `HalfRange` answers with a valid 206 of half the range asked,
and `IgnoreRange` answers a range with the whole object. Its own
crate's tests and the S3 store's pass with it, and five new tests pin
the three (`tests/http/ranges.rs`).

A campaign by seed (`tests/fill/campaign.rs`) sends requests for paths
and blocks in bursts, which wait and leave, while the origin is told at
random to stall, reset, cut bodies short, answer with other ranges and
with statuses, and its objects are stored anew and erased; on a quiet
network and on one with faults. Each request that stays is answered
once, every block the store holds is the object its version names, the
books agree after every call, and nothing is left in flight or held.
The seeds are shown to reach every way a fetch ends, with the bound,
the room and the race at work.

Each path of a fill replays to its trace hash (`tests/fill/paths.rs`),
and no two paths are one run but a whole object that came damaged and
one that came whole, which differ only in body bytes the hash does not
see; the paths replay on a network with faults too. Bit flips are left
out of these networks: a range carries no checksum, which the design
now says.

564 tests. Explorations, their deliberate bugs and the loom models pass
on macOS and in the Linux container. No mutation run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Task 2.5 of add-s3-cache. The fills are explored on the cache's store,
the S3 store and the in-tree origin, every choice the chooser's
(`tests/explore/fills.rs`), in two scenarios as small as their
properties need: the object stored anew underneath while its two
blocks are fetched one at a time with room for one more, up to two
departures from the first order of completions (100,120 states) and
with a reset anywhere (24,723); and a fetch stalled and raced, its
completions in their first order (59), since at each step of a stall
the simulator picks where to look first though nothing completes. A
block entered is its version's bytes, each request that stays is
answered once, the books agree, and nothing is held at the end.

The deliberate bug `cache_fill_without_if_match` (no precondition, and
the answer's ETag not compared) is found. The fills and their claims
have a digest that leaves out what only records history; the origin
gained `Server::store_object`, an object changed underneath at once.

A review of the fill code found no defect that serves a wrong byte. A
404 for a version the cache has left now starts its requests over, as
the spec says; the fills' tokens wrap as `on_done` takes them apart;
the deadline is documented as per request to the origin.

Every exploration with its deliberate bug, the loom models and the
tests pass on macOS and in the Linux container. Group 2's full
mutation run was not made, at the user's choice.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Group 3 of add-s3-cache, serving. A cache owns its store, its fills and
its origins' S3 stores and serves GET and HEAD (whole, ranges,
conditions, pipelined): a hit by `Op::SendZc` straight from its chunk,
its hold released at the send's last completion; a disk hit through one
direct read; a miss through the fills; slow clients bounded. Every
request is verified against the cache's own key table, reread on its
schedule, by SigV4 recomputed and compared in constant time
(`longshore_s3::sigv4::verify`). PUT, DELETE, copy, multipart and
listing are relayed with the origin's own answers; an acknowledged body
is kept as the new version's block in the chunk it was received into,
multipart parts in whole blocks under their upload, listings
remembered. TLS through `longshore_stream`, the seal being the one copy
and the plain path untouched; a build without `tls` refuses a TLS
setting. Fuzz targets of heads, ranges and a misbehaving client; three
explorations of serving with the deliberate bug
`cache_hold_released_early`.

Group 4, consistency. Prefix modes by the longest prefix (`immutable`,
`through`, `ttl`, `validate`), keys under no rule relayed uncached; a
write and the reads of its key meet in one place, the path forgotten or
replaced before the write is answered and a first sight in flight
spoiled when it lands; confirmations by one HEAD a path, stamped at
their send; the notice of a direct write. An equivalence check holds
every read to a version the origin's history and the mode allow, seeded
and as a fuzz target; an exploration of the modes has the deliberate
bug `cache_write_not_forgotten`.

The checks found four defects, fixed with tests: a read under
`validate` that joined a confirmation sent before the object changed
was served the old version; confirmations were stamped at their answer,
stretching `ttl`; the books flagged a slot rightly waiting for its call
at the origin; a request short of a chunk for a moment was answered 503
(it now waits within the answer's bound).

Outside the cache: `longshore_s3` passes on an origin's error code and
a completed upload's or copy's ETag (`S3::said`) and verifies SigV4; the
in-tree origin's listing carries ETags and its completion the assembled
tag; the facade forwards the cache's TLS features.

Tests, clippy on three builds, the loom models, every exploration and
the seven deliberate bugs pass on macOS; in the Linux container every
exploration that changed in the end passes and the rest passed when
built. No mutation run, at the user's choice.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…default

A cache must not drop a header or metadata. Each path now keeps its
object's describing lines exactly as the origin sent them, and every
read replays them as S3 would for that answer; a path whose lines are
unknown is confirmed with one HEAD before its first hit, and an object
whose lines do not fit, or came cut, is relayed uncached with all of
them, never trimmed. Writes carry every end-to-end header the client
sent, signed, conditions and the client's checksums included; the
client is answered the origin's own lines and, for an error or a copy,
its document byte for byte.

longshore_s3: `Options` holds 64 headers in 8 KiB; `put_with`,
`head_with`, `get_with`, `copy_with`, `multipart_store_part_with` and
`multipart_complete_with`; `S3::said_head()` gives an answer's header
lines in order, flagged when cut, and its document. The HTTP client
takes answers of up to 128 header lines and non-ASCII values; the
in-tree origin keeps and serves every header S3 keeps.

Settings: every default a cache is planned with, 43 of them, in one
table with unit and range, overridden by a `name = value` file and then
`LONGSHORE_CACHE_*` variables; bad or contradictory values are refused
naming the setting and its source; `Settings::sizes()` gives the plan.

Still open, defects by the same rule: a read the origin refuses is
answered with the cache's own document; a client's SSE-C and
conditional-read headers on GET and HEAD are not forwarded, and an
SSE-C object must not be served from the cache without its key; DELETE
and abort with a condition are refused 501; a completion's success
document is the cache's own; a request head too large to relay ends as
503 rather than refused up front.

Tests, clippy on three builds, the S3 client's loom model, and the
explorations the change touches (serving, modes, fills, tiers, stops,
the S3 store's and the HTTP pool's) pass on macOS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every answer the origin gives reaches the client as it came: status,
every line, document. Relayed writes, refusals of reads, copies,
listings and every call the cache has no name for (S3::forward: method,
query as written, all end-to-end headers, Range and x-amz-copy-source
among them, body) are answered with the origin's own answer
(Reply::Origin); nothing added, nothing taken away.

- Reads of a version, a part, with response-* overrides, with a
  customer's key, a payer or an expected owner are relayed whole and
  kept nowhere; a read the origin refused to the cache's own fill is
  sent on, so the client gets the origin's 404/403/400 and document.
  A GET is asked as a HEAD with the client's headers first; a body of
  more than a block goes in blocks under the HEAD's status and lines.
- Conditions on hits are weighed in RFC 9110's order, the dates
  included; one that does not hold is answered by the origin.
- SSE-C writes are never kept. Relayed calls are sent once
  (Options::once) and no checksum is added to a client's PUT.
- A DeleteObjects forgets every key its body names; any other call
  sent on whole forgets its key.
- No request id is made up for a hit.
- The in-tree origin answers as S3 does where the comparison needs it:
  conditions and dates, overrides, partNumber, delete markers, SSE-C,
  tagging, requester pays, expected owner, error documents, open and
  suffix ranges, 416, a HEAD never with a body.

tests/transparent compares each call of S3's object API, with every
header S3 takes, direct and through the cache under each mode: 109
pass. One known limit is marked: a PUT of more than one block is
refused; relaying it needs request bodies of several buffers.

Checks: tests of longshore_cache, longshore_s3, longshore_http_client
(all features, and the cache without defaults); clippy with all and no
default features; rustfmt on the files changed; license headers; the
serving, modes and fills explorations and their four deliberate bugs on
macOS and in the Linux container. The store, tier and stop explorations
cover code this does not change and were not rerun.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…routes

The cache relays a body longer than a block as it arrives, the origin's
100 Continue passed on. A shard of a cluster relays a request for a key
another owns to it, over a Unix-domain socket within the node and TCP
between nodes, marked so that none goes round, and answers 503 when the
owner cannot be reached; it listens on its own port, the node's shared
port and its socket. The map is learned from a list or a DNS name and
shared by a node's cores and a client's lanes (longshore_s3::membership).

longshore-cached runs one pinned shard a core, waits for its disk tier
before it listens, announces a node leaving before it stops, saves the
memory tier on a stop, and keeps serving when one shard fails. The disk
tier's log now carries the lines describing each object (format 2), so a
restart serves what it saved with the origin gone.

The longshore client built with a cache sends each request to the shard
that owns its key and to the origin when the shard cannot answer: at once
for no connection or 503, at the deadline for a read or an unsent write;
keys written around an owner are told to it afterwards. S3 gains a
per-operation target, cancel and whether a request was sent.

A Kubernetes example in deploy/cache. Tasks 5.1 to 5.4.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A simulated cluster of four nodes, a nameserver, an origin, a routing
client and plain clients on one backend (task 5.5), with partitions
(SimIo::cut and heal): nodes found by name, added and removed, a client
cut off from an owner writing around it and telling it afterwards, and
nodes whose maps differ answering every read correctly. It found that a
refresher asked every node over one host of its HTTP client, whose pool
reuses connections by host, and that a node cut off held the refresher's
connections for good; both fixed.

Two nodes explored with their maps changing at any point, the request
relayed at most once, and its deliberate bug (cache_hop_unmarked); a loom
model of the map threads share (task 5.7, the mutation run to come).

The Kubernetes example in deploy/cache, scaled and rolled under load on
io_uring with whole bodies checked (tasks 5.6 and 5.8; results in
bench/results/cache-k8s-orbstack.md). On io_uring a read relayed between
two cores of a pod lost its body: the owner sent it in place, which Linux
refuses on a Unix-domain socket. It now sends plainly there, and the
simulator refuses such a send as Linux does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nt::copy) into add-s3-cache

Conflicts, all of both sides kept:
- client/threads.rs: the Builder's timing settings beside the cache's;
  an IP-literal host becomes the address before deciding whether names
  are looked up (a cache found by name still is).
- client/worker/dispatch.rs: the copy in the one submit both routes use.
- s3.rs: both sides' imports and modules.

What the merge needed besides:
- A copy through a client with a cache is a write of its destination:
  it goes to the destination's owner, and one sent around it is kept
  for a notice. Without this a copy went straight to the origin, and a
  read of the destination could be the owner's object from before it.
- A write around its owner whose answer was lost may have landed: its
  key is kept for a notice too, not only one the origin acknowledged.
- The copy answer's XML reader moves out of multipart.rs into
  multipart/answer.rs, its tokenizer into answer/scan.rs, and also
  reads the result's ETag; S3::said reads a copy's code and ETag
  through it, so markup in a comment is never taken for either.
- The object-operations spec says again, as requirements, how a copy's
  answer is read; add-s3-cache's high-level-client delta routes copies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The job ran out of its 30 minutes on carverauto#70 while still exploring, and
add-s3-cache adds the cache's explorations and their mutants to it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The cache was two crates, `longshore_cache` and `longshore-cached`, the
second depending on nothing the first did not. It is one crate now,
named for what it is, `longshore_s3_cache`:

- The program is its binary `longshore-cached`
  (`src/bin/longshore-cached/`), the same name, so the image and the
  manifests run it unchanged. Its modules are the binary's own, not the
  library's API; its tests are the binary's, all twelve passing.
- `publish = false`: no release of it reaches crates.io until it is
  done. The `longshore` facade no longer re-exports it, so the facade
  can still be published; the packaging check leaves out every crate
  that is not published.
- CI lints it with each TLS provider itself, which the facade did for
  it before.
- The two store files `cargo fmt --check` refused are formatted.
- The README, the design notes, `openspec/project.md` and add-s3-cache's
  proposal, spec, design and tasks say all of this.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The copy answer's reader is a module of `multipart.rs`, which the
`multipart_response` target includes by its path: its modules are given
paths that read the same there, and its sizes are its own, held to the
store's by assertions at compile time. The target now also feeds every
input to `copy_answer`, whose code and ETag must stay within their
limits.

`cache_request` builds again too: the cache's conditions read a
`Last-Modified` through `heads` and take the object's date, and the
target tries each kind of date.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@marvin-hansen marvin-hansen self-assigned this Dec 2, 2026
marvin-hansen and others added 9 commits December 2, 2026 19:04
call_future_await_wait_and_detach_tag_order failed on CI (carverauto#73, no TLS):
nothing held the worker back from answering before the caller detached,
so the detach could take the answer. The worker now answers only once
the caller says it has detached.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On carverauto#73 both ran out of time. The explorations ran one after another in
one job, and the cache's alone took more than the 37 minutes left of 60;
the mutants of a pull request that adds the whole cache crate are 6,424,
about three minutes each on a runner.

- Explorations: nine jobs. Everything but the cache's (the explored
  build linted once, there); the cache's in four shares, even by the
  time each test took (scripts/explore-cache-times.txt: the slowest
  first, each to the lightest share; a test not listed weighs 1, so
  every test runs in exactly one share); the deliberate bugs in four.
  scripts/test-explore.sh --part rest|cache|mutants and --shard K/N; with
  neither it runs everything, as before.
- Mutation testing: four shards (cargo-mutants --shard). A change whose
  lines have more than sixty mutants, about what four runners check in
  their time, is not run, and a warning on the pull request says so: the
  full run that closes each group of tasks checks it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Three shares failed on carverauto#73, every one at an exploration's time limit,
not on a property: a share ran its tests all at once, each with its own
four checker threads, on a small runner, and the slowest stopped short of
covering their space. A share now runs its tests one at a time, as they
were timed for sharing out.

And LONGSHORE_EXPLORE_TIME_SCALE multiplies every exploration's time
limit, for a machine slower than those the bounds were set on; CI sets 2.
The limit keeps an exploration whose bounds blow up from running on; the
space each must cover is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The explorer's own test of a time limit (sim_explore) checks the limit it
set is the one an exploration stops at; doubled everywhere, it failed.
Only the cache's shares, set on faster machines, get the scale.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A world's digest is taken at every quiet point, and most of it does not
change from one to the next. The simulated disk keeps each data slot's
digest until a write, a poisoning, a corruption or a power loss marks it
stale; the test server keeps each object's data digest until its bytes
are written again; and buffer contents go in by 4 KiB pieces, each digest
kept beside a copy of its bytes and used again while they compare equal
(Digester::add_contents). Nothing has to say a piece changed, and with
LONGSHORE_DIGEST_CHECK set every kept digest is recomputed and must match.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Script::branching answers each decision past the end of the list with
what a hook returns, for an explorer that walks the tree of runs on the
live world. Such a decision and its answer are recorded as a listed
one's are (asked, given), since a scenario reads what was asked and
answered to judge its cases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The replaying explorer built a fresh world and replayed the whole list of
answers for every state it visited, on stateright's threads. The new
explorer builds the world once, in an arena the binary's global allocator
gives the thread (explore::arena::Arena), and walks the tree depth first
on it: a decision is answered 0 at once and its other answers wait; to
try one, a copy of the arena from the quiet point before the decision's
step is put back where it was, every pointer in it valid again, and that
step runs again with the next answer.

Most quiet points have no decision with answers left after them, so none
is copied when it is reached: a decision waits on the nearest copy below
it, and when the walk first comes back to it that copy is put back and
the steps since are run again, copying its quiet point and those of the
decisions waiting on the same copy on the way. Each step is run again at
most once for this, and a quiet point whose merge audit is due is copied
before its step. On the refusals exploration that took copies from 4.15
million to 165 thousand, for the same states.

States, merging and the merge audit are the replaying explorer's. A
merge at a decision is checked against what the walk recorded from the
state it merged with; where the record has no step for it, both lists
are followed past the point in each audit run. A field left out of a
digest is still caught. Decisions asked while the world is being built
go back by building it again, at the same address.

A world holding memory C code allocates (AWS-LC's key exchanges, in a
TLS handshake) cannot be put back from a copy of the arena: such
scenarios say so (Scenario::in_arena) and are replayed as before, as are
sampled explorations; the shortest failing list is still found by
stateright breadth first.

The explorer runs on one thread, so a binary's explorations run side by
side, one to a core: the cache's shares no longer run one at a time. In
the rust:1-bookworm container (8 cores) the cache's 37 explorations take
102 s together, 550 s on one thread, where the replaying explorer took
982 s on sixteen threads on the same machine; the times by which the
shares are balanced are the new ones.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The explorer builds each world once, in an arena the binary's global
allocator gives the thread, and walks the tree of answers depth first,
going back by putting a copy of the arena in place, copied only where a
decision has answers left. Digests keep what did not change since the
last quiet point. Explorations run on one thread each, side by side.

In the rust:1-bookworm container: the cache's 37 explorations in 102 s
(550 s on one thread; the replaying explorer took 982 s on sixteen
threads), every other exploration and all 15 deliberate bugs found, and
CI's lint steps clean. TLS worlds, which hold AWS-LC's own memory, are
replayed as before.

Revert this merge (git revert -m 1) to go back to the replaying explorer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@marvin-hansen
marvin-hansen merged commit 879fd78 into carverauto:main Dec 3, 2026
31 checks passed
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