Skip to content

feat(cli): dg review parity (review-parity PR 7) - #76

Merged
PastaPastaPasta merged 7 commits into
masterfrom
feat/dg-review-parity
Sep 27, 2026
Merged

PastaPastaPasta merged 7 commits into
masterfrom
feat/dg-review-parity

Conversation

@PastaPastaPasta

@PastaPastaPasta PastaPastaPasta commented Sep 27, 2026 •

Copy link
Copy Markdown
Owner

Review parity for the CLI: PR 7 of docs/design/review-parity-spec.md (§2.5 C1–C13, §7 PR 7). It is built on master's forge-core Collab API (#48/#56): post_target_event, patches_from_branch, PatchView.head, and review/comment with anchors and reviewId. It is stacked on F-1's document replace (Collab::update_target), which this PR carries as its first commit, and wired into #68's seal_if_private.

Commands

Command Spec
dg pr review … --file P --line N [--start-line M] [--side old|new] --body … (repeatable), --suggest TEXT, summary --body/--body-file C1, R1, R3, R5
dg pr review … --pending keeps the comments in a local draft (nothing is written); a later --approve/--request-changes/--comment submits 1 review + N comments; --resume; --discard C1, R1, R2
dg pr comment (general, inline, --reply-to) C2, R2, R6
dg pr view --comments: threads grouped under path:line / path:3-5 (old), outdated / resolved markers, suggestions, a Reviewers list (approved / changes requested / commented / awaiting / stale / dismissed / doesn't count, re-requested), the "new commits since your review" marker, the policy status C3, R7, R8, R9, R11, R12, R13
dg pr edit --title/--body/--body-file (a replace; a re-run writes nothing) C6, P5, R15
dg pr sync [--head]; git push of your PR's branch moves its head (dash.prAutoSync, default on) C6, R14
dg pr create --draft, dg pr ready, dg pr draft C7, P6
dg pr resolve / unresolve (any comment of a thread) C8, R7
dg pr request-review / unrequest-review (id or @name; re-request after a review) C9, R9
dg pr dismiss-review --reason C10, R11
dg pr checks (newest checkRun per name on the head; trusted = current member) C4, P3
dg pr commits C5, P2
dg pr merge --squash [--message] (Co-authored-by per other author), --delete-branch C11, M1, M7
dg pr update-branch (merge the base into the PR branch, then a head update) C12, M6
dg pr suggestion apply <ids>… | --all (one commit on the PR branch with Forge-Suggestion: trailers, then a head update) C13, R5

Every command has --json with a stable shape (documented in the scenario's assertions), and all have E-codes. New in this PR: E107 "suggestion not applicable", for overlapping suggestions, an older head, the old side, or lines that no longer exist. "Not a writer of the source repo" reuses E601 and names the source repo.

Built on #66 (repo settings):

forge-core

  • comment_props / review_props: pure builders. Collab::comment and Collab::review wrap them and call seal_if_private (feat(private): seal issues, pull requests, comments and reviews in the CLI #68).
  • Collab::create_once(repo, ContentKind, props, saved, persist): a single create that is resumable across runs. The signed transition is persisted before its first broadcast and replayed byte for byte. Sealing happens only when a fresh transition is signed. The review submit is built on it: the review first (with commentCount), then each comment (with reviewId). The draft file records each intent and landed id, so an interrupted submit finishes on re-run without writing anything twice.
  • Collab::check_runs / newest_check_runs / CheckRun: the first checkRun reader. I-1 extends its trust rule once runner memberships exist. The e2e seeds a run through a test-only example (examples/seed_check_run.rs), so no public writer is added.
  • Collab::prs_following: the open PRs of a pushed branch, found through the sourceRef index.
  • Patch.repo_id.

git-remote-dash

pr_sync.rs: after a push, each moved branch's open PRs whose author is the signer get a headUpdate, logged as PR #7 in o/r follows this branch: updating its head (≈ 0.00072 DASH). For other people's PRs, or with dash.prAutoSync=false, the helper prints the dg pr sync line instead. A failure here never fails the push. The commands that push to a PR branch on the user's behalf (suggestion apply, update-branch) turn auto-sync off and post the head update themselves.

Hardening

  • Before any dash:// fetch, the PR's base ref must be a plain branch and its head a hex oid (require_git_safe in fetch_base_and_head). This also covers update-branch and suggestion apply, which previously put an unchecked base into a refspec.
  • The source branch is checked with require_branch_ref before it becomes a push destination.

Fuzz (asked alongside)

  • parseSuggestions (web) was quadratic. Its fence trim /^[ \t\r]+|[ \t\r]+$/g took 180 ms at 20 KB of spaces and hung the 1 MiB batch past its 60 s deadline. It is now a linear scan. applySuggestion also no longer spreads a large replacement into splice(...), which would overflow the stack at 1 MiB.
  • The parser moved to lib/rules/suggestion.ts (no imports), so the fuzz worker can load it.
  • render-fuzz.test.ts gains adversarial, 1 MiB and random batches for parseSuggestions and applySuggestion, with the same budgets as the other renderers (≤250 ms per input at 20 KB, ≤3 s at 1 MiB). They fail on the old regex (a 1 MiB hang) and pass now.
  • The Rust parse_suggestions / apply_suggestion were already linear. They get bounded-time tests with the same budgets (rules::review::bounded_time).

Tests

  • CLI e2e, live on moutai: new e2e/cli/scenarios/21-review-round-trip.sh passed 40/40 (log in QA evidence). It follows the task's round trip:
    1. The contributor opens a draft PR from a fork, then ready.
    2. The maintainer builds a pending review of 3 inline comments (a line; a 3–5 range on the old side; a suggestion), which spends nothing. The submit as request changes is cut after 2 of 4 documents, and re-running the same command finishes it with nothing duplicated (the same review id, 3 of 3 comments).
    3. A stranger's resolve gets E601.
    4. The contributor runs suggestion apply --all (trailer present, head follows), then git pushes one more commit and the helper moves the head (prSync).
    5. The maintainer sees "new commits since your review", with all threads outdated and the review stale. They resolve all threads, request and unrequest COLLAB, reply, and approve.
    6. dg pr checks reads a seeded run, dg pr commits lists 3, and edit is idempotent.
    7. merge --squash: the base tip is one commit on the old base, with the head's tree and Co-authored-by.
  • Request budget: dg pr view measured 23 DAPI requests, counted from the SDK's dapi_client::dispatch trace (7 are getDataContract). The scenario asserts ≤ 30, with a TODO for P-5 to tighten it once the contract memo lands.
  • CLI↔web fold cross-check: forge-web/e2e/review-round-trip.spec.ts ran with Playwright against the master web build, served locally (moutai). It reads the fold dg pr view --json produced and checks the page shows the same thing: title, merged, folded head, 2 head updates, both reviews with their commits and verdicts, the 3 threads as "4 comments on an older version" with the same anchors (including lines 3–5 (old)), 3 "resolved a conversation" entries, and the approval fold. It passed.
  • Unit tests: the inline flag grouping (by command-line position), thread grouping (reply chains, cycles), all reviewer standings, the new-commits marker, draft round-trip and estimates, suggestion planning and overlap refusal (E107), trailers, squash messages, and a malformed base/head never reaching git.
  • cargo clippy --all-targets -D warnings and cargo test pass for forge-core, dg and git-remote-dash. Web typecheck, lint and vitest (rules + fuzz) pass.

QA evidence: dash-forge-qa/evidence/impl/feat-dg-review-parity/. It holds the scenario log, dg pr view --comments output, the fold JSON, and web screenshots of the outdated threads and the timeline.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 56 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: 53a6ef8c-d9fe-4e89-8dbc-50885c318f5a

📥 Commits

Reviewing files that changed from the base of the PR and between a420fb5 and 44cfd2d.

📒 Files selected for processing (28)
  • crates/dg/src/common.rs
  • crates/dg/src/errors.rs
  • crates/dg/src/git.rs
  • crates/dg/src/issue.rs
  • crates/dg/src/main.rs
  • crates/dg/src/pr/branch.rs
  • crates/dg/src/pr/inline.rs
  • crates/dg/src/pr/mod.rs
  • crates/dg/src/pr/review.rs
  • crates/dg/src/pr/state.rs
  • crates/dg/src/pr/threads.rs
  • crates/forge-core/examples/seed_check_run.rs
  • crates/forge-core/src/collab/v2.rs
  • crates/forge-core/src/rules/review.rs
  • crates/forge-core/src/user_error.rs
  • crates/git-remote-dash/src/helper.rs
  • crates/git-remote-dash/src/main.rs
  • crates/git-remote-dash/src/policy.rs
  • crates/git-remote-dash/src/pr_sync.rs
  • docs/errors.md
  • docs/guides/collaborating.md
  • e2e/README.md
  • e2e/cli/run.sh
  • e2e/cli/scenarios/21-review-round-trip.sh
  • forge-web/e2e/review-round-trip.spec.ts
  • forge-web/lib/rules/review.ts
  • forge-web/lib/rules/suggestion.ts
  • forge-web/lib/view/render-fuzz.test.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 5 commits September 27, 2026 11:37
…edit

WriteEngine::replace_document signs one DocumentReplace over the stored document with the changes merged and the revision bumped, skips an edit that already holds (nothing signed), refuses a non-owner before signing, and confirms a spent nonce or a revision refusal by re-reading. Collab::update_target / update_comment are the author edits (title/body, comment body); private repos are refused (plaintext would sit next to enc). dg issue edit --title/--body/--body-file uses it. Verified live on moutai: an edit landed (13.5M credits), a re-run wrote nothing, a non-author was refused with E601 before signing.

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

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…tch; add scenario 20

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

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A submit that fails before the review is signed no longer saves the draft, so re-running it cannot add its comments twice (test). prs_following reads only the signer's PRs, skips unreadable ones and is capped. suggestion apply --all takes members' and the author's suggestions only, skips resolved threads by root, prints each replacement before confirming and reads regular files only. update-branch needs an open PR. Reviewer rows put counted verdicts before dismissals. pr view falls back to an anonymous reader; its --json lists explicit fields and side is 0/1 everywhere. --body-file must precede --file. Push errors name their action. Drafts are created 0600. The auto-sync honours dash.confirm refuse/always and skips private PR repos.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
PastaPastaPasta and others added 2 commits September 27, 2026 12:02
Takes master's WriteEngine::replace_document (update_target/update_comment call it). dg pr merge uses #66's require_merge_rights and policy_refusal; a squash is checked as method bit 4 (METHOD_SQUASH), up front and after planning; --override-policy is on PrMergeArgs. Every PR 7 write opens through Session::open_for_write (E606 on an archived repo unless --allow-archived), and pushes to a PR branch pass -o allow-archived under --allow-archived; checks and commits read without it.

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

Master took scenario number 20 (config-storage-ux), so the review round trip is renumbered 21 (E2E_S21_* and the web spec's E2E_S21_STATE follow). helper.rs keeps both new helpers.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@PastaPastaPasta
PastaPastaPasta merged commit 610cef4 into master Sep 27, 2026
22 checks passed
PastaPastaPasta added a commit that referenced this pull request Sep 27, 2026
Keeps F-1's private-repo refusal in update_target/update_comment (collab_contract no longer refuses private repos, so without it a CLI edit would publish plaintext beside enc). The #n/@name autolinks ride #82's markdown render context. The CLI issue-parity scenario is renumbered 22.

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