Skip to content

Releases

v0.7.0 — correct, or you'll hear about it

Choose a tag to compare

@baer baer released this 20 Nov 02:18
Immutable release. Only release title and notes can be modified.

In 0.6, two inserts of the same _id could both report success. An update could bring back a row you'd just deleted. A collection could keep accepting writes after compaction stopped making progress, leaving reads to get slower as the log grew.

I'd written a blog post about why silent failures were worse than explicit errors. Then I shipped several.

0.7.0 fixes those cases, makes capacity limits explicit, and removes some machinery that wasn't earning its keep. It also breaks a few APIs. The bucket format is unchanged; the application changes are below.

Upgrading

pnpm add @gusto/baerly-storage@0.7.0

Back up first. baerly admin dump exports collection rows. Files your application writes directly to the bucket need a separate copy or bucket versioning.

There are three rollout details to read before deploying:

  • All writers to a collection must run 0.7.0 before you can rely on the new concurrency guarantees. Older writers don't enforce them.
  • 0.7.0 stops writing index markers. A 0.6.0 process reading after a 0.7.0 write can miss rows in indexed queries. This affects mixed deployments and rollbacks. Keep index/ while rollback remains possible, and read the upgrade guide's index marker section.
  • If you use R2 through the S3 API, maintenance has been failing in 0.6.0 too. The first maintenance pass after upgrading folds the backlog. The R2 binding is unaffected.

The runtime requirement is now Node 26 or later. On Workers Paid, set BAERLY_MAINTENANCE_PROFILE=cf-paid; a Worker can't detect its plan and defaults to Free limits. Workers Free with S3 over HTTP is no longer supported. Use Workers Paid with that setting, or the R2 binding.

Application and integration changes

If you use… Change in 0.7.0
err.code === "Conflict" Use WriteConflict for retryable conflicts and AlreadyExists for duplicate inserts. retriable is derived from the error code.
Positional optional arguments to BaerlyError Use an options object: new BaerlyError(code, msg, { cause }).
An exhaustive BaerlyErrorCode switch Remove Conflict. Add WriteConflict, AlreadyExists, AmbiguousCommit, CapacityExceeded, MaintenancePending, CursorExpired, and UnsupportedMediaType.
Values such as Date, Map, NaN, or undefined array entries Convert them explicitly to plain JSON before writing. They are now rejected rather than coerced.
Non-string or non-NFC IDs; non-NFC app, tenant, or collection names Validate and normalize at the application boundary. _id must be a well-formed NFC string.
Duplicate insert calls as upserts Duplicate inserts now throw AlreadyExists. Use update or replace as appropriate.
Patches typed as Partial<T> Use the exported MergePatch<T> type. Patches follow RFC 7396 at every depth.
Declared indexes Declarations are still validated, but do nothing in 0.7.0. rebuild-index has been removed.
A custom Storage implementation Remove versionId, conditional GET, and lastModified. Throw WriteConflict when a precondition fails.
The HTTP API directly Send a JSON Content-Type on POST, PATCH, and PUT, or receive 415. On a 410 CursorExpired from /v1/since, restart with cursor: "".
JWTs without exp bearerJwt and cloudflareAccess now reject them with 401. Configure an expiry at your identity provider.
runScheduledMaintenance or undocumented exports /maintenance now exports one function, addressed by collection; undocumented internals have been removed from the package exports. See the upgrade guide for replacements.

The upgrade guide groups changes by application, host, and data. The changelog has before-and-after examples for every breaking change. If the prose and shipped .d.ts files disagree, use the types.

Capacity limits now stop writes

In 0.6, a collection could exceed its host's compaction limit while continuing to accept writes. Maintenance stopped keeping up, but the log kept growing. The warning was a counter you had to know to watch.

0.7.0 refuses writes that would grow a collection past its host's limit. The errors distinguish a collection that needs less data from one that needs maintenance:

Error Meaning Recovery
CapacityExceeded — HTTP 409, not retryable The write would exceed the collection's capacity limit. Nothing is committed. Make room or move to a host with a larger limit. Reads, deletes, and shrinking updates remain available, subject to request budgets.
MaintenancePending — HTTP 503, retryable Folding pending changes would make room for the write. The write was refused. Retry after the indicated delay. Each retry performs another fold pass; the bundled client handles this.

Capacity is checked against the current collection state on every request. There is no stored read-only flag to clear after making room.

Writes nearing the limit carry a Baerly-Capacity-Warning header. The HTTP client exposes it through onWarning, and logs include capacity_warning.

Requests also have a storage-call budget. Retries and LIST pages count toward it. A request that cannot fit is refused with CapacityExceeded; a read is never shortened to fit the budget.

Host profiles now have separate fold limits. Node can fold up to 32 MiB / 65,536 rows; Workers Paid, 8 MiB / 32,768 rows. Previously, all profiles inherited the Free limits, with an arithmetic bug making Node's limit lower still. See scale-ceilings.md for the full limits.

Refusals log at warn with outcome: "refused". Alert on error.code: four codes share HTTP 409. Capacity refusals aren't counted as conflicts, and maintenance refusals aren't counted as errors.

Concurrent writes

Concurrent inserts of the same _id now have at most one winner. The first commit keeps the row; competing inserts throw AlreadyExists and commit nothing. Previously, both could report success while one silently replaced the other's document.

An update that races another write now applies its patch to the newest committed version of the row. It preserves concurrent changes to other fields and leaves a concurrently deleted row deleted. Previously, it could write back the version it first read, losing changes or resurrecting the row. A patch also cannot change _id.

When the outcome of a commit cannot be established from durable state, the operation returns AmbiguousCommit (HTTP 409, not retryable). It no longer reports success or suggests a blind retry. Read the row identified by err._id to reconcile the result. For an insert, retrying with the same _id is the safe recovery.

Auto-ID inserts through the HTTP client now get a UUIDv7 before sending. Resending the request replays the original success rather than creating another row. Other requests that are safe to resend get up to three attempts with jittered backoff; the client honors Retry-After up to 10 seconds.

Writes accept plain JSON

A document must be plain JSON, no larger than 1 MiB or 100 levels deep, with a well-formed NFC string for _id. The same validation runs in-process, in the HTTP client before sending, and during baerly admin restore.

Previously, JSON.stringify supplied some undocumented policy: a Date became a string, a Map became {}, and NaN became null. A numeric _id could be replaced with a UUID. These inputs are now rejected before I/O, with an error identifying the path and an err.resolution describing the remedy.

Invalid values and oversized documents produce InvalidConfig; excessive depth produces SchemaError. get(id) also throws InvalidConfig for an ID that could never be stored, rather than returning undefined. Existing rows that predate these rules remain readable and deletable.

The types now match these rules: _id is a string throughout, and MergePatch<T> represents patches, including null deleting an optional field.

Storage and maintenance

The retry logic had retries. A failing commit could make up to 81 create attempts. There is now one retry layer: at most three creates and one readback.

A commit uses one storage write: creating the next log/<seq> object if absent. Separate content/<sha>.json objects and index markers are no longer written.

Log cleanup uses a sequence window rather than timed mark-and-sweep. Log object counts stay bounded, and replaced snapshots are reclaimed at the rate folds create them.

The R2-over-S3 maintenance failure came from weak ETags on compressed JSON responses. Those ETags never matched If-Match, so compare-and-swap operations failed and the log accumulated. This is fixed for both r2Storage and s3Storage pointed at R2.

Garbage collection now measures grace periods from marking rather than object age on S3, GCS, and R2. Deletion candidates are tied to the generation that marked them, and orphan snapshots are checked for obsolescence before deletion. /v1/since cursors also carry a generation, so baerly admin restore --force cannot silently skip rows in an existing stream.

Other changes

  • React queries support useQuery(cb, deps, { live: false }) and expose a stable refetch(). Superseded fetches are cancelled, and expired cursors trigger a fresh subscription bootstrap.
  • HTTP count() honors limit, matching the server SDK.
  • JSON Content-Type requirements close off CORS-simple request forgery on body routes. webRoot rejects symlinks that escape its root. listen(port, { hostname }) supports binding to loopback, and invalid BAERLY_MAINTENANCE_* settings fail at startup.
  • Both packages use npm trusted...
Read more

v0.6.0 — Google Cloud Storage, natively

Choose a tag to compare

@baer baer released this 16 Jul 00:53

Google Cloud Storage, natively

baerly-storage 0.6.0 promotes Google Cloud Storage to a first-class backend and sharpens a few operational signals for everything else. Maintenance now tells you when a delete fails instead of silently succeeding, and a client's mistake no longer pages your on-call. Plus a dev-server ergonomics win for monorepos.

GCS is now a Tier-1 backend

Previously, gcsStorage produced an S3-interop client whose conditional write headers GCS silently ignored. Basically, Google does a Google-flavored thing instead of a true S3 interop. That meant it could not linearize the commit log, which is the one coordination primitive baerly-storage needs from a bucket. So, I had this half-baked GCP adapter that was kinda a dead end.

  • gcsStorage now speaks the native GCS XML API. It drives GCS's own generation-precondition writes (x-goog-if-generation-match), so it gains real create-if-absent and compare-and-swap, returning 412 → Conflict on a lost write. The gcsStorage({ bucket, credentials }) signature is unchanged. Existing callers keep compiling; what changes is that the writes now actually commit correctly.
  • Credentials remain GCS HMAC interop keys (accessKeyId / secretAccessKey). Node host only in v1. No Worker /gcs subpath and no GCP deploy target yet.

