fix(test): filter recall evidence log capture to recall lines - #1266
Merged
Conversation
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: Combined Review (
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The seven recall-evidence tests in
internal/db/recall_evidence_window_test.gocapture the globallogoutput viacaptureRecallEvidenceLogand assert on the whole buffer — mostly exact-equality against a single expectedrecall: 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:
ReplaceSessionMessageslogs adb: ReplaceSessionMessages ...diagnostic when the call exceedsslowOpThreshold(100ms). Under the coverage job's instrumentation the call crossed the threshold and the diagnostic landed in the captured buffer, failingTestRecallEvidenceReconciliationLogsStableReason/missing_digeston an unrelated PR (run 30135996204).This change filters at the capture point instead of loosening assertions:
captureRecallEvidenceLognow returns a writer that retains onlyrecall:-prefixed lines (the only prefix the revocation flush emits) and discards everything else. Since the writer embedsbytes.Buffer, all seven call sites —String(),Reset(), theassert.Emptychecks — 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.Writeprefix check: it relies on the stdliblogpackage issuing oneWriteper formatted line, which holds because the helper clears flags and prefix while installed.