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
10 changes: 10 additions & 0 deletions src/trace-analyst/behavioral-metrics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,16 @@ describe('computeTraceMetrics — deterministic behavioral signals (no LLM)', ()
expect(m.signals.map((s) => s.code)).not.toContain('no-self-verification')
})

it('counts real read/inspect tool names (Read/Grep) as self-verification', () => {
for (const tool of ['Read', 'Grep', 'read_file', 'git.status']) {
const spans = fixture530()
spans.push(toolSpan(8, tool))
const m = computeTraceMetrics(spans)
expect(m.hasSelfVerification).toBe(true)
expect(m.signals.map((s) => s.code)).not.toContain('no-self-verification')
}
})

it('FIRES monotonic-input-growth on a 0→huge blowup (first call reported 0 input tokens)', () => {
// First LLM call reports 0 input tokens, then context explodes. Ratio is
// unbounded — the old `first > 0 ? last/first : 0` forced growth to 0 and
Expand Down
9 changes: 7 additions & 2 deletions src/trace-analyst/behavioral-metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,13 @@ export interface BehavioralMetrics {
const INPUT_GROWTH_FACTOR = 3
/** Tool-usage signals need at least this many calls to be meaningful. */
const MIN_TOOL_CALLS = 3
/** Tool names matching this are self-verification, not state mutation. */
const VERIFY_RE = /verif|eval|inspect|check|assert|validat|review|confirm/i
/** Tool names that read or check state count as self-verification, not mutation.
* Covers the inspect verbs plus the read/search tools real harnesses use to
* verify (Claude Code Read/Grep/Glob, codex read_file/ls/cat, git status/diff,
* test/lint). A pure shell tool (Bash/exec_command) is intentionally NOT matched
* — its name can't tell a `pytest` from an `rm`. */
const VERIFY_RE =
/verif|eval|inspect|check|assert|validat|review|confirm|read|grep|glob|search|view|\blist\b|\bls\b|\bcat\b|\bfind\b|diff|status|\btest|lint|typecheck/i

function num(v: unknown): number | null {
return typeof v === 'number' && Number.isFinite(v) ? v : null
Expand Down
Loading