Commit 6a0e546
authored
fix(test): filter recall evidence log capture to recall lines (#1266)
The seven recall-evidence tests in
`internal/db/recall_evidence_window_test.go` capture the global `log`
output via `captureRecallEvidenceLog` and assert on the whole buffer —
mostly exact-equality against a single expected `recall: revoked
provenance ...` line, plus two empty-buffer checks on rollback paths.
That is stricter than the tests' intent: any unrelated line written to
the global logger inside the capture window fails them.
One such line exists in practice: `ReplaceSessionMessages` logs a `db:
ReplaceSessionMessages ...` diagnostic when the call exceeds
`slowOpThreshold` (100ms). Under the coverage job's instrumentation the
call crossed the threshold and the diagnostic landed in the captured
buffer, failing
`TestRecallEvidenceReconciliationLogsStableReason/missing_digest` on an
unrelated PR (run 30135996204).
This change filters at the capture point instead of loosening
assertions: `captureRecallEvidenceLog` now returns a writer that retains
only `recall: `-prefixed lines (the only prefix the revocation flush
emits) and discards everything else. Since the writer embeds
`bytes.Buffer`, all seven call sites — `String()`, `Reset()`, the
`assert.Empty` checks — are unchanged, and the exact-equality assertions
keep their full strength for recall lines specifically. A small
regression test replays the pollution scenario directly.
The slow-op diagnostics themselves are intentional production
instrumentation and are untouched. Other log-capture helpers in the repo
(`cmd/agentsview`, `internal/config`, `internal/parser`,
`internal/duckdb`) already use substring/count-based assertions and are
not affected by this failure mode, so they are deliberately left alone.
Reviewers should look at the `recallEvidenceLogBuffer.Write` prefix
check: it relies on the stdlib `log` package issuing one `Write` per
formatted line, which holds because the helper clears flags and prefix
while installed.1 parent 9e5324c commit 6a0e546
1 file changed
Lines changed: 33 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1189 | 1189 | | |
1190 | 1190 | | |
1191 | 1191 | | |
1192 | | - | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
1193 | 1211 | | |
1194 | | - | |
| 1212 | + | |
1195 | 1213 | | |
1196 | 1214 | | |
1197 | 1215 | | |
| |||
1205 | 1223 | | |
1206 | 1224 | | |
1207 | 1225 | | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
0 commit comments