Skip to content

Live schema editing: a nested project commits to its own paths - #23

Merged
fgatti675 merged 2 commits into
mainfrom
feat/live-schema-editing
Aug 23, 2026
Merged

fgatti675 merged 2 commits into
mainfrom
feat/live-schema-editing

Conversation

@fgatti675

Copy link
Copy Markdown
Member

Follow-up to #21, which is merged. Three things it left behind.

A project in a subdirectory wrote to the wrong place

DEFAULT_COMMIT_PATHS names the generated artifacts relative to the project
root, and the repository resolves them against its root. Those coincide only
when the project is the whole repository — a rebase init scaffold — so this
was invisible there and wrong everywhere else.

For a project in a subdirectory the commit created backend/ and drizzle/
beside .git, left the project's real generated files untouched, and committed
a source change alongside a stale schema. That is the failure committing the
whole change exists to prevent, arriving through the design itself.

The project root is now the nearest ancestor holding a rebase.json — already
how loadDeclaredStorageSources finds what a project declares, so there is one
answer to "where does this project start" rather than two that can disagree.

Verified against this repository, whose own app/ is the nested case: the
commit carries app/backend/src/schema.generated.ts and app/drizzle/*.sql,
and nothing lands at the root.

And two smaller ones

SchemaCommitPaths moves to @rebasepro/types — it is a contract, not an
engine detail, and @rebasepro/server has to derive it without importing a
driver.

The docs now say how the paths resolve, and that a project with no
rebase.json keeps the plain ones.

Still not done, deliberately

Rebase Cloud remains unwired, and the docs say so. It is not a config gap: the
AST editor rewrites a file on disk, and a bundle deployment has none, so the
cloud path needs fetch-from-GitHub → edit → commit-back. That is design work
rather than plumbing, and a half-wired version would look like it works.

`DEFAULT_COMMIT_PATHS` names the generated artifacts as
`backend/src/schema.generated.ts`, `drizzle/schema.sql` and so on, which is
correct read from the **project** root and wrong read from anywhere else. The
repository resolves what it is given against its own root, and those two
coincide only when the project is the whole repository.

A `rebase init` project is exactly that, so this was invisible. A project in a
subdirectory is not: the commit created `backend/` and `drizzle/` beside `.git`,
left the project's real generated files untouched, and committed a source change
alongside a stale schema — the failure that committing the whole change exists
to prevent, arriving through the design itself.

The project root is the nearest ancestor holding a `rebase.json`, which is
already how `loadDeclaredStorageSources` finds what a project declares. One
answer to "where does this project start", not two that can disagree. The walk
is bounded for the same reason that one is: from a misconfigured path an
unbounded walk climbs to the filesystem root and reads whatever it finds.

`commitPathsFor` returns `undefined` — not an identity prefix — when there is
nothing to correct: no marker, or a project that *is* the repository. Saying "no
change needed" rather than "a change that happens to be empty" is what leaves
every project that already worked on exactly the behaviour it had.

`SchemaCommitPaths` and its defaults move to `@rebasepro/types`. They are a
contract rather than an engine detail, and `@rebasepro/server` has to derive
them for a nested project without importing a driver to do it.

Verified against this repository, whose own `app/` is the nested case: the
commit now carries `app/backend/src/schema.generated.ts` and `app/drizzle/*.sql`
and nothing lands at the root.

Co-Authored-By: Claude Opus 5 <[email protected]>
Cloud is wired. So is any self-host serving a bundle.

The blocker was never authentication or the Git Data API — both have worked and
been tested for a while. It was that the AST editor rewrites a collection *file*,
opening it from a directory on disk, and a bundle ships compiled output. There
was nothing for it to open.

So the file is brought to it. `rewriteRemoteCollection` reads the current source
from the repository, puts it in a scratch directory shaped the way the editor
expects, lets the editor do exactly what it does locally, and reads the result
back. The editor is untouched, which is the point: it is the part that knows how
to keep a collection file's imports, comments and formatting, and a second
implementation of that for the remote case would be a second thing to get wrong.

Configured as `liveSchema.repository` — owner, repo, branch, where the source
lives, and either a token or a GitHub App installation. A token is for one
project committing to a repository its owner already has; standing up an App so
your own server can commit to your own repository is a great deal of ceremony
around a one-line credential. The App is for a control plane holding one key
across many projects, which is Cloud's shape: one App, an installation per
project, no per-customer secret to rotate.

Details that decide whether this is safe:

- The scratch directory holds one file and is removed on every path, including
  the failing one. It is a copy of the customer's source, and a server that
  accumulates those is a slow leak of the thing most worth not leaking.
- A repository that cannot read refuses rather than returning nothing. Treating
  "cannot read" as "empty file" would have the editor recreate the collection
  from the payload, and the commit would delete everything else in it.
- A file that is absent is a normal answer, not an error — a collection being
  created has no source yet, which is the same state the editor sees locally.
- A configured repository wins over a working tree that happens to exist beside
  the process: a deployment that names one is saying its source is *there*.

Verified against a real repository with no local source: creates a collection
that did not exist, rewrites one that did, and the rewritten file still carries
the comment that was above it.

Co-Authored-By: Claude Opus 5 <[email protected]>
@fgatti675
fgatti675 merged commit 2d1aec8 into main Aug 23, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant