Review read names the findings that owner rulings leave open (GST-3267) (#4553)

When owner rulings don't clear a stopped review, `gstack-review-read`
now names each finding still missing a ruling (a `noted` CRITICAL
included), and for a gate finding the `gate_id` its gate disposition
needs.

Why: on harness-evals#498 all 22 rulings applied, yet both rows stayed
unverified because 7 duplicates were logged `noted` at CRITICAL, and
nothing said so.

Nothing to do: the review rules are unchanged; only the reason text gets
more specific.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Review-Finding: p1/specialist-batched#1 reader=specialist-batched
Review-Finding: p1/specialist-batched#2 reader=specialist-batched
This commit is contained in:
Garry Tanandcapy-ai[bot] authored and GitHub committed 2026-11-20 10:03:45 +00:00
1 parent a26529ac8e
commit bd0428974a
6 files changed
+120 -6

No files matched your search

+27 -1
View File
@@ -352,8 +352,11 @@ export const holdsOpen = (f: unknown) => !record(f) || unresolvedFinding(f) || f
* taken out the same way only when `gated` holds its `<fingerprint> <gate_id>` key (the owner's gate_disposition rows whose
* head lies in this row's range, lib/gate-dispositions.ts, GST-2491); a ruling never closes a gate finding.
*/
const isRuledBy = (ruled: ReadonlySet<string>, gated: ReadonlySet<string>) => (f: unknown) => record(f) && typeof f.fingerprint === 'string' &&
(f.gate ? (f.action === 'open' || f.action === 'kept') && gated.has(`${f.fingerprint} ${f.gate_id}`) : RULABLE.has(f.action) && ruled.has(f.fingerprint));
function withoutRuledNotes(rec: Record<string, any>, ruled: ReadonlySet<string>, gated: ReadonlySet<string>): Record<string, any> {
const isRuled = (f: unknown) => record(f) && typeof f.fingerprint === 'string' && (f.gate ? (f.action === 'open' || f.action === 'kept') && gated.has(`${f.fingerprint} ${f.gate_id}`) : RULABLE.has(f.action) && ruled.has(f.fingerprint));
const isRuled = isRuledBy(ruled, gated);
if ((!ruled.size && !gated.size) || rec.status_source === 'derived' || rec.completed !== true || !Array.isArray(rec.findings) ||
!rec.findings.some(isRuled) || rec.findings.length < Number(rec.issues_found ?? 0) ||
rec.findings.filter(f => record(f) && isCriticalFinding(f)).length < Number(rec.critical ?? 0) ||
@@ -361,6 +364,29 @@ function withoutRuledNotes(rec: Record<string, any>, ruled: ReadonlySet<string>,
return { ...rec, status: 'clean', issues_found: 0, critical: 0, informational: 0, findings: rec.findings.filter(f => !isRuled(f)) };
}
/**
* GST-3267 (harness-evals#498): why the rulings did not clear a completed pass that stopped (converged:false, bound
* `incomplete` on unchanged content). Names each finding that still holds the row open with no ruling, a `noted` or
* `deferred` CRITICAL included, and a gate finding with the gate_id its disposition needs, or says the findings list
* fewer issues than the row claims; undefined for any other row.
*/
export function rulingGap(rec: Record<string, any>, ruled: ReadonlySet<string>, gated: ReadonlySet<string>): string | undefined {
const binding = rec.review_binding;
if (!DIFF_REVIEWS.has(rec.skill) || rec.skill === 'ship' || rec.scope === 'fix-range' || rec.status_source === 'derived' ||
rec.completed !== true || rec.converged !== false || binding?.state !== 'incomplete' || !binding.start_wtree ||
binding.start_wtree !== binding.end_wtree || !Array.isArray(rec.findings)) return;
const issues = Number(rec.issues_found ?? 0), critical = Number(rec.critical ?? 0);
const listedCritical = rec.findings.filter(f => record(f) && isCriticalFinding(f)).length;
if (rec.findings.length < issues || listedCritical < critical) {
return `its findings list ${rec.findings.length} issue(s) and ${listedCritical} CRITICAL, fewer than the ${issues} issue(s) and ${critical} CRITICAL it claims, so no ruling can cover the rest`;
}
const isRuled = isRuledBy(ruled, gated);
const left = rec.findings.filter(f => !isRuled(f) && holdsOpen(f))
.map(f => !record(f) ? 'malformed finding' : `${f.fingerprint ?? 'unfingerprinted'} (${f.severity ?? 'unknown'}, ${f.action ?? 'no action'}${f.gate ? `; gate ${f.gate_id ?? 'with no gate_id'} needs a gate disposition, not a ruling` : ''})`);
if (!left.length) return;
return `${left.length} finding(s) still need an owner ruling at this head: ${left.slice(0, 10).join('; ')}${left.length > 10 ? `; +${left.length - 10} more` : ''} (a noted or deferred CRITICAL still counts as open)`;
}
export function reviewFreshness(rec: Record<string, any>, currentWtree: string, ruled: ReadonlySet<string> = new Set(), gated: ReadonlySet<string> = new Set()): { status: string; reason: string } | undefined {
if (!DIFF_REVIEWS.has(rec.skill)) return;
if (rec.skill === 'ship') return { status: 'UNVERIFIED', reason: 'ship telemetry is not a review pass' };