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

+2 -2
View File
@@ -16,7 +16,7 @@ import type { ReviewRoundGrant } from './review-round-grant';
export interface PrReviewHistory {
/** /ship runs that reviewed (stubs and carries excluded). */
runs: number;
/** R51 rounds: full and scoped passes plus fix-checks, every run and started stub. */
/** R51 rounds: full and scoped passes, every run and started stub; a fix-check is no round (fix_checks counts it). */
rounds: number;
full: number;
scoped: number;
@@ -31,7 +31,7 @@ export interface PrReviewHistory {
source: 'pr-body';
}
const roundsOf = (l: ReceiptRun['review_loop']) => (l ? (l.rounds ?? (l.passes ?? 0) + (l.fix_checks ?? 0)) : 0);
const roundsOf = (l: ReceiptRun['review_loop']) => l?.passes ?? 0;
/** Every entry the body records, oldest first: the runs block, then the current receipt. */
function entries(body: string): ReceiptRun[] {
+4 -2
View File
@@ -329,7 +329,8 @@ export function parseFindings(reader: string, output: string, fixableRaises = tr
export interface VerdictCheck { state: 'valid' | 'missing' | 'malformed'; parsed: number; declared?: number; agrees?: boolean; why?: string }
export interface ReplyFinding { label: string; raw: string; summary?: true; synthetic?: true }
const FINDING_KIND = new RegExp(`(?<![A-Za-z0-9])${SEV_LIST}\\s+findings?(?![A-Za-z0-9])(?!\\s*:)`, 'g');
const KIND_STATUS = '(?:noted|deferred|ruled|dismissed|lowered|downgraded|duplicate|folded)';
const FINDING_KIND = new RegExp(`(?<![A-Za-z0-9])(?:${SEV_LIST}\\s+(?:findings?|duplicates?)|${KIND_STATUS}\\s+${SEV_LIST}|${SEV}(?:\\s*(?:,|/|\\bor\\b|\\band\\b|\\bnor\\b)\\s*${SEV})+)(?![A-Za-z0-9])(?!\\s*:)`, 'g');
const blockingRow = (f: { label: string; raw: string }) => (rank(f.label) ?? 0) >= 4 && !statesNoBlocks(f.raw);
/**
@@ -340,7 +341,8 @@ const blockingRow = (f: { label: string; raw: string }) => (rank(f.label) ?? 0)
* is not one, and in a NO FINDINGS reply a list item is not one either, GST-2972) and no Blocks: yes a summary candidate, whether a CRITICAL or P0 word or the native voice's FIXABLE raise made it block. It still
* blocks until lead judgment lowers it with a reason. A reply whose valid line declares blocking=0 marks the same way, at its own label,
* each single-line bullet with no structure, no file:line and no label beyond severities naming findings as a kind (`- a HIGH finding still
* refused;`, `- \`missing_verdict\` can't occur alongside P0 or P1 findings.`, #4518 and #4519): a scope list or passed check the lead
* refused;`, `- \`missing_verdict\` can't occur alongside P0 or P1 findings.`, #4518 and #4519), a list of severities (`P0 or P1`), or a
* status a finding already has (`noted CRITICAL duplicates`, `a deferred CRITICAL`, #4553): a scope list or passed check the lead
* may lower with a reason, though `- Two P0 findings remain unfixed.` has the same shape, so it still blocks until judged.
*/
export function parseReply(reader: string, output: string, fixableRaises = true, asked = false): { findings: ReplyFinding[]; verdict?: VerdictCheck } {
+15 -1
View File
@@ -9,7 +9,8 @@
*/
import { spawnSync } from './spawn-sync';
import { locate, readRecord, type ApprovalRow, type Env } from './approval-record';
import { isGstackActorName } from './ruled-notes';
import { isGstackActorName, publicRuledNote, type RuledNote } from './ruled-notes';
import { isSecurityFinding, opaqueFindingId, REDACTED_FINDING, REDACTED_REASON } from './security-findings';
export const ROUND_GRANT_KINDS = ['extra-round', 'fix-check'] as const;
export type RoundGrantKind = (typeof ROUND_GRANT_KINDS)[number];
@@ -38,6 +39,19 @@ export function reviewRoundGrants(rows: readonly ApprovalRow[]): ReviewRoundGran
return out;
}
/**
* A grant as the receipt in the PR body may carry it: a security-class finding it names leaves its fingerprint in the approval
* record (lib/security-findings.ts). One the owner ruled not security class shows as that ruling's public text does, and any
* other becomes an opaque id, so gstack-post never refuses the receipt over a grant's finding list (gbrain-evals#567). The grant's
* reason is free text that can describe the finding, so it becomes REDACTED_REASON whenever a security finding stays hidden.
*/
export function publicRoundGrant(g: ReviewRoundGrant, ruled: readonly RuledNote[]): ReviewRoundGrant {
if (!g.findings?.some(f => isSecurityFinding(f))) return g;
const shown = (f: string) => { const n = ruled.find(r => r.finding === f && r.not_security); return n ? publicRuledNote(n).finding : undefined; };
const hidden = g.findings.some(f => isSecurityFinding(f) && (shown(f) ?? REDACTED_FINDING) === REDACTED_FINDING);
return { ...g, findings: g.findings.map(f => !isSecurityFinding(f) ? f : shown(f) ?? opaqueFindingId(f, `round grant ${g.approval}`)), ...(hidden ? { reason: REDACTED_REASON } : {}) };
}
export function readReviewRoundGrants(cwd: string, env: Env = process.env): ReviewRoundGrant[] {
const loc = locate({ cwd, env });
return 'code' in loc ? [] : reviewRoundGrants(readRecord(loc).rows);
+2 -2
View File
@@ -289,7 +289,7 @@ export interface ReviewLoopSummary {
fix_checks?: number;
/** Passes that were scoped repeats (`"scope":"scoped"` rows): rounds, not full rounds (GST-2673). */
scoped?: number;
/** Review rounds (R51): passes plus fix-checks; the loop caps them at 2. */
/** Review rounds (R51): full and scoped passes. A fix-check reads only a round's fixes, so like any re-check of what changed it is no round; fix_checks counts it. */
rounds?: number;
/** Reviewer dispatches of this invocation by role (specialist, red-team, adversarial-native, outside-voice, fix-check, targeted). */
dispatches?: Record<string, number>;
@@ -504,7 +504,7 @@ export function summarizeReviewLoop(rows: readonly Record<string, any>[], since:
if (voided.length) out.voided = voided;
const fixChecks = Math.max(rowFixChecks, fixCheckStarts.length);
if (fixChecks) out.fix_checks = fixChecks;
out.rounds = passes.length + fixChecks;
out.rounds = passes.length;
const scopedPasses = passes.filter(r => r.scope === 'scoped').length;
if (scopedPasses) out.scoped = scopedPasses;
const byRole: Record<string, number> = {};
+1 -1
View File
@@ -482,7 +482,7 @@ export function receiptDepthVerdict(root: string, baseRef: string, r: ShipReceip
const need = depthOfCommitInput({ ...c, scope, gateTagged: tagged, ...riskPathsOf(review), ...(x.state === 'active' ? { excluded: x.excluded } : {}) });
const have = rd?.depth;
const inputs = `base@${short(baseSha.ok ? baseSha.out : null)},registry@${short(c.registry.sha)},gate_scan@${scanBound ? short(rd!.gate_scan.head) : 'missing'}`;
const line = `REVIEW_DEPTH: receipt=${have ?? 'none'} required=${need.depth} runtime_lines=${need.runtimeLines} class=${need.class} reasons=${need.reasons.join(',')} inputs=${inputs} rounds=${r.review_loop?.rounds ?? (r.review_loop ? r.review_loop.passes + (r.review_loop.fix_checks ?? 0) : 'none')}`;
const line = `REVIEW_DEPTH: receipt=${have ?? 'none'} required=${need.depth} runtime_lines=${need.runtimeLines} class=${need.class} reasons=${need.reasons.join(',')} inputs=${inputs} rounds=${r.review_loop?.rounds ?? r.review_loop?.passes ?? 'none'}`;
if (have === 'platform') {
const pr = rd!.platform_review;
const fits = need.depth === 'light' && platformFits(need.class, c.paths, need.runtimeLines, scanNumbers(c.added));