Repository navigation
Live schema editing: commit, then apply - #21
Merged
Merged
Conversation
Member
Author
|
The "not verified" caveat is now closed. Added an end-to-end that runs the whole chain against a real Postgres container and a real git repository — plan through the real driver, commit with real git, apply real DDL, then ask both whether it happened. Five cases, and the fixture table starts with a row in it so the NOT NULL question is real rather than theoretical:
Remaining gap is unchanged and stated in the PR body: the panel UI. This is the API and the machinery, now proven against real infrastructure. |
`POST /api/functions/deploy/cancel` used to have one outcome: a build was
stopped, or 404. It now has two. A project's `status` column can claim
`deploying` while no deployment row backs the claim — the state
`prospector` was wedged in for five days, Redeploy greyed out with no way
to clear it — and cancelling is what clears it. The control plane
reconciles and answers `{ success: true, deploymentId: null, unstranded:
true, projectStatus }` instead of refusing.
`cancelCommand` printed `Cancelled deployment ${res.deploymentId}`
unconditionally, so the request that had just un-wedged the project
reported "Cancelled deployment null".
`cancelView` is split out of the command because the branch is worth
testing and the command is not reachable without a client — the same
shape as `deploymentView` beside it. It branches on the ABSENT ID rather
than on `unstranded`: the flag is the server being explicit and it is the
newer half of the contract, while a missing id means there was no
deployment whatever else the response carries, so a CLI meeting a control
plane that grew the behaviour without the flag still says something true.
The JSON view carries `unstranded` and `projectStatus` through, since a
piped run is what scripts read (`rebase cloud` returns JSON off-TTY) and
"did this cancel a build or clear a stuck flag?" is exactly the question
a script needs answered.
Co-Authored-By: Claude Opus 5 <[email protected]>
The first four stages of #5, as pure logic plus one real git adapter. No routes yet; nothing is reachable from outside the package. **Classify.** The editor may only make changes the boot-time ensure path can carry out, and its vocabulary is small: create a table, add a column, create an enum type, create an index, add a foreign key. No ALTER COLUMN TYPE, no DROP. That gives three verdicts rather than two, and the middle one is the point. `diverges` is a change the ensure path *partly* applies, leaving a database that does not match its configuration and saying nothing: - a required property added to an existing collection arrives nullable, because NOT NULL is withheld on a table that already has rows; - a value added to an existing enum never lands, because an enum type already present is skipped entirely; - relaxing a required property leaves the old NOT NULL in place. All three read as "applied successfully" today. Reporting them as safe would be worse than refusing them. **Generate.** The commit is not a file. It carries `schema.generated.ts`, `schema.sql`, `policies.sql` and `search.sql`, because a stale generated schema has broken every deploy at least once. The migration statements come from a plain difference between two ensure plans — `plan(after) − plan(before)` — which needs no Atlas, no dev database and no diff engine. That works precisely because the classifier already refused everything non-additive. The round trip is asserted across six shapes and mutation-checked: dropping one statement fails eight tests. **Apply.** Commit first, then run the DDL. The failure directions are not symmetric — apply-first leaves an orphan column the additive ensure will never drop and never mention, while commit-first leaves the repository ahead of the database, which is the ordinary state between an edit and a deploy and which boot reconciles. So a failed apply is a *result*, not an error: committed, and it will land on the next boot. **Git.** Real adapter, tested against real git in a temp repository rather than against a mock of my idea of git. It stages the exact paths and never `add -A`: a schema commit that sweeps up somebody's half-finished edit is a commit nobody can review, and there is a test asserting their staged work survives untouched. It refuses a detached HEAD, refuses to write outside the tree, and treats regenerating an unchanged schema as the non-event it is. 131 suites, 2224 tests.
Wires the planner, the commit generator and the git adapter into two routes, and puts the engine-specific half behind a capability so the pieces sit on the right side of the line. **The capability.** `@rebasepro/server` has no database driver, deliberately, so it cannot import the Postgres planner — and the Postgres package cannot import the server's routes. The shared vocabulary now lives in `@rebasepro/types` (`SchemaChangePlan`, the verdicts, the file shape) and the driver exposes `planSchemaChange` on its admin, detected structurally by `isSchemaEditingAdmin` exactly as SQL already is. Planning is engine-specific; committing and serving are not. **Two routes, and `/plan` is the important one.** It has no side effects and answers what would happen. A schema change has three verdicts and two of them are refusals, so a UI that could only try-and-see would be asking people to discover `needs-migration` by pressing a button on a live database. It also surfaces the `diverges` cases, which nothing else in the system reports. **Ordering, twice over.** `/apply` plans and refuses *before* `writeSource` touches anything: the AST editor writes to disk outside the repository's own checks, so a rejected change would otherwise leave a rewritten collection file behind while reporting that nothing happened. Then commit, then DDL — a failed apply is a result, not an error, because the durable half landed. **Mounted on whether a repository exists, not on NODE_ENV.** That is the whole difference from the editor it sits beside: that one is off in production because a deploy overwrites its edits, and this one survives a deploy precisely because the deploy is built from what it committed. A bundle deployment has compiled output and no source, and answers a refusal that says so rather than 404ing. Behind the admin gate, and the commit is attributed to whoever pressed the button — a schema change with an author and a diff in the project's history is the part neither competitor offers. server 178 suites / 2754 tests, server-postgres 129 / 2199, api-surface, deps, headless, core-types and unused all clean.
…no source The local implementation commits with `git`, which needs the working tree on the same machine. A Cloud tenant runs a built bundle and its repository lives somewhere else, so this one has no working tree at all: the Git Data API creates a blob, a tree, a commit and moves a ref in four calls, and nothing is cloned. A GitHub App rather than a token per project. One private key held globally; each project stores an `installationId`, which is not a secret. A per-project personal access token would be a credential to hold, rotate and leak for every customer. Two decisions make this safe to run against somebody's repository, and both are asserted rather than assumed: - **`base_tree`.** A tree built without it commits a repository containing only the files in the request — everything else appears deleted, in a commit that looks like a schema change. - **`force: false`.** The commit is parented on the head read at the start, and the ref update is never forced. If anything landed meanwhile GitHub rejects it, which is the correct outcome: silently discarding somebody's commit is worse than failing. The app JWT backdates `iat` by a minute. GitHub rejects a token whose `iat` is in its own future, and a server clock a few seconds fast is enough to trigger it — a failure that appears in production and nowhere else. There is a test for exactly that. Installation tokens are cached until shortly before they lapse, because minting one is a round trip and a single edit makes eight calls. Also documents the feature: the three verdicts, what a `diverges` change does, what lands in the commit, why the order is commit-then-apply, and the deployment table — the line is whether the server has source on disk, not whether it is production.
…epository Everything else about this feature is asserted at the unit level — the classifier over collection shapes, the commit generator over file contents, the ordering over fakes. All of that can be true while the feature does not work, because the two things it actually has to do are put a column in a database and a commit in a repository, and a fake cannot prove either. This runs the whole chain: plan through the real Postgres driver, commit with real git, apply real DDL, then ask both of them whether it happened. Five cases, and the table starts with a row in it so the NOT NULL question is real rather than theoretical: - an added property lands as a column, the commit carries `schema.generated.ts` and `drizzle/schema.sql` as well as the collection, the author is the panel user, and the existing row survives untouched; - a *required* property added to that populated table is refused, and the refusal is verified to leave neither a column nor a commit — this is the `diverges` case the whole three-verdict design exists for; - dropping a column is refused and the data is still there afterwards; - a brand-new table takes its constraints, `NOT NULL` included, because a fresh table has no rows for the constraint to be checked against — the same declaration behaves differently depending on what it lands on, which is the thing that is hard to believe until a database says it; - with the apply forced to fail, the commit is still in git and the column is still absent. That is the ordering working: the repository ends up ahead of the database, which is where every project sits between an edit and a deploy.
Two calls mirroring the routes — ask what a change would do, then do it — kept separate here as well as on the server, because a UI that could only try-and-see would be asking somebody to discover that their change is refused by pressing a button on a live database. Its real job is keeping three unhappy outcomes distinguishable, and the tests are mostly about that: - the change is **refused**, and the user needs the explanation and the remedy; - the feature is **unavailable** — a Mongo backend, or a bundle deployment with no source. Nothing about the change is wrong; - the request **broke**. Collapsing the second into the first tells somebody their perfectly good change was rejected. Collapsing the first into the second hides the explanation they need. `asUnavailable` is the discriminator and it deliberately returns nothing for an ordinary refusal. **Not wired into the editor's save path, on purpose.** Some of those saves post *partial* payloads — `saveProperty` follows up with a one-key `collection/save` carrying `partial: true`. Live editing needs the whole collection, because it computes the proposed state by replacing one collection in the set: handed a partial it would read every unmentioned property as a removal and refuse the change. Reconciling that is a UI change with a confirmation step in it, not a substitution, so the existing path is untouched until there is somewhere to show the verdict.
A required property arrived nullable, a new enum value never reached the database, and relaxing `required` left the old NOT NULL in place. All three read as success, and the only evidence was a database that disagreed with its own configuration. The ensure path now carries out what it can and reports what it cannot: - `ALTER TYPE … ADD VALUE IF NOT EXISTS` for a value missing from an existing type. Purely additive, so this runs at boot too — its absence was an outright bug, not a conservative choice. - NOT NULL on a new required column when it cannot fail: a table being created, a table with no rows, or a column arriving with a DEFAULT that backfills. - `withheldConstraints` on the plan for every constraint that is asked for and not applied, which boot logs at warn. Withheld is no longer the same as unmentioned. Tightening or dropping an existing column's NOT NULL happens only under `constraints: "converge"`, which the live editor passes and the unattended boot does not. A database adopted by introspection carries NOT NULL on columns the generated collection deliberately leaves optional — `introspect-db-logic` withholds `required` from a column with a default or a trigger behind it — so converging at boot would strip constraints nobody edited. `readExistingSchema` gathers the three facts this needs: enum values in `enumsortorder`, column nullability, and which tables hold rows. The last is an `EXISTS … LIMIT 1` per table rather than `reltuples`, because a planner estimate is -1 on a table that was never analyzed and stale after a DELETE, and a wrong "empty" here is a boot that aborts on a constraint violation. `additiveStatements` now plans both sides against the real database instead of against an empty one. Planned against nothing, every table reads as one being created, and a new required property came out as `ADD COLUMN … NOT NULL` — correct for a fresh table, rejected by a live one holding rows. Those statements would have been generated, committed, and then refused by the database they were written for. Co-Authored-By: Claude Opus 5 <[email protected]>
`planSchemaChange` reads the live catalogue before it plans. Whether a NOT NULL can be added is a question about rows and whether an enum value will land is a question about the type — neither is answerable from the collections, and both decide whether the statements the plan returns are accepted or rejected. The plan carries `withheldConstraints` so the answer travels with it: a change can be applicable and still leave something the configuration asks for unenforced, and that is the sentence the person confirming needs to read. Co-Authored-By: Claude Opus 5 <[email protected]>
The API grew one feature at a time and ended up with three ideas about where an
admin route lives. `/api/cron`, `/api/logs` and `/api/schema-editor` were
admin-gated but sat at the top level, beside the data plane; `/api/admin/backups`
and `/api/admin/rls-audit` were not. The shape of a path had stopped predicting
whether a caller needed to be an admin, and the only way to find out was to read
`init.ts`.
All three move under `/api/admin`, and live schema editing lands at
`/api/admin/schema` rather than `/api/schema`. `mountWithLegacyAlias` keeps the
shipped paths serving the same router — one set of handlers and one gate, so an
alias that forgot to apply the gate is not a state this can reach — with a
`Deprecation` header and a `Link` naming the successor, which is what makes the
old path removable at a major.
An alias rather than a 308: `fetch` follows redirects but drops `Authorization`
on a cross-origin hop, and much of the client code posts to these paths with one
attached.
Two consequences worth naming:
- The schema editor becomes a *sibling* of live schema editing, not a child.
Nested under `/admin/schema`, its requests would first meet the live editor's
`use("/*")` gate — harmless while that gate calls `next()`, and a silent
hijack the moment it does not, since with no auth configured it answers 501
itself and this surface's callers would get a refusal describing the wrong one.
- Live schema editing now mounts even without a `collectionsDir`, to refuse in
its own words. Under `/api/admin` an unmounted path is caught by the gate in
front of it, so an operator who forgot the setting would have been told 401
and gone to check their token.
`docs/api-conventions.md` states the rules and audits every mounted route
against them, including the drift left deliberately unfixed.
Co-Authored-By: Claude Opus 5 <[email protected]>
Wires live schema editing into the editor's save path. A save now asks the backend what the change would do, shows it, and does nothing until somebody agrees: the verdict in a sentence, then each change with its remedy, then the constraints the change asks for and will not get, with the SQL and the file list collapsed underneath as evidence rather than summary. `reviewChange` returns a promise that rejects on cancel. A save that was cancelled must not leave the form believing it succeeded — the collection on screen would then differ from the one on disk, and the *next* save would be computed from the wrong `before`. Three things this had to not break: - A backend that cannot edit its schema — a bundle deployment, a non-Postgres driver, a version too old to have the endpoint — falls straight through to the source-only editor. `status` is asked once, and every way of failing to get an answer means the same thing to a caller deciding whether to offer the control. - The editor's own saves post partials, and live editing needs the whole collection: handed a patch it reads every unmentioned property as a removal. The controller assembles the whole collection before planning, next to the collections it needs to read. - Removing a property can never be applied, because the ensure path has no `DROP COLUMN`. Refusing the save outright would mean a dev could no longer delete a field from a collection they are designing, so a refused change offers "Edit source only" — exactly what the editor did before this existed, except that it now says what it leaves behind instead of reporting success. The dialog renders from `ConfigControllerProvider`, via an optional `dialog` on the controller: a controller that has to ask before it writes needs somewhere to ask, and a hook cannot render. Co-Authored-By: Claude Opus 5 <[email protected]>
… an author The admin gate in front of the live schema routes answers one question — is this an admin — and applying a schema change asks two. It alters the database, and it writes a commit into the project's repository under somebody's name. `admin-roles.ts` already said where this belongs: `schema-admin` is administrative "by any definition that matters", and "if a genuinely lesser role is added later, it does not belong in this list — it belongs in a capability check of its own." This is that check. The split is not between roles, it is between a person and a machine: - `plan` has no side effects, and a CI job asking whether a proposed collection change is applicable is a good use of this API. Anyone through the admin gate may do it. - `apply` commits, and the commit carries an author. That is the stated point of the feature — a schema change with an author and a diff in the project's history is the thing worth having, and an anonymous one is just a commit. The service key has no author. `api-key:7c3f…` has no author. Letting either write to the project's source produces exactly the unattributable history this replaces, using the credential most likely to be sitting in a CI environment variable. So machines plan and do not apply. `liveSchema.allowMachineApply` turns it on deliberately, and the commit is then attributed to the credential by name — `Rebase API key (7c3f)` — so `git log` still distinguishes a change somebody made from one a pipeline made. Machines are detected by uid, not by role: `service` is a role a person could be granted, and losing the ability to commit under your own name because of an unfortunate role name would be a strange rule. `/status` reports the caller's capabilities rather than only the server's, and the panel greys out the button and says why. Being refused at the moment of pressing is the worst time to learn it — the plan has already been read and the decision already made. `/plan` re-checks too, though the gate has run and previewing writes nothing: a capability function that trusts its caller to have checked is one refactor away from granting everything. The route harness now sets a user, because production always has one. A harness that left it undefined was exercising a request that cannot happen, and would have hidden the fact that these routes now refuse a credential the gate admits. Co-Authored-By: Claude Opus 5 <[email protected]>
…pply Co-Authored-By: Claude Opus 5 <[email protected]>
Two suites boot a whole backend per test and ran on jest's default 5s, which is not a timeout for that — it is a coin flip. Alone they passed; under `--runInBand` they passed; in a full parallel run they failed at random, because a boot that takes under a second on its own takes several while a dozen others are booting beside it. The symptom reads as a flaky feature, which is the expensive part: a gate that is wrong often enough gets ignored, and then it is not a gate. Naming the real cost is the fix. Verified the constant is actually wired rather than decorative — the first attempt produced `}), BOOTS_A_BACKEND;`, a comma expression that evaluates the number and throws it away, leaving every test on the default. Setting it to 1ms now fails every test in the suite with "Exceeded timeout of 1 ms", which is what proves it reaches jest at all. Co-Authored-By: Claude Opus 5 <[email protected]>
The `useMemo` in `useLocalCollectionsConfigController` closes over four helpers that are rebuilt every render, so listing them would defeat the memo. Each is covered transitively by what *is* listed, and the disable comment says which by which — the gate asks for a reason, not a silencer. The directive has to be the last comment line before the dependency array. Written first in a block of continuation lines, it applies to the next comment rather than to the code, and the finding stayed. Baseline banked at 178: the file had a pre-existing finding that this replaces. Co-Authored-By: Claude Opus 5 <[email protected]>
fgatti675
force-pushed
the
feat/live-schema-editing
branch
from
August 23, 2026 01:15
24dc642 to
9468615
Compare
`write()` read `liveSchema.status`, which is undefined for one round trip after mount. A save issued in that window took the source-only branch with no confirmation; the same save a second later opened a dialog. Nothing on screen distinguished them, and which one you got depended on how fast you clicked. The hook now exposes `ready()` — the probe as a promise, resolved once and shared, so awaiting it costs at most the round trip that was already in flight. `status` stays for rendering, where "not answered yet" is a real state worth showing. The regression guard is at the controller, not at the hook: reverting `write()` left every test in `live-schema-editing-flow.test.tsx` passing, because those exercise the flow once it is entered and this is about whether it is entered at all. `live-schema-controller-wiring.test.tsx` holds the status probe open, saves, and asserts that nothing has been written and nothing has resolved — which fails against the reverted version. Also regenerates the API surface baseline for the `liveSchema` config key. That gate reads `packages/server/dist/index.d.ts`, so it passes locally against a stale build and only tells the truth in CI. Co-Authored-By: Claude Opus 5 <[email protected]>
Introduced with `ready()` and missed because the local typecheck ran before it. Caught by CI, which is the gate that reads the whole workspace. Also folds the duplicate plan in `generateSchemaCommit`: the withheld constraints needed the `after` plan, and `additiveStatements` computed it a second time. The planner is pure, so it was wasted work rather than a correctness problem — but this runs on every keystroke in the panel. Co-Authored-By: Claude Opus 5 <[email protected]>
…e login The eager JavaScript budget caught it: `index` grew 227 kB → 241 kB, over the 238 kB ceiling. The eager set is everything downloaded before the login screen paints, and 14 kB of it had become a dialog that only opens when somebody edits a collection. The cause was a static import. `useLiveSchemaEditing` is reached from the collections config controller, which is constructed on every admin boot, so importing `SchemaChangeDialog` at the top pulled it and the `@rebasepro/ui` surface it draws on into the entry chunk. Now `lazyChunk`, with no Suspense boundary mounted until there is something to review — the same shape as `CollectionEditorDialogs` beside it. The chunk is fetched by the first `reviewChange`; a session that never edits a collection never pays for it. Also drops `SchemaChangeDialog` from the package barrel. Re-exporting it there puts it straight back in the eager bundle and quietly undoes the lazy import, which is why neither `CollectionEditorDialog` nor `PropertyFormDialog` is exported either. Banking the growth with `--update` was the other option and the wrong one: the budget is doing exactly what it exists for. Co-Authored-By: Claude Opus 5 <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
`/apply` could never succeed. It called `writeSource` — which rewrites the collection file through the filesystem — and only then ran `applySchemaChange`, whose first act is to refuse when the working tree is dirty. By that point the tree was dirty *because of this change*: `git status --porcelain` reports untracked files too, so a new collection's source file always counted, and an existing collection's always showed as modified. Every change came back 409 `SCHEMA_EDIT_DIRTY_TREE`, and the rewritten file was left behind, so the retry found a dirty tree as well. The module's own comment describes exactly this hazard and guards the *applicability* check against it. The dirty check sat on the other side of the write. `writeSource` is now called from inside `applySchemaChange`, after the check and before the commit, and the caller supplies `sourcePaths` — the paths it is about to touch, derivable without touching them — so those still take part in the check. Somebody else's half-finished edit to the same file is refused exactly as before; only the change's own edit stops counting against it. Found by driving the real editor in a browser against a real Postgres and a real repository. Every existing test missed it because they hand `applySchemaChange` files that are already written, which is the one shape that cannot reproduce it. The new tests model what `git status` actually does — clean before the write, dirty after — and all three fail against the old ordering. The e2e spec is updated for the flow it now describes: saving plans the change and waits for a confirmation. It races the dialog against a direct navigation so it still passes against a backend that cannot edit its own schema. Co-Authored-By: Claude Opus 5 <[email protected]>
…s used `writeSource` was a function that existed and threw when the AST editor was unavailable. `/status` can only see whether the field is *set*, so it answered `enabled: true`, the panel offered the control, and `/apply` came back 500 the moment somebody confirmed — after they had read a plan and agreed to it. It is now absent in that case. The same fact, stated where both surfaces can read it: `/status` reports `SCHEMA_EDITOR_MISSING_DEPENDENCY`, the panel falls through to the source-only editor, and a caller that asks anyway is refused by name. And anything else that fails between the dirty check and the commit — a file the AST editor cannot parse, a commit git refuses, a path outside the repository — is now a 400 `SCHEMA_CHANGE_FAILED` carrying the underlying message, rather than a 500. It is a refusal of this change, not a broken server, and the message is the useful part. The dirty-tree and unapplicable cases keep their own codes. Co-Authored-By: Claude Opus 5 <[email protected]>
The listener threw the status and discarded the body. "returned status 500" is
indistinguishable between a missing dependency, a refused commit and a real
crash — and the server's own log is not always in the CI artifact to fall back
on, which is exactly the position this left me in.
This server answers `{error:{code,message}}` on every refusal, and the message
is written for whoever has to act on it. Now it reaches the failure.
The handler cannot be async — Playwright does not await it — so the body is read
separately and thrown from there.
Co-Authored-By: Claude Opus 5 <[email protected]>
Two halves of the same mistake, both found by driving the editor in a browser. **The e2e was committing into this repo.** `rebase dev` serves the app from `app/`, so `findRepositoryRoot` resolves to the checkout itself — meaning a developer running `pnpm e2e` locally got generated files committed onto their current branch, at the repository root rather than under `app/`. The spec now stops at the preview and cancels. The apply half is covered where it can be done safely: `live-schema-editing-e2e.test.ts` drives it against a real Postgres and a repository it creates under `mkdtemp`. That is a smaller test, deliberately. It still asserts the part only a browser can: that the wizard builds a collection, that the review opens, and that it names what it would do — the verdict, the SQL, the files. **Cancelling reported itself as a failure.** A save has to reject when it is cancelled, or the form goes on believing it saved. But the collection editor caught every rejection the same way, so the person's own choice came back as a console error and a red snackbar: "Error persisting collection: The schema change was not applied." It also meant the e2e's console listener would fail the test on a cancellation, which is how this surfaced. `isSchemaChangeCancelled` lives in `liveSchemaClient` — no React, so the dialog can import it without pulling a hook in — and matches on `name` rather than `instanceof`, which answers false the moment two copies of the package share a bundle. Verified in a browser: the dialog opens with all three disclosures, cancelling closes it, only `plan` is called, the URL does not move, no commit is made, and the console stays clean. Co-Authored-By: Claude Opus 5 <[email protected]>
A sweep of the feature, and each of these is the same shape as the bug it was built to prevent: a report that disagrees with what happened. **Escape closed the dialog mid-apply.** `onOpenChange` reaches `onClose`, and of the three ways to dismiss — button, Escape, backdrop — only the button was disabled while applying. Pressing Escape rejected the caller as *cancelled* while the commit and the DDL carried on. Somebody would be told nothing happened, while something did, which is precisely what this feature exists to end. **A second review abandoned the first.** `setPending` overwrote `resolve` and `reject` with nobody left holding them, so a double-clicked save left its first promise unsettled forever and the editor's save never returned. The replaced review is now rejected as cancelled, which is what it is. **A late plan described the wrong change.** The response was applied to whatever review was open when it landed, so a slow plan for change A could render into the dialog for change B — the reader confirming SQL for something they were not looking at. Responses now carry the review they belong to and stale ones are dropped. **And the collection id is checked where it enters.** It becomes a filename, `<collectionsDir>/<id>.ts`, derived in two places: the AST editor sanitises before writing, and the caller derives the same path *first*, to tell the dirty-tree check what is about to be touched. Only the editor checked. A refusal arriving one layer in is a refusal the layer above has already acted on. Both UI fixes are mutation-tested. The first attempt at the Escape test asserted that the Cancel button was disabled — which is true, and not the bug: Escape does not go through the button. It presses Escape now, and fails without the guard. Also corrects the docs: Rebase Cloud is listed as working "with a connected repository", and nothing connects one. `createGitHubRepository` is constructed only in tests — `init.ts` returns the local git backend unconditionally and `saas/backend` has no reference to it. A Cloud tenant gets the same `SCHEMA_EDITING_NO_REPOSITORY` refusal as any bundle. The backend is written and tested; the plumbing is not, and the docs now say so. Co-Authored-By: Claude Opus 5 <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
The gate failed on one chunk: `useCollectionsConfigController`, 261 B → 1,811 B.
That is this feature's eager cost and it is deliberate — the controller now has
to decide, on every save, whether the backend can review a schema change. The
hook runs during render so it cannot be lazy; what is heavy, the dialog, already
is, and stays a separate 6 kB chunk fetched on first use.
`--update` rebaselines every chunk, so this also absorbs growth that is **not
from this branch**. Saying so rather than letting it read as the feature's:
rebase-core 1925 → 1950 kB (+25 kB)
form 377 → 384 kB (+6.8 kB)
index 232 → 239 kB (+7.3 kB — this one is ours)
The baseline was last banked on 2026-08-09, before 0.16.0 and before a deprecated-
alias removal, an auth refactor and an i18n cleanup all landed in `packages/app`,
`packages/forms` and `packages/ui`. Each of those stayed inside the 5% headroom
individually, so nothing failed and nothing was banked, and the drift accumulated
quietly for two weeks. That is the ratchet's blind spot: it catches a step, not a
slope.
`index` is 234 kB against a 238 kB budget, so the entry chunk still has room.
Co-Authored-By: Claude Opus 5 <[email protected]>
This was referenced Aug 23, 2026
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.
Implements #5, along the design in
docs/live-schema-editing-plan-2026-08.md.The schema editor rewrites collection source and is off in production, for an
honest reason: a deployed server's files are rebuilt from the repository on
every deploy, so an edit there is discarded. This commits the change to the
repository, then applies the DDL — so the edit survives the next deploy,
because the deploy is built from it.
Three verdicts, and the middle one is the point
The editor may only make changes the boot-time ensure path can carry out, and
that vocabulary is small: create a table, add a column, create an enum type, add
an index or a foreign key. No
ALTER COLUMN TYPE, noDROP.That gives three answers rather than two.
divergesis a change the ensurepath partly applies, leaving a database that does not match its configuration
and saying nothing:
NOT NULLis withheld on a table that already has rows;present is skipped entirely, and the first row using it is rejected;
NOT NULLin place.All three read as "applied successfully" today. Reporting them as safe would be
worse than refusing them, which is why
/planexists separately: two of threeverdicts are refusals, and a try-and-see UI would make people discover
needs-migrationby pressing a button on a live database.The migration needs no Atlas
Because the classifier already refused everything non-additive, the DDL is a
plain difference between two ensure plans —
plan(after) − plan(before). Nodiff engine, no dev database, no binary. The round trip (
before ∪ delta === after) is asserted across six shapes and mutation-checked: dropping onestatement fails eight tests.
Ordering, twice
/applyplans and refuses beforewriteSourcetouches anything, because theAST editor writes to disk outside the repository's checks — otherwise a rejected
change leaves a rewritten collection file behind while reporting that nothing
happened.
Then commit, then DDL. Apply-first would leave a column the repository does not
describe, which the additive ensure will never drop and never mention.
Commit-first leaves the repository ahead of the database — the ordinary state
between an edit and a deploy. So a failed apply is a result, not an error.
Where it works
The line is whether the server has source on disk, not whether it is
production:
rebase devTwo safety properties, both tested: it stages only its own files and refuses
outright if the tree already has one of them modified (there is a test asserting
somebody's staged work survives untouched); and the remote path never
force-updates a ref, so a lost race refuses instead of discarding a commit.
Architecture note
@rebasepro/serverhas no database driver and cannot import the Postgresplanner. The shared vocabulary now lives in
@rebasepro/typesand the driverexposes
planSchemaChangeon its admin, detected byisSchemaEditingAdminexactly as SQL already is. Planning is engine-specific; committing and serving
are not.
Verification
repository rather than a mock; the GitHub path is tested at the protocol level
(call order,
base_tree,force: false, the backdated JWTiat).packages/server179 suites / 2770 tests;packages/server-postgres129 / 2199derived-names, runtime-image and verify:docs all clean
Not verified: an end-to-end edit against a live Postgres and a real GitHub
repository. Everything is asserted at the unit and protocol level.
Not included: the panel UI. This is the API and the machinery; the
/plan-then-confirm flow in the admin is the next piece. Also no migration fileis written — a boot-ensure project needs none, and a migration-provisioned one
should run
rebase db generate, which mints the Atlas integrity hash that onlyAtlas can produce.