Skip to content

Commit d74ade1

Browse files
tmchowclaude
andcommitted
fix(gain): match full command for retry detection
Partition the LAG window by the full original_cmd instead of just the base command name. The previous approach grouped all invocations of a bare command (e.g. every `ls`) into one partition, so any pair within 60 s was counted as a retry -- producing 99 %+ false-positive rates on high-frequency commands. Matching the full command string means only identical commands re-run within 60 s are flagged, which is what "retry" actually means. Reported-by: @aeppling in PR #900 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 928a4a2 commit d74ade1

1 file changed

Lines changed: 1 addition & 15 deletions

File tree

src/core/tracking.rs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -499,21 +499,7 @@ impl Tracker {
499499
END AS base_cmd,
500500
timestamp,
501501
LAG(timestamp) OVER (
502-
PARTITION BY
503-
CASE
504-
WHEN original_cmd LIKE 'git %' THEN
505-
CASE
506-
WHEN instr(substr(original_cmd, 5), ' ') > 0
507-
THEN substr(original_cmd, 1, instr(substr(original_cmd, 5), ' ') + 3)
508-
ELSE original_cmd
509-
END
510-
ELSE
511-
CASE
512-
WHEN instr(original_cmd, ' ') > 0
513-
THEN substr(original_cmd, 1, instr(original_cmd, ' ') - 1)
514-
ELSE original_cmd
515-
END
516-
END
502+
PARTITION BY original_cmd
517503
ORDER BY timestamp
518504
) AS prev_ts
519505
FROM commands

0 commit comments

Comments
 (0)