Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .changeset/37593-ask-round-nothing-measured-exit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
'@objectstack/scenarios': patch
---

fix(scenarios): `run-scenarios` exits 3 when a card's ask mode asked none of its planned turns

Clause-②: yes (widening)
Metadata-protocol: none

A round whose ask host app never became ready (`objectstack dev exited before it was ready`), whose build was not installed, or whose every turn failed before the driver ran it used to exit 0, so a round that measured nothing read as a clean one until someone opened the scorecard. The command now exits **3** when any card's ask mode asked 0 of its planned question, dataset-question and operation turns, and prints one `nothing measured: <card>: ask mode asked 0 of N planned turns — <reason>` line per such card. 3 stands apart from 1 (a thrown error) and 2 (a refused argument), as `skill-evals` exits 3 when its quota stop leaves turns not run.

New exports on the `./runner` entry: `askPhaseNotRun(card, run)` (why a card's ask mode measured nothing, or `undefined`), `NOTHING_MEASURED_EXIT` (3) and `NO_VERIFIED_BUILD` (the existing skip text, now named; its bytes are unchanged).

Every run record is written exactly as before; nothing is added to it. Only ask mode counts: scratch, template and door modes run an authoring turn first, whose Build half is a measurement however the rest goes, and an ask mode skipped because the same run's scratch build was measured and did not pass leaves that build's fail as the round's result. A scratch mode that measured no Build half (a scaffold or namespace skip, an authoring turn that did not finish) leaves the round with nothing measured, so it exits 3. `gallery-refresh` runs scratch mode only, so its exit is unchanged.
9 changes: 9 additions & 0 deletions packages/qa/scenarios/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,15 @@ pnpm --filter @objectstack/scenarios run-scenarios --modes door --door-rules bui
Per card and mode the runner writes `docs/qa/platform-checklist/runs/<date>-scenario-<card>.json`
(git-ignored) and prints the scorecard.

**Exit code.** 2 when an argument is refused or no card is left to run; 1 on a thrown
error. **3** when a card's ask mode measured nothing: it planned question, dataset-question and operation turns and
asked none of them — its host app never became ready, its build was not installed, or no turn reached the driver.
Otherwise 0. Every record is still written, and the runner prints one `nothing measured: …` line per such card. Only ask mode
counts: every other mode runs an authoring turn first, and an ask mode skipped because this run's scratch build was
measured and did not pass leaves that build's fail as the result (a scratch mode that measured no Build half — a
scaffold or namespace skip, an authoring turn that did not finish — does not). A wrapper (the daily ask round, a keep/drop round) reads 3 as "this
round measured nothing", apart from a crash, as `skill-evals` exits 3 when its quota stop left turns not run.

### Many runs in one table — `summary`

