Code changes get a second-model review of their final fixes, and the shipping record names that model's family (GST-4140) (#4886)

When a code change's first review leads to fixes, the second-model
review now reads those fixes and the final review again, instead of
being skipped once it had run.

A reviewer from the same model family as the author (a Claude reader
checking Claude's work) no longer counts as the second model, and the
review record names the model family that reviewed.

Nothing to do: when the second model can't run (Codex down, rate-limited
or refused), that is still recorded and never blocks shipping.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Review-Finding: p1/specialist-batched#1 reader=testing
Review-Finding: p1/red-team#1 reader=red-team
Review-Finding: s11/outside-voice#1 reader=outside-voice
Review-Finding: s11/outside-voice#2 reader=outside-voice
Review-Finding: s11/outside-voice#3 reader=outside-voice
Review-Finding: s11/outside-voice#4 reader=outside-voice
Review-Finding: s11/adversarial-native#1 reader=adversarial-native
Review-Finding: s11/adversarial-native#2 reader=adversarial-native
Review-Finding: s11/adversarial-native#3 reader=adversarial-native
Review-Finding: s11/adversarial-native#5 reader=adversarial-native
Review-Finding: s11/adversarial-native#7 reader=adversarial-native
This commit is contained in:
Garry Tanandcapy-ai[bot] authored and GitHub committed 2026-11-28 22:51:30 +00:00
1 parent 942a12c618
commit 4a40464ea7
20 files changed
+557 -38

No files matched your search

