Repository navigation
feat(action): Add incremental PR review - #561
Merged
Merged
Conversation
Skip hunks that were already reviewed by the same skill at a clean baseline commit. Baselines are recorded in the per-skill check run external_id and hunks are matched by content fingerprint against the PR diff at that baseline, so rebases and merges from the base branch do not trigger re-review of unchanged code. Opt-in via the `incremental` action input. Requires `checks: read`. Fails open to a full review whenever a baseline cannot be resolved. Refs #408 Co-Authored-By: Claude <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Only trust baseline checks written by the GitHub App named in the new incremental-app input, so look-alike checks from other apps cannot make Warden skip hunks. Without it, incremental review falls back to a full review. Never record an aborted run as a baseline, since queued hunks cancelled by the shared abort are not counted as failures. Keep a previous CHANGES_REQUESTED review while a Warden comment on a carried hunk is still open, and match carried comments by GitHub's current line as well as the marker line so shifted hunks stay protected. Co-Authored-By: Claude <[email protected]>
Jeffreyhung
added a commit
that referenced
this pull request
Nov 4, 2026
zod < 4.6.6 parses every element of an array/set/map schema and records an issue per invalid element before any upper size bound runs, so oversized input can exhaust memory ([GHSA-mrhx-c7xc-m3w5](GHSA-mrhx-c7xc-m3w5)). Semgrep flagged it on #561. ## Changes - Direct `zod` dependency `^4.4.3` → `^4.6.7` in `packages/warden`, `packages/warden-service`, `packages/warden-service-api`, `packages/evals`, and `apps/warden-service`. - New `pnpm.overrides` entry `"zod@>=4.0.0 <4.6.6": "4.6.7"` for the transitive `[email protected]` pulled in by the Vercel CLI (`vercel`, `@vercel/cli-auth`, `@vercel/cli-config`). - `specs/jsonl-schema.json` regenerated. zod 4.6 emits slightly different JSON Schema: a primitive union collapses to `type: [...]`, and the `datetime` pattern now requires seconds. ## Behavior change to know about `z.string().datetime()` in 4.6 rejects minute-precision timestamps (`2026-01-01T00:00Z`). 4.4.3 accepted them. Every timestamp Warden and the service client produce comes from `Date#toISOString()`, which always includes seconds, so nothing in-repo should be affected. External callers sending `from`/`to` to the history API without seconds would now get a 400. ## Not covered - `[email protected]` stays, via `@vercel/backends`, `@vercel/express`, `@vercel/hono`, and `@vercel/python-analysis`. The advisory has no patched 3.x release, and forcing those packages onto zod 4 is a major-version jump inside Vercel's build tooling. That is a deploy-time dependency and doesn't handle untrusted input at runtime. - The advisory also recommends adding `.max()` bounds to collection schemas that parse untrusted input. That needs per-schema limits and is left for a follow-up. ## Verification - `pnpm install --frozen-lockfile` succeeds. Every workspace package resolves `zod 4.6.7`. - `pnpm lint`, `pnpm build`, and typecheck pass. - `pnpm test` passes except `src/skills/remote.test.ts`, which needs network git and fails the same way on `main` in my environment. <!-- junior-request-attribution:start --> via **Jeffrey Hung**. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:slack%3AD0AH1TP6CHJ%3A1793816729.438159 --> -- [View Session](https://junior-prod.sentry.dev/conversations/slack%3AD0AH1TP6CHJ%3A1793816729.438159) [[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AD0AH1TP6CHJ%3A1793816729.438159/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: Jeffrey Hung <[email protected]>
Move incremental review from action inputs to warden.toml. `incremental` follows the usual trigger > skill > defaults merge, so each skill picks its own mode. `defaults.incrementalApp` names the GitHub App whose checks count as baselines; repo skills inherit it from a base config, and a repo config cannot change the mode of base skills. Co-Authored-By: Jeffrey Hung <[email protected]>
…kips Include the PR base branch in the incremental external_id. Baselines are rebuilt against the current base, so a check recorded before a retarget would describe a diff it never reviewed. Only path-based ignore skips keep a run eligible as a baseline. Generated detection reads file content, so a file skipped as generated can become reviewable later while its unchanged hunks still match the baseline.
…cremental Skipped hunks contribute no findings, so a baseline recorded under a looser policy never applies a stricter one to those hunks. Add requestChanges and maxFindings to the incremental external_id, plus the auxiliary, synthesis, and context settings that change what analysis finds.
Jeffreyhung
marked this pull request as ready for review
November 4, 2026 22:21
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 47443a6. Configure here.
…tal review GitHub drops the current line on outdated comments, and the Warden marker keeps the line from the original post. After a rebase shifts a skipped hunk, neither line lands in the carried range, so the stale pass could resolve a finding that was never re-checked. Treat an outdated comment as carried when its skill skipped any hunk in the same file. Co-Authored-By: Jeffrey Hung <[email protected]>
Scan limits ran on the full PR diff before incremental review dropped already-reviewed hunks. Unchanged hunks used up the file and changed-line budgets, so a large PR could limit-skip files, which also stopped the run from becoming a baseline. Count only hunks still to analyze, and keep fully reviewed files out of the file budget.
The Warden marker keeps the line a finding was first posted on. After a shift it can land inside an unrelated carried hunk while GitHub's current line tracks the comment to a re-reviewed hunk, which kept fixed comments open and blocked review dismissal. Carried ranges are in current-diff lines, so use GitHub's current line when present and fall back to the marker line only when it is missing.
…ed hunks A failed or skipped comment fetch left the fetched list empty, so the carried-comment guard saw nothing open and a prior CHANGES_REQUESTED review could be dismissed while comments on skipped hunks stayed open. Track whether the fetch succeeded and treat an unknown comment state as open whenever any hunk was carried.
…he PR Skill checks carried the baseline external_id from the moment they completed, before the review was posted. If posting then failed, the head moved, or findings were capped by maxFindings, the next push skipped the unchanged hunks and those findings were never shown again. Complete checks without external_id and mark the baseline after posting, only when every reportable finding was posted or matched an existing comment. A failed write leaves no baseline, so the next run is full.
Jeffreyhung
approved these changes
Nov 5, 2026
sentry-junior Bot
added a commit
that referenced
this pull request
Nov 5, 2026
Resolve conflicts with incremental PR review (#561) by keeping both features: alwaysScan and skipHunks scan options, hunkGate and incremental report fields, and partialScopeSkills plus carriedRanges for stale-comment resolution. Co-Authored-By: Jeffrey Hung <[email protected]>
Jeffreyhung
added a commit
that referenced
this pull request
Nov 5, 2026
…t changes (#565) Follow-up to #561. Fixes the medium `security-review` finding that showed up only in the check summary on #561's last run (`pr-workflow.ts:2122`). **The gap.** With `requestChanges` and `failOn` on but `failCheck` off, a run with a blocking finding gets a `neutral` check, so it could still become an incremental baseline. On the next push its hunks were skipped. If someone then resolved the blocking comment, Warden saw no current findings and dismissed the earlier `CHANGES_REQUESTED` review without checking the finding again. **The fix.** A run that requested changes is never recorded as a baseline, so the next push gets a full review and the finding is checked again before the review can be dismissed. The request-changes check is pulled into one `requestsChanges()` helper, which both baseline recording and review dismissal now use, so the two can't drift apart. **Tradeoff.** PRs with an open blocking finding don't get incremental review until a run comes back clean. That matches how failed checks are already handled. Incremental review is off unless `warden.toml` turns it on, so nobody running the default config sees any change. **Tests.** I added a workflow-level regression test, `records no baseline when the run requested changes`, and confirmed it fails without the fix. I also added a line to the docs fallback list. <!-- junior-request-attribution:start --> via **Jeffrey Hung**. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:slack%3AD0AH1TP6CHJ%3A1793816729.438159 --> -- [View Session](https://junior-prod.sentry.dev/conversations/slack%3AD0AH1TP6CHJ%3A1793816729.438159) [[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AD0AH1TP6CHJ%3A1793816729.438159/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: Jeffrey Hung <[email protected]>
3 tasks done
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Every
synchronizecurrently re-reviews the whole PR diff. On PRs that get many pushes, or that merge/rebase from main, most of that work repeats analysis of hunks that haven't changed. This adds opt-in incremental review: a skill only re-analyzes hunks whose content changed since its last clean run on the PR.Refs #408
How it works
Baseline storage. No new storage. When a skill check completes with
successorneutraland the run reviewed everything (no failed hunks, no files skipped by scan limits or as generated, not cut short by a shared abort), Warden writes anexternal_idon that check run. It writes it only after the review is posted and every reportable finding reached the PR (posted or matched an existing comment); if posting fails, the head moves first, or findings are overmaxFindings, the run is not a baseline:Any change to the skill, its prompt, Warden's version, the trigger config, or the PR's base branch changes the id, so old baselines stop matching and the next run is a full review.
Finding a baseline. On a new push,
createIncrementalBaselineSourcewalks the newest PR commits (excluding head, capped at 10), listswarden: *check runs for each withfilter: latest, and takes the newest commit with a completed, clean check whoseexternal_idmatches and whoseapp.slugequalsdefaults.incrementalApp. The id is built from predictable fields, so the app check is what stops a look-alike check from another app being accepted as a baseline. It then rebuilds the PR diff as of that commit with a three-dot compare (base...baseline).Matching hunks. Hunks are fingerprinted on path + hunk body, ignoring line numbers (
hunkFingerprint), and matched as a multiset. Hunks whose fingerprint was already present at the baseline are dropped inprepareFilesbefore split/coalesce. Rebases, merges from main, and edits elsewhere in a file don't invalidate a hunk that didn't change.Comments on carried hunks. Existing Warden comments that sit on a skipped ("carried") hunk are kept open and are excluded from fix evaluation and stale resolution, the same way re-detected findings are treated. Without this they would be auto-resolved because the current run didn't re-find them. A comment counts as carried if GitHub's current line falls in the carried range, so a hunk shifted by a rebase stays covered. The marker line is only used when GitHub gives no current line. While any carried comment is unresolved, Warden won't dismiss an earlier
CHANGES_REQUESTEDreview.Fail open. Any error (API failure, missing permission, no matching check, compare failure) logs and falls back to a full review. Incremental mode never makes a run review less than it should because of a lookup problem.
Replay.
SkillReport.incremental(externalId,baselineSha,carriedRanges,complete) is carried through the replay report so split analyze/report workflows behave the same as single-job runs.specs/jsonl-schema.jsonis regenerated.Enabling it
Configured in
warden.toml, not the workflow.incrementalfollows the same trigger > skill > defaults merge asfailCheck, so each skill (built-in or not) picks its own mode:false. The baseline lookup only runs when at least one matched skill has it on.incrementalApplives in[defaults]only. Without it, an incremental skill warns and does a full review.base-config-path), repo-defined skills inherit the baseincrementalApp. The repo config can't change the mode of a base skill, since repo duplicates of base skills are already dropped.checks: read(a GitHub permission, not a Warden setting) andpost-checkson, since the check run is where the baseline lives.incremental.Docs:
github/workflow.mdx("Incremental Review") andconfig/output.mdx.Known limitations
SKILL.mdwon't invalidate baselines.incrementalApp(for example a same-repo branch whose workflow can mint that app's token) can still forge a baseline. Fork PRs can't. That actor can already change or skip the Warden workflow on their branch, so this adds no new bypass. Likewise, a PR can edit its ownwarden.tomland name a different app, but it could just as well remove the skill; skills from a base config takeincrementalAppfrom the base config, which the PR can't change.Relationship to the #408 fork
The fork linked in #408 was read for ideas only; no code was taken from it. It reviews the raw SHA delta between the last reviewed commit and head. That re-reviews everything pulled in by a merge from main, needs
fetch-depth: 0, and keys state on line ranges that shift on rebase. This PR matches on hunk content against the PR diff at the baseline instead, which avoids all three.Questions for reviewers
Testing
action/incremental.test.tsfor fingerprinting, planning, baseline id, and baseline lookup (including fail-open paths).executor.test.ts,github-checks.test.ts,prepare.test.ts, andpr-workflow.test.ts, including a two-run end-to-end analyze-mode test, a report-mode test that carried comments aren't resolved, and regression tests for untrusted-app checks, aborted runs, shifted comments, review dismissal with open carried comments, base retargets, and generated-file skips.loader.test.tscovers the trigger > skill > defaults merge and layeredincrementalAppinheritance;executor.test.tsandpr-workflow.test.tscover skills with it off and a missingincrementalApp.pnpm lint && pnpm buildpass. Test suite passes exceptsrc/skills/remote.test.ts, which fails the same way onmainin my environment (network-dependent).--
View Session [Sentry]