fix: pre-landing review fixes

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
garrytanandcapy-ai[bot] committed 2026-10-31 01:25:38 +00:00
1 parent 990ba7bee8
commit 1a8a62cb10
8 files changed
+42 -8

No files matched your search

+7
View File
@@ -61,6 +61,13 @@ describe('gstack-model-benchmark --dry-run', () => {
expect(r.stdout).not.toContain('gpt-42-fake');
});
test('a --models list with no valid provider is an error, never a claude run', () => {
const r = run(['--prompt', 'hi', '--models', 'Particle', '--dry-run']);
expect(r.status).toBe(1);
expect(r.stderr).toContain("No valid provider in --models 'Particle'");
expect(r.stdout).not.toContain('providers: claude');
});
test('empty --models list falls back to claude default', () => {
const r = run(['--prompt', 'hi', '--models', '', '--dry-run']);
expect(r.status).toBe(0);
+12 -1
View File
@@ -4,6 +4,7 @@ import * as os from 'os';
import * as path from 'path';
import { GatewayAdapter, GATEWAY_MODELS, gatewayEnvironment, foreignModels } from './helpers/providers/gateway';
import { PROVIDER_NAMES, isProviderName } from './helpers/providers/registry';
import { PANEL_ARMS, cellCostUsd } from './helpers/model-panel-harness';
import { familyConflict, modelFamily } from '../lib/outside-voice-runner';
import { estimateCostUsd, hasPricing } from '../lib/pricing';
@@ -23,6 +24,7 @@ function fakeClaude(): string {
fs.writeFileSync(script, [
"const fs = require('fs');",
"fs.writeFileSync(process.env.FAKE_ENV_OUT, Object.entries(process.env).map(([k, v]) => k + '=' + v).join('\\n') + '\\n');",
"if (process.env.FAKE_ERROR) { process.stdout.write(JSON.stringify({ type: 'result', subtype: 'error_during_execution', is_error: true, result: '' })); process.exit(0); }",
"const modelUsage = JSON.parse('{' + (process.env.FAKE_MODELS || '') + '}');",
"process.stdout.write(JSON.stringify({ type: 'result', subtype: 'success', is_error: false, result: 'ok', num_turns: 2, usage: { input_tokens: 1000, output_tokens: 10, cache_read_input_tokens: 50, cache_creation_input_tokens: 7 }, modelUsage }));",
].join('\n') + '\n');
@@ -56,7 +58,9 @@ describe('gateway provider', () => {
const childEnv = fs.readFileSync(envOut, 'utf-8');
expect(childEnv).not.toContain('sk-ant-real');
expect(childEnv).toContain('ANTHROPIC_AUTH_TOKEN=sk-or');
expect(adapter.estimateCost(result.tokens, result.modelUsed)).toBe(+((1000 * 0.25 + 10 * 1.0 + 50 * 0.03) / 1e6).toFixed(6));
expect(adapter.estimateCost(result.tokens, result.modelUsed)).toBeCloseTo((1000 * 0.25 + 10 * 1.0 + 50 * 0.03 + 7 * 0.25) / 1e6, 5);
const particleArm = PANEL_ARMS.find(a => a.id === 'particle')!;
expect(adapter.estimateCost(result.tokens, result.modelUsed)).toBe(cellCostUsd(particleArm, { input: 1000, output: 10, cached: 50, cacheWrite: 7, modelsBilled: [], isError: false, apiErrorStatus: null, turns: 2 }));
});
test('a run that billed another model is a MODEL_MIX error, not a result', async () => {
@@ -67,6 +71,13 @@ describe('gateway provider', () => {
expect(foreignModels('particle-ai/particle-1', ['particle-1', 'PARTICLE-AI/particle-1'])).toEqual([]);
});
test('an error envelope from the gateway is an error, not a benchmark result', async () => {
process.env.GSTACK_CLAUDE_BIN = fakeClaude();
const adapter = new GatewayAdapter('particle', { PATH: process.env.PATH, HOME: tmp, OPENROUTER_API_KEY: 'sk-or', FAKE_ENV_OUT: path.join(tmp, 'env-err.txt'), FAKE_ERROR: '1' });
const result = await adapter.run({ prompt: 'hi', workdir: tmp, timeoutMs: 10_000 });
expect(result.error?.reason).toMatch(/empty or invalid output/);
});
test('available() names the missing key with a fix', async () => {
process.env.GSTACK_CLAUDE_BIN = fakeClaude();
const check = await new GatewayAdapter('particle', { PATH: process.env.PATH }).available();
+3 -2
View File
@@ -185,8 +185,9 @@ export type CellVerdict = 'pass' | 'fail' | 'infra';
* INFRA cells are excluded from pass rates, reported, and never rerun to
* change a verdict: no result event, a CLI or API error before the model
* produced a turn, a 402/429/5xx from the API, a startup timeout, or a run
* that billed any model besides the arm's (MODEL_MIX). Everything else is
* scored by the hidden check, including a run that timed out after working.
* that billed any model besides the arm's (MODEL_MIX). A CLI killed at the
* timeout writes no result event, so it is INFRA too. Everything else is
* scored by the hidden check.
*/
export function classifyCell(arm: PanelArm, exitReason: string, usage: CellUsage | null): { verdict: 'infra'; reason: string } | { verdict: 'scored' } {
if (exitReason === 'timeout_startup') return { verdict: 'infra', reason: 'startup timeout' };
+4
View File
@@ -19,6 +19,10 @@ export const PERIODIC_CI_EXCLUDE: Record<string, { reason: string; tracking: str
reason: 'needs macOS with the Aside app open (asideAvailable()); CI runners are Linux, so every case self-skips',
tracking: 'TODOS.md "CI-unrunnable paid evals" (re-entry: the CLI/device is available in the CI image; review by 2026-12-28)',
},
'test/skill-e2e-model-panel.test.ts': {
reason: 'needs OPENROUTER_API_KEY, which no CI workflow carries; a preregistered research instrument run on demand, not weekly coverage',
tracking: 'TODOS.md "CI-unrunnable paid evals" (re-entry: OPENROUTER_API_KEY in the periodic slice env and a new preregistration; review by 2026-12-28)',
},
'test/skill-e2e-ios-device.test.ts': {
reason: 'needs a physical iPhone over USB/devicectl — manual hardware, not a CI runner capability',
tracking: 'TODOS.md "CI-unrunnable paid evals" (re-entry: the CLI/device is available in the CI image; review by 2026-12-28)',
+7 -4
View File
@@ -1,6 +1,6 @@
import { ClaudeAdapter, claudeExecEnvironment } from './claude';
import type { AvailabilityCheck, ProviderAdapter, RunOpts, RunResult } from './types';
import { estimateCostUsd } from '../pricing';
import type { AvailabilityCheck, ProviderAdapter, RunOpts, RunResult, TokenUsage } from './types';
import { estimateCostUsd, pricingRow } from '../pricing';
import { resolveClaudeCommand } from '../../../lib/claude-bin';
/**
@@ -93,7 +93,10 @@ export class GatewayAdapter implements ProviderAdapter {
return result;
}
estimateCost(tokens: { input: number; output: number; cached?: number }, model?: string): number {
return estimateCostUsd(tokens, model ?? this.model);
/** Cache writes are billed at the input rate: the gateway's providers publish no separate write price (as the model panel prices them). */
estimateCost(tokens: TokenUsage, model?: string): number {
const id = model ?? this.model;
const writeRate = pricingRow(id)?.input_per_mtok ?? 0;
return +(estimateCostUsd(tokens, id) + (tokens.cacheWrite ?? 0) * writeRate / 1_000_000).toFixed(6);
}
}