Repository navigation
[codex] Add auth profile runtime contracts - #71029
100yenadmin wants to merge 7 commits into
Conversation
Greptile SummaryThis PR adds test-only auth/profile runtime contract coverage for the Pi/CLI command adapter and the Codex app-server adapter, locking down the Confidence Score: 5/5Safe to merge — all remaining findings are P2 style/clarity issues with no impact on correctness or production behavior. The PR is intentionally test-only and introduces no production code changes. The contract assertions correctly cover startup, resume, override, and no-leak paths. All three inline comments are P2 (naming clarity, redundant delete, static helper divergence risk) and do not affect test correctness. No files require special attention. Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/agents/auth-profile-runtime-contract.test.ts
Line: 213-218
Comment:
**Test description implies real registry, but registry is mocked**
The test is titled "resolves codex-cli through the real provider auth alias registry," but `loadPluginManifestRegistry` is mocked via `vi.mock` to return `createAuthAliasManifestRegistry()`. The _resolver function_ (`resolveProviderIdForAuth`) is real, but the data source is synthetic. A future maintainer modifying the bundled manifest will not see this test react unless the `createAuthAliasManifestRegistry` fixture is updated in lockstep. Consider renaming to something like "resolves codex-cli through the real resolver using a mocked manifest" to keep the intent clear.
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: test/helpers/agents/auth-profile-runtime-contract.ts
Line: 14-18
Comment:
**Static alias mapping can silently diverge from production**
`resolveContractAuthProvider` hardcodes only the single `codex-cli → openai-codex` mapping. If new deprecated provider IDs are registered in `providerAuthChoices.deprecatedChoiceIds` in production, the helper will not pick them up, and `expectedForwardedAuthProfile` callers may assert against a stale expected value. Since the production logic uses `resolveProviderIdForAuth` (which reads the mocked registry), the two paths are kept in sync only as long as `createAuthAliasManifestRegistry` and this helper are manually updated together.
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: extensions/codex/src/app-server/auth-profile-runtime-contract.test.ts
Line: 166-167
Comment:
`createParams` never sets `authProfileId`, so the property is already absent on the returned object. The `delete` call is a no-op and may mislead readers into thinking `createParams` populates this field.
```suggestion
// authProfileId intentionally omitted to exercise the "resume uses bound profile" path
const params = createParams(sessionFile, tmpDir);
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "test: strengthen auth profile runtime co..." | Re-trigger Greptile |
There was a problem hiding this comment.
Pull request overview
Adds contract-first tests to lock down current auth-profile forwarding semantics across the Pi/CLI command adapter and the Codex app-server adapter, ensuring codex-cli and openai-codex share the same session-bound profile behavior without leaking profiles to unrelated providers.
Changes:
- Added a shared auth/profile contract fixture for consistent test inputs and expected forwarding behavior.
- Added Pi/CLI adapter contract tests covering auth alias resolution and profile forwarding/non-leakage.
- Added Codex app-server adapter contract tests covering startup, resume binding reuse, and explicit override precedence for
authProfileId.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| test/helpers/agents/auth-profile-runtime-contract.ts | Shared constants + expected forwarding helper used by Pi/CLI and Codex adapter tests. |
| src/agents/auth-profile-runtime-contract.test.ts | Contract tests for Pi/CLI runAgentAttempt auth alias resolution and profile forwarding behavior. |
| extensions/codex/src/app-server/auth-profile-runtime-contract.test.ts | Contract tests ensuring Codex app-server startup/resume uses and persists the correct authProfileId. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 819fe28cab
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Summary
Adds the auth/profile contract rung from RFC #71004. This is test-only: it locks current auth/profile forwarding invariants across the Pi/CLI command path and the Codex app-server adapter before later PRs move auth policy into
AgentRuntimePlan.No production auth behavior changes in this PR.
Files Changed And Why
test/helpers/agents/auth-profile-runtime-contract.tssrc/agents/auth-profile-runtime-contract.test.tsextensions/codex/src/app-server/auth-profile-runtime-contract.test.tsContract Matrix
openai,openai-codex,codex-cli, andcodexresolve through realresolveProviderIdForAuthusing mocked plugin-manifest metadata.codex-cliforwards existingopenai-codex:*profiles through canonical and legacy auth-provider aliases.codex-cli/*does not inherit a directopenai:*API-key profile.openai-codex/*forwards matchingopenai-codex:*profiles through canonical and legacy aliases.openai/*forwards matchingopenai:*profiles and does not inheritopenai-codex:*profiles.authProfileIdreaches app-server startup unchanged.authProfileId.Known Red Rows
These are explicit TODOs because proving them end-to-end requires the shared runtime-plan/harness-adapter phase or a targeted production fix, not more fixture-only assertions.
codex/*harness startup path.openai/*forced through the Codex harness can use OpenAI-Codex OAuth profiles.How This Helps The RuntimePlan Work
The shared plan should resolve auth provider identity once and hand both adapters a stable auth profile decision. These tests define the expected behavior before that policy moves.
Reviewer Notes
Verification
node scripts/run-vitest.mjs run --config test/vitest/vitest.agents.config.ts src/agents/auth-profile-runtime-contract.test.ts— 12 passed, 2 todonode scripts/run-vitest.mjs run --config test/vitest/vitest.extensions.config.ts extensions/codex/src/app-server/auth-profile-runtime-contract.test.ts— 3 passed./node_modules/.bin/oxlint --tsconfig tsconfig.oxlint.core.json test/helpers/agents/auth-profile-runtime-contract.ts src/agents/auth-profile-runtime-contract.test.ts extensions/codex/src/app-server/auth-profile-runtime-contract.test.tsgit diff --check -- test/helpers/agents/auth-profile-runtime-contract.ts src/agents/auth-profile-runtime-contract.test.ts extensions/codex/src/app-server/auth-profile-runtime-contract.test.tsRefs #71004
Follows #71009