Repository navigation
refactor(storage): reduce the storage contract to revisioned records - #39
Merged
Merged
Conversation
brandonweeks
force-pushed
the
storage-revisions
branch
from
July 18, 2026 06:20
12855ec to
9f0163f
Compare
Storage backends now implement typed reads and writes with optimistic revisions and three sentinels: ErrNotFound, ErrConflict on a stale revision, and ErrExists on a duplicate create. The reservation, lease, and status-transition machine moves into the CA as a read-classify-write loop that retries from a fresh read on conflict, so every lost race is judged against the exact record the winning write replaced and backends never classify ACME state. Records round-trip by encoding rather than struct identity: a read returns a record that marshals to the document that was written. Leases and nonce expiry are judged with the CA host clock, so backends need no clock; the CreateNonce ttl is a hint that only licenses storage-level cleanup. The badger backend keeps its key schema, wraps records in an envelope carrying an explicit revision counter, and drops all reservation logic. storage/storagetest provides a conformance suite for backend authors, and NewMemoryStorage is a reference backend that passes it.
A certificate is served only when the order it names references it back, so one left behind by a failed or superseded finalize belongs to no one. The account-wide order scan it replaces was the last caller of GetOrdersByAccount, which leaves the Storage contract.
RFC 8555 Section 7.1.2 requires the account object to name an orders URL, and a client may refuse an account without one. Compose the URL on read like the other wire fields rather than persisting and back-filling it, and back it with an account orders endpoint: CreateOrder names each new order on its account, and the list is composed from those IDs, so Storage still needs no lookup beyond GetAccountByKey.
brandonweeks
force-pushed
the
storage-revisions
branch
from
July 18, 2026 06:39
9f0163f to
08fda54
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Storage backends now implement typed reads and writes with optimistic revisions and three sentinels: ErrNotFound, ErrConflict on a stale revision, and ErrExists on a duplicate create. The reservation, lease, and status-transition machine moves into the CA as a read-classify-write loop that retries from a fresh read on conflict, so backends never classify ACME state. storage/storagetest provides a conformance suite for backend authors, and NewMemoryStorage is a reference backend that passes it.
Orders store ids and compose urls on read. On top of the contract change, handlers now authorize certificate fetches through the issuing order, enforce order and authorization expiry, and serve the account orders URL and order list required by RFC 8555 §7.1.2.