Repository navigation
Let a given pull selection replace an interrupted one - #6167
Merged
Merged
Conversation
1 task done
chubes4
marked this pull request as ready for review
November 24, 2026 02:10
1 task done
chubes4
added a commit
that referenced
this pull request
Nov 30, 2026
## Related issues - Part of the Reprint pull rollout (removing `STUDIO_ENABLE_PULL_REPRINT`). Follows #6163–#6167. ## How AI was used in this PR Claude Opus 5.5 (Claude Code), running as Franklin, Chris's agent, found this while stress-testing Reprint pull on real WordPress.com sites, then wrote the fix and tests and ran the reproduction below. Chris reviews before merge. ## Proposed Changes - Two local sites pulling the same WordPress.com site at the same time failed with `AUTH_UNKNOWN_KEY` (HTTP 403). Studio generated a Reprint key per local site, and Jetpack keeps one key per site (Automattic/jetpack#53537: "Installing a key replaces the previous one"). The second pull installed its key over the first one's, and the first pull's next request was refused. - Studio now signs every Reprint pull with one key per machine, `~/.studio/reprint-key.pem`, passed to `preflight`, `pull-files` and `pull-db` as `--private-key-path`. Every local site on the machine installs the same key, so they no longer replace each other's. - The key is generated in Node (RSA 3072, the same as `reprint keygen`) on first use. It is written to a temporary file and hard-linked into place, so pulls that start at the same time end up with the same key. This also removes the `pull-metadata` and `keygen` Reprint calls from the start of each pull. - Keys in existing per-site state directories are no longer used. `--private-key-path` takes precedence over them, and the next pull installs the machine key. - Pulling one site from two different machines still conflicts, because Jetpack keeps one key per site. That limit was a deliberate Jetpack decision and is out of scope here. ## Testing Instructions With `STUDIO_ENABLE_PULL_REPRINT=1`, start two pulls of the same remote into two different local sites, about two seconds apart: ``` studio pull --path <site-a> --remote-site <id> --options all & studio pull --path <site-b> --remote-site <id> --options all & ``` - On trunk (macOS, a preview site): the first pull succeeds and the second fails at `files-pull` with `AUTH_UNKNOWN_KEY`. - With this change: both pulls succeed, in two runs out of two. The first run started with no `~/.studio/reprint-key.pem`. Afterwards there is a single key file with mode `0600`. Unit tests: `npx vitest run apps/cli/lib/pull apps/cli/commands/tests/pull.test.ts`. The new test checks that three pulls starting together get one key, and that it signs for the public key it reports. The same key-creation code was also run on a Windows 11 VM, with the same result. ## Pre-merge Checklist - [x] Have you checked for TypeScript, React or other console errors?
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.
Related issues
STUDIO_ENABLE_PULL_REPRINT). Split out of Reprint pull: fix bugs found before making it the default #6157.How AI was used in this PR
Claude Opus 5.5 (Claude Code), running as Franklin, Chris's agent, found this while stress-testing Reprint pull on real WordPress.com Atomic and preview sites, then wrote the fix and tests. It was split out of #6157. Chris reviews before merge.
Proposed Changes
--onlyselection blocked every later pull of that site. Studio saved the selection before the pull and reused it whenever an interrupted pull existed, so--only nonexistent/pathkept failing even after rerunning with--options all.studio pullresume). A different selection aborts the interrupted pull and starts over.Testing Instructions
With
STUDIO_ENABLE_PULL_REPRINT=1:studio pull --remote-site <id> --only nonexistent/path. It fails.--options all. On trunk it fails again with the old selection. With this change, the earlier selection is discarded and the full site pulls.studio pull: it resumes with the saved selection.Checked on macOS, Linux (Ubuntu) and a Windows 11 VM. On Linux, an interrupted and resumed pull ended with the same 23,365 files as a full pull.
Unit tests:
npx vitest run apps/cli/lib/pull apps/cli/commands/tests/pull.test.ts.Pre-merge Checklist