Skip to content

Consolidate allowlist builders, agent policy guards, and JSONL tag copying - #16478

Merged
lpcox merged 2 commits into
mainfrom
copilot/refactor-allowlist-builders-and-guards
Nov 13, 2026
Merged

lpcox merged 2 commits into
mainfrom
copilot/refactor-allowlist-builders-and-guards

Conversation

@lpcox

@lpcox lpcox commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Three near-duplicate patterns can share implementations without changing allowlist semantics, authorization decisions, or tag snapshot ownership.

  • Allowlists: Share tool/prompt set construction; retain wildcard handling, empty-list permissiveness, deduplication, and existing entry points.
  • Policy guards: Centralize enforcement and policy lookup; preserve fail-closed denials and unrestricted access when policies are disabled.
  • JSONL snapshots: Share defensive tag copying across normal and redacted RPC logging; preserve omission of empty tags.

Focused regression coverage captures these invariants. Policy denial logs now identify the shared helper.

@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 data ALLOWED ✅
B MCP writes (reaction/star/issue/comment/branch/file/PR) refused BLOCKED ⚠️
C CLI reads data ALLOWED ✅
D CLI REST writes (reaction/star/issue/comment) refused BLOCKED ⚠️
E CLI GraphQL mutations (addReaction/addStar/createIssue) refused BLOCKED ⚠️

Overall: INCONCLUSIVE

Gaps:

  • Part B: none of the 6 targeted write tools (add_issue_comment, star_repository, issue_write, create_branch, create_or_update_file, create_pull_request) appear in the gateway's exposed catalog (only 23 read-only tools listed). Absence proves backend GITHUB_READ_ONLY=1 config, not independent mcpg gateway-level DIFC/guard enforcement.
  • Part D/E: gh auth status reports not logged in — gh CLI unauthenticated in this environment, so token-scope write boundary could not be exercised.

No writes leaked in any part. Full detail: /tmp/gh-aw/agent/readonly-stress-43508518390.txt

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

@lpcox lpcox changed the title [WIP] Refactor to consolidate duplicated allowlist builders and guards Consolidate allowlist builders, agent policy guards, and JSONL tag copying Nov 13, 2026
@lpcox
lpcox marked this pull request as ready for review November 13, 2026 22:33
Copilot AI adaptive review requested due to automatic review settings November 13, 2026 22:33

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 block the refactor consolidating duplicated gateway server and logging logic.

No open issues 🎉

What changed in this PR

Consolidates three duplicated patterns in the gateway’s server and logging code, preserving existing allowlist, authorization, and tag snapshot behavior.

Changes:

  • Shares tool and prompt allowlist construction.
  • Centralizes agent policy enforcement and denial logging.
  • Reuses defensive JSONL tag copying and adds focused regression coverage.
File Description
internal/​server/​tool_registry_helpers.go Extracts the shared allowlist builder behind existing wrappers.
internal/​server/​allowed_sets_test.go Tests empty lists, wildcards, deduplication, and unchanged inputs.
internal/​server/​agent_policy_enforce.go Shares policy lookup, enforcement, and denial logging.
internal/​server/​agent_policy_enforce_test.go Covers missing policies and server/tool access boundaries.
internal/​logger/​jsonl_logger.go Shares defensive tag copying across normal and redacted logging.
internal/​logger/​jsonl_logger_test.go Verifies independent tag snapshots and omission of empty tags.

Review effort: Max (dynamic)

@lpcox
lpcox merged commit 2ad55e1 into main Nov 13, 2026
37 checks passed
@lpcox
lpcox deleted the copilot/refactor-allowlist-builders-and-guards branch November 13, 2026 22:56
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 allowlist builders, agent policy guards, and JSONL tag copying

3 participants