Clearer errors for GitHub email-privacy pushes, approval refusals and bisect case names (#4748)

/ship now tells you to fix your commit email when GitHub refuses a push
with GH007, instead of sending you into a pointless merge;
`gstack-approvals` says which `--owner-ref` check failed; and the merge
queue's bisect accepts a red judge case whose name has a space.

Why: three small, plainly correct fixes from outside reports (#4738,
#4718 with #4720, #4724 for #3580), taken as one batch.

Nothing to do.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: Barack-zero-to-one <121355791+Barack-zero-to-one@users.noreply.github.com>
Review-Finding: p1/outside-voice#1 reader=outside-voice
Review-Finding: p1/outside-voice#2 reader=outside-voice
Review-Finding: p1/adversarial-native#1 reader=adversarial-native
Review-Finding: p1/adversarial-native#3 reader=adversarial-native
Review-Finding: p1/specialist-batched#1 reader=testing
This commit is contained in:
authored and GitHub committed 2026-11-23 19:26:27 +00:00
1 parent 0d6cc1be56
commit 100e109ccd
14 files changed
+174 -21

No files matched your search

+8 -4
View File
@@ -29,7 +29,7 @@ import { spawnSync } from 'node:child_process';
import * as path from 'node:path';
import { EXIT, exitTableHelp } from '../lib/headless-artifacts';
import { appendRows, branchExists, buildRow, importAutoplan, locate, readRecord, renderMode, renderRecord, repoVisibility, syncRecord, type RecordError, type StoreLocation } from '../lib/approval-record';
import { isGstackActor, isGstackActorName, openShipRun, OWNER_REF, RULED_NOTE_SCOPE, ruledNoteRow, ruledNoteSource, ruledNotes, ruledNoteText } from '../lib/ruled-notes';
import { isGstackActor, isGstackActorName, openShipRun, OWNER_REF, OWNER_REF_SHAPE, RULED_NOTE_SCOPE, ruledNoteRow, ruledNoteSource, ruledNotes, ruledNoteText } from '../lib/ruled-notes';
import { resultLine } from '../lib/result-codes';
import { parsePlanLine, publicPlanLine, resolvePlan } from '../lib/plan-record';
import { TEST_LANE_EXCEPTION_SCOPE, testLaneExceptionRow } from '../lib/test-lane-exception';
@@ -50,6 +50,7 @@ const HELP = `gstack-approvals — the per-thread approval record (capy/skill/gs
counts that finding closed on a fix-check whose range_base..commit holds the head, and the receipt and PR body
list it; inside this checkout's open /ship run it needs --owner-ref, the message the lane relays the owner's
words from, and the row, receipt and Ruled note line then say relayed from it (APPROVAL_RULING_RUN_OPEN without);
the ref is ${OWNER_REF_SHAPE};
--not-security: the owner's call that a red-team finding is not security class, so public text shows it;
refused while a /ship run is open on this checkout
rulings the "Ruled note: …" lines the Pre-Landing Review and the PR body carry
@@ -64,7 +65,7 @@ const HELP = `gstack-approvals — the per-thread approval record (capy/skill/gs
round-grant --pr <n> --head <the head that needs the round> --kind extra-round|fix-check --reason <why, one line>
--by <the lane or its Captain> [--words <their words; default the reason>]
[--owner-ref <thread code>:<message id or timestamp>: relays the grant from the lane's or Captain's message, so it
records while a stopped /ship run is still open on this checkout; needs --words]
records while a stopped /ship run is still open on this checkout; needs --words; the same shape as rule's]
[--stop-run <run> --findings <ids>: fix-check only, the stop gstack-ship-receipt stop recorded and the findings
its fix round is for; it buys one scoped fix-check of the PR's own change since that stop's head. A fix-check
with neither buys one scoped fix-check of the change since --head, the reviewed head: a post-review edit (the
@@ -189,7 +190,8 @@ function main(argv: string[]): number {
if (!flags['--head'] || head.status !== 0) return invalid('round-grant needs --head <the head that needs the round, a commit in this repository>');
if (!by || isGstackActorName(by)) return invalid('round-grant needs --by <the lane or its Captain>: gstack never grants itself a round');
const ownerRef = flags['--owner-ref']?.trim();
if (ownerRef !== undefined && (!OWNER_REF.test(ownerRef) || !(flags['--words'] ?? '').trim())) return invalid('--owner-ref relays the lane\'s or Captain\'s grant: <thread code>:<message id or timestamp> (GSTA-36:2026-11-19T12:29:59Z), with --words <their exact words>');
if (ownerRef !== undefined && !OWNER_REF.test(ownerRef)) return invalid(`--owner-ref is not ${OWNER_REF_SHAPE}`);
if (ownerRef !== undefined && !(flags['--words'] ?? '').trim()) return invalid('--owner-ref relays the lane\'s or Captain\'s grant, so round-grant needs --words <their exact words>');
const stopRun = (flags['--stop-run'] ?? '').trim(), findings = [...new Set((flags['--findings'] ?? '').split(',').map(f => f.trim()).filter(Boolean))];
const open = openShipRun(process.cwd());
const ownStop = open?.state === 'stopped' && !open.claim && kind === 'fix-check' && stopRun === open.run && open.stop?.head === head.stdout.trim().toLowerCase();
@@ -222,7 +224,9 @@ function main(argv: string[]): number {
if (!flags['--head'] || head.status !== 0) return invalid('rule needs --head <the stop head the owner ruled at, a commit in this repository>');
if (isGstackActor(flags['--by'] ?? '')) return invalid('--by names gstack; a ruling is the owner\'s, so --by names who ruled');
const ownerRef = flags['--owner-ref']?.trim(), notSecurity = bools.has('--not-security');
if (ownerRef !== undefined && (!OWNER_REF.test(ownerRef) || !(flags['--words'] ?? '').trim() || !(flags['--by'] ?? '').trim())) return invalid('--owner-ref relays the owner\'s ruling: <thread code>:<message id or timestamp> (GSTA-36:2026-11-19T12:29:59Z), with --by <the owner> and --words <their exact words>');
if (ownerRef !== undefined && !OWNER_REF.test(ownerRef)) return invalid(`--owner-ref is not ${OWNER_REF_SHAPE}`);
if (ownerRef !== undefined && !(flags['--words'] ?? '').trim()) return invalid('--owner-ref relays the owner\'s ruling, so rule needs --words <the owner\'s exact words>');
if (ownerRef !== undefined && !(flags['--by'] ?? '').trim()) return invalid('--owner-ref relays the owner\'s ruling, so rule needs --by <the owner>');
if (notSecurity && !/:red-team$/i.test(finding)) return invalid('--not-security is the owner\'s call on a red-team finding (path:line:red-team); a security, auth or secret finding is security class by its category');
const open = openShipRun(process.cwd());
if (open && notSecurity) return invalid(`--not-security lifts a red-team finding's redaction, so it is recorded only outside a /ship run: ${open.line}; record it after the run ends`);
@@ -0,0 +1,5 @@
**`/ship` now tells you what to change when GitHub refuses a push for email privacy.** A push GitHub declines with GH007 (a commit carries an email address your account keeps private) used to be reported as a non-fast-forward, sending you into a pointless merge and a rerun of the release steps. It now says to set `user.email` to your GitHub noreply address and rewrite the commits, and any other refusal from the remote, such as a protected branch, is quoted (through the secret scanner) instead of read as a merge problem. (#4738) Reported by @raymondllee
**`gstack-approvals rule` and `round-grant` now say which `--owner-ref` check failed.** A ref in the wrong shape, a missing `--words` and a missing `--by` each get their own line, the shape refusal states what a valid ref looks like, and no invalid-record refusal tells you to rerun `gstack-approvals add` with flags the command you ran doesn't take. (#4718) Idea and first version by @Barack-zero-to-one in #4720
**The merge queue's bisect now accepts a red judge case whose name holds a space.** A judge case such as `setup-browser-cookies/SKILL.md workflow` was refused as outside the gate's plan, because bisect's own id check left out the space that the release bisect and the CI route already allow; all three now share one rule. (#3580) Idea and first version by @Barack-zero-to-one in #4724
+1 -2
View File
@@ -32,7 +32,7 @@ import { MAX_BISECT_CASES, MAX_PREFIXES, RELEASE_BISECT_ARTIFACT, RELEASE_BISECT
import type { ReleaseGatePolicy } from '../../lib/release-gate-policy';
import { loadPolicyFromBase, mergePolicy, validatePolicy } from '../../lib/ship-policy';
import {
NOTES_REF, fetchNotes, nowIso, persist, repoIdentity,
CASE_ID, NOTES_REF, fetchNotes, nowIso, persist, repoIdentity,
type PrefixResult, type ReleaseBisect, type ReleaseBisectRound, type ReleaseRecord,
} from './ship-queue-train-record';
@@ -47,7 +47,6 @@ export const MAX_BISECT_ROUNDS = 4;
/** An open gate (a run past its budget, or a red gate's running bisect) on an older commit is finished first for this many cadences; after that it stops holding up main's head. */
export const OPEN_GATE_CADENCES = 3;
const SHA = /^[0-9a-f]{40}$/;
const CASE_ID = /^[A-Za-z0-9 _.:/-]{1,128}$/;
const HOUR = 3_600_000;
const GH_MS = 60_000;
+2
View File
@@ -69,6 +69,8 @@ export interface TrainRecord {
landing?: Record<string, LandingRecord>;
effects: Array<{ at: string; what: string }>; error: string | null; created_at: string; updated_at: string;
}
/** A gate case id a bisect can name: a judge case id holds a space ("<skill>/SKILL.md workflow") and no comma, which joins the cases dispatch input; train bisect, the release bisect and the CI route (crew/scripts/train-gate.ts) share it. */
export const CASE_ID = /^[A-Za-z0-9 _.:/-]{1,128}$/;
export type AttemptPurpose = 'gate' | 'rebuild' | 'infra-redispatch' | 'bisect';
export type GateOutcome = 'PENDING' | 'GREEN' | 'RED' | 'INCOMPLETE';
export interface CasePanel {
+9 -4
View File
@@ -19,7 +19,7 @@ import {
checkRun, downloadJson, execFor, asRun, remoteBranchSha, repoSlug, runView, type CheckInfo, type RunInfo,
} from './ship-queue-train-github';
import {
attemptsOf, loadBisect, nowIso, persist, trainDir, trainFile,
CASE_ID, attemptsOf, loadBisect, nowIso, persist, trainDir, trainFile,
type AttemptRecord, type BisectRecord, type CasePanel, type GateOutcome, type PrefixResult, type TrainRecord,
} from './ship-queue-train-record';
import {
@@ -222,11 +222,16 @@ function bisectOutcome(env: TrainEnv, t: TrainRecord, b: BisectRecord): TrainOut
/** The commits a bisect tests: T0 and the plain prefixes, or for a stamped train T0 and S_1..S_k, the chain its gate ran. */
const bisectPrefixes = (t: TrainRecord) => t.stamped ? [t.prefixes[0]!, ...t.stamped] : t.prefixes;
/** Why a red attempt's cases cannot be bisected, or null: each red case must be a case id one of the gate's own panels holds. */
export function redCasesOutsidePlan(red: Pick<AttemptRecord, 'red_cases' | 'panels'>): string | null {
const id = red.red_cases.find(c => !CASE_ID.test(c) || !red.panels.some(p => p.case === c));
return id === undefined ? null : `red case ${id} is not in the gate's plan`;
}
/** Validate bisect inputs: red cases from the gate's own plan, every prefix an ancestor of train/<nonce>'s head. */
function bisectInputs(env: TrainEnv, t: TrainRecord, red: AttemptRecord): string | null {
for (const id of red.red_cases) {
if (!/^[A-Za-z0-9_.:/-]{1,128}$/.test(id) || !red.panels.some(p => p.case === id)) return `red case ${id} is not in the gate's plan`;
}
const outside = redCasesOutsidePlan(red);
if (outside) return outside;
const ref = `refs/gstack/${t.branch}`;
const f = git(env.ctx.repoRoot, ['fetch', '--no-tags', '-q', env.remote, `+refs/heads/${t.branch}:${ref}`]);
if (!f.ok) return `cannot fetch ${t.branch}: ${f.err.slice(0, 120)}`;
+1 -2
View File
@@ -29,7 +29,7 @@ import { normalizeLockfile } from '../../lib/evidence-bundle';
import { stampMentions, rewriteStamps, versionAtRef } from '../../lib/restamp';
import { loadPolicyFromHead, matchesAny, type ShipPolicy } from '../../lib/ship-policy';
import type { BisectPrefixRecord, TrainGateRecord } from '../lib/ship-queue-train-verdict';
import type { CasePanel } from '../lib/ship-queue-train-record';
import { CASE_ID, type CasePanel } from '../lib/ship-queue-train-record';
import { E2E_TIERS, LLM_JUDGE_TOUCHFILES } from '../../test/helpers/touchfiles-data';
import { panelVerdict } from '../../test/helpers/eval-store';
import { UNRECORDED_SHARD_MS, nonceScope, plannedSerialMs } from '../../scripts/eval-bg';
@@ -41,7 +41,6 @@ import { paidSelectionEnv } from '../../scripts/lib/paid-select';
import { ROOT } from '../../scripts/lib/paid-types';
const SHA = /^[0-9a-f]{40}$/;
const CASE_ID = /^[A-Za-z0-9 _.:/-]{1,128}$/;
export const JUDGE_FILE = 'test/skill-llm-eval.test.ts';
/** T1 caps a train at 6 PRs, so a bisect has at most 7 prefixes (T0..T6). */
export const MAX_PREFIXES = 7;
+19 -1
View File
@@ -11,7 +11,7 @@ import { DEFAULT_POLICY, TRAIN_KEYS_VERSION, validatePolicy } from '../../lib/sh
import { fillDue, orderSlots, parseOrder, parsePins, prsArgs } from '../lib/ship-queue-train';
import { gstackPaidSelection, skillOwnCases, touchedSkills } from '../lib/ship-queue-train-ready';
import { normalizeRemoteUrl, repoIdentity, type TrainSlot } from '../lib/ship-queue-train-record';
import { INFRA_REDISPATCH, REBUILD_ONCE, classifyBisect, classifyGate } from '../lib/ship-queue-train-verdict';
import { INFRA_REDISPATCH, REBUILD_ONCE, classifyBisect, classifyGate, redCasesOutsidePlan } from '../lib/ship-queue-train-verdict';
import { EVAL_POLICY } from '../../test/helpers/periodic-exclude-data';
import { COMPLETE, FAIL, PASS, TRAIN_BLOCK } from '../../test/helpers/ship-queue-train-fixture';
import { spawnSync } from 'node:child_process';
@@ -270,3 +270,21 @@ describe("eval-bg nonce key: purpose and screen policy", () => {
expect(dispatchPlan('gate', { sha: SHA, baseRef: 'main', baseSha: base, nonce: 'n' })).toEqual([{ workflow: 'evals.yml', inputs: { evals_all: 'true', expected_sha: SHA, nonce: 'n' } }]);
});
});
// Value: protects=train bisect takes a red case by the id the gate's panels carry, with the id rule the release bisect and the CI route already apply;
// fails_when=a judge case whose id holds a space ("<skill>/SKILL.md workflow") is refused as outside the plan, or an id the dispatch input
// cannot carry (empty, a comma, a newline, over 128 characters) gets through; why_new=no test fed bisect a red judge case (#3580, idea
// from @Barack-zero-to-one in #4724); seam=redCasesOutsidePlan
describe('bisect red cases: the ids the gate plan holds (#3580)', () => {
const JUDGE = 'setup-browser-cookies/SKILL.md workflow';
test('a red judge case whose id holds a space is in the plan', () => {
expect(redCasesOutsidePlan({ red_cases: [JUDGE], panels: [PASS('c1'), { ...FAIL(JUDGE), kind: 'judge' }] })).toBeNull();
});
test('an id the dispatch input cannot carry is refused even when a panel holds it', () => {
for (const id of ['', 'a,b', 'a\nb', 'x'.repeat(129)]) expect(redCasesOutsidePlan({ red_cases: [id], panels: [FAIL(id)] })).toContain("is not in the gate's plan");
});
test('a red id no panel holds is refused', () => {
expect(redCasesOutsidePlan({ red_cases: ['c2'], panels: [FAIL('c1')] })).toBe("red case c2 is not in the gate's plan");
});
});
+18 -3
View File
@@ -2278,8 +2278,15 @@ holds an open /ship run, and for `lane-exception` a `--files` list that is
empty or holds whitespace. `add` refuses a `ruled_note` or
`test_lane_exception` scope ([ruled notes](ship-policy.md#ruled-notes),
[test-lane exceptions](ship-policy.md#test-lane-exceptions)).
`rule` and `round-grant` refuse an `--owner-ref` that is not
`<thread code>:<message id or timestamp>`, where the thread code looks like
`GSTA-36` (an uppercase letter, then uppercase letters or digits, a dash and a
number from 1), and an `--owner-ref` given without `--words` (for `rule`, also
without `--by`). Each of these checks prints its own line, and the shape
refusal never repeats the rejected ref.
**Fix.** Rerun with every required flag inside the caps the line names. A
**Fix.** Rerun the same command with the flag the line names, inside its caps
(`gstack-approvals --help` lists each command's flags). A
ruling or a test-lane exception is the owner's: record it from the owner's
session, outside the lane's /ship run.
@@ -6237,8 +6244,16 @@ pushed. [The push line](unattended.md#push-line).
branch lacks (non-fast-forward), or the remote refused the update. Nothing
was pushed.
**Fix.** Fetch and inspect the remote, merge it under Step 3's conflict
rules, run Steps 5-16 again, then rerun push. Never force-push.
**Fix.** For a non-fast-forward, fetch and inspect the remote, merge it under
Step 3's conflict rules, run Steps 5-16 again, then rerun push. When the remote
refused the update, the `STOP:` line quotes its reason; a merge will not help,
so change what it names instead. GitHub's `GH007` means a commit carries an
email address your account keeps private: set `git config user.email` to your
GitHub noreply address (shown at github.com/settings/emails), rewrite every
commit that carries the private one
(`git rebase origin/<base> --exec 'git commit --amend --reset-author --no-edit'`),
repeat Step 16 and push. The quoted reason passes through the secret scanner
first. Never force-push.
<a id="push-git-failed"></a>
### `PUSH_GIT_FAILED`
+1 -1
View File
@@ -13,7 +13,7 @@ export const CAPY_RESULT_CODES = {
APPROVAL_RECORD_INVALID: {
anchor: 'approval-record-invalid',
summary: 'an approval row is missing a required field, holds a value outside its enum, or exceeds a length cap',
fix: 'rerun gstack-approvals add with every required flag (--ask, --words, --scope, --by) inside the caps it names; nothing was written',
fix: 'rerun the command this line names with the flag its detail names, inside its caps (gstack-approvals --help lists each command\'s flags); nothing was written',
},
APPROVAL_RULING_RUN_OPEN: {
anchor: 'approval-ruling-run-open',
+1 -1
View File
@@ -701,7 +701,7 @@ export const RELEASE_RESULT_CODES = {
PUSH_REJECTED: {
anchor: 'push-rejected',
summary: 'git push was rejected: the remote branch has commits this branch lacks (non-fast-forward) or the remote refused the update, so nothing was pushed',
fix: 'fetch and merge the remote under Step 3\'s conflict rules, run Steps 5-16 again, then rerun push; never force-push',
fix: 'for a non-fast-forward, fetch and merge the remote under Step 3\'s conflict rules, run Steps 5-16 again, then rerun push; when the remote refused the update (GH007 email privacy, a protected branch), change what the STOP: line names instead (for GH007, the noreply email on every commit); never force-push',
},
PUSH_GIT_FAILED: {
anchor: 'push-git-failed',
+2
View File
@@ -30,6 +30,8 @@ export const RULED_NOTE_SCOPE = /^\s*ruled_note\b/;
export const ruledNoteRow = (finding: string, head: string, reason: string) => ({ scope: `ruled_note ${finding} ${head}`, ask: `ruled_note ${finding} at ${head}: ${reason}` });
/** Where a lane relays the owner's ruling from: `<thread code>:<message id or timestamp>`, a message a reader can look up. */
export const OWNER_REF = /^[A-Z][A-Z0-9]*-[1-9]\d*:[A-Za-z0-9][\w.:+-]*$/;
/** OWNER_REF in words, for the refusals and help that name it; a refusal never echoes the rejected ref, which may hold anything (#4718). */
export const OWNER_REF_SHAPE = '<thread code>:<message id or timestamp>, where the thread code is an uppercase letter, then uppercase letters or digits, a dash and a number from 1, and the message part starts with a letter or digit (GSTA-36:2026-11-19T12:29:59Z)';
const RED_TEAM = /:red-team$/i;
/** A ruling row's source: `relayed:<owner ref>` for a relayed ruling and `not-security` for a red-team finding the owner ruled not security class. */
export const ruledNoteSource = (o: { ownerRef?: string; notSecurity?: boolean }) => [o.ownerRef ? `relayed:${o.ownerRef}` : '', o.notSecurity ? 'not-security' : ''].filter(Boolean).join(' ') || undefined;
+7 -3
View File
@@ -32,6 +32,7 @@ import { reviewRoundGrants } from './review-round-grant';
import { dispositionedOn, gateDispositionText, gateKey, readGateDispositions } from './gate-dispositions';
import { parseReviewLoopException, type ReviewLoopException } from './ship-receipt-depth';
import { parseReceiptDocs, type ReceiptDocs } from './ship-receipt-docs';
import { redactFindingSpans } from './redact-engine';
import { resolveStateRoot } from './state-root';
import { bumpVersion, cmpVersion, fmtVersion, parseVersion, versionWidth, type Bump } from './version-source';
import { waitForRun } from './ci-carry';
@@ -833,9 +834,12 @@ function pushOnce(argv: readonly string[], cwd: string, r: Report): string {
if (plain.length) { r.add(`BRANCH: refused ${plain.map(f => `"${f.match}"`).join(', ')}`); return refuse(`the branch name ${branch} is not plain words (docs/ship-policy.md#plain-titles): rename it with git branch -m <plain words>[-<issue code>], then rerun push --branch <new name>`); }
const p = git(cwd, ['push', '-u', 'origin', branch], 600_000);
if (p.status !== 0) {
const nff = /non-fast-forward|fetch first|rejected/.test(p.stderr);
return nff ? refuse('non-fast-forward: fetch and merge the remote under Step 3\'s conflict rules, run Steps 5-16, then push again; never force-push', 'PUSH_REJECTED')
: refuse(`push failed (${firstLine(p.stderr)}): repair the auth, hook or network cause, repeat Step 16, then push; never bypass a guard`, 'PUSH_GIT_FAILED');
if (/^remote: error: GH007:|\[remote rejected\][^\n]*\(push declined due to email privacy restrictions\)/m.test(p.stderr)) return refuse(`GitHub refused the push (GH007): a commit carries the private email address your account blocks from command-line pushes. Set git config user.email to your GitHub noreply address (github.com/settings/emails), rewrite every commit that carries the private one (git rebase origin/${flag('--base') ?? '<base>'} --exec 'git commit --amend --reset-author --no-edit'), repeat Step 16, then push; a fetch and merge will not fix it`, 'PUSH_REJECTED');
if (/^ ! \[rejected\][^\n]*\((?:non-fast-forward|fetch first)\)$/m.test(p.stderr)) return refuse('non-fast-forward: fetch and merge the remote under Step 3\'s conflict rules, run Steps 5-16, then push again; never force-push', 'PUSH_REJECTED');
const declined = (/^remote: error: (GH\d{3}:.+)$/m.exec(p.stderr) ?? /^remote: error: (.+)$/m.exec(p.stderr) ?? /^ ! \[remote rejected\][^(\n]*\(([^)\n]+)\)$/m.exec(p.stderr))?.[1];
const quoted = declined && redactFindingSpans(declined.replace(/[\x00-\x1f\x7f]/g, ' ').trim());
if (declined) return refuse(`the remote refused the push (${quoted ? quoted.slice(0, 240) : 'its reason is withheld: the secret scanner could not redact it'}): change what it names, repeat Step 16, then push; a fetch and merge will not fix it; never force-push or bypass a guard`, 'PUSH_REJECTED');
return refuse(`push failed (${firstLine(p.stderr)}): repair the auth, hook or network cause, repeat Step 16, then push; never bypass a guard`, 'PUSH_GIT_FAILED');
}
r.next('Step 18');
return `PUSH: pushed remote=origin ref=${branch} head=${local}`;
+65
View File
@@ -599,3 +599,68 @@ describe('import --autoplan --stack', () => {
expect(bin(['import', '--autoplan', tmp('appr-run-'), '--branch', 'feature/one', '--stack', 'feature/one'], { cwd }).status).toBe(2);
});
});
// Value: protects=each --owner-ref refusal of rule and round-grant names the one check that failed and the ref shape OWNER_REF accepts, never echoes the rejected ref, and every APPROVAL_RECORD_INVALID fix clause stops pointing at add's flags;
// fails_when=a bad ref, a missing --words and a missing --by print one shared sentence again, the refusal prints the raw ref, or fix: sends rule, round-grant, lane-exception or gate to add (--ask, --scope) (#4718, idea from @Barack-zero-to-one in #4720);
// why_new=no test read the refusal text, only its exit code; seam=gstack-approvals rule|round-grant|lane-exception|gate
describe('APPROVAL_RECORD_INVALID names the failed check and no other command (#4718)', () => {
const committed = () => {
const cwd = repo();
spawnSync('git', ['-c', 'user.name=t', '-c', 'user.email=t@example.invalid', 'commit', '-q', '--allow-empty', '-m', 'init'], { cwd, timeout: 30_000 });
return { cwd, env: { GSTACK_STATE_ROOT: tmp('appr-state-') } };
};
const split = (err: string) => { const at = err.indexOf('; fix: '); return { why: err.slice(0, at), fix: err.slice(at + 7) }; };
const RULE = ['rule', '--finding', 'a.txt:1:docs', '--head', 'HEAD', '--reason', 'synthetic'];
const REF = 'SHIP-161:2026-11-22T18:42:14Z';
const BAD = 'ship-161:2026-11-22T18:40:00Z';
test('rule: a bad ref is refused for its shape alone, without echoing it; a good ref still records', () => {
const o = committed();
const r = bin([...RULE, '--words', 'A', '--by', 'owner', '--owner-ref', BAD], o);
expect([r.status, r.err]).toEqual([2, expect.stringContaining('(APPROVAL_RECORD_INVALID)')]);
const { why } = split(r.err);
expect(why).toContain('--owner-ref');
expect(why).toMatch(/uppercase/);
expect(why).not.toContain(BAD);
expect(why).not.toContain('--words');
expect(why).not.toContain('--by');
const ok = bin([...RULE, '--words', 'A', '--by', 'owner', '--owner-ref', REF], o);
expect(ok.status, ok.err).toBe(0);
});
test('rule: a good ref without --words names --words alone, and without --by names --by alone', () => {
const noWords = split(bin([...RULE, '--by', 'owner', '--owner-ref', REF], committed()).err).why;
expect(noWords).toContain('--words');
expect(noWords).not.toContain('--by');
expect(noWords).not.toMatch(/uppercase/);
const noBy = split(bin([...RULE, '--words', 'A', '--owner-ref', REF], committed()).err).why;
expect(noBy).toContain('--by');
expect(noBy).not.toContain('--words');
expect(noBy).not.toMatch(/uppercase/);
});
test('round-grant: a bad ref is refused for its shape alone; a good ref without --words names --words', () => {
const grant = ['round-grant', '--pr', '7', '--head', 'HEAD', '--kind', 'extra-round', '--reason', 'r', '--by', 'Captain'];
const bad = split(bin([...grant, '--owner-ref', 'ship-161:x', '--words', 'w'], committed()).err).why;
expect(bad).toMatch(/uppercase/);
expect(bad).not.toContain('ship-161');
expect(bad).not.toContain('--words');
const noWords = split(bin([...grant, '--owner-ref', REF], committed()).err).why;
expect(noWords).toContain('--words');
expect(noWords).not.toMatch(/uppercase/);
});
test('the fix clause of rule, round-grant, lane-exception and gate names no flag of add', () => {
const o = committed();
for (const args of [[...RULE, '--words', 'A', '--by', 'owner', '--owner-ref', BAD], ['round-grant'], ['lane-exception'], ['gate']]) {
const r = bin(args, o);
expect([args[0], r.status, r.err]).toEqual([args[0], 2, expect.stringContaining('(APPROVAL_RECORD_INVALID)')]);
const { fix } = split(r.err);
expect(fix).not.toContain('gstack-approvals add');
expect(fix).not.toContain('--ask');
expect(fix).not.toContain('--scope');
expect(fix).toContain('nothing was written');
}
});
});
+35
View File
@@ -331,6 +331,41 @@ describe('push (Step 17)', () => {
expect(r.stdout).toContain('never force-push');
});
// Value: protects=a push the remote refuses (GitHub's GH007 email privacy block, a protected branch) stops with the remote's own reason and what to change, never the fetch-and-merge route, and keeps PUSH_REJECTED;
// fails_when=any output holding "rejected" is read as a non-fast-forward and sends the user into a merge and a rerun of Steps 5-16 (#4738); seam=git push against a bare origin whose pre-receive hook declines; no_claim=GitHub's exact wording beyond the GH007 code
test('a remote refusal stops with its reason, and GH007 says to use the no-reply email, not to merge (#4738)', () => {
const f = fx();
const hook = path.join(f.origin, 'hooks', 'pre-receive');
const decline = (lines: string[]) => fs.writeFileSync(hook, `#!/bin/sh\n${lines.map(l => `echo '${l}' >&2`).join('\n')}\nexit 1\n`, { mode: 0o755 });
decline(['error: GH007: Your push would publish a private email address.', 'You can make your email public or disable this protection by visiting:', 'https://github.com/settings/emails']);
const gh007 = f.run(RELEASE, ['push', '--branch', 'feat'], { GSTACK_SESSION_KIND: 'unattended' });
expect(gh007.status, gh007.stdout + gh007.stderr).toBe(3);
expect(gh007.stdout).toContain('GH007');
expect(gh007.stdout).toContain('user.email');
expect(gh007.stdout).toContain('noreply');
expect(gh007.stdout).not.toContain('non-fast-forward');
expect(gh007.stdout).not.toContain('merge the remote');
expect(lineOf(gh007.stdout, 'PUSH')).toBe('PUSH: failed reason=PUSH_REJECTED');
f.git('branch', '-m', 'fix-non-fast-forward-GH007');
decline(['Trace: 0123abcd', 'error: GH006: Protected branch update failed for refs/heads/fix-non-fast-forward-GH007.']);
const protectedBranch = f.run(RELEASE, ['push', '--branch', 'fix-non-fast-forward-GH007'], { GSTACK_SESSION_KIND: 'unattended' });
expect(protectedBranch.status).toBe(3);
expect(protectedBranch.stdout).toContain('the remote refused the push (GH006: Protected branch update failed');
expect(protectedBranch.stdout).not.toContain('merge the remote');
expect(protectedBranch.stdout).not.toContain('noreply');
expect(lineOf(protectedBranch.stdout, 'PUSH')).toBe('PUSH: failed reason=PUSH_REJECTED');
const token = `ghp_${'a'.repeat(36)}`;
decline([`error: GH013: Push cannot contain secrets: ${token}`]);
const secret = f.run(RELEASE, ['push', '--branch', 'fix-non-fast-forward-GH007'], { GSTACK_SESSION_KIND: 'unattended' });
expect(secret.stdout).toContain('the remote refused the push (GH013: Push cannot contain secrets');
expect(secret.stdout).not.toContain(token);
decline(['nope']);
const plain = f.run(RELEASE, ['push', '--branch', 'fix-non-fast-forward-GH007'], { GSTACK_SESSION_KIND: 'unattended' });
expect(plain.stdout).toContain('the remote refused the push (pre-receive hook declined)');
expect(lineOf(plain.stdout, 'PUSH')).toBe('PUSH: failed reason=PUSH_REJECTED');
expect(f.git('ls-remote', '--heads', 'origin').stdout.trim()).not.toContain('fix-non-fast-forward');
});
// Value: protects=a never-pushed branch whose name breaks the repo's plain-words policy stops before the push, and a plain name pushes; fails_when=a coded or jargon branch name reaches origin, or a plain one is refused;
// why_new=plain public record (docs/ship-policy.md#plain-titles); seam=.gstack/plain-titles.json, git ls-remote; no_claim=branches already on origin
test('a never-pushed branch name with a tracker code or coined term in its front stops; a plain name pushes', () => {