mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-23 08:31:44 +01:00
Defaults name current models, and review stops reading "the HIGH branch" as a HIGH finding (GST-3462) (#4678)
Three defaults gstack picks now name current models, and a reviewer's mention of a code name like "the HIGH branch" no longer becomes a HIGH finding. Why: our rule is no older-generation model in a role we choose, and the review parser forced a ruling on two notes that only quoted code. Nothing to do: no settings change; overrides work as before. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> Review-Finding: p1/adversarial-native#1 reader=adversarial-native Review-Finding: p1/outside-voice#1 reader=outside-voice Review-Finding: p1/adversarial-native#5 reader=adversarial-native Review-Finding: p1/red-team#1 reader=red-team Review-Finding: p1/adversarial-native#6 reader=adversarial-native Review-Finding: p1/outside-voice#3 reader=outside-voice
This commit is contained in:
1 parent
24b15c6823
commit
8ffd2b85f1
9 files changed
+131
-19
No files matched your search
@@ -0,0 +1 @@
|
||||
**Defaults gstack picks for you now name current models, and /ship's review no longer reads a code name like "the HIGH branch" as a HIGH finding.** The design prototype script builds its request with the design binary's own helper, so it takes its models from the binary's one setting and stops with the binary's fix-it message on a model that cannot drive the image tool (it sent gpt-4o, which cannot). A Gemini run whose CLI reports no model is labelled and priced as Gemini 4 Argon instead of Gemini 2.5 Pro, and `gstack-context-bill --exact` counts tokens with Claude Opus 5.5 instead of Opus 4.5. In a reviewer's reply, a capitalized severity word that names something in the code ("the HIGH branch", "the MEDIUM and LOW tiers") collects at INFORMATIONAL, so the reviewer's own Severity fields decide; CRITICAL always keeps its label, even in "the HIGH and CRITICAL write paths".
|
||||
+3
-9
@@ -9,6 +9,7 @@
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import { openaiUrl } from "./src/auth";
|
||||
import { imageRequestBody } from "./src/models";
|
||||
import { receiptedFetch } from "./src/receipted-fetch";
|
||||
|
||||
const API_KEY = process.env.OPENAI_API_KEY;
|
||||
@@ -41,6 +42,7 @@ async function generateMockup(brief: { name: string; prompt: string }) {
|
||||
console.log(`Generating: ${brief.name}`);
|
||||
console.log(`${"=".repeat(60)}`);
|
||||
|
||||
const body = imageRequestBody(brief.prompt, { size: "1536x1024", quality: "high" });
|
||||
const startTime = Date.now();
|
||||
|
||||
const controller = new AbortController();
|
||||
@@ -52,15 +54,7 @@ async function generateMockup(brief: { name: string; prompt: string }) {
|
||||
"Authorization": `Bearer ${API_KEY}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
model: "gpt-4o",
|
||||
input: brief.prompt,
|
||||
tools: [{
|
||||
type: "image_generation",
|
||||
size: "1536x1024",
|
||||
quality: "high"
|
||||
}],
|
||||
}),
|
||||
body,
|
||||
signal: controller.signal,
|
||||
});
|
||||
clearTimeout(timeout);
|
||||
|
||||
@@ -1171,6 +1171,12 @@ ones, and the arm lost blockers. `bin/gstack-review-dispatch` closes both ends:
|
||||
field `Blocks: no` (colon required, and no `Blocks: yes`) is not counted as a blocker by the ledger count, nor by the
|
||||
review-log count or classify when the finding carries `stated` (GST-1031); lead judgment that raises such a line above
|
||||
its label counts it again.
|
||||
A capitalized HIGH, MEDIUM or LOW that names something in the code rather than rating a finding ("the HIGH branch",
|
||||
"the redact-doc HIGH and scanner-failure branches", "the MEDIUM and LOW tiers": after "the" and at most one qualifier,
|
||||
before a noun that is not a word for a finding or its rating) is a name, not a label (GSTA-711). A prose line with no
|
||||
`Severity` field whose every label is such a name collects at INFORMATIONAL, so the reviewer's own fields decide.
|
||||
CRITICAL never counts as a name, so "the HIGH and CRITICAL write paths" still collects at CRITICAL, and `Blocks: yes`
|
||||
still raises the line.
|
||||
A phantom finding costs a fold; a lost one costs the gate.
|
||||
A reply with no finding counts as a review only with the clean marker its own brief asks for: `NO FINDINGS` alone on a
|
||||
line for the specialists, the batched specialist, the targeted reader, the Red Team and fix-check, the `Recommendation:`
|
||||
|
||||
+5
-4
@@ -817,9 +817,10 @@ export function renderDiff(diff: { rows: DiffRow[]; grew: boolean }): string {
|
||||
return lines.join("\n") + "\n";
|
||||
}
|
||||
|
||||
// --exact defaults to the model the offline divisor was calibrated against, so
|
||||
// `--exact` and the estimate are comparable. Later tokenizers differ.
|
||||
export const EXACT_DEFAULT_MODEL = "claude-opus-4-5";
|
||||
// --exact defaults to the current model, so it counts what a session pays today.
|
||||
// The offline divisors were fitted on claude-opus-4-5's tokenizer; the
|
||||
// calibration block shows how far they sit from the current one.
|
||||
export const EXACT_DEFAULT_MODEL = "claude-opus-5-5";
|
||||
const COUNT_TOKENS_URL = "https://api.anthropic.com/v1/messages/count_tokens";
|
||||
const EXACT_CONCURRENCY = 8;
|
||||
|
||||
@@ -1219,7 +1220,7 @@ const USAGE =
|
||||
" `calibration` block grades the offline divisors\n" +
|
||||
" (TOKEN_DIVISORS) file by file against measured counts.\n" +
|
||||
" --exact-model <id> model whose tokenizer to count against\n" +
|
||||
` (default ${EXACT_DEFAULT_MODEL}, the calibration model).\n`;
|
||||
` (default ${EXACT_DEFAULT_MODEL}, the current model).\n`;
|
||||
|
||||
export interface MainOptions {
|
||||
cwd?: string;
|
||||
|
||||
+13
-1
@@ -59,6 +59,17 @@ const HEADING = /^(?:#{1,6}\s|\*\*[^*]+\*\*:?$)/;
|
||||
const LIST_ITEM = /^(?:[-*+]|\d+[.)])\s+\S/;
|
||||
/** A numbered finding heading ("**1. …**", "### 2) …", GST-1031) or a finding lead that names its number ("**Finding 1 (FIXABLE): …**", GST-1657). */
|
||||
const NUMBERED_HEAD = /^(?:#{1,6}\s+|\*\*\s*)(?:\d+[.)]\s|Finding\s+\d+\b)/;
|
||||
/**
|
||||
* A severity word that names something in the code under review rather than rating a finding (GSTA-711: "the redact-doc HIGH and
|
||||
* scanner-failure branches", "runs after the HIGH branch"): in capitals, as code spells a constant, after "the" and at most one
|
||||
* qualifier, and before a noun (after an optional "and X") that is not a word for a finding or its rating. CRITICAL never counts, so
|
||||
* "reaches the CRITICAL write path" and "the HIGH and CRITICAL write paths" still block until judged: X is a name only when it is
|
||||
* HIGH, MEDIUM or LOW. nameUses gives each such word's index; a line whose every label is one
|
||||
* collects at INFORMATIONAL, kept on record without a severity it never stated.
|
||||
*/
|
||||
const RATING_NOUN = '(?:findings?|fix(?:es)?|issues?|severity|severities|risks?|priority|impact|bugs?|defects?|problems?|concerns?|blockers?|items?|notes?|regressions?|ones?|levels?|rating|labels?|bar|floor|threshold|confidence|vulnerabilit(?:y|ies)|chances?|likelihood|probability|exposures?)';
|
||||
const NAME_USE = new RegExp(`(?<![A-Za-z0-9])[Tt]he\\s+(?:[\\w.\\x60-]+\\s+)?(HIGH|MEDIUM|LOW)(?:\\s+(?:and|or)\\s+(?:(HIGH|MEDIUM|LOW)|[\\w.\\x60-]+))?\\s+(?!${RATING_NOUN}(?![\\w-]))[a-z][\\w-]*`, 'dg');
|
||||
const nameUses = (t: string) => new Set([...t.matchAll(NAME_USE)].flatMap(m => [m.indices![1]![0], m.indices![2]?.[0] ?? -1]));
|
||||
const stronger = (a: string, b: string) => ((rank(a) ?? 0) >= (rank(b) ?? 0) ? a : b);
|
||||
/** A prose voice's `Blocks: yes` (GSTA-167 normalizer v2): the finding is CRITICAL whatever its label; `Blocks: no` never lowers one. */
|
||||
const BLOCKS_YES = /(?<![A-Za-z0-9])Blocks:?\**:?\s*\**\s*yes(?![A-Za-z0-9])/i;
|
||||
@@ -207,6 +218,7 @@ function parseLabelled(reader: string, output: string, fixableRaises: boolean):
|
||||
const named = (l: string) => (role === 'adversarial-native' && l.toUpperCase() === 'FIXABLE' ? 'CRITICAL' : l);
|
||||
const strongestOf = (labels: Array<string | undefined>) => labels.reduce<string | undefined>((a, b) => (a === undefined ? b : b === undefined ? a : stronger(a, b)), undefined);
|
||||
const strongest = (t: string) => strongestOf([...t.matchAll(ALL_LABELS)].map(m => named(m[1]!)));
|
||||
const namesOnly = (t: string) => { const at = nameUses(t); const ms = [...t.matchAll(ALL_LABELS)]; return ms.length > 0 && ms.every(m => at.has(m.index!)); };
|
||||
const fieldOf = (t: string) => { const ls = [...t.matchAll(SEVERITY_FIELD)].flatMap(m => (m[1] ?? m[2]!).match(FIELD_LABELS)!); return ls.length === 1 && (fixableRaises || role !== 'adversarial-native' || rank(ls[0]!)) ? ls[0] : undefined; };
|
||||
const critical = (t: string) => BLOCKS_YES.test(t) || (fixableRaises && role === 'adversarial-native' && /(?<![A-Za-z0-9])FIXABLE(?![A-Za-z0-9])/.test(t));
|
||||
const leadOf = (t: string) => { const l = LEAD_LABEL.exec(t)?.[1]; return l === undefined || !fixableRaises ? l : named(l); };
|
||||
@@ -216,7 +228,7 @@ function parseLabelled(reader: string, output: string, fixableRaises: boolean):
|
||||
const summary = continued ? undefined : closingSummary(led && !ANY_LABEL.test(led[1]!) ? led[2]! : t);
|
||||
if (summary) return strongestOf([...summary.labels.map(named), summary.prose ? 'INFORMATIONAL' : undefined]);
|
||||
const field = fieldOf(t);
|
||||
if (field === undefined) return strongest(t);
|
||||
if (field === undefined) return namesOnly(t) && !critical(t) ? 'INFORMATIONAL' : strongest(t);
|
||||
return critical(t) ? 'CRITICAL' : strongestOf([leadOf(t), field])!;
|
||||
};
|
||||
const push = (label: string, raw: string, fields: string[] = [], lead?: string): Finding => { const f = { label, raw, fields: new Set(fields), list: LIST_ITEM.test(raw), lead }; out.push(f); return f; };
|
||||
|
||||
@@ -591,7 +591,7 @@ describe("token estimate calibration", () => {
|
||||
expect(text).toContain("Bytes are always exact");
|
||||
const exactText = tokenDisclaimer({
|
||||
tokenEstimateErrorPct: 0,
|
||||
tokenSource: "count_tokens (claude-opus-4-5)",
|
||||
tokenSource: "count_tokens (claude-opus-5-5)",
|
||||
});
|
||||
expect(exactText).toContain("measured with count_tokens");
|
||||
expect(exactText).not.toContain("ESTIMATES");
|
||||
@@ -1397,7 +1397,7 @@ describe("--exact (opt-in measurement; offline here via an injected fetch)", ()
|
||||
});
|
||||
fs.rmSync(tmp, { recursive: true, force: true });
|
||||
expect(code).toBe(0);
|
||||
expect(JSON.parse(stdout.text()).tokenSource).toBe("count_tokens (claude-opus-4-5)");
|
||||
expect(JSON.parse(stdout.text()).tokenSource).toBe("count_tokens (claude-opus-5-5)");
|
||||
});
|
||||
|
||||
it("refuses a walked file swapped for a FIFO instead of hanging", () => {
|
||||
|
||||
@@ -75,6 +75,9 @@ export function parseGeminiStreamJson(raw: string): GeminiStreamParse {
|
||||
return { output, tokens: { input, output: out }, toolCalls, modelUsed };
|
||||
}
|
||||
|
||||
/** The model a run is labelled and priced as when the Gemini CLI reports none (its own default is not passed to us). */
|
||||
export const GEMINI_UNREPORTED_MODEL = 'gemini-4-argon';
|
||||
|
||||
/**
|
||||
* Map a raw stream-json dump to a RunResult, including the empty-success
|
||||
* hardening from #2159. Exported so adapter e2e can exercise the full
|
||||
@@ -85,7 +88,7 @@ export function resultFromGeminiStream(
|
||||
opts: { model?: string; durationMs?: number } = {},
|
||||
): RunResult {
|
||||
const parsed = parseGeminiStreamJson(raw);
|
||||
const modelUsed = parsed.modelUsed || opts.model || 'gemini-2.5-pro';
|
||||
const modelUsed = parsed.modelUsed || opts.model || GEMINI_UNREPORTED_MODEL;
|
||||
const durationMs = opts.durationMs ?? 0;
|
||||
if (!parsed.output.trim()) {
|
||||
return {
|
||||
@@ -180,7 +183,7 @@ export class GeminiAdapter implements ProviderAdapter {
|
||||
}
|
||||
|
||||
estimateCost(tokens: { input: number; output: number; cached?: number }, model?: string): number {
|
||||
return estimateCostUsd(tokens, model ?? 'gemini-2.5-pro');
|
||||
return estimateCostUsd(tokens, model ?? GEMINI_UNREPORTED_MODEL);
|
||||
}
|
||||
|
||||
private emptyResult(durationMs: number, error: RunResult['error'], model?: string): RunResult {
|
||||
@@ -189,7 +192,7 @@ export class GeminiAdapter implements ProviderAdapter {
|
||||
tokens: { input: 0, output: 0 },
|
||||
durationMs,
|
||||
toolCalls: 0,
|
||||
modelUsed: model ?? 'gemini-2.5-pro',
|
||||
modelUsed: model ?? GEMINI_UNREPORTED_MODEL,
|
||||
error,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* R116 (Garry, 2026-11-21): no gpt-4o or older-generation model in a role gstack chooses. These are the defaults the
|
||||
* eval-plan check cannot see because no preregistration names them: the design prototype's orchestrator, the Gemini
|
||||
* adapter's label for a run whose CLI reports no model, and context-bill's --exact model. A model counts as current when
|
||||
* lib/pricing.ts prices it and names no replacement (currentReplacement).
|
||||
*/
|
||||
import { describe, expect, test } from 'bun:test';
|
||||
import * as fs from 'node:fs';
|
||||
import * as path from 'node:path';
|
||||
import { EXACT_DEFAULT_MODEL } from '../lib/context-bill';
|
||||
import { currentReplacement, hasPricing } from '../lib/pricing';
|
||||
import { resultFromGeminiStream } from './helpers/providers/gemini';
|
||||
|
||||
const ROOT = path.resolve(import.meta.dir, '..');
|
||||
const current = (model: string) => [model, hasPricing(model), currentReplacement(model)];
|
||||
|
||||
describe('defaults gstack chooses are the current generation (R116)', () => {
|
||||
test('the design prototype builds its request with design/src/models.ts, never a literal such as gpt-4o', () => {
|
||||
const src = fs.readFileSync(path.join(ROOT, 'design', 'prototype.ts'), 'utf8');
|
||||
expect(src).toContain('imageRequestBody(brief.prompt');
|
||||
expect(src).not.toMatch(/gpt-4o|model:/);
|
||||
});
|
||||
|
||||
test('a Gemini run whose CLI reports no model is labelled and priced as a current model', () => {
|
||||
const label = resultFromGeminiStream('{"type":"message","role":"assistant","content":"PONG"}').modelUsed!;
|
||||
expect(current(label)).toEqual([label, true, null]);
|
||||
expect(resultFromGeminiStream('{"type":"init","model":"gemini-3.8-flash"}\n{"type":"message","role":"assistant","content":"PONG"}').modelUsed).toBe('gemini-3.8-flash');
|
||||
});
|
||||
|
||||
test('context-bill --exact counts with a current model', () => {
|
||||
expect(current(EXACT_DEFAULT_MODEL)).toEqual([EXACT_DEFAULT_MODEL, true, null]);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* A severity word that a reader uses as the name of something in the code under review is no severity (GSTA-711). On a /ship
|
||||
* review of #4612 the native adversarial reader wrote "In the redact-doc HIGH and scanner-failure branches" and "runs after the HIGH
|
||||
* branch" about redact-doc's HIGH exit path, and both lines collected as HIGH findings the lead could not lower, beside the reply's real
|
||||
* findings, which each state Severity: Medium or Low. Such a line now collects at INFORMATIONAL; a severity word that rates a finding
|
||||
* still collects as written.
|
||||
*/
|
||||
import { describe, expect, test } from 'bun:test';
|
||||
import { parseFindings } from '../lib/review-ledger';
|
||||
|
||||
const CAPTURED_4612_NATIVE = [
|
||||
'REVIEWED_TREE: e92bbfcdb1cd8727b991a3800c2e21f094f50d4c /workspace/gstack',
|
||||
'REVIEW_VERDICT: blocking=0',
|
||||
'',
|
||||
'I found nothing that blocks the merge.',
|
||||
'',
|
||||
'**What I reviewed and checked**',
|
||||
'- Every unforced `rm` on a required file follows a guard that proves the file exists:',
|
||||
' - In the redact-doc HIGH and scanner-failure branches, `[ -s "$REDACT_FILE" ]` runs before the scan, so exit codes 3 and 1 are kept.',
|
||||
' - The brief, feedback and prompt files are all checked with `-s` first.',
|
||||
'',
|
||||
'**Findings**',
|
||||
'',
|
||||
'1. `gstack-upgrade/SKILL.md.tmpl:280`: the vendored-sync removal now hides every failure. FIXABLE. Severity: Medium. Blocks: no.',
|
||||
'',
|
||||
'3. Unforced `rm` on files that may already be gone now prints errors. Three cases:',
|
||||
' - The redact-doc cleanup at `scripts/resolvers/redact-doc.ts:112` runs after the HIGH branch has already removed `REDACT_FILE`.',
|
||||
'',
|
||||
' No data or exit gate depends on these lines. FIXABLE: add `2>/dev/null || true`. Severity: Low. Blocks: no.',
|
||||
].join('\n');
|
||||
|
||||
const label = (line: string) => parseFindings('red-team', line).map(f => f.label);
|
||||
|
||||
describe('a severity word naming code is no severity (GSTA-711)', () => {
|
||||
test('the captured #4612 reply: the two lines quoting the HIGH branch collect at INFORMATIONAL, the real findings at their fields', () => {
|
||||
expect(parseFindings('adversarial-native', CAPTURED_4612_NATIVE).map(f => [f.label, f.raw.slice(0, 30)])).toEqual([
|
||||
['INFORMATIONAL', '- In the redact-doc HIGH and s'],
|
||||
['Medium', '1. `gstack-upgrade/SKILL.md.tm'],
|
||||
['INFORMATIONAL', '- The redact-doc cleanup at `s'],
|
||||
['Low', 'No data or exit gate depends o'],
|
||||
]);
|
||||
});
|
||||
|
||||
test('negative controls: CRITICAL, and a severity word that rates a finding, leads, stands apart or is spelled as prose, keep their label', () => {
|
||||
for (const [line, want] of [
|
||||
['- the HIGH finding above still stands', ['HIGH']],
|
||||
['- HIGH: the auth check is skipped at auth.ts:9', ['HIGH']],
|
||||
['- The HIGH branch drops the token check, so this is HIGH.', ['HIGH']],
|
||||
['- the CRITICAL fix is covered by the new test', ['CRITICAL']],
|
||||
['- Unauthenticated input reaches the CRITICAL write path.', ['CRITICAL']],
|
||||
['- the LOW risk path is fine', ['LOW']],
|
||||
['- the High branch drops the token check', ['High']],
|
||||
['- the HIGH branch drops the token check. Blocks: yes', ['CRITICAL']],
|
||||
['- the MEDIUM and LOW tiers both skip the check', ['INFORMATIONAL']],
|
||||
['- the HIGH and CRITICAL write paths drop the auth check (store.ts:40)', ['CRITICAL']],
|
||||
['- the HIGH and P0 paths skip validation at store.ts:40', ['P0']],
|
||||
['- The HIGH and CRITICAL vulnerabilities remain unresolved', ['CRITICAL']],
|
||||
['- the HIGH vulnerability in auth.ts:9 is still open', ['HIGH']],
|
||||
['- There is the HIGH chance of a torn write that loses data at store.ts:40', ['HIGH']],
|
||||
] as const) expect([line, label(line)]).toEqual([line, [...want]]);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user