Commit 348b45a
authored
feat: proxy pre-agent gh CLI calls through DIFC gateway (#2294)
## Summary
Routes all pre-agent `gh` CLI calls in `repo-assist` through the MCP
gateway DIFC proxy, applying the same `min-integrity: merged` policy
that governs the agent's MCP tool calls.
## Problem
The repo-assist workflow runs several `gh` CLI calls **before** the
agent starts (issue list, PR list, repo-memory clone). These calls
bypass the DIFC pipeline entirely — the agent's guard policy only
applies to MCP tool calls during the agent phase.
## Solution
Add two steps to `repo-assist.lock.yml`:
### Start DIFC Proxy (before first `GH_TOKEN` step)
- Runs `ghcr.io/github/gh-aw-mcpg:v0.1.19` in proxy mode with TLS on
port 18443
- Same policy as agent:
`{"allow-only":{"repos":["github/*"],"min-integrity":"merged"}}`
- Adds proxy CA cert to system trust store (`update-ca-certificates`) so
`gh` CLI (Go) trusts it
- Writes `GH_HOST=localhost:18443` to `$GITHUB_ENV` — all subsequent
steps inherit it
### Stop DIFC Proxy (before agent execution)
- Stops the proxy container
- Clears `GH_HOST` from `$GITHUB_ENV` to prevent leaking into `awf
--env-all`
## Steps Covered
| Pre-Agent Step | Uses `GH_TOKEN` | Proxied | Mechanism |
|---|---|---|---|
| Configure gh CLI for GHE | ✅ | ✅ | `$GITHUB_ENV` |
| Fetch repo data (gh issue/pr list) | ✅ | ✅ | `$GITHUB_ENV` |
| Clone repo-memory branch | ✅ | ✅ | `$GITHUB_ENV` |
| Checkout PR branch | ✅ | ❌ | Uses Octokit, not `gh` CLI |
| Install Copilot CLI | — | ❌ | Explicit `GH_HOST: github.com` override
|
| Agent (awf container) | — | ❌ | `GH_HOST` cleared before agent |
## Design Decisions
- **`$GITHUB_ENV` over per-step env vars**: Propagates to
framework-injected steps (clone-repo-memory) that we can't modify from
the `.md` source
- **System CA trust store**: `gh` CLI uses Go's `http.DefaultTransport`
which reads system CAs — `NODE_EXTRA_CA_CERTS` only works for Node.js
- **Port 18443**: Avoids conflict with the agent's MCP gateway (port 80)
- **Graceful fallback**: If proxy fails to start, workflow continues
with direct API access
- **Lock file only**: Editing `.lock.yml` directly for debugging; `.md`
source changes will follow once validated
## Testing
This is a lock file change — needs to be validated by running the
repo-assist workflow in CI.6 files changed
Lines changed: 166 additions & 25 deletions
File tree
- .github/workflows
- guards/github-guard/rust-guard/src/labels
- internal/proxy
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1034 | 1034 | | |
1035 | 1035 | | |
1036 | 1036 | | |
| 1037 | + | |
| 1038 | + | |
1037 | 1039 | | |
1038 | 1040 | | |
1039 | 1041 | | |
1040 | 1042 | | |
1041 | 1043 | | |
1042 | 1044 | | |
| 1045 | + | |
| 1046 | + | |
1043 | 1047 | | |
1044 | 1048 | | |
1045 | 1049 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
847 | 847 | | |
848 | 848 | | |
849 | 849 | | |
850 | | - | |
| 850 | + | |
| 851 | + | |
851 | 852 | | |
852 | 853 | | |
853 | 854 | | |
| |||
893 | 894 | | |
894 | 895 | | |
895 | 896 | | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
896 | 907 | | |
897 | 908 | | |
898 | 909 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
38 | 42 | | |
39 | 43 | | |
40 | 44 | | |
| |||
170 | 174 | | |
171 | 175 | | |
172 | 176 | | |
| 177 | + | |
| 178 | + | |
173 | 179 | | |
174 | 180 | | |
175 | | - | |
| 181 | + | |
176 | 182 | | |
0 commit comments