Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4658bdfc83 |
+1
-1
@@ -340,7 +340,7 @@ func NewMCPServer(kdb *db.KnoxDB) *mcp.Server {
|
|||||||
}
|
}
|
||||||
selected := make([]db.Thread, 0, len(threads))
|
selected := make([]db.Thread, 0, len(threads))
|
||||||
for _, t := range threads {
|
for _, t := range threads {
|
||||||
if strings.Contains(t.Provenance, "auto_thread") || strings.HasPrefix(t.Motivation, "Auto-detected") {
|
if t.IsDraft() {
|
||||||
selected = append(selected, t)
|
selected = append(selected, t)
|
||||||
}
|
}
|
||||||
if len(selected) >= limit {
|
if len(selected) >= limit {
|
||||||
|
|||||||
@@ -390,7 +390,7 @@ a better title and motivation. Apply changes with ` + "`knox thread update <id>`
|
|||||||
}
|
}
|
||||||
var shown int
|
var shown int
|
||||||
for _, t := range threads {
|
for _, t := range threads {
|
||||||
if !isAutoThreaded(t) {
|
if !t.IsDraft() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
obs, _ := kdb.ThreadObservations(t.ID)
|
obs, _ := kdb.ThreadObservations(t.ID)
|
||||||
@@ -419,13 +419,6 @@ a better title and motivation. Apply changes with ` + "`knox thread update <id>`
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func isAutoThreaded(t db.Thread) bool {
|
|
||||||
if strings.Contains(t.Provenance, "auto_thread") {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return strings.HasPrefix(t.Motivation, "Auto-detected")
|
|
||||||
}
|
|
||||||
|
|
||||||
func newThreadUpdateCmd(kdb *db.KnoxDB) *cobra.Command {
|
func newThreadUpdateCmd(kdb *db.KnoxDB) *cobra.Command {
|
||||||
var title, motivation, priority, tags string
|
var title, motivation, priority, tags string
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
|
|||||||
@@ -1602,6 +1602,17 @@ type Thread struct {
|
|||||||
LastActivity string // newest linked observation's signal time (created_at)
|
LastActivity string // newest linked observation's signal time (created_at)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsDraft reports whether a thread still carries the heuristic auto-threader's
|
||||||
|
// editorial copy and is worth offering for polish. Merged clusters are resolved
|
||||||
|
// and left with no observations, so they are excluded: there is nothing to
|
||||||
|
// rewrite and the queue could never drain.
|
||||||
|
func (t Thread) IsDraft() bool {
|
||||||
|
if t.Status == "resolved" || t.EntryCount == 0 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return strings.Contains(t.Provenance, "auto_thread") || strings.HasPrefix(t.Motivation, "Auto-detected")
|
||||||
|
}
|
||||||
|
|
||||||
// stallAfterDays is how long a thread may go without activity before it is
|
// stallAfterDays is how long a thread may go without activity before it is
|
||||||
// considered stalled (derived, reversible — not a stored state).
|
// considered stalled (derived, reversible — not a stored state).
|
||||||
const stallAfterDays = 14
|
const stallAfterDays = 14
|
||||||
|
|||||||
@@ -805,3 +805,28 @@ func TestUpdateThreadClearsAutoThreadMarker(t *testing.T) {
|
|||||||
t.Fatalf("unrelated provenance was rewritten: %s", got.Provenance)
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user