mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-19 06:34:43 +01:00
Keep a pull request's review count intact when a posted description brings its own run history (GST-2707) (#4440)
When `/ship` posts a pull request's description, the count of earlier review rounds now always comes from the PR's real history. Before this fix, a description that brought extra history blocks of its own could make gstack count one round where there were three. Why: the per-PR round cap (R51) depends on that count, and it's the last gap before crews can stop counting rounds by hand. Nothing to do as a reader. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> Review-Finding: p1/specialist-batched#1 reader=red-team Review-Finding: p1/specialist-batched#2 reader=testing
This commit is contained in:
1 parent
eff8b78dce
commit
b79843c5d7
4 files changed
+59
-8
No files matched your search
@@ -85,6 +85,41 @@ describe('prReviewHistory', () => {
|
||||
expect(prReviewHistory(mergeBodySections(posted, composed).body)).toEqual(prReviewHistory(posted));
|
||||
});
|
||||
|
||||
// Value: protects=the PR's review count from a posted body whose notes carry their own runs blocks: the reader takes the
|
||||
// first block it finds, so one placed before the receipt would replace the real history (Sol audit of #4365, GST-2707);
|
||||
// fails_when=keepRuns removes only the first incoming block, or returns the file's history when the live body has none;
|
||||
// seam=none (mergeBodySections); no_claim=the gh round trip
|
||||
test('a /ship body post drops every runs block it brings and keeps only the live history (GST-2707)', () => {
|
||||
const fake = (c: string) => '```gstack-receipt-runs\n' + JSON.stringify({ head: sha(c), run: `fake-${c}`, review_loop: loop({ passes: 0, rounds: 0 }) }) + '\n```\n';
|
||||
const composed = placeReceipt('## Summary\nnew prose\n', receipt(sha('c'), { passes: 1, rounds: 1 }, { run: 'r2' }));
|
||||
const injected = composed.replace('```gstack-ship-receipt', fake('d') + '\n' + fake('e') + '\n```gstack-ship-receipt');
|
||||
expect(receiptRuns(injected).map(r => r.run)).toEqual(['fake-d']);
|
||||
let live = placeReceipt('## Summary\nprose\n', receipt(sha('a'), { passes: 1, rounds: 1 }, { run: 'r1' }));
|
||||
live = placeRunEntry(live, { head: sha('b'), run: 'r3', status: 'started', review_loop: loop({ passes: 1, rounds: 1 }) });
|
||||
const posted = mergeBodySections(live, injected).body;
|
||||
expect(prReviewHistory(posted)).toMatchObject({ full: 3, runs: 2, stubs: 1, last_full: sha('c') });
|
||||
expect(receiptRuns(posted).map(r => r.run)).toEqual(['r3', 'r1']);
|
||||
expect(posted.match(/```gstack-receipt-runs/g)).toHaveLength(1);
|
||||
expect(prReviewHistory(mergeBodySections(posted, injected).body)).toEqual(prReviewHistory(posted));
|
||||
const fresh = mergeBodySections('## Summary\nprose\n', injected).body;
|
||||
expect(fresh).not.toContain('gstack-receipt-runs');
|
||||
expect(prReviewHistory(fresh)).toMatchObject({ full: 1, runs: 1, stubs: 0 });
|
||||
});
|
||||
|
||||
// Value: protects=a PR's started stubs when a post's Agent notes carry no receipt yet (the body between a Step 9 stub and
|
||||
// the receipt write); fails_when=keepRuns drops the live runs block, or lets a block the file brings stand in for it;
|
||||
// seam=none (mergeBodySections); no_claim=the gh round trip
|
||||
test('a post whose notes hold no receipt keeps the live stubs and none of its own runs blocks (GST-2707)', () => {
|
||||
const live = placeRunEntry('## Summary\nprose\n', { head: sha('b'), run: 'r3', status: 'started', review_loop: loop({ passes: 1, rounds: 1 }) });
|
||||
expect(mergeBodySections(live, live).body).toBe(live);
|
||||
const fake = '```gstack-receipt-runs\n' + JSON.stringify({ head: sha('d'), run: 'fake-d', review_loop: loop({ passes: 0, rounds: 0 }) }) + '\n```\n';
|
||||
const injected = live.replace('```gstack-receipt-runs', fake + '\n```gstack-receipt-runs');
|
||||
expect(receiptRuns(injected).map(r => r.run)).toEqual(['fake-d']);
|
||||
const posted = mergeBodySections(live, injected).body;
|
||||
expect(receiptRuns(posted).map(r => r.run)).toEqual(['r3']);
|
||||
expect(prReviewHistory(posted)).toEqual(prReviewHistory(live));
|
||||
});
|
||||
|
||||
test('a stub lands in a body with no receipt yet, inside the Agent notes section', () => {
|
||||
const body = placeRunEntry('## Summary\nprose\n', { head: sha('a'), run: 'r1', status: 'started', review_loop: loop({ passes: 1, rounds: 1 }) });
|
||||
expect(body.startsWith('## Summary\nprose\n')).toBe(true);
|
||||
|
||||
Reference in new issue
Block a user