Cleaner operational signal

  • delete() now surfaces unexpected failures instead of swallowing them. On the S3/GCS adapter, 200/204/404 still count as success (delete is idempotent), but anything else now maps through the shared error classifier (403 → AccessDenied, 429/≥500 → retryable NetworkError). Before this, a 403 during GC or compaction looked like it removed an object it never touched — so the bucket would grow while maintenance reported success. This is a correctness fix.
  • A 4xx now logs at warn, not error. A 4xx is the caller's fault, not a server fault — the reachable 409 Conflict is a duplicate-_id insert (a reused id or a double-submitted POST). Logging these at error polluted error budgets and could page on-call for normal operation. error is now reserved for genuine server faults. The line still carries the structured { code, message }; only the (unneeded) stack drops off.
  • Bumped @logtape/logtape 2.2.2 → 2.2.4 to pick up the upstream fix for a configure() process exit-listener leak (dahlia/logtape#192). This wasn't broken, I just got to delete my workaround, and repeated reconfiguration in one process (test suites, hot-reload) no longer leaks listeners.

Smoother dev server for monorepos

  • baerlyDev can now load baerly.config itself. BaerlyDevOptions.config is optional; pass a configPath, or nothing at all to load <viteRoot>/src/baerly.config.ts by convention (mirroring how reactRouter() loads react-router.config.ts). This keeps your vite.config.ts free of a baerly.config import, which is what an Nx @nx/vite inference plugin would otherwise bundle and choke on during project-graph creation. Passing an explicit config object still works, unchanged.

Upgrade

pnpm add @gusto/baerly-storage@0.6.0

No action required for most apps.

  • On GCS? Dope. Your app works now. Didn't before. But I was clear on that in the docs, so you can't say I didn't warn you.
  • Calling a Storage adapter's delete() directly and relying on it never throwing? A non-2xx/404 status now surfaces as a BaerlyError. This is safe on the maintenance path (the runner already swallows non-Conflict throws after logging them); catch BaerlyError if you drive delete() yourself.

Full changelog + migration notes: CHANGELOG.md

📦 npm · 📚 Docs · 🧠 Theory

v0.5.0 — a well-behaved library

Choose a tag to compare

@baer baer released this 07 Jul 16:16
40f533b

A well-behaved library

baerly-storage is a library, not an application — and this release makes it act like one. The headline fix: it no longer hijacks your app's logging configuration at boot. Plus an honest rename of one /v1/spec field.

Stop clobbering your logging

Previously, the Node and Cloudflare adapters called LogTape's configure({ reset: true }) unconditionally at startup — silently wiping the sinks and loggers of any app that had already configured LogTape (and, depending on boot order, sometimes wiping baerly-storage's own config instead). The documented "leave the field unset to skip configuration" escape hatch never actually worked.

  • baerly-storage now checks getConfig() first. When LogTape is already configured by something other than baerly-storage, it leaves that config intact and emits a single ["logtape", "meta"] notice instead of resetting it. Its own config still reconfigures last-call-wins, so standalone servers and dev hot-reload are unchanged.
  • New observability: false opt-out. Pass it to baerlyNode / baerlyWorker to skip auto-configuration entirely, for apps that own the process-wide (isolate-wide on Workers) LogTape configuration themselves.

An honest field name

  • /v1/spec renames kernelVersion → serverVersion. The value and meaning are unchanged (the published package version, a build-provenance stamp), but kernelVersion wrongly implied a separate "kernel" contract axis. Key contract decisions off specVersion — which stays "1" — never off serverVersion.

    GET /v1/spec → { "specVersion": "1", "kernelVersion": "0.4.1", ... }   // before
    GET /v1/spec → { "specVersion": "1", "serverVersion": "0.5.0", ... }   // after
    

Upgrade

pnpm add @gusto/baerly-storage@0.5.0

No action required for most apps. Two things to know:

  • If your app configures LogTape itself, baerly-storage now respects it — you'll see a one-line ["logtape", "meta"] notice instead of your config being wiped. Pass observability: false to opt out entirely.
  • If you read kernelVersion off /v1/spec, switch to serverVersion. (You should be keying contract decisions off specVersion regardless.)

Full changelog + migration notes: CHANGELOG.md

📦 npm · 📚 Docs · 🧠 Theory

v0.4.1 — fail safe by default

Choose a tag to compare

@baer baer released this 06 Jul 22:29
29fbbca

Fail safe by default

baerly-storage 0.4.1 is an operational-hardening release. The theme: when something is misconfigured, fail loud at boot instead of quietly losing data. Plus two new ways to run it — Cloudflare Workers over S3, and S3 on EKS.

