Repository navigation
Register hosted Grok Bot KB OAuth client - #67
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
OpenRouter review posted ( |
There was a problem hiding this comment.
OpenRouter pull-request review
Verdict: issues
Scope: full-pr (full-pr)
Mode: initial
Commit: 37135e8b37f4fed7a23d9b6b47a3df17f24e744a
Judge: openai/gpt-5.6-luna (repaired(canonical+2): source coverage preserved before publication cap)
Cost: $0.1061 (lanes $0.1025 + judge $0.0036)
Lanes
openai/gpt-6.1-sol: ok (3 finding(s), 34.2s, 75800+1480 tokens (51298 cached), 4 tool round(s), via Azure, $0.0893)z-ai/glm-5.3-flash: ok (4 finding(s), 78.8s, 280799+7255 tokens (239936 cached), 11 tool round(s), via Wafer, $0.0133)
Warning
openai/gpt-6.1-sol: coverage claims 3 finding(s) in 'worker/wrangler.jsonc' but 0 were reported
Warning
z-ai/glm-5.3-flash: coverage claims 4 finding(s) in 'worker/wrangler.jsonc' but 0 were reported
Findings
🔴 Issue 1 — Deployment-blocking three-client assertion
src/knowledge-authoring-config.test.ts:75 · bug · identified by openai/gpt-6.1-sol
Merging this registration causes the normal Node test suite to fail and prevents the main deployment workflow from reaching Worker deployment.
src/knowledge-authoring-config.test.ts reads the actual worker/wrangler.jsonc and asserts that runtime.configuration.clients equals an array containing exactly the three existing registrations. The new fourth client makes that toEqual assertion fail. Update the expected profile and test title alongside the configuration, and include the hosted callback in the authorization-request checks.
I checked vitest.config.ts, package.json, and .github/workflows/deploy.yml: this test is included in test:node, which is a mandatory step before deployment. createAgentAccessRuntime preserves the supplied client array rather than filtering out the new registration. Tests were not executed in the read-only review environment.
🔴 Issue 2 — Node test pins the exact three-client profile and will fail on the new fourth registration
src/knowledge-authoring-config.test.ts:70 · bug · identified by z-ai/glm-5.3-flash
With the new pg-kb-grok-accept-v1 entry in worker/wrangler.jsonc, the test constructs the exact checked-in three-client profile and serves both discovery documents fails. It builds the runtime from the checked-in config via unstable_readConfig and asserts runtime.configuration.clients toEqual exactly the three Codex/Claude/device clients; a fourth client makes that strict equality fail, so pnpm test (run by .github/workflows/ci.yml) goes red on this PR.
Evidence: src/knowledge-authoring-config.test.ts:70-99 builds the list from deploymentConfiguration().vars.PEGMA_AGENT_CLIENTS_JSON (line 28, 71) and compares it with toEqual against a three-element literal. vitest.config.ts includes src/**/*.test.ts, so this file runs in CI. Note that if @pegma/agent-access@0.1.1 additionally rejects the new hosted redirect URI at construction time (see the separate issuer-availability finding), configuredRuntime throws 'Expected configured Agent Access.' (line 51) and every test in this file fails, not just this one.
The fix is to extend the expected profile to four clients (and add the new client to the per-client it.each cases, which currently cover only Codex and Claude callbacks).
🟠 Issue 3 — New hosted redirect URI is untested and one invalid registration disables the whole Agent Access issuer
worker/src/knowledge-host.ts:69 · risk · identified by z-ai/glm-5.3-flash
This is the first registration in the array whose callback is neither an IP-loopback http URI nor empty: https://www.cursor.com/agents/mcp/oauth/callback. Nothing in this PR exercises it. The existing test pattern pins each authorization_code client with an it.each case hitting the real authorize endpoint (Codex and Claude have both accept and reject cases; the Grok client has none), so a malformed hosted URI would ship untested.
The blast radius of a validation failure is not limited to the new client. worker/src/knowledge-host.ts:69-91 wraps the entire createAgentAccessRuntime({... clients: readAgentClients(...)}) call in one try/catch; if @pegma/agent-access@0.1.1 throws while constructing with the new client (its redirect/OAuth validation is delegated to that package per docs/KNOWLEDGE_COMPOSITION.md line ~181: "delegates redirect and OAuth validation to Agent Access"), agentAccess becomes null and every /api/agent-access/* request and both /.well-known metadata routes return 503 agent_access_not_configured — taking down the three previously working registrations along with the new one. The deployment then looks healthy while OAuth for all clients is offline.
Proof gap: node_modules is not present in the review checkout, so I could not inspect Agent Access 0.1.1's redirect-URI rules to confirm or refute acceptance of a non-loopback https callback; the repo's own drift tests (src/knowledge-authoring-config.test.ts:175-201) only pin loopback behaviors (wildcard http://127.0.0.1/* and missing localhost port). Because the repo treats the checked-in profile as the exact deployable set, a passing readAgentClients structural parse does not establish that createAgentAccess accepts this URI. At minimum, add a test that constructs the full four-client runtime and drives the Grok client through the actual authorize endpoint before merge.
🔵 Issue 4 — Stale generated client-registration type
worker/worker-configuration.d.ts:9 · nit · identified by openai/gpt-6.1-sol
After deployment, TypeScript still describes Env.PEGMA_AGENT_CLIENTS_JSON as the old three-client JSON literal, although Wrangler supplies the new four-client value. Typed fixtures or configuration assignments using the actual deployment value can consequently be rejected, and the generated declarations no longer represent the deployed environment.
worker/worker-configuration.d.ts:9 retains the previous literal. Regenerate the Worker declarations using the existing worker:types script so this configuration change and its generated type remain synchronized.
I checked worker/tsconfig.json, which includes these declarations, and package.json, which provides generation and normalization. The current Knowledge host widens this setting to string, so this is declaration drift rather than an established runtime failure.
🔵 Issue 5 — Outdated operator registration inventory
docs/KNOWLEDGE_COMPOSITION.md:150 · nit · identified by openai/gpt-6.1-sol
An operator following the Knowledge qualification runbook will see an incomplete client inventory and be told that Hosted Grok Bot registration is still pending even after this change registers it. This makes the documented activation state and callback reference misleading during compatibility testing.
docs/KNOWLEDGE_COMPOSITION.md still describes three explicit registrations at line 114, lists only those three in the registration table, and states at lines 150–151 that Hosted Grok Bot registration and acceptance remain pending. Add the fourth registration and its exact HTTPS callback, while keeping hosted-client acceptance explicitly pending.
I checked the full repository references to PEGMA_AGENT_CLIENTS_JSON, the existing client IDs, and Grok. The configuration now contains the new registration, but this operator-facing inventory was not updated; registration and successful client acceptance remain distinct states.
🔵 Issue 6 — Generated worker-configuration.d.ts is stale and no longer matches wrangler.jsonc
worker/worker-configuration.d.ts:9 · nit · identified by z-ai/glm-5.3-flash
worker/worker-configuration.d.ts is generated from worker/wrangler.jsonc (wrangler types per its header, hash 8fa6956b4f94dd9c45eaa17f2a294bf2), and the repo's own runbook says to regenerate it on config changes: docs/KNOWLEDGE_COMPOSITION.md line ~186, "Change configuration through review and regenerate Worker types", with the pnpm run worker:types script (which also runs scripts/normalize-worker-types.mjs).
This PR changes the PEGMA_AGENT_CLIENTS_JSON value but leaves the generated file with the old three-client string literal (line 9) and the old generation hash (line 2). Nothing in CI diffs the regenerated file against the checked-in one, so the drift is silent: the checked-in ProcessEnv/Cloudflare.Env types (consumed by worker/tsconfig.json and scripts/tsconfig.support-assistant-stage.json, e.g. scripts/seed-support-assistant-stage.mts) now misdescribe the deployed variable, and the next regeneration will surface a confusing unrelated diff.
I checked .github/workflows/ci.yml (only pnpm run check, pnpm test, pnpm run build) and grepped for any sync check on this file; none exists.
🔵 Issue 7 — KNOWLEDGE_COMPOSITION.md still says three registrations and that the Grok registration is pending
docs/KNOWLEDGE_COMPOSITION.md:150 · nit · identified by z-ai/glm-5.3-flash
docs/KNOWLEDGE_COMPOSITION.md is the operational runbook for exactly this configuration and now contradicts worker/wrangler.jsonc in four places:
- Lines 5-7: "the checked-in profile enables controlled staff authoring qualification with three explicit public client registrations".
- Lines 113-115: "sets
PEGMA_KNOWLEDGE_ENABLED=trueand three explicit public client registrations". - Lines 137-142: the operator table of registrations lists only
pg-kb-codex-accept-v1,pg-kb-claude-accept-v1andpg-kb-device-accept-v1; the newpg-kb-grok-accept-v1row (hosted callback, authorization code with PKCE) is missing, so a tester following the table will not know the Grok registration exists or what it permits. - Lines 149-151: "Hosted Grok Bot and T3 Code registrations and acceptance remain pending" — the Grok registration is no longer pending after this PR (only its acceptance is), so the runbook tells the operator the wrong state.
The doc also instructs reading back the discovery documents and confirming the registrations before client tests (lines ~122-130), so a stale count directly misleads that pre-flight check. I grepped the whole repo for the new client ID and "Grok" to confirm no other doc or test references it; only this doc and the changed config do.
|
Addressed the configured review findings in 177af32.
The original failed assertion and seven findings remain preserved. Qualification results are recorded in the accompanying current-source validation report. Both Node 22.18 and 24.18 passed normal check, test and build. Each ran 1,330 ordinary tests, 155 real D1 tests and two bench tests, with zero skips. The focused registration cases passed all 17 checks. Current-head GitHub CI and OpenRouter follow-up review are running. |
There was a problem hiding this comment.
OpenRouter pull-request review
Verdict: clean
Scope: latest-commit (commit-range)
Mode: verify
Commit: 177af321330b1811443d09c25ca0ef9c5e1e62f7
Judge: openai/gpt-5.6-luna
Cost: $0.0613 (lanes $0.0612 + judge $0.0001)
Lanes
openai/gpt-6.1-sol: ok (0 finding(s), 19.7s, 34223+788 tokens (18284 cached), 2 tool round(s), via Azure, $0.0545)z-ai/glm-5.3-flash: ok (0 finding(s), 61.5s, 218199+5181 tokens (142848 cached), 10 tool round(s), via PrimeIntellect, $0.0067)
Round 2 resolution
- ✅
r1-1fixed correctly — Deployment-blocking three-client assertion: The strict client-array assertion and test title now describe all four checked-in registrations, including the exact Grok HTTPS callback, scopes and authorization-code grant. The hosted callback also has a successful authorization-request case. The test remains included in the Node suite used by both CI and deployment. Read-only inspection confirms the stale assertion is removed; tests were not ex… - ✅
r1-2fixed correctly — Node test pins the exact three-client profile and will fail on the new fourth registration: This duplicates r1-1's stale three-client expectation. The current exact four-client expectation matchesworker/wrangler.jsonc, preserving the existing registrations and their protocol coverage.vitest.config.tsstill includes this test inpnpm testandtest:node, so the fix covers both affected workflow gates. - ✅
r1-3fixed correctly — New hosted redirect URI is untested and one invalid registration disables the whole Agent Access issuer: The tests now construct the complete checked-in profile through the actual runtime using pinned@pegma/agent-access0.1.1, verify both discovery documents, and exercise the Grok HTTPS callback through the authorization endpoint into existing login. Negative cases reject a different callback host or path, PKCE downgrade, resource mismatch and scope escalation before login. This addresses the unte… - 4 nit finding(s) from earlier rounds retired (severity floor for follow-up rounds is
risk). - Open findings after this round: 0 (0 bug-severity).
No structured findings from the successful lane(s).
Change
Register the requested hosted Grok Bot public OAuth client for KB compatibility testing.
The installed Grok Bot 0.79.3 emitted this exact HTTPS redirect during its normal custom Remote HTTPS flow. It also emitted S256, the canonical protected resource and the three existing draft/evidence scopes. The current deployment correctly rejects the unregistered client.
The registration permits authorization-code flow with the existing Admin consent boundary. It supplies no client secret and grants no access by itself. Existing registrations and scope limits are preserved.
Validation
The one changed JSON configuration value was parsed and checked against the observed client, redirect, scopes and grant type. Normal local host checks and current-head GitHub CI/OpenRouter review are pending. Full hosted-client tool and revocation acceptance follows deployment and explicit scoped consent.