Repository navigation
Live schema editing: a nested project commits to its own paths - #23
Merged
Merged
Conversation
`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]>
5 of 7 tasks
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]>
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.
Follow-up to #21, which is merged. Three things it left behind.
A project in a subdirectory wrote to the wrong place
DEFAULT_COMMIT_PATHSnames the generated artifacts relative to the projectroot, and the repository resolves them against its root. Those coincide only
when the project is the whole repository — a
rebase initscaffold — so thiswas invisible there and wrong everywhere else.
For a project in a subdirectory the commit created
backend/anddrizzle/beside
.git, left the project's real generated files untouched, and committeda 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— alreadyhow
loadDeclaredStorageSourcesfinds what a project declares, so there is oneanswer to "where does this project start" rather than two that can disagree.
Verified against this repository, whose own
app/is the nested case: thecommit carries
app/backend/src/schema.generated.tsandapp/drizzle/*.sql,and nothing lands at the root.
And two smaller ones
SchemaCommitPathsmoves to@rebasepro/types— it is a contract, not anengine detail, and
@rebasepro/serverhas to derive it without importing adriver.
The docs now say how the paths resolve, and that a project with no
rebase.jsonkeeps 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.