mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-24 09:01:28 +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
+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; };
|
||||
|
||||
Reference in new issue
Block a user