Skip to content

feat: label merges that do not contain their PR; request changes blocks merge (E3) - #373

Merged
PastaPastaPasta merged 5 commits into
masterfrom
feat/e3-merge-integrity
Oct 4, 2026
Merged

PastaPastaPasta merged 5 commits into
masterfrom
feat/e3-merge-integrity

Conversation

@PastaPastaPasta

@PastaPastaPasta PastaPastaPasta commented Oct 4, 2026 •

Copy link
Copy Markdown
Owner

What

Readers can now tell when a recorded merge does not contain its pull request, and a standing request for changes blocks merging.

  • Merge check (web and dg). A merged PR shows whether its merge commit contains the PR, is a squash or a rebase of it, or does not contain its commits (in red). dg pr verify <repo> <n> fetches the base and the head and says the same; dg pr view says it when the current repository already has the commits.
  • dg pr merge --event-only refuses a commit that does not contain the PR, and refuses a writer on a protected base (only a maintainer can push there, so only a maintainer can record a merge there).
  • Request changes blocks merge. When the branch policy requires approvals, a request for changes from a maintainer or writer whose approval would count blocks the merge in the web and in dg, until they approve or the review is dismissed. A maintainer can still bypass it, and the bypass is recorded.

Why

Consensus admits a merge transition naming any commit the base once held, and a merged PR is final. With stock dg, a writer on a protected base could permanently mark any open PR "merged" by naming an old tip of main, and readers showed it as an ordinary merge. Platform cannot read git, so this has to be a reader rule. Request changes was computed but never blocked anything, unlike GitHub.

How

  • Shared reader rule forge_core::rules::merge_check / forge-web/lib/rules/merge-content.ts, with 19 merge_content__* conformance vectors run in both languages. It works from git facts: whether the head is in the merge, whether the merge is built on the base's previous tip, and three tree-level diffs. A fact that can't be read gives unknown, never missing.
  • dg gathers the facts with git merge-base --is-ancestor and git diff-tree. A shallow repository or a failed walk counts as unknown. The web gathers them through the PR comparison's object readers once the comparison has loaded, so the page makes no extra Platform requests.
  • meets_policy / meetsPolicy return blockedBy. 7 new policy__* vectors, and the existing ones gain the field.
  • Docs: docs/guides/collaborating.md, docs/contracts/forge-v2.md (both conventions).

How tested

  • Rust fmt, clippy -D warnings, and cargo test -p dg -p forge-core. Web: tsc, eslint and the full vitest run (5,675 tests, including a new merge-check.test.ts against real git objects). dg has a git-backed unit test covering a merge commit, a squash, an unrelated commit and an old tip.
  • Live on devnet sakura, scratch repo 2D3Akz31nwDupidzP4hJ16s8tqjByYe55Vtg1iQN1MrZ/mp-merge-a:
    • --event-only naming an old tip: refused with "does not contain PR build: make the Rust workspace buildable and pin the Platform SDK #1" (E201).
    • A writer's --event-only on a protected main: refused (E601).
    • The deployed dg still records that fake merge (the hole this closes). After that, the new dg pr verify and dg pr view print ! merged as fc857f6c9986: does not contain this PR's commits, and the web labels it in red.
    • dg pr merge --squash gives "is a squash of this PR"; --no-ff gives "contains this PR's commits".
    • A policy of one approval, with one maintainer approving and another requesting changes: dg pr merge is refused with "changes requested by 1 reviewer" (E804), and the web merge box names it.
  • Evidence: /Users/pasta/workspace/dash-forge-qa/evidence/p0/merge-power/. It holds the dg transcripts mp-merge-a-*.txt/.json and the screenshots after-pr1-fake-merge-{dark,light,390-dark}.png, after-pr2-squash-light.png, after-pr3-merge-commit-light.png, after-pr4-changes-requested-light.png, plus the before-* ones from forge.dashhq.org.

