First slice of archie-core-afbk.3's pr-review pipeline (phases 1 and 3's deterministic logic): depth classification from changed-line count with the operator-override rule, the depth-to-dimension-cap table, cross-lens dimension merge/dedup/cap, and the hallucination-check dimension added for a likely-machine-written PR. Table-driven tests cover the classification boundaries, the override rule, duplicate-name merging, priority-ordered capping and the AI-generated threshold. Stage wiring (agent calls, StepExecution recording, the fan-out concurrency phases 3/4/9 need, and a PR diff/snapshot source) is still open; see the bead for what remains.
62 lines
1.6 KiB
Go
62 lines
1.6 KiB
Go
package prreview
|
|
|
|
import "testing"
|
|
|
|
func TestClassifyDepth(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
tests := []struct {
|
|
name string
|
|
changedLines int
|
|
want Depth
|
|
}{
|
|
{"zero lines is quick", 0, DepthQuick},
|
|
{"just under the quick boundary", 99, DepthQuick},
|
|
{"the quick boundary itself is standard", 100, DepthStandard},
|
|
{"just under the standard boundary", 499, DepthStandard},
|
|
{"the standard boundary itself is deep", 500, DepthDeep},
|
|
{"far above the standard boundary is deep", 5000, DepthDeep},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
t.Parallel()
|
|
if got := ClassifyDepth(tt.changedLines); got != tt.want {
|
|
t.Errorf("ClassifyDepth(%d) = %q, want %q", tt.changedLines, got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestMaxDimensionsFor(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
tests := []struct {
|
|
depth Depth
|
|
want int
|
|
}{
|
|
{DepthQuick, 3},
|
|
{DepthStandard, 6},
|
|
{DepthDeep, 12},
|
|
{Depth("unknown"), 3}, // an unrecognised depth is treated as the cheapest, never the most expensive
|
|
}
|
|
for _, tt := range tests {
|
|
if got := MaxDimensionsFor(tt.depth); got != tt.want {
|
|
t.Errorf("MaxDimensionsFor(%q) = %d, want %d", tt.depth, got, tt.want)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestExplicitDepthOverridesClassification(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
got := ResolveDepth(5000, DepthQuick)
|
|
if got != DepthQuick {
|
|
t.Errorf("ResolveDepth with an explicit operator depth = %q, want %q (the explicit value must win over the line count)", got, DepthQuick)
|
|
}
|
|
|
|
got = ResolveDepth(5000, "")
|
|
if got != DepthDeep {
|
|
t.Errorf("ResolveDepth with no explicit depth = %q, want %q (falls back to classification)", got, DepthDeep)
|
|
}
|
|
}
|