Skip to content

feat(finalize-pr): run the reviews together, gate once, and skip opted-out generated files - #313

Merged
Ardnived merged 16 commits into
mainfrom
claude/finalize-pr-speed
Nov 24, 2026
Merged

Ardnived merged 16 commits into
mainfrom
claude/finalize-pr-speed

Conversation

@Ardnived

@Ardnived Ardnived commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • finalize-pr gets faster without losing a review. /simplify and /code-review high start together. The lean gate runs once. A tiny diff skips the /simplify pass and is read inline instead.
  • A generated file is left out of review only when its repo opts it out with "review": "skip". A path the security trigger names is always reviewed.

Change outline

Flow — finalize-pr steps 0 to 4

The three reviews used to run one after another, with a gate after each fix. A new script now decides the scope and the tier before step 1.

 0. Pre-flight
+   review-scope.mjs --base origin/<base>             workflow/lib/review-scope.mjs
+     prints TINY | FULL, then review:/skip: per path
+     TINY → no /simplify; read the review: paths inline; step 2, step 3 + comment check as usual
+     FULL → step 3 trigger check, then /simplify, then at once /code-review high <branch>
+            wait for both reports, then triage
 1. /simplify
-   re-run the lean gate, commit
+   commit, then read that commit for bugs (no reviewer saw it)
 2. /code-review high, triage
-   each fix: commit + lean gate
+   each fix: commit
 3. /security-review on a trigger match
+   after step 1's commit, never beside /simplify: it takes no target and reads the worktree
 4. Lean gate
+   once, after every fix from steps 1–3

Behaviour — what review-scope.mjs skips and how it counts

 classify(files, { skip, trigger, skipWhen })        workflow/lib/review-scope.mjs
+  skip a path only if its generatedFiles entry has review: "skip"     config.mjs generatedPatterns(review)
+    an entry with no usable pattern skips nothing
+  never skip a path securityReview.triggerPattern matches
+  every path would be skipped → skip nothing
+  TINY when the review: paths are within review.skipWhen, else FULL
+  no loop-config.json, no base workflow.json, or a failed git diff → FULL, skip nothing
+  workflow.json is read from the base, so a branch cannot widen its own skip list

Contract — generatedFiles entries in each repo's .claude/workflow.json

 { "pattern": "^src/migrations/.+\\.json$", "reason": "…"
+, "review": "skip"
 }

The edit guard ignores the new key. Until a repo sets it, nothing is skipped.

Contract impact

The new optional review key on generatedFiles entries. Each repo opts in with its own config PR, listed under Notes. Each needs an attended edit, because .claude/ is a protected path. Merge order does not matter: the old skill and the edit hook ignore the key, and the script reads it from the base.

Test results

  • Lean gate: ✓ claude plugin validate ./workflow --strict, plus 171 lib tests passing (9 new in review-scope.test.mjs), from the checkout and from a .claude/worktrees/ worktree
  • rule-delta.mjs: 93 → 93 directives, none removed
  • comment-lint.mjs: no findings
  • Script spot checks: SahajCloud#1216's real numstat gives FULL with the snapshot and payload-types.ts skipped. The migration .ts stays in review (4 files, 91 lines).

Manual verification

  1. After merge, watch one bot run that opens a PR (docs/routine-setup.md §6). Check three things:
    • the journal or transcript shows review-scope.mjs ran,
    • /code-review started before /simplify's report came back,
    • the gate ran once.
  2. On the next SahajCloud migration PR, after its config PR lands, check the snapshot is listed as skip:.

