From 3c15b7210b0dec54d0d447246d47afd278932d55 Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Sat, 14 Nov 2026 17:50:10 +0800 Subject: [PATCH] Let /ship render its second-model review on its own for PRs over 2 MB again (GST-2632) (#4361) The standalone render now passes the requested role to the review-size ceiling, so the outside voice keeps its exemption there as it does in the pass manifest. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --- bin/gstack-review-dispatch | 2 +- .../fix-outside-voice-render-ceiling.md | 4 +++ test/review-reader-selection.test.ts | 36 +++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 changelog.d/fix-outside-voice-render-ceiling.md diff --git a/bin/gstack-review-dispatch b/bin/gstack-review-dispatch index 727f8f1a4..80cd9306a 100755 --- a/bin/gstack-review-dispatch +++ b/bin/gstack-review-dispatch @@ -167,7 +167,7 @@ function render(): number { const sel = base && diffBase ? standaloneSelection(readerKey(role, name), base, diffBase, readers) : { reader: readerKey(role, name), exclude: flag('--exclude'), keep: parseTail(flag('--keep')).filter(s => s !== '--'), disclosure: flag('--disclosure') }; const policyItems = parseTail(sel.exclude).filter(s => s.startsWith(':(top,exclude,glob)')); if (base && diffBase) { - const over = ceiling('gstack-review-dispatch render', base, out, [sel], diffBase, undefined); + const over = ceiling('gstack-review-dispatch render', base, out, [{ ...sel, role }], diffBase, undefined); if (over) { process.stderr.write(over.line + '\n'); return over.exit; } settleExcerpt(sel, diffBase, path.resolve(out)); if (role === 'outside-voice') diff = branchDiff(diffBase, sel); diff --git a/changelog.d/fix-outside-voice-render-ceiling.md b/changelog.d/fix-outside-voice-render-ceiling.md new file mode 100644 index 000000000..23af6c126 --- /dev/null +++ b/changelog.d/fix-outside-voice-render-ceiling.md @@ -0,0 +1,4 @@ +--- +important: regression +--- +- **/ship's second-model review can be rendered on its own for a PR whose diff is over 2 MB again.** Since the cyber_policy retry change (#4350), the 2 MB review-size ceiling exempts the outside voice by its role, but `gstack-review-dispatch render` built its reader without one, so `render --role outside-voice` on a large PR stopped at `REVIEW_DIFF_TOO_LARGE` instead of writing its brief with a sliced diff. The standalone render now passes the role it was asked for. The ceiling's size, which readers it exempts and the pass manifest's own stages are unchanged, and every other reader on the standalone path is still refused over the ceiling. diff --git a/test/review-reader-selection.test.ts b/test/review-reader-selection.test.ts index 091199dc7..d3c2a4d75 100644 --- a/test/review-reader-selection.test.ts +++ b/test/review-reader-selection.test.ts @@ -185,3 +185,39 @@ describe('every reader path builds its diff from the base policy\'s selection', expect(sub).toBe(root); }, 120_000); }); + +describe('the review-size ceiling on a standalone render', () => { + /** A plain change beside about 2.5 MB of data with no base policy, so every reader's selection is over the 2 MB ceiling. */ + function large() { + const repo = makeFixtureRepo({ prefix: 'gstack-sel-big-' }); + repos.push(repo); + const files: Record = { 'lib/a.ts': 'export const a = 1;\n' }; + for (let k = 0; k < 6; k++) files['data/t' + k + '.json'] = ('{"x": "' + 'y'.repeat(200) + '"}\n').repeat(2000); + commit(repo, files); + return { repo, mb: repo.git('merge-base', 'origin/main', 'HEAD') }; + } + + // Value: protects=the outside voice rendered on its own keeps its exemption from the 2 MB ceiling and gets a sliced diff; + // fails_when=render's selection carries no role, so the ceiling's outside-voice exemption never matches and the render + // stops at REVIEW_DIFF_TOO_LARGE (#4350 regression, GST-2632); why_new=GST-2632; seam=gstack-review-dispatch render on a + // real repository; no_claim=the pass manifest's voices stage + test('the outside voice renders over the ceiling with a sliced diff', () => { + const { repo, mb } = large(); + const out = path.join(repo.root, 'ov'); + const r = render(repo, mb, out, 'outside-voice'); + expect({ status: r.status, err: r.err }).toEqual({ status: EXIT.ok, err: '' }); + expect(fs.statSync(path.join(out, 'outside-voice.diff')).size).toBeLessThanOrEqual(REVIEW_DIFF_MAX_BYTES); + }, 120_000); + + // Value: protects=every other reader on the same standalone path is still refused over the ceiling; fails_when=the + // outside voice's exemption widens to the reader rendered beside it; why_new=GST-2632; seam=gstack-review-dispatch render + // on a real repository; no_claim=the wording of the refusal + test('a reader that is not the outside voice is still refused over the ceiling', () => { + const { repo, mb } = large(); + const out = path.join(repo.root, 'rt'); + const r = render(repo, mb, out, 'red-team', ['--findings-file', empty(repo), '--specialists', '1']); + expect(r.status).toBe(EXIT.refused); + expect(r.err).toContain('REVIEW_DIFF_TOO_LARGE'); + expect(fs.existsSync(path.join(out, 'red-team.prompt.md'))).toBe(false); + }, 120_000); +});