diff --git a/bin/gstack-review-plan b/bin/gstack-review-plan
index 7ffb503b7..3e12f65f2 100755
--- a/bin/gstack-review-plan
+++ b/bin/gstack-review-plan
@@ -247,7 +247,7 @@ function main(): number {
if (flag('--gate-tagged') !== undefined) gateTagged = Number(flag('--gate-tagged'));
} else gateTagged = flag('--gate-tagged') !== undefined ? Number(flag('--gate-tagged')) : gateTagsOf([diffBase]);
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' });
+ 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', vendoredFetch: true });
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;
@@ -311,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' || 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');
+ ...(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, ...(active.vendored ? { vendored_selection: active.vendored } : {}) } } : {}) }) + '\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)}`,
diff --git a/changelog.d/review-skips-verified-vendored-files.md b/changelog.d/review-skips-verified-vendored-files.md
new file mode 100644
index 000000000..9259cb54b
--- /dev/null
+++ b/changelog.d/review-skips-verified-vendored-files.md
@@ -0,0 +1 @@
+Review can now leave out copied open-source files that gstack has verified. When a base branch declares both `review_vendored` and `review_exclude_paths`, a matched file that is byte-for-byte its upstream's file at the pinned commit leaves the reviewers' diff, and a re-pin's deleted files are checked at the old pin. Agent instructions, config, executables, credential lines and gate-tagged files stay in review, so a gate-tagged upstream test file is still read whole. `gstack-review-plan` prints what verified and what didn't, and the verified list is part of the selection the ship receipt binds (docs/vendored-code.md#what-review-leaves-out).
diff --git a/docs/ship-policy.md b/docs/ship-policy.md
index f978731c9..728ff8190 100644
--- a/docs/ship-policy.md
+++ b/docs/ship-policy.md
@@ -77,7 +77,7 @@ branch that changes the policy.
| `review_content_patterns` | git glob pathspecs | `[]` | Files that `review_exclude_paths` also matches and that count as content whatever their extension (`.patch` files, `MANIFEST.sha256`, extension-less licence texts), so the exclusion leaves them out. Source code, agent prose, config and the other keep rules still keep a matched file in review. Explicit policy only; a pattern here with no `review_exclude_paths` pattern over the same files excludes nothing. Read from the base only. See [review_content_patterns](#review-content-patterns). Needs `min_gstack_version`. |
| `review` | `{ panel?, reader_model?, platform?, risk_paths? }` | `{ all, lane, off, [] }` | Who does `/ship`'s review, read from the base only; see [Who reads](review-policy.md#who-reads-r65-the-base-policys-review-key). `panel`: `all` (today's panel on every class) \| `risk` \| `off` (the opt-in one-reader shapes); `reader_model`: `lane`, `cross-family` or a model id; `platform`: `off` \| `on` (a docs or tests diff with no numeric, results or prereg claims whose PR carries capy-ai[bot]'s review at the exact head skips the readers); `risk_paths`: globs of code paths that count as risk class `policy`. Introduced at 1.94.30.0; needs `min_gstack_version` when set to a non-default value. |
| `readers` | `{ forbid_fetch?, forbid_paths?, brief_note? }` | `{ [], [], null }` | What `/ship`'s readers may not reach beyond the fetch rule every brief carries; see [readers](#readers). Read from the base; the head may add `forbid_fetch` entries, never remove one. Needs `min_gstack_version`. |
-| `review_vendored` | `{ upstreams, manifests }` or `null` | `null` | The repositories this repo copies unchanged files from (https URLs, or `{ url, branches }`) and the manifests that pin each copied file to a path at a commit. `gstack-vendored-verify` checks every pinned file is byte-for-byte that upstream file at a commit on the upstream's default branch or a tag; see [vendored-code.md](vendored-code.md). Read from the base only. Needs `min_gstack_version`. |
+| `review_vendored` | `{ upstreams, manifests }` or `null` | `null` | The repositories this repo copies unchanged files from (https URLs, or `{ url, branches }`) and the manifests that pin each copied file to a path at a commit. `gstack-vendored-verify` checks every pinned file is byte-for-byte that upstream file at a commit on the upstream's default branch, a tag, or a branch the base names for that upstream. Under `review_exclude_paths`, a matched file that verifies is vendored content that review can leave out; every other keep rule still applies (see [vendored-code.md](vendored-code.md#what-review-leaves-out)). Read from the base only. Needs `min_gstack_version`. |
| `min_gstack_version` | version or `null` | `null` | The oldest gstack that may read the file; see the compatibility rule above. |
| `docs` | `{ caps: [{ path, max_bytes }] }` or `null` | `null` | Documentation files with a byte cap. `/ship` Step 14.5 runs `gstack-ship-receipt docs-caps --base ` (the caps come from `origin/`'s policy, never the branch's copy; `--policy ` is for a repository bootstrapping its policy) before the verification gate and prints one `DOCS_CAP: / ok\|over` line per cap; any `over` (an absent file counts) exits 1 and blocks the ship until the file is trimmed or the cap raised on the base branch (`DOCS_AUDIT_BLOCKED`). At most 64 caps, each path contained. See [the ship receipt](#ship-receipt). Needs `min_gstack_version`. |
| `train` | `{ gate_workflow, free_workflow, full_gate_check, record_artifact, max_size, fill_hours, screen_selection, trial_reservation_usd, land? }`, `{ gates, land, max_size, fill_hours }` or `null` | `null` | Turns on [merge trains](#run-a-merge-train), read from the base revision only. Every field is required and an unknown field is `POLICY_INVALID`: `max_size` 1 to 6, `fill_hours` above 0 and at most 24, `screen_selection` `gstack-paid` \| `none`, `trial_reservation_usd` above 0 and at most 100. A block with `gates` ([any repository](#train-gates)) takes `max_size` 1 to 5 and needs `min_gstack_version` at least `TRAIN_GATES_KEY_VERSION`. `null` keeps the per-PR queue exactly as it is. Needs `min_gstack_version`. |
diff --git a/docs/vendored-code.md b/docs/vendored-code.md
index 0053786b5..889e01b07 100644
--- a/docs/vendored-code.md
+++ b/docs/vendored-code.md
@@ -146,9 +146,44 @@ The check
runs from the head's workflow file, so it is a backstop for honest mistakes; a
workflow edit is itself reviewed like any other `.github/` change.
-## What comes next
+## What review leaves out
-Today the check proves the claim. A later release lets `/ship`'s review skip
-verified files under a `review_exclude_paths` pattern while still showing
-reviewers the manifest, every pin and the lines in those files that skip or
-silence tests.
+When the base policy also lists `review_exclude_paths`, a file one of those
+patterns matches that verifies byte for byte counts as vendored content, so
+`/ship`'s reviewers can leave it out. Nothing else about the keep rules
+changes: a vendored file stays in review when it is agent prose (`AGENTS.md`,
+`CLAUDE.md`), config, executable, a link, under `.github/` or `.gstack/`, on a
+gate path, holds a credential value, or carries a gate tag. A file kept only
+for a credential line is shown as an excerpt, as any data file would be. A
+gate-tagged file is excerpted only off the gate floor, so a gate-tagged
+upstream test file (anything under `tests/`, `test/` or `spec/`) stays in
+review whole. When a re-pin deletes files, a deleted file that verifies at the
+base's pin can be left out too; a file the branch drops from the manifest but
+keeps stays in review. A file that does not verify keeps the reason it had
+before. Keep the manifest outside every `review_exclude_paths` pattern: when a
+pattern matches it, nothing counts as verified and the plan prints
+`REVIEW_VENDORED: unavailable`.
+
+`gstack-review-plan` fetches the upstreams into the cache first and prints one
+summary line, one line per pin and up to 20 files that did not verify:
+
+```text
+REVIEW_VENDORED: verified=1054 unverified=2 pins=71 digest=
+REVIEW_VENDORED_PIN: https://github.com/pallets/click@ reachable_from=tags/8.1.7 files=40 verified=40
+REVIEW_VENDORED_KEPT: mode tasks/.../tests/test_rr.py (head 100755, upstream 100755)
+```
+
+Every later step (the review dispatch, the receipt write and carry) reads the
+same cache without the network, and the verified list is part of the
+selection digest the receipt binds. A machine with an empty cache verifies
+nothing, so its selection differs and the receipt says so; run
+`gstack-vendored-verify --base ` there first. Reviewers still read the
+manifest, every pin change and all of the repo's own code. When unverified
+vendored files make a pattern keep too many files, the refusal names them as
+`REVIEW_VENDORED_KEPT` and points at `gstack-vendored-verify`.
+
+How much this saves depends on the gate tags. On harness-evals#504 (1,056
+upstream test files), 877 files and 4.47 MB leave review, but 161 gate-tagged
+upstream test files (5.83 MB, mostly skip markers) stay whole, so that PR
+stays over the 2 MB reader limit; 5 gate-tagged `pyproject.toml` files are
+shown as excerpts.
diff --git a/lib/review-exclude.ts b/lib/review-exclude.ts
index c3996bcf5..7c893e0e5 100644
--- a/lib/review-exclude.ts
+++ b/lib/review-exclude.ts
@@ -44,6 +44,8 @@ import { secretExcerpt } from './review-secret-excerpt';
import { cmpVersion, parseVersion } from './version-source';
import { REVIEW_EXCLUDE_KEY_VERSION, SHIP_POLICY_PATH, isUnavailable, policyUnavailableLine } from './ship-policy';
import { loadPolicyAt } from './ship-policy-at';
+import { resolveStateRoot } from './state-root';
+import { vendoredCacheRoot, vendoredPolicy, vendoredSelection, type VendoredSelection } from './review-vendored';
/** The most diff bytes one reader is handed (about 500K tokens); above it the pass stops instead of truncating. */
export const REVIEW_DIFF_MAX_BYTES = 2_000_000;
@@ -61,12 +63,16 @@ export type KeptReason = (typeof KEPT_REASONS)[number];
export interface ExcludeRecord {
source: string; patterns: string[]; applied: string[]; unmatched: string[];
excluded: number; excluded_bytes: number; kept: number; gate_tagged: string[]; patterns_sha256: string; list_sha256: string; digest: string;
+ /** Excluded files that are verified vendored upstream files (docs/vendored-code.md); absent when none are. */
+ vendored?: number;
}
export interface ActiveExclusion {
state: 'active'; record: ExcludeRecord; excluded: Set; specs: string[]; keep: string[];
/** The kept files (a subset of keep, as `:(top,literal)` items) whose only reason is a secret line, or gate tags on data lines: pass readers get an excerpt. */
excerpt: string[];
kept: Array<{ path: string; reason: KeptReason }>; content: Record; references: Array<{ prefix: string; files: string[] }>;
+ /** The base policy's review_vendored check over the matched files; absent when the base declares none. */
+ vendored?: VendoredSelection | { error: string };
}
export type Exclusion =
| { state: 'none' }
@@ -89,6 +95,8 @@ export interface ExcludeInput {
gateTagged?: ReadonlySet | null;
/** The command name the refusal lines start with. */
context: string;
+ /** Fetch review_vendored upstreams into the cache first (gstack-review-plan); every other caller reads the cache offline. */
+ vendoredFetch?: boolean;
}
const sha256 = (s: string) => createHash('sha256').update(s).digest('hex');
@@ -300,13 +308,13 @@ function attributeBinaryLines(i: ExcludeInput, paths: readonly string[], unread:
}
/** The kind of content a path holds when the policy may exclude it, or null for code (tests included). */
-export type ContentKind = 'binary' | 'data' | 'docs' | 'log' | 'declared';
+export type ContentKind = 'binary' | 'data' | 'docs' | 'log' | 'declared' | 'vendored';
/**
* One range's input with the matched files a pattern names by their file name (its last segment, with no glob character): a
* config name there is data; and the files a review_exclude_paths and a review_content_patterns pattern both match, which
* the base policy declares content.
*/
-type Scope = ExcludeInput & { named?: ReadonlySet; declared?: ReadonlySet; keptDeclared?: ReadonlySet };
+type Scope = ExcludeInput & { named?: ReadonlySet; declared?: ReadonlySet; keptDeclared?: ReadonlySet; vendored?: ReadonlySet };
const config = (i: Scope, p: string) => isDataConfig(p) && !i.named?.has(p);
/** Source code by its name, in any letter case: a program extension, or a build or task file name. A declared file with one stays code. */
const SOURCE = /(?:\.(?:[cm]?[jt]sx?|py[iw]?|pyx|rb|erb|rake|sh|bash|zsh|fish|ksh|csh|ps1|psm1|psd1|bat|cmd|vbs|go|rs|dart|java|kt|kts|scala|sc|groovy|gradle|clj[sc]?|swift|m|mm|c|h|cc|cpp|cxx|hpp|hh|hxx|ino|cs|fs|fsx|vb|php|phtml|pl|pm|lua|r|jl|ex|exs|erl|hrl|hs|ml|mli|elm|zig|nim|v|sol|sql|vue|svelte|astro|html?|xhtml|css|scss|sass|less|wasm|wat|tf|hcl|nix|mk|cmake|bzl|star|awk|sed|asm|s|applescript|jsonnet|tmpl|ejs|hbs|jinja2?|j2|mdx)|(?:^|\/)(?:Makefile|GNUmakefile|Dockerfile|Containerfile|Rakefile|Gemfile|Brewfile|Justfile|Procfile|Vagrantfile|Jenkinsfile|Earthfile|Tiltfile|BUILD|WORKSPACE|CMakeLists\.txt|meson\.build)(?:\.[^/]*)?)$/i;
@@ -317,6 +325,7 @@ function contentKind(i: Scope, p: string, binary: ReadonlySet): ContentK
if (DATA_PATH.test(p) && !config(i, p)) return 'data';
if (/\.log$/i.test(p)) return 'log';
if (classifyPath(p, i.classRoot) === 'docs' && !SOURCE.test(p)) return 'docs';
+ if (i.vendored?.has(p)) return 'vendored';
return declaredData(i, p) ? 'declared' : null;
}
@@ -367,11 +376,15 @@ function pathReason(i: Scope, p: string, m: Matched, binary: ReadonlySet
/**
* A file whose full-path reference keeps excluded content: a code or test file (not docs, data, a .log or binary) outside the
- * would-be-excluded set, or a declared file that stays in review (kept in this range, or an executable or link at `mode`).
+ * would-be-excluded set, or a declared file that stays in review (kept in this range, or an executable or link at `mode`). A
+ * verified vendored file counts as the code it is, excluded or not, so the files it names keep the selection they had before.
*/
-const consumer = (i: Scope, f: string, candidates: ReadonlySet, mode?: string) =>
- !candidates.has(f) && !f.startsWith('.gstack/tmp/') && (contentKind(i, f, new Set()) === null
- || (!!i.declared?.has(f) && (!!i.keptDeclared?.has(f) || mode === '100755' || mode === '120000')));
+const consumer = (i: Scope, f: string, candidates: ReadonlySet, mode?: string) => {
+ if (f.startsWith('.gstack/tmp/')) return false;
+ const kind = contentKind(i, f, new Set());
+ if (kind === 'vendored' && !declaredData(i, f)) return true;
+ return !candidates.has(f) && (kind === null || (!!i.declared?.has(f) && (!!i.keptDeclared?.has(f) || mode === '100755' || mode === '120000')));
+};
/**
* An uncapped search for fixed strings at the head (or the working tree) and `revs`: string -> the consumer files
@@ -469,8 +482,12 @@ export function reviewExclude(i: ExcludeInput): Exclusion {
const native = new Set();
const claimed = i.perPath.filter(e => e.binary && sel.files.has(e.path)).map(e => e.path);
const binary = binaryContent(i, sel.files, new Set([...claimed, ...(bytesBinary(i, patterns) ?? sel.files.keys())]), unread, native);
+ const vpol = vendoredPolicy(load.policy);
+ const hiddenManifest = vpol?.manifests.find(m => sel.files.has(m));
+ const vsel = hiddenManifest ? { error: `${hiddenManifest} matches review_exclude_paths, so readers would not see its pins` } : vpol ? vendoredSelection({ root: i.root, policy: vpol, head: i.head, mergeBase: i.mergeBase, changed: new Set(sel.files.keys()), fetch: !!i.vendoredFetch, cacheRoot: vendoredCacheRoot(resolveStateRoot()) }) : undefined;
+ const vendored = vsel && !('error' in vsel) ? new Set(vsel.verified) : undefined;
const fileName = (s: string) => s.slice(s.lastIndexOf('/') + 1);
- const x: Scope = { ...i, declared, named: new Set(patterns.flatMap(q => /[*?[\\]/.test(fileName(q)) ? [] : (sel.byPattern.get(q) ?? []).filter(f => fileName(f) === fileName(q)))) };
+ const x: Scope = { ...i, declared, vendored, named: new Set(patterns.flatMap(q => /[*?[\\]/.test(fileName(q)) ? [] : (sel.byPattern.get(q) ?? []).filter(f => fileName(f) === fileName(q)))) };
const text = { ...x, added: { ...i.added, ...attributeBinaryLines(i, claimed.filter(p => !binary.has(p) && !unread.has(p)), unread) } };
const collected = new Map(i.perPath.map(e => [e.path, e]));
const unseen = (p: string) => { const e = collected.get(p); return !e || (!e.binary && e.lines > 0 && !(p in text.added)); };
@@ -478,7 +495,7 @@ export function reviewExclude(i: ExcludeInput): Exclusion {
for (const [p, m] of sel.files) reasons.set(p, unread.has(p) ? 'consumer-scan-unavailable' : pathReason(text, p, m, binary, native) ?? (unseen(p) ? 'consumer-scan-unavailable' : null));
const candidates = new Set([...reasons].filter(([, r]) => r === null).map(([p]) => p));
const secretOnly = [...reasons].filter(([p, r]) => r === 'secret-line' && !p.includes('\n')).map(([p]) => p);
- const tagOnly = [...reasons].filter(([p, r]) => r === 'gate-tagged' && !p.includes('\n') && (GATE_DATA.test(p) || (/\.json$/i.test(p) && RESULTS_TREE.test(p)))
+ const tagOnly = [...reasons].filter(([p, r]) => r === 'gate-tagged' && !p.includes('\n') && (GATE_DATA.test(p) || (/\.json$/i.test(p) && RESULTS_TREE.test(p)) || !!vendored?.has(p))
&& !binary.has(p) && !unseen(p) && pathReason({ ...text, gateTagged: null }, p, sel.files.get(p)!, binary, native) === null).map(([p]) => p);
const renamed = tagOnly.length ? renamedPaths(i) : null;
const floorCtx = { project: parseGateIntegrityBlock(readClaudeMd(i.root)), specIsTestPath: true };
@@ -504,7 +521,9 @@ export function reviewExclude(i: ExcludeInput): Exclusion {
const why = new Map();
for (const f of kept) why.set(reasons.get(f)!, (why.get(reasons.get(f)!) ?? 0) + 1);
const top = [...why].sort((a, b) => b[1] - a[1]).map(([r, n]) => `${r}:${n}`).join(',');
- return { state: 'refused', code: 'REVIEW_EXCLUDE_KEEP_TOO_LARGE', lines: [`${i.context}: review_exclude_paths pattern ${p} on ${source} keeps ${kept.length} matched files in review (${top}), and the command readers run to read them would need ${bytes} argument bytes (more than ${KEEP_ARG_MAX_BYTES}), so the pattern cannot be applied and is not dropped either; fix: when those files are published data, add a review_content_patterns entry for them beside the pattern on ${base} as its own PR (docs/ship-policy.md#review-content-patterns), else narrow the pattern or split the PR; nothing was planned (REVIEW_EXCLUDE_KEEP_TOO_LARGE)`] };
+ const unverified = vsel ? ('error' in vsel ? kept.length : vsel.failed.filter(e => kept.includes(e.path)).length) : 0;
+ const vfix = unverified ? `${unverified} of them are vendored files that did not verify (gstack-review-plan lists them as REVIEW_VENDORED_KEPT); run gstack-vendored-verify --base ${base} and fix what it names, then rerun once; ` : '';
+ return { state: 'refused', code: 'REVIEW_EXCLUDE_KEEP_TOO_LARGE', lines: [`${i.context}: review_exclude_paths pattern ${p} on ${source} keeps ${kept.length} matched files in review (${top}), and the command readers run to read them would need ${bytes} argument bytes (more than ${KEEP_ARG_MAX_BYTES}), so the pattern cannot be applied and is not dropped either; fix: ${vfix}when those files are published data, add a review_content_patterns entry for them beside the pattern on ${base} as its own PR (docs/ship-policy.md#review-content-patterns), else narrow the pattern or split the PR; nothing was planned (REVIEW_EXCLUDE_KEEP_TOO_LARGE)`] };
}
applied.push(p);
for (const f of kept) keep.add(f);
@@ -513,20 +532,21 @@ export function reviewExclude(i: ExcludeInput): Exclusion {
const excerpt = [...excerptable].filter(p => keep.has(p)).sort();
const keptList = [...reasons].filter(([, r]) => r !== null).map(([p, r]) => ({ path: p, reason: r! })).sort((a, b) => (a.path < b.path ? -1 : a.path > b.path ? 1 : 0));
const sortedExcluded = [...excluded].sort();
- const content: Record = { binary: 0, data: 0, docs: 0, log: 0, declared: 0 };
+ const content: Record = { binary: 0, data: 0, docs: 0, log: 0, declared: 0, vendored: 0 };
for (const p of sortedExcluded) content[contentKind(x, p, binary)!]++;
const prefixes = [...new Set(applied.map(literalPrefix).filter(Boolean))];
const refs = grepFixed(y, prefixes, excluded, []) ?? new Map>();
const patterns_sha256 = sha256(JSON.stringify(patterns));
- const list_sha256 = sha256(JSON.stringify({ applied, excluded: sortedExcluded, kept: keptList.map(k => [k.path, k.reason]) }));
+ const list_sha256 = sha256(JSON.stringify({ applied, excluded: sortedExcluded, kept: keptList.map(k => [k.path, k.reason]), ...(vendored?.size ? { vendored: (vsel as VendoredSelection).digest } : {}) }));
const record: ExcludeRecord = {
source, patterns: [...patterns], applied, unmatched: patterns.filter(p => !(sel.byPattern.get(p) ?? []).length),
excluded: excluded.size, excluded_bytes: excludedBytes(i, sortedExcluded, sel.files), kept: keptList.length,
gate_tagged: keptList.filter(k => k.reason === 'gate-tagged').map(k => k.path), patterns_sha256, list_sha256, digest: sha256(`${patterns_sha256}\n${list_sha256}`),
+ ...(content.vendored ? { vendored: content.vendored } : {}),
};
return {
state: 'active', record, excluded, specs: applied.map(p => `:(top,exclude,glob)${p}`), keep: [...keep].sort().map(literal), excerpt: excerpt.map(literal), kept: keptList, content,
- references: prefixes.filter(p => refs.has(p)).map(p => ({ prefix: p, files: [...refs.get(p)!].sort() })),
+ references: prefixes.filter(p => refs.has(p)).map(p => ({ prefix: p, files: [...refs.get(p)!].sort() })), ...(vsel ? { vendored: vsel } : {}),
};
}
@@ -551,6 +571,14 @@ export function excludeLines(x: Exclusion, base: string): string[] {
if (x.state === 'fallback') return [fallbackLine(x, base)];
const r = x.record;
const out = [`REVIEW_EXCLUDE: patterns=${r.applied.length}/${r.patterns.length} excluded=${r.excluded} bytes=${r.excluded_bytes} kept=${r.kept} content=${Object.entries(x.content).filter(([, n]) => n).map(([k, n]) => `${k}:${n}`).join(',') || 'none'} source=${r.source} digest=${r.digest}${r.unmatched.length ? ` unmatched=${r.unmatched.join(',')}` : ''}`];
+ const v = x.vendored;
+ if (v && 'error' in v) out.push(`REVIEW_VENDORED: unavailable (${v.error}); no vendored file is treated as verified; fix: gstack-vendored-verify --base ${base} (docs/vendored-code.md)`);
+ else if (v) {
+ out.push(`REVIEW_VENDORED: verified=${v.verified.length} unverified=${v.failed.length} pins=${v.pins.length} digest=${v.digest}`);
+ for (const p of v.pins) out.push(`REVIEW_VENDORED_PIN: ${p.upstream}@${p.commit.slice(0, 12)} reachable_from=${p.reachable_from ?? 'none'} files=${p.files} verified=${p.verified}`);
+ for (const f of v.failed.slice(0, 20)) out.push(`REVIEW_VENDORED_KEPT: ${f.verdict} ${f.path}${f.detail ? ` (${f.detail})` : ''}`);
+ if (v.failed.length > 20) out.push(`REVIEW_VENDORED_KEPT: +${v.failed.length - 20} more (gstack-vendored-verify --base ${base} --json lists every one)`);
+ }
for (const k of x.kept.slice(0, 20)) out.push(`REVIEW_EXCLUDE_KEPT: ${k.reason} ${k.path}`);
if (x.kept.length > 20) out.push(`REVIEW_EXCLUDE_KEPT: +${x.kept.length - 20} more (gstack-review-plan --json lists every kept file)`);
const gated = x.excerpt.filter(s => x.kept.some(k => k.reason === 'gate-tagged' && literal(k.path) === s)).length;
@@ -560,8 +588,8 @@ export function excludeLines(x: Exclusion, base: string): string[] {
}
/** The one line every brief gets under an active exclusion; it names the selection digest the receipt binds (verify's REVIEW_EXCLUDE_RECORD). */
-export function disclosureLine(r: Pick): string {
- return `Excluded by base policy ${r.source} (selection ${r.digest}): ${r.excluded} files, ${r.excluded_bytes} bytes on this branch matching ${r.applied.join(' ') || 'no applied pattern'}. They are not in your diff; do not report on their absence. Kept despite a match: ${r.kept} files (listed in the plan).`;
+export function disclosureLine(r: Pick): string {
+ return `Excluded by base policy ${r.source} (selection ${r.digest}): ${r.excluded} files, ${r.excluded_bytes} bytes on this branch matching ${r.applied.join(' ') || 'no applied pattern'}. They are not in your diff; do not report on their absence. Kept despite a match: ${r.kept} files (listed in the plan).${r.vendored ? ` ${r.vendored} of the excluded files are vendored upstream files gstack verified byte for byte against the pins the base allowlists; the manifest that pins them is in your diff.` : ''}`;
}
/** The selection digest a disclosure line names, or undefined. */
export const disclosureDigest = (line: string | undefined) => line?.match(/^Excluded by base policy \S+ \(selection ([0-9a-f]{64})\)/)?.[1];
diff --git a/lib/review-vendored.ts b/lib/review-vendored.ts
index d6f0fd44c..0a6390d9a 100644
--- a/lib/review-vendored.ts
+++ b/lib/review-vendored.ts
@@ -204,6 +204,7 @@ function fetchUpstream(cacheRoot: string, up: VendoredUpstream, pins: Map l.split('\t')[1]).filter(Boolean));
const named = up.branches.filter(b => b.includes('*') || heads.has(`refs/heads/${b}`));
+ for (const b of up.branches) if (!b.includes('*') && !heads.has(`refs/heads/${b}`)) git(refs, ['update-ref', '-d', `refs/vendored/heads/${b}`], genv);
const specs = [`+refs/heads/${def}:refs/vendored/heads/${def}`, '+refs/tags/*:refs/vendored/tags/*', ...named.map(b => `+refs/heads/${b}:refs/vendored/heads/${b}`)];
const f = git(refs, [...flags, 'fetch', '--quiet', '--no-tags', '--prune', '--filter=tree:0', url, ...specs], genv, t);
if (!f.ok) { fail(`could not fetch its branches and tags (${f.err.split('\n').pop()})`); return; }
@@ -289,3 +290,50 @@ export function resolveVendored(i: ResolveInput): { entries: EntryResult[]; pins
/** The cache directory under a state root. */
export const vendoredCacheRoot = (stateRoot: string) => path.join(stateRoot, 'vendored-cache');
+
+/** What a review range may treat as vendored (lib/review-exclude.ts): sorted verified paths, the entries that did not verify, the pins, and a digest of the verified list. */
+export interface VendoredSelection { verified: string[]; failed: EntryResult[]; pins: PinResult[]; digest: string }
+
+/**
+ * The verified vendored files among `changed`: entries of the head's manifests, checked at the head, and files the range
+ * deletes that the merge base's manifests list, checked at the merge base (a re-pin's old files). With no head (a live
+ * tree) the manifests and blobs come from HEAD, and a file the working tree or index changes is not verified. A manifest
+ * that is missing at the head, does not parse, or pins one path twice gives { error } and nothing is verified.
+ */
+export function vendoredSelection(i: { root: string; policy: VendoredPolicy; head?: string; mergeBase: string; changed: ReadonlySet; fetch: boolean; cacheRoot: string; env?: NodeJS.ProcessEnv }): VendoredSelection | { error: string } {
+ const show = (rev: string, f: string) => { const r = spawnSync('git', ['show', `${rev}:${f}`], { cwd: i.root, encoding: 'utf8', timeout: 60_000, maxBuffer: 64 * 1024 * 1024 }); return r.status === 0 ? r.stdout ?? '' : null; };
+ const rev = i.head ?? 'HEAD';
+ const now: VendoredEntry[] = [];
+ const old: VendoredEntry[] = [];
+ for (const m of i.policy.manifests) {
+ const text = show(rev, m);
+ if (text === null) return { error: `${m} is not in ${i.head ? i.head.slice(0, 12) : 'HEAD'}` };
+ const parsed = parseManifest(text, m);
+ if (parsed.errors.length) return { error: parsed.errors[0]! };
+ now.push(...parsed.entries);
+ const before = show(i.mergeBase, m);
+ if (before !== null) old.push(...parseManifest(before, m).entries);
+ }
+ const lower = new Set();
+ for (const e of now) { if (lower.has(e.path.toLowerCase())) return { error: `${e.path} is pinned more than once` }; lower.add(e.path.toLowerCase()); }
+ const atHead = now.filter(e => i.changed.has(e.path));
+ const dropped = old.filter(e => i.changed.has(e.path) && !lower.has(e.path.toLowerCase()) && !e.path.includes('\n'));
+ const probe = dropped.length ? spawnSync('git', ['cat-file', '--batch-check=%(objectname)'], { cwd: i.root, input: dropped.map(e => `${rev}:${e.path}\n`).join(''), encoding: 'utf8', timeout: 60_000, maxBuffer: 64 * 1024 * 1024 }) : null;
+ if (probe && probe.status !== 0) return { error: 'git could not check which vendored files the range deletes' };
+ const probed = (probe?.stdout ?? '').split('\n');
+ const gone = dropped.filter((e, k) => probed[k] === `${rev}:${e.path} missing` && (i.head || !fs.existsSync(path.join(i.root, e.path))));
+ const head = resolveVendored({ root: i.root, rev, policy: i.policy, entries: atHead, fetch: i.fetch, cacheRoot: i.cacheRoot, env: i.env });
+ const base = gone.length ? resolveVendored({ root: i.root, rev: i.mergeBase, policy: i.policy, entries: gone, fetch: i.fetch, cacheRoot: i.cacheRoot, env: i.env }) : { entries: [], pins: [], digest: '' };
+ if (!head || !base) return { error: 'git could not list the vendored files' };
+ const dirty = new Set();
+ if (!i.head) {
+ const d = spawnSync('git', ['-c', 'core.quotePath=false', 'diff', '--name-only', '-z', '--no-renames', 'HEAD'], { cwd: i.root, encoding: 'utf8', timeout: 60_000, maxBuffer: 64 * 1024 * 1024 });
+ if (d.status !== 0) return { error: 'git could not list the working tree changes' };
+ for (const f of (d.stdout ?? '').split('\0')) if (f) dirty.add(f);
+ }
+ const all = [...head.entries, ...base.entries];
+ const verified = all.filter(e => e.verdict === 'verified' && !dirty.has(e.path)).map(e => e.path).sort();
+ const failed = all.filter(e => e.verdict !== 'verified' || dirty.has(e.path)).map(e => (e.verdict === 'verified' ? { ...e, verdict: 'mismatched' as const, detail: 'changed in the working tree' } : e));
+ return { verified, failed, pins: [...head.pins, ...base.pins], digest: createHash('sha256').update(JSON.stringify(verified)).digest('hex') };
+}
+
diff --git a/test/fixtures/review-pins/replays/GST-3298.json b/test/fixtures/review-pins/replays/GST-3298.json
new file mode 100644
index 000000000..9d1c67d39
--- /dev/null
+++ b/test/fixtures/review-pins/replays/GST-3298.json
@@ -0,0 +1 @@
+{"replay":"GST-3298","justification":"GST-3298 PR 2 no-loss replay (CREW rule 15): deterministic, no paid run. lib/review-exclude.ts adds the content kind 'vendored': a file a review_exclude_paths pattern matches that the base policy's review_vendored verifies byte for byte (lib/review-vendored.ts vendoredSelection, read from the cache offline; gstack-review-plan fills it) is content instead of code, and a re-pin's deleted file verified at the merge base's pin is too. Every other keep reason (policy-dir, gate-path, executable, link, gate-tagged, agent-prose, config, secret-line, named-by-code) runs unchanged, gate-tagged vendored files are excerpted only off the gate floor as #4574 does for data, and list_sha256 gains a vendored digest only when a file verified, so a repo without review_vendored hashes byte for byte as before. Reviewer prompts and briefs are unchanged except one disclosure sentence when vendored files were excluded. Replay (GStack Minder drive handoffs/GST-3298/replay.ts, rows replay-rows.jsonl): reviewExclude from main 69ad103's lib/review-exclude.ts and from this branch on each first-parent commit's collectCommit input (parent as base, gate scan an empty set on both sides): gstack 56 (shallow checkout; gstack declares no review_exclude_paths), harness-evals 60 to HEAD (63 patterns), gstack-evals 100 to HEAD (10 patterns). 216 of 216 identical, 134 of them active selections. None declares review_vendored, so no selection moved. The intended change is harness-evals#504 (head 24a377ab with tests unpacked, base policy with review_vendored and the two verifier subtrees excluded, #4574's real gate scan through gstack-review-plan): main refuses REVIEW_EXCLUDE_KEEP_TOO_LARGE; this branch verifies 1,054 of 1,056 (2 mode failures stay kept), excludes 880 files (vendored 877, binary 1, data 2; 4.47 MB) and keeps 176 (166 gate-tagged: 161 upstream test files kept whole at 5.83 MB on the gate floor and 5 pyproject.toml files excerpted; 5 agent-prose, 3 config, 2 executable; recounted from the plan's kept list and git blob sizes), so #504 stays over the 2 MB reader limit. The empty-gate-scan replay of #504 excludes 1,046, every one a verified vendored file or data, and newly keeps the 10 files whose keep rules (agent prose, config, executable, mode) a verified kind does not lift."}
diff --git a/test/review-exclude-vendored.test.ts b/test/review-exclude-vendored.test.ts
new file mode 100644
index 000000000..5261874d0
--- /dev/null
+++ b/test/review-exclude-vendored.test.ts
@@ -0,0 +1,199 @@
+/**
+ * review_vendored in review_exclude_paths (GST-3298, docs/vendored-code.md): a matched file that is byte-for-byte an
+ * allowlisted upstream's file at a pinned commit is vendored content, so it can be excluded; every other keep reason still
+ * applies, a file that does not verify keeps its old reason, and a re-pin's deleted files verify at the base's pin.
+ * Upstreams are local bare repositories reached through GSTACK_VENDORED_FETCH_ROOT.
+ */
+import { afterEach, describe, expect, setDefaultTimeout, test } from 'bun:test';
+import { spawnSync } from 'node:child_process';
+import * as fs from 'node:fs';
+import * as os from 'node:os';
+import * as path from 'node:path';
+import { disclosureLine } from '../lib/review-exclude';
+import { receiptReviewAtHead } from '../lib/ship-receipt-depth';
+import { REVIEW_VENDORED_KEY_VERSION } from '../lib/ship-policy';
+import { cleanup, commit, makeFixtureRepo, runBin, type FixtureRepo } from './helpers/pregate-fixture';
+
+setDefaultTimeout(120_000);
+const repos: FixtureRepo[] = [];
+const dirs: string[] = [];
+afterEach(() => { while (repos.length) cleanup(repos.pop()!); while (dirs.length) fs.rmSync(dirs.pop()!, { recursive: true, force: true }); });
+
+const UP = 'https://example.test/up/lib';
+const BIN = path.join(import.meta.dir, '..', 'bin');
+const A = 'def test_a():\n assert 1 + 1 == 2\n';
+const B1 = 'def test_b():\n assert "x".upper() == "X"\n';
+const B2 = B1 + '\ndef test_c():\n assert [] == []\n';
+const C = 'def test_d():\n assert {} == {}\n';
+const U = 'VALUE = 1\n';
+const D = 'import json\nDATA = json.load(open("up/lib/tests/data.json"))\n';
+const SKIP = 'import pytest\n\n@pytest.mark.skip(reason="needs network")\ndef test_net():\n assert False\n';
+const KEY = ['OPENAI_API_KEY=sk', 'proj', 'Ab3dEf6hIj9kLm2nOp5qRs8tUv1wXy4zAb7cDe0fGh3iJk6lMn9o'].join('-');
+const ENV = { GIT_AUTHOR_DATE: '2026-01-01T00:00:00Z', GIT_COMMITTER_DATE: '2026-01-01T00:00:00Z' };
+
+function run(cwd: string, args: string[], env: Record): string {
+ const r = spawnSync('git', args, { cwd, encoding: 'utf8', timeout: 30_000, env: { ...process.env, ...env, ...ENV } });
+ if (r.status !== 0) throw new Error(`git ${args.join(' ')}: ${r.stderr}`);
+ return r.stdout.trim();
+}
+
+/** An upstream at /upstreams/example.test/up/lib: c1 (tag v1) and c2 on main, which changes b.py, adds c.py and deletes lib/util.py. */
+function upstream(repo: FixtureRepo) {
+ const bare = path.join(repo.root, 'upstreams', 'example.test', 'up', 'lib');
+ const work = fs.mkdtempSync(path.join(os.tmpdir(), 'gstack-vx-up-'));
+ dirs.push(work);
+ fs.mkdirSync(bare, { recursive: true });
+ run(bare, ['init', '-q', '--bare', '-b', 'main'], repo.env);
+ run(work, ['init', '-q', '-b', 'main'], repo.env);
+ const put = (rel: string, text: string | null) => { const f = path.join(work, rel); if (text === null) { fs.rmSync(f); return; } fs.mkdirSync(path.dirname(f), { recursive: true }); fs.writeFileSync(f, text); };
+ const snap = (msg: string) => { run(work, ['add', '-A'], repo.env); run(work, ['commit', '-q', '-m', msg], repo.env); return run(work, ['rev-parse', 'HEAD'], repo.env); };
+ put('tests/a.py', A); put('tests/b.py', B1); put('lib/util.py', U); put('tests/d.py', D); put('tests/test_skip.py', SKIP); put('tests/keys.env', KEY + '\n'); put('AGENTS.md', '# agents\n'); put('README.md', 'lib\n');
+ const c1 = snap('c1');
+ run(work, ['tag', 'v1'], repo.env);
+ put('tests/b.py', B2); put('tests/c.py', C); put('lib/util.py', null);
+ const c2 = snap('c2');
+ run(work, ['push', '-q', bare, 'main', 'v1'], repo.env);
+ return { c1, c2, fetchRoot: path.join(repo.root, 'upstreams') };
+}
+
+const manifest = (commit: string, files: string[]) => JSON.stringify({ schema: 'gstack-vendored/v1', pins: [{ upstream: UP, commit, local_prefix: 'up/lib/', upstream_prefix: '', files }] }, null, 1) + '\n';
+const policy = (vendored = true, manifestPath = 'VENDORED.json') => JSON.stringify({ review_exclude_paths: ['up/**'], ...(vendored ? { review_vendored: { upstreams: [UP], manifests: [manifestPath] } } : {}), min_gstack_version: REVIEW_VENDORED_KEY_VERSION }) + '\n';
+const local = (files: Record) => Object.fromEntries(Object.entries(files).map(([k, v]) => [`up/lib/${k}`, v]));
+
+function fixture(vendored = true, manifestPath = 'VENDORED.json') {
+ const repo = makeFixtureRepo({ prefix: 'gstack-vx-', baseFiles: { '.gstack/ship-policy.json': policy(vendored, manifestPath) } });
+ repos.push(repo);
+ const up = upstream(repo);
+ repo.git('checkout', '-q', '-b', 'feat');
+ const plan = (json: boolean) => runBin(repo, 'gstack-review-plan', ['--base', 'main', '--gate-tagged', '0', ...(json ? ['--json'] : [])], { GSTACK_VENDORED_FETCH_ROOT: up.fetchRoot });
+ return { repo, up, plan };
+}
+const keptOf = (out: string) => JSON.parse(out).review_exclude.kept_files as Array<{ path: string; reason: string }>;
+
+describe('review_exclude_paths with review_vendored', () => {
+ // Value: protects=byte-identical upstream files under an applied pattern leave the readers' diff, the manifest and our own
+ // code stay, and the receipt's commit-mode selection binds the digest the live plan printed; fails_when=verified code is
+ // still kept as code, or plan and receipt disagree; why_new=GST-3298 (harness-evals#504 refused at 1,593 kept files)
+ test('verified vendored files are excluded, and the receipt binds the plan\'s selection', () => {
+ const f = fixture();
+ commit(f.repo, { ...local({ 'tests/a.py': A, 'tests/b.py': B1 }), 'VENDORED.json': manifest(f.up.c1, ['tests/a.py', 'tests/b.py']), 'src/run.ts': 'export const run = () => 1;\n' }, 'vendor lib');
+ const text = f.plan(false);
+ expect(text.out).toContain('REVIEW_VENDORED: verified=2 unverified=0 pins=1');
+ expect(text.out).toMatch(/REVIEW_VENDORED_PIN: https:\/\/example\.test\/up\/lib@[0-9a-f]{12} reachable_from=heads\/main files=2 verified=2/);
+ expect(text.out).toMatch(/REVIEW_EXCLUDE: patterns=1\/1 excluded=2 .*content=vendored:2/);
+ const p = JSON.parse(f.plan(true).out);
+ expect(p.review_exclude.kept_files).toEqual([]);
+ const head = f.repo.git('rev-parse', 'HEAD').trim();
+ const saved = process.env.GSTACK_STATE_ROOT;
+ process.env.GSTACK_STATE_ROOT = f.repo.env.GSTACK_STATE_ROOT;
+ try {
+ const r = receiptReviewAtHead(f.repo.work, 'main', BIN, head);
+ expect(r.exclude.state).toBe('active');
+ expect(r.exclude.state === 'active' && r.exclude.record.digest).toBe(p.review_exclude.digest);
+ } finally { if (saved === undefined) delete process.env.GSTACK_STATE_ROOT; else process.env.GSTACK_STATE_ROOT = saved; }
+ });
+
+ // Value: protects=one changed byte keeps its file for its old reason and the plan names it; fails_when=a mismatch is
+ // excluded; why_new=GST-3298; seam=gstack-review-plan
+ test('one changed byte keeps the file as code and names it as REVIEW_VENDORED_KEPT', () => {
+ const f = fixture();
+ commit(f.repo, { ...local({ 'tests/a.py': A, 'tests/b.py': B1.replace('X', 'Y') }), 'VENDORED.json': manifest(f.up.c1, ['tests/a.py', 'tests/b.py']) }, 'vendor lib');
+ expect(f.plan(false).out).toContain('REVIEW_VENDORED_KEPT: mismatched up/lib/tests/b.py');
+ expect(keptOf(f.plan(true).out)).toEqual([{ path: 'up/lib/tests/b.py', reason: 'code' }]);
+ });
+
+ // Value: protects=verifying a file never lifts agent prose, a credential value or a gate tag out of review: AGENTS.md stays
+ // whole, the key line is excerpted, and a gate-tagged test file stays whole because test paths are gate floor paths
+ // (#4574 excerpts only off the floor); fails_when=the vendored kind skips a keep rule or cuts a floor file;
+ // why_new=GST-3298 plan F5; no_claim=the excerpt text itself (test/review-exclude.test.ts owns it)
+ test('agent prose, a credential value and a gate-tagged test file stay in review even when verified', () => {
+ const f = fixture();
+ const files = ['AGENTS.md', 'tests/a.py', 'tests/keys.env', 'tests/test_skip.py'];
+ commit(f.repo, { ...local({ 'AGENTS.md': '# agents\n', 'tests/a.py': A, 'tests/keys.env': KEY + '\n', 'tests/test_skip.py': SKIP }), 'VENDORED.json': manifest(f.up.c1, files) }, 'vendor lib');
+ const out = runBin(f.repo, 'gstack-review-plan', ['--base', 'main', '--json'], { GSTACK_VENDORED_FETCH_ROOT: f.up.fetchRoot }).out;
+ const x = JSON.parse(out).review_exclude;
+ expect(x.kept_files).toEqual([
+ { path: 'up/lib/AGENTS.md', reason: 'agent-prose' }, { path: 'up/lib/tests/keys.env', reason: 'secret-line' }, { path: 'up/lib/tests/test_skip.py', reason: 'gate-tagged' },
+ ]);
+ expect(x.excerpt).toEqual([':(top,literal)up/lib/tests/keys.env']);
+ expect(x.excluded).toBe(1);
+ });
+
+ // Value: protects=a re-pin's modified, added and deleted files all leave the diff (the deleted one verified at the base's
+ // pin), so a re-pin does not fall back to whole files; fails_when=deletions are kept or verified against the head;
+ // why_new=GST-3298 plan C1
+ test('a re-pin with modified, added and deleted files excludes all three', () => {
+ const f = fixture();
+ f.repo.git('checkout', '-q', 'main');
+ commit(f.repo, { ...local({ 'lib/util.py': U, 'tests/b.py': B1 }), 'VENDORED.json': manifest(f.up.c1, ['lib/util.py', 'tests/b.py']) }, 'vendor lib at v1');
+ f.repo.git('push', '-q', 'origin', 'main');
+ f.repo.git('checkout', '-q', '-B', 'feat');
+ commit(f.repo, { 'up/lib/lib/util.py': null, ...local({ 'tests/b.py': B2, 'tests/c.py': C }), 'VENDORED.json': manifest(f.up.c2, ['tests/b.py', 'tests/c.py']) }, 're-pin');
+ expect(f.plan(false).out).toContain('REVIEW_VENDORED: verified=3 unverified=0 pins=2');
+ const x = JSON.parse(f.plan(true).out).review_exclude;
+ expect({ excluded: x.excluded, kept: x.kept_files }).toEqual({ excluded: 3, kept: [] });
+ });
+
+ // Value: protects=a file the branch drops from the manifest but keeps and rewrites stays in review as code; only a file the
+ // range deletes verifies at the base's pin; fails_when=the base's pin verifies a file the head still has;
+ // why_new=/ship review of #4665 (specialist finding lib/review-vendored.ts:320)
+ test('a file dropped from the manifest but rewritten at the head stays in review', () => {
+ const f = fixture();
+ f.repo.git('checkout', '-q', 'main');
+ commit(f.repo, { ...local({ 'lib/util.py': U, 'tests/b.py': B1 }), 'VENDORED.json': manifest(f.up.c1, ['lib/util.py', 'tests/b.py']) }, 'vendor lib at v1');
+ f.repo.git('push', '-q', 'origin', 'main');
+ f.repo.git('checkout', '-q', '-B', 'feat');
+ commit(f.repo, { ...local({ 'lib/util.py': 'import os\nos.system("true")\n' }), 'VENDORED.json': manifest(f.up.c1, ['tests/b.py']) }, 'drop util from the manifest');
+ const x = JSON.parse(f.plan(true).out).review_exclude;
+ expect(x.kept_files).toEqual([{ path: 'up/lib/lib/util.py', reason: 'code' }]);
+ expect(x.vendored_selection.verified).toEqual([]);
+ });
+
+ // Value: protects=a manifest under an applied pattern turns the vendored check off, so the files it pins stay in review
+ // whole and a hidden re-pin cannot hide them too; fails_when=files verify against a manifest readers cannot see;
+ // why_new=/ship review of #4665 (red-team finding lib/review-exclude.ts:483)
+ test('a manifest under the applied pattern verifies nothing', () => {
+ const f = fixture(true, 'up/VENDORED.json');
+ commit(f.repo, { ...local({ 'tests/a.py': A }), 'up/VENDORED.json': manifest(f.up.c1, ['tests/a.py']) }, 'vendor lib');
+ expect(f.plan(false).out).toContain('REVIEW_VENDORED: unavailable (up/VENDORED.json matches review_exclude_paths');
+ expect(keptOf(f.plan(true).out)).toEqual([{ path: 'up/lib/tests/a.py', reason: 'code' }]);
+ });
+
+ // Value: protects=a verified vendored file still keeps the non-vendored file it names by full path (named-by-code), as on
+ // main, and the plan JSON keeps the numeric vendored count the brief's disclosure line prints; fails_when=a vendored
+ // file stops counting as a consumer, or the count is overwritten; why_new=/ship review of #4665 (s11/outside-voice#1)
+ test('a verified vendored file keeps the non-vendored data file it names', () => {
+ const f = fixture();
+ commit(f.repo, { ...local({ 'tests/d.py': D, 'tests/data.json': '{"x": 1}\n' }), 'VENDORED.json': manifest(f.up.c1, ['tests/d.py']) }, 'vendor lib');
+ const x = JSON.parse(f.plan(true).out).review_exclude;
+ expect(x.kept_files).toEqual([{ path: 'up/lib/tests/data.json', reason: 'named-by-code' }]);
+ expect(x.vendored).toBe(1);
+ expect(disclosureLine(x)).toContain(' 1 of the excluded files are vendored upstream files');
+ });
+
+ // Value: protects=a repo without review_vendored plans exactly as before: the same files kept as code, no vendored line and
+ // no vendored field; fails_when=the key's absence changes a selection; why_new=GST-3298 no-loss (CREW rule 15)
+ test('without review_vendored nothing changes', () => {
+ const f = fixture(false);
+ commit(f.repo, { ...local({ 'tests/a.py': A }), 'VENDORED.json': manifest(f.up.c1, ['tests/a.py']) }, 'vendor lib');
+ const text = f.plan(false).out;
+ expect(text).not.toContain('REVIEW_VENDORED');
+ const x = JSON.parse(f.plan(true).out).review_exclude;
+ expect(x.kept_files).toEqual([{ path: 'up/lib/tests/a.py', reason: 'code' }]);
+ expect(x.vendored).toBeUndefined();
+ expect(x.vendored_selection).toBeUndefined();
+ });
+
+ // Value: protects=too many unverified vendored files refuse with a fix that names REVIEW_VENDORED_KEPT and the verify
+ // command instead of the review_content_patterns fix; fails_when=the old fix is printed; why_new=GST-3298 plan F1
+ test('a keep-too-large refusal over unverified vendored files names the verify command', () => {
+ const f = fixture();
+ const many: Record = {};
+ const names: string[] = [];
+ for (let k = 0; k < 330; k++) { const n = `tests/a_rather_long_vendored_file_name_that_fills_the_argument_bound_${k}.py`; names.push(n); many[n] = A; }
+ commit(f.repo, { ...local({ ...many, 'tests/a.py': A }), 'VENDORED.json': manifest(f.up.c1, [...names, 'tests/a.py']) }, 'vendor lib');
+ const r = f.plan(false);
+ expect(r.out + r.err).toContain('REVIEW_EXCLUDE_KEEP_TOO_LARGE');
+ expect(r.out + r.err).toContain('330 of them are vendored files that did not verify (gstack-review-plan lists them as REVIEW_VENDORED_KEPT); run gstack-vendored-verify --base main');
+ });
+});