Skip to content

fix(codex): name the dynamic-tool loading replacement operation - #137972

Closed
gaoanze888 wants to merge 1 commit into
openclaw:mainfrom
gaoanze888:fix/codex-supervision-operation-rebased
Closed

gaoanze888 wants to merge 1 commit into
openclaw:mainfrom
gaoanze888:fix/codex-supervision-operation-rebased

Conversation

@gaoanze888

Copy link
Copy Markdown

Rebase of #135413 onto current main (59bfe7734). The original branch base was 1300+ commits behind main, causing stale check-lint failures. Cherry-picked onto current main with no conflicts — main did not touch the 2 changed files during that window. Original description below.


Closes #135310

What Problem This Solves

Supervised Codex threads were correctly refused whenever a persisted lifecycle fingerprint drifted from the prepared config, but every refusal reported the same generic Refusing to replace supervised Codex thread <id> while rotating a stale thread binding, hiding which setting actually changed. This PR gives each of the nine lifecycle checks its own cause-specific operation so the refusal names the real mismatch.

Why This Change Was Made

startOrResumeThread reuses one generic "rotating a stale thread binding" operation string at several distinct lifecycle checks. This PR replaces that generic string with a cause-specific operation at each site:

  • changing the app-server runtime identity
  • changing MCP configuration
  • changing web-search configuration
  • changing the context-engine binding
  • changing the user MCP servers
  • changing the network proxy configuration
  • changing the plugin app configuration
  • changing the dynamic tool loading mode
  • changing the dynamic tool catalog

The fail-closed ownership guard (assertCodexBindingMayBeReplaced) and the binding mutation order are unchanged; only the operator-visible operation text is narrowed. Checks that already passed a specific operation (configured MCP ownership, native-tool/delegation-restricted turns, ring-zero, GPT-5.6 multi-agent, ephemeral/plugin-app warm-rotate) are left as-is.

User Impact

Operators and maintainers can now see exactly which configuration drifted (e.g. web search vs. dynamic tools) instead of a generic stale-binding message, without any change to the supervised-binding safety guarantee.

Evidence

Exact head: 3d34631288a61bbcbaefc86e5d5581a8167a46ed.

  • extensions/codex/src/app-server/session-binding.test.ts — new focused regression proving the specific operation is interpolated into the supervised refusal (while changing the dynamic tool loading mode) and that a non-supervised binding is not refused. 55 passed.
  • extensions/codex/src/app-server/thread-lifecycle.binding.test.ts — 136 passed (fail-closed supervised-binding behavior preserved).
  • Production typecheck and check:changed pass for the changed files.

AI Assistance

AI-assisted implementation. I manually verified each lifecycle-check site, the cause-specific operation strings, the unchanged fail-closed guard, the new focused regression, and the changed-file gates.

@clawsweeper

clawsweeper Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 4, 2026
@clawsweeper

clawsweeper Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed September 4, 2026, 2:44 AM ET / 06:44 UTC.

ClawSweeper review

What this changes

The PR replaces generic supervised-thread replacement messages with named configuration causes, while also changing Codex thread-resume and incognito reuse logic.

Regression provenance

Possible regression — probable (reviewed change; known regression link). No predecessor PR is attributed.

Merge readiness

⛔ Blocked before merge - 9 items remain

Keep open: the branch contains build-breaking lifecycle changes beyond the stated diagnostic fix and removes a native-runtime ownership gate from replacement paths.