```bash
Expand Down
18 changes: 17 additions & 1 deletion packages/qa/scenarios/src/runner/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@
* run records back instead and prints one author-model × ask-model table per
* card and mode (`summary.ts`; its own flags, `--card` and `--mode`).
*
* Exit codes: 2 a refused argument, or no card to run; 1 a
* thrown error; 3 (`NOTHING_MEASURED_EXIT`) a card's ask mode asked none of its
* planned turns (`askPhaseNotRun`: the host never became ready, the build was
* not installed, no turn reached the driver); otherwise 0. Every record is
* still written either way.
*
* ⛔ No API-billed model: the live driver refuses to start when an API key is
* configured (the cost ruling on cloud#3600).
*/
Expand All @@ -156,7 +162,7 @@ import { ClaudeCodeDriver, RecordedDriver, RecordingDriver, type AgentDriver } f
import { CodexDriver } from './drivers/codex.js';
import { ExternalDriver } from './drivers/external.js';
import { CAPABILITY_AREAS_DIR, locateLibraryRoot } from './library.js';
import { askModeRefusal, minutesText, runCard, type CardRun, type ProjectOps } from './orchestrate.js';
import { askModeRefusal, askPhaseNotRun, minutesText, NOTHING_MEASURED_EXIT, runCard, type CardRun, type ProjectOps } from './orchestrate.js';
import { installedSpecVersion, PACKAGES_MODES, prepareWorkspacePackages, settleWorkspaceProject, workspaceScaffolder, type PackageSource, type PackagesMode } from './packages.js';
import { bootDev, os, readArtifact, readNamespace, scaffold } from './project.js';
import { PROMPT_LANGS, PROMPT_LENGTHS, promptChoiceText, promptLanguageRefusal, statedPromptChoice, type PromptChoice, type PromptLang, type PromptLength } from './prompts.js';
Expand Down Expand Up @@ -637,6 +643,8 @@ export async function main(argv: readonly string[]): Promise<number> {
/* not a checkout */
}
const date = new Date().toISOString().slice(0, 10);
/** Each card whose ask mode asked none of its planned turns (`askPhaseNotRun`): the round exits apart from a clean one. */
const notRun: string[] = [];

for (const loaded of chosen) {
// The card's dates move onto the day this card starts, so its "today", its
Expand All @@ -661,6 +669,14 @@ export async function main(argv: readonly string[]): Promise<number> {
console.log(renderScorecard(cardScorecard(cardRun, packages, card)));
console.log(`record: ${file}`);
if (driver instanceof RecordingDriver && args.record) driver.save(args.record);
const nothing = askPhaseNotRun(scenario.card, cardRun);
if (nothing) notRun.push(nothing);
}
// A round that measured nothing on a card is not a clean exit: its records are written, and it exits apart from a crash (#37593).
if (notRun.length) {
for (const line of notRun) console.error(`nothing measured: ${line}`);
console.error(`exit ${NOTHING_MEASURED_EXIT}: ${notRun.length} of ${chosen.length} card(s) measured nothing in ask mode; every record is written`);
return NOTHING_MEASURED_EXIT;
}
return 0;
}
Expand Down
50 changes: 49 additions & 1 deletion packages/qa/scenarios/src/runner/orchestrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2157,6 +2157,13 @@ interface VerifiedBuild {
* another manifest installed in its place (template mode's iterated app,
* {@link iteratedManifest}); `manifest` is the one the run's install sent.
*/
/**
* Why a template or ask mode installs nothing: this run's from-scratch build
* did not pass and no template was supplied. That build's own Build half is
* the run's measurement of it ({@link askPhaseNotRun} reads this skip so).
*/
export const NO_VERIFIED_BUILD = 'no verified build of this card to install: the from-scratch build did not pass and no template was supplied';

async function withInstalledBuild(
original: LoadedScenario,
ops: ProjectOps,
Expand All @@ -2171,7 +2178,7 @@ async function withInstalledBuild(
// The installed copy keeps the TEMPLATE's namespace, which must be the card's own.
const ns = scenarioNamespace(original.card);
if (!verified) {
mode.skipped = 'no verified build of this card to install: the from-scratch build did not pass and no template was supplied';
mode.skipped = NO_VERIFIED_BUILD;
return;
}
const templateNs = namespaceOfArtifact(verified.artifact);
Expand Down Expand Up @@ -2435,6 +2442,47 @@ export function askModeRefusal(modes: ReadonlyArray<ModeRun['mode']>, templateSu
return 'ask mode runs the questions and operations on a verified build and authors none: give it one with --template F, or run scratch mode with it (--modes scratch,ask), whose build it installs when that build passes';
}

/**
* Why a card's ask mode measured nothing, or `undefined` when it measured
* something or had nothing to measure: the mode planned question, dataset
* question and operation turns (the card's, each question turn as many times
* as {@link CardRun.askRepeats}) and asked none of them — its host app never
* became ready, its build was not installed, or every turn failed before the
* driver ran it. Read off the record as written (`counts`, each result's
* `turn`), which it leaves as it is. Ask mode alone: every other mode runs an
* authoring turn first, whose Build half is a measurement however the rest
* goes; and an ask mode skipped because this run's scratch build did not pass
* ({@link NO_VERIFIED_BUILD}) leaves that build's fail as the run's result —
* when that Build half was measured. A scratch mode that measured no Build half
* (its scaffold or namespace skipped it, or its authoring turn did not finish)
* leaves the ask mode's 0 of N as the round's whole reading.
* The CLI exits {@link NOTHING_MEASURED_EXIT} on one (#37593).
*/
export function askPhaseNotRun(card: Pick<Card, 'run'>, run: CardRun): string | undefined {
const mode = run.modes.find((m) => m.mode === 'ask');
if (!mode) return undefined;
// This run's scratch build did not pass: its measured Build half is the result. One that was never measured (a
// scaffold or namespace skip, an authoring turn that did not finish) leaves the round with nothing measured.
const scratch = run.modes.find((m) => m.mode === 'scratch');
if (mode.skipped === NO_VERIFIED_BUILD && scratch?.build !== undefined && scratch.build.notMeasured === undefined && scratch.skipped === undefined) return undefined;
const repeats = run.askRepeats ?? 1;
const planned = (run.counts.questionTurns + (card.run.datasetQuestions?.length ?? 0)) * repeats + run.counts.operations;
if (planned === 0) return undefined;
const half = mode.run;
const asked = half ? [...half.questions, ...(half.datasetQuestions ?? []), ...half.operations].filter((r) => r.turn !== undefined).length : 0;
if (asked > 0) return undefined;
const why = mode.skipped ?? half?.error ?? (half ? 'no turn reached the driver' : (mode.findings[0]?.split('\n')[0] ?? 'the host app never became ready'));
return `${run.card}: ask mode asked 0 of ${planned} planned turns — ${why}`;
}

/**
* The exit code of a `run-scenarios` round in which a card's ask mode measured
* nothing ({@link askPhaseNotRun}): apart from 1 (a thrown error) and 2 (a
* refused argument), as `skill-evals` exits 3 when its quota stop left turns
* not run. Every record is still written.
*/
export const NOTHING_MEASURED_EXIT = 3;

/** Run one card in the requested modes. */
export async function runCard(scenario: LoadedScenario, driver: AgentDriver, ops: ProjectOps, opts: RunOptions): Promise<CardRun> {
const { card } = scenario;
Expand Down
106 changes: 105 additions & 1 deletion packages/qa/scenarios/test/runner/orchestrate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { exportGallery } from '../../src/export/exporter.js';
import { writeRecord as writeGalleryRecord } from '../export/fixture.js';
import { loadedCardStamp, main as runScenarios, makeDriver, parseArgs, promptChoiceOf } from '../../src/runner/cli.js';
import { citationLabels, namespacedScenario } from '../../src/runner/namespace.js';
import { askModeRefusal, buildPassed, doorHarnessGap, confirmationAmbiguous, confirmationNotRecorded, hiddenValues, readRollupSourceFinding, restoreObjects, restoreSeededRows, rollupSourceCharges, runCard, runHalf, seededRows, seedApp, type CardRun, type OperationResult, type ProjectOps, type QuestionResult } from '../../src/runner/orchestrate.js';
import { askModeRefusal, askPhaseNotRun, buildPassed, NO_VERIFIED_BUILD, NOTHING_MEASURED_EXIT, doorHarnessGap, confirmationAmbiguous, confirmationNotRecorded, hiddenValues, readRollupSourceFinding, restoreObjects, restoreSeededRows, rollupSourceCharges, runCard, runHalf, seededRows, seedApp, type CardRun, type OperationResult, type ProjectOps, type QuestionResult } from '../../src/runner/orchestrate.js';
import { derivedFields, RESTORE_UNCOMPARED, rollupFields, rowDrift } from '../../src/runner/seed.js';
import { askCostText, askSpend, askTimeText, buildDenialFindings, cardScorecard, cardStampOf, confirmationTally, datasetTally, confirmedWriteTally, elapsedText, guardrailTally, kindCell, kindTally, modelTally, opsTally, renderScorecard, repeatTally, runRecord, type AskSpend } from '../../src/runner/scorecard.js';
import { askKindCounts } from '../../src/ask-kinds.js';
Expand Down Expand Up @@ -3163,6 +3163,110 @@ describe('runCard — `--modes ask` runs only the questions and operations on a
});
});

// ── A round that measured nothing (#37593) ─────────────────────────────────

describe('askPhaseNotRun — an ask mode that asked none of its planned turns is told apart from a clean one, and the record is written as before (#37593)', () => {
// The crm card: 16 question turns and 6 operations, no dataset questions.
const PLANNED = 22;
const card = () => load().card;
const meta = (driver: AgentDriver) => ({ run: 'r', date: '2026-11-28', packages: PUBLISHED, driver: driver.info(), runner: 'test', evidenceDir: '/tmp' });

it('the exit code is its own: neither a thrown error (1) nor a refused argument (2)', () => {
expect(NOTHING_MEASURED_EXIT).toBe(3);
});

it('a host app that never became ready: 0 of 22 asked, the boot failure named, and the record holds its rows as before', async () => {
const { scenario, ops, driver } = setup();
ops.boot = async () => {
throw new Error('objectstack dev exited before it was ready:\npackage targets protocol ^18 … this runtime is protocol 19.0.0');
};
const run = await runCard(scenario, driver, ops, { modes: ['ask'], admin: ADMIN, templateArtifact: artifact() });
expect(driver.seen).toEqual([]);
expect(askPhaseNotRun(card(), run)).toBe(`crm_account_with_contacts: ask mode asked 0 of ${PLANNED} planned turns — boot/run: objectstack dev exited before it was ready:`);
// The record is the one it always was: every half not-run, nothing added for the exit.
const record = runRecord(meta(driver), run);
expect(Object.keys(record)).toEqual(['run', 'date', 'scope', 'app', 'env', 'runner', 'evidenceDir', 'results', 'scorecard', 'cardRun']);
const results = record.results as Array<{ id: string; verdict: string }>;
expect(results.filter((r) => r.id.includes('.run-')).map((r) => r.verdict)).toEqual(['not-run', 'not-run']);
});

it('a clean ask round measured something: nothing to tell', async () => {
const { scenario, ops, driver } = setup();
const run = await runCard(scenario, driver, ops, { modes: ['ask'], admin: ADMIN, templateArtifact: artifact() });
expect(run.modes[0]!.run!.questions.every((q) => q.turn !== undefined)).toBe(true);
expect(askPhaseNotRun(card(), run)).toBeUndefined();
});

it('every turn failing before the driver ran it is nothing measured too; one turn asked is not', async () => {
const { scenario, ops, driver } = setup();
const dead: AgentDriver = Object.assign(Object.create(driver) as AgentDriver, {
ask: async () => {
throw new Error('spawn claude ENOENT');
},
});
const run = await runCard(scenario, dead, ops, { modes: ['ask'], admin: ADMIN, templateArtifact: artifact() });
expect(run.modes[0]!.run!.questions.map((q) => q.error)).toEqual(run.modes[0]!.run!.questions.map(() => 'spawn claude ENOENT'));
expect(askPhaseNotRun(card(), run)).toBe(`crm_account_with_contacts: ask mode asked 0 of ${PLANNED} planned turns — no turn reached the driver`);

const one = setup();
let asked = 0;
const once: AgentDriver = Object.assign(Object.create(one.driver) as AgentDriver, {
ask: async (task: AskTask) => {
if (asked++ > 0) throw new Error('spawn claude ENOENT');
return one.driver.ask(task);
},
});
const partial = await runCard(one.scenario, once, one.ops, { modes: ['ask'], admin: ADMIN, templateArtifact: artifact() });
expect(askPhaseNotRun(card(), partial)).toBeUndefined();
});

it('a skipped or refused install names its reason; repeats count in the planned turns', async () => {
const elsewhere = setup();
const other = await runCard(elsewhere.scenario, elsewhere.driver, elsewhere.ops, { modes: ['ask'], admin: ADMIN, templateArtifact: artifact({ ns: 'democrx' }), askRepeats: 2 });
expect(askPhaseNotRun(card(), other)).toBe(`crm_account_with_contacts: ask mode asked 0 of 38 planned turns — the template declares namespace \`democrx\`, not the card's \`democrm\`: its names would not be the card's`);

class RefusingInstall extends FakeApp {
override installAnswer: HttpAnswer = { ok: false, status: 409, body: {}, code: 'UNCOPYABLE', message: 'the build carries a managed item' };
}
const refused = setup({ app: () => new RefusingInstall() });
const r = await runCard(refused.scenario, refused.driver, refused.ops, { modes: ['ask'], admin: ADMIN, templateArtifact: artifact() });
expect(askPhaseNotRun(card(), r)).toBe(`crm_account_with_contacts: ask mode asked 0 of ${PLANNED} planned turns — unmanaged install refused: 409 UNCOPYABLE the build carries a managed item`);
});

it('a scratch build that was measured and did not pass is that run\'s result, not nothing measured; one never measured is; a run without ask mode is never told', async () => {
const degraded = setup({ degradedBuild: true });
const run = await runCard(degraded.scenario, degraded.driver, degraded.ops, { modes: ['scratch', 'ask'], admin: ADMIN });
expect(run.modes[1]!.skipped).toBe(NO_VERIFIED_BUILD);
expect(askPhaseNotRun(card(), run)).toBeUndefined();

// A scratch mode that measured no Build half is no result to stand on: the round measured nothing (review F2).
const killed = setup({ authorAs: { 'scratch/build': KILLED } });
const unmeasured = await runCard(killed.scenario, killed.driver, killed.ops, { modes: ['scratch', 'ask'], admin: ADMIN });
expect([unmeasured.modes[0]!.build!.notMeasured !== undefined, unmeasured.modes[1]!.skipped]).toEqual([true, NO_VERIFIED_BUILD]);
expect(askPhaseNotRun(card(), unmeasured)).toBe(`crm_account_with_contacts: ask mode asked 0 of ${PLANNED} planned turns — ${NO_VERIFIED_BUILD}`);
const noScaffold = setup();
noScaffold.ops.scaffold = async (name, under) => ({ dir: `${under}/${name}`, result: { command: `create-objectstack ${name}`, exit: 1, tail: 'npm ERR! 404', ms: 1 } });
const skipped = await runCard(noScaffold.scenario, noScaffold.driver, noScaffold.ops, { modes: ['scratch', 'ask'], admin: ADMIN });
expect([skipped.modes[0]!.skipped, skipped.modes[1]!.skipped]).toEqual(['scaffold failed: npm ERR! 404', NO_VERIFIED_BUILD]);
expect(askPhaseNotRun(card(), skipped)).toBe(`crm_account_with_contacts: ask mode asked 0 of ${PLANNED} planned turns — ${NO_VERIFIED_BUILD}`);

const scratchOnly = setup();
scratchOnly.ops.boot = async () => {
throw new Error('objectstack dev exited before it was ready');
};
const s = await runCard(scratchOnly.scenario, scratchOnly.driver, scratchOnly.ops, { modes: ['scratch'], admin: ADMIN });
expect(askPhaseNotRun(card(), s)).toBeUndefined();
});

it('dataset questions count in the planned turns, each as many times as the repeats', () => {
const base = load().card;
const withDatasets = { run: { ...base.run, datasetQuestions: [{}, {}] as unknown as NonNullable<typeof base.run.datasetQuestions> } };
const run: CardRun = { card: 'c', title: base.title, capabilities: [], counts: { questions: 1, questionTurns: 3, operations: 2, personas: 1 }, askRepeats: 2, modes: [{ mode: 'ask', findings: [] }] };
expect(askPhaseNotRun(withDatasets, run)).toBe('c: ask mode asked 0 of 12 planned turns — the host app never became ready');
expect(askPhaseNotRun({ run: { ...base.run, datasetQuestions: [] } }, { ...run, counts: { questions: 0, questionTurns: 0, operations: 0, personas: 0 } })).toBeUndefined();
});
});

// ── Ask mode's managed fallback ─────────────────────────────────────────────

describe('runCard — ask mode installs a build the unmanaged door refuses UNMANAGED_INSTALL_UNCOPYABLE managed instead, and records the mode (#34687)', () => {
Expand Down
Loading