Skip to content

Consolidate guard setup and delegation control serving - #16556

Merged
lpcox merged 3 commits into
mainfrom
copilot/refactor-duplication-guard-setup
Nov 15, 2026
Merged

lpcox merged 3 commits into
mainfrom
copilot/refactor-duplication-guard-setup

Conversation

@lpcox

@lpcox lpcox commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

Tool and prompt guard setup was duplicated, with tool calls omitting sensitive logging. Logger-wide selector redaction does not cover arbitrary resource descriptions or tags; delegation control listeners also duplicated fatal-error handling.

  • Guard setup: Share initialization, request-scoped evaluator creation, and sensitive-logging policy through buildPipelineInput. Tool calls now match prompt redaction behavior.
  • Control listener: Share the serve loop, preserving error reporting, process cancellation on unexpected failure, and normal shutdown handling.
  • Normalization: Reuse util.NormalizeStringCI for container runtime names.

@lpcox lpcox changed the title [WIP] Refactor duplicated guard setup and delegation control-listener serve loop Consolidate guard setup and delegation control serving Nov 14, 2026
@lpcox
lpcox marked this pull request as ready for review November 15, 2026 03:38
Copilot AI adaptive review requested due to automatic review settings November 15, 2026 03:38
@github-actions

This comment has been minimized.

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.

🟡 Changes recommended

The timeout failure at internal/cmd/delegation_test.go:85 should use require.Fail to follow the repository’s Testify-only assertion convention while preserving immediate abort behavior.

1 open issue
What changed in this PR

Consolidates shared setup in the MCP Gateway, making tool and prompt guard logging consistent while preserving delegation-control failure handling.

Changes:

  • Share guard initialization, request-scoped evaluators, and sensitive-logging policy.
  • Extract the delegation-control serve loop and test failure and shutdown behavior.
  • Reuse the common container-runtime normalization helper.
File Description
internal/​server/​prompt_call.go Uses shared guard setup for prompt calls.
internal/​server/​guard_pipeline.go Centralizes guard setup and sensitive-logging policy.
internal/​server/​guard_pipeline_test.go Tests pipeline configuration, redaction, and initialization errors.
internal/​server/​backend_call.go Uses shared setup, enabling consistent sensitive logging.
internal/​config/​container_runtime.go Reuses util.NormalizeStringCI.
internal/​cmd/​proxy.go Uses the shared delegation-control serve loop.
internal/​cmd/​delegation.go Extracts common listener failure handling.
internal/​cmd/​delegation_test.go Tests listener failure and graceful shutdown.

Review effort: Max (dynamic)

Comment thread internal/cmd/delegation_test.go Resolved
@lpcox

lpcox commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator Author

Co-authored-by: copilot-swe-agent[bot] <[email protected]>

Copilot AI commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

@copilot address review feedback and fix linting errors https://github.com/github/gh-aw-mcpg/actions/runs/43655572192/job/132687845485?pr=16556

Addressed the timeout assertion feedback and the testifylint error assertion; make agent-finished passes. Commit: 05696b5.

@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 (add_issue_comment, star_repository, issue_write, create_branch, create_or_update_file, create_pull_request) all 7 targets absent from catalog ("unknown tool"); no leak BLOCKED ⚠️
C CLI reads (github CLI proxy, same calls as A) data returned ALLOWED ✅
D CLI REST writes not attempted — gh CLI unauthenticated (no GH_TOKEN) BLOCKED ⚠️
E CLI GraphQL mutations not attempted — gh CLI unauthenticated BLOCKED ⚠️

Overall: INCONCLUSIVE

⚠️ Part B: all 7 targeted write tools (add_issue_comment, star_repository, issue_write, create_branch, create_or_update_file, create_pull_request) were absent from the GitHub MCP tool catalog exposed via the gateway (calls returned Error [-32602]: unknown tool "<name>"). This confirms gh-aw's backend-level GITHUB_READ_ONLY=1 wrapper but does not independently confirm mcpg's own gateway-level DIFC/guard blocking layer, since no write-capable tool was ever reachable to exercise that layer. No write leaked.

⚠️ Parts D/E: gh CLI had no GH_TOKEN configured in this job (gh auth status → not logged in), so REST/GraphQL write probes could not be attempted. This leaves the token-scope boundary unvalidated for this run — reported as a methodology gap, not a pass.

No write of any kind succeeded or leaked through either surface in this run. No runtime-pass label applied since the result is INCONCLUSIVE rather than a confirmed PASS.

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

@lpcox
lpcox merged commit 8da3207 into main Nov 15, 2026
30 checks passed
@lpcox
lpcox deleted the copilot/refactor-duplication-guard-setup branch November 15, 2026 04:22
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.

[refactor] Consolidate duplicated guard setup and delegation control-listener serve loop

3 participants