refactor: move DIFC filter events into JSONL log#2077
Merged
Conversation
Write DIFC_FILTERED entries to rpc-messages.jsonl alongside RPC request/response traffic so filter events appear in context with the tool call that triggered them. - Add JSONLFilteredItem type and LogDifcFilteredItem() to JSONL logger - Extract logEntry() helper from LogMessage() for generic JSONL writes - Remove dedicated DifcFilterEntry type (replaced by JSONLFilteredItem) - No new log files; filter events share the existing JSONL stream Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors DIFC filtering event logging so filtered-item events are written into the existing JSONL RPC log stream (rpc-messages.jsonl) to appear alongside the request/response that triggered filtering.
Changes:
- Replace per-item file-log output with JSONL “DIFC_FILTERED” entries emitted via the JSONL logger.
- Add
JSONLFilteredItemandLogDifcFilteredItem()to the JSONL logger, and extract a genericlogEntry()writer helper. - Remove the dedicated structured log type previously used for DIFC-filtered items.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| internal/server/difc_log.go | Switch DIFC filtered-item logging to emit JSONL entries via logger.LogDifcFilteredItem. |
| internal/logger/jsonl_logger.go | Introduce generic JSONL logEntry() helper plus new JSONLFilteredItem + LogDifcFilteredItem() writer. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
internal/server/difc_log.go
Outdated
Comment on lines
+16
to
+17
| entry := buildFilteredLogEntry(serverID, toolName, detail) | ||
| logger.LogDifcFilteredItem(entry) |
…tion to fix lint failure Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
…ix lint failure (#2078) CI lint failed with `undefined: FilteredItemLogEntry` because `difc_log_test.go` referenced two symbols that didn't exist in production code: `FilteredItemLogEntry` (struct) and `buildFilteredItemLogEntry` (func). The production code had a mismatched `buildFilteredLogEntry` returning `*logger.JSONLFilteredItem` with no text-log output. ## Changes to `internal/server/difc_log.go` - **New `FilteredItemLogEntry` struct** — local type with JSON tags matching what the tests deserialize; decoupled from `logger.JSONLFilteredItem` - **Renamed `buildFilteredLogEntry` → `buildFilteredItemLogEntry`** — returns `FilteredItemLogEntry` value (not pointer), matching test call sites - **Updated `logFilteredItems`** — marshals entry to JSON and writes `[DIFC-FILTERED] <json>` to both unified and per-server text logs via `LogInfoWithServer`; continues emitting to JSONL via `LogDifcFilteredItem` for backward compatibility - **Added `toJSONLFilteredItem()` method** — converts `FilteredItemLogEntry` → `*logger.JSONLFilteredItem` to eliminate duplicated field mapping - **Improved error handling** — logs marshal failures via `LogInfoWithServer` instead of silently dropping them > [!WARNING] > > <details> > <summary>Firewall rules blocked me from connecting to one or more addresses (expand for details)</summary> > > #### I tried to connect to the following addresses, but was blocked by firewall rules: > > - `example.com` > - Triggering command: `/tmp/go-build2821814806/b332/launcher.test /tmp/go-build2821814806/b332/launcher.test -test.testlogfile=/tmp/go-build2821814806/b332/testlog.txt -test.paniconexit0 -test.timeout=10m0s /tmp/go-build2821814806/b237/vet.cfg 1.4.0/mcp/client.go 1.4.0/mcp/cmd.go x_amd64/compile` (dns block) > - `invalid-host-that-does-not-exist-12345.com` > - Triggering command: `/tmp/go-build2821814806/b317/config.test /tmp/go-build2821814806/b317/config.test -test.testlogfile=/tmp/go-build2821814806/b317/testlog.txt -test.paniconexit0 -test.timeout=10m0s main�� mat.go se.go x_amd64/compile --detach contextprotocol/-unsafeptr=false` (dns block) > - `nonexistent.local` > - Triggering command: `/tmp/go-build2821814806/b332/launcher.test /tmp/go-build2821814806/b332/launcher.test -test.testlogfile=/tmp/go-build2821814806/b332/testlog.txt -test.paniconexit0 -test.timeout=10m0s /tmp/go-build2821814806/b237/vet.cfg 1.4.0/mcp/client.go 1.4.0/mcp/cmd.go x_amd64/compile` (dns block) > - `slow.example.com` > - Triggering command: `/tmp/go-build2821814806/b332/launcher.test /tmp/go-build2821814806/b332/launcher.test -test.testlogfile=/tmp/go-build2821814806/b332/testlog.txt -test.paniconexit0 -test.timeout=10m0s /tmp/go-build2821814806/b237/vet.cfg 1.4.0/mcp/client.go 1.4.0/mcp/cmd.go x_amd64/compile` (dns block) > - `this-host-does-not-exist-12345.com` > - Triggering command: `/tmp/go-build2821814806/b341/mcp.test /tmp/go-build2821814806/b341/mcp.test -test.testlogfile=/tmp/go-build2821814806/b341/testlog.txt -test.paniconexit0 -test.timeout=10m0s /tmp/go-build2821814806/b253/vet.cfg _.a ternal/fips140/hkdf/cast.go 522601/b097=>` (dns block) > > If you need me to access, download, or install something from one of these locations, you can either: > > - Configure [Actions setup steps](https://gh.io/copilot/actions-setup-steps) to set up my environment, which run before the firewall is enabled > - Add the appropriate URLs or hosts to the custom allowlist in this repository's [Copilot coding agent settings](https://github.com/github/gh-aw-mcpg/settings/copilot/coding_agent) (admins only) > > </details> <!-- START COPILOT CODING AGENT SUFFIX --> <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > Fix the failing GitHub Actions workflow lint > Analyze the workflow logs, identify the root cause of the failure, and implement a fix. > Job ID: 67501871628 > Job URL: https://github.com/github/gh-aw-mcpg/actions/runs/23223729138/job/67501871628 </details> <!-- START COPILOT CODING AGENT TIPS --> --- 💬 Send tasks to Copilot coding agent from [Slack](https://gh.io/cca-slack-docs) and [Teams](https://gh.io/cca-teams-docs) to turn conversations into code. Copilot posts an update in your thread when it's finished.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
`LogDifcFilteredItem` was passing `*JSONLFilteredItem` to
`logger.LogMessage`, which only accepts `*JSONLRPCMessage`, causing a
compile error.
## Change
- **`internal/logger/jsonl_logger.go`**: Replace
`logger.LogMessage(entry)` with `logger.logEntry(entry)` in
`LogDifcFilteredItem`. `logEntry` accepts `interface{}` and is the
underlying method `LogMessage` already delegates to — making it the
correct call site for non-RPC entry types.
```go
// Before
_ = logger.LogMessage(entry) // type error: *JSONLFilteredItem is not *JSONLRPCMessage
// After
_ = logger.logEntry(entry) // accepts interface{}, handles any JSON-serializable type
```
This was referenced Mar 18, 2026
This was referenced Mar 18, 2026
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.
Write DIFC_FILTERED entries to rpc-messages.jsonl alongside RPC request/response traffic so filter events appear in context with the tool call that triggered them.