Repository navigation
Design: live schema editing — commit, then apply - #14
Merged
Merged
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]>
Issue #5 has been the plan's blocking item because it needs a decision nobody should make at speed: where a collection definition lives once a project is deployed. Making the database authoritative was the obvious answer and it is the wrong one. `serializeCollections` already defines the serializable subset of a collection, and it drops the `admin` block wholesale and every function it walks past — callbacks, dynamicProps, conditions. So a database-backed collection is slug, table, properties, relations and securityRules, and a panel that can only edit that is a SQL editor with row-level security. BaaS mode already shows what that feels like. The design here keeps the repository authoritative and writes to it: the panel commits, then applies the DDL live. Immediate feedback, no second source of truth, and no ceiling — the panel is editing source, so editing an `admin` block or scaffolding a callback later is the same mechanism with a better editor in front of it. Two things the document exists to pin down. The order is load-bearing. Apply-then-commit leaves an orphan column in the database that the additive ensure will never drop and never mention. Commit-then-apply fails into "repository ahead of database", which is the ordinary state between an edit and a deploy and which boot already reconciles. The commit is the work. Not the collection file — also `schema.generated.ts`, a migration with a correctly minted `when`, and the regenerated policy/schema/search SQL, or a deploy against a fresh database produces something other than what was clicked. It also records a dependency that decides the timeline: a project's `gitRepoUrl` is metadata today. Deploys upload a source tarball, so nothing in the pipeline can write to that repository, and the credential path has to be built before any of this can be enabled in production.
…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.
5 of 7 tasks
The plan said "a self-hoster running a bundle has no repository" and moved on, which reads as though the no-repo case is the self-host case. It is not, and the ordering it implies is backwards. The line is whether the running server has the collection source on disk: - `rebase dev`, and a self-host with the project mounted, both have a working tree and a local git. The commit is a `git commit` with nothing to authenticate and nothing to fetch — this works there before any credential plumbing exists. - Cloud is the hard case, precisely because the repository is elsewhere: the tenant runs a bundle, the source arrived as a tarball, and GitHub is a third party that needs a token. So the credential gap decides when *Cloud* gets this, not when it works at all. The staging is re-cut to match: committing to a local working tree is now its own stage, ahead of live apply, and the remote write path is last and marked as the Cloud-only one. Everything above it ships without it. The bundle path stays immutable on purpose — `boot.ts` hard-codes `schemaEditor: false` and its comment is right, a bundle is compiled output. Which makes "run from source" the documented way for a self-hoster to get the editor, and that is now an open question rather than an assumption: today the self-hosting docs lead with the bundle.
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.
Design only — nothing built. For #5, the item that has been blocking the plan
because it needs a decision that shouldn't be made at speed.
The decision
Making the database authoritative was the obvious answer and it's wrong.
serializeCollectionsalready defines the serializable subset of a collection,and
withoutAdminBlockdrops theadminblock wholesale while the walk dropsevery function it passes —
callbacks,dynamicProps,conditions. Whatsurvives is slug, table, properties, relations,
securityRules. A panel that canonly edit that is a SQL editor with row-level security, and BaaS mode already
shows what it feels like: it works, and it's visibly thinner.
So: the repository stays the source of truth, and the panel writes to it.
Commit first, then apply the DDL live. Immediate feedback, one source of truth,
and no ceiling — the panel is editing source, so editing an
adminblock orscaffolding a callback later is the same mechanism with a richer editor.
It also produces something neither competitor has: a schema change with an
author and a diff, in the history of the project it changed.
Two things the document exists to pin down
The order is load-bearing, not taste. The failure directions aren't
symmetric. Apply-then-commit leaves a column in the database that the repository
doesn't describe — and the ensure path is strictly additive (every
DROP COLUMNin it is inside advice text), so the next deploy neither removes it nor mentions
it. Commit-then-apply fails into "repository ahead of database", which is the
ordinary state between an edit and a deploy and which boot already reconciles.
The commit is the work. Not the collection file — also
backend/src/schema.generated.ts(a stale one has broken every deploy before), amigration with a correctly minted
when(Drizzle skips out-of-order ones), andthe regenerated
policies.sql/schema.sql/search.sql. Row-level securityis migration-applied, so
securityRulesin the collection file alone iscosmetic. Without all of it, a deploy against a fresh database produces something
other than what was clicked.
The dependency that sets the timeline
A cloud project already carries a
gitRepoUrl— but it's metadata only.Deploys work by the CLI packaging a source tarball and uploading it, so nothing
in the pipeline can write to that repository. The credential path (GitHub App or
per-project token, stored in a
SecretStore, with scope and rotation) has toexist before any of this can be enabled in production. That gates the ship date
more than the DDL work does.
Suggested start
Stages 1 and 2 — classify a change as safe/unsafe, and generate the complete
commit as a set of file contents — have no dependency on the credential work and
carry most of the risk. Both are pure logic and fully testable: assert that a
fresh database built from the generated commit matches the schema the change
describes.
Open questions are listed at the end of the doc; the branch-per-environment one
in particular needs your answer.
Cut from local
main, 17 commits ahead oforigin/main; those appear in thediff until main is pushed.