Priority: P1
Reviewed head: e3efb23d9722f71047dd73093abcc469f2f041e2

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The useful diagnostic intent is blocked by definite production-contract errors and a removed ownership guard.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The PR body reports focused tests and checks, but provides no redacted after-fix run of the changed Codex app-server lifecycle behavior; moreover, the cited head differs from the reviewed head. Add real app-server evidence after correcting the branch, with private details redacted. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🧂 unranked krab (1/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR body reports focused tests and checks, but provides no redacted after-fix run of the changed Codex app-server lifecycle behavior; moreover, the cited head differs from the reviewed head. Add real app-server evidence after correcting the branch, with private details redacted. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 5 items Introduced compile break: The branch imports two names that the local lifecycle-adoption module neither exports nor defines, then passes unsupported fields instead of the required resume preparation callbacks.
Current ownership invariant: Current main passes expected session runtime ownership to every replacement check and to the fresh-thread check; the PR removes those arguments.
Existing regression contract: The lifecycle suite explicitly requires expected native ownership to reject native-tool or delegation restrictions without issuing thread/start or changing the binding.
Findings 2 actionable findings [P1] Restore the lifecycle resume API contract
[P1] Keep expected native ownership on replacement paths
Security Needs attention Native-owned sessions can lose their replacement fence: Removing the expected ownership argument permits a valid native-owned host-connection binding to pass the supervision-only check, be cleared for a restriction change, and proceed toward a fresh thread.

How this fits together

The Codex plugin maps an OpenClaw turn to a persisted app-server thread binding, then resumes or rotates that binding when configuration changes. The lifecycle guard prevents a native-owned thread from being replaced with a host-selected thread.

flowchart LR
  A[OpenClaw turn] --> B[Codex thread lifecycle]
  B --> C[Persisted thread binding]
  C --> D{Configuration compatible?}
  D -->|No| E[Refuse or rotate binding]
  D -->|Yes| F[Resume app-server thread]
  E --> G[Operator diagnostic]
  F --> G
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR body reports focused tests and checks, but provides no redacted after-fix run of the changed Codex app-server lifecycle behavior; moreover, the cited head differs from the reviewed head. Add real app-server evidence after correcting the branch, with private details redacted. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Restore the lifecycle resume API contract (P1) - thread-lifecycle-adoption.ts has a private assertAdoptedCodexThreadResumeAllowed and exports prepareCodexThreadResume, not either imported name. The new call also omits required prepareResume and releaseRetainedThread fields from CodexResumeThreadContext, so this production file cannot type-check. Remove this unrelated rewrite or update its owning modules coherently.
  • Keep expected native ownership on replacement paths (P1) - This drops expectedSessionRuntimeOwnership before the native-tool restriction path. A binding that passed the initial ownership check can now be cleared and reach the fresh-thread path; current coverage requires that exact native-owned case to fail before thread/start. Continue passing the expected ownership to every replacement check and retain the final fresh-start assertion.
  • Resolve security concern: Native-owned sessions can lose their replacement fence - Removing the expected ownership argument permits a valid native-owned host-connection binding to pass the supervision-only check, be cleared for a restriction change, and proceed toward a fresh thread.
  • Resolve merge risk (P1) - If the import/type errors are repaired without restoring the removed expected-ownership arguments, a native-owned host-connection binding can be cleared and replaced after a restriction change rather than failing closed.
  • Complete next step (P2) - Restore the lifecycle resume contract and expected native-ownership checks before merge, then provide redacted real app-server proof.
  • Improve patch quality - Restore the existing lifecycle resume API contract or split the unrelated rewrite out.
  • Improve patch quality - Reinstate expected native-ownership checks for every replacement and fresh-start path.
  • Improve patch quality - After correction, add a redacted real app-server trace showing the named refusal and preserved binding; updating the PR body should trigger a new review, or a maintainer can request @clawsweeper re-review.

Findings

  • [P1] Restore the lifecycle resume API contract — extensions/codex/src/app-server/thread-lifecycle-run.ts:35-39
  • [P1] Keep expected native ownership on replacement paths — extensions/codex/src/app-server/thread-lifecycle-run.ts:493
  • [medium] Native-owned sessions can lose their replacement fence — extensions/codex/src/app-server/thread-lifecycle-run.ts:493
Agent review details

Security

Needs attention: The branch removes a fail-closed native-runtime ownership check from thread replacement paths.

PR surface

Source +14, Tests +18. Total +32 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 78 64 +14
Tests 1 52 34 +18
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 130 98 +32

Review metrics

Metric Value Why it matters
Production versus test delta production +14, tests +18 The production growth includes a distinct resume-path rewrite beyond the stated operator-message repair.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #135310
Summary: This PR is a candidate implementation of the linked supervised-binding diagnostic issue.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Restore the narrow diagnostic patch (recommended)
    Remove the introduced resume rewrite, restore the existing ownership arguments, and keep only the cause-specific refusal messages plus focused coverage.
  2. Separate and prove resume changes
    Move the resume rewrite to a separate PR with complete API updates and boundary proof for native ownership, subscriptions, and incognito reuse.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Restore the current lifecycle resume API and expected native-ownership checks; retain only the named diagnostic-operation changes and focused regression coverage.

Technical review

Best possible solution:

Restore the current lifecycle resume contract and retain only the cause-specific diagnostic strings needed by the linked issue, preserving every expected native-ownership refusal path.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: the imported lifecycle names are absent and the resume call no longer satisfies its required context contract, so production type checking can reproduce the failure without running untrusted contributor code.

Is this the best way to solve the issue?

No: restoring the existing lifecycle contract and applying the diagnostic wording as a narrow patch is safer than combining it with unrequested resume behavior.

Full review comments:

  • [P1] Restore the lifecycle resume API contract — extensions/codex/src/app-server/thread-lifecycle-run.ts:35-39
    thread-lifecycle-adoption.ts has a private assertAdoptedCodexThreadResumeAllowed and exports prepareCodexThreadResume, not either imported name. The new call also omits required prepareResume and releaseRetainedThread fields from CodexResumeThreadContext, so this production file cannot type-check. Remove this unrelated rewrite or update its owning modules coherently.
    Confidence: 0.99
  • [P1] Keep expected native ownership on replacement paths — extensions/codex/src/app-server/thread-lifecycle-run.ts:493
    This drops expectedSessionRuntimeOwnership before the native-tool restriction path. A binding that passed the initial ownership check can now be cleared and reach the fresh-thread path; current coverage requires that exact native-owned case to fail before thread/start. Continue passing the expected ownership to every replacement check and retain the final fresh-start assertion.
    Confidence: 0.97

Overall correctness: patch is incorrect
Overall confidence: 0.99

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against fcdd8533696b.

Labels

Label changes:

  • add P1: The branch both fails the production TypeScript contract and weakens the native-owned thread replacement invariant.
  • add merge-risk: 🚨 session-state: The changed code decides whether a persisted thread binding resumes, is cleared, or is replaced.
  • add merge-risk: 🚨 auth-provider: Expected native model and connection ownership is no longer passed to replacement guards.
  • add merge-risk: 🚨 security-boundary: The removed guard is the fail-closed boundary that prevents a native-prepared session from becoming a replacement thread.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦪 silver shellfish and patch quality is 🧂 unranked krab.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body reports focused tests and checks, but provides no redacted after-fix run of the changed Codex app-server lifecycle behavior; moreover, the cited head differs from the reviewed head. Add real app-server evidence after correcting the branch, with private details redacted. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Label justifications:

  • P1: The branch both fails the production TypeScript contract and weakens the native-owned thread replacement invariant.
  • merge-risk: 🚨 session-state: The changed code decides whether a persisted thread binding resumes, is cleared, or is replaced.
  • merge-risk: 🚨 auth-provider: Expected native model and connection ownership is no longer passed to replacement guards.
  • merge-risk: 🚨 security-boundary: The removed guard is the fail-closed boundary that prevents a native-prepared session from becoming a replacement thread.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦪 silver shellfish and patch quality is 🧂 unranked krab.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body reports focused tests and checks, but provides no redacted after-fix run of the changed Codex app-server lifecycle behavior; moreover, the cited head differs from the reviewed head. Add real app-server evidence after correcting the branch, with private details redacted. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

Security concerns:

  • [medium] Native-owned sessions can lose their replacement fence — extensions/codex/src/app-server/thread-lifecycle-run.ts:493
    Removing the expected ownership argument permits a valid native-owned host-connection binding to pass the supervision-only check, be cleared for a restriction change, and proceed toward a fresh thread.
    Confidence: 0.97

Acceptance criteria:

  • [P1] pnpm test extensions/codex/src/app-server/session-binding.test.ts.
  • [P1] pnpm test extensions/codex/src/app-server/thread-lifecycle.binding.test.ts.
  • [P1] pnpm test extensions/codex/src/app-server/thread-lifecycle.test.ts.
  • [P1] pnpm check:changed -- extensions/codex/src/app-server/session-binding.test.ts extensions/codex/src/app-server/thread-lifecycle-run.ts.

What I checked:

  • Introduced compile break: The branch imports two names that the local lifecycle-adoption module neither exports nor defines, then passes unsupported fields instead of the required resume preparation callbacks. (extensions/codex/src/app-server/thread-lifecycle-run.ts:35, e3efb23d9722)
  • Current ownership invariant: Current main passes expected session runtime ownership to every replacement check and to the fresh-thread check; the PR removes those arguments. (extensions/codex/src/app-server/thread-lifecycle-run.ts:241, fcdd8533696b)
  • Existing regression contract: The lifecycle suite explicitly requires expected native ownership to reject native-tool or delegation restrictions without issuing thread/start or changing the binding. (extensions/codex/src/app-server/thread-lifecycle.test.ts:3623, fcdd8533696b)
  • Codex app-server contract inspected: The locally available Codex sibling source shows that loaded-thread resume overrides can be ignored when the thread remains observed, supporting OpenClaw's existing teardown/ownership checks; its local-cache remote does not independently verify repository ownership. (codex-rs/app-server/src/request_processors/thread_processor.rs:4167, 41e22fee981a63b3698df7ed36bad393cda24715)
  • Verified introduced scope: The merge-base-to-head diff contains the extra resume rewrite as well as the diagnostic wording changes. (extensions/codex/src/app-server/thread-lifecycle-run.ts:633, e3efb23d9722)

Likely related people:

  • TheAngryPit: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@gaoanze888

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: codex merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Codex supervision errors hide the incompatible binding policy

1 participant