Limits

  • The web check runs on the PR detail page. List rows keep the cheaper "found on the base" check.
  • A merge whose commit was never a base tip keeps its existing "merge commit not found on the base" label and is not checked further.
  • Still to come in this epic: the relay flag, the "rules at merge time" audit, web "Edit base" and "Record merge".

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added dg pr verify to report whether a recorded merge contains a pull request’s changes, including through a squash or rebase.
    • Pull request pages and command output now show merge-content verdicts, including combined files and cases that cannot be checked.
  • Bug Fixes
    • Event-only merges are refused when the commit does not contain the pull request or its status cannot be verified.
    • Qualifying, unresolved requests for changes now block merges when approvals are required, with blocking reviewers shown in policy status.

PastaPastaPasta and others added 3 commits October 4, 2026 12:19
…ks merge

A merge transition only has to name a commit the base once held, so a member could mark any PR merged by naming an old tip. A shared reader rule (forge-core merge_check, web merge-content.ts, merge_content__* vectors) now labels a recorded merge as containing the PR, a squash or a rebase of it, or not containing it. The web shows it next to a merged PR's state; dg pr verify fetches and checks; dg pr view says it when the commits are local. dg pr merge --event-only refuses a commit that does not contain the PR, and refuses writers on a protected base.

With required approvals, a standing request for changes from a reviewer whose approval would count now blocks the merge in both clients until they approve or the review is dismissed (meets_policy blockedBy, policy__* vectors).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A squash that leaves alone a path the base already changed like the PR now counts. dg treats a failed or shallow ancestry walk as unknown, checks the head as it was at the merge, skips merges whose commit was never a base tip (as the web does), fetches every branch when the base was deleted, and no longer fails when the PR head cannot be fetched. Both clients stop after the merge is known not to build on the base. Combined paths sort by code point via compareStrings.

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

coderabbitai Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 72489bf9-2242-4fb1-857a-a4d2c5f7a9b5
📥 Commits

Reviewing files that changed from the base of the PR and between e5ba904 and 34ca136.