Note: 0.4.1 supersedes 0.4.0, which has been deprecated on npm. 0.4.0 shipped a mis-stamped kernelVersion ("0.3.0") in its served /v1/spec; 0.4.1 corrects it and is otherwise identical to 0.4.0. Install 0.4.1.

Fail closed, not silent

The failure mode this release closes: an app falls back to in-memory or local-disk storage in production, writes "succeed" into RAM or an ephemeral container disk, then vanish on the next restart with no signal.

  • MemoryStorage refuses to construct in a detected deployment (NODE_ENV=production or a known PaaS marker) unless you explicitly pass { ephemeral: true } or set BAERLY_ALLOW_EPHEMERAL_STORAGE=true. Tests, local dev, and CI are unaffected.
  • The Node example servers fail loud in a deployment when a real bucket is missing or typo'd — they won't silently run on the local-fs dev fallback.
  • Invalid object keys are rejected before the wire. . / .. / empty keys now throw a clear InvalidConfig on every adapter, instead of drawing an opaque bucket-root 403.
  • sigV4Signer fails fast on blank or whitespace-only credentials rather than signing with empty values and drawing a 403.

Runs in more places

  • Cloudflare Workers can now use S3-compatible storage over HTTP, not just a native R2 binding — via the new Worker-safe @gusto/baerly-storage/s3 subpath. Opt-in; the R2 binding stays the default.
  • S3 on EKS works out of the box. New fromWebIdentity() and fromEks() credential providers add IRSA (AWS_ROLE_ARN + AWS_WEB_IDENTITY_TOKEN_FILE) support alongside the existing Pod Identity path — no AWS SDK dependency.
  • Zero-credential local dev. The new localFsStorage() factory lets Node apps run against the local filesystem in development and promote to S3/R2 once bucket env vars are set.

Also in this release

  • New type exports — PredicateArg, Predicate, Collection (root) and PredicateArg (/client) — so you can name .where(...) arguments directly. Fixes a Path<T> bug where an optional array field broke predicate typing.
  • Smaller S3 bundle — swapped fast-xml-parser for @rgrove/parse-xml: −87 KiB raw / −14 KiB min-gz on the s3.js closure, zero transitive deps, and the XML-entity-expansion CVE class can no longer recur.
  • Durable-contract promises written down — LogEntry is versionless and additive-only, version axes are drift-gated, and storage capabilities are split required vs. optional. Docs + internal tooling only; no runtime change.

Upgrade

pnpm add @gusto/baerly-storage@0.4.1

No action required for apps already on a real S3/R2 bucket. The one thing to know: if you were (accidentally) running on in-memory or local-fs storage in a deployment, it will now refuse to boot — that's the point.


Full changelog + migration notes: CHANGELOG.md

📦 npm · 📚 Docs · 🧠 Theory

v0.3.0 — baerly-storage goes public

Choose a tag to compare

@baer baer released this 16 Jun 22:41
5b7692c

Storage is the missing primitive for agent-built software — and all you need is a library.

baerly-storage turns AWS S3, Cloudflare R2, or any conformant S3-compatible bucket into a document database. There is no runtime. None. No daemon, no leader, no scheduler, no catalog, no database bill, no on-call. The only persistent component is your bucket — the data lives in your account, in a format you can read.

This is the first release intended for outside use. 🎉

Why it exists

Compute   →  FaaS
Tokens    →  LLM API
Storage   →  this.

Built like git: content-addressed documents, immutable numbered log entries, and one conditional log create as the commit, per collection. You get a document model, live queries, and snapshot isolation — and the whole public API fits in a ~12k-token dist/API.md, small enough for an LLM to hold in context and use zero-shot.

The server bundle is ~100 KB gzipped; the browser client ~5 KB. Maintenance (compaction + GC) rides the write path — Cloudflare finishes it with ctx.waitUntil, Node runs it inline — so idle buckets pay nothing and there's no cron to install.

Get started

# scaffold an app — Cloudflare Workers + R2, or self-hosted Node + S3
pnpm create @gusto/baerly-storage@latest

# …or add it to an existing project
pnpm add @gusto/baerly-storage

Day-one templates ship for Cloudflare Workers (R2) and self-hosted Node (S3), plus a React SPA variant of each.

Is it for you?

Sized for small, server-only-write apps with a ~10 GB ceiling and a mechanical exit to Postgres when they outgrow it. If that's your shape, you get a tool that matches it instead of a stack that doesn't. If you need multi-writer client sync, multi-document transactions, or terabytes, reach for a real database — and baerly will tell you when you've crossed the line.

Pre-1.0

This is 0.x: the on-disk format and public API may still change between minor versions until 1.0. Pin your version.


Full technical changelog (including migration notes for anyone who ran an internal 0.1–0.2 build): see the 0.3.0 entry in CHANGELOG.md.

📦 @gusto/baerly-storage on npm · 📚 Docs · 🧠 Theory