Skip to content

feat(web): merge pull requests in the browser (fast-forward and disjoint merges) - #61

Merged
PastaPastaPasta merged 6 commits into
masterfrom
feat/web-launch-ux-c2
Sep 27, 2026
Merged

PastaPastaPasta merged 6 commits into
masterfrom
feat/web-launch-ux-c2

Conversation

@PastaPastaPasta

Copy link
Copy Markdown
Owner

What

Web launch UX "C2": maintainers and writers can merge a pull request in the browser. forge-v2, public repos, desktop. It stacks on #58 (C1).

What the browser merges. File contents are never merged in the browser (product decision).

  • Fast-forward when the head descends from the base tip.
  • A merge commit only when the two sides changed disjoint sets of paths since their single merge base. Each path takes the side that changed it, and deletions that together empty a directory drop it, as git does. The commit is authored and committed by the merger (Settings name and email), with the message Merge pull request #n from <branch>.
  • Everything else shows "Conflicts or overlapping changes — merge with dg pr merge" plus the dg pr checkout line. That covers:
    • a path, or an ancestor or descendant of it, touched (add, modify, delete, mode change) by both sides, even identically;
    • a directory one side emptied while the other added under it;
    • criss-cross histories with several merge bases.

fsck parity. Every commit and tree the base branch would gain is checked as git fsck --strict does, fast-forwards included. checkMerge runs the same pack walk as runMerge, so the button never offers a merge the run then refuses. The checks:

  • commit headers in git's order;
  • idents, and dates up to 2^63−1;
  • no NUL anywhere in a commit;
  • tree modes, byte order and duplicates;
  • names: UTF-8, at most 4096 bytes, and no .git look-alikes, using exact ports of git's is_ntfs_dotgit, is_ntfs_dot_generic (including the gi7eba-style fall-back short names) and is_hfs_dot_generic;
  • no null-oid entries;
  • no trees deeper than 2048;
  • .gitmodules and .gitattributes only as files, .gitignore and .mailmap never as symlinks.

A new or changed .gitmodules or .gitattributes anywhere is refused in the browser, because git checks their contents and the browser does not. A merge past the walk or read limits is refused as "too large", not reported as an error.

The run. The step list is:

  1. fetch
  2. merge
  3. build the pack and verify its closure against the base repo's own reader
  4. upload to the merger's storage profile, or Platform after a priced question
  5. write the kind-0 packManifest
  6. write the kind-1 locator fragment (best effort)
  7. update the ref (refUpdate / protectedRefUpdate; the base tip is re-read first)
  8. write the merge event

Every step is resumable. A failure after the upload names exactly which documents already exist.

Removed: isomorphic-git, the diff3 text driver, and the in-memory git fs.

Tests

  • lib/merge/git-parity.test.ts (real git; skipped only when git is absent):
    • (a) random pairs of tree edits: every file mode (including symlinks and gitlinks), renames, directory moves, file↔directory swaps, identical adds on both sides. The browser refuses exactly when a pure file-level statement of the rule says so. Whenever the browser calls a merge clean, git merge-tree --write-tree is clean and writes the identical tree oid.
    • (b) random mutations of commits and trees, plus trees naming git's special files in every mode. The web accepts nothing git fsck --strict rejects.
    • CI runs 300 cases per property. Locally all passed at 3000 cases on each of five seeds (20260926, 1, 2, 3, 7), set with FORGE_PARITY_CASES / FORGE_PARITY_SEED.
  • lib/merge/reattack.test.ts: every repro from the third adversarial review. 20 of its 32 tests fail on the previous commit; the other 12 pin behaviour that must stay allowed (git-accepted names, the 2^63−1 date, 2048 levels, a duplicate parent, an unchanged .gitmodules, a clean rename). All 32 pass now.
  • lib/merge/security.test.ts, engine.test.ts, runner.test.ts, verify.test.ts, locator.test.ts: earlier review regressions, the pack closure, and the step runner.
  • pnpm typecheck, pnpm lint, pnpm test pass.
  • Live moutai e2e/v2-pulls.spec.ts passed 7/7 with the disjoint-path engine. c7 merges a divergent PR in the browser with a merge commit stored on Platform, and the PR folds as merged. The later review follow-ups did not touch that path. c7 will be run again against the deployed site after merge.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 15 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 24349ff5-12cd-4a37-9e4f-975dfdaefd94

📥 Commits

Reviewing files that changed from the base of the PR and between d9c67eb and 762e82d.

⛔ Files ignored due to path filters (1)
  • forge-web/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (35)
  • docs/design/ux-dx-spec.md
  • forge-web/app/settings/page.tsx
  • forge-web/components/display-prefs-panel.tsx
  • forge-web/components/repo/merge-panel.tsx
  • forge-web/components/repo/merge-upload.tsx
  • forge-web/components/repo/pull-content.tsx
  • forge-web/components/repo/pull-diff.tsx
  • forge-web/components/repo/pull-merge.tsx
  • forge-web/e2e/v2-pulls.spec.ts
  • forge-web/lib/merge/client.ts
  • forge-web/lib/merge/engine.test.ts
  • forge-web/lib/merge/engine.ts
  • forge-web/lib/merge/git-oracle.ts
  • forge-web/lib/merge/git-parity.test.ts
  • forge-web/lib/merge/locator.test.ts
  • forge-web/lib/merge/locator.ts
  • forge-web/lib/merge/merge-seed.live.test.ts
  • forge-web/lib/merge/merge.worker.ts
  • forge-web/lib/merge/objects.ts
  • forge-web/lib/merge/pack-writer.ts
  • forge-web/lib/merge/protocol.ts
  • forge-web/lib/merge/reattack.test.ts
  • forge-web/lib/merge/runner.test.ts
  • forge-web/lib/merge/runner.ts
  • forge-web/lib/merge/security.test.ts
  • forge-web/lib/merge/verify.test.ts
  • forge-web/lib/merge/verify.ts
  • forge-web/lib/repo/push.ts
  • forge-web/lib/rules/index.ts
  • forge-web/lib/rules/oid.ts
  • forge-web/lib/view/git-objects.ts
  • forge-web/lib/view/prefs.ts
  • forge-web/lib/view/pull-actions.test.ts
  • forge-web/lib/view/pull-actions.ts
  • forge-web/lib/view/pull-diff.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