📒 Files selected for processing (56)
  • crates/dg/src/errors.rs
  • crates/dg/src/main.rs
  • crates/dg/src/pr/mod.rs
  • crates/dg/src/pr/verify.rs
  • crates/forge-core/src/collab/v2.rs
  • crates/forge-core/src/rules.rs
  • crates/forge-core/src/rules/merge_check.rs
  • crates/forge-core/src/rules/review.rs
  • docs/contracts/forge-v2.md
  • docs/guides/collaborating.md
  • forge-contracts/vectors/merge_content__contains_fast_forward.json
  • forge-contracts/vectors/merge_content__contains_merge_commit.json
  • forge-contracts/vectors/merge_content__missing_base_rewritten.json
  • forge-contracts/vectors/merge_content__missing_different_content.json
  • forge-contracts/vectors/merge_content__missing_extra_path.json
  • forge-contracts/vectors/merge_content__missing_never_a_tip.json
  • forge-contracts/vectors/merge_content__missing_old_tip.json
  • forge-contracts/vectors/merge_content__missing_path_left_out.json
  • forge-contracts/vectors/merge_content__rebase_exact.json
  • forge-contracts/vectors/merge_content__squash_base_already_had_a_change.json
  • forge-contracts/vectors/merge_content__squash_combined_with_a_base_change.json
  • forge-contracts/vectors/merge_content__squash_deletes_like_the_pr.json
  • forge-contracts/vectors/merge_content__squash_exact.json
  • forge-contracts/vectors/merge_content__squash_keeping_the_base_side_is_combined.json
  • forge-contracts/vectors/merge_content__squash_without_the_ancestry_walk.json
  • forge-contracts/vectors/merge_content__unknown_base_change_unread.json
  • forge-contracts/vectors/merge_content__unknown_diff_unread.json
  • forge-contracts/vectors/merge_content__unknown_head_walk_unfinished.json
  • forge-contracts/vectors/merge_content__unknown_nothing_read.json
  • forge-contracts/vectors/policy__any_member_counts_writer.json
  • forge-contracts/vectors/policy__any_member_excludes_triage_and_reader.json
  • forge-contracts/vectors/policy__author_approval_not_counted.json
  • forge-contracts/vectors/policy__author_plus_other_member.json
  • forge-contracts/vectors/policy__changes_requested_by_an_approver_blocks.json
  • forge-contracts/vectors/policy__changes_requested_then_approved_unblocks.json
  • forge-contracts/vectors/policy__dismissed_approval_not_counted.json
  • forge-contracts/vectors/policy__dismissed_changes_request_unblocks.json
  • forge-contracts/vectors/policy__maintainers_only_excludes_writer.json
  • forge-contracts/vectors/policy__no_required_approvals_no_block.json
  • forge-contracts/vectors/policy__stale_approval_not_counted.json
  • forge-contracts/vectors/policy__stale_changes_request_does_not_block.json
  • forge-contracts/vectors/policy__triage_changes_request_does_not_block.json
  • forge-contracts/vectors/policy__writer_changes_request_does_not_block_maintainers_only.json
  • forge-contracts/vectors/policy__writer_promoted_to_maintainer_counts.json
  • forge-contracts/vectors/policy__zero_required_always_met.json
  • forge-web/components/repo/pull-content.tsx
  • forge-web/lib/repo/issues.ts
  • forge-web/lib/repo/review-parity.live.test.ts
  • forge-web/lib/rules/conformance.test.ts
  • forge-web/lib/rules/merge-content.ts
  • forge-web/lib/rules/review.ts
  • forge-web/lib/rules/v2.ts
  • forge-web/lib/view/merge-check.test.ts
  • forge-web/lib/view/merge-check.ts
  • forge-web/lib/view/pull-actions.test.ts
  • forge-web/lib/view/pull-actions.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The pull request adds Git-based checks for whether recorded merges contain pull-request changes. It exposes those checks in CLI and web views and adds a guard for event-only merges. Approval policy results also identify eligible reviewers whose current change requests block merging.

Changes

Recorded merge integrity

Layer / File(s) Summary
Merge facts and verdict rules
crates/forge-core/src/collab/v2.rs, crates/forge-core/src/rules/*, forge-contracts/vectors/merge_content__*.json
Patch views retain ordered base-tip history. The shared rules classify merge facts as contains, squash, rebase, missing, or unknown, and report paths combined with base changes. Conformance vectors cover these outcomes and unreadable facts.
Git fact readers and verification entry points
crates/dg/src/main.rs, crates/dg/src/errors.rs, crates/dg/src/pr/*, forge-web/lib/repo/issues.ts, forge-web/lib/view/merge-check*
dg pr verify fetches the relevant commits and reports a verdict. The web comparison reader gathers ancestry and tree-change facts. Pull views expose the merge commit OID and merge time for checking.
Merge views and event-only checks
crates/dg/src/pr/mod.rs, forge-web/components/repo/pull-content.tsx, docs/contracts/forge-v2.md, docs/guides/collaborating.md
CLI and web pull views display merge-content results. Event-only merge recording accepts contains, squash, or rebase verdicts and applies the protected-branch precheck. Documentation describes the checks and verdicts.

Change-request review policy

Layer / File(s) Summary
Policy status and conformance cases
crates/forge-core/src/rules/review.rs, forge-web/lib/rules/review.ts, forge-contracts/vectors/policy__*.json, forge-web/lib/repo/review-parity.live.test.ts
Policy results include blockedBy. An eligible reviewer’s standing change request on the current head blocks policy satisfaction when approvals are required. Vectors cover role eligibility, stale and dismissed reviews, and updates to review verdicts.
Policy reporting and guidance
crates/dg/src/pr/mod.rs, forge-web/components/repo/pull-content.tsx, forge-web/lib/view/pull-actions*, docs/contracts/forge-v2.md, docs/guides/collaborating.md
CLI and web output report blocking change requests separately from insufficient approval counts. Fixtures include the blocker field, and documentation describes the blocking rule.

Priority: ➖ Normal

Estimated code review effort: 4 (Complex) | ~60 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant DgVerify
  participant ScratchRepo
  participant MergeRules
  User->>DgVerify: request verification for a repository and pull request
  DgVerify->>ScratchRepo: fetch base and pull request objects
  DgVerify->>ScratchRepo: read merge ancestry and tree changes
  DgVerify->>MergeRules: pass Git-derived merge facts
  MergeRules-->>DgVerify: return verdict and combined paths
  DgVerify-->>User: print JSON or text result
Loading

Merge Risk: ⚪ Minimal · up to 34ca1

The identified concerns do not block merge verification or event-only merge safeguards. No actionable merge-blocking issue remains after normal checks.

Security Architecture Review

Security architecture risk: 🟡 Moderate · up to 34ca1

The change strengthens merge checks and review blocking, but a positive squash or rebase result does not establish that every PR change survived in overlapping files. That matters when verifying that a security-sensitive fix landed. Writer and maintainer requirements limit exposure; concurrency and final enforcement remain only partially verified.

Retained concerns

  • Medium · security · inferred: The new positive squash/rebase classification permits a differing blob, or no merge-side change, wherever the base also changed the PR path. An authorized writer can therefore pass the new event-only gate and obtain a positive verification label while PR changes on overlapping paths are absent. The combined-path list discloses overlap, but cannot prove that the PR contribution survived. Recording such a merge was already possible; the introduced concern is the stronger integrity assurance attached to it.
Security review details

Security Blast Radius

  • inferred — The identified concern affects integrity assurance for individual PR merge records and downstream readers of those records. Exploitation requires merge-recording authority in the repository and a qualifying historical base commit; it does not itself grant Git push privileges, disclose private data or cross repository ownership boundaries.

Security Findings and Attack Paths

  • inferred — An authorized member can select a historical base commit whose qualifying path comparisons omit PR contributions on overlapping files. The new rule can classify it positively, allowing event-only recording and a squash/rebase label. Explicit combined-path disclosure and the intentional conformance case limit the claim: this is an integrity-assurance concern, not a newly introduced authorization bypass.

Trust Boundaries and Controls

  • observed — Merge-content and approval-policy enforcement remain client rules over a pre-existing consensus boundary. The CLI requires writer authority, limits explicit policy override to maintainers, and now applies the protected-base precheck to event-only recording. These checks do not turn the recorded transition into consensus-verified Git inclusion.
  • observed — The new CLI verification path uses a temporary repository, validates branch and head fields before fetching, and selects an authenticated read environment for private repositories. Web fact collection uses the comparison's existing readers and releases its history walker in finally.

Resilience and Maintainability Implications

  • observed — The protected-pattern lookup still returns success on read failure, and merge validation uses an earlier PR/policy snapshot before posting a transition without an explicit head or policy version parameter. These limitations predate this change; final consensus handling of concurrent head and policy changes remains incompletely inspected.

Hardening Proposals

  • proposed — Separate verified content inclusion from overlapping-path compatibility. When PR contribution cannot be established on combined paths, expose a qualified or indeterminate result rather than an unqualified squash/rebase assurance, and make the event-only acceptance policy explicit.
  • proposed — For stronger future client enforcement, fail closed when event-only protected-base authority cannot be established, and bind or revalidate the checked head and policy at the terminal merge transition. This would address existing control gaps rather than a demonstrated privilege regression in this PR.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the two main changes: labeling merges that do not contain their PR and blocking merges when qualifying reviewers request changes.
Docstring Coverage ✅ Passed Docstring coverage is 81.16% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 69 functions across 19 files. (37 skipped: …
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

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