+22 -3
View File
@@ -23,7 +23,8 @@ import * as fs from 'node:fs';
import * as path from 'node:path';
import { EXIT, exitTableHelp } from '../lib/headless-artifacts';
import { BRIEF_ROLES, BriefError, briefFile, checkReviewedTree, checkoutRoot, checkoutTree, promptHash, renderBrief, sectionTexts, sliceDiff, sliceNote, withWorkspace, type BriefRole, type Slots, type TreeCheck } from '../lib/review-brief';
import { cleanMarkers, collect, fixableRaises, mayBeUnavailable, parseReply, readJsonl, readLedger, readerKey, recordJudgment, recordSent, appendEvent, verify, type JudgedLine, type MergedLine, type VerdictCheck, type VerifyRow } from '../lib/review-ledger';
import { cleanMarkers, collect, fixableRaises, mayBeUnavailable, outsideVoiceRecord, parseReply, readJsonl, readLedger, readerKey, recordJudgment, recordSent, appendEvent, verify, type JudgedLine, type MergedLine, type VerdictCheck, type VerifyRow } from '../lib/review-ledger'
import { outsideProvenance, sameFamily } from '../lib/outside-voice-record';
import { SLICE_CAP, listSha, planNote, planSlices, selectionNames, sliceMembers, sliceOf, sliceSelection, verifySlices } from '../lib/review-slices';
import { buildManifest, checklistFile, chunkCount, chunkOf, manifestPath, markReader, planCyberRetry, readManifest, renderStage, withAuditModel, writeManifest, STAGES, type Extra, type Manifest, type PassReader, type ReaderState, type Stage } from '../lib/review-pass';
import { classifyOutsideReview } from '../lib/outside-review-result';
@@ -61,6 +62,10 @@ const HELP = `gstack-review-dispatch — verbatim reviewer briefs and loss-free
sent --ledger <f> --role <role> [--name <n>] --sent <file>
the exact prompt a dispatch passed: BRIEF_SENT: … match, or BRIEF_MISMATCH: … (exit 1; the pass is not reviewed)
collect --ledger <f> --role <role> [--name <n>] --output <file> --merged <merged.jsonl> [--manifest <f>]
[--outside-model <id> --outside-provider <p> --native-model <id>] (the outside voice only)
the outside voice's provenance comes from those flags or else its reply's closing OUTSIDE_STATUS: line (model=, provider=);
the family always comes from the model id. A read in the native model's family is COLLECT_SAME_FAMILY (exit 1, nothing
merged): never outside coverage (GST-4140)
the reader's raw output: hashes it and appends each finding to merged.jsonl with its label as written. A reply with
no finding must carry its brief's clean marker (NO FINDINGS; the Recommendation: line for the voices); without one it is
COLLECT_NOT_REVIEWED (exit 1): a refusal, an empty reply or a reader that never saw the diff, and verify reports NOT_COLLECTED
@@ -75,6 +80,10 @@ const HELP = `gstack-review-dispatch — verbatim reviewer briefs and loss-free
JUDGMENT_REJECTED: dropped=… downgraded=… (exit 1). An empty merged.jsonl needs no judged file: judge writes an
empty one and prints JUDGMENT: ok nothing to judge; a merge with findings and no judged file is refused (exit 2)
verify --ledger <f> [--targeted-out <file>]
on a clean ledger prints OUTSIDE_VOICE_RECORD: {"status","provider","model","family"[,"native_family"][,"reason"]} for the last
collected outside voice (gstack-ship-receipt write --outside-voice takes it; completed only for a recognized family beside a
different recognized native family, else unavailable with the reason); a dirty ledger prints OUTSIDE_VOICE_RECORD_WITHHELD
instead. A same-family outside read is OUTSIDE <reader> SAME_FAMILY, dirty
BRIEF, OUTPUT and JUDGE rows from the ledger alone, then VERIFY: clean (exit 0), VERIFY: dirty (exit 1) or
VERIFY: no brief records (exit 3: this run's ledger kept no prompts). A ledger with a targeted brief also prints
TARGETED_RECORD: and --targeted-out writes it as the JSON gstack-ship-receipt write --review-targeted reads; under
@@ -669,6 +678,14 @@ function main(): number {
const unavailable = flag('--unavailable');
if (unavailable !== undefined && !mayBeUnavailable(reader)) { process.stderr.write(`gstack-review-dispatch collect: --unavailable is for the outside voice only; ${reader}'s missing coverage leaves the review incomplete, never clean\n`); return EXIT.usage; }
if (unavailable !== undefined && !unavailable.trim()) { process.stderr.write('gstack-review-dispatch collect: --unavailable needs a reason\n'); return EXIT.usage; }
const voiceFlags = ['--outside-model', '--outside-provider', '--native-model'].filter(f => flag(f) !== undefined);
if (voiceFlags.length && !mayBeUnavailable(reader)) { process.stderr.write(`gstack-review-dispatch collect: ${voiceFlags.join(', ')} record the outside voice's provenance; ${reader} is not the outside voice\n`); return EXIT.usage; }
const outside = mayBeUnavailable(reader) ? outsideProvenance({ model: flag('--outside-model'), provider: flag('--outside-provider'), nativeModel: flag('--native-model'), output }) : undefined;
const same = outside && unavailable === undefined ? sameFamily(outside) : undefined;
if (same) {
process.stdout.write(`COLLECT_SAME_FAMILY: reader=${reader} model=${outside!.model} family=${outside!.family} native=${outside!.native_model} (${same}: a same-family fallback is one voice, never outside coverage; nothing was merged. Rerun the outside voice on another family. When no other family can read it, record the missing second-model read by collecting a file that holds only the reason, not this reply (--unavailable refuses output that holds findings), with --unavailable '<reason>')\n`);
return EXIT.fail;
}
const asked = readLedger(ledger).filter(e => e.event === 'rendered' && e.reader === reader).at(-1)?.verdict === 1;
const held = () => parseReply(reader, output, true, asked).findings.length;
if (unavailable !== undefined && held()) { process.stderr.write(`gstack-review-dispatch collect: ${reader}'s output holds findings; collect it without --unavailable so none is lost\n`); return EXIT.usage; }
@@ -676,14 +693,14 @@ function main(): number {
const tree = unavailable === undefined && rendered && 'tree' in rendered ? checkReviewedTree(output, typeof rendered.tree === 'string' ? rendered.tree : null) : undefined;
if (tree && !tree.ok && mayBeUnavailable(reader) && !held()) {
const why = `reviewed another tree: reported ${tree.reported}, expected ${tree.expected}`;
const r = collect(ledger, reader, output, merged, path.resolve(outFile!), why);
const r = collect(ledger, reader, output, merged, path.resolve(outFile!), why, undefined, true, outside);
process.stdout.write(`COLLECT_UNAVAILABLE: reader=${reader} sha256=${r.sha} reason=${JSON.stringify(why)} (missing outside coverage: unavailable, never clean)\n`);
return EXIT.ok;
}
const mf = flag('--manifest');
let plan: ReturnType<typeof readManifest> | undefined;
try { plan = mf ? readManifest(mf) : undefined; } catch (e) { process.stderr.write(`gstack-review-dispatch collect: ${(e as Error).message}; native FIXABLE collects as CRITICAL\n`); }
const r = collect(ledger, reader, output, merged, path.resolve(outFile!), unavailable, tree, fixableRaises(plan && path.resolve(plan.ledger) === path.resolve(ledger) ? plan.plan_lines : undefined));
const r = collect(ledger, reader, output, merged, path.resolve(outFile!), unavailable, tree, fixableRaises(plan && path.resolve(plan.ledger) === path.resolve(ledger) ? plan.plan_lines : undefined), outside);
if (tree && !tree.ok) {
if (mf && plan) { markReader(plan, reader, 'failed', { output: outFile, error: `reviewed another tree: ${tree.reported}` }); writeManifest(mf, plan); }
process.stdout.write(wrongTree(reader, tree));
@@ -734,6 +751,8 @@ function main(): number {
if (sel && 'mixed' in sel) process.stdout.write(`REVIEW_EXCLUDE_RECORD: mixed digests=${sel.mixed.join(',')} (readers read different review_exclude_paths selections; rerun the review so every reader reads HEAD's)\n`);
for (const r of slices) process.stdout.write(`${r.kind} ${r.reader} ${r.status} ${r.detail}\n`);
const clean = v.clean && !(sel && 'mixed' in sel) && slices.every(r => r.status === 'MATCH');
const voice = outsideVoiceRecord(ledger);
if (voice) process.stdout.write(clean ? `OUTSIDE_VOICE_RECORD: ${JSON.stringify(voice)}\n` : 'OUTSIDE_VOICE_RECORD_WITHHELD: VERIFY is dirty, so the outside voice\'s record does not bind; fix the rows above and verify again\n');
if (v.verdicts.asked) process.stdout.write(`VERIFY_VERDICT: agree=${v.verdicts.agree} asked=${v.verdicts.asked} (informational: a disagreeing count already counts its blockers; docs/review-policy.md#verdict-line)\n`);
process.stdout.write(`VERIFY: ${clean ? 'clean' : 'dirty'} briefs=${v.briefs} outputs=${v.rows.filter(r => r.kind === 'OUTPUT').length} voided=${v.voided}${v.unavailable ? ` unavailable=${v.unavailable}` : ''}\n`);
return clean ? EXIT.ok : EXIT.fail;
+19 -1
View File
@@ -7,7 +7,7 @@
* [--session-kind <k>] [--artifacts-consumed <n>/<m>] [--run <id>] [--thread <id>]
* [--receipt <tree-receipt.json>] [--policy <label>] [--preregistration <text>] [--history <text>]
* [--pregate <pregate.json>] [--issues <json|@file>] [--approval <line>]... [--approval-run <dir>]...
* [--base-red <pause.json>]
* [--base-red <pause.json>] [--outside-voice <OUTSIDE_VOICE_RECORD json|@file>]
* [--out <file>] [--body <pr-body.md>] [--json]
* gstack-ship-receipt read --pr <n> [--repo <owner/repo>] [--check-prose] [--json]
* gstack-ship-receipt read --body <file> [--json]
@@ -161,6 +161,10 @@ write flags: --pr --head --base --version --gated-tree --predecessor --gate <jso
another run refuses (GST-1616).
--no-stop <json|@file> (a JSON array of {class, reason, evidence}: each routine stop the run recorded and went on past, class one of
test-timeout-fix, pregate-flake-rerun, autoplan-regate; gstack-no-stop refuses the retired scoped-fix-check); recorded as no_stop.
--outside-voice <json|@file> (gstack-review-dispatch verify's OUTSIDE_VOICE_RECORD: {status, provider, model, family}, its JSON or
text holding the line, such as verify's whole output): recorded as outside_voice; status completed, unavailable or skipped. A
completed read needs a recognized family and a different recognized native_family; anything else completed is RECEIPT_INVALID.
Missing coverage is unavailable or skipped, never blocking (GST-4140).
--declare-risk <classes> (the same list gstack-review-plan --declare-risk took): joins review_depth's risk and only raises
its depth; review_depth.declared and .detected record both lists (GST-1129). An unknown class is RECEIPT_INVALID.
--platform-review <id> (NEXT: platform's PLATFORM_REVIEW: id): records review_depth platform with capy-ai[bot]'s review <id> at HEAD;
@@ -193,6 +197,19 @@ function jsonArg(raw: string | undefined): Record<string, unknown> | undefined {
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) throw new Error('expected a JSON object');
return parsed;
}
/**
* --outside-voice: verify's OUTSIDE_VOICE_RECORD: JSON (one line or pretty-printed), or text holding its OUTSIDE_VOICE_RECORD: line
* such as verify's whole output, or @<file> holding either (GST-4140); validateReceipt checks it.
*/
function outsideVoiceArg(raw: string | undefined): ShipReceipt['outside_voice'] {
if (raw === undefined) return undefined;
const text = (raw.startsWith('@') ? fs.readFileSync(raw.slice(1), 'utf8') : raw).trim();
const parse = (s: string) => { try { return { v: JSON.parse(s) }; } catch { return undefined; } };
const line = text.split('\n').map(l => l.trim()).filter(l => l.startsWith('OUTSIDE_VOICE_RECORD:')).at(-1);
const got = parse(text) ?? (line === undefined ? undefined : parse(line.slice('OUTSIDE_VOICE_RECORD:'.length).trim()));
if (got) return got.v;
throw new Error(`--outside-voice expects the JSON gstack-review-dispatch verify prints after OUTSIDE_VOICE_RECORD: ({"status","provider","model","family"}), or text holding that line; verify prints it only when VERIFY is clean. Got ${JSON.stringify(text.slice(0, 120))}`);
}
/** --no-stop <json|@file>: the routine stops this run recorded and went on past (K1), a JSON array of {class, reason, evidence}. */
function noStopArg(raw: string | undefined): ShipReceipt['no_stop'] {
if (raw === undefined) return undefined;
@@ -411,6 +428,7 @@ async function cmdWrite(rest: string[], json: boolean): Promise<number> {
review_exclude_fallback: receiptExcludeFallback(review.exclude),
docs_audit_read: excludeBound.read,
no_stop: noStopArg(flag(rest, '--no-stop')),
outside_voice: outsideVoiceArg(flag(rest, '--outside-voice')),
};
} catch (e: any) { process.stderr.write(`gstack-ship-receipt write: ${e.message}\n`); return EXIT.usage; }
if (input.pr !== undefined && !Number.isInteger(input.pr)) { process.stderr.write('gstack-ship-receipt write: --pr must be an integer\n'); return EXIT.usage; }