Skipped quarantined tests fail the run, and the upgrade snooze sticks for git installs (GST-3344) (#4590)

A quarantined test that the runner skipped now fails the run, and "Not
now" on the upgrade prompt now lasts its full snooze on git installs.

Why: four outside reports showed a false pass, a snooze that came back
after two hours, a model check that ignored `config.toml`, and two `$B`
rules missing from /browse.

Nothing to do.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Review-Finding: p1/specialist-batched#1 reader=red-team
This commit is contained in:
Garry Tanandcapy-ai[bot] authored and GitHub committed 2026-11-21 07:26:14 +00:00
1 parent 0adfab9dd9
commit e096fa850c
15 files changed
+175 -84

No files matched your search

+8 -5
View File
@@ -297,10 +297,10 @@ function mayRunAgain(again: Ran, first: JunitReport, quarantined: ReadonlySet<st
const history = (t: JunitTest, runs: Ran[]): Attempt[] =>
[...t.attempts, ...runs.flatMap(r => r.report?.tests.find(x => x.id === t.id)?.attempts ?? ['fail' as const])];
/** A quarantined test passes only when it never failed or an attempt with the runner's full verdict cleared it. */
/** A quarantined test passes only when its final attempt ran and passed, and it never failed or an attempt with the runner's full verdict cleared it; a skip is not a run. */
const quarantinedStatus = (attempts: string[], cleared: boolean): 'quarantined-pass' | 'quarantined-fail' | 'hard-break' =>
cleared || !attempts.includes('fail') ? 'quarantined-pass'
: attempts.length >= QUARANTINE_ATTEMPTS && attempts.every(a => a === 'fail') ? 'hard-break' : 'quarantined-fail';
attempts.length >= QUARANTINE_ATTEMPTS && attempts.every(a => a === 'fail') ? 'hard-break'
: attempts.at(-1) === 'pass' && (cleared || !attempts.includes('fail')) ? 'quarantined-pass' : 'quarantined-fail';
export async function runFlaky(opts: RunOptions): Promise<RunResult> {
const cwd = opts.cwd ?? process.cwd();
@@ -363,7 +363,7 @@ export async function runFlaky(opts: RunOptions): Promise<RunResult> {
if (why) settle(t, t.attempts, why);
else eligible.push(t);
}
const passedQ = report.tests.filter(t => isQ(t) && finalAttempt(t) !== 'fail' && t.attempts.some(a => a !== 'skip'));
const passedQ = report.tests.filter(t => isQ(t) && finalAttempt(t) !== 'fail');
const wholeRerun = !eligible.length ? undefined
: opts.rerunScope !== 'test' ? 'the default; --rerun-scope test reruns the failed test alone'
: incompleteRun(report.runner, first.output, first.exit, opts.command, runnerFlaky.length) ?? undefined;
@@ -409,7 +409,10 @@ export async function runFlaky(opts: RunOptions): Promise<RunResult> {
if (reruns) fs.writeFileSync(junit, firstXml);
}
const green = runs.length ? fullGreen(runs.at(-1)!, report) : reruns > 0 || first.exit === 0;
for (const t of passedQ) settleQ(t, history(t, runs), green, 'the attempt that decided the run was not a full green run', runs.length ? 'command' : undefined);
for (const t of passedQ) {
const attempts = history(t, runs);
settleQ(t, attempts, green, attempts.at(-1) === 'skip' ? 'quarantined, and skipped on the final attempt instead of running' : 'the attempt that decided the run was not a full green run', runs.length ? 'command' : undefined);
}
const red = !green || outcomes.some(o => !PASSING.has(o.status));
const q = outcomes.filter(o => o.status === 'quarantined-pass' || o.status === 'quarantined-fail' || o.status === 'hard-break').length;
return { exitCode: red ? 1 : 0, tests: report.tests.length, commandExit: first.exit, outcomes, reruns, quarantined: q, ...(wholeRerun && reruns ? { wholeRerun } : {}), ledger };
+13 -1
View File
@@ -1,7 +1,10 @@
import * as path from 'node:path';
import { CODEX_EFFORT_LEVELS, MODEL_CATALOG, MODEL_CATALOG_VERSION, MODEL_PROVIDERS, MODEL_TIERS, modelCatalogSha256, type ModelProvider } from './model-catalog';
import {
CODEX_MODEL_REPAIR,
codexNativeModel,
CUSTOM_PROVIDER_UNSCANNED,
DOCS_PROVIDER,
describeSelection,
MODEL_OVERRIDE_KEYS,
ModelPolicyError,
@@ -319,13 +322,22 @@ export function modelsMain(args: string[], env: StateRootEnv = process.env, plat
: { code: 1, stdout: '', stderr: errors.map(renderError).join('') };
}
const codexModel = codexNativeModel({ kind: 'exec', env });
const nativeModel = () => {
try {
return codexModel();
} catch (error) {
if (error instanceof ModelPolicyError) throw error;
throw new ModelPolicyError({ reason: 'native_provider_unresolved', problem: 'gstack cannot read the model your Codex config.toml names', cause: (error as Error).message, key: null, source: 'native', repair: [CODEX_MODEL_REPAIR], docs: DOCS_PROVIDER });
}
};
const selections: ModelSelection[] = [];
const errors: CliError[] = [];
const roles: ModelRole[] = command === 'list' ? ['plan-review', 'implementation'] : [role === 'eval-arms' ? 'implementation' : role as ModelRole];
for (const r of roles) {
for (const p of provider ? [provider] : MODEL_PROVIDERS) {
attempt(r, p, () => r === 'plan-review'
? [resolvePlanReviewModel({ provider: p, env, platform, cwd, config })]
? [resolvePlanReviewModel({ provider: p, env, platform, cwd, config, ...(p === 'openai' ? { nativeModel } : {}) })]
: resolveImplementationModels({ provider: p, env, platform, cwd, config }), selections, errors);
}
}
+65 -1
View File
@@ -43,7 +43,7 @@ export const ANTHROPIC_MODEL_ID_PATTERN = /^[A-Za-z0-9._:/@+[\]-]{1,512}$/;
const DOCS = 'https://github.com/garrytan/gstack/blob/main/docs/troubleshooting.md';
const DOCS_CONFIG = `${DOCS}#model-policy-config`;
const DOCS_PROVIDER = `${DOCS}#model-policy-provider`;
export const DOCS_PROVIDER = `${DOCS}#model-policy-provider`;
const DOCS_SELECTION = `${DOCS}#model-policy-selection`;
const PROVIDER_LABEL: Record<ModelProvider, string> = { anthropic: 'Anthropic (Claude Code)', openai: 'OpenAI (Codex)' };
@@ -695,3 +695,67 @@ export function modelPolicyCommands() {
restoreDefault: 'gstack-config unset plan_review_tier',
};
}
export const CODEX_MODEL_REPAIR = 'Choose a model your Codex account can use: name it for this request, set GSTACK_CODEX_MODEL=<model>, or set model in the Codex config.toml.';
const stripControlChars = (value: string): string => value.replace(/[\x00-\x1f\x7f]/g, ' ');
/**
* The model Codex's own config.toml names for this invocation kind
* (`review_model` first for native review, then the legacy active profile's
* model, then `model`). `value` is null when it names none, and `source`
* then says what was missing. Shared by the runtime and plan-review records.
*/
export function codexConfigModel(opts: {
kind: 'exec' | 'review';
env: Record<string, string | undefined>;
codexHome?: string;
home?: string;
}): { value: string | null; source: string } {
const home = opts.home ?? opts.env.HOME ?? os.homedir();
const codexHome = opts.codexHome ?? opts.env.CODEX_HOME ?? path.join(home, '.codex');
if (!path.isAbsolute(codexHome)) {
throw new Error(`CODEX_HOME '${sanitize(codexHome)}' is not an absolute path, so its config.toml model cannot be read. ${CODEX_MODEL_REPAIR}`);
}
const configPath = path.join(codexHome, 'config.toml');
let raw: string;
try {
raw = fs.readFileSync(configPath, 'utf8');
} catch (error) {
if ((error as NodeJS.ErrnoException).code === 'ENOENT') return { value: null, source: `no ${stripControlChars(configPath)}` };
throw new Error(`Could not read ${sanitize(configPath)}. ${CODEX_MODEL_REPAIR}`);
}
let parsed: Record<string, unknown>;
try {
parsed = Bun.TOML.parse(raw) as Record<string, unknown>;
} catch {
throw new Error(`Could not parse ${sanitize(configPath)}. ${CODEX_MODEL_REPAIR}`);
}
const profileName = typeof parsed.profile === 'string' ? parsed.profile : undefined;
const profiles = parsed.profiles as Record<string, Record<string, unknown> | undefined> | undefined;
const profile = profileName && typeof profiles === 'object' ? profiles?.[profileName] : undefined;
const candidates: Array<[string, unknown]> = [
...(opts.kind === 'review' ? [[`${configPath} review_model`, parsed.review_model] as [string, unknown]] : []),
[`${configPath} [profiles.${profileName}].model`, profile?.model],
[`${configPath} model`, parsed.model],
];
for (const [source, value] of candidates) {
if (value === undefined) continue;
if (typeof value !== 'string') throw new Error(`${sanitize(source)} is not a string. ${CODEX_MODEL_REPAIR}`);
return { value, source };
}
return { value: null, source: `no model in ${stripControlChars(configPath)}` };
}
/** The model Codex's config.toml names, in the shape resolvePlanReviewModel's nativeModel reads, so every plan-review caller sees the same custom-provider model. */
export function codexNativeModel(opts: {
kind: 'exec' | 'review';
env: Record<string, string | undefined>;
codexHome?: string;
home?: string;
}): () => { model: string; label: string } | null {
return () => {
const named = codexConfigModel(opts);
return named.value === null ? null : { model: named.value.trim(), label: stripControlChars(named.source) };
};
}