fix: make the snippet queue reviewable (#35)
Two causes, both fixed here. Classification: trivialProbe bailed out on any newline, so multi-line chores were never judged — 'cd X && sed -n 60,200p f' and 'git status && git log --oneline -3' all became technique candidates. Newlines are now segment separators like ';', sed (without -i) and read-only git subcommands count as inspections, and context flags (-A/-B/-C, git log -p, --since, --graph, --all) keep a command because selecting history is method, not a chore. Over the live corpus the trivial verdicts go from 307 to 1,081 of 11,552 techniques, and the archaeology that matters (git log -p | grep -B 50) still survives. Retention: nothing ever aged a candidate out, so 16,149 of them sat in the queue. knox snippets expire --days N rejects uncurated candidates older than the window. It is reversible and never touches encoded rows: the code did not change, the review window moved past it.
This commit is contained in:
@@ -166,3 +166,39 @@ func TestSnippetExtractorDoesNotDoubleCountV1AndV2(t *testing.T) {
|
||||
t.Fatalf("projects = %v, want demo and old", seen)
|
||||
}
|
||||
}
|
||||
|
||||
// trivialProbe decides what a "technique" candidate is: an inspection chore
|
||||
// (hidden) versus transferable method (kept). Multi-line commands used to be
|
||||
// exempted wholesale, which kept every transcript of `cd … && cat …` chores.
|
||||
func TestTrivialProbe(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
cmd string
|
||||
want bool
|
||||
}{
|
||||
{"single read", "ls -la /tmp", true},
|
||||
{"chained reads", "cd /repo && sed -n '60,200p' tools/deploy.py", true},
|
||||
{"multi-line reads", "ls -la\nsed -n '1,20p' main.go\nwc -l main.go", true},
|
||||
{"git chores", "git status --short && git log --oneline -3", true},
|
||||
{"show file", "git show 1d244cf:engine/scroll.py | head -n 100", true},
|
||||
{"pwd", "pwd && git rev-parse --show-toplevel", true},
|
||||
|
||||
{"test run", "go test ./... 2>&1 | tail -6", false},
|
||||
{"archaeology", `git log --all -p --since="3 months ago" -- engine/app.py | grep -B 50 "class Camera"`, false},
|
||||
{"context grep", `grep -A 5 "def main" engine/app.py`, false},
|
||||
{"ssh diagnostic", "ssh host 'dmesg | grep dwc3'", false},
|
||||
{"ssh read", "ssh host 'ls /usr/src'", true},
|
||||
{"heredoc script", "python3 - <<'PY'\nprint(1)\nPY", false},
|
||||
{"in-place edit", "sed -i 's/a/b/' main.go", false},
|
||||
{"write", "git push origin main", false},
|
||||
{"redirect", "cat > out.txt <<EOF\nx\nEOF", false},
|
||||
{"substitution", "echo $(date)", false},
|
||||
{"compose up", "docker compose up -d", false},
|
||||
{"empty", "", false},
|
||||
}
|
||||
for _, c := range cases {
|
||||
if got := trivialProbe(c.cmd); got != c.want {
|
||||
t.Errorf("%s: trivialProbe(%q)=%v, want %v", c.name, c.cmd, got, c.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user