Skip to content

[codex] Add auth profile runtime contracts - #71029

Closed
100yenadmin wants to merge 7 commits into
openclaw:mainfrom
electricsheephq:contract-first/auth-profile-runtime-contracts
Closed

100yenadmin wants to merge 7 commits into
openclaw:mainfrom
electricsheephq:contract-first/auth-profile-runtime-contracts

Conversation

@100yenadmin

@100yenadmin 100yenadmin commented Apr 24, 2026 •

Copy link
Copy Markdown
Contributor

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.

flowchart TD
  Manifest["Provider auth alias manifest"] --> Resolver["resolveProviderIdForAuth"]
  Session["Session auth profile override"] --> AuthContract["Auth/profile runtime contract"]
  Resolver --> AuthContract
  AuthContract --> PiCli["Pi / CLI command adapter"]
  AuthContract --> Codex["Codex app-server adapter"]
  PiCli --> Forward["Forward matching profile"]
  PiCli --> NoLeak["No unrelated-provider leakage"]
  Codex --> Startup["Pass exact profile to startup"]
  Codex --> Resume["Reuse or override persisted binding"]
Loading

Files Changed And Why

File Purpose
test/helpers/agents/auth-profile-runtime-contract.ts Shared constants and real alias-resolver expectation helper.
src/agents/auth-profile-runtime-contract.test.ts Pi/CLI command-path forwarding and no-leak matrix.
extensions/codex/src/app-server/auth-profile-runtime-contract.test.ts Codex app-server startup/resume binding behavior.

Contract Matrix

Path Covered behavior
Auth alias resolver openai, openai-codex, codex-cli, and codex resolve through real resolveProviderIdForAuth using mocked plugin-manifest metadata.
Pi / CLI command adapter codex-cli forwards existing openai-codex:* profiles through canonical and legacy auth-provider aliases.
Pi / CLI command adapter codex-cli/* does not inherit a direct openai:* API-key profile.
Pi / CLI command adapter Unrelated CLI providers do not inherit OpenAI-Codex profiles.
Embedded Pi adapter openai-codex/* forwards matching openai-codex:* profiles through canonical and legacy aliases.
Embedded Pi adapter openai/* forwards matching openai:* profiles and does not inherit openai-codex:* profiles.
Codex app-server adapter Runtime authProfileId reaches app-server startup unchanged.
Codex app-server adapter Persisted app-server binding is reused on resume when params omit authProfileId.
Codex app-server adapter Explicit runtime profile overrides stale persisted binding and rewrites the binding.

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.

Future row Why not green here
Preserve OpenAI-Codex profiles through the real codex/* harness startup path. Requires full embedded runner + harness selection + auth bootstrap path.
Validate openai/* forced through the Codex harness can use OpenAI-Codex OAuth profiles. Crosses model selection, forced harness policy, and auth-provider validation.

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

  • Test-only, no production auth code changes.
  • App-server tests prove exact startup/resume behavior, while TODOs honestly mark the deeper harness-path coverage still needed.
  • This captures the audit’s Bug 8 class without trying to fix runtime behavior in Phase 1.

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 todo
  • node 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.ts
  • git 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.ts

Refs #71004
Follows #71009

@100yenadmin
100yenadmin marked this pull request as ready for review April 24, 2026 09:15
@100yenadmin
100yenadmin requested a review from a team as a code owner April 24, 2026 09:15
Copilot AI review requested due to automatic review settings April 24, 2026 09:15
@greptile-apps

greptile-apps Bot commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds test-only auth/profile runtime contract coverage for the Pi/CLI command adapter and the Codex app-server adapter, locking down the openai-codex:* profile forwarding semantics before later refactors move policy into a shared runtime plan. All three new files follow existing contract-test conventions cleanly.

Confidence Score: 5/5

Safe 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 AI
This 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

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.

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.

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.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 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".

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.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

@steipete

Copy link
Copy Markdown
Contributor

Closing as superseded by #71096, which consolidates this contract shard into the single RuntimePlan / Pi-Codex parity review branch.

Codex review note: keeping the individual shard open would split the same contract surface across multiple stale branches now that #71096 carries the combined stack.

@steipete steipete closed this Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling extensions: codex size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants