Add a test that stops /ship from gaining refusals without a stated reason (GST-3562) (#4740)

A new test lists the 131 ways /ship can refuse to continue today and
fails when a new one appears without a written reason.

Why: about a third of gstack's recent PRs were gstack repairing its own
gates, and new refusals are how that work grows.

Nothing for readers to do; it changes no /ship behavior.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
Garry Tanandcapy-ai[bot] authored and GitHub committed 2026-11-23 12:52:23 +00:00
1 parent af6deb996e
commit 45b48f17d9
4 files changed
+182

No files matched your search

+1
View File
@@ -0,0 +1 @@
**/ship can't quietly gain new refusals.** A new test lists the 131 ways /ship can refuse to continue today and fails when a new one appears without a written reason, so new stopping points have to justify themselves. test/ship-refusal-code-ratchet.test.ts (GST-3562)
+137
View File
@@ -0,0 +1,137 @@
{
"_comment": "GST-3562 Q: /ship refusal codes. baseline lists the codes raised before GST-3562 (2026-11-23) and may only shrink: delete a name when its code leaves the source. A new code goes in codes with a value starting R56: that states its evidence or measurement plan.",
"baseline": [
"APPROVAL_IMPORT_UNANSWERED",
"APPROVAL_RECORD_INVALID",
"APPROVAL_RECORD_NO_BRANCH",
"APPROVAL_RECORD_SECRET",
"APPROVAL_RECORD_UNAVAILABLE",
"APPROVAL_RECORD_WRITE_FAILED",
"APPROVAL_RULING_RUN_OPEN",
"ARTIFACT_INVALID_JSON",
"ARTIFACT_MALFORMED_JSONL",
"ARTIFACT_MISSING",
"BASE_CONTAINS_HEAD",
"BASE_RED_PAUSE_EXPIRED",
"BRIEF_INPUT_MISSING",
"BUDGET_CAP_REACHED",
"BUDGET_CHECK_SKIPPED",
"BUDGET_LEDGER_INVALID",
"BUDGET_METER_UNAVAILABLE",
"BUDGET_READING_MISSING",
"BUDGET_READING_REJECTED",
"BUN_RESOLUTION_DRIFT",
"CEO_ONLY_NO_GATE",
"CHANGELOG_FRAGMENT_INVALID",
"DOCS_AUDIT_BLOCKED",
"EVIDENCE_IDENTITY_UNKNOWN",
"GATE_AHEAD_ATTEMPT_INVALID",
"INSTALL_UNVERIFIED",
"METER_SCOPE_PARENT",
"POLICY_CONTAINMENT",
"POLICY_FLOOR_ABOVE_STABLE",
"POLICY_GSTACK_TOO_OLD",
"POLICY_INVALID",
"POLICY_SOURCE_UNAVAILABLE",
"PREGATE_CONFIG_INVALID",
"PREGATE_ENVIRONMENT",
"PREGATE_GSTACK_TOO_OLD",
"PREGATE_GUARD_FAILED",
"PREGATE_HEAD_POLICY_LOOSENS",
"PREGATE_INCOMPLETE",
"PREGATE_LANE_FAILED",
"PREGATE_LITERALS",
"PREGATE_NO_LANE",
"PREGATE_NO_POLICY",
"PREGATE_REMOTE_UNCLEARED",
"PREGATE_SECRETS",
"PREGATE_STALE",
"PREGATE_STALLED",
"PREGATE_STRAYS",
"PREGATE_TIMING_ASSERTION",
"PUSH_GIT_FAILED",
"QUEUE_BASE_RED_NO_TRAIN",
"QUEUE_BASE_UNFETCHED",
"QUEUE_GATE_MISSING",
"QUEUE_LAND_BASE_BUSY",
"QUEUE_LAND_CHECKS",
"QUEUE_LAND_CONFLICT",
"QUEUE_LAND_DRIFT",
"QUEUE_LAND_LOCKED",
"QUEUE_LAND_MERGED_CHECKS",
"QUEUE_LAND_NOT_CLEAN",
"QUEUE_LAND_PIN_MOVED",
"QUEUE_LAND_STAMPED",
"QUEUE_LAND_UNVERIFIED",
"QUEUE_NOT_READY",
"QUEUE_POST_MERGE_RED",
"QUEUE_PROOF_MISSING",
"QUEUE_READY_NOTE_UNPUSHED",
"QUEUE_RECEIPT_BASE_MISMATCH",
"QUEUE_RECEIPT_CONDITIONAL",
"QUEUE_RECEIPT_DEPTH_RAISED",
"QUEUE_RECEIPT_EXCEPTION_INVALID",
"QUEUE_RECEIPT_MISSING",
"QUEUE_RECEIPT_STALE",
"QUEUE_RECEIPT_TARGETED_MISSING",
"QUEUE_SCREEN_NOT_RUN",
"QUEUE_SCREEN_RED",
"QUEUE_SCREEN_STALE_REF",
"QUEUE_STALE",
"QUEUE_STAMP_NOT_STAMP_ONLY",
"QUEUE_TRAIN_BASE_RED",
"QUEUE_TRAIN_BISECT_CAPPED",
"QUEUE_TRAIN_CONFLICT",
"QUEUE_TRAIN_DISPATCH_UNKNOWN",
"QUEUE_TRAIN_DOCTOR_FINDINGS",
"QUEUE_TRAIN_FREE_RED",
"QUEUE_TRAIN_FROZEN",
"QUEUE_TRAIN_INCOMPLETE",
"QUEUE_TRAIN_INIT_REFUSED",
"QUEUE_TRAIN_LAND_METHOD",
"QUEUE_TRAIN_MOVED",
"QUEUE_TRAIN_OFF",
"QUEUE_TRAIN_PENDING",
"QUEUE_TRAIN_PREFIX_INVALID",
"QUEUE_TRAIN_REBUILD_REFUSED",
"QUEUE_TRAIN_RED",
"QUEUE_TRAIN_RED_ON_MAIN",
"QUEUE_TRAIN_SPEND_CAP",
"QUEUE_TRAIN_STACK_RED",
"QUEUE_TRAIN_STALE",
"QUEUE_TRAIN_STAMP_MISMATCH",
"QUEUE_TRAIN_TREE_MISMATCH",
"QUEUE_TRAIN_UNATTRIBUTED",
"QUEUE_TRAIN_UNSTAMPED",
"QUEUE_TRAIN_UNTRUSTED",
"QUEUE_TRAIN_WAITING",
"QUEUE_VERIFY_MISMATCH",
"QUEUE_WAVE_DUPLICATE",
"READY_SCREEN_CHOICE_REQUIRED",
"RECEIPT_CARRY_PREGATE_STALE",
"RECEIPT_CARRY_PRODUCT_CHANGED",
"RECEIPT_CARRY_REFUSED",
"RECEIPT_CARRY_SCOPED_REVIEW",
"RECEIPT_CARRY_TREE_MISMATCH",
"RECEIPT_GIT_TOO_OLD",
"RECEIPT_INVALID",
"REGEN_COMMAND_FAILED",
"REGEN_DEPS_MISSING",
"REGEN_REGISTRY_INVALID",
"REGEN_STALE",
"RELEASE_STAMP_INVALID",
"REPO_COMMANDS_NOT_ALLOWED",
"RESTAMP_CONFLICT",
"RESTAMP_NOT_STAGED",
"RESTAMP_UNSTAGED_EDITS",
"REVIEW_DIFF_TOO_LARGE",
"REVIEW_DIFF_UNREADABLE",
"REVIEW_EXCLUDE_KEEP_TOO_LARGE",
"REVIEW_SCOPE_INPUT",
"REVIEW_STATUS_MISMATCH",
"SHIP_BASE_RED_FIXER",
"STABLE_RELEASE_UNKNOWN",
"WTREE_UNAVAILABLE"
],
"codes": {}
}
+1
View File
@@ -220,6 +220,7 @@ export const FREE_FIXTURES: Readonly<Record<string, readonly string[]>> = {
'test/fixtures/review-fetch/**': ['test/review-fetch.test.ts'],
'test/fixtures/review-ledger/**': ['test/review-dispatch.test.ts'],
'test/fixtures/review-pins/**': ['test/review-packets-removed.test.ts'],
'test/fixtures/ship-refusal-codes.json': ['test/ship-refusal-code-ratchet.test.ts'],
'test/fixtures/review-risk/gbrain-evals-289.json': ['test/review-risk-routing.test.ts'],
'test/fixtures/review-design-lite-reports-ci-36633323521.json': ['test/review-finalization-budget.test.ts'],
'test/fixtures/review-gate-integrity-opus-reports.json': ['test/gate-integrity-templates.test.ts'],
+43
View File
@@ -0,0 +1,43 @@
/**
* GST-3562 Q: /ship's refusal codes may only shrink. On 2026-11-22, 25 of 67 merged gstack PRs were gstack repairing its own gates,
* so a new refusal in /ship's review, receipt, pregate or queue code needs a stated R56 reason (evidence that it helps, or a
* reason and a plan to measure it) in test/fixtures/ship-refusal-codes.json; a code that leaves the source leaves the list.
*/
import { describe, expect, test } from 'bun:test';
import * as fs from 'node:fs';
import * as path from 'node:path';
const ROOT = path.resolve(import.meta.dir, '..');
const LIST = path.join(ROOT, 'test', 'fixtures', 'ship-refusal-codes.json');
const BASELINE_MAX = 131;
const SOURCES = /^(lib\/(ship-|review-|fix-check-clearing|pr-review-history|approval-record|ci-carry|tree-receipt|restamp)[^/]*\.ts|lib\/pregate\/.*\.ts|crew\/lib\/ship-[^/]*\.ts|bin\/gstack-(ship-[a-z-]+|review-[a-z-]+|pregate|approvals|ci-carry|tree-receipt|restamp))$/;
function walk(dir: string): string[] {
return fs.readdirSync(path.join(ROOT, dir), { withFileTypes: true }).flatMap(e => e.isDirectory() ? walk(path.join(dir, e.name)) : [path.join(dir, e.name)]);
}
/** Every `code: 'X'` or `refused('X', …)`-style refusal in /ship's machinery, with the first file that raises it. */
function refusalCodes(): Map<string, string> {
const found = new Map<string, string>();
for (const file of [...walk('lib'), ...walk('crew/lib'), ...walk('bin')].map(f => f.split(path.sep).join('/')).filter(f => SOURCES.test(f) && !f.endsWith('.test.ts')).sort()) {
for (const m of fs.readFileSync(path.join(ROOT, file), 'utf8').matchAll(/(?:code: |\b(?:refused|refuse|budgetError|BudgetError|ReviewLogError)\()'([A-Z][A-Z0-9_]+)'/g)) if (!found.has(m[1]!)) found.set(m[1]!, file);
}
return found;
}
describe('ship refusal-code ratchet (GST-3562 Q)', () => {
// Value: protects=GST-3562 Q, no new /ship refusal without an R56 reason, and the list shrinks as codes are deleted;
// fails_when=a new code: '...' or refused('...')-style refusal appears in /ship's review, receipt, pregate or queue code
// without a reason, a new code is filed under the baseline, or a listed code disappears from the source and stays listed;
// why_new=GST-3562 Q; seam=the source text; no_claim=that a reason is true
test('every refusal code is listed, every new one names an R56 reason, the baseline only shrinks, and no listed code is gone', () => {
const list: { baseline: string[]; codes: Record<string, string> } = JSON.parse(fs.readFileSync(LIST, 'utf8'));
const listed = new Set([...list.baseline, ...Object.keys(list.codes)]);
const now = refusalCodes();
const unlisted = [...now].filter(([c]) => !listed.has(c)).map(([c, f]) => `${c} (${f}): add it to codes in test/fixtures/ship-refusal-codes.json with its R56 reason`);
const unreasoned = Object.entries(list.codes).filter(([, why]) => !/^R56: .{20,}/.test(why)).map(([c]) => `${c}: a new code's reason starts with "R56: " and says what evidence or measurement plan admits it`);
const grown = list.baseline.length > BASELINE_MAX ? [`baseline grew to ${list.baseline.length} of ${BASELINE_MAX}: a new code goes in codes with its R56 reason`] : [];
const gone = [...listed].filter(c => !now.has(c)).map(c => `${c}: no longer raised, so remove it from the list`);
expect([...unlisted, ...unreasoned, ...grown, ...gone]).toEqual([]);
});
});