| 1 | package memory |
| 2 | |
| 3 | import "testing" |
| 4 | |
| 5 | // The shadow contract: V2 rankings ride the result for telemetry and never |
| 6 | // change what production recall serves. |
| 7 | func TestAutoRecallAttachesShadowWithoutChangingProduction(t *testing.T) { |
| 8 | store := recallTestStore(t) |
| 9 | recallTestWrite(t, store.Dir, Memory{ |
| 10 | ID: "mem-sym", Name: "retry-config", Title: "Retry configuration", |
| 11 | Description: "Where retry limits live", Type: TypeProject, Scope: FactScopeProject, |
| 12 | Body: "Configure RetryPolicy.MaxBackoffMs in policy/retry.toml.", |
| 13 | }) |
| 14 | result := AutoRecall(store, "where do I configure retry limits policy", RecallOptions{}) |
| 15 | if len(result.Hits) == 0 { |
| 16 | t.Fatalf("production recall should hit: %+v", result) |
| 17 | } |
| 18 | if len(result.ShadowHits) == 0 || result.ShadowHits[0].ID != "mem-sym" { |
| 19 | t.Fatalf("shadow ranking must ride the result: %+v", result.ShadowHits) |
| 20 | } |
| 21 | if result.Block() == "" || len(result.Block()) < 10 { |
| 22 | t.Fatal("production block must be unaffected") |
| 23 | } |
| 24 | // The V2 code-symbol split finds what V1 unigrams cannot. |
| 25 | segQuery := AutoRecall(store, "max backoff tuning", RecallOptions{}) |
| 26 | if len(segQuery.ShadowHits) == 0 { |
| 27 | t.Fatalf("V2 shadow should match camel-case segments: %+v", segQuery) |
| 28 | } |
| 29 | } |
| 30 |