Fix /ship review counting, cleared reviewer notes and security findings in the posted PR description (GST-3343) (#4595)

/ship no longer stalls on summary notes a reviewer already cleared,
counts only full review passes as rounds, records a round approval
relayed during a stopped run, and keeps security findings out of the
ship record it posts in the PR description.

These four bugs each stopped a real /ship run until someone edited a
record by hand; the goal is unattended shipping that finishes on its
own.

Nothing to do as a reader.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Review-Finding: s11/outside-voice#1 reader=outside-voice
Review-Finding: s11/adversarial-native#2 reader=adversarial-native
This commit is contained in:
Garry Tanandcapy-ai[bot] authored and GitHub committed 2026-11-21 08:51:13 +00:00
1 parent 387a65c9a2
commit b281effa07
18 files changed
+178 -38

No files matched your search

+1 -1
View File
@@ -348,7 +348,7 @@ describe('factory-scorecard: pieces', () => {
// Value: protects=a PR shipped three times at two rounds each reports 6 rounds, not the largest run's 2 (GST-2673); fails_when=the scorecard takes the max again; why_new=R51 counts per PR; seam=none; no_claim=bodies without a receipt, which keep the marker's max
test('receiptRounds sums R51 rounds across the receipt and its runs', () => {
const run = (c: string, id: string) => JSON.stringify({ head: c.repeat(40), run: id, review_loop: { passes: 1, blocking_found: 0, deferred: 0, fix_checks: 1, rounds: 2 } });
const run = (c: string, id: string) => JSON.stringify({ head: c.repeat(40), run: id, review_loop: { passes: 2, blocking_found: 0, deferred: 0, fix_checks: 1, rounds: 2 } });
const body = '```gstack-ship-receipt\n' + JSON.stringify({ schema_version: 1, ...JSON.parse(run('c', 'r3')) }) + '\n```\n\n```gstack-receipt-runs\n' + run('a', 'r1') + '\n' + run('b', 'r2') + '\n```\n';
expect(receiptRounds(body)).toBe(6);
expect(receiptRounds('passes=2')).toBeNull();
+4 -4
View File
@@ -20,11 +20,11 @@ describe('prReviewHistory', () => {
expect(prReviewHistory('## Summary\nprose\n')).toMatchObject({ rounds: 0, full: 0, runs: 0, first_full: null, source: 'pr-body' });
});
test('rounds follow R51 (passes plus fix-checks) summed across /ship runs, not the largest run', () => {
test('rounds follow R51 (passes, never fix-checks) summed across /ship runs, not the largest run', () => {
let body = placeReceipt('', receipt(sha('a'), { passes: 1, fix_checks: 1, rounds: 2 }, { run: 'r1' }));
body = placeReceipt(body, receipt(sha('b'), { passes: 1, fix_checks: 1, rounds: 2 }, { run: 'r2' }));
const h = prReviewHistory(body);
expect(h).toMatchObject({ runs: 2, rounds: 4, full: 2, fix_checks: 2, first_full: sha('a'), last_full: sha('b') });
expect(h).toMatchObject({ runs: 2, rounds: 2, full: 2, fix_checks: 2, first_full: sha('a'), last_full: sha('b') });
});
test('a scoped pass 2 is a round but not a full round', () => {
@@ -54,10 +54,10 @@ describe('prReviewHistory', () => {
expect(prReviewHistory(body)).toMatchObject({ rounds: 2, stubs: 1 });
body = placeRunEntry(body, { head: sha('b'), run: 'r2', status: 'started', review_loop: loop({ passes: 1, fix_checks: 1, rounds: 2 }) });
expect(receiptRuns(body).filter(r => r.status === 'started').length).toBe(1);
expect(prReviewHistory(body).rounds).toBe(3);
expect(prReviewHistory(body).rounds).toBe(2);
body = placeReceipt(body, receipt(sha('c'), { passes: 1, fix_checks: 1, rounds: 2 }, { run: 'r2' }));
expect(receiptRuns(body).some(r => r.status === 'started')).toBe(false);
expect(prReviewHistory(body)).toMatchObject({ rounds: 3, stubs: 0, runs: 2 });
expect(prReviewHistory(body)).toMatchObject({ rounds: 2, stubs: 0, runs: 2 });
});
test('a voided stub (an infrastructure failure) counts nothing', () => {
+2 -2
View File
@@ -121,9 +121,9 @@ describe('gstack-ship-receipt history and stub', () => {
expect(h.stdout).toMatch(/^PR_REVIEW_ROUTE: final \(the PR had 1 full review round; this head gets a fresh full review/m);
expect(h.stdout).not.toMatch(/drift|recheck_blocked/);
const s = r.run('gstack-ship-receipt', ['stub', '--body', body, '--run', 'r2', '--review-loop', JSON.stringify({ ...loop, fix_checks: 1, rounds: 2 })]);
expect(s.stdout).toContain('RUN_STUB: run=r2 status=started rounds=2');
expect(s.stdout).toContain('RUN_STUB: run=r2 status=started rounds=1');
const after = r.run('gstack-ship-receipt', ['history', '--body', body, '--pr', '5']).stdout;
expect(after).toContain('PR_REVIEW_FLAGS: --prior-rounds 3 --prior-full 2\n');
expect(after).toContain('PR_REVIEW_FLAGS: --prior-rounds 2 --prior-full 2\n');
expect(after).toMatch(/^PR_REVIEW_ROUTE: read-only \(.*no fix round/m);
expect(fs.readFileSync(body, 'utf8').startsWith('## Summary\nprose\n')).toBe(true);
expect(r.run('gstack-ship-receipt', ['stub', '--body', body]).status).toBe(2);
+50
View File
@@ -90,3 +90,53 @@ describe('a reader\'s scope and passed-checks bullets under a blocking=0 verdict
expect(lowered('red-team', reply(ZERO, '- P0: the gate drops a HIGH finding.'))).toMatchObject({ ok: false, downgraded: ['red-team#1'] });
});
});
/**
* #4553 (GSTA-666, 2026-11-20): the native reader's Scope bullets named findings the run already had by their status, "the 7 noted
* CRITICAL duplicates" and "a deferred CRITICAL", and #4519's Red Team bullet named severities as a list with no "findings" after it.
* Each collected as a blocker the lead could not lower, so two owner rulings cleared them. The captured output stayed on that run's
* machine; this reply rebuilds its shape from the run's decision trail (rows 22-23) and the lane's report.
*/
const REBUILT_4553_P1_ADVERSARIAL = [
'REVIEWED_TREE: f680df6d0000000000000000000000000000beef /workspace/gstack',
'REVIEW_VERDICT: blocking=0',
'',
'I found no blocking findings.',
'',
'**Scope.** I read the full diff of gstack-review-read and its tests. The tests cover:',
'- 22 rulings leave the 7 noted CRITICAL duplicates named;',
'- a row listing fewer findings than it claims;',
'- ruling every finding makes all three rows CURRENT;',
'- a deferred CRITICAL and a gate finding.',
'',
'Recommendation: Ship as-is.',
].join('\n');
describe('a scope bullet naming a finding by its status or a list of severities (#4553, #4519)', () => {
// Value: protects=a bullet that names findings by a status they already have (noted, deferred) or names severities as a list, in a
// reply declaring blocking=0, is a summary candidate the lead may lower with a reason; fails_when=#4553's Scope bullets or the
// bare "P0 or P1" passed check need an owner ruling again, or a bullet stating a blocker loses its label; why_new=GSTA-666 needed two
// Captain rulings for them; seam=parseReply with the verdict ask and judge, as collect and the lead use them; no_claim=-
test('#4553: the noted and deferred CRITICAL bullets keep CRITICAL as summary candidates the lead can lower', () => {
expect(rows('adversarial-native', REBUILT_4553_P1_ADVERSARIAL)).toEqual([
['CRITICAL', '- 22 rulings leave the 7 noted CRITICAL ', true],
['CRITICAL', '- a deferred CRITICAL and a gate finding', true],
]);
expect(lowered('adversarial-native', REBUILT_4553_P1_ADVERSARIAL)).toMatchObject({ ok: true, dismissed: ['adversarial-native#1', 'adversarial-native#2'], downgraded: [] });
});
test('#4519: a passed check naming "P0 or P1" with no noun after it is a summary candidate too', () => {
const line = '- `missing_verdict` cannot occur alongside P0 or P1';
expect(rows('red-team', reply(ZERO, line))).toEqual([['P0', line.slice(0, 40), true]]);
expect(lowered('red-team', reply(ZERO, line))).toMatchObject({ ok: true, dismissed: ['red-team#1'] });
});
test('negative controls: a status or list that leads a claim, a located line and a reply with no blocking=0 still block', () => {
expect(rows('red-team', reply(ZERO, '- a deferred CRITICAL: the gate drops rows.'))[0]![2]).toBe(false);
expect(rows('red-team', reply(ZERO, '- a deferred CRITICAL in lib/gate.ts:12 drops rows.'))[0]![2]).toBe(false);
expect(rows('red-team', reply(ZERO, '- the CRITICAL path drops rows.'))[0]![2]).toBe(false);
expect(rows('red-team', reply('REVIEW_VERDICT: blocking=1', '- a deferred CRITICAL and a gate finding.'))[0]).toEqual(['CRITICAL', '- a deferred CRITICAL and a gate finding', false]);
expect(parseReply('red-team', '- `missing_verdict` cannot occur alongside P0 or P1', true, false).findings.map(f => [f.label, !!f.summary])).toEqual([['P0', false]]);
expect(lowered('red-team', reply(ZERO, '- a deferred CRITICAL: the gate drops rows.'))).toMatchObject({ ok: false, downgraded: ['red-team#1'] });
});
});
+8 -8
View File
@@ -110,9 +110,9 @@ describe('GST-951: the receipt counts every blocker the readers found', () => {
pass(path.join(run, 'p1'), [['specialist/security', '- [INFORMATIONAL] lib/review-depth.ts:1a a CSS escape\n- [INFORMATIONAL] lib/review-depth.ts:1b a zero-padded reference\n- [INFORMATIONAL] lib/review-depth.ts:1c a split handler line'], ['red-team', CLEAN]]);
pass(path.join(run, 'p2'), [['red-team', '[CRITICAL] lib/review-depth.ts:212 a stray quote hides an external href from the drawing check']]);
pass(path.join(run, 'p2-voices'), [['outside-voice', OUTSIDE_CLEAN], ['adversarial-native', 'lib/review-depth.ts:300 CSS image-set() loads an outside image. FIXABLE\nRecommendation: fix because the drawing loads a remote URL']]);
expect(loop(summary(repo, '--no-ledger'))).toMatchObject({ passes: 2, blocking_found: 1, noted: 8, fixed: 4, fix_checks: 3, rounds: 5 });
expect(loop(summary(repo, '--no-ledger'))).toMatchObject({ passes: 2, blocking_found: 1, noted: 8, fixed: 4, fix_checks: 3, rounds: 2 });
const s = loop(summary(repo, '--run', run));
expect(s).toMatchObject({ passes: 2, blocking_found: 2, deferred: 0, noted: 8, fixed: 4, fix_checks: 3, rounds: 5, unrecorded: 1, ledgers_read: 3 });
expect(s).toMatchObject({ passes: 2, blocking_found: 2, deferred: 0, noted: 8, fixed: 4, fix_checks: 3, rounds: 2, unrecorded: 1, ledgers_read: 3 });
});
// #3837 (reconstruction): pass 1's row was logged before the outside voice's seven findings were classified, so they sit in the
@@ -131,12 +131,12 @@ describe('GST-951: the receipt counts every blocker the readers found', () => {
...seven.map((f, i) => `${i + 1}. ${f.fingerprint.split(':').slice(0, 2).join(':')} finding ${i + 1} Severity: High Blocks: yes`),
'Recommendation: fix 1-6 because a self-grandfathered row skips every plan rule',
].join('\n')]]);
expect(loop(summary(repo, '--no-ledger'))).toMatchObject({ passes: 2, blocking_found: 0, noted: 11, fixed: 0, fix_checks: 3, rounds: 5 });
expect(loop(summary(repo, '--no-ledger'))).toMatchObject({ passes: 2, blocking_found: 0, noted: 11, fixed: 0, fix_checks: 3, rounds: 2 });
const s = loop(summary(repo, '--run', run));
expect(s).toMatchObject({ passes: 2, blocking_found: 7, noted: 11, fixed: 0, unrecorded: 7, ledgers_read: 2, rounds: 5 });
expect(s).toMatchObject({ passes: 2, blocking_found: 7, noted: 11, fixed: 0, unrecorded: 7, ledgers_read: 2, rounds: 2 });
const line = runBin(repo, 'gstack-review-scope', ['summary', '--since', SINCE, '--run', run]);
expect(line.out.trim()).toBe('REVIEW_LOOP: passes=2 blocking_found=7 deferred=0 noted=11 fixed=0 scope=frozen unrecorded=7 ledgers_read=2 fix_checks=3');
expect(parseReviewLoop(s)).toMatchObject({ blocking_found: 7, unrecorded: 7, ledgers_read: 2, rounds: 5 });
expect(parseReviewLoop(s)).toMatchObject({ blocking_found: 7, unrecorded: 7, ledgers_read: 2, rounds: 2 });
});
test('a blocker both sources hold counts once, and a disposed one is not unrecorded', () => {
@@ -266,7 +266,7 @@ describe('GST-986 item 5: fix-check passes and their findings count from the led
step('fc2', [['fix-check', CLEAN]]);
step('s11', [['targeted', '- [INFORMATIONAL] lib/stamp-only.ts:14 a comment names the old bound\n- [INFORMATIONAL] lib/stamp-only.ts:30 the side argument has no default test']]);
const s = loop(summary(repo, '--run', run));
expect(s).toMatchObject({ passes: 1, blocking_found: 2, fixed: 2, fix_checks: 2, rounds: 3, ledgers_read: 4 });
expect(s).toMatchObject({ passes: 1, blocking_found: 2, fixed: 2, fix_checks: 2, rounds: 1, ledgers_read: 4 });
expect(s.unrecorded).toBeUndefined();
});
@@ -283,7 +283,7 @@ describe('GST-986 item 5: fix-check passes and their findings count from the led
step('p1', [['red-team', '[CRITICAL] lib/a.ts:5 a deferred defect outside the diff\n[CRITICAL] lib/b.ts:9 a fixed defect']]);
step('fc1', [['fix-check', '[CRITICAL] lib/c.ts:3 the fix broke the caller']]);
const s = loop(summary(repo, '--run', run));
expect(s).toMatchObject({ passes: 1, blocking_found: 3, deferred: 1, fixed: 0, fix_checks: 1, rounds: 2, unrecorded: 2 });
expect(s).toMatchObject({ passes: 1, blocking_found: 3, deferred: 1, fixed: 0, fix_checks: 1, rounds: 1, unrecorded: 2 });
});
// Value: protects=a blocker the last fix-check raises again is not fixed: only a fix-check after its last occurrence follows it
@@ -317,7 +317,7 @@ describe('GST-986 item 5: fix-check passes and their findings count from the led
const r = summary(repo, '--run', run);
expect(r.err).not.toContain('REVIEW_SCOPE_UNBOUND');
const s = loop(r);
expect(s).toMatchObject({ passes: 2, blocking_found: 1, fixed: 1, fix_checks: 1, rounds: 3, ledgers_read: 3 });
expect(s).toMatchObject({ passes: 2, blocking_found: 1, fixed: 1, fix_checks: 1, rounds: 2, ledgers_read: 3 });
expect(s.unbound).toBeUndefined();
});
});
+18
View File
@@ -160,6 +160,24 @@ describe('the CLI seams', () => {
expect(r.run('gstack-approvals', ['round-grant', '--pr', '7', '--head', s, '--kind', 'fix-check', '--stop-run', 'ro', '--findings', 'f#1', '--reason', 'x', '--by', 'gstack']).status).toBe(2);
});
// Value: protects=a Captain's fix-check grant can be recorded on the /ship machine while the stopped run's marker is still there,
// as a relay naming the Captain's message, and never as an unrelayed row inside the run; fails_when=round-grant refuses the relay
// (APPROVAL_RECORD_INVALID, #4531) or accepts an unrelayed grant inside an open run; why_new=#4531's fix-check grant could not be
// recorded; seam=gstack-approvals round-grant; no_claim=-
test('#4531: inside an open /ship run a grant records only as a relay with --owner-ref and --words', () => {
const r = stopRepo();
const s = r.head();
fs.writeFileSync(path.resolve(r.f.work, r.f.git('rev-parse', '--git-path', 'gstack-ship-run').stdout.trim()), 'ro\n');
const grant = (extra: string[]) => r.run('gstack-approvals', ['round-grant', '--pr', '7', '--head', s, '--kind', 'fix-check', '--stop-run', 'ro', '--findings', 'p1/red-team#2', '--reason', 'fixable blocker', '--by', 'Captain GStack Minder (GSTA-36)', ...extra]);
const bare = grant([]);
expect([bare.status, bare.stderr]).toEqual([2, expect.stringContaining('/ship run ro is open on this checkout')]);
expect(grant(['--owner-ref', 'GSTA-36:2026-11-19T12:29:59Z']).status).toBe(2);
expect(grant(['--owner-ref', 'not a ref', '--words', 'one fix-check']).status).toBe(2);
const relayed = grant(['--owner-ref', 'GSTA-36:2026-11-19T12:29:59Z', '--words', 'one fix-check for red-team#2']);
expect(relayed.status, relayed.stderr).toBe(0);
expect(r.run('gstack-approvals', ['list', '--json']).stdout).toContain('relayed:GSTA-36:2026-11-19T12:29:59Z');
});
// Value: protects=GST-2968's own shape end to end: the read-only run stops, the stop is recorded, a fix-check grant is recorded after
// it, history (as preflight runs it) routes the fix-check and the plan plans it; fails_when=history prints read-only and the plan
// prints next=full; seam=gstack-ship-receipt stop/history/claim, gstack-review-plan
+45 -1
View File
@@ -14,7 +14,8 @@ import { gateDispositionText, type GateDisposition } from '../lib/gate-dispositi
import { EXIT as POST_EXIT, runPost, type PostEnv } from '../lib/gstack-post';
import { deferredRecord, renderDeferredSection } from '../lib/review-scope';
import { ruledNoteRow, ruledNoteText, type RuledNote } from '../lib/ruled-notes';
import { securityFingerprints } from '../lib/security-findings';
import { publicRoundGrant, type ReviewRoundGrant } from '../lib/review-round-grant';
import { REDACTED_REASON, securityFingerprints } from '../lib/security-findings';
import { RELEASE, shipFixture, type ShipFx } from './helpers/ship-bin-fixture';
setDefaultTimeout(90_000);
@@ -183,5 +184,48 @@ describe('a red-team finding the owner ruled not security class (gstack-evals #3
expect(write.status, write.stderr).toBe(EXIT.ok);
expect(fs.readFileSync(body, 'utf8')).toContain('"not_security": true');
});
// Value: protects=a fix-check grant naming a red-team finding the owner ruled not security class, or another security finding, never
// puts the raw fingerprint into the receipt, so gstack-post accepts the body; fails_when=the receipt's review_round_grants copies
// README.md:515:red-team as gbrain-evals#567's did; why_new=GBEV-103 had to publish #567's body with another tool; seam=gstack-ship-receipt
// write with the grant and ruling in the approval store, then gstack-post's own fingerprint check; no_claim=-
test.skipIf(process.platform === 'win32')('a round grant\'s finding list carries the ruled public form or an opaque id, never the fingerprint (gbrain-evals#567)', () => {
const f = shipFixture({ 'src/x.ts': 'export const x = 1;\n' }, { 'src/x.ts': 'export const x = 2;\n' });
ships.push(f);
fs.writeFileSync(path.join(f.root, 'stub', 'gh'), '#!/bin/sh\ncase "$*" in *visibility*) echo PUBLIC ;; *) exit 1 ;; esac\n', { mode: 0o755 });
const run = (bin: string, args: string[]) => f.run(path.join(BIN, bin), args, { GSTACK_APPROVALS_MIRROR: '0' });
const head = f.git('rev-parse', 'HEAD').stdout.trim();
const ruled = run('gstack-approvals', ['rule', '--finding', 'README.md:515:red-team', '--head', head, '--reason', 'README wording about the power figure; not a security finding', '--words', 'not security', '--by', 'Fixture Owner', '--not-security']);
expect(ruled.status, ruled.stderr).toBe(0);
const grant = run('gstack-approvals', ['round-grant', '--pr', '7', '--head', head, '--kind', 'fix-check', '--stop-run', 'run1', '--findings', 'test/x.test.ts:70:functional-contract,README.md:515:red-team,src/net/retry.ts:42:security', '--reason', 'branch-caused failures', '--by', 'Fixture Captain']);
expect(grant.status, grant.stderr).toBe(0);
const body = path.join(f.root, 'body.md');
fs.writeFileSync(body, `## Pre-Landing Review\n\n${run('gstack-approvals', ['rulings']).stdout.trim()}\n`);
const write = run('gstack-ship-receipt', ['write', '--pr', '7', '--base', 'main', '--version', '1.0.0', '--session-kind', 'unattended', '--body', body]);
expect(write.status, write.stderr).toBe(EXIT.ok);
const text = fs.readFileSync(body, 'utf8');
expect(securityFingerprints(text)).toEqual([]);
expect(text).toContain('"README.md:515 (red-team, ruled not security class)"');
expect(text).toContain('"test/x.test.ts:70:functional-contract"');
expect(text).toMatch(/"sf-[0-9a-f]{12}"/);
expect(leaks(text, 'src/net/retry.ts:42', 'retry.ts')).toEqual([false, false]);
});
});
// Value: protects=a round grant whose finding list names an unruled security finding publishes neither the fingerprint nor the grant's
// free-text reason, which can describe the hole, while a grant whose only security finding the owner ruled not security class keeps
// its reason; fails_when=publicRoundGrant redacts the findings and passes the reason through; seam=publicRoundGrant, the one mapping
// gstack-ship-receipt write applies to review_round_grants; no_claim=the approval record's own private copy
describe('round grants in the receipt', () => {
const grant = (findings: string[]): ReviewRoundGrant => ({ kind: 'fix-check', head: HEAD, pr: 7, by: 'Fixture Captain', reason: SECRET_REASON, at: '2026-11-18T00:00:00Z', approval: 'a-0123456789ab', stop_run: 'run1', findings });
test('an unruled security finding redacts the reason too; a ruled-not-security one and a plain grant keep it', () => {
const hidden = JSON.stringify(publicRoundGrant(grant([SEC, 'test/x.test.ts:70:functional-contract']), []));
expect(leaks(hidden, 'src/net/retry.ts', SECRET_REASON)).toEqual([false, false]);
expect(hidden).toContain(REDACTED_REASON);
expect(securityFingerprints(hidden)).toEqual([]);
const ruled = publicRoundGrant(grant(['README.md:515:red-team']), [{ ...note('README.md:515:red-team', 'README wording'), not_security: true }]);
expect(ruled).toMatchObject({ reason: SECRET_REASON, findings: ['README.md:515 (red-team, ruled not security class)'] });
expect(publicRoundGrant(grant(['test/x.test.ts:70:functional-contract']), [])).toEqual(grant(['test/x.test.ts:70:functional-contract']));
});
});
+2 -2
View File
@@ -262,8 +262,8 @@ describe('gstack-ship-preflight', () => {
fs.writeFileSync(path.join(f.root, 'body.json'), JSON.stringify({ body }));
f.gh(`case "$*" in *"pr view"*) cat '${path.join(f.root, 'body.json')}';; *) echo 7;; esac`);
const r = f.run(PREFLIGHT, ['--base', 'main']);
expect(lineOf(r.stdout, 'PR_REVIEW_HISTORY')).toMatch(/^PR_REVIEW_HISTORY: pr=#7 rounds=4 cap=2 full=2 /);
expect(lineOf(r.stdout, 'PR_REVIEW_FLAGS')).toBe('PR_REVIEW_FLAGS: --prior-rounds 4 --prior-full 2');
expect(lineOf(r.stdout, 'PR_REVIEW_HISTORY')).toMatch(/^PR_REVIEW_HISTORY: pr=#7 rounds=2 cap=2 full=2 /);
expect(lineOf(r.stdout, 'PR_REVIEW_FLAGS')).toBe('PR_REVIEW_FLAGS: --prior-rounds 2 --prior-full 2');
expect(lineOf(r.stdout, 'PR_REVIEW_ROUTE')).toMatch(/^PR_REVIEW_ROUTE: read-only \(the PR had 2 full review rounds; this head gets one read-only full review/);
expect(r.stdout).not.toMatch(/--recheck|drift_lines|recheck_blocked/);
});