unknown
Root cause: two handlers existed — the Retrieve handler in memories_search.go:148 (which had DOGFOOD-004 relevance_score plumbing) and the live MemoryHandler.Search wired in main.go:1191 to POST /v1/memories/search. The live handler never copied RelevanceScore from the internal RetrieveResult into the SearchResponse, so every agent hit the wire with relevance_score: 0 — while judge PASS came from unit tests that exercised the unwired handler/Retrieve directly.
The fix — one line in the live handler (main.go):
func (h *MemoryHandler) Search(w http.ResponseWriter, r *http.Request) {
results := Retrieve(r.URL.Query().Get("q"))
out := make([]SearchResponse, 0, len(results))
for _, res := range results {
out = append(out, SearchResponse{
ID: res.ID,
Text: res.Text,
RelevanceScore: res.RelevanceScore, // THE FIX: 1-line field copy
})
}
writeJSON(w, out)
}
Regression test (main_test.go) — the key change is that it hits the actual route registration agents call, not the unwired handler. It builds the server through the same newMux() used in production (the thing to grep for in main.go):
func newTestServer() *httptest.Server {
return httptest.NewServer(newMux(&MemoryHandler{})) // same wiring as main.go:1191
}
// TestSearchRouteCarriesRelevanceScore is the DOGFOOD-004 regression test:
// it would have failed on day one of the incident because the live route
// returned 0.0 for every relevance_score.
func TestSearchRouteCarriesRelevanceScore(t *testing.T) {
srv := newTestServer()
defer srv.Close()
resp, err := http.Post(srv.URL+"/v1/memories/search?q=dexdat", "application/json", nil)
if err != nil {
t.Fatalf("POST route: %v", err)
}
defer resp.Body.Close()
var out []SearchResponse
if err := json.NewDecoder(resp.Body).Decode(&out); err != nil {
t.Fatalf("decode: %v", err)
}
for i, m := range out {
if m.RelevanceScore == 0 {
t.Errorf("result %d: relevance_score = 0 on live route (DOGFOOD-004 regression), want > 0", i)
}
}
}
Also added edge-case coverage: empty query returns [] (not null), the wire payload contains the relevance_score JSON key, and scores are preserved per result (0.92, 0.61) rather than clobbered. Repo: ~/dexdat-fix.
**Before the fix** — regression reproduced exactly as the incident described:
```
--- FAIL: TestSearchRouteCarriesRelevanceScore (0.00s)
main_test.go:46: result 0: relevance_score = 0 on live route (DOGFOOD-004 regression), want > 0
main_test.go:46: result 1: relevance_score = 0 on live route (DOGFOOD-004 regression), want > 0
--- FAIL: TestSearchRouteEdgeCases/scores_preserved_per_result,_not_clobbered
main_test.go:92: out[0].RelevanceScore = 0, want 0.92
main_test.go:92: out[1].RelevanceScore = 0, want 0.61
```
Live E2E curl of the actual route (buggy binary): `[{"id":"m1","text":"dexdat memory one","relevance_score":0},{"id":"m2","text":"dexdat memory two","relevance_score":0}]` — the zero-score wire response agents saw for 3 days.
**After the fix** — `go vet` clean, `gofmt` clean, all tests pass:
```
=== RUN TestSearchRouteCarriesRelevanceScore
--- PASS: TestSearchRouteCarriesRelevanceScore (0.00s)
=== RUN TestSearchRouteEdgeCases
--- PASS: empty_query_returns_empty_array,_not_null
--- PASS: wire_JSON_contains_relevance_score_key
--- PASS: scores_preserved_per_result,_not_clobbered
PASS ok dexdat 0.004s
```
Live E2E curl of the actual route (fixed binary): `[{"id":"m1","text":"dexdat memory one","relevance_score":0.92},{"id":"m2","text":"dexdat memory two","relevance_score":0.61}]` — scores now on the wire.
Edge cases verified: empty query → `[]` (not `null`); missing/wrong method → 405 (route registered as POST-only); multiple results keep distinct per-item scores; JSON key name `relevance_score` present in raw payload; response decodes into the shipped `SearchResponse` struct. One operational caveat worth recording: a stale buggy process holding the port can mask verification — I confirmed the running binary was the rebuilt artifact (`go build -o`, fresh high port) before trusting the curl.{"model": "deepseek-v4-flash", "result": "completed"}Root cause: two handlers existed — the Retrieve handler in memories_search.go:148 (which had DOGFOOD-004 relevance_score plumbing) and the live MemoryHandler.Search wired in main.go:1191 to POST /v1/memories/search. The live handler never copied RelevanceScore from the internal RetrieveResult into the SearchResponse, so every agent hit the wire with relevance_score: 0 — while judge PASS came from unit tests that exercised the unwired handler/Retrieve directly.
The fix — one line in the live handler (main.go):
func (h *MemoryHandler) Search(w http.ResponseWriter, r *http.Request) {
results := Retrieve(r.URL.Query().Get("q"))
out := make([]SearchResponse, 0, len(results))
for _, res := range results {
out = append(out, SearchResponse{
ID: res.ID,
Text: res.Text,
RelevanceScore: res.RelevanceScore, // THE FIX: 1-line field copy
})
}
writeJSON(w, out)
}
Regression test (main_test.go) — the key change is that it hits the actual route registration agents call, not the unwired handler. It builds the server through the same newMux() used in production (the thing to grep for in main.go):
func newTestServer() *httptest.Server {
return httptest.NewServer(newMux(&MemoryHandler{})) // same wiring as main.go:1191
}
// TestSearchRouteCarriesRelevanceScore is the DOGFOOD-004 regression test:
// it would have failed on day one of the incident because the live route
// returned 0.0 for every relevance_score.
func TestSearchRouteCarriesRelevanceScore(t *testing.T) {
srv := newTestServer()
defer srv.Close()
resp, err := http.Post(srv.URL+"/v1/memories/search?q=dexdat", "application/json", nil)
if err != nil {
t.Fatalf("POST route: %v", err)
}
defer resp.Body.Close()
var out []SearchResponse
if err := json.NewDecoder(resp.Body).Decode(&out); err != nil {
t.Fatalf("decode: %v", err)
}
for i, m := range out {
if m.RelevanceScore == 0 {
t.Errorf("result %d: relevance_score = 0 on live route (DOGFOOD-004 regression), want > 0", i)
}
}
}
Also added edge-case coverage: empty query returns [] (not null), the wire payload contains the relevance_score JSON key, and scores are preserved per result (0.92, 0.61) rather than clobbered. Repo: ~/dexdat-fix.
**Before the fix** — regression reproduced exactly as the incident described:
```
--- FAIL: TestSearchRouteCarriesRelevanceScore (0.00s)
main_test.go:46: result 0: relevance_score = 0 on live route (DOGFOOD-004 regression), want > 0
main_test.go:46: result 1: relevance_score = 0 on live route (DOGFOOD-004 regression), want > 0
--- FAIL: TestSearchRouteEdgeCases/scores_preserved_per_result,_not_clobbered
main_test.go:92: out[0].RelevanceScore = 0, want 0.92
main_test.go:92: out[1].RelevanceScore = 0, want 0.61
```
Live E2E curl of the actual route (buggy binary): `[{"id":"m1","text":"dexdat memory one","relevance_score":0},{"id":"m2","text":"dexdat memory two","relevance_score":0}]` — the zero-score wire response agents saw for 3 days.
**After the fix** — `go vet` clean, `gofmt` clean, all tests pass:
```
=== RUN TestSearchRouteCarriesRelevanceScore
--- PASS: TestSearchRouteCarriesRelevanceScore (0.00s)
=== RUN TestSearchRouteEdgeCases
--- PASS: empty_query_returns_empty_array,_not_null
--- PASS: wire_JSON_contains_relevance_score_key
--- PASS: scores_preserved_per_result,_not_clobbered
PASS ok dexdat 0.004s
```
Live E2E curl of the actual route (fixed binary): `[{"id":"m1","text":"dexdat memory one","relevance_score":0.92},{"id":"m2","text":"dexdat memory two","relevance_score":0.61}]` — scores now on the wire.
Edge cases verified: empty query → `[]` (not `null`); missing/wrong method → 405 (route registered as POST-only); multiple results keep distinct per-item scores; JSON key name `relevance_score` present in raw payload; response decodes into the shipped `SearchResponse` struct. One operational caveat worth recording: a stale buggy process holding the port can mask verification — I confirmed the running binary was the rebuilt artifact (`go build -o`, fresh high port) before trusting the curl.{"model": "deepseek-v4-flash", "result": "completed"}