feat(sites): migrate - #209
Conversation
|
@codex review |
🦋 Changeset detectedLatest commit: cd75e41 The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Greptile SummaryThis PR adds a hidden migration command that converts router-era site state to the edge-rule architecture and cleans up the former middleware script.
Confidence Score: 3/5The PR is not yet safe to merge because migration can still modify a sibling pull zone sharing the same origin and can permanently delete a same-named replacement middleware script. The ownership check compares only the storage-zone ID, which is shared by valid sibling pull zones, while script cleanup treats the expected router name as sufficient identity even when the attached script ID differs from the legacy state. Files Needing Attention: packages/cli/src/commands/sites/api.ts
|
| Filename | Overview |
|---|---|
| packages/cli/src/commands/sites/api.ts | Adds legacy-state classification and the remote-resource migration sequence, including middleware cleanup. |
| packages/cli/src/commands/sites/migrate.ts | Defines the hidden migration command, confirmation flow, progress reporting, and completion output. |
| packages/cli/src/commands/sites/constants.ts | Adds the version-1 state schema, parser, and conversion into the current format. |
| packages/cli/src/commands/sites/api.test.ts | Adds migration tests covering state conversion, conflict handling, ownership mismatch, and script cleanup. |
| packages/cli/src/commands/sites/index.ts | Registers the hidden migration command in the sites namespace. |
Sequence Diagram
sequenceDiagram
participant CLI as sites migrate
participant Storage as Site state
participant Core as Core API
participant Compute as Compute API
CLI->>Storage: Read version-1 state
CLI->>Core: Fetch and validate pull zone
CLI->>Core: Detach middleware
CLI->>Core: Apply edge rules and cache settings
CLI->>Storage: Verify state and write version 2
CLI->>Compute: Fetch detached script
opt Expected router identity
CLI->>Compute: Delete router script
end
Reviews (4): Last reviewed commit: "fixes" | Re-trigger Greptile
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6d9685188b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| await applySiteCacheSettings(coreClient, state.pullZoneId); | ||
|
|
||
| step("Writing site state..."); | ||
| await writeRemoteState(connection, state); |
There was a problem hiding this comment.
Revalidate legacy state before replacing it
When a router-era deploy or publish runs after this command selects the site—especially while the user is answering the confirmation—this unconditional write uses the stale snapshot and overwrites the new deploy record and current/previous pointers. That can silently roll production back and lose deploy history; carry the raw state's hash/etag through selection and abort or merge if it changed before writing version 2.
Useful? React with 👍 / 👎.
| await applySiteCacheSettings(coreClient, state.pullZoneId); | ||
|
|
||
| step("Writing site state..."); | ||
| await writeRemoteState(connection, state); |
There was a problem hiding this comment.
Finalize state only after fallible migration steps
If promoteDeploy throws after this version-2 write—for example because hostname resolution, an edge-rule request, or a purge fails—the next sites migrate run classifies the zone as already migrated and refuses to resume. Script deletion was never reached, and its ID has already been removed from state, so the automatic cleanup cannot be retried; leave the legacy marker in place until the remaining steps finish or preserve resumable migration metadata.
Useful? React with 👍 / 👎.
Temp
migratecommand for earlysitesusers to use to migrate to routerless setup.