Repository navigation
Meter GitHub API point budgets per HTTP request - #11915
Conversation
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
The startup probe forwards a dummy authorization token that breaks liveness checks, while GraphQL misclassification allows budget and body-cap bypasses and can reject valid reads.
3 open issues
What changed in this PR
This PR moves GitHub API point accounting from command parsing to the protected gh HTTP shim, addressing the high-level command and pagination gaps in #11914.
Changes:
- Enforce independent REST and GraphQL budgets per HTTP request, including pagination and retries.
- Classify read/write costs, validate request targets, and cap buffered GraphQL bodies at 1 MiB.
- Expand regression coverage and document startup-probe exclusion and partial command execution.
| File | Description |
|---|---|
docs/awf-config-spec.md |
Documents per-request costs, limits, and failure semantics. |
containers/cli-proxy/server.test.js |
Adds real-gh regressions against a local upstream. |
containers/cli-proxy/server.js |
Removes command-level point enforcement. |
containers/cli-proxy/github-api-point-limiter.test.js |
Tests HTTP costs, GraphQL classification, and independent budgets. |
containers/cli-proxy/github-api-point-limiter.js |
Replaces argument pricing with HTTP request accounting. |
containers/cli-proxy/gh-http-shim.test.js |
Covers budget denials, concurrency, request targets, and body limits. |
containers/cli-proxy/gh-http-shim.js |
Enforces budgets before forwarding requests. |
containers/cli-proxy/entrypoint.sh |
Moves shim startup after liveness probes and changes probe headers. |
Review effort: Max (adaptive)
| if timeout "${LIVENESS_TIMEOUT_SECONDS}" gh api rate_limit \ | ||
| # The HTTP shim is not running yet; remove gh's placeholder authorization | ||
| # here just as the shim does for agent traffic. | ||
| if timeout "${LIVENESS_TIMEOUT_SECONDS}" gh api rate_limit -H 'Authorization:' \ |
| function isGraphqlRequest(url) { | ||
| const path = decodeURIComponent(url.split('?', 1)[0]).replace(/\/+/g, '/'); | ||
| const pathname = new URL(`http://localhost${path}`).pathname.replace(/\/+$/, ''); | ||
| return pathname === '/graphql' || pathname === '/api/graphql'; |
| } | ||
| if (!endpoint || invalidMethod) return null; | ||
| if (endpoint === 'graphql') return { kind: 'graphql', points: READ_POINTS }; | ||
| return firstToken === 'query' || firstToken === '{'; |
|
@copilot address review feedback |
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Addressed the probe auth, GraphQL path normalization, and top-level operation classification feedback in |
|
✅ Copilot review passed with no inline comments. @lpcox Add the |
Documentation PreviewDocumentation has been built for this PR. To view locally:
Built from commit 1dfb9e7 |
✅ Coverage Check PassedOverall Coverage
📁 Per-file Coverage Changes (4 files)
✨ New Files (9 files)
Coverage comparison generated by |


GitHub API point budgets counted only literal
gh apiinvocations, leaving high-level commands unmetered and pagination undercounted. Implicit POSTs and GraphQL mutations were also underpriced.pr comment,issue create, pagination, implicit POSTs, concurrent requests, and accounting bypasses.gh apiinvocations #11914