mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-23 08:31:44 +01:00
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:
1 parent
0adfab9dd9
commit
e096fa850c
15 files changed
+175
-84
No files matched your search
+5
-4
@@ -483,10 +483,11 @@ publish cookie values, passwords, profile/account text, or session details.
|
||||
|
||||
## Fallback command reference
|
||||
|
||||
The table in the Browser fallback section covers what the cookbook covers. Everything
|
||||
else `$B` can do — extraction, tabs, dialogs, uploads, meta/server commands, and the
|
||||
full snapshot-flag reference — lives in the generated section below. Read it before
|
||||
reaching for a `$B` command that is not in the table.
|
||||
Read the section below before using a `$B` command the table lacks.
|
||||
|
||||
- `$B eval <file>` reads only files under the temp dir or the daemon's working dir.
|
||||
- Each git root gets its own daemon: after a `cd` into another repo (nested too), `$B`
|
||||
starts a new one without your session. Run `$B` from the project dir.
|
||||
|
||||
> **STOP.** Before using any command or snapshot flag beyond the Browser fallback translation table — the full generated reference for every browse command, its argument shape, and every snapshot flag, Read `~/.claude/skills/gstack/browse/sections/command-list.md` and execute it
|
||||
> in full. Do not work from memory — that section is the source of truth for this step.
|
||||
@@ -120,9 +120,10 @@ publish cookie values, passwords, profile/account text, or session details.
|
||||
|
||||
## Fallback command reference
|
||||
|
||||
The table in the Browser fallback section covers what the cookbook covers. Everything
|
||||
else `$B` can do — extraction, tabs, dialogs, uploads, meta/server commands, and the
|
||||
full snapshot-flag reference — lives in the generated section below. Read it before
|
||||
reaching for a `$B` command that is not in the table.
|
||||
Read the section below before using a `$B` command the table lacks.
|
||||
|
||||
- `$B eval <file>` reads only files under the temp dir or the daemon's working dir.
|
||||
- Each git root gets its own daemon: after a `cd` into another repo (nested too), `$B`
|
||||
starts a new one without your session. Run `$B` from the project dir.
|
||||
|
||||
{{SECTION:command-list}}
|
||||
@@ -0,0 +1 @@
|
||||
**A quarantined test that the runner skipped now fails the run instead of passing it.** `gstack-flaky` treats a skip on the attempt that decided the run as a quarantined failure, because a quarantined test still has to run; a test skipped first and passing on the retry still passes (#4550, fix found in #4551). Also: "Not now" on the upgrade prompt now sticks for git installs, because the snooze snippet takes the whole `UPGRADE_AVAILABLE` line and keys on the same field the update check reads (#4561); `gstack-models resolve` and `list` read a custom Codex provider's `config.toml` model the way `gstack-codex-probe role-ready` does, instead of always saying no model is set (#4491); and the /browse skill now says that `$B eval` reads files only from the temp directory or the daemon's working directory, and that the daemon belongs to the git root you run `$B` from (#4557, #4558).
|
||||
+3
-1
@@ -90,7 +90,9 @@ live quarantined test, and nothing else is wrong with that attempt (no kill, no
|
||||
failure outside the report, no first-run test missing), the whole command may
|
||||
run again, up to 3 attempts in total. The run is green only when one of those
|
||||
attempts is fully green. A quarantined test that fails all 3 is a **hard
|
||||
break**, and the run is red. A test that is not quarantined keeps its one
|
||||
break**, and the run is red. A quarantined test skipped on the final attempt
|
||||
did not run, so it is a quarantined failure and the run is red; it never counts
|
||||
toward the clean streak. A test that is not quarantined keeps its one
|
||||
rerun. A red attempt never turns green because its only reported failure is a
|
||||
quarantined test, because the runner's exit status can come from things the
|
||||
report does not show (a coverage threshold, a fail-on-flaky policy, a global
|
||||
|
||||
@@ -113,9 +113,10 @@ because you already route that ID to your endpoint. Any other name there, such
|
||||
as a smart-tier model or a deployment alias, is refused
|
||||
(`custom_provider_model_not_tier`): it could be any model, so name it with the
|
||||
tier setting or the environment override if you want it as your plan reviewer.
|
||||
`gstack-codex-probe role-ready` and `gstack-outside-voice run --runner codex-cli`
|
||||
(for the `autoplan` and `spec` gates) share this selection, so the readiness
|
||||
check and the review never pick different models. A model identifier passing syntax validation
|
||||
`gstack-codex-probe role-ready`, `gstack-outside-voice run --runner codex-cli`
|
||||
(for the `autoplan` and `spec` gates), and `gstack-models resolve` and `list`
|
||||
share this selection, so the readiness check, the review and the listing never
|
||||
pick different models. A model identifier passing syntax validation
|
||||
is not proof of account availability. See [provider recovery](troubleshooting.md#model-policy-provider).
|
||||
|
||||
Detection is conservative, not a replacement for the CLI's settings engine.
|
||||
|
||||
@@ -50,7 +50,8 @@ Tell user: "Auto-upgrade enabled. Future updates will install automatically." Th
|
||||
```bash
|
||||
GSTACK_STATE_ROOT=$(~/.claude/skills/gstack/bin/gstack-paths --get GSTACK_STATE_ROOT); : "${GSTACK_STATE_ROOT:?gstack-paths failed; reinstall with ./setup or /gstack-upgrade}"
|
||||
_SNOOZE_FILE="$GSTACK_STATE_ROOT/update-snoozed"
|
||||
_REMOTE_VER="{new}"
|
||||
_UPGRADE_LINE="{line}"
|
||||
_REMOTE_VER=$(printf '%s\n' "$_UPGRADE_LINE" | awk '{print (NF >= 4 ? $(4) : $(3))}')
|
||||
_CUR_LEVEL=0
|
||||
if [ -f "$_SNOOZE_FILE" ]; then
|
||||
_SNOOZED_VER=$(awk '{print $(1)}' "$_SNOOZE_FILE")
|
||||
@@ -63,7 +64,7 @@ _NEW_LEVEL=$((_CUR_LEVEL + 1))
|
||||
[ "$_NEW_LEVEL" -gt 3 ] && _NEW_LEVEL=3
|
||||
echo "$_REMOTE_VER $_NEW_LEVEL $(date +%s)" > "$_SNOOZE_FILE"
|
||||
```
|
||||
Note: `{new}` is the remote version from the `UPGRADE_AVAILABLE` output — substitute it from the update check result. On a four-field line use the SHA (fourth field) as `{new}`, so the snooze ends when main moves.
|
||||
Note: `{line}` is the whole `UPGRADE_AVAILABLE` line, exactly as printed; the snippet picks the field `gstack-update-check` reads.
|
||||
|
||||
Tell user the snooze duration: "Next reminder in 24h" (or 48h or 1 week, depending on level). Tip: "Set `auto_upgrade: true` in `~/.gstack/config.yaml` for automatic upgrades."
|
||||
|
||||
|
||||
@@ -56,7 +56,8 @@ Tell user: "Auto-upgrade enabled. Future updates will install automatically." Th
|
||||
```bash
|
||||
GSTACK_STATE_ROOT=$(~/.claude/skills/gstack/bin/gstack-paths --get GSTACK_STATE_ROOT); : "${GSTACK_STATE_ROOT:?gstack-paths failed; reinstall with ./setup or /gstack-upgrade}"
|
||||
_SNOOZE_FILE="$GSTACK_STATE_ROOT/update-snoozed"
|
||||
_REMOTE_VER="{new}"
|
||||
_UPGRADE_LINE="{line}"
|
||||
_REMOTE_VER=$(printf '%s\n' "$_UPGRADE_LINE" | awk '{print (NF >= 4 ? $(4) : $(3))}')
|
||||
_CUR_LEVEL=0
|
||||
if [ -f "$_SNOOZE_FILE" ]; then
|
||||
_SNOOZED_VER=$(awk '{print $(1)}' "$_SNOOZE_FILE")
|
||||
@@ -69,7 +70,7 @@ _NEW_LEVEL=$((_CUR_LEVEL + 1))
|
||||
[ "$_NEW_LEVEL" -gt 3 ] && _NEW_LEVEL=3
|
||||
echo "$_REMOTE_VER $_NEW_LEVEL $(date +%s)" > "$_SNOOZE_FILE"
|
||||
```
|
||||
Note: `{new}` is the remote version from the `UPGRADE_AVAILABLE` output — substitute it from the update check result. On a four-field line use the SHA (fourth field) as `{new}`, so the snooze ends when main moves.
|
||||
Note: `{line}` is the whole `UPGRADE_AVAILABLE` line, exactly as printed; the snippet picks the field `gstack-update-check` reads.
|
||||
|
||||
Tell user the snooze duration: "Next reminder in 24h" (or 48h or 1 week, depending on level). Tip: "Set `auto_upgrade: true` in `~/.gstack/config.yaml` for automatic upgrades."
|
||||
|
||||
|
||||
+8
-5
@@ -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
@@ -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
@@ -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) };
|
||||
};
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import * as fs from 'fs';
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
import { ALL_MODEL_NAMES, resolveModel, type Model } from './models';
|
||||
import { ModelPolicyError, resolvePlanReviewModel, selectionRepair, type ModelSelection } from '../lib/model-policy';
|
||||
import { CODEX_MODEL_REPAIR, codexConfigModel, codexNativeModel, ModelPolicyError, resolvePlanReviewModel, selectionRepair, type ModelSelection } from '../lib/model-policy';
|
||||
import { emitModelPolicyNotice } from '../lib/model-policy-notice';
|
||||
|
||||
export interface CodexGenerationModelResolution {
|
||||
@@ -117,7 +117,7 @@ export interface CodexRuntimeModelSelection {
|
||||
/** Characters a model id may carry before it is interpolated into `-c "model=\"…\""`. */
|
||||
export const CODEX_RUNTIME_MODEL_PATTERN = /^[A-Za-z0-9._:/-]{1,100}$/;
|
||||
|
||||
const 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 REPAIR = CODEX_MODEL_REPAIR;
|
||||
|
||||
/**
|
||||
* Runtime model for gstack-owned Codex calls (#2914). Unlike the generation
|
||||
@@ -150,53 +150,6 @@ export function resolveCodexRuntimeModel(opts: {
|
||||
return chosen(named.source, named.value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
function codexConfigModel(opts: {
|
||||
kind: CodexInvocationKind;
|
||||
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. ${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 ${stripControl(configPath)}` };
|
||||
throw new Error(`Could not read ${sanitize(configPath)}. ${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)}. ${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. ${REPAIR}`);
|
||||
return { value, source };
|
||||
}
|
||||
return { value: null, source: `no model in ${stripControl(configPath)}` };
|
||||
}
|
||||
|
||||
export interface CodexPlanReviewSelection extends CodexRuntimeModelSelection {
|
||||
selection: ModelSelection;
|
||||
/** Source-aware repair for this record, never a lower-priority setting. */
|
||||
@@ -218,11 +171,7 @@ export function resolveCodexPlanReviewModel(opts: {
|
||||
cwd?: string;
|
||||
}): CodexPlanReviewSelection {
|
||||
const env = opts.env ?? process.env;
|
||||
const nativeModel = () => {
|
||||
const named = codexConfigModel({ ...opts, env });
|
||||
return named.value === null ? null : { model: named.value.trim(), label: stripControl(named.source) };
|
||||
};
|
||||
const selection = resolvePlanReviewModel({ provider: 'openai', requestedModel: opts.explicit || undefined, env, cwd: opts.cwd, nativeModel });
|
||||
const selection = resolvePlanReviewModel({ provider: 'openai', requestedModel: opts.explicit || undefined, env, cwd: opts.cwd, nativeModel: codexNativeModel({ ...opts, env }) });
|
||||
const repair = stripControl(selectionRepair(selection).join('; '));
|
||||
if (selection.status === 'selected') {
|
||||
const model = selection.requestedModel;
|
||||
|
||||
@@ -187,6 +187,31 @@ describe('gstack-models inspector', () => {
|
||||
expect(doc.errors.map((e: { reason: string; role: string }) => `${e.reason}/${e.role}`)).toEqual(['custom_provider_requires_model/plan-review', 'custom_provider_requires_model/implementation']);
|
||||
});
|
||||
|
||||
// #4491 follow-up: resolve and list read the custom provider's config.toml model the way gstack-codex-probe role-ready does.
|
||||
test('a custom Codex provider naming the frontier catalog ID in config.toml resolves; any other name is not the tier', () => {
|
||||
const { env, home } = fixture();
|
||||
fs.mkdirSync(path.join(home, '.codex'));
|
||||
const toml = (model: string) => fs.writeFileSync(path.join(home, '.codex', 'config.toml'), `model = "${model}"\nmodel_provider = "proxy"\n`);
|
||||
toml('gpt-6-astra');
|
||||
const ok = json(['resolve', '--role', 'plan-review', '--provider', 'openai'], env);
|
||||
expect(ok.code).toBe(0);
|
||||
expect(ok.doc.selections[0]).toMatchObject({ role: 'plan-review', provider: 'openai', requestedModel: 'gpt-6-astra' });
|
||||
expect(json([], env).doc.errors.filter((e: { role: string }) => e.role === 'plan-review')).toEqual([]);
|
||||
toml('my-alias');
|
||||
const alias = json(['resolve', '--role', 'plan-review', '--provider', 'openai'], env);
|
||||
expect(alias.code).toBe(1);
|
||||
expect(alias.doc.errors[0]).toMatchObject({ reason: 'custom_provider_model_not_tier', provider: 'openai' });
|
||||
});
|
||||
|
||||
test('a custom provider whose config.toml model is not a string reports a structured error', () => {
|
||||
const { env, home } = fixture();
|
||||
fs.mkdirSync(path.join(home, '.codex'));
|
||||
fs.writeFileSync(path.join(home, '.codex', 'config.toml'), 'model = 5\nmodel_provider = "proxy"\n');
|
||||
const r = json(['resolve', '--role', 'plan-review', '--provider', 'openai'], env);
|
||||
expect(r.code).toBe(1);
|
||||
expect(r.doc.errors[0]).toMatchObject({ reason: 'native_provider_unresolved', provider: 'openai', role: 'plan-review' });
|
||||
});
|
||||
|
||||
test('project settings in the working directory are custom routing; detection limits are published', () => {
|
||||
const { env, root } = fixture();
|
||||
const project = path.join(root, 'project');
|
||||
|
||||
@@ -219,6 +219,7 @@ function fakeRun(reports: (n: number, argv: string[]) => string | null, exits: (
|
||||
const suite = (cases: string, file = 'a.test.ts') => `<testsuites name="bun test"><testsuite name="${file}" file="${file}">${cases}</testsuite></testsuites>`;
|
||||
const pass = (name: string) => `<testcase name="${name}" classname="" file="a.test.ts"/>`;
|
||||
const fail = (name: string) => `<testcase name="${name}" classname="" file="a.test.ts"><failure message="boom"/></testcase>`;
|
||||
const skipped = (name: string) => `<testcase name="${name}" classname="" file="a.test.ts"><skipped/></testcase>`;
|
||||
const Q = new Set(['a.test.ts::::q']);
|
||||
const run = (f: ReturnType<typeof fakeRun>, extra: Partial<Parameters<typeof runFlaky>[0]> = {}) =>
|
||||
runFlaky({ command: ['bun', 'test'], junit: 'r.xml', maxReruns: 3, cwd: tmp(), spawn: f.spawn, env: {}, now: () => NOW, quarantined: Q, ...extra });
|
||||
@@ -307,6 +308,34 @@ describe('the quarantine attempt budget under the full green verdict', () => {
|
||||
expect(renderResult(r, '/l').at(-1)).toContain('failed=0 flaky=0 quarantined=1');
|
||||
});
|
||||
|
||||
// #4550: a quarantined test still runs, so a skip on the attempt that decides the run is a quarantined failure.
|
||||
test('a quarantined test the runner skipped is a quarantined failure and the run is red', async () => {
|
||||
const f = fakeRun(() => suite(skipped('q') + pass('a')), () => 0);
|
||||
const r = await run(f);
|
||||
expect(f.calls).toHaveLength(1);
|
||||
expect(r.exitCode).toBe(1);
|
||||
expect(r.outcomes).toMatchObject([{ status: 'quarantined-fail', attempts: ['skip'], reason: 'quarantined, and skipped on the final attempt instead of running' }]);
|
||||
expect(r.ledger.map(l => [l.kind, l.id, l.attempts])).toEqual([['quarantined-fail', 'a.test.ts::::q', ['skip']]]);
|
||||
expect(renderResult(r, '/l').at(-1)).toBe('FLAKY_RESULT: tests=2 failed=1 flaky=0 quarantined=1 reruns=0 command_exit=0 verdict=fail ledger=/l');
|
||||
});
|
||||
|
||||
test('a quarantined test that passed and was then skipped on the whole-command retry is a quarantined failure', async () => {
|
||||
const f = fakeRun(n => n === 1 ? suite(pass('q') + fail('a')) : suite(skipped('q') + pass('a')), n => n === 1 ? 1 : 0);
|
||||
const r = await run(f);
|
||||
expect(f.calls).toHaveLength(2);
|
||||
expect(r.exitCode).toBe(1);
|
||||
expect(r.ledger.find(l => l.id === 'a.test.ts::::q')).toMatchObject({ kind: 'quarantined-fail', attempts: ['pass', 'skip'] });
|
||||
});
|
||||
|
||||
test('a quarantined test skipped first and passing on the whole-command retry still passes, and an ordinary skip follows the runner', async () => {
|
||||
const retried = fakeRun(n => n === 1 ? suite(skipped('q') + fail('a')) : suite(pass('q') + pass('a')), n => n === 1 ? 1 : 0);
|
||||
const r = await run(retried);
|
||||
expect(r.exitCode).toBe(0);
|
||||
expect(r.outcomes.find(o => o.test.id === 'a.test.ts::::q')).toMatchObject({ status: 'quarantined-pass', attempts: ['skip', 'pass'] });
|
||||
const ordinary = await run(fakeRun(() => suite(skipped('s') + pass('a')), () => 0), { quarantined: new Set() });
|
||||
expect(ordinary).toMatchObject({ exitCode: 0, quarantined: 0, outcomes: [], ledger: [] });
|
||||
});
|
||||
|
||||
test('quarantined failures do not count against --max-reruns', async () => {
|
||||
const f = fakeRun(n => suite(pass('a') + (n === 1 ? fail('q') : pass('q'))), n => n === 1 ? 1 : 0);
|
||||
expect((await run(f, { maxReruns: 0 })).exitCode).toBe(0);
|
||||
|
||||
@@ -96,15 +96,15 @@ for (const host of ['claude', 'codex'] as const) for (const args of [[], tenArgu
|
||||
});
|
||||
test(`${label}: upgrade snooze advances the same-version level`, () => {
|
||||
mkdirSync(join(root, '.gstack'), { recursive: true });
|
||||
writeFileSync(join(root, '.gstack/update-snoozed'), '{new} 1 0\n');
|
||||
writeFileSync(join(root, '.gstack/update-snoozed'), '1.0.1 1 0\n');
|
||||
const block = skill(host, 'gstack-upgrade').match(/```bash\n((?:\[ -d "\$\{GSTACK_ROOT[^\n]*\n(?:GSTACK_BIN=[^\n]*\n)?)?(?:GSTACK_STATE_ROOT=\$\([^\n]*gstack-paths --get GSTACK_STATE_ROOT[^\n]*\n)?_SNOOZE_FILE=[\s\S]*?)```/)![1];
|
||||
// The block resolves the state root through the installed helper first.
|
||||
const bin = join(root, '.claude/skills/gstack/bin');
|
||||
mkdirSync(bin, { recursive: true });
|
||||
mkdirSync(join(dirname(bin), 'lib'), { recursive: true }); // C1: an exported GSTACK_ROOT needs bin/ and lib/
|
||||
for (const name of ['gstack-paths', 'gstack-state-root.sh']) writeFileSync(join(bin, name), readFileSync(join(import.meta.dir, '../bin', name)), { mode: 0o755 });
|
||||
expect(run(apply(block), { GSTACK_STATE_ROOT: join(root, '.gstack'), GSTACK_BIN: bin, GSTACK_ROOT: dirname(bin) }).status).toBe(0);
|
||||
expect(readFileSync(join(root, '.gstack/update-snoozed'), 'utf8')).toMatch(/^\{new\} 2 \d+\n$/);
|
||||
expect(run(apply(block).replace('{line}', 'UPGRADE_AVAILABLE 1.0.0 1.0.1'), { GSTACK_STATE_ROOT: join(root, '.gstack'), GSTACK_BIN: bin, GSTACK_ROOT: dirname(bin) }).status).toBe(0);
|
||||
expect(readFileSync(join(root, '.gstack/update-snoozed'), 'utf8')).toMatch(/^1\.0\.1 2 \d+\n$/);
|
||||
});
|
||||
test(`${label}: health error preserves its diagnostic argument`, () => {
|
||||
const helper = skill(host, 'health').match(/health_capture_error\(\) \{[\s\S]*?\n \}/)![0];
|
||||
|
||||
@@ -171,7 +171,8 @@ describe('equal VERSION, main moved past the checkout', () => {
|
||||
expect(run().stdout).toBe('UPGRADE_AVAILABLE 1.0.0 1.0.0+2 ' + short(next));
|
||||
});
|
||||
|
||||
test("gstack-upgrade's Not-now block, with the fourth field substituted for {new}, snoozes exactly that SHA", () => {
|
||||
// #4561: the block takes the whole line and derives the key itself, so an agent never picks the field by hand.
|
||||
test("gstack-upgrade's Not-now block, given the whole four-field line, snoozes exactly that SHA", () => {
|
||||
const local = head();
|
||||
const main = pushUpstream('c2');
|
||||
serveCompare(local, main, 'ahead', 1);
|
||||
@@ -180,14 +181,14 @@ describe('equal VERSION, main moved past the checkout', () => {
|
||||
expect(fields).toHaveLength(4);
|
||||
const skill = fs.readFileSync(path.join(ROOT, 'gstack-upgrade', 'SKILL.md'), 'utf8');
|
||||
const block = /```bash\n(GSTACK_STATE_ROOT=\$\(~\/\.claude\/skills\/gstack\/bin\/gstack-paths[^\n]*\n_SNOOZE_FILE=[\s\S]*?)```/.exec(skill)![1]!;
|
||||
expect(block).toContain('_REMOTE_VER="{new}"');
|
||||
expect(skill).toContain('On a four-field line use the SHA (fourth field) as `{new}`');
|
||||
expect(block).toContain('_UPGRADE_LINE="{line}"');
|
||||
expect(block).not.toContain('{new}');
|
||||
const bin = path.join(fx.root, '.claude', 'skills', 'gstack', 'bin');
|
||||
fs.mkdirSync(bin, { recursive: true });
|
||||
fs.mkdirSync(path.join(path.dirname(bin), 'lib'), { recursive: true });
|
||||
for (const name of ['gstack-paths', 'gstack-state-root.sh']) fs.copyFileSync(path.join(ROOT, 'bin', name), path.join(bin, name));
|
||||
for (const name of ['gstack-paths', 'gstack-state-root.sh']) fs.chmodSync(path.join(bin, name), 0o755);
|
||||
const r = spawnSync('bash', ['-c', block.replace('{new}', fields[3]!)], { encoding: 'utf8', timeout: 15_000, env: { ...process.env, HOME: fx.root, GSTACK_STATE_ROOT: fx.state, GSTACK_ROOT: path.dirname(bin) } });
|
||||
const r = spawnSync('bash', ['-c', block.replace('{line}', line.trim())], { encoding: 'utf8', timeout: 15_000, env: { ...process.env, HOME: fx.root, GSTACK_STATE_ROOT: fx.state, GSTACK_ROOT: path.dirname(bin) } });
|
||||
expect(r.status).toBe(0);
|
||||
expect(fs.readFileSync(path.join(fx.state, 'update-snoozed'), 'utf8')).toMatch(new RegExp('^' + short(main) + ' 1 \\d+\\n$'));
|
||||
expect(run().stdout).toBe('');
|
||||
|
||||
Reference in new issue
Block a user