Skip to content

Consolidate shared environment names and OIDC startup handling - #16929

Merged
lpcox merged 2 commits into
mainfrom
copilot/refactor-semantic-function-clustering
Nov 20, 2026
Merged

lpcox merged 2 commits into
mainfrom
copilot/refactor-semantic-function-clustering

Conversation

@lpcox

@lpcox lpcox commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Duplicated environment names and OIDC readiness checks leave configuration validation and runtime initialization vulnerable to drift. This refactor addresses the remaining duplication without changing startup semantics.

  • Environment names: Share log-directory, OTLP fan-out, and OIDC constants; reuse the existing DEBUG constant.
  • OIDC initialization: Add ProviderFromEnv() and share RequestCredentials.Available() between validation and provider construction.
    provider := oidc.ProviderFromEnv() // nil when the request URL is unset or empty
  • Compatibility: Preserve URL-only OIDC readiness, explicitly empty env overrides, and CLI precedence. Add regression coverage for these cases; retain the existing guards-mode and control-handler helpers.

@lpcox lpcox changed the title [WIP] Refactor env reads bypassing envutil and duplicated handling Consolidate shared environment names and OIDC startup handling 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

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 7 targets absent from the 23-tool catalog (list/get/search/*_read only) — no gateway-level refusal could be exercised BLOCKED ⚠️ INCONCLUSIVE
C CLI reads via proxied github CLI data returned ALLOWED ✅
D CLI REST writes (reaction/star/issue/comment) gh not authenticated in this job (no GH_TOKEN) — no write attempted BLOCKED ⚠️ INCONCLUSIVE
E CLI GraphQL mutations (addReaction/addStar/createIssue) gh not authenticated — no mutation attempted BLOCKED ⚠️ INCONCLUSIVE

Overall: INCONCLUSIVE

Notes:

  • Part A/C fully confirm read access works through both the MCP tool surface and the proxied CLI.
  • Part B: the gateway-fronted GitHub MCP tool catalog exposes only 23 read-only tools (list_*, get_*, search_*, issue_read, pull_request_read). All 7 targeted write tool names (add_issue_comment, star_repository, issue_write, create_branch, create_or_update_file, create_pull_request, pull_request_write) return 'Unknown command' — absent from the catalog entirely. This is consistent with gh-aw's GITHUB_READ_ONLY=1 backend behavior but does not independently confirm mcpg's own gateway-level write-blocking layer, since no write call ever reached a write-capable backend tool.
  • Part D/E: gh auth status confirms the CLI is unauthenticated in this job (no GH_TOKEN); all gh api/gh api graphql write probes failed before reaching GitHub with an auth-setup error, not a permission/scope error, so the token-scope boundary could not be exercised this run.
  • No writes were attempted, retried, or leaked. No cleanup needed.

Full details: /tmp/gh-aw/agent/readonly-stress-44772550107.txt

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

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

The environment-variable and OIDC startup consolidation has no active review issues.

No open issues 🎉

What changed in this PR

Consolidates environment-variable names and OIDC startup handling across the gateway’s configuration, CLI, tracing, and launcher code while preserving existing startup semantics.

Changes:

  • Shares log-directory, OTLP fan-out, and OIDC environment constants; reuses the existing DEBUG constant.
  • Centralizes OIDC provider creation and URL-only readiness checks.
  • Adds regression coverage for OIDC credentials, empty environment overrides, and CLI precedence.
File Description
internal/​tracing/​config_resolver.go Defines and uses the OTLP fan-out environment constant.
internal/​oidc/​provider.go Adds OIDC constants, readiness checks, and provider creation from environment values.
internal/​oidc/​provider_test.go Tests provider availability and captured credentials.
internal/​launcher/​launcher.go Uses centralized OIDC provider creation.
internal/​launcher/​launcher_test.go Verifies URL-only OIDC initialization.
internal/​config/​validation_test.go Tests authentication validation without a request token.
internal/​config/​validation_server.go Uses shared OIDC readiness checks and constants.
internal/​config/​validation_env.go Uses the shared log-directory constant.
internal/​config/​gateway_env.go Defines the log-directory environment constant.
internal/​cmd/​root.go Reuses debug and OTLP environment constants.
internal/​cmd/​root_test.go Covers guards-mode environment overrides and flag precedence.
internal/​cmd/​proxy.go Uses the shared log-directory constant.
internal/​cmd/​flags_logging.go Uses the shared constant for logging and cache defaults.

Review effort: Max (adaptive)

@lpcox
lpcox merged commit e5d4333 into main Nov 20, 2026
37 checks passed
@lpcox
lpcox deleted the copilot/refactor-semantic-function-clustering branch November 20, 2026 18:03
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] Semantic function clustering: env reads bypass envutil, guards-mode and OIDC env handling duplicated, ControlHandler near-duplic

3 participants