mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-24 00:51:31 +01:00
A base branch with too many review_exclude_paths patterns no longer stops every /ship (GST-3399) (#4637)
When the base branch's ship policy fails only because of its `review_exclude_paths` or `review_content_patterns` list (for example 65 patterns, one over the limit of 64), /ship now reviews every file instead of stopping. Why: harness-evals main went to 65 patterns, and every /ship there stopped with POLICY_INVALID, including the PR that shortens the list. Nothing to do: the plan prints a `REVIEW_EXCLUDE: fallback (WARNING: ...)` line naming the error and the fix, and `gstack-ship-policy validate` still reports the list. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> Review-Finding: p1/red-team#1 reader=red-team Review-Finding: p1/specialist-batched#1 reader=testing Review-Finding: lib/ship-receipt-depth.ts:69:stale-comment reader=core
This commit is contained in:
1 parent
2887261a47
commit
dd611038ca
15 files changed
+211
-19
No files matched your search
@@ -32,7 +32,7 @@ import { gateOutcomeLine } from '../lib/gate-outcomes';
|
||||
import { runScriptSync } from '../lib/script-invocation';
|
||||
import { baseNote } from '../lib/gate-diff/git';
|
||||
import { collectCommit, collectLive, reviewPlanTimeoutMs } from '../lib/review-collect';
|
||||
import { excludeLines, reviewExclude, type Exclusion } from '../lib/review-exclude';
|
||||
import { excludeLines, fallbackLine, reviewExclude, type Exclusion } from '../lib/review-exclude';
|
||||
import { isUnavailable } from '../lib/ship-policy';
|
||||
import { reviewPolicy } from '../lib/ship-policy-review';
|
||||
import { platformReviewAt } from '../lib/review-platform';
|
||||
@@ -249,6 +249,7 @@ function main(): number {
|
||||
if (gateTagged !== null && !Number.isFinite(gateTagged)) gateTagged = null;
|
||||
const exclusion: Exclusion = !baseSha || !collected.mergeBase ? { state: 'none' } : reviewExclude({ root, baseSha, ref, mergeBase: collected.mergeBase, perPath: collected.perPath, added: collected.added, classRoot: root, gateTagged: tagged, context: 'gstack-review-plan' });
|
||||
if (exclusion.state === 'refused') { for (const l of exclusion.lines) process.stderr.write(l + '\n'); return exclusion.code === 'REVIEW_DIFF_UNREADABLE' ? EXIT.fail : EXIT.refused; }
|
||||
if (exclusion.state === 'fallback') process.stderr.write(`gstack-review-plan: ${fallbackLine(exclusion, base)}\n`);
|
||||
const active = exclusion.state === 'active' ? exclusion : null;
|
||||
const kept = <T,>(rec: Record<string, T>) => (active ? Object.fromEntries(Object.entries(rec).filter(([p]) => !active.excluded.has(p))) : rec);
|
||||
const exclusionInput = active ? { excluded: active.excluded, exclusion: { specs: active.specs, keep: active.keep } } : {};
|
||||
@@ -310,7 +311,7 @@ function main(): number {
|
||||
if (has('--json')) {
|
||||
const { runtimeLines, stepDepth, depthReasons, ...rest } = plan;
|
||||
process.stdout.write(JSON.stringify({ ...rest, review_policy: review, platform_review: platform ? (platform.ok ? platform.review : { none: platform.reason }) : null, readers, targeted: { ...targeted, brief, targeted_patch_id: patch }, step_depth: stepDepth, runtime_lines: runtimeLines, depth_reasons: depthReasons, depth_floor: floor ?? null, gate_scan: gateScan, fix_range: fixRange ?? null, targeted_delta: targetedDeltaOut, registry: { sha: registry.sha, outputs: registry.outputs }, per_path: perPath, diff_lines: diffLines, base: collected.base, pass, audit_effort: auditEffort, scope, gate_tagged: gateTagged, paths, deleted, stamp_only: stampOnly, consumed: collected.consumed, drawings: collected.drawings, executables: collected.executables,
|
||||
...(exclusion.state === 'head-only' ? { review_exclude: exclusion } : active ? { review_exclude: { state: 'active', ...active.record, specs: active.specs, keep: active.keep, excerpt: active.excerpt, kept_files: active.kept, content: active.content, references: active.references } } : {}) }) + '\n');
|
||||
...(exclusion.state === 'head-only' || exclusion.state === 'fallback' ? { review_exclude: exclusion } : active ? { review_exclude: { state: 'active', ...active.record, specs: active.specs, keep: active.keep, excerpt: active.excerpt, kept_files: active.kept, content: active.content, references: active.references } } : {}) }) + '\n');
|
||||
return EXIT.ok;
|
||||
}
|
||||
const out = [`REVIEW_CLASS: ${plan.class} (${plan.reasons.slice(0, 3).join('; ') || 'no signals'})`, reviewDepthLine(plan), `GATE_SCAN: ${gateTagged === null ? 'unavailable' : `tagged=${gateTagged}`} head=${head}`, `REVIEW_BASE: ${ref} ${baseSha.slice(0, 12)}`,
|
||||
|
||||
@@ -17,6 +17,7 @@ import * as fs from 'node:fs';
|
||||
import * as path from 'node:path';
|
||||
import { EXIT, exitTableHelp } from '../lib/headless-artifacts';
|
||||
import { resultLine } from '../lib/result-codes';
|
||||
import { fallbackLine } from '../lib/review-exclude';
|
||||
import {
|
||||
BUMP_NEVER_KEY_VERSION, POLICY_KEYS, POLICY_KEY_INTRODUCED, SHIP_POLICY_PATH, examplePolicyJson, explainPolicy, isUnavailable, loadPolicyFromBase, loadPolicyFromHead,
|
||||
minimumReader, policyUnavailableLine, renderEffective, resolveBaseBranch, type LoadedPolicy,
|
||||
@@ -91,6 +92,8 @@ function main(argv: string[]): number {
|
||||
if (cmd === 'validate' || cmd === 'show-effective') {
|
||||
const loaded = load(root, rest, cmd === 'validate' ? 'head' : 'base');
|
||||
if (typeof loaded === 'number') return loaded;
|
||||
if (loaded.setAside && cmd === 'validate') loaded.errors = loaded.setAside;
|
||||
else if (loaded.setAside) process.stderr.write(`gstack-ship-policy: ${fallbackLine({ state: 'fallback', source: loaded.source.label, errors: loaded.setAside.map(e => `${e.path}: ${e.message}`) }, flag(rest, '--base') ?? resolveBaseBranch(root))}\n`);
|
||||
const floor: ReturnType<typeof floorAgainstStable> = cmd === 'validate' && loaded.present ? floorAgainstStable(loaded.policy.min_gstack_version, newestStableRelease()) : {};
|
||||
if (floor.error) loaded.errors.push(floor.error);
|
||||
const set = POLICY_KEYS.filter(k => loaded.values[k] && loaded.values[k] !== 'default');
|
||||
|
||||
@@ -57,7 +57,7 @@ import {
|
||||
import { checkDocsCaps, docsCapLine, docsExceptionLine, parseReceiptDocs } from '../lib/ship-receipt-docs';
|
||||
import { comparePath, contextPacket, PACKET_SECTION_CAP, readScopedReview, touchedPaths } from '../lib/ship-patch';
|
||||
import { planRecheck, recheckPacket } from '../crew/lib/ship-recheck';
|
||||
import { carryExcludeBinds, deeper, depthBelow, exceptionHead, exceptionLoopProblem, exceptionProblems, parseReviewLoopException, parseReviewTargeted, plainDocsSince, platformReceiptDepth, receiptExclude, receiptReviewAtHead, receiptTargetedAtHead, reviewLoopExceptionLine, targetedClassesSince, writeExcludeBinds } from '../lib/ship-receipt-depth';
|
||||
import { carryExcludeBinds, deeper, depthBelow, exceptionHead, exceptionLoopProblem, exceptionProblems, parseReviewLoopException, parseReviewTargeted, plainDocsSince, platformReceiptDepth, receiptExclude, receiptExcludeFallback, receiptReviewAtHead, receiptTargetedAtHead, reviewLoopExceptionLine, targetedClassesSince, writeExcludeBinds } from '../lib/ship-receipt-depth';
|
||||
import { RISK_CLASSES, type RiskClass } from '../lib/review-risk';
|
||||
import { checkReceiptProse, proseLine } from '../lib/ship-receipt-prose';
|
||||
import { resolveStateRoot } from '../lib/state-root';
|
||||
@@ -390,6 +390,7 @@ function cmdWrite(rest: string[], json: boolean): number {
|
||||
design: review.frontend ? { mode: 'static', reason: 'no preview declared' } : undefined,
|
||||
base_red: pause ? receiptBaseRed(pause) : undefined,
|
||||
review_exclude: receiptExclude(review.exclude),
|
||||
review_exclude_fallback: receiptExcludeFallback(review.exclude),
|
||||
no_stop: noStopArg(flag(rest, '--no-stop')),
|
||||
};
|
||||
} catch (e: any) { process.stderr.write(`gstack-ship-receipt write: ${e.message}\n`); return EXIT.usage; }
|
||||
@@ -824,7 +825,7 @@ function cmdCarry(rest: string[], json: boolean): number {
|
||||
const digest = review.exclude.state === 'active' ? review.exclude.record.digest : 'none';
|
||||
if (!carryExcludeBinds(review.exclude, receipt)) return refused('RECEIPT_CARRY_REFUSED', `review_exclude changed: recorded=${receipt.review_exclude?.digest ?? 'none'} now=${digest} source=${review.exclude.state === 'active' ? review.exclude.record.source : `${base} (no review_exclude_paths)`}; the receipt's digest is the --review-exclude argument write was given, and it names another selection than HEAD ${head.slice(0, 12)} has under the base policy and the two give the PR's files different selections (carry compares those, not the review ledger), so carry does not apply; run /ship on ${head.slice(0, 12)}`);
|
||||
if (depthBelow(receipt.review_depth.depth, now.depth)) return refused('RECEIPT_CARRY_REFUSED', `HEAD ${head.slice(0, 12)} needs ${now.depth} review depth (${now.reasons.join(', ')}), above the receipt's ${receipt.review_depth.depth}; run /ship on ${head.slice(0, 12)}`);
|
||||
depthField = { review_depth: { ...now, depth: deeper(receipt.review_depth.depth, now.depth) }, review_exclude: receiptExclude(review.exclude) };
|
||||
depthField = { review_depth: { ...now, depth: deeper(receipt.review_depth.depth, now.depth) }, review_exclude: receiptExclude(review.exclude), review_exclude_fallback: receiptExcludeFallback(review.exclude) };
|
||||
}
|
||||
// The rebound product_patch_id is HEAD's diff against the carry's base, so a retargeted receipt names that base from now on.
|
||||
// A receipt that records a version names HEAD's, read as write reads it: a restamp after a base merge moves it (GST-1030).
|
||||
|
||||
Reference in new issue
Block a user