Notes for reviewer

  • Sibling config PRs, any order:

    Lockfiles and SahajCloud's importMap.js stay reviewed, as do its migration .ts and the WordPress plugin's vendor/.

  • One PR, one commit per behaviour. Each behaviour is a separate revert, but they share one measurement: the run's duration. The commits are scope, together, gate-once and tiny, then a rewrap and a review-fix commit, then this round's seven: the tiny-tier fix, the security-review ordering, two streamline folds, the effort revert, and two fixes the round's own /security-review and triage found.

  • Reverted after review: effort: max → high, in 32e250b. The altitude reviewer and then the critic made the same case: it moves the one measurement the other four behaviours share, and has no baseline of its own. Cherry-pick 32e250b into its own PR once this branch's duration is measured.

  • Check most closely: the TINY tier. It now skips /simplify only, because the dispatcher skips the critic on the same review.skipWhen and dropping step 2's review as well left a small PR with no agent read at all.

  • Not closed here: the critic (review-pr) still reads the whole diff, snapshot included, and the dispatcher's skipWhen count still includes skipped files. A contract-sync PR is the sharpest case: every path is a review: "skip" path, so the swap that keeps something readable puts them all back and the verdict is FULL, while contractSyncOnly means no critic either. All three are one change in the dispatcher.

  • Latent, named rather than built: review-scope.mjs compiles securityReview.triggerPattern with new RegExp, while step 3's own gate is grep -E, so a pattern only POSIX grep accepts leaves the override off while the skip patterns still apply. And the override reads only the path arm of step 3's gate, not contentPattern/contentPaths. Neither bites today: every repo's trigger compiles identically under both engines, and no repo sets contentPattern.

  • Dismissed findings:

    • Test coverage on tiny diffs: no routine has ever had pr-test-analyzer. implement-ticket step 9 owns coverage.
    • Gate once makes a failure hard to pin on one commit: this trade was chosen on purpose. A failure is fixed in a new commit either way.
    • Split the shared skipWhen into its own key: that is a ceiling change, and the repo's rule keeps it out of this PR. The $comment and why.md now name both readers.
Detail

Measurements behind each change:

  • Bot PRs: 20 to 45 minutes between the last implementation commit and the PR opening. Examples: SahajCloud#1249 took about 38, #1216 about 42, WeMeditateWeb#337 about 30, claude-workflow#300 about 41.
  • Local /code-review high: median 6 minutes over 11 runs, 42 at worst.
  • Lean gate: median 26 to 54 seconds per run across 45 local runs in three repos, and it ran 3 to 6 times per finalize.
  • Snapshots: SahajCloud#1216, #1217, #1225, #1241 and #1244 each carried a ~29,600-line migration snapshot into every review lens.

Changed after review: this branch's first version reused the whole generatedFiles list as "skip in review". Two problems came out of review:

  • The security review found that the list also covers SahajAtlasWeb's pnpm-lock.yaml, which that repo's own security trigger exists to review, and the WordPress plugin's hand-vendored vendor/, which runs on 13 sites and controls their updates.
  • The other reviewers found that the list's inline jq/awk count also dropped SahajCloud's migration .ts. That made schema PRs count as tiny, and the count failed open, printing 0 0, when it could not read the config.

The opt-in key and the tested script replace both.

Review passes run on this branch:

  • /simplify: four lenses.
  • /code-review high: twice, once per version.
  • /security-review: on the first version. The second version adds one script, which runs git with fixed arguments through execFileSync, with no shell, and adds no new sink.
  • The critic (review-pr) on 5ce8671: six findings, five adopted, one rebutted. The rebutted one is the all-generated diff, now under Not closed here.
  • /security-review a third time, over the round's commits. It found one medium: --numstat -z drops git's path quoting, so a changed path carrying a newline printed extra skip: lines — forging an instruction to skip a path the security trigger protects. Reproduced in a scratch repo, fixed in 3d7610c. Triage of its lower-confidence notes found one more: the streamline fold had moved a try and turned a non-list generatedFiles from [] into a throw (3522e97).

🤖 Generated with Claude Code

Ardnived and others added 9 commits November 24, 2026 10:59
A generatedFiles entry opts out of review with "review": "skip". Being
generated is not enough: the edit guard also lists SahajAtlasWeb's
lockfile, which its security trigger exists to review, and the plugin's
hand-vendored vendor/ code. A path the security trigger names is never
skipped, and both config files are read from the base, so a branch
cannot widen its own skip list. The script also prints TINY or FULL
against review.skipWhen, over the paths kept in review, and fails
toward FULL when it cannot read either config.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Steps 1-3 skip the paths review-scope.mjs lists as skip: a generated
file whose entry sets "review": "skip", unless the security trigger
names it. Five SahajCloud PRs carried a ~29,600-line migration snapshot
into every review lens. Nothing is skipped until each repo opts entries
in, in its own config PR.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
/simplify, /code-review high and /security-review ran one after another,
each fanning out its own agents. /simplify's agents run in the
background and only /simplify edits, so the two report-only reviews
start straight after it, and triage waits for every report. No reviewer
then sees /simplify's own commit, so the run reads it for bugs and sends
it to /security-review when it touches a trigger path.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The gate ran after /simplify, after each fixed finding and after the
security review: three to six runs at a median 26 to 54 seconds each.
The fixes stay separate commits, so one gate after triage still names a
failing fix quickly, and CI gates the pushed branch in full.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
When review-scope.mjs says TINY, at or under review.skipWhen over the
paths kept in review, finalize skips /simplify and the step 2 review
and reads that diff itself. The security review and the comment check
still run, and the PR body says the diff was read inline, so the critic
and the reviewer know which review it had.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Most of finalize is mechanical, and max effort priced each of those
turns at the rate of the triage. Shipped as its own commit, with no
measured baseline, so it can be reverted alone if triage quality drops.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
- An opt-out entry with a missing or empty pattern no longer skips every
  path: it compiled to a regex that matches anything.
