Repository navigation
Storage: cacheable delivery, and stop marking private objects public - #13
Conversation
`rebase cloud resources` printed a Plan line reading "legacy (no plan)" against a column that no longer exists, and `rebase cloud billing` built a `compute_<provider>_<vmSize>` lookup key — a price for a machine on a list this platform does not buy from, dead since `vmSize` was removed on 2026-08-20 and printing a bare label ever since. Both now ask the control plane what the project's dials cost (`POST /api/functions/pricing/quote`) and print the itemised answer. Best-effort: an older control plane has no such endpoint, and a resources listing that failed because a price could not be fetched would be worse than one without it. Four dials the plans used to decide are flags now — `--replicas`, `--spot`, `--scale-to-zero`, `--storage` — and `projects create` takes the same set, so a project can be created at the size it needs rather than resized afterwards. It also stops sending `vm_size`, which the control plane dropped. `--spot false` is parsed to the boolean `false`, not the string. The string is truthy, and would have put a project that asked for on-demand capacity onto preemptible nodes at a third of the price with the restarts it declined. Co-Authored-By: Claude Opus 5 <[email protected]>
`import { defineFunction } from "@rebasepro/server"` reaches the whole
framework — boot, the collection loader, the backup routes, the SPA server,
`@hono/node-server`, `ws`, `jsonwebtoken`, Drizzle. On Node that costs start-up
time and nothing else. It also means a function file can only ever resolve
inside a Node process, however portable the function's own code is, and that
import line is in every function file, template and doc page — so it is not a
thing that can be changed later without breaking everyone who wrote one.
The new entry point carries the authoring surface and nothing else. Its
published bundle imports exactly two things, `hono` and `hono/adapter`, and two
gates keep it that way: a test walks the import graph from source and names the
chain that broke the rule, and the build evaluates the emitted file in a `vm`
context holding web globals and no `process`, `Buffer` or `require` at all.
Both are mutation-tested. Importing from the package root still works and
behaves identically.
Also in the authoring surface, because each was a gap the same move exposed:
- Typed context accessors. `getUser(c)` returns `{ uid, roles, …claims }` with
`roles` always an array, replacing the `c.get("user") as { uid: string;
roles?: string[] } | undefined` cast that every example opened with — an
assertion in a security-relevant position, and wrong for at least one auth
path that reaches it. Plus `requireDriver`, `requireRole`, and guards that
read the resolved identity rather than parsing a token (equivalent inside a
function, where the middleware has already run; fail-closed outside one).
- `waitUntil(c, promise)`. A floating promise at SIGTERM is dropped mid-flight,
so a rolling deploy could always lose a webhook the request had already
answered 200 for; shutdown now drains tracked work, bounded, and reports what
it could not wait for.
- Configuration read from the request: `getEnv`/`env`/`requireEnv`/
`lazyResource`. `new Stripe(process.env.KEY!)` at module scope is a live
defect today — it throws while the file is being imported, and the loader
reports that as a *skipped function*, so the route 404s with the reason in a
boot log. `rebase build` and `rebase doctor` now report those reads.
- `rebase build` records per-function portability in the bundle manifest, so a
host can tell what is in a bundle without booting it.
`packages/server/functions/package.json` is a resolution redirect, not a
package: TypeScript's `moduleResolution: "node"` — which the scaffolded backend
uses — ignores `exports`, and without it the template's own import fails `tsc`
while running fine. `assert-build-output.mjs` verifies redirect targets for the
same reason it verifies entry points: a broken one is silent.
Docs rewritten in all six locales, with the anchors fixed (the machine
translations had kept the English ones), and the scaffolded template and the
three agent skills moved onto the new import. The API-surface gate now tracks
both entry points.
Co-Authored-By: Claude Opus 5 <[email protected]>
`tsc` writes relative specifiers into `.d.ts` exactly as the source wrote them — extensionless, because the source is compiled by a bundler. Every package here is `"type": "module"`, and under `moduleResolution: "nodenext"` an extensionless relative specifier inside an ESM declaration file is an error. TypeScript's response is the part that matters: it does not fail at the consumer's import. It resolves the package, discards every declaration it could not follow, and types the whole import `any`. So there was no diagnostic anywhere near the cause. The first thing a consumer saw was an implicit-any error in *their own file*, pointing at their code, in a project that had done nothing wrong. Measured on `@rebasepro/server`: `bundler` resolution sees 170 value exports, `nodenext` sees zero. It has been that way for the whole life of the packages. Fixed by appending the extension the declarations always needed — `./init` → `./init.js`, and `./auth` → `./auth/index.js` where the target is a directory, resolved against the filesystem rather than guessed, because a dangling specifier degrades to `any` again. Not a trade: TypeScript maps `./x.js` onto `./x.d.ts` under node10, bundler and nodenext alike, so nothing that worked before stops working. 547 specifiers across the five packages that were built to verify it; the step runs in all 21 published builds. The rewriter refuses a `dist` whose realpath is outside its package. That is what a git worktree's symlinked node_modules looks like, and without the guard a build run there silently rewrites the primary checkout's published output. `pnpm check:dts` is the gate, in verify.yml after the build. Nothing in this repository could have caught the original defect, which is the more interesting half: `pnpm typecheck`, the docs verifier and the template checks all map `@rebasepro/*` onto source, and the API-surface gate reads a single `.d.ts` in isolation. Every gate looked at something other than the artifact a stranger installs. So this one installs each built package into a throwaway directory by symlink, imports it, and compares the value exports the type checker can see in each resolution mode — a question that needs no knowledge of any package's API, and so keeps working as they change. It detects a single reverted specifier (167 exports where 170 are expected) and names the file and line that caused it. node10 is expected for package roots always, and for a subpath only where the package ships a redirect directory — with `@rebasepro/server/functions` named explicitly, since the backend `rebase init` scaffolds compiles with `moduleResolution: "node"` and deleting that redirect would otherwise reduce coverage silently rather than fail. Co-Authored-By: Claude Opus 5 <[email protected]>
Building the fourteen packages this worktree had never built turned the gate green across all 21 — and then a mutation test on `@rebasepro/admin` walked straight past it. Reverting one specifier in its `dist/index.d.ts`, exactly the defect the gate exists for, was not caught. The discriminator was value exports: functions, consts, classes. That is the right signal for a package whose surface is mostly values, and blind for one whose surface is mostly types. `admin`'s broken re-export was `./types/index`, which carries no values at all, so nothing it exported could go missing from a count of values. `@rebasepro/types` — the package most consumers feel first — was blind for the same reason along its whole surface. Three changes: - Read the diagnostics off the package's own declarations directly, rather than inferring damage from the export surface afterwards. TS2834/2835 is the exact nodenext rule being broken; it needs no inference and no export to be lost. This meant turning `skipLibCheck` off, because it suppresses precisely the errors under test. - Compare *all* exports across resolution modes, not only the value ones. - Stage every workspace package into the throwaway consumer, not just the one under test, so its layout matches an installed tree. Turning declaration checking on surfaced a false positive immediately: a sibling `@rebasepro/*` import inside a dependency's own `.d.ts` reported TS2307 under node10. That is the probe's fault, not the package's — symlinking means TypeScript resolves from the real repository path, so an upward lookup never reaches the staged node_modules, while a real install has the whole closure flat and resolves it without trouble. TS2307 now counts only for a *relative* specifier, which is an emission defect; for a bare one it is a question the staging cannot honestly answer. Verified by mutation on three shapes it previously could not distinguish: a value-heavy package (server), a pure-type package (types), and the type-only re-export that started this (admin). Plus the node10 redirect deletion. All 21 packages now build and pass; the full run takes ~75s. Co-Authored-By: Claude Opus 5 <[email protected]>
…osed Both scripts were verified by running them and reading the output, which checks that they work on today's input and nothing about the cases they were written to handle. The gate had already stopped gating once within hours of being written, so that is not a hypothetical standard. Writing the fixtures found two more defects in the gate, neither visible by inspection and both of which made it inert rather than wrong: - The diagnostic filter was scoped to `/packages/` — the repository's own directory shape — so it silently exempted any package outside that path. Every fixture is outside it, which is why the first run of the new suite had four failures against a gate that passes the real packages. Scoped to the package under test now, which also makes the earlier cross-package false positive (a sibling's diagnostics reported under `@rebasepro/admin`) impossible by construction rather than by filtering. - The prefix comparison used the literal path. TypeScript reports resolved paths, and on macOS `/var/folders/…` is a symlink to `/private/var/…`, so the comparison matched nothing for anything under the temp directory. Real arguments happened to match; fixtures never could. The suites encode the shapes each script must tell apart. For the rewrite: a directory specifier becoming `<dir>/index.js` rather than `<dir>.js` (guessing dangles the re-export and restores the `any`), a string-literal type and an ambient `declare module` name left alone (claims that lived in a comment and nowhere else), idempotency, the symlinked-dist refusal, and a dangling specifier failing loudly. For the gate: healthy, values-broken, types-broken, a package with no values at all, subpaths with and without a node10 redirect, and a `.css` export that is not a module. Mutation-tested both suites. A naive `+ ".js"` breaks the directory test; a regex-instead-of-AST collector breaks exactly the two tests guarding syntactic position — and getting that mutation to be live took two attempts, because the first one was mis-escaped and passed vacuously. Wired into `test:gates`, which verify.yml already runs. Co-Authored-By: Claude Opus 5 <[email protected]>
Portable @rebasepro/server/functions entry point, plus the .d.ts resolution gates that keep it honest.
CLI prices resources by dial, with no plan left to name.
…reads Co-Authored-By: Claude Opus 5 <[email protected]>
`frameworkVersion` meant the framework the runtime IMAGE ships in `cloud status`, and the framework a BUNDLE installed in `cloud deployments`. The image supplies the server and the bundle supplies the driver, so the two are routinely different — printed under one name they read as the control plane disagreeing with itself about a single number, which is how it was reported. Now `imageFrameworkVersion` and `builtAgainst`, spelled out where they print so neither can be misread. Co-Authored-By: Claude Opus 5 <[email protected]>
…nning a version The security table still named 0.10.x long after 0.10 stopped being the latest minor, so it documented the opposite of the policy it meant. The rule now sits above the table and the table only illustrates it. Co-Authored-By: Claude Opus 5 <[email protected]>
…nto the site copy_changelog.js only ever moved one file; copy_repo_docs.js mirrors any repo-root document, copying rather than moving so existing references keep resolving. check:generated gates the copies so they cannot drift. Co-Authored-By: Claude Opus 5 <[email protected]>
…se study Co-Authored-By: Claude Opus 5 <[email protected]>
The dropdown panels were tall enough to cover the hero: 558px for Product, 410px for Developers at 1440x900. Two of that height came from shape, not content — a two-column grid capped at max-w-3xl, plus a full-width footer row below it holding the overview/docs links. Fold that footer into a third headed column (Explore, Resources), let the grid span the panel's inner width, and tighten the row rhythm. Wider columns also stop most descriptions wrapping to a second line, which pays again in height: Product is 380px now, Developers 298px. Mobile flattens columns into one list, so those links still appear there. Co-Authored-By: Claude Opus 5 <[email protected]>
Ports the wall from the FireCMS site into this file's own structure: INTRINSIC sizing, the shared class constants and the `product` field all stay, and the new entries feed into them rather than around them. Every new entry is tagged `product: "firecms"`. Unlike the existing seventeen this is not a guess: each is a FireCMS Cloud customer verified from signup and project activity, which is the evidence the `product` comment asks for. The tally moves from 1 known / 17 unknown to 1 rebase / 26 firecms / 16 unknown, so the caption still needs its qualifier. INTRINSIC values were read back with `new Image()` as the comment instructs, and that mattered: a viewBox-only SVG reports a 300px natural width, not its viewBox width, so seven entries would have carried numbers 2-6x too large had they been parsed from markup. Also: eight marks were too dark once grayscale and opacity-60 composited over the near-black ground (Team Global Express measured 21 against 153 for white ink); they were dark-coloured marks wrongly flagged `invert: false`. MedicalMotion moves to the white asset already here. withu.png was 84% transparent padding and overflowed its cell. Adds a "companies" type, an optional textClass, matching brightness for text fallbacks, and two-up logos on mobile. Co-Authored-By: Claude Opus 5 <[email protected]>
Three-column mega-nav and the 26-logo client wall. Co-Authored-By: Claude Opus 5 <[email protected]>
The checked-in files predate three generator changes: the users read policy compares `id = rebase.uid()::uuid` rather than casting the column to text, `orders` gained its `order` column, and the search block now emits the immutability guard that refuses to re-apply when a generated column's expression changed underneath it. Regenerating twice produces identical output. Co-Authored-By: Claude Opus 5 <[email protected]>
…write The skills had drifted from the API they describe: `@rebasepro/ui` was said to export `AddIcon`/`DeleteIcon`, which do not exist — it re-exports lucide-react under its own names (`PlusIcon`, `Trash2Icon`); the studio skill named `sideEntityController` rather than `sidePanelController`; and the project-structure tree omitted `backend/functions/`. An agent following any of these writes code that does not compile. Co-Authored-By: Claude Opus 5 <[email protected]>
…blic Three problems in the served-object headers, one of them a leak. **`public` on private objects.** Every response said `public, max-age=3600`, including for an object that had just required credentials to fetch. `public` is explicit permission for a *shared* cache — a CDN, a corporate proxy — to store the response and hand it to the next caller. Objects outside the `public/` prefix are now `private`, and `Vary: Authorization` is sent so a cache that does key on it cannot merge two callers' answers. **`immutable` on mutable keys.** The remote path claimed it at an hour and the transform paths at a year. `immutable` promises the body at this URL will never change; writing to an existing key is an ordinary operation, so the promise is false for every object here, and the symptom was an upload that replaced a file which then did not visibly change until the window lapsed. Gone, everywhere. **No caching at all on the local path.** It sent no cache headers, so every load of every image re-read the file and re-sent the body. All four response paths now carry a weak `ETag` and `Last-Modified` and answer 304 to `If-None-Match` / `If-Modified-Since`. The local path takes them from a `stat` that replaces the existence-check `access` — one syscall doing two jobs rather than two doing one each — and the 304 is decided before the file is read, which is the point. The validators are weak on purpose: they are size and mtime, not a digest, which is the trade nginx makes for static files. Hashing every object on every request would cost more than it saves for bytes this server is already streaming from somewhere else. Short max-age plus cheap revalidation replaces the long lie: 60s for objects, 3600s for transforms, `stale-while-revalidate` for public ones so the round trip is not something a user waits for. Not included: range requests. Media seeking still fetches whole objects.
The transform cache key named the object but not which version of it — `source/bucket/path` plus the transform options. Overwriting the source left the old rendition valid for the cache's full hour, and the HTTP `max-age` sat on top of that, so a replaced image could stay visibly unchanged for two. The key now carries the source's validator, so replacing the source produces a different key rather than shadowing one, and the superseded entry ages out on its own with no invalidation to get wrong. Proved by mutation: dropping the version from the key fails the new test.
|
Added a second commit: a replaced image no longer serves its old rendition. While writing the header work I noticed the transform cache key names the object The key now carries the source's validator. Replacing the source produces a Proved by mutation rather than by assertion alone: dropping
This is a third of the "durable transform cache" item in #7 — it fixes staleness |
…r the build
Every pull request has been failing since the portable functions entry point
landed:
FAIL baas
backend/functions/hello.ts(7,8): error TS2307:
Cannot find module '@rebasepro/server/functions'
`check:templates` and `check:eject` compile a *scaffolded project*, which
resolves `@rebasepro/*` through node_modules and its `exports` map. `./functions`
points at `dist/functions/index.d.ts`, so before `pnpm run build` it resolves to
nothing and the baas preset — whose `hello.ts` now imports it — fails to compile.
Both checks ran before the build step.
Nothing caught it locally because a developer's checkout has a `dist` lying
around from the last build; CI installs and has none. Reproduced by deleting
`packages/server/dist/functions` and running the check, which fails identically.
Moved both after `Build packages`, where `check:api-surface` already sits for
exactly this reason — its comment says "Reads dist/index.d.ts, hence after the
build". The cost is that a broken template is reported a few minutes later; the
alternative is a gate that cannot pass on a clean checkout.
Verified the rest of the lane separately: core-types, types-headless, baas-types,
test-scripts, control-chars, untranslated, hooks, unused, api-surface, dts,
deps, headless, names, derived-names and verify:docs all pass on this commit, so
this is the only thing standing between main and a green run.
`check:generated` runs the website generators and fails on any diff, so a docs change that does not carry its regenerated artifact fails CI. Mechanical.
Second item of #7.
Three problems in the served-object headers. One of them is a leak, so leading
with that.
publicon objects that required credentialsEvery response said
public, max-age=3600, immutable— including for an objectthat had just been through
readAuthMiddleware.publicis explicit permissionfor a shared cache (a CDN, a corporate proxy) to store the response and serve
it to the next caller.
Objects outside the
public/prefix are nowprivate, andVary: Authorizationis sent so a cache that does key on it cannot merge two callers' answers.
immutablewas false for every key hereThe remote path claimed it at an hour, the transform paths at a year.
immutablepromises the body at this URL will never change — but writing to anexisting key is an ordinary operation, so an upload that replaced a file stayed
invisible until the window lapsed. Removed everywhere and replaced with cheap
revalidation.
The local path cached nothing at all
No headers, so every load of every image re-read the file and re-sent the body.
What replaces it
All four response paths (local/remote × plain/transformed) carry a weak
ETagand
Last-Modifiedand answer 304 toIf-None-Match/If-Modified-Since.public/prefix orpublicReadpublic, max-age=60, stale-while-revalidate=86400, must-revalidateprivate, max-age=60, must-revalidatemax-age=3600The local path takes its validators from a
statthat replaces theexistence-check
access— one syscall doing two jobs instead of two doing oneeach — and the 304 is decided before the file is read.
Validators are weak (size + mtime, not a digest), the same trade nginx makes for
static files: hashing every object on every request would cost more than it saves
for bytes already being streamed from elsewhere.
The proxying decision is untouched — signed-URL redirects still break on mixed
content and unreachable VPC endpoints. This only changes how well the proxied
response caches, which is what makes a CDN in front of it work.
Verification
cached copy, the public/private split, and RFC ordering (
If-None-Matchwinsover
If-Modified-Since)packages/server: 2153 passing, no regressionspnpm typecheckandverify:docscleandocumented that this contradicts
Not verified: behavior behind a real CDN. Header semantics are asserted, not
observed through Cloudflare.
Not included: range requests. Media seeking still fetches whole objects —
that is a separate change with its own streaming work.
Note on the diff size: cut from local
main, 17 commits ahead oforigin/mainand unpushed; those appear here until main is pushed.