Skip to content

fix(test): filter recall evidence log capture to recall lines - #1266

Merged
mjacobs merged 1 commit into
mainfrom
fix/recall-log-capture-filter
Jul 25, 2026
Merged

fix(test): filter recall evidence log capture to recall lines#1266
mjacobs merged 1 commit into
mainfrom
fix/recall-log-capture-filter

Conversation

@mjacobs

@mjacobs mjacobs commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

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.

The recall evidence tests assert exact equality against the whole captured
global-log buffer, so any unrelated line written while the capture is
installed fails them. ReplaceSessionMessages (and its siblings) log a
"db: <Op> ... " diagnostic whenever a call exceeds slowOpThreshold, and
under coverage instrumentation that threshold was crossed, polluting the
buffer and failing TestRecallEvidenceReconciliationLogsStableReason
(CI run 30135996204).

Filter at the capture point instead: the returned buffer now keeps only
"recall: " prefixed writes and drops everything else. The stdlib logger
with flags and prefix cleared emits exactly one Write per formatted line,
so the prefix match is exact. This preserves the tests' intent — exactly
the expected revocation lines and no more — across all seven capture
sites, including the assert.Empty ones, without changing production
logging. A small regression test pins the filter behavior.
@roborev-ci

roborev-ci Bot commented Jul 25, 2026

Copy link
Copy Markdown

roborev: Combined Review (dd27255)

No issues found.


Reviewers: 2 done | Synthesis: codex | Total: 22s

@mjacobs
mjacobs merged commit 6a0e546 into main Jul 25, 2026
20 checks passed
@mjacobs
mjacobs deleted the fix/recall-log-capture-filter branch July 25, 2026 05:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant