fix: keep merged and resolved threads out of the draft queue (#33)
build / image (push) Successful in 36s
build / test (push) Successful in 3m21s

The draft predicate only looked at the auto_thread marker, so a cluster
merged into another (resolved, zero observations left) stayed on the list
forever and the queue could never drain: 6 of 13 candidates on this index
were merged or resolved.

IsDraft now owns the predicate for both surfaces: auto-threaded, not
resolved, and still holding at least one observation.
This commit is contained in:
2026-11-04 20:37:53 -08:00
parent 45f966d44f
commit 4658bdfc83
4 changed files with 38 additions and 9 deletions
+25
View File
@@ -805,3 +805,28 @@ func TestUpdateThreadClearsAutoThreadMarker(t *testing.T) {
t.Fatalf("unrelated provenance was rewritten: %s", got.Provenance)
}
}
// The draft queue is "auto-threaded clusters still worth polishing". A merged
// cluster is resolved and empty, so it must not come back as a candidate.
func TestThreadIsDraft(t *testing.T) {
cases := []struct {
name string
t Thread
draft bool
}{
{"marker", Thread{Status: "active", EntryCount: 12, Provenance: `{"trigger":"auto_thread"}`}, true},
{"prefix", Thread{Status: "stalled", EntryCount: 3, Motivation: "Auto-detected cluster of 4"}, true},
{"groomed", Thread{Status: "active", EntryCount: 12,
Provenance: `{"groomed":true,"cluster":"plant"}`, Motivation: "Plant watering"}, false},
{"merged", Thread{Status: "resolved", EntryCount: 0, Provenance: `{"trigger":"auto_thread"}`}, false},
{"resolved with work", Thread{Status: "resolved", EntryCount: 9, Provenance: `{"trigger":"auto_thread"}`}, false},
{"empty cluster", Thread{Status: "active", EntryCount: 0, Motivation: "Auto-detected cluster"}, false},
{"manual", Thread{Status: "active", EntryCount: 4,
Provenance: `{"trigger":"display-watch"}`, Motivation: "By hand"}, false},
}
for _, c := range cases {
if got := c.t.IsDraft(); got != c.draft {
t.Errorf("%s: IsDraft()=%v, want %v", c.name, got, c.draft)
}
}
}