gstack-pr-wait ignores cancelled checks a newer pass replaced, and the npm git-dependency hint names allow-git (#4832)

`gstack-pr-wait` no longer blocks on a cancelled check that a newer run
of the same check replaced, and the `DEPS_MISSING` stop names npm 12's
`allow-git` setting when the lockfile installs a package from git.

The docs audit that /gstack-ship launches also starts after a reviewer's
install, and a refused launch no longer uses up its one retry.

Nothing for you to do. Fixes #4807 and #4815; thanks to exGeni for both
reports and the repro.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Review-Finding: p1/red-team#1 reader=red-team
This commit is contained in:
Garry Tanandcapy-ai[bot] authored and GitHub committed 2026-11-25 18:13:02 +00:00
1 parent 959df8ccc4
commit 8aafd408e2
16 files changed
+175 -23

No files matched your search

+18 -1
View File
@@ -12,7 +12,7 @@ import { readFileSync } from 'node:fs';
import { join } from 'node:path';
import type { GhResult } from '../lib/ci-gate';
import { MAX_LIMIT_WAITS, MIN_POLL_MS, parseHeadChecks, parsePullState, pollDelayMs, rateLimitKind, rateLimitWaitMs, withRateLimit } from '../lib/gh-poll';
import { GhError, fetchChecks, runGh } from '../lib/pr-wait-github';
import { GhError, bucketClass, fetchChecks, runGh } from '../lib/pr-wait-github';
import { waitForRun } from '../lib/ci-carry';
import { ciRest } from './helpers/ci-attempts-fixture';
@@ -188,6 +188,23 @@ describe('REST replies parse from recorded fixtures', () => {
]);
expect(calls.some(c => c[0] === 'pr' || c[1] === 'graphql')).toBe(false);
});
// Value: protects=gstack-pr-wait agrees with gstack-ship-queue ready on a cancelled run that a newer passing run of the same app and
// check name replaced (concurrency: cancel-in-progress), pending while that run is still going, and every other duplicate keeps
// the worst bucket (#4807, exGeni's repro); fails_when=the replaced cancel blocks with PR_WAIT_BLOCKED, or a cancel that is newest, a failure, or another app's pass stops
// gating; seam=fetchChecks over the shared REST fake; no_claim=the CLI exit
test("fetchChecks drops a cancelled run that a newer passing or running run of the same check replaced, and nothing else (#4807)", () => {
const app = { id: 15368 };
const run = (id: number, suite: number, conclusion: string, done: string, appId = app): Record<string, unknown> =>
({ id, name: 'title-check', status: 'completed', conclusion, completed_at: done, check_suite: { id: suite }, app: appId });
const bucket = (check_runs: Array<Record<string, unknown>>) => fetchChecks({ gh: (args: string[]) => ciRest(args, { check_runs }) ?? ok(''), sleep: () => {}, log: () => {} }, 'owner/repo', 'a'.repeat(40)).get('title-check')!.bucket;
expect(bucket([run(1, 100, 'cancelled', '2026-01-01T10:00:10Z'), run(2, 200, 'success', '2026-01-01T10:00:50Z')])).toBe('pass');
expect(bucketClass(bucket([run(1, 100, 'cancelled', '2026-01-01T10:00:50Z'), run(2, 200, 'success', '2026-01-01T10:00:10Z')]))).toBe('fail');
expect(bucketClass(bucket([run(1, 100, 'failure', '2026-01-01T10:00:10Z'), run(2, 200, 'success', '2026-01-01T10:00:50Z')]))).toBe('fail');
expect(bucketClass(bucket([run(1, 100, 'cancelled', '2026-01-01T10:00:10Z'), run(2, 200, 'success', '2026-01-01T10:00:50Z', { id: 99 })]))).toBe('fail');
expect(bucketClass(bucket([run(1, 100, 'cancelled', '2026-01-01T10:00:10Z'), run(2, 200, 'failure', '2026-01-01T10:00:50Z')]))).toBe('fail');
expect(bucketClass(bucket([run(1, 100, 'cancelled', '2026-01-01T10:00:10Z'), { ...run(2, 200, 'success', '2026-01-01T10:00:50Z'), status: 'in_progress', conclusion: null, completed_at: null }]))).toBe('pending');
});
});
describe('waits sleep at least the floor', () => {
+24
View File
@@ -176,6 +176,30 @@ describe('install verdict keyed by (checkout, project): both twins', () => {
expect(bashAdmit('ship', proj, { _GH: sr, ...env }).line).toBe(without.line);
});
// Value: protects=a document-release audit that /ship launches after a reviewer's review-voice install rewrote the shared verdict
// is admitted by /ship's own passing record for this checkout and HEAD (CAPY-1, yc-software/qm#3974), in both twins;
// fails_when=it refuses with INSTALL_UNVERIFIED, or a /ship record for another HEAD or one that skipped claude admits it;
// seam=gstack_install_admission and checkInstallAdmission on fixture verdicts
test("CAPY-1: a review-voice install rewrote the launched verdict; document-release admits from /ship's own record, never from a stale or narrower one", () => {
const sr = tmp();
const proj = project('qm');
const shared = writeVerdict(sr, { project: proj, bun_path: BUN, bun_version: '1.4.2', schema_version: 2, for: 'review-voice',
required: ['patch', 'runtime', 'helpers', 'state-root', 'privacy', 'cores', 'revision'], trailer: 'gstack: ok 9.9.9.9 for=review-voice' });
const env = { GSTACK_STATE_ROOT: sr, GSTACK_INSTALL_VERDICT: shared };
const without = both('document-release', proj, env);
expect(without).toMatchObject({ refuse: true, status: 'verdict', code: 'INSTALL_UNVERIFIED' });
expect(without.detail).toContain('certified for=review-voice, which does not cover claude that document-release needs');
const ship = shared.replace(/\.json$/, '.for/ship.json');
const shipVerdict = { project: proj, bun_path: BUN, bun_version: '1.4.2', schema_version: 2, for: 'ship', trailer: 'gstack: ok 9.9.9.9 for=ship' };
writeVerdict(sr, shipVerdict, ship);
expect(both('document-release', proj, env)).toMatchObject({ refuse: false, status: 'ok' });
expect(bashAdmit('document-release', proj, { _GH: sr, ...env }).line).toBe('INSTALL_VERDICT: ok gstack: ok 9.9.9.9 for=ship');
writeVerdict(sr, { ...shipVerdict, head: 'f'.repeat(40) }, ship);
expect(both('document-release', proj, env)).toMatchObject({ refuse: true, status: 'verdict', detail: without.detail });
writeVerdict(sr, { ...shipVerdict, required: ['codex', 'patch', 'runtime', 'pins', 'state-root', 'privacy', 'cores', 'revision'] }, ship);
expect(both('document-release', proj, env)).toMatchObject({ refuse: true, status: 'verdict', detail: without.detail });
});
test('a running Bun other than the recorded one refuses with BUN_RESOLUTION_DRIFT and names both', () => {
const sr = tmp();
const a = project('a');
@@ -91,6 +91,25 @@ describe('preflight Step 5: a worktree with no installed packages stops with the
expect(testsOnly(plain).stdout).not.toContain('DEPS_MISSING');
});
// Value: protects=a lockfile with a git-resolved package gets a hint that names npm's allow-git setting and its flag, since plain
// npm ci fails with EALLOWGIT under npm 12 (#4815, exGeni), while the suggested command stays plain npm ci (no default
// --allow-git=all); fails_when=the hint is plain npm ci for a git package, or a registry-only lockfile gets the note;
// seam=bin/gstack-ship-preflight --tests-only, depsInstall
test('a lockfile that resolves a package from git names allow-git and its flag, never as the default command (#4815)', () => {
const pkg = '{"name":"fx","version":"1.0.0","dependencies":{"dep":"git+https://github.com/o/dep.git#abc"}}\n';
const lock = (resolved: string) => JSON.stringify({ lockfileVersion: 3, packages: { 'node_modules/dep': { version: '1.0.0', resolved } } }) + '\n';
const git = shipFixture({ 'package.json': pkg, 'package-lock.json': lock('git+ssh://git@github.com/o/dep.git#abc') });
fixtures.push(git);
const stop = lineOf(testsOnly(git).stdout, 'STOP');
expect(stop).toContain(`&& npm ci (package-lock.json resolves a package from git, which npm 12 and later install only when npm's allow-git setting permits it: add --allow-git=all if you trust that source), then rerun this command`);
const v1 = shipFixture({ 'package.json': pkg, 'npm-shrinkwrap.json': JSON.stringify({ lockfileVersion: 1, dependencies: { dep: { version: 'github:o/dep#abc' } } }) });
fixtures.push(v1);
expect(lineOf(testsOnly(v1).stdout, 'STOP')).toContain("&& npm ci (npm-shrinkwrap.json resolves a package from git");
const registry = shipFixture({ 'package.json': pkg, 'package-lock.json': lock('https://registry.npmjs.org/dep/-/dep-1.0.0.tgz') });
fixtures.push(registry);
expect(lineOf(testsOnly(registry).stdout, 'STOP')).toContain('&& npm ci, then rerun this command');
});
// Value: protects=an installed Yarn Plug'n'Play checkout, which never has node_modules, runs Step 5 instead of stopping on an
// install that cannot clear the stop; fails_when=depsInstall checks node_modules alone; seam=bin/gstack-ship-preflight --tests-only
test('a Yarn PnP checkout (.pnp.cjs, no node_modules) never stops on DEPS_MISSING', () => {
+13
View File
@@ -92,4 +92,17 @@ describe('no_stop receipt field (K1)', () => {
expect(extractReceipt(fs.readFileSync(body, 'utf8')).receipt!.no_stop).toEqual([{ class: 'pregate-flake-rerun', reason: 'r', evidence: 'run 1' }]);
} finally { cleanup(repo); }
});
// Value: protects=write leaves out a retired scoped-fix-check row as gstack-no-stop (checkNoStop) refuses one (#4829 notes);
// fails_when=the receipt records a scoped-fix-check no-stop; seam=none (the real bin on a fixture repo); no_claim=the gh round trip
test('write drops a scoped-fix-check row from --no-stop, as gstack-no-stop refuses one', () => {
const repo = makeFixtureRepo();
try {
const body = path.join(repo.root, 'body.md');
const rows = JSON.stringify([{ class: 'scoped-fix-check', reason: 'r', evidence: 'commit abc' }, { class: 'pregate-flake-rerun', reason: 'r', evidence: 'run 1' }]);
const w = runBin(repo, 'gstack-ship-receipt', ['write', '--pr', '9', '--base', 'main', '--version', '1.0.0', '--session-kind', 'unattended', '--no-stop', rows, '--body', body]);
expect([w.status, w.err], w.out).toEqual([EXIT.ok, expect.stringContaining('NO_STOP: dropped "scoped-fix-check"')]);
expect(extractReceipt(fs.readFileSync(body, 'utf8')).receipt!.no_stop).toEqual([{ class: 'pregate-flake-rerun', reason: 'r', evidence: 'run 1' }]);
} finally { cleanup(repo); }
});
});
+15
View File
@@ -623,6 +623,21 @@ describe('test-only and audit-requested edits after the docs audit (GST-391, gbr
const reset = f.run(path.join(BIN, 'gstack-docs-candidate'), ['attempt', refused, '--state', corrupt]);
expect([reset.status, reset.stdout.includes('ATTEMPT: counted (a second install refusal in this invocation)')]).toEqual([3, true]);
});
// Value: protects=a child whose install check refused document-release and that then reported the refusal as a blocked result
// (no file reviewed or updated, as Step 14.5's contract asks) does not spend the PR's re-audit (CAPY-1, yc-software/qm#3974);
// fails_when=that blocked line reads as an audit, or a blocked result that reviewed or updated a file stops counting; seam=none
test('gstack-docs-candidate attempt does not count an install refusal reported as an empty blocked result', () => {
const f = fx();
const out = (name: string, text: string) => { const p = path.join(f.root, name); fs.writeFileSync(p, text); return p; };
const attempt = (file: string, state: string) => f.run(path.join(BIN, 'gstack-docs-candidate'), ['attempt', file, '--state', path.join(f.root, state)]).stdout.trim();
const refusal = 'SESSION_KIND: spawned\nINSTALL: fail verdict — the install verdict certified for=review-voice, which does not cover claude that document-release needs; fix: run the installer (INSTALL_UNVERIFIED)\nGSTACK_RESULT: skill=document-release status=refused run=-\n';
const blocked = (reviewed: string[], updated: string[]) => JSON.stringify({ schema_version: 1, audit_id: 'a1', status: 'blocked', files_updated: updated, files_reviewed: reviewed, blockers: ['install admission refused document-release'], decisions: [], documentation_section: 'blocked' }) + '\n';
expect(attempt(out('empty.txt', refusal + blocked([], [])), 's1.json')).toBe("ATTEMPT: not-counted (the audit child's install check refused document-release)");
expect(attempt(out('reviewed.txt', refusal + blocked(['README.md'], [])), 's2.json')).toBe('ATTEMPT: counted');
expect(attempt(out('updated.txt', refusal + blocked([], ['README.md'])), 's3.json')).toBe('ATTEMPT: counted');
expect(attempt(out('current.txt', refusal + JSON.stringify({ schema_version: 1, audit_id: 'a1', status: 'current', files_updated: [], files_reviewed: [] }) + '\n'), 's4.json')).toBe('ATTEMPT: counted');
});
});
describe('preflight carry route for a spliced hunk (GST-442)', () => {