PastaPastaPasta and others added 6 commits September 27, 2026 05:22
A merge engine in a Web Worker: fast-forward detection, or a clean 3-way merge through isomorphic-git over a virtual fs backed by the browse readers, and a non-thin pack of only the objects the base lacks. The button states follow ux-dx-spec 5.7. A resumable step runner uploads through lib/storage (the merger's policy; Platform only after a priced confirm), writes the kind-0 manifest, publishes the kind-1 index fragment at its real packRef, moves the base branch (protected when it matches), and posts the merge event. Partial failures name which documents exist.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…retry

Critical: the pack walk skipped a tree it had taken under different same-path parents, so a revert inside a PR or subtrees swapped across a merge could leave a blob out. It now memoizes by (tree, parents), with regression tests. As a hard net, before anything is uploaded, the new tip's closure is verified against the pack plus the base repo, and a gap stops the merge with nothing written.

A merge run is tied to its base tip and head: a changed tip starts over, and the base ref is re-read just before the ref update, which stops if the branch moved. Binary or non-UTF-8 files both sides changed are conflicts (a text-only merge driver), never a corrupted clean merge. Protected patterns are read fresh for the ref update. The check worker aborts when superseded, and worker failures name their phase. sourceRefName goes into the message only when it is a legal ref name. The merge identity is required for merge commits only, the local timezone is used, and only mergers resolve the readers. Dead code and the unused buffer dependency removed.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Commits and trees are read as git reads them and checked as fsck would (one tree first, contiguous parents, then author and committer; git modes, names and order in trees). A merge refuses any history that fails, so a head carrying two tree/parent sets can no longer look like a fast-forward while git sees a revert.

The closure check runs only against the base repo's own reader (never the fork fallback), and re-reads the head's commits, trees and blobs through it rather than trusting an index. The button waits for the base repo to load. The base must be an existing plain branch (check-ref-format, parity with dg's require_branch_ref) and the head a full oid, checked in the panel and again before any paid step. The pack walk decides tree against blob by the object and skips only on the same mode and oid, never on a gitlink. The check has a 100k-read budget and a 60 s timeout, and files over 1 MiB are conflicts. The title is one bounded line. Protected routing reads the complete config timeline. Private repos are not merged in the browser. The Platform price covers the index fragment, and the pack size and object count show before any upload. Each fix has a regression test that failed before it.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Commits are checked on their raw bytes: they must begin with 'tree ', with no BOM (which decoders dropped) and no NUL in the header, and dates must not be zero-padded. Blob-mode entries must name blobs, never commits or tags. Tree names must be UTF-8 (isomorphic-git would rewrite others) and not look like .git on any filesystem, and .gitmodules must not be a symlink.

After the three-way merge, the merged tree is audited against both sides: a path both sides changed where one changed its type (file to symlink) is a conflict, as git's 'distinct types'. Symlink and submodule targets are never invented. Every written tree passes the fsck order check, so check and run agree.

Real git judges the result: merges over directories, symlinks, executables, gitlinks and non-ASCII names pass fsck --strict, log and clone, and a property test mutates commits and trees and asserts the web never accepts what git's object checks reject. These tests skip when git is not installed.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Product decision: the browser never merges file contents. It fast-forwards, or writes a merge commit only when the two sides changed disjoint paths since their single merge base; a path (or an ancestor or descendant of it) touched by both, a directory one side emptied while the other added under it, and criss-cross histories are refused with 'Conflicts or overlapping changes - merge with dg pr merge'. Deletions that together empty a directory drop it, as git does. isomorphic-git, the diff3 driver and the in-memory fs are removed.

fsck parity on every new commit and tree, fast-forwards included (checkMerge runs the pack walk too, so check and run agree): exact ports of is_ntfs_dot_generic (gi7eba fall-back names) and is_hfs_dot_generic; .gitmodules/.gitattributes only as files and never new or changed in the browser; .gitignore/.mailmap not as symlinks; null-oid entries; names over 4096 bytes; trees deeper than 2048; dates over 2^63-1; a NUL anywhere in a commit. The read budget counts distinct objects, repeated tree visits have their own cap, and a limit is a 'too large' refusal rather than an error. The commit's timezone is the one in force at its timestamp.

git-parity.test.ts gains two differential properties against real git: the browser refuses exactly by the file-level rule and a clean merge is the tree git merge-tree --write-tree writes, and the web accepts nothing git fsck --strict rejects. reattack.test.ts holds the third review's repros.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
MalformedObjectError used a constructor parameter property, which Node's type stripping cannot run; master's render fuzz workers load this module that way.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant