Skip to content

feat(codex): bind a checkout to an existing Scope - #1760

Merged
Teingi merged 4 commits into
oceanbase:masterfrom
knqiufan:feat/codex-workspace-bind-scope
Sep 28, 2026
Merged

Teingi merged 4 commits into
oceanbase:masterfrom
knqiufan:feat/codex-workspace-bind-scope

Conversation

@knqiufan

@knqiufan knqiufan commented Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator

Which issue or RFC does this PR close?

Closes #1759. Follows RFC 1345's server-owned Scope identity and explicit workspace binding contract.

Rationale for this change

Codex can select one process-wide Scope or freeze the current Session, but it lacks the checkout binding command already available in Claude Code and WorkBuddy. Without it, new sessions in separate projects fall back to Default; MCP set_scope_binding only changes the current Session.

What changes are included in this PR?

  • Add bind_scope, clear_scope_binding, --bind-scope, and --clear-scope to the Codex scope script. The stored key uses integration=codex, kind=workspace, and the existing Git-root path hash.
  • With only --cwd, print the effective directory Scope without writing a Session binding. Bind an existing server-assigned Scope; never create a Scope or derive its ID from a path, remote, or branch.
  • Document the commands in both integration guides and route checkout-binding requests from the Skill entry point. Explain plugin path discovery, clearing, and verification when an explicit Scope variable overrides the workspace binding.
  • Add a real HTTP/SQLite service-chain test invoking the CLI and hook subprocesses. Cover Git-root/subdirectory readback, repository isolation, old/new sessions, explicit Scope precedence, invalid Scope rejection, mutually exclusive flags, repeated clearing, retained Session bindings, and unchanged Scope records.

Are there any user-facing changes?

Users can persist a checkout to an existing Scope for later sessions. POWERCONTEXT_CODEX_SCOPE_ID retains precedence, and existing Session bindings remain intact. MCP binding tools still target the current Session. No API or persisted-format changes.

How was this change tested?

  • With loopback requests bypassing the local proxy: uv run pytest -q tests/codex_plugin tests/e2e/test_codex_service_chain.py — 242 passed, 6 skipped.
  • uv run prek run -a with PREK_SKIP=ty-check — passed; type checking ran separately below.
  • uv run ty check --python-platform linux --exclude docs/my — passed. Default local type checking includes unrelated untracked research scripts and Linux-only APIs on Windows.
  • uv lock --check and git diff --check — passed.

The service-chain test uses the real HTTP server and SQLite with direct CLI/hook invocation; it does not establish acceptance inside the real Codex UI or against OceanBase.

AI usage statement

Grok 4.7 assisted with implementation, tests, and documentation. OpenAI Codex assisted with review, Skill guidance, service-chain coverage, and validation.

Codex could only pin one process-wide Scope or the current session. Persist a workspace binding so a later session in that Git root resolves the chosen Scope.
ty rejects subscripting the request payload object. Compare the recorded binding with the typed workspace key instead.
@knqiufan
knqiufan marked this pull request as ready for review September 28, 2026 06:52

@Alanxtl Alanxtl 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

@Teingi
Teingi merged commit e597899 into oceanbase:master Sep 28, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add a Codex workspace --bind-scope command

2 participants