Skip to content

test(e2e): rely on setup to build the Codex plugin environment - #2646

Merged
PsiACE merged 1 commit into
oceanbase:masterfrom
Fengzdadi:test/codex-e2e-setup-builds-plugin
Nov 16, 2026
Merged

PsiACE merged 1 commit into
oceanbase:masterfrom
Fengzdadi:test/codex-e2e-setup-builds-plugin

Conversation

@Fengzdadi

Copy link
Copy Markdown
Collaborator

Which issue or RFC does this PR close?

No tracking issue. Follow-up to #2624 (real-host Codex E2E) and #2626 (setup builds the plugin environment).

Rationale for this change

#2624's host E2E built the installed plugin's uv environment itself after powercontext setup codex. Without that step, the MCP header helper and the SessionStart hook built the environment at the same time while Codex started. They ran under different interpreters, and the helper could fail on the half-replaced environment. Since #2626, setup runs the same uv sync --frozen --quiet --project <plugin>, so the test's step only repeats setup's work. It also hides a regression in setup's build, which is the path users get.

Setup's build is only useful if the Codex session reuses it. That holds when setup's uv sync and the session's uv run request the same interpreter:

  • The E2E derives the setup environment and the codex exec environment from the same _isolated_environment. Both carry UV_PYTHON=sys.executable, and both resolve the same uv on PATH. Setup prepends the Codex binary's directory to PATH, and locally that directory holds the same uv that is already first on PATH.
  • The codex-host job in master.yml and the setup-python-env action set no UV_* variable, so CI matches the local run.
  • The MCP header helper runs with Codex's filtered environment, which has no UV_*. With UV_PYTHON unset, uv reuses the existing environment.

What changes are included in this PR?

  • tests/e2e/test_codex_host_service_chain.py: the post-setup uv sync step and its comment are removed. The comments on the uv cache and on UV_PYTHON now say that setup builds the environment and that the hooks reuse it only because they request the same interpreter.
  • Codex integration docs (en/zh): the setup section now says that uv rebuilds the plugin environment when UV_PYTHON names a different interpreter from the one setup used. In that case the first session's SessionStart hook rebuilds it, and that session can start without PowerContext's MCP tools. The docs also say how to avoid it.

Are there any user-facing changes?

The test change is not user-facing. The docs now describe the UV_PYTHON limitation below. Behavior is unchanged.

Known limitation (not fixed here): uv run recreates the plugin's .venv when UV_PYTHON names a different interpreter from the one setup built it with. A Codex session started with such a UV_PYTHON therefore rebuilds the environment once, on its first SessionStart hook, while the MCP header helper may be using it. That first session can miss the PowerContext MCP tools, as before #2626. Later sessions reuse the rebuilt environment. The real fix changes how the plugin runtime chooses its Python, so that the hooks stop depending on the session's UV_PYTHON. That is a separate change.

How was this change tested?

  • CODEX_CLI_BIN=<codex 0.167.2> UV_OFFLINE=1 uv run pytest tests/e2e/test_codex_host_service_chain.py tests/e2e/test_host_model_responses.py -n 5, with real Codex CLI 0.167.2 on macOS arm64, three runs in a row: 6 passed each time (55 s, 43 s, 40 s). The load average was about 40 from other work on the machine. Not run on Linux locally; the codex-host job runs on Linux.

  • In each Codex case of the first run, the installed plugin's .venv and its bin/python were created about 0.4 s before setup returned. Nothing recreated them during the Codex sessions, so the cases ran on setup's build.

  • Control on a copy of the plugin, run offline. It builds the environment as setup does (uv sync --frozen --quiet, UV_PYTHON = the repository's Python 3.13), then runs the hooks' uv run --frozen --quiet --project <plugin> python:

    UV_PYTHON for uv run Result
    same as setup environment reused (same bin/python inode), runs 3.13
    unset, as for the MCP header helper environment reused, runs 3.13
    Python 3.11 environment rebuilt (new inode, pyvenv.cfg 3.11.13), runs 3.11
  • make check passes.

  • Self-review (code-review, high): no findings.

AI usage statement

Claude Code (Claude Opus 5.5) checked the interpreter handling, made the change, ran the verification above and wrote this description.

`powercontext setup codex` builds the installed plugin's uv environment,
so the host E2E's own post-setup `uv sync` repeated setup's work and hid
a regression in it. Setup and the Codex session read the same UV_PYTHON
from the fixture's environment, so the session's hooks reuse what setup
built.

Document that uv rebuilds the plugin environment when Codex starts with
a UV_PYTHON naming a different interpreter from the one setup used, and
that the first session can then miss PowerContext's MCP tools.

@hireview001 hireview001 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hidb4ai hidb4ai 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.

No blocking findings. Removing the redundant post-setup sync makes the host E2E exercise setup's existing plugin environment build, and the bilingual docs accurately describe the interpreter-mismatch limitation. No database tables or interfaces are added.

Validated with Codex CLI 0.167.2 against a real PowerContext Server using fixture models, plus setup/diagnostic tests and interpreter-reuse checks. Live-model, TUI, and Desktop acceptance remain outside this validation.

@PsiACE
PsiACE merged commit 747f040 into oceanbase:master Nov 16, 2026
42 checks passed
@hidb4ai hidb4ai added the 1.6.0 v1.6.0 release tracking label Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1.6.0 v1.6.0 release tracking

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants