Repository navigation
Commit ae0d686
fork: CI check that refuses database schema and migration changes (#3)
* fork: CI check that refuses database schema and migration changes
T3 has no down-migrations, so a fork patch that changes the schema would
strand every install that later returns to upstream. fork-checks.yml runs
on every pull request and fails when the change touches the migration files
or adds a schema statement to shipped source. The follow workflow runs the
same script over the whole patch series.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
* fork: schema check runs from the base branch and reads whole files
Review round 1 of the schema check:
- The workflow runs on pull_request_target, so its file and the check script
come from the default branch; a pull request can no longer weaken, skip or
delete the check that judges it. The pull request's commits are only fetched
and read as blobs, never checked out or run.
- Changes to the check's own files or to any .gitattributes are refused once
the base has the check; only the owner can merge such a change.
- Files the migrations import (transitively, computed from both trees) count
as schema files, and a shipped file whose text holds a schema statement
before or after the change is refused; statements match across lines.
- Paths come from `git diff --raw -z` and texts from the blobs, so quoted
non-ASCII paths and .gitattributes cannot hide a change.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
* fork: schema check judges its own files against the base's copy
- A check file or .gitattributes that the branch carries unchanged from
the base passes. After main is rebased onto a new upstream release, a
branch from the old main is told to rebase onto main (its commits are
matched on main by author, author time and subject), never to merge
past the red check.
- Package root imports (@t3tools/contracts) are followed to the files
that declare the imported names, so migration 064's schemas in
threadPullRequest.ts are covered while the rest of the package is not.
- Schema statements also match across SQL comments and string joins, and
with upper-case keywords around an interpolation (CREATE ${kind}).
- parseRawDiff throws on output it cannot read; actions/checkout is
pinned by commit SHA.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
* fork: schema check guards re-exporting barrels and fails closed on untraced names
A name imported from a package root that no file is seen to declare now
guards the whole barrel and everything it re-exports, instead of dropping
out of the guarded set. The tracer also knows export async function, a local
export { type X }, export { default as X } from, and destructured exports.
The barrels on the way to a declaring file are guarded too, so a barrel-only
edit cannot re-point a name a migration imports.
On a branch holding commits already on main, a real edit to a check file is
reported as one, and the message no longer assumes main was rebased.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
* fork: schema check guards package.json and refuses imports it cannot resolve
- The package.json of every workspace package that schema code imports is
guarded, so an edit that re-points such an import (another export target,
a condition Node picks first, exports removed in favour of main) is
refused. Every file any export condition can pick is guarded, and main,
module and types are followed when a package has no exports.
- An import that should resolve inside the repository but does not is
refused, naming the import: a workspace package with no entry file, a
relative import of a missing file, a #name import, a computed import()
or require(), import.meta.glob. Only packages outside the workspace
resolve to nothing; the output lists them.
- Workspace packages come from the pnpm workspace list (scoped or not, at
any depth), and a change to that list is refused. A test-path file that
schema code imports is guarded like any other.
- The tracer no longer counts the key in `export const { S: renamed }` as
declaring S.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
* fork: schema check guards the importer's dependency specs and judges only new unfollowable imports
- The dependency specs of every name schema code imports (workspace packages and outside names
such as effect) are compared in the package.json files of the packages holding schema code and
the root one, plus pnpm-workspace.yaml catalog/catalogs/overrides/patchedDependencies and the
root pnpm.overrides/patchedDependencies/resolutions. Patch files of those names are guarded.
Other dependency changes stay free.
- A package.json is judged by the fields that map the imports schema code makes through it
(name, type, main/module/types/browser, imports, the export entries answering those keys), so
adding a module to a package stays free.
- An import the check cannot follow is refused only when the branch brings it; ones already on
the merge-base are listed, not refused. Imports are read from code with comments and string
contents blanked, so prose like "require (in order)" is not an import.
- Tests: the browser fallback, the four importer-side probes and more, manifest field judging,
the lexer and the merge-base rule.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---------
Co-authored-by: t3code-fork <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>1 parent 82bebcb commit ae0d686
3 files changed
Lines changed: 2211 additions & 0 deletions
0 commit comments