Skip to content

Centralize DIFC Phase 5 pipeline wiring - #16927

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

lpcox merged 3 commits into
mainfrom
copilot/duplicate-code-fix-difc-filter

Conversation

@lpcox

@lpcox lpcox commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Proxy, tool, and prompt handlers repeat the same six-argument Phase 5 call. This refactor centralizes that wiring alongside the existing Phase 4 and Phase 6 helpers.

  • Shared invocation: Add guard.RunPipelinePhase5, extracting agent labels and operation from PipelinePreResult, and migrate all three handlers:
    filterResult, err := guard.RunPipelinePhase5(requestEvaluator, pre, labeledData, enforcementMode)
  • Behavior preserved: Keep blocked/filtered branches, error handling, and HTTP status decisions in each handler.
  • Regression coverage: Add focused cases for label and operation forwarding, enforcement modes, nil/simple data, and conversion errors.

@lpcox lpcox changed the title [WIP] Fix duplicated DIFC Phase 5 filter invocation across handlers Centralize DIFC Phase 5 pipeline wiring Nov 20, 2026
@lpcox
lpcox marked this pull request as ready for review November 20, 2026 17:48
Copilot AI adaptive review requested due to automatic review settings November 20, 2026 17:48
@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 Phase 5 tests lack a regression case verifying that the helper preserves a propagate-mode evaluator’s capability ceiling and keeps out-of-scope collection items filtered.

1 open issue
What changed in this PR

Centralizes DIFC Phase 5 filtering and result conversion in a shared guard helper, removing repeated wiring from the HTTP proxy and MCP tool and prompt handlers.

Changes:

  • Adds guard.RunPipelinePhase5 alongside the existing phase helpers.
  • Migrates all three callers while preserving their error, response, and HTTP status handling.
  • Adds regression tests for label and operation forwarding, enforcement modes, nil/simple data, and conversion errors.
File Description
internal/​server/​prompt_call.go Uses the shared helper for prompt responses.
internal/​server/​backend_call.go Uses the shared helper for tool responses.
internal/​proxy/​handler.go Uses the shared helper for proxy responses.
internal/​guard/​pipeline.go Adds the Phase 5 wrapper and updates pipeline comments.
internal/​guard/​pipeline_test.go Adds focused Phase 5 regression coverage.

Review effort: Max (adaptive)

Comment thread internal/guard/pipeline_test.go Resolved
Add a test for RunPipelinePhase5 to check secrecy propagation.

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
@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 AWF (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 (star_repository, issue_write, add_issue_comment, create_branch, create_or_update_file, create_pull_request) refused: "unknown tool" (-32602), all 6 absent from 23-tool read-only catalog BLOCKED ⚠️
C CLI reads (same probes via github CLI proxy) data returned ALLOWED ✅
D CLI REST writes (reaction/star/issue/comment) gh CLI unauthenticated — not attempted BLOCKED ⚠️
E CLI GraphQL mutations (addReaction/addStar/createIssue) gh CLI unauthenticated — not attempted BLOCKED ⚠️

Overall: INCONCLUSIVE

⚠️ Part B: all 6 targeted write tools were absent from the gateway-exposed catalog entirely (gh-aw's tools.github: always launches the backend with GITHUB_READ_ONLY=1), so refusals only confirm backend/toolset configuration, not mcpg's own gateway-level DIFC/guard enforcement — per the task's methodology this is INCONCLUSIVE, not PASS.

⚠️ Parts D/E: gh auth status reported no authenticated host in this environment, so the token-scope write-boundary could not be exercised; these rows are INCONCLUSIVE rather than PASS/FAIL.

No write of any kind leaked through any surface in this run.

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

@lpcox
lpcox merged commit 3882c30 into main Nov 20, 2026
30 checks passed
@lpcox
lpcox deleted the copilot/duplicate-code-fix-difc-filter branch November 20, 2026 18:13
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: Repeated DIFC Phase 5 Filter Invocation

3 participants