From 642812b1f6c32992b6785ca21e50ff0257ff8145 Mon Sep 17 00:00:00 2001 From: Mistium <92952823+Mistium@users.noreply.github.com> Date: Sun, 22 Nov 2026 12:31:19 +0000 Subject: [PATCH 01/12] Document pull requests that follow their remix and syncing a remix with its original --- docs/backend/storage.md | 14 ++++++++++++++ docs/community/releases-and-feedback.md | 4 ++++ 2 files changed, 18 insertions(+) diff --git a/docs/backend/storage.md b/docs/backend/storage.md index f2de77a0..8b7d7150 100644 --- a/docs/backend/storage.md +++ b/docs/backend/storage.md @@ -51,6 +51,20 @@ The first start after history sizes were recorded measured the history of existi Upload callers hold the project's save lock (`project-history-`). History preparation takes that lock itself, after resolving ancestors, and checks the saved source hasn't changed since. So an upload releases its lock while history is prepared and takes it back afterwards. That avoids deadlocking on its own lock and holding nested locks across a chain of remix ancestors. +### Pull requests and remix sync + +A pull request records the remix's head when it is opened, but an open pull request follows the remix: `GET /v1/projects/:id/pulls/:index`, its `diff` and its `merge` use the current head of the remix branch the pull request was opened from (`headBranch`). If that branch no longer exists, they fall back to the recorded head. Merged and closed pull requests keep the head they had. The diff compares the remix head with the closest commit it shares with the target's current head, so changes the remix brought in from the target are not shown as part of the pull request. The `pull` object in a diff response carries that `baseCommit` and `headCommit`. + +`POST /v1/projects/:id/pulls/:index/merge` merges against the same shared commit. When the target's head is an ancestor of the remix head and the remix head is the remix's saved project, the server fast-forwards and answers `{merged: true, fastForward: true}`. Otherwise it answers `{merged: false, merge, expectedHead, sourceHead}`, where `merge` is the three-way merge with `changes`, `conflicts` and `baseHead`. A remix whose history shares no commit with the target answers 409 `pull_merge_unavailable`, and one whose changes are already in the target answers 409 `already_merged`. The client applies `merge.changes` to the target tree at `expectedHead` and uploads the result with `pullId`, `expectedHead`, `mergeTree` and `mergeSourceHead` (the `sourceHead` it merged). If the remix has moved since, the upload answers 409 `pull_head_changed`. An upload without `mergeSourceHead` merges the remix's current head. Once merged, the pull request records the remix head it merged as `headCommit`. + +`POST /v1/projects/:id/remix/sync` prepares a merge of the original project's current head into a remix. Only a maintainer of the remix who can see inside both projects may call it. It answers `{merge, sourceProjectId, sourceTitle, sourceHead, targetHead, expectedHead}`. `merge.alreadyMerged` is true when the remix already contains the original's head, and `merge.fastForward` when the remix has no commits of its own since. Text conflicts are marked `this remix` and `original`. The client applies the changes to the remix tree at `targetHead` and uploads them with `syncHead` (the `sourceHead`), `expectedHead` and `mergeTree`. The server then writes a merge commit, `Merge changes from `, whose parents are the remix head and the original's head. A sync refuses with: + +- 404 when the project is not a remix, or its original no longer exists. +- 403 for anyone else, or once the original's source is no longer visible to the caller. +- 409 `uncommitted_changes` while the remix has saved changes that are not committed, because the merged project would replace them. +- 409 `head_changed` when `expectedHead` is missing or the remix moved, and 409 `original_changed` when the original moved after the sync was prepared. +- 400 when `syncHead` is combined with `pullId`, branch merge fields, `restoreCommit` or `replaceHistory`. + ### Serving snapshots Project, release and report-evidence snapshots are served from the local copy while one exists. Otherwise the API fetches the object from R2 through a presigned URL and passes it on as stored, with `Content-Encoding: gzip` when the stored copy is gzipped: diff --git a/docs/community/releases-and-feedback.md b/docs/community/releases-and-feedback.md index b206f1e6..8b3935f0 100644 --- a/docs/community/releases-and-feedback.md +++ b/docs/community/releases-and-feedback.md @@ -43,6 +43,10 @@ You can send an improvement without changing the creator's project directly: 4. Open the fork's project page, choose **Contribute**, and create a pull request. 5. The project owner reviews the changes and decides whether to merge them. +A pull request follows your fork. Commits you save to the fork after opening it appear in the pull request, so you can answer review feedback by changing the fork. + +When the original project gets new commits, keep your fork up to date with **Sync with original**. It is on the fork's developer view (the **Code** tab), next to the line that says how far ahead and behind the original your fork is. A sync brings the original's new commits into your fork as one merge commit. If you and the original changed the same part of a sprite, edit the marked conflict and choose which version of each changed costume or sound to keep, then select **Save resolutions and sync**. Commit any changes you saved in the editor first, because the synced project replaces them. + A bounty is a credit reward for a specific piece of work. Attach it when you create the pull request. MistWarp pays the reward when the project owner merges that pull request. Creating a fork or pull request alone does not claim the credits. Project owners create bounties under **Manage and analytics**, **Collaboration**, then **Bounties**. A useful bounty says exactly what should change and what the owner will accept as done. From 26159885439a9f365058fcf95541e8e928f8df96 Mon Sep 17 00:00:00 2001 From: Mistium <92952823+Mistium@users.noreply.github.com> Date: Sun, 22 Nov 2026 13:14:02 +0000 Subject: [PATCH 02/12] Document pull merge refusals, legacy pulls and single-file sync conflicts --- docs/backend/storage.md | 9 +++++---- docs/community/releases-and-feedback.md | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/backend/storage.md b/docs/backend/storage.md index 8b7d7150..03b352a8 100644 --- a/docs/backend/storage.md +++ b/docs/backend/storage.md @@ -53,17 +53,18 @@ Upload callers hold the project's save lock (`project-history-`). History pr ### Pull requests and remix sync -A pull request records the remix's head when it is opened, but an open pull request follows the remix: `GET /v1/projects/:id/pulls/:index`, its `diff` and its `merge` use the current head of the remix branch the pull request was opened from (`headBranch`). If that branch no longer exists, they fall back to the recorded head. Merged and closed pull requests keep the head they had. The diff compares the remix head with the closest commit it shares with the target's current head, so changes the remix brought in from the target are not shown as part of the pull request. The `pull` object in a diff response carries that `baseCommit` and `headCommit`. +A pull request records the remix's head when it is opened, but an open pull request follows the remix: `GET /v1/projects/:id/pulls/:index`, its `diff` and its `merge` use the current head of the remix branch the pull request was opened from (`headBranch`). A pull request opened before branches were recorded follows the remix's only branch, or keeps its recorded head when the remix has several. If the branch no longer exists, they fall back to the recorded head. Merged and closed pull requests keep the head they had, and `GET` shows the live head only to callers who can inspect the pull request. The diff compares the remix head with the closest commit it shares with the head of the target branch (`baseBranch`), so changes the remix brought in from the target are not shown as part of the pull request. The `pull` object in a diff response carries that `baseCommit` and `headCommit`. Merge bases are cached by the two heads, because the commits behind a head never change. -`POST /v1/projects/:id/pulls/:index/merge` merges against the same shared commit. When the target's head is an ancestor of the remix head and the remix head is the remix's saved project, the server fast-forwards and answers `{merged: true, fastForward: true}`. Otherwise it answers `{merged: false, merge, expectedHead, sourceHead}`, where `merge` is the three-way merge with `changes`, `conflicts` and `baseHead`. A remix whose history shares no commit with the target answers 409 `pull_merge_unavailable`, and one whose changes are already in the target answers 409 `already_merged`. The client applies `merge.changes` to the target tree at `expectedHead` and uploads the result with `pullId`, `expectedHead`, `mergeTree` and `mergeSourceHead` (the `sourceHead` it merged). If the remix has moved since, the upload answers 409 `pull_head_changed`. An upload without `mergeSourceHead` merges the remix's current head. Once merged, the pull request records the remix head it merged as `headCommit`. +`POST /v1/projects/:id/pulls/:index/merge` merges against the same shared commit, or against the recorded `baseCommit` when the two histories no longer share one. It refuses with 409 `target_branch_changed` (with `branch`) while the target is on another branch than the pull request's `baseBranch`, and 409 `uncommitted_changes` while the target has saved changes that are not committed. When the target's head is an ancestor of the remix head and the remix has no uncommitted changes, the server writes a merge commit whose tree is the remix head and answers `{merged: true, fastForward: true}`. When the target already has the remix head, the pull request is marked merged and the answer is `{merged: true, alreadyMerged: true}`. Otherwise it answers `{merged: false, merge, expectedHead, sourceHead}`, where `merge` is the three-way merge with `changes`, `conflicts` and `baseHead`. A merge that cannot be prepared answers 409 `pull_merge_unavailable`. The client applies `merge.changes` to the target tree at `expectedHead` and uploads the result with `pullId`, `expectedHead`, `mergeTree` and `mergeSourceHead` (the `sourceHead` it merged). If the remix has moved since, the upload answers 409 `pull_head_changed`. An upload without `mergeSourceHead` is checked against the pull request's recorded head instead, so an older client fails with 409 `pull_head_changed` once the remix has moved, rather than merging a tree that does not match the remix head. Once merged, the pull request records the remix head it merged as `headCommit`. -`POST /v1/projects/:id/remix/sync` prepares a merge of the original project's current head into a remix. Only a maintainer of the remix who can see inside both projects may call it. It answers `{merge, sourceProjectId, sourceTitle, sourceHead, targetHead, expectedHead}`. `merge.alreadyMerged` is true when the remix already contains the original's head, and `merge.fastForward` when the remix has no commits of its own since. Text conflicts are marked `this remix` and `original`. The client applies the changes to the remix tree at `targetHead` and uploads them with `syncHead` (the `sourceHead`), `expectedHead` and `mergeTree`. The server then writes a merge commit, `Merge changes from `, whose parents are the remix head and the original's head. A sync refuses with: +`POST /v1/projects/:id/remix/sync` prepares a merge of the original project's current head into a remix. Only a maintainer of the remix who can see inside both projects may call it. It answers `{merge, sourceProjectId, sourceTitle, sourceHead, targetHead, expectedHead}`. `merge.alreadyMerged` is true when the remix already contains the original's head, and `merge.fastForward` when the remix has no commits of its own since. Text conflicts are marked `this remix` and `original`. A history that still stores the whole project as one `project.sb3` file has a single binary conflict for that file, so the choice is the whole remix or the whole original. The client applies the changes to the remix tree at `targetHead` and uploads them with `syncHead` (the `sourceHead`), `expectedHead` and `mergeTree`. The server then writes a merge commit, `Merge changes from `, whose parents are the remix head and the original's head. A sync writes that merge commit even when it could fast-forward. A sync refuses with: - 404 when the project is not a remix, or its original no longer exists. - 403 for anyone else, or once the original's source is no longer visible to the caller. +- 409 `sync_history_unavailable` when either project has no MistWarp history, and 409 `sync_unavailable` when the two histories share no commit or the merge cannot be prepared. - 409 `uncommitted_changes` while the remix has saved changes that are not committed, because the merged project would replace them. - 409 `head_changed` when `expectedHead` is missing or the remix moved, and 409 `original_changed` when the original moved after the sync was prepared. -- 400 when `syncHead` is combined with `pullId`, branch merge fields, `restoreCommit` or `replaceHistory`. +- 400 when `syncHead` is combined with `pullId`, branch merge fields, `restoreCommit` or `replaceHistory`, or the upload has no `mergeTree`. ### Serving snapshots diff --git a/docs/community/releases-and-feedback.md b/docs/community/releases-and-feedback.md index 8b3935f0..22ca1a73 100644 --- a/docs/community/releases-and-feedback.md +++ b/docs/community/releases-and-feedback.md @@ -43,9 +43,9 @@ You can send an improvement without changing the creator's project directly: 4. Open the fork's project page, choose **Contribute**, and create a pull request. 5. The project owner reviews the changes and decides whether to merge them. -A pull request follows your fork. Commits you save to the fork after opening it appear in the pull request, so you can answer review feedback by changing the fork. +A pull request follows your fork. Commits you save to the fork after opening it appear in the pull request, so you can answer review feedback by changing the fork. Owners need to commit any changes they saved in the editor before merging, and the project has to be on the branch the pull request targets. -When the original project gets new commits, keep your fork up to date with **Sync with original**. It is on the fork's developer view (the **Code** tab), next to the line that says how far ahead and behind the original your fork is. A sync brings the original's new commits into your fork as one merge commit. If you and the original changed the same part of a sprite, edit the marked conflict and choose which version of each changed costume or sound to keep, then select **Save resolutions and sync**. Commit any changes you saved in the editor first, because the synced project replaces them. +When the original project gets new commits, keep your fork up to date with **Sync with original**. It is on the fork's developer view (the **Code** tab), next to the line that says how far ahead and behind the original your fork is. A sync brings the original's new commits into your fork as one merge commit. If you and the original changed the same part of a sprite, edit the marked conflict and choose which version of each changed costume or sound to keep, then select **Save resolutions and sync**. Commit any changes you saved in the editor first, because the synced project replaces them. Projects whose history was saved before sprites were stored as separate files show one conflict for the whole project, so you choose either your fork or the original. A bounty is a credit reward for a specific piece of work. Attach it when you create the pull request. MistWarp pays the reward when the project owner merges that pull request. Creating a fork or pull request alone does not claim the credits. From 94ee5b6abf5c154677b5159de73bc5cfe4035b38 Mon Sep 17 00:00:00 2001 From: Mistium <92952823+Mistium@users.noreply.github.com> Date: Sun, 22 Nov 2026 14:02:30 +0000 Subject: [PATCH 03/12] Document the deleted target branch refusal and the prepared remix head --- docs/backend/storage.md | 4 ++-- docs/community/releases-and-feedback.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/backend/storage.md b/docs/backend/storage.md index 03b352a8..4291ed5d 100644 --- a/docs/backend/storage.md +++ b/docs/backend/storage.md @@ -55,13 +55,13 @@ Upload callers hold the project's save lock (`project-history-`). History pr A pull request records the remix's head when it is opened, but an open pull request follows the remix: `GET /v1/projects/:id/pulls/:index`, its `diff` and its `merge` use the current head of the remix branch the pull request was opened from (`headBranch`). A pull request opened before branches were recorded follows the remix's only branch, or keeps its recorded head when the remix has several. If the branch no longer exists, they fall back to the recorded head. Merged and closed pull requests keep the head they had, and `GET` shows the live head only to callers who can inspect the pull request. The diff compares the remix head with the closest commit it shares with the head of the target branch (`baseBranch`), so changes the remix brought in from the target are not shown as part of the pull request. The `pull` object in a diff response carries that `baseCommit` and `headCommit`. Merge bases are cached by the two heads, because the commits behind a head never change. -`POST /v1/projects/:id/pulls/:index/merge` merges against the same shared commit, or against the recorded `baseCommit` when the two histories no longer share one. It refuses with 409 `target_branch_changed` (with `branch`) while the target is on another branch than the pull request's `baseBranch`, and 409 `uncommitted_changes` while the target has saved changes that are not committed. When the target's head is an ancestor of the remix head and the remix has no uncommitted changes, the server writes a merge commit whose tree is the remix head and answers `{merged: true, fastForward: true}`. When the target already has the remix head, the pull request is marked merged and the answer is `{merged: true, alreadyMerged: true}`. Otherwise it answers `{merged: false, merge, expectedHead, sourceHead}`, where `merge` is the three-way merge with `changes`, `conflicts` and `baseHead`. A merge that cannot be prepared answers 409 `pull_merge_unavailable`. The client applies `merge.changes` to the target tree at `expectedHead` and uploads the result with `pullId`, `expectedHead`, `mergeTree` and `mergeSourceHead` (the `sourceHead` it merged). If the remix has moved since, the upload answers 409 `pull_head_changed`. An upload without `mergeSourceHead` is checked against the pull request's recorded head instead, so an older client fails with 409 `pull_head_changed` once the remix has moved, rather than merging a tree that does not match the remix head. Once merged, the pull request records the remix head it merged as `headCommit`. +`POST /v1/projects/:id/pulls/:index/merge` merges against the same shared commit, or against the recorded `baseCommit` when the two histories no longer share one. It refuses with 409 `target_branch_changed` (with `branch`) while the target is on another branch than the pull request's `baseBranch`, 409 `target_branch_missing` once that branch has been deleted or renamed, and 409 `uncommitted_changes` while the target has saved changes that are not committed. Projects without branch metadata skip the branch check. The upload repeats both branch checks. When the target's head is an ancestor of the remix head and the remix has no uncommitted changes, the server writes a merge commit whose tree is the remix head and answers `{merged: true, fastForward: true}`. When the target already has the remix head, the pull request is marked merged under the project's save lock and the answer is `{merged: true, alreadyMerged: true}`. Otherwise it stores the remix head it merged on the pull request as `preparedSourceHead` and answers `{merged: false, merge, expectedHead, sourceHead}`, where `merge` is the three-way merge with `changes`, `conflicts` and `baseHead`. A merge that cannot be prepared answers 409 `pull_merge_unavailable`. The client applies `merge.changes` to the target tree at `expectedHead` and uploads the result with `pullId`, `expectedHead`, `mergeTree` and `mergeSourceHead` (the `sourceHead` it merged). If the remix has moved since, the upload answers 409 `pull_head_changed`. An upload without `mergeSourceHead` is checked against `preparedSourceHead` (or the recorded head before any merge was prepared), so an older client can merge what the server last prepared and fails with 409 `pull_head_changed` if the remix moved after that. A pull request upload must carry `mergeTree` and no `workspace`, `restoreCommit` or branch merge fields, or it answers 400. Once merged, the pull request records the remix head it merged as `headCommit`. `POST /v1/projects/:id/remix/sync` prepares a merge of the original project's current head into a remix. Only a maintainer of the remix who can see inside both projects may call it. It answers `{merge, sourceProjectId, sourceTitle, sourceHead, targetHead, expectedHead}`. `merge.alreadyMerged` is true when the remix already contains the original's head, and `merge.fastForward` when the remix has no commits of its own since. Text conflicts are marked `this remix` and `original`. A history that still stores the whole project as one `project.sb3` file has a single binary conflict for that file, so the choice is the whole remix or the whole original. The client applies the changes to the remix tree at `targetHead` and uploads them with `syncHead` (the `sourceHead`), `expectedHead` and `mergeTree`. The server then writes a merge commit, `Merge changes from `, whose parents are the remix head and the original's head. A sync writes that merge commit even when it could fast-forward. A sync refuses with: - 404 when the project is not a remix, or its original no longer exists. - 403 for anyone else, or once the original's source is no longer visible to the caller. -- 409 `sync_history_unavailable` when either project has no MistWarp history, and 409 `sync_unavailable` when the two histories share no commit or the merge cannot be prepared. +- 409 `sync_history_unavailable` when either project has no MistWarp history, 409 `sync_unavailable` when the two histories share no commit or the merge cannot be prepared, and 500 when a history exists but cannot be read. - 409 `uncommitted_changes` while the remix has saved changes that are not committed, because the merged project would replace them. - 409 `head_changed` when `expectedHead` is missing or the remix moved, and 409 `original_changed` when the original moved after the sync was prepared. - 400 when `syncHead` is combined with `pullId`, branch merge fields, `restoreCommit` or `replaceHistory`, or the upload has no `mergeTree`. diff --git a/docs/community/releases-and-feedback.md b/docs/community/releases-and-feedback.md index 22ca1a73..accea329 100644 --- a/docs/community/releases-and-feedback.md +++ b/docs/community/releases-and-feedback.md @@ -43,7 +43,7 @@ You can send an improvement without changing the creator's project directly: 4. Open the fork's project page, choose **Contribute**, and create a pull request. 5. The project owner reviews the changes and decides whether to merge them. -A pull request follows your fork. Commits you save to the fork after opening it appear in the pull request, so you can answer review feedback by changing the fork. Owners need to commit any changes they saved in the editor before merging, and the project has to be on the branch the pull request targets. +A pull request follows your fork. Commits you save to the fork after opening it appear in the pull request, so you can answer review feedback by changing the fork. Owners need to commit any changes they saved in the editor before merging, and the project has to be on the branch the pull request targets. If that branch has been deleted, close the pull request and open a new one. When the original project gets new commits, keep your fork up to date with **Sync with original**. It is on the fork's developer view (the **Code** tab), next to the line that says how far ahead and behind the original your fork is. A sync brings the original's new commits into your fork as one merge commit. If you and the original changed the same part of a sprite, edit the marked conflict and choose which version of each changed costume or sound to keep, then select **Save resolutions and sync**. Commit any changes you saved in the editor first, because the synced project replaces them. Projects whose history was saved before sprites were stored as separate files show one conflict for the whole project, so you choose either your fork or the original. From 18666bee74a845b1e46c7e699b298dce356c2b4b Mon Sep 17 00:00:00 2001 From: Mistium <92952823+Mistium@users.noreply.github.com> Date: Sun, 22 Nov 2026 14:53:48 +0000 Subject: [PATCH 04/12] Describe the live base on GET, the merge base cache and the pull upload refusals --- docs/backend/storage.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/backend/storage.md b/docs/backend/storage.md index 4291ed5d..b7bb7768 100644 --- a/docs/backend/storage.md +++ b/docs/backend/storage.md @@ -53,9 +53,9 @@ Upload callers hold the project's save lock (`project-history-`). History pr ### Pull requests and remix sync -A pull request records the remix's head when it is opened, but an open pull request follows the remix: `GET /v1/projects/:id/pulls/:index`, its `diff` and its `merge` use the current head of the remix branch the pull request was opened from (`headBranch`). A pull request opened before branches were recorded follows the remix's only branch, or keeps its recorded head when the remix has several. If the branch no longer exists, they fall back to the recorded head. Merged and closed pull requests keep the head they had, and `GET` shows the live head only to callers who can inspect the pull request. The diff compares the remix head with the closest commit it shares with the head of the target branch (`baseBranch`), so changes the remix brought in from the target are not shown as part of the pull request. The `pull` object in a diff response carries that `baseCommit` and `headCommit`. Merge bases are cached by the two heads, because the commits behind a head never change. +A pull request records the remix's head when it is opened, but an open pull request follows the remix: `GET /v1/projects/:id/pulls/:index`, its `diff` and its `merge` use the current head of the remix branch the pull request was opened from (`headBranch`). A pull request opened before branches were recorded follows the remix's only branch, or keeps its recorded head when the remix has several. If the branch no longer exists, they fall back to the recorded head. Merged and closed pull requests keep the head they had. `GET` shows the live head and its live base only to callers who can inspect the pull request, and everyone else sees the recorded pair. The diff compares the remix head with the closest commit it shares with the head of the target branch (`baseBranch`), so changes the remix brought in from the target are not shown as part of the pull request. The `pull` object in a diff response carries that `baseCommit` and `headCommit`. The diff's merge base is cached by the two heads, because the commits behind a head never change, and a cached base is used only while both histories still contain it. Preparing a merge always walks the histories. -`POST /v1/projects/:id/pulls/:index/merge` merges against the same shared commit, or against the recorded `baseCommit` when the two histories no longer share one. It refuses with 409 `target_branch_changed` (with `branch`) while the target is on another branch than the pull request's `baseBranch`, 409 `target_branch_missing` once that branch has been deleted or renamed, and 409 `uncommitted_changes` while the target has saved changes that are not committed. Projects without branch metadata skip the branch check. The upload repeats both branch checks. When the target's head is an ancestor of the remix head and the remix has no uncommitted changes, the server writes a merge commit whose tree is the remix head and answers `{merged: true, fastForward: true}`. When the target already has the remix head, the pull request is marked merged under the project's save lock and the answer is `{merged: true, alreadyMerged: true}`. Otherwise it stores the remix head it merged on the pull request as `preparedSourceHead` and answers `{merged: false, merge, expectedHead, sourceHead}`, where `merge` is the three-way merge with `changes`, `conflicts` and `baseHead`. A merge that cannot be prepared answers 409 `pull_merge_unavailable`. The client applies `merge.changes` to the target tree at `expectedHead` and uploads the result with `pullId`, `expectedHead`, `mergeTree` and `mergeSourceHead` (the `sourceHead` it merged). If the remix has moved since, the upload answers 409 `pull_head_changed`. An upload without `mergeSourceHead` is checked against `preparedSourceHead` (or the recorded head before any merge was prepared), so an older client can merge what the server last prepared and fails with 409 `pull_head_changed` if the remix moved after that. A pull request upload must carry `mergeTree` and no `workspace`, `restoreCommit` or branch merge fields, or it answers 400. Once merged, the pull request records the remix head it merged as `headCommit`. +`POST /v1/projects/:id/pulls/:index/merge` merges against the same shared commit, or against the recorded `baseCommit` when the two histories no longer share one. It refuses with 409 `target_branch_changed` (with `branch`) while the target is on another branch than the pull request's `baseBranch`, 409 `target_branch_missing` once that branch has been deleted or renamed, and 409 `uncommitted_changes` while the target has saved changes that are not committed. Projects without branch metadata skip the branch check. The upload repeats both branch checks. When the target's head is an ancestor of the remix head and the remix has no uncommitted changes, the server writes a merge commit whose tree is the remix head and answers `{merged: true, fastForward: true}`. When the target already has the remix head, the pull request is marked merged under the project's save lock and the answer is `{merged: true, alreadyMerged: true}`. Otherwise it stores the remix head it merged on the pull request as `preparedSourceHead` and answers `{merged: false, merge, expectedHead, sourceHead}`, where `merge` is the three-way merge with `changes`, `conflicts` and `baseHead`. A merge that cannot be prepared answers 409 `pull_merge_unavailable`. The client applies `merge.changes` to the target tree at `expectedHead` and uploads the result with `pullId`, `expectedHead`, `mergeTree` and `mergeSourceHead` (the `sourceHead` it merged). If the remix has moved since, the upload answers 409 `pull_head_changed`. An upload without `mergeSourceHead` is checked against `preparedSourceHead` (or the recorded head before any merge was prepared), so an older client can merge what the server last prepared and fails with 409 `pull_head_changed` if the remix moved after that. A pull request upload must carry `mergeTree` and no `workspace`, `restoreCommit`, `mergeSourceBranch` or `mergeTargetBranch`, or it answers 400. It answers 409 `head_changed` without `expectedHead` or when the target moved, and 409 `pull_not_open` once the pull request was closed or merged. Merging needs the same edit access as saving the project, so admins and group managers who can edit it can merge too. Once merged, the pull request records the remix head it merged as `headCommit`. `POST /v1/projects/:id/remix/sync` prepares a merge of the original project's current head into a remix. Only a maintainer of the remix who can see inside both projects may call it. It answers `{merge, sourceProjectId, sourceTitle, sourceHead, targetHead, expectedHead}`. `merge.alreadyMerged` is true when the remix already contains the original's head, and `merge.fastForward` when the remix has no commits of its own since. Text conflicts are marked `this remix` and `original`. A history that still stores the whole project as one `project.sb3` file has a single binary conflict for that file, so the choice is the whole remix or the whole original. The client applies the changes to the remix tree at `targetHead` and uploads them with `syncHead` (the `sourceHead`), `expectedHead` and `mergeTree`. The server then writes a merge commit, `Merge changes from `, whose parents are the remix head and the original's head. A sync writes that merge commit even when it could fast-forward. A sync refuses with: From 1a362f6126a0449d3f1a8bca0b3527960046bde1 Mon Sep 17 00:00:00 2001 From: Mistium <92952823+Mistium@users.noreply.github.com> Date: Sun, 22 Nov 2026 15:31:49 +0000 Subject: [PATCH 05/12] Document the recorded base on GET, merging an already merged pull with uncommitted changes, and the fast-forward conditions --- docs/backend/storage.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/backend/storage.md b/docs/backend/storage.md index b7bb7768..92cea9fd 100644 --- a/docs/backend/storage.md +++ b/docs/backend/storage.md @@ -53,9 +53,9 @@ Upload callers hold the project's save lock (`project-history-`). History pr ### Pull requests and remix sync -A pull request records the remix's head when it is opened, but an open pull request follows the remix: `GET /v1/projects/:id/pulls/:index`, its `diff` and its `merge` use the current head of the remix branch the pull request was opened from (`headBranch`). A pull request opened before branches were recorded follows the remix's only branch, or keeps its recorded head when the remix has several. If the branch no longer exists, they fall back to the recorded head. Merged and closed pull requests keep the head they had. `GET` shows the live head and its live base only to callers who can inspect the pull request, and everyone else sees the recorded pair. The diff compares the remix head with the closest commit it shares with the head of the target branch (`baseBranch`), so changes the remix brought in from the target are not shown as part of the pull request. The `pull` object in a diff response carries that `baseCommit` and `headCommit`. The diff's merge base is cached by the two heads, because the commits behind a head never change, and a cached base is used only while both histories still contain it. Preparing a merge always walks the histories. +A pull request records the remix's head when it is opened, but an open pull request follows the remix: `GET /v1/projects/:id/pulls/:index`, its `diff` and its `merge` use the current head of the remix branch the pull request was opened from (`headBranch`). A pull request opened before branches were recorded follows the remix's only branch, or keeps its recorded head when the remix has several. If the branch no longer exists, they fall back to the recorded head. Merged and closed pull requests keep the head they had. `GET` shows the live head only to callers who can inspect the pull request. Its `baseCommit` stays the recorded fork point, so loading the pull request does no history work, and the diff response carries the live base. The diff compares the remix head with the closest commit it shares with the head of the target branch (`baseBranch`), or with the recorded base once that branch has been deleted, so changes the remix brought in from the target are not shown as part of the pull request. The `pull` object in a diff response carries that `baseCommit` and `headCommit`. The diff's merge base is cached by the two heads, because the commits behind a head never change, and a cached base is used only while both histories still contain it. Preparing a merge always walks the histories. -`POST /v1/projects/:id/pulls/:index/merge` merges against the same shared commit, or against the recorded `baseCommit` when the two histories no longer share one. It refuses with 409 `target_branch_changed` (with `branch`) while the target is on another branch than the pull request's `baseBranch`, 409 `target_branch_missing` once that branch has been deleted or renamed, and 409 `uncommitted_changes` while the target has saved changes that are not committed. Projects without branch metadata skip the branch check. The upload repeats both branch checks. When the target's head is an ancestor of the remix head and the remix has no uncommitted changes, the server writes a merge commit whose tree is the remix head and answers `{merged: true, fastForward: true}`. When the target already has the remix head, the pull request is marked merged under the project's save lock and the answer is `{merged: true, alreadyMerged: true}`. Otherwise it stores the remix head it merged on the pull request as `preparedSourceHead` and answers `{merged: false, merge, expectedHead, sourceHead}`, where `merge` is the three-way merge with `changes`, `conflicts` and `baseHead`. A merge that cannot be prepared answers 409 `pull_merge_unavailable`. The client applies `merge.changes` to the target tree at `expectedHead` and uploads the result with `pullId`, `expectedHead`, `mergeTree` and `mergeSourceHead` (the `sourceHead` it merged). If the remix has moved since, the upload answers 409 `pull_head_changed`. An upload without `mergeSourceHead` is checked against `preparedSourceHead` (or the recorded head before any merge was prepared), so an older client can merge what the server last prepared and fails with 409 `pull_head_changed` if the remix moved after that. A pull request upload must carry `mergeTree` and no `workspace`, `restoreCommit`, `mergeSourceBranch` or `mergeTargetBranch`, or it answers 400. It answers 409 `head_changed` without `expectedHead` or when the target moved, and 409 `pull_not_open` once the pull request was closed or merged. Merging needs the same edit access as saving the project, so admins and group managers who can edit it can merge too. Once merged, the pull request records the remix head it merged as `headCommit`. +`POST /v1/projects/:id/pulls/:index/merge` merges against the same shared commit, or against the recorded `baseCommit` when the two histories no longer share one. It refuses with 409 `target_branch_changed` (with `branch`) while the target is on another branch than the pull request's `baseBranch`, 409 `target_branch_missing` once that branch has been deleted or renamed, and 409 `uncommitted_changes` while the target has saved changes that are not committed, unless the pull request is already merged, since closing it touches no project files. Projects without branch metadata skip the branch check. The upload repeats both branch checks. When the target's head is an ancestor of the remix head, the remix has no uncommitted changes and the remix is on the branch the pull request follows, the server writes a merge commit whose tree is the remix head and answers `{merged: true, fastForward: true}`. When the target already has the remix head, the pull request is marked merged under the project's save lock and the answer is `{merged: true, alreadyMerged: true}`. Otherwise it stores the remix head it merged on the pull request as `preparedSourceHead` and answers `{merged: false, merge, expectedHead, sourceHead}`, where `merge` is the three-way merge with `changes`, `conflicts` and `baseHead`. A merge that cannot be prepared answers 409 `pull_merge_unavailable`. The client applies `merge.changes` to the target tree at `expectedHead` and uploads the result with `pullId`, `expectedHead`, `mergeTree` and `mergeSourceHead` (the `sourceHead` it merged). If the remix has moved since, the upload answers 409 `pull_head_changed`. An upload without `mergeSourceHead` is checked against `preparedSourceHead` (or the recorded head before any merge was prepared), so an older client can merge what the server last prepared and fails with 409 `pull_head_changed` if the remix moved after that. A pull request upload must carry `mergeTree` and no `workspace`, `restoreCommit`, `mergeSourceBranch` or `mergeTargetBranch`, or it answers 400. It answers 409 `head_changed` without `expectedHead` or when the target moved, and 409 `pull_not_open` once the pull request was closed or merged. Merging needs the same edit access as saving the project, so admins and group managers who can edit it can merge too. Once merged, the pull request records the remix head it merged as `headCommit`. `POST /v1/projects/:id/remix/sync` prepares a merge of the original project's current head into a remix. Only a maintainer of the remix who can see inside both projects may call it. It answers `{merge, sourceProjectId, sourceTitle, sourceHead, targetHead, expectedHead}`. `merge.alreadyMerged` is true when the remix already contains the original's head, and `merge.fastForward` when the remix has no commits of its own since. Text conflicts are marked `this remix` and `original`. A history that still stores the whole project as one `project.sb3` file has a single binary conflict for that file, so the choice is the whole remix or the whole original. The client applies the changes to the remix tree at `targetHead` and uploads them with `syncHead` (the `sourceHead`), `expectedHead` and `mergeTree`. The server then writes a merge commit, `Merge changes from `, whose parents are the remix head and the original's head. A sync writes that merge commit even when it could fast-forward. A sync refuses with: From 459aa2519e0ce625a8615fab7866cbab535abf00 Mon Sep 17 00:00:00 2001 From: Mistium <92952823+Mistium@users.noreply.github.com> Date: Sun, 22 Nov 2026 15:51:37 +0000 Subject: [PATCH 06/12] Document baseBranchMissing and the upload's uncommitted refusal --- docs/backend/storage.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/backend/storage.md b/docs/backend/storage.md index 92cea9fd..572bd409 100644 --- a/docs/backend/storage.md +++ b/docs/backend/storage.md @@ -55,7 +55,7 @@ Upload callers hold the project's save lock (`project-history-`). History pr A pull request records the remix's head when it is opened, but an open pull request follows the remix: `GET /v1/projects/:id/pulls/:index`, its `diff` and its `merge` use the current head of the remix branch the pull request was opened from (`headBranch`). A pull request opened before branches were recorded follows the remix's only branch, or keeps its recorded head when the remix has several. If the branch no longer exists, they fall back to the recorded head. Merged and closed pull requests keep the head they had. `GET` shows the live head only to callers who can inspect the pull request. Its `baseCommit` stays the recorded fork point, so loading the pull request does no history work, and the diff response carries the live base. The diff compares the remix head with the closest commit it shares with the head of the target branch (`baseBranch`), or with the recorded base once that branch has been deleted, so changes the remix brought in from the target are not shown as part of the pull request. The `pull` object in a diff response carries that `baseCommit` and `headCommit`. The diff's merge base is cached by the two heads, because the commits behind a head never change, and a cached base is used only while both histories still contain it. Preparing a merge always walks the histories. -`POST /v1/projects/:id/pulls/:index/merge` merges against the same shared commit, or against the recorded `baseCommit` when the two histories no longer share one. It refuses with 409 `target_branch_changed` (with `branch`) while the target is on another branch than the pull request's `baseBranch`, 409 `target_branch_missing` once that branch has been deleted or renamed, and 409 `uncommitted_changes` while the target has saved changes that are not committed, unless the pull request is already merged, since closing it touches no project files. Projects without branch metadata skip the branch check. The upload repeats both branch checks. When the target's head is an ancestor of the remix head, the remix has no uncommitted changes and the remix is on the branch the pull request follows, the server writes a merge commit whose tree is the remix head and answers `{merged: true, fastForward: true}`. When the target already has the remix head, the pull request is marked merged under the project's save lock and the answer is `{merged: true, alreadyMerged: true}`. Otherwise it stores the remix head it merged on the pull request as `preparedSourceHead` and answers `{merged: false, merge, expectedHead, sourceHead}`, where `merge` is the three-way merge with `changes`, `conflicts` and `baseHead`. A merge that cannot be prepared answers 409 `pull_merge_unavailable`. The client applies `merge.changes` to the target tree at `expectedHead` and uploads the result with `pullId`, `expectedHead`, `mergeTree` and `mergeSourceHead` (the `sourceHead` it merged). If the remix has moved since, the upload answers 409 `pull_head_changed`. An upload without `mergeSourceHead` is checked against `preparedSourceHead` (or the recorded head before any merge was prepared), so an older client can merge what the server last prepared and fails with 409 `pull_head_changed` if the remix moved after that. A pull request upload must carry `mergeTree` and no `workspace`, `restoreCommit`, `mergeSourceBranch` or `mergeTargetBranch`, or it answers 400. It answers 409 `head_changed` without `expectedHead` or when the target moved, and 409 `pull_not_open` once the pull request was closed or merged. Merging needs the same edit access as saving the project, so admins and group managers who can edit it can merge too. Once merged, the pull request records the remix head it merged as `headCommit`. +`POST /v1/projects/:id/pulls/:index/merge` merges against the same shared commit, or against the recorded `baseCommit` when the two histories no longer share one. It refuses with 409 `target_branch_changed` (with `branch`) while the target is on another branch than the pull request's `baseBranch`, 409 `target_branch_missing` once that branch has been deleted or renamed, and 409 `uncommitted_changes` while the target has saved changes that are not committed, unless the pull request is already merged, since closing it touches no project files. Projects without branch metadata skip the branch check. The upload repeats both branch checks and the `uncommitted_changes` refusal. `GET` reports `baseBranchMissing: true` once the target branch is gone, so a client can say so before anyone tries to merge. When the target's head is an ancestor of the remix head, the remix has no uncommitted changes and the remix is on the branch the pull request follows, the server writes a merge commit whose tree is the remix head and answers `{merged: true, fastForward: true}`. When the target already has the remix head, the pull request is marked merged under the project's save lock and the answer is `{merged: true, alreadyMerged: true}`. Otherwise it stores the remix head it merged on the pull request as `preparedSourceHead` and answers `{merged: false, merge, expectedHead, sourceHead}`, where `merge` is the three-way merge with `changes`, `conflicts` and `baseHead`. A merge that cannot be prepared answers 409 `pull_merge_unavailable`. The client applies `merge.changes` to the target tree at `expectedHead` and uploads the result with `pullId`, `expectedHead`, `mergeTree` and `mergeSourceHead` (the `sourceHead` it merged). If the remix has moved since, the upload answers 409 `pull_head_changed`. An upload without `mergeSourceHead` is checked against `preparedSourceHead` (or the recorded head before any merge was prepared), so an older client can merge what the server last prepared and fails with 409 `pull_head_changed` if the remix moved after that. A pull request upload must carry `mergeTree` and no `workspace`, `restoreCommit`, `mergeSourceBranch` or `mergeTargetBranch`, or it answers 400. It answers 409 `head_changed` without `expectedHead` or when the target moved, and 409 `pull_not_open` once the pull request was closed or merged. Merging needs the same edit access as saving the project, so admins and group managers who can edit it can merge too. Once merged, the pull request records the remix head it merged as `headCommit`. `POST /v1/projects/:id/remix/sync` prepares a merge of the original project's current head into a remix. Only a maintainer of the remix who can see inside both projects may call it. It answers `{merge, sourceProjectId, sourceTitle, sourceHead, targetHead, expectedHead}`. `merge.alreadyMerged` is true when the remix already contains the original's head, and `merge.fastForward` when the remix has no commits of its own since. Text conflicts are marked `this remix` and `original`. A history that still stores the whole project as one `project.sb3` file has a single binary conflict for that file, so the choice is the whole remix or the whole original. The client applies the changes to the remix tree at `targetHead` and uploads them with `syncHead` (the `sourceHead`), `expectedHead` and `mergeTree`. The server then writes a merge commit, `Merge changes from `, whose parents are the remix head and the original's head. A sync writes that merge commit even when it could fast-forward. A sync refuses with: From d5a0ca7a6667ad90f34e4b15868e0ca4fc7e767e Mon Sep 17 00:00:00 2001 From: Mistium <92952823+Mistium@users.noreply.github.com> Date: Mon, 23 Nov 2026 23:29:34 +0000 Subject: [PATCH 07/12] Document pull merge mark failures and scoped pull commit access --- docs/backend/storage.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/backend/storage.md b/docs/backend/storage.md index 572bd409..577075f6 100644 --- a/docs/backend/storage.md +++ b/docs/backend/storage.md @@ -53,9 +53,9 @@ Upload callers hold the project's save lock (`project-history-`). History pr ### Pull requests and remix sync -A pull request records the remix's head when it is opened, but an open pull request follows the remix: `GET /v1/projects/:id/pulls/:index`, its `diff` and its `merge` use the current head of the remix branch the pull request was opened from (`headBranch`). A pull request opened before branches were recorded follows the remix's only branch, or keeps its recorded head when the remix has several. If the branch no longer exists, they fall back to the recorded head. Merged and closed pull requests keep the head they had. `GET` shows the live head only to callers who can inspect the pull request. Its `baseCommit` stays the recorded fork point, so loading the pull request does no history work, and the diff response carries the live base. The diff compares the remix head with the closest commit it shares with the head of the target branch (`baseBranch`), or with the recorded base once that branch has been deleted, so changes the remix brought in from the target are not shown as part of the pull request. The `pull` object in a diff response carries that `baseCommit` and `headCommit`. The diff's merge base is cached by the two heads, because the commits behind a head never change, and a cached base is used only while both histories still contain it. Preparing a merge always walks the histories. +A pull request records the remix's head when it is opened, but an open pull request follows the remix: `GET /v1/projects/:id/pulls/:index`, its `diff` and its `merge` use the current head of the remix branch the pull request was opened from (`headBranch`). A pull request opened before branches were recorded follows the remix's only branch, or keeps its recorded head when the remix has several. If the branch no longer exists, they fall back to the recorded head. Merged and closed pull requests keep the head they had. `GET` shows the live head only to callers who can inspect the pull request. Its `baseCommit` stays the recorded fork point, so loading the pull request does no history work, and the diff response carries the live base. The diff compares the remix head with the closest commit it shares with the head of the target branch (`baseBranch`), or with the recorded base once that branch has been deleted, so changes the remix brought in from the target are not shown as part of the pull request. The `pull` object in a diff response carries that `baseCommit` and `headCommit`. The diff's merge base is cached by the two heads, because the commits behind a head never change, and a cached base is used only while both histories still contain it. Preparing a merge always walks the histories. Reading a project's commits or files with `?pull=&pullTarget=` is limited to commits that belong to that pull request (its recorded base, recorded target head, recorded head, prepared head, live head and live base), and downloading `workspace.mwp?pull=` also requires a signed-in editor of the target project or the owner of the remix. -`POST /v1/projects/:id/pulls/:index/merge` merges against the same shared commit, or against the recorded `baseCommit` when the two histories no longer share one. It refuses with 409 `target_branch_changed` (with `branch`) while the target is on another branch than the pull request's `baseBranch`, 409 `target_branch_missing` once that branch has been deleted or renamed, and 409 `uncommitted_changes` while the target has saved changes that are not committed, unless the pull request is already merged, since closing it touches no project files. Projects without branch metadata skip the branch check. The upload repeats both branch checks and the `uncommitted_changes` refusal. `GET` reports `baseBranchMissing: true` once the target branch is gone, so a client can say so before anyone tries to merge. When the target's head is an ancestor of the remix head, the remix has no uncommitted changes and the remix is on the branch the pull request follows, the server writes a merge commit whose tree is the remix head and answers `{merged: true, fastForward: true}`. When the target already has the remix head, the pull request is marked merged under the project's save lock and the answer is `{merged: true, alreadyMerged: true}`. Otherwise it stores the remix head it merged on the pull request as `preparedSourceHead` and answers `{merged: false, merge, expectedHead, sourceHead}`, where `merge` is the three-way merge with `changes`, `conflicts` and `baseHead`. A merge that cannot be prepared answers 409 `pull_merge_unavailable`. The client applies `merge.changes` to the target tree at `expectedHead` and uploads the result with `pullId`, `expectedHead`, `mergeTree` and `mergeSourceHead` (the `sourceHead` it merged). If the remix has moved since, the upload answers 409 `pull_head_changed`. An upload without `mergeSourceHead` is checked against `preparedSourceHead` (or the recorded head before any merge was prepared), so an older client can merge what the server last prepared and fails with 409 `pull_head_changed` if the remix moved after that. A pull request upload must carry `mergeTree` and no `workspace`, `restoreCommit`, `mergeSourceBranch` or `mergeTargetBranch`, or it answers 400. It answers 409 `head_changed` without `expectedHead` or when the target moved, and 409 `pull_not_open` once the pull request was closed or merged. Merging needs the same edit access as saving the project, so admins and group managers who can edit it can merge too. Once merged, the pull request records the remix head it merged as `headCommit`. +`POST /v1/projects/:id/pulls/:index/merge` merges against the same shared commit, or against the recorded `baseCommit` when the two histories no longer share one. It refuses with 409 `target_branch_changed` (with `branch`) while the target is on another branch than the pull request's `baseBranch`, 409 `target_branch_missing` once that branch has been deleted or renamed, and 409 `uncommitted_changes` while the target has saved changes that are not committed, unless the pull request is already merged, since closing it touches no project files. Projects without branch metadata skip the branch check. The upload repeats both branch checks and the `uncommitted_changes` refusal. `GET` reports `baseBranchMissing: true` once the target branch is gone, so a client can say so before anyone tries to merge. When the target's head is an ancestor of the remix head, the remix has no uncommitted changes and the remix is on the branch the pull request follows, the server writes a merge commit whose tree is the remix head and answers `{merged: true, fastForward: true}`. When the target already has the remix head, the pull request is marked merged under the project's save lock and the answer is `{merged: true, alreadyMerged: true}`. Otherwise it stores the remix head it merged on the pull request as `preparedSourceHead` and answers `{merged: false, merge, expectedHead, sourceHead}`, where `merge` is the three-way merge with `changes`, `conflicts` and `baseHead`. A merge that cannot be prepared answers 409 `pull_merge_unavailable`. The client applies `merge.changes` to the target tree at `expectedHead` and uploads the result with `pullId`, `expectedHead`, `mergeTree` and `mergeSourceHead` (the `sourceHead` it merged). If the remix has moved since, the upload answers 409 `pull_head_changed`. An upload without `mergeSourceHead` is checked against `preparedSourceHead` (or the recorded head before any merge was prepared), so an older client can merge what the server last prepared and fails with 409 `pull_head_changed` if the remix moved after that. A pull request upload must carry `mergeTree` and no `workspace`, `restoreCommit`, `mergeSourceBranch` or `mergeTargetBranch`, or it answers 400. It answers 409 `head_changed` without `expectedHead` or when the target moved, 409 `pull_not_open` once the pull request was closed or merged, and 409 `pull_not_closed` (or 500 on the merge endpoint) if the project saves but the pull request record cannot be marked merged. Merging needs the same edit access as saving the project, so admins and group managers who can edit it can merge too. Once merged, the pull request records the remix head it merged as `headCommit`. `POST /v1/projects/:id/remix/sync` prepares a merge of the original project's current head into a remix. Only a maintainer of the remix who can see inside both projects may call it. It answers `{merge, sourceProjectId, sourceTitle, sourceHead, targetHead, expectedHead}`. `merge.alreadyMerged` is true when the remix already contains the original's head, and `merge.fastForward` when the remix has no commits of its own since. Text conflicts are marked `this remix` and `original`. A history that still stores the whole project as one `project.sb3` file has a single binary conflict for that file, so the choice is the whole remix or the whole original. The client applies the changes to the remix tree at `targetHead` and uploads them with `syncHead` (the `sourceHead`), `expectedHead` and `mergeTree`. The server then writes a merge commit, `Merge changes from `, whose parents are the remix head and the original's head. A sync writes that merge commit even when it could fast-forward. A sync refuses with: From a4e9d574bbd9e50686ef16e33e9236a5e88f92ff Mon Sep 17 00:00:00 2001 From: Mistium <92952823+Mistium@users.noreply.github.com> Date: Tue, 24 Nov 2026 00:29:18 +0000 Subject: [PATCH 08/12] Clarify pull merge checks after already_merged --- docs/backend/storage.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/backend/storage.md b/docs/backend/storage.md index 577075f6..6cb309e4 100644 --- a/docs/backend/storage.md +++ b/docs/backend/storage.md @@ -55,7 +55,7 @@ Upload callers hold the project's save lock (`project-history-`). History pr A pull request records the remix's head when it is opened, but an open pull request follows the remix: `GET /v1/projects/:id/pulls/:index`, its `diff` and its `merge` use the current head of the remix branch the pull request was opened from (`headBranch`). A pull request opened before branches were recorded follows the remix's only branch, or keeps its recorded head when the remix has several. If the branch no longer exists, they fall back to the recorded head. Merged and closed pull requests keep the head they had. `GET` shows the live head only to callers who can inspect the pull request. Its `baseCommit` stays the recorded fork point, so loading the pull request does no history work, and the diff response carries the live base. The diff compares the remix head with the closest commit it shares with the head of the target branch (`baseBranch`), or with the recorded base once that branch has been deleted, so changes the remix brought in from the target are not shown as part of the pull request. The `pull` object in a diff response carries that `baseCommit` and `headCommit`. The diff's merge base is cached by the two heads, because the commits behind a head never change, and a cached base is used only while both histories still contain it. Preparing a merge always walks the histories. Reading a project's commits or files with `?pull=&pullTarget=` is limited to commits that belong to that pull request (its recorded base, recorded target head, recorded head, prepared head, live head and live base), and downloading `workspace.mwp?pull=` also requires a signed-in editor of the target project or the owner of the remix. -`POST /v1/projects/:id/pulls/:index/merge` merges against the same shared commit, or against the recorded `baseCommit` when the two histories no longer share one. It refuses with 409 `target_branch_changed` (with `branch`) while the target is on another branch than the pull request's `baseBranch`, 409 `target_branch_missing` once that branch has been deleted or renamed, and 409 `uncommitted_changes` while the target has saved changes that are not committed, unless the pull request is already merged, since closing it touches no project files. Projects without branch metadata skip the branch check. The upload repeats both branch checks and the `uncommitted_changes` refusal. `GET` reports `baseBranchMissing: true` once the target branch is gone, so a client can say so before anyone tries to merge. When the target's head is an ancestor of the remix head, the remix has no uncommitted changes and the remix is on the branch the pull request follows, the server writes a merge commit whose tree is the remix head and answers `{merged: true, fastForward: true}`. When the target already has the remix head, the pull request is marked merged under the project's save lock and the answer is `{merged: true, alreadyMerged: true}`. Otherwise it stores the remix head it merged on the pull request as `preparedSourceHead` and answers `{merged: false, merge, expectedHead, sourceHead}`, where `merge` is the three-way merge with `changes`, `conflicts` and `baseHead`. A merge that cannot be prepared answers 409 `pull_merge_unavailable`. The client applies `merge.changes` to the target tree at `expectedHead` and uploads the result with `pullId`, `expectedHead`, `mergeTree` and `mergeSourceHead` (the `sourceHead` it merged). If the remix has moved since, the upload answers 409 `pull_head_changed`. An upload without `mergeSourceHead` is checked against `preparedSourceHead` (or the recorded head before any merge was prepared), so an older client can merge what the server last prepared and fails with 409 `pull_head_changed` if the remix moved after that. A pull request upload must carry `mergeTree` and no `workspace`, `restoreCommit`, `mergeSourceBranch` or `mergeTargetBranch`, or it answers 400. It answers 409 `head_changed` without `expectedHead` or when the target moved, 409 `pull_not_open` once the pull request was closed or merged, and 409 `pull_not_closed` (or 500 on the merge endpoint) if the project saves but the pull request record cannot be marked merged. Merging needs the same edit access as saving the project, so admins and group managers who can edit it can merge too. Once merged, the pull request records the remix head it merged as `headCommit`. +`POST /v1/projects/:id/pulls/:index/merge` merges against the same shared commit, or against the recorded `baseCommit` when the two histories no longer share one. It refuses with 409 `target_branch_changed` (with `branch`) while the target is on another branch than the pull request's `baseBranch`, and with 409 `target_branch_missing` once that branch has been deleted or renamed or 409 `uncommitted_changes` while the target has saved changes that are not committed (unless, for `target_branch_missing` or `uncommitted_changes`, the pull request is already merged, since closing it touches no project files). Projects without branch metadata skip the branch check. The upload repeats both branch checks and the `uncommitted_changes` refusal. `GET` reports `baseBranchMissing: true` once the target branch is gone, so a client can say so before anyone tries to merge. When the target's head is an ancestor of the remix head, the remix has no uncommitted changes and the remix is on the branch the pull request follows, the server writes a merge commit whose tree is the remix head and answers `{merged: true, fastForward: true}`. When the target already has the remix head, the pull request is marked merged under the project's save lock and the answer is `{merged: true, alreadyMerged: true}`. Otherwise it stores the remix head it merged on the pull request as `preparedSourceHead` and answers `{merged: false, merge, expectedHead, sourceHead}`, where `merge` is the three-way merge with `changes`, `conflicts` and `baseHead`. A merge that cannot be prepared answers 409 `pull_merge_unavailable`. The client applies `merge.changes` to the target tree at `expectedHead` and uploads the result with `pullId`, `expectedHead`, `mergeTree` and `mergeSourceHead` (the `sourceHead` it merged). If the remix has moved since, the upload answers 409 `pull_head_changed`. An upload without `mergeSourceHead` is checked against `preparedSourceHead` (or the recorded head before any merge was prepared), so an older client can merge what the server last prepared and fails with 409 `pull_head_changed` if the remix moved after that. A pull request upload must carry `mergeTree` and no `workspace`, `restoreCommit`, `mergeSourceBranch` or `mergeTargetBranch`, or it answers 400. It answers 409 `head_changed` without `expectedHead` or when the target moved, 409 `pull_not_open` once the pull request was closed or merged, and 409 `pull_not_closed` (or 500 on the merge endpoint) if the project saves but the pull request record cannot be marked merged. Merging needs the same edit access as saving the project, so admins and group managers who can edit it can merge too. Once merged, the pull request records the remix head it merged as `headCommit`. `POST /v1/projects/:id/remix/sync` prepares a merge of the original project's current head into a remix. Only a maintainer of the remix who can see inside both projects may call it. It answers `{merge, sourceProjectId, sourceTitle, sourceHead, targetHead, expectedHead}`. `merge.alreadyMerged` is true when the remix already contains the original's head, and `merge.fastForward` when the remix has no commits of its own since. Text conflicts are marked `this remix` and `original`. A history that still stores the whole project as one `project.sb3` file has a single binary conflict for that file, so the choice is the whole remix or the whole original. The client applies the changes to the remix tree at `targetHead` and uploads them with `syncHead` (the `sourceHead`), `expectedHead` and `mergeTree`. The server then writes a merge commit, `Merge changes from `, whose parents are the remix head and the original's head. A sync writes that merge commit even when it could fast-forward. A sync refuses with: From 6a66fa9c291c10e0c2608c7de6543c3fbef0492c Mon Sep 17 00:00:00 2001 From: Mistium <92952823+Mistium@users.noreply.github.com> Date: Tue, 24 Nov 2026 00:41:57 +0000 Subject: [PATCH 09/12] Note UI merge button behavior when baseBranchMissing is set --- docs/backend/storage.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/backend/storage.md b/docs/backend/storage.md index 6cb309e4..ec1202e6 100644 --- a/docs/backend/storage.md +++ b/docs/backend/storage.md @@ -55,7 +55,7 @@ Upload callers hold the project's save lock (`project-history-`). History pr A pull request records the remix's head when it is opened, but an open pull request follows the remix: `GET /v1/projects/:id/pulls/:index`, its `diff` and its `merge` use the current head of the remix branch the pull request was opened from (`headBranch`). A pull request opened before branches were recorded follows the remix's only branch, or keeps its recorded head when the remix has several. If the branch no longer exists, they fall back to the recorded head. Merged and closed pull requests keep the head they had. `GET` shows the live head only to callers who can inspect the pull request. Its `baseCommit` stays the recorded fork point, so loading the pull request does no history work, and the diff response carries the live base. The diff compares the remix head with the closest commit it shares with the head of the target branch (`baseBranch`), or with the recorded base once that branch has been deleted, so changes the remix brought in from the target are not shown as part of the pull request. The `pull` object in a diff response carries that `baseCommit` and `headCommit`. The diff's merge base is cached by the two heads, because the commits behind a head never change, and a cached base is used only while both histories still contain it. Preparing a merge always walks the histories. Reading a project's commits or files with `?pull=&pullTarget=` is limited to commits that belong to that pull request (its recorded base, recorded target head, recorded head, prepared head, live head and live base), and downloading `workspace.mwp?pull=` also requires a signed-in editor of the target project or the owner of the remix. -`POST /v1/projects/:id/pulls/:index/merge` merges against the same shared commit, or against the recorded `baseCommit` when the two histories no longer share one. It refuses with 409 `target_branch_changed` (with `branch`) while the target is on another branch than the pull request's `baseBranch`, and with 409 `target_branch_missing` once that branch has been deleted or renamed or 409 `uncommitted_changes` while the target has saved changes that are not committed (unless, for `target_branch_missing` or `uncommitted_changes`, the pull request is already merged, since closing it touches no project files). Projects without branch metadata skip the branch check. The upload repeats both branch checks and the `uncommitted_changes` refusal. `GET` reports `baseBranchMissing: true` once the target branch is gone, so a client can say so before anyone tries to merge. When the target's head is an ancestor of the remix head, the remix has no uncommitted changes and the remix is on the branch the pull request follows, the server writes a merge commit whose tree is the remix head and answers `{merged: true, fastForward: true}`. When the target already has the remix head, the pull request is marked merged under the project's save lock and the answer is `{merged: true, alreadyMerged: true}`. Otherwise it stores the remix head it merged on the pull request as `preparedSourceHead` and answers `{merged: false, merge, expectedHead, sourceHead}`, where `merge` is the three-way merge with `changes`, `conflicts` and `baseHead`. A merge that cannot be prepared answers 409 `pull_merge_unavailable`. The client applies `merge.changes` to the target tree at `expectedHead` and uploads the result with `pullId`, `expectedHead`, `mergeTree` and `mergeSourceHead` (the `sourceHead` it merged). If the remix has moved since, the upload answers 409 `pull_head_changed`. An upload without `mergeSourceHead` is checked against `preparedSourceHead` (or the recorded head before any merge was prepared), so an older client can merge what the server last prepared and fails with 409 `pull_head_changed` if the remix moved after that. A pull request upload must carry `mergeTree` and no `workspace`, `restoreCommit`, `mergeSourceBranch` or `mergeTargetBranch`, or it answers 400. It answers 409 `head_changed` without `expectedHead` or when the target moved, 409 `pull_not_open` once the pull request was closed or merged, and 409 `pull_not_closed` (or 500 on the merge endpoint) if the project saves but the pull request record cannot be marked merged. Merging needs the same edit access as saving the project, so admins and group managers who can edit it can merge too. Once merged, the pull request records the remix head it merged as `headCommit`. +`POST /v1/projects/:id/pulls/:index/merge` merges against the same shared commit, or against the recorded `baseCommit` when the two histories no longer share one. It refuses with 409 `target_branch_changed` (with `branch`) while the target is on another branch than the pull request's `baseBranch`, and with 409 `target_branch_missing` once that branch has been deleted or renamed or 409 `uncommitted_changes` while the target has saved changes that are not committed (unless, for `target_branch_missing` or `uncommitted_changes`, the pull request is already merged, since closing it touches no project files). Projects without branch metadata skip the branch check. The upload repeats both branch checks and the `uncommitted_changes` refusal. `GET` reports `baseBranchMissing: true` once the target branch is gone, so the UI hides the merge action and tells the viewer to close and reopen the pull request before anyone tries to merge. When the target's head is an ancestor of the remix head, the remix has no uncommitted changes and the remix is on the branch the pull request follows, the server writes a merge commit whose tree is the remix head and answers `{merged: true, fastForward: true}`. When the target already has the remix head, the pull request is marked merged under the project's save lock and the answer is `{merged: true, alreadyMerged: true}`. Otherwise it stores the remix head it merged on the pull request as `preparedSourceHead` and answers `{merged: false, merge, expectedHead, sourceHead}`, where `merge` is the three-way merge with `changes`, `conflicts` and `baseHead`. A merge that cannot be prepared answers 409 `pull_merge_unavailable`. The client applies `merge.changes` to the target tree at `expectedHead` and uploads the result with `pullId`, `expectedHead`, `mergeTree` and `mergeSourceHead` (the `sourceHead` it merged). If the remix has moved since, the upload answers 409 `pull_head_changed`. An upload without `mergeSourceHead` is checked against `preparedSourceHead` (or the recorded head before any merge was prepared), so an older client can merge what the server last prepared and fails with 409 `pull_head_changed` if the remix moved after that. A pull request upload must carry `mergeTree` and no `workspace`, `restoreCommit`, `mergeSourceBranch` or `mergeTargetBranch`, or it answers 400. It answers 409 `head_changed` without `expectedHead` or when the target moved, 409 `pull_not_open` once the pull request was closed or merged, and 409 `pull_not_closed` (or 500 on the merge endpoint) if the project saves but the pull request record cannot be marked merged. Merging needs the same edit access as saving the project, so admins and group managers who can edit it can merge too. Once merged, the pull request records the remix head it merged as `headCommit`. `POST /v1/projects/:id/remix/sync` prepares a merge of the original project's current head into a remix. Only a maintainer of the remix who can see inside both projects may call it. It answers `{merge, sourceProjectId, sourceTitle, sourceHead, targetHead, expectedHead}`. `merge.alreadyMerged` is true when the remix already contains the original's head, and `merge.fastForward` when the remix has no commits of its own since. Text conflicts are marked `this remix` and `original`. A history that still stores the whole project as one `project.sb3` file has a single binary conflict for that file, so the choice is the whole remix or the whole original. The client applies the changes to the remix tree at `targetHead` and uploads them with `syncHead` (the `sourceHead`), `expectedHead` and `mergeTree`. The server then writes a merge commit, `Merge changes from `, whose parents are the remix head and the original's head. A sync writes that merge commit even when it could fast-forward. A sync refuses with: From 277e886e78eb198073dc417b3237756a571fddf9 Mon Sep 17 00:00:00 2001 From: Mistium <92952823+Mistium@users.noreply.github.com> Date: Tue, 24 Nov 2026 00:50:19 +0000 Subject: [PATCH 10/12] Clarify remix sync edit access in storage docs --- docs/backend/storage.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/backend/storage.md b/docs/backend/storage.md index ec1202e6..3e5f6f64 100644 --- a/docs/backend/storage.md +++ b/docs/backend/storage.md @@ -57,7 +57,7 @@ A pull request records the remix's head when it is opened, but an open pull requ `POST /v1/projects/:id/pulls/:index/merge` merges against the same shared commit, or against the recorded `baseCommit` when the two histories no longer share one. It refuses with 409 `target_branch_changed` (with `branch`) while the target is on another branch than the pull request's `baseBranch`, and with 409 `target_branch_missing` once that branch has been deleted or renamed or 409 `uncommitted_changes` while the target has saved changes that are not committed (unless, for `target_branch_missing` or `uncommitted_changes`, the pull request is already merged, since closing it touches no project files). Projects without branch metadata skip the branch check. The upload repeats both branch checks and the `uncommitted_changes` refusal. `GET` reports `baseBranchMissing: true` once the target branch is gone, so the UI hides the merge action and tells the viewer to close and reopen the pull request before anyone tries to merge. When the target's head is an ancestor of the remix head, the remix has no uncommitted changes and the remix is on the branch the pull request follows, the server writes a merge commit whose tree is the remix head and answers `{merged: true, fastForward: true}`. When the target already has the remix head, the pull request is marked merged under the project's save lock and the answer is `{merged: true, alreadyMerged: true}`. Otherwise it stores the remix head it merged on the pull request as `preparedSourceHead` and answers `{merged: false, merge, expectedHead, sourceHead}`, where `merge` is the three-way merge with `changes`, `conflicts` and `baseHead`. A merge that cannot be prepared answers 409 `pull_merge_unavailable`. The client applies `merge.changes` to the target tree at `expectedHead` and uploads the result with `pullId`, `expectedHead`, `mergeTree` and `mergeSourceHead` (the `sourceHead` it merged). If the remix has moved since, the upload answers 409 `pull_head_changed`. An upload without `mergeSourceHead` is checked against `preparedSourceHead` (or the recorded head before any merge was prepared), so an older client can merge what the server last prepared and fails with 409 `pull_head_changed` if the remix moved after that. A pull request upload must carry `mergeTree` and no `workspace`, `restoreCommit`, `mergeSourceBranch` or `mergeTargetBranch`, or it answers 400. It answers 409 `head_changed` without `expectedHead` or when the target moved, 409 `pull_not_open` once the pull request was closed or merged, and 409 `pull_not_closed` (or 500 on the merge endpoint) if the project saves but the pull request record cannot be marked merged. Merging needs the same edit access as saving the project, so admins and group managers who can edit it can merge too. Once merged, the pull request records the remix head it merged as `headCommit`. -`POST /v1/projects/:id/remix/sync` prepares a merge of the original project's current head into a remix. Only a maintainer of the remix who can see inside both projects may call it. It answers `{merge, sourceProjectId, sourceTitle, sourceHead, targetHead, expectedHead}`. `merge.alreadyMerged` is true when the remix already contains the original's head, and `merge.fastForward` when the remix has no commits of its own since. Text conflicts are marked `this remix` and `original`. A history that still stores the whole project as one `project.sb3` file has a single binary conflict for that file, so the choice is the whole remix or the whole original. The client applies the changes to the remix tree at `targetHead` and uploads them with `syncHead` (the `sourceHead`), `expectedHead` and `mergeTree`. The server then writes a merge commit, `Merge changes from `, whose parents are the remix head and the original's head. A sync writes that merge commit even when it could fast-forward. A sync refuses with: +`POST /v1/projects/:id/remix/sync` prepares a merge of the original project's current head into a remix. Only someone who can edit the remix (its maintainers, or admins and group managers who can edit it) and see inside both projects may call it. It answers `{merge, sourceProjectId, sourceTitle, sourceHead, targetHead, expectedHead}`. `merge.alreadyMerged` is true when the remix already contains the original's head, and `merge.fastForward` when the remix has no commits of its own since. Text conflicts are marked `this remix` and `original`. A history that still stores the whole project as one `project.sb3` file has a single binary conflict for that file, so the choice is the whole remix or the whole original. The client applies the changes to the remix tree at `targetHead` and uploads them with `syncHead` (the `sourceHead`), `expectedHead` and `mergeTree`. The server then writes a merge commit, `Merge changes from `, whose parents are the remix head and the original's head. A sync writes that merge commit even when it could fast-forward. A sync refuses with: - 404 when the project is not a remix, or its original no longer exists. - 403 for anyone else, or once the original's source is no longer visible to the caller. From 32651242174c5cb7cd9e4bc95e1519e4adb54e26 Mon Sep 17 00:00:00 2001 From: Mistium <92952823+Mistium@users.noreply.github.com> Date: Tue, 24 Nov 2026 01:28:02 +0000 Subject: [PATCH 11/12] Note source-visibility check on pull-merge upload --- docs/backend/storage.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/backend/storage.md b/docs/backend/storage.md index 3e5f6f64..716a898f 100644 --- a/docs/backend/storage.md +++ b/docs/backend/storage.md @@ -55,7 +55,7 @@ Upload callers hold the project's save lock (`project-history-`). History pr A pull request records the remix's head when it is opened, but an open pull request follows the remix: `GET /v1/projects/:id/pulls/:index`, its `diff` and its `merge` use the current head of the remix branch the pull request was opened from (`headBranch`). A pull request opened before branches were recorded follows the remix's only branch, or keeps its recorded head when the remix has several. If the branch no longer exists, they fall back to the recorded head. Merged and closed pull requests keep the head they had. `GET` shows the live head only to callers who can inspect the pull request. Its `baseCommit` stays the recorded fork point, so loading the pull request does no history work, and the diff response carries the live base. The diff compares the remix head with the closest commit it shares with the head of the target branch (`baseBranch`), or with the recorded base once that branch has been deleted, so changes the remix brought in from the target are not shown as part of the pull request. The `pull` object in a diff response carries that `baseCommit` and `headCommit`. The diff's merge base is cached by the two heads, because the commits behind a head never change, and a cached base is used only while both histories still contain it. Preparing a merge always walks the histories. Reading a project's commits or files with `?pull=&pullTarget=` is limited to commits that belong to that pull request (its recorded base, recorded target head, recorded head, prepared head, live head and live base), and downloading `workspace.mwp?pull=` also requires a signed-in editor of the target project or the owner of the remix. -`POST /v1/projects/:id/pulls/:index/merge` merges against the same shared commit, or against the recorded `baseCommit` when the two histories no longer share one. It refuses with 409 `target_branch_changed` (with `branch`) while the target is on another branch than the pull request's `baseBranch`, and with 409 `target_branch_missing` once that branch has been deleted or renamed or 409 `uncommitted_changes` while the target has saved changes that are not committed (unless, for `target_branch_missing` or `uncommitted_changes`, the pull request is already merged, since closing it touches no project files). Projects without branch metadata skip the branch check. The upload repeats both branch checks and the `uncommitted_changes` refusal. `GET` reports `baseBranchMissing: true` once the target branch is gone, so the UI hides the merge action and tells the viewer to close and reopen the pull request before anyone tries to merge. When the target's head is an ancestor of the remix head, the remix has no uncommitted changes and the remix is on the branch the pull request follows, the server writes a merge commit whose tree is the remix head and answers `{merged: true, fastForward: true}`. When the target already has the remix head, the pull request is marked merged under the project's save lock and the answer is `{merged: true, alreadyMerged: true}`. Otherwise it stores the remix head it merged on the pull request as `preparedSourceHead` and answers `{merged: false, merge, expectedHead, sourceHead}`, where `merge` is the three-way merge with `changes`, `conflicts` and `baseHead`. A merge that cannot be prepared answers 409 `pull_merge_unavailable`. The client applies `merge.changes` to the target tree at `expectedHead` and uploads the result with `pullId`, `expectedHead`, `mergeTree` and `mergeSourceHead` (the `sourceHead` it merged). If the remix has moved since, the upload answers 409 `pull_head_changed`. An upload without `mergeSourceHead` is checked against `preparedSourceHead` (or the recorded head before any merge was prepared), so an older client can merge what the server last prepared and fails with 409 `pull_head_changed` if the remix moved after that. A pull request upload must carry `mergeTree` and no `workspace`, `restoreCommit`, `mergeSourceBranch` or `mergeTargetBranch`, or it answers 400. It answers 409 `head_changed` without `expectedHead` or when the target moved, 409 `pull_not_open` once the pull request was closed or merged, and 409 `pull_not_closed` (or 500 on the merge endpoint) if the project saves but the pull request record cannot be marked merged. Merging needs the same edit access as saving the project, so admins and group managers who can edit it can merge too. Once merged, the pull request records the remix head it merged as `headCommit`. +`POST /v1/projects/:id/pulls/:index/merge` merges against the same shared commit, or against the recorded `baseCommit` when the two histories no longer share one. It refuses with 409 `target_branch_changed` (with `branch`) while the target is on another branch than the pull request's `baseBranch`, and with 409 `target_branch_missing` once that branch has been deleted or renamed or 409 `uncommitted_changes` while the target has saved changes that are not committed (unless, for `target_branch_missing` or `uncommitted_changes`, the pull request is already merged, since closing it touches no project files). Projects without branch metadata skip the branch check. The upload repeats the source-visibility check, both branch checks and the `uncommitted_changes` refusal. `GET` reports `baseBranchMissing: true` once the target branch is gone, so the UI hides the merge action and tells the viewer to close and reopen the pull request before anyone tries to merge. When the target's head is an ancestor of the remix head, the remix has no uncommitted changes and the remix is on the branch the pull request follows, the server writes a merge commit whose tree is the remix head and answers `{merged: true, fastForward: true}`. When the target already has the remix head, the pull request is marked merged under the project's save lock and the answer is `{merged: true, alreadyMerged: true}`. Otherwise it stores the remix head it merged on the pull request as `preparedSourceHead` and answers `{merged: false, merge, expectedHead, sourceHead}`, where `merge` is the three-way merge with `changes`, `conflicts` and `baseHead`. A merge that cannot be prepared answers 409 `pull_merge_unavailable`. The client applies `merge.changes` to the target tree at `expectedHead` and uploads the result with `pullId`, `expectedHead`, `mergeTree` and `mergeSourceHead` (the `sourceHead` it merged). If the remix has moved since, the upload answers 409 `pull_head_changed`. An upload without `mergeSourceHead` is checked against `preparedSourceHead` (or the recorded head before any merge was prepared), so an older client can merge what the server last prepared and fails with 409 `pull_head_changed` if the remix moved after that. A pull request upload must carry `mergeTree` and no `workspace`, `restoreCommit`, `mergeSourceBranch` or `mergeTargetBranch`, or it answers 400. It answers 409 `head_changed` without `expectedHead` or when the target moved, 409 `pull_not_open` once the pull request was closed or merged, and 409 `pull_not_closed` (or 500 on the merge endpoint) if the project saves but the pull request record cannot be marked merged. Merging needs the same edit access as saving the project, so admins and group managers who can edit it can merge too. Once merged, the pull request records the remix head it merged as `headCommit`. `POST /v1/projects/:id/remix/sync` prepares a merge of the original project's current head into a remix. Only someone who can edit the remix (its maintainers, or admins and group managers who can edit it) and see inside both projects may call it. It answers `{merge, sourceProjectId, sourceTitle, sourceHead, targetHead, expectedHead}`. `merge.alreadyMerged` is true when the remix already contains the original's head, and `merge.fastForward` when the remix has no commits of its own since. Text conflicts are marked `this remix` and `original`. A history that still stores the whole project as one `project.sb3` file has a single binary conflict for that file, so the choice is the whole remix or the whole original. The client applies the changes to the remix tree at `targetHead` and uploads them with `syncHead` (the `sourceHead`), `expectedHead` and `mergeTree`. The server then writes a merge commit, `Merge changes from `, whose parents are the remix head and the original's head. A sync writes that merge commit even when it could fast-forward. A sync refuses with: From b50ba2b471cf706129d0cc8e49bde5e6b9ad6dbb Mon Sep 17 00:00:00 2001 From: Mistium <92952823+Mistium@users.noreply.github.com> Date: Tue, 24 Nov 2026 18:19:09 +0000 Subject: [PATCH 12/12] Document targetProjectId in remix sync response shape --- docs/backend/storage.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/backend/storage.md b/docs/backend/storage.md index 716a898f..f8fdc6ce 100644 --- a/docs/backend/storage.md +++ b/docs/backend/storage.md @@ -57,7 +57,7 @@ A pull request records the remix's head when it is opened, but an open pull requ `POST /v1/projects/:id/pulls/:index/merge` merges against the same shared commit, or against the recorded `baseCommit` when the two histories no longer share one. It refuses with 409 `target_branch_changed` (with `branch`) while the target is on another branch than the pull request's `baseBranch`, and with 409 `target_branch_missing` once that branch has been deleted or renamed or 409 `uncommitted_changes` while the target has saved changes that are not committed (unless, for `target_branch_missing` or `uncommitted_changes`, the pull request is already merged, since closing it touches no project files). Projects without branch metadata skip the branch check. The upload repeats the source-visibility check, both branch checks and the `uncommitted_changes` refusal. `GET` reports `baseBranchMissing: true` once the target branch is gone, so the UI hides the merge action and tells the viewer to close and reopen the pull request before anyone tries to merge. When the target's head is an ancestor of the remix head, the remix has no uncommitted changes and the remix is on the branch the pull request follows, the server writes a merge commit whose tree is the remix head and answers `{merged: true, fastForward: true}`. When the target already has the remix head, the pull request is marked merged under the project's save lock and the answer is `{merged: true, alreadyMerged: true}`. Otherwise it stores the remix head it merged on the pull request as `preparedSourceHead` and answers `{merged: false, merge, expectedHead, sourceHead}`, where `merge` is the three-way merge with `changes`, `conflicts` and `baseHead`. A merge that cannot be prepared answers 409 `pull_merge_unavailable`. The client applies `merge.changes` to the target tree at `expectedHead` and uploads the result with `pullId`, `expectedHead`, `mergeTree` and `mergeSourceHead` (the `sourceHead` it merged). If the remix has moved since, the upload answers 409 `pull_head_changed`. An upload without `mergeSourceHead` is checked against `preparedSourceHead` (or the recorded head before any merge was prepared), so an older client can merge what the server last prepared and fails with 409 `pull_head_changed` if the remix moved after that. A pull request upload must carry `mergeTree` and no `workspace`, `restoreCommit`, `mergeSourceBranch` or `mergeTargetBranch`, or it answers 400. It answers 409 `head_changed` without `expectedHead` or when the target moved, 409 `pull_not_open` once the pull request was closed or merged, and 409 `pull_not_closed` (or 500 on the merge endpoint) if the project saves but the pull request record cannot be marked merged. Merging needs the same edit access as saving the project, so admins and group managers who can edit it can merge too. Once merged, the pull request records the remix head it merged as `headCommit`. -`POST /v1/projects/:id/remix/sync` prepares a merge of the original project's current head into a remix. Only someone who can edit the remix (its maintainers, or admins and group managers who can edit it) and see inside both projects may call it. It answers `{merge, sourceProjectId, sourceTitle, sourceHead, targetHead, expectedHead}`. `merge.alreadyMerged` is true when the remix already contains the original's head, and `merge.fastForward` when the remix has no commits of its own since. Text conflicts are marked `this remix` and `original`. A history that still stores the whole project as one `project.sb3` file has a single binary conflict for that file, so the choice is the whole remix or the whole original. The client applies the changes to the remix tree at `targetHead` and uploads them with `syncHead` (the `sourceHead`), `expectedHead` and `mergeTree`. The server then writes a merge commit, `Merge changes from `, whose parents are the remix head and the original's head. A sync writes that merge commit even when it could fast-forward. A sync refuses with: +`POST /v1/projects/:id/remix/sync` prepares a merge of the original project's current head into a remix. Only someone who can edit the remix (its maintainers, or admins and group managers who can edit it) and see inside both projects may call it. It answers `{merge, targetProjectId, sourceProjectId, sourceTitle, sourceHead, targetHead, expectedHead}`. `merge.alreadyMerged` is true when the remix already contains the original's head, and `merge.fastForward` when the remix has no commits of its own since. Text conflicts are marked `this remix` and `original`. A history that still stores the whole project as one `project.sb3` file has a single binary conflict for that file, so the choice is the whole remix or the whole original. The client applies the changes to the remix tree at `targetHead` and uploads them with `syncHead` (the `sourceHead`), `expectedHead` and `mergeTree`. The server then writes a merge commit, `Merge changes from `, whose parents are the remix head and the original's head. A sync writes that merge commit even when it could fast-forward. A sync refuses with: - 404 when the project is not a remix, or its original no longer exists. - 403 for anyone else, or once the original's source is no longer visible to the caller.