Skip to content

Deduplicate RPC markdown writes and JSONL entry construction - #16948

Merged
lpcox merged 2 commits into
mainfrom
copilot/duplicate-code-fix
Nov 20, 2026
Merged

lpcox merged 2 commits into
mainfrom
copilot/duplicate-code-fix

Conversation

@lpcox

@lpcox lpcox commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

RPC logging duplicates markdown sink writes across three call sites and JSONL entry construction across two paths.

Changes

  • Markdown: Route all three writes through logRPCMarkdown, centralizing locking, formatting, level, and category.
  • JSONL: Use newJSONLRPCMessage for shared metadata and copied tag snapshots; keep error handling and redacted-only fields in their respective paths.
  • Regression coverage: Check constructor fields, tag independence, and redacted sink metadata while preserving existing output.

@lpcox lpcox changed the title [WIP] Fix duplicate code pattern in logger package Deduplicate RPC markdown writes and JSONL entry construction Nov 20, 2026
@lpcox
lpcox marked this pull request as ready for review November 20, 2026 20:42
Copilot AI adaptive review requested due to automatic review settings November 20, 2026 20:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are reported for the RPC logging consolidation.

No open issues 🎉

What changed in this PR

This PR addresses #16903 by consolidating duplicated RPC logging code in the gateway’s logger package while preserving existing output and redaction behavior.

Changes:

  • Centralizes all three markdown sink writes in logRPCMarkdown.
  • Shares JSONL metadata construction and tag copying through newJSONLRPCMessage, keeping error handling and redacted-only fields separate.
  • Adds regression checks for constructor fields, independent tag snapshots, and redacted sink output.
File Description
internal/​logger/​rpc_logger.go Extracts and reuses the markdown sink helper.
internal/​logger/​rpc_logger_enclave_test.go Expands checks for redacted markdown output and JSONL metadata.
internal/​logger/​jsonl_logger.go Adds a shared constructor for normal and redacted JSONL entries.
internal/​logger/​jsonl_logger_test.go Tests constructor metadata, timestamps, and tag-copy independence.

Review effort: Balanced (adaptive)

@github-actions

Copy link
Copy Markdown
Contributor

🔒 mcpg Read-Only Stress — default

Surface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Isolation runtime: default (normal container isolation)

Part Surface Op Result Expected Status
A MCP reads (list_issues, list_pull_requests, get_file_contents, list_commits) data returned ALLOWED ✅
B MCP writes (reaction/star/issue/comment/branch/file/PR) all 6 write tool names absent from exposed catalog (23 read-only tools only) BLOCKED ⚠️
C CLI reads (list_issues, get_file_contents) data returned ALLOWED ✅
D CLI REST writes (reaction/star/issue/comment/file) gh auth status = not logged in; all attempts failed before reaching GitHub API BLOCKED ⚠️
E CLI GraphQL mutations (addReaction/addStar/createIssue) gh unauthenticated, same as D BLOCKED ⚠️

Overall: INCONCLUSIVE

  • Part A and C fully PASS — reads succeeded on both MCP and CLI surfaces.
  • Part B: no write tool (add_issue_comment, star_repository, issue_write, create_branch, create_or_update_file, create_pull_request) appears in the github MCP tool catalog proxied by mcpg (only 23 read-only tools listed). This confirms backend/toolset config is read-only but does not independently confirm mcpg's own gateway-level write-blocking layer, since no write tool call ever reached a write-capable backend.
  • Part D/E: gh CLI is unauthenticated in this environment (gh: To use GitHub CLI in a GitHub Actions workflow, set the GH_TOKEN environment variable), so REST/GraphQL write attempts failed on auth before hitting GitHub's API — this does not validate the token-scope boundary mcpg relies on for CLI writes.
  • No write of any kind leaked on any surface during this run.

⚠️ = INCONCLUSIVE — gap noted above for each row; not a confirmed enforcement failure, but methodology cannot independently confirm gateway-level blocking for these rows in this run.

🔒 mcpg read-only stress (default AWF runtime) by Read-Only Stress: default runtime

@lpcox
lpcox merged commit c4def0d into main Nov 20, 2026
35 checks passed
@lpcox
lpcox deleted the copilot/duplicate-code-fix branch November 20, 2026 20:48
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.

[duplicate-code] Duplicate Code Pattern: RPC Log Sink Writes and JSONL Entry Construction in Logger Package

3 participants