- A diff whose every path would be skipped now skips nothing, so a
  regenerated-only branch is still read.
- A failed git diff prints FULL and skips nothing, instead of a stack.
- The parallel /code-review takes the branch as its target, so it reads
  commits and never /simplify's half-applied working tree.
- /simplify's own commit goes to /security-review on step 3's content
  check too, not only its path check.
- A run without loop-config.json, such as a member's installed plugin,
  gets FULL, and the skill says how to pass --config.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sydevs-dispatcher

sydevs-dispatcher Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

🤖 no session running

recent dispatches
  • 18:19Z address-review · attempt 1 · session · done
  • 18:19Z address-review · attempt 1 · session
  • 18:08Z review-pr · attempt 1 · session · done
  • 18:08Z review-pr · attempt 1 · session

Written by the sydevs dispatcher. Sessions never edit this comment.

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧐 Adversarial review

Each of the five behaviours is the right size for the problem and separately revertable. The opt-in key is the right shape: the whole generatedFiles list would have dropped a lockfile and vendored code.

One thing is not closed. review.skipWhen now gates two skips that stack, and the note on the divergent counts stops a step short of the overlap. When finalize prints TINY with nothing skipped, the dispatcher skips the critic too, so the PR reaches the reviewer having had no agent read it.

Keeping effort: high here also spends the one measurement the other four commits share.

Findings

  • should-fix — TINY and the critic skip compound to no agent review — finalize-pr/SKILL.md:103
  • should-fix — /security-review reads the worktree /simplify is editing — SKILL.md:109
  • should-fix — Streamline reviewSkipPatterns into generatedPatterns — config.mjs:68
  • should-fix — Streamline triggerFrom into main — review-scope.mjs:80
  • consider — the effort commit cannot be attributed — SKILL.md:4
  • consider — a generated-only diff swaps back to the full fan-out — review-scope.mjs:73

What was checked

11 files, +353/−18, 9 commits, read whole. On the branch: review-scope.mjs, its test, config.mjs, finalize-pr/SKILL.md, the why.md additions. On main: dispatcher/decide.mjs (underThreshold, criticSkipped), base-ref.mjs (baseline is the branch point, so the two-dot diff is right), the three generatedPatterns callers.

Verified, not read from the body: the branch's 6 review-scope tests pass from a copy outside the checkout, and parseNumstat matches --numstat -z --no-renames record order.

Ladder walked on the pieces new-pieces.mjs skipped: no dependency, none nested. Streamliner: 6 covered, 4 kept, both findings held. No question threads. Profile read.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

Comment thread workflow/skills/finalize-pr/SKILL.md Resolved
Comment thread workflow/skills/finalize-pr/SKILL.md Resolved
Comment thread workflow/lib/config.mjs Resolved
Comment thread workflow/lib/review-scope.mjs Resolved
Comment thread workflow/lib/review-scope.mjs Resolved
Comment thread workflow/skills/finalize-pr/SKILL.md Resolved
@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 24, 2026
@sydevs-dispatcher sydevs-dispatcher Bot moved this from Working to Pending in SYDevelopers Technical Roadmap Nov 24, 2026
@sydevs-dispatcher sydevs-dispatcher Bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 24, 2026
@sydevs-dispatcher sydevs-dispatcher Bot moved this from Pending to Working in SYDevelopers Technical Roadmap Nov 24, 2026
sydevs-bot and others added 6 commits November 24, 2026 18:24
The TINY tier skipped `/simplify` and step 2's review. The dispatcher's
`underThreshold` (dispatcher/decide.mjs) skips the critic on the same
`review.skipWhen`, over GitHub's totals, which never fall below the count
finalize-pr makes over the paths it keeps in review. So the two skips agree
whenever nothing is skipped, and a two-file, forty-line PR reached the
reviewer with no `/simplify`, no `/code-review` and no critic — less review
than it got before this branch.

The tier now skips `/simplify` and nothing else. The why.md entry carried
the divergent counts but stopped short of that overlap; it now names it.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjWxFZSXaRfdTsQZznT
Step 2's review was given the branch as its target so it reads commits
only. `/security-review` takes no target: it reads the worktree, which
`/simplify` is editing at that moment, so a parallel start risks a torn
read in the one lens whose misses are worst.

Step 1 already re-ran it over `/simplify`'s commit on a match, so running
it in parallel bought nothing there either. It now runs once, after that
commit, over the whole diff — which covers the commit too, so step 1's
extra run goes.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjWxFZSXaRfdTsQZznT
`reviewSkipPatterns` was `generatedPatterns` plus one filter. The streamliner
asked for the parameter instead: `generatedPatterns(text, { review: 'skip' })`
gives the same skip set, five lines shorter, with one docstring to keep true.

The fold also moves the new function's per-entry care onto the three existing
callers, which is a fix, not a side effect. `new RegExp(undefined)` compiles to
`/(?:)/`, so an entry with no `pattern` made comment-fingerprint, doc-weight
and new-pieces treat every path as generated; one uncompilable pattern voided
the whole list for them. A new test locks both, filtered and unfiltered.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjWxFZSXaRfdTsQZznT
A private nine-line wrapper with one caller, and no second in sight: step 3
reads `triggerPattern` with `jq`, not through here. It now sits beside the
`workflow` text it parses, three lines shorter, with the same null for a
trigger that is absent, unparseable or uncompilable.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjWxFZSXaRfdTsQZznT
Reverts 32e250b. The critic and the altitude reviewer before it made the
same point: the other four behaviours on this branch are judged by one
measurement, the run's duration, and this one moves that number too. Shipped
together, a faster run cannot say which did it, and a prose change cannot be
re-run to find out — the failure the repo's skill/ceiling split exists to
stop. Its own why.md entry admitted it had no measured baseline.

It costs one frontmatter line to redo. Cherry-pick 32e250b into its own PR
once this branch's duration is measured, against that baseline.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjWxFZSXaRfdTsQZznT
`git diff --numstat -z` deliberately drops git's own C-quoting, so a changed
path may carry a newline, and `parseNumstat` splits only on NUL and tab. The
printed `review:`/`skip:` lines are what the skill tells each review to skip,
step 3's `/security-review` included, so one oddly-named path could inject a
`skip:` line for a path `securityReview.triggerPattern` exists to protect —
the override `classify` is written to guarantee.

Found by this round's `/security-review` and reproduced in a scratch repo: a
directory named `docs\n  skip: src/auth/keys.ts` printed that forged line.
Odd paths now print as JSON, the way git quotes them without `-z`.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjWxFZSXaRfdTsQZznT
b4d05bc moved the iteration outside the `try`, so a `generatedFiles` that
parses but is not an array threw a TypeError where the old `.map` inside the
`try` returned `[]`. review-scope.mjs would have exited on a stack instead of
printing FULL. An `Array.isArray` guard restores the fail-safe, with a test.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjWxFZSXaRfdTsQZznT
@sydevs-bot

Copy link
Copy Markdown
Contributor

Five of six critic findings adopted, one rebutted.

This round's own /security-review found a medium: an odd path could forge a skip: line past the security-trigger override (3d7610c). Triage found a fail-safe the fold had moved (3522e97).

Base was current.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 24, 2026

@sydevs-dispatcher sydevs-dispatcher Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved for Ardnived, who wrote it: GitHub refuses an author's own approval. CI is green and the automated review has run. 🤖 Written by the sydevs autonomous loop — see what this is

@Ardnived
Ardnived added this pull request to the merge queue Nov 24, 2026
@sydevs-dispatcher sydevs-dispatcher Bot moved this from Working to Pending in SYDevelopers Technical Roadmap Nov 24, 2026
@sydevs-dispatcher sydevs-dispatcher Bot moved this from Pending to Awaiting in SYDevelopers Technical Roadmap Nov 24, 2026
Merged via the queue into main with commit 39ea9df Nov 24, 2026
97 of 106 checks passed
@Ardnived
Ardnived deleted the claude/finalize-pr-speed branch November 24, 2026 18:39
@sydevs-dispatcher sydevs-dispatcher Bot moved this from Awaiting to Done in SYDevelopers Technical Roadmap Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

2 participants