Skip to content

refactor: move DIFC filter events into JSONL log#2077

Merged
lpcox merged 9 commits intomainfrom
feat/difc-filtered-item-logging
Mar 18, 2026
Merged

refactor: move DIFC filter events into JSONL log#2077
lpcox merged 9 commits intomainfrom
feat/difc-filtered-item-logging

Conversation

@lpcox
Copy link
Collaborator

@lpcox lpcox commented Mar 18, 2026

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

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>
Copilot AI review requested due to automatic review settings March 18, 2026 00:52
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 JSONLFilteredItem and LogDifcFilteredItem() to the JSONL logger, and extract a generic logEntry() 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.

Comment on lines +16 to +17
entry := buildFilteredLogEntry(serverID, toolName, detail)
logger.LogDifcFilteredItem(entry)
Copilot AI and others added 6 commits March 18, 2026 01:04
…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=&gt;` (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
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants