Skip to content

fix(codex): release exact closed thread handoffs - #180204

Merged
RomneyDa merged 1 commit into
mainfrom
openclaw/remediate-session-admission
Oct 22, 2026
Merged

RomneyDa merged 1 commit into
mainfrom
openclaw/remediate-session-admission

Conversation

@RomneyDa

Copy link
Copy Markdown
Member

What Problem This Solves

A Codex thread handoff waits for the retired app-server process to exit. Unrelated sibling leases can keep that process alive after the exact target thread has closed, blocking scheduled or interactive continuation indefinitely.

User Impact

A successor can continue once the old physical client reports the exact target thread closed, while unrelated sibling sessions keep using that process. Ownership loss without a closure signal still preserves process-exit writer fencing.

What Changed

  • record bounded, physical-client-scoped exact thread/closed receipts across same-build module copies
  • race retired process exit against the exact target closure and clean listeners on every path
  • clear stale receipts only after successful new thread retention
  • cover closure before and after listener registration plus the no-closure negative control

Validation

  • focused Codex lifecycle/runtime tests: 33 passed
  • extension production and test typechecks
  • touched-file typed lint and format
  • independent P0-P2 review: no findings

This extracts the exact-thread handoff repair from #174967 while leaving its busy-message behavior decision and security-sensitive changes out. #178764 already covers scheduled session admission; #177351 is Goal/autonomy scope and is intentionally not included.

Limits: synthetic in-process app-server transport; no live Codex binary integration. Exact-head PR CI supplies broad proof.

@clawsweeper

clawsweeper Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@RomneyDa
RomneyDa force-pushed the openclaw/remediate-session-admission branch 2 times, most recently from eec6cd9 to 98d6fb2 Compare October 22, 2026 03:02
Let a successor resume after the retired physical client reports the exact thread closed, without waiting for unrelated sibling leases to terminate the whole process. Retain process-exit fencing when ownership merely disappears, and cover both notification orderings.

Co-authored-by: Paul Bohm <[email protected]>

Co-authored-by: RomneyDa <[email protected]>
@RomneyDa
RomneyDa force-pushed the openclaw/remediate-session-admission branch from 98d6fb2 to ae872ec Compare October 22, 2026 03:02
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 22, 2026
@clawsweeper

clawsweeper Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR remembers exact thread-closure notifications so a later handoff can proceed while sibling sessions keep the retired process alive.

Example: The old client reports thread-a closed before its handoff listener is registered, while thread-b keeps that process alive.

  • Before: The successor misses the notification and waits for the old process to exit.
  • After: The successor finds thread-a's recorded closure and can resume without stopping thread-b.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The narrow patch has no identified correctness defect and green exact-head checks, but supplied proof does not meet the repository's production-path requirement.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A scheduled or interactive continuation can remain blocked after its target native thread has closed because another session keeps the old process alive.
Reason: This maintainer-authored repair completes the existing exact-thread handoff direction without adopting the linked PR's broader scheduling changes.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR addresses an early-closure handoff gap still present on main, and inspection found no concrete introduced defect.

Priority: P2
Reviewed head: ae872ec029c718fe57603e82184aff51a5a533dc

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Show early closure followed by successor resume through the real Codex app-server while a sibling remains usable, including the no-closure fencing control; base-red/head-green execution of the new regression is not recorded.
Agent review details

How this fits together

The Codex plugin's lifecycle layer transfers native-thread ownership between physical app-server clients, consuming closure notifications and client leases before allowing successor resume requests.

flowchart TD
  A[Native app server] --> B[Client notification dispatch]
  B --> C[Physical client closure receipts]
  B --> D[Live thread ownership]
  C --> E[Thread handoff]
  D --> E
  F[Retired process exit] --> E
  E --> G[Successor thread resume]
Loading

Technical review

Best possible solution:

Remember closure on the original physical client and consult it in the existing handoff while preserving process-exit fencing when no exact receipt exists.

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

Source shows that closure delivered before handoff registration is forgotten on main, leaving the handoff waiting for process exit while a sibling lease remains; no target code was executed during this review.

Is this the best way to solve the issue?

The patch narrowly extends the existing handoff contract with bounded, build-shared, physical-client-scoped receipts while retaining claimed-thread, protected-thread, cancellation, and no-closure fencing.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 461123273058.

Provenance checked

  • Exact-thread handoff keeps the original intent (f83b7ad: Allow a successor after exact native-thread shutdown without requiring unrelated sibling sessions to terminate.)
  • Physical-client runtime and retention keeps the original intent (5a79d19: Preserve independent warm conversations and retire only their exact physical-client/thread ownership; later same-build sharing preserves that original owner.)
  • Cancellation and writer fencing keeps the original intent (92eba62: Cancellation releases the abandoned queue and binding lease while successors independently retain physical-exit fencing.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Paul Bohm: Raw commit f83b7ad adds extensions/codex/src/app-server/thread-lifecycle-warm.ts:186 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: f83b7ade15f3; files: extensions/codex/src/app-server/thread-lifecycle-warm.ts)
  • Peter Steinberger: Raw commit 5a79d19 adds extensions/codex/src/app-server/client-runtime.ts:55 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 5a79d19ba179; files: extensions/codex/src/app-server/client-runtime.ts)
  • Dallin Romney: Raw commit 92eba62 adds extensions/codex/src/app-server/thread-lifecycle-warm.ts:156 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 92eba62bdfd7; files: extensions/codex/src/app-server/thread-lifecycle-warm.ts)

PR surface

Source +60, Tests +56. Total +116 across 6 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 60 0 +60
Tests 3 65 9 +56
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 125 9 +116

Review metrics

Metric Value Why it matters
Production versus test LOC Production +60; tests +65/-9 The growth implements bounded closure memory and distinct early-closure and no-closure controls without changing public configuration or persisted formats.

Labels

Label changes:

  • add P2: A specific Codex client-rotation ordering can stall continuation while unrelated sibling leases keep the retired process alive.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: A specific Codex client-rotation ordering can stall continuation while unrelated sibling leases keep the retired process alive.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 21, 2026, 11:21 PM ET / October 22, 2026, 03:21 UTC.

@RomneyDa
RomneyDa merged commit a09a59e into main Oct 22, 2026
116 checks passed
@RomneyDa
RomneyDa deleted the openclaw/remediate-session-admission branch October 22, 2026 22:49
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 23, 2026
Let a successor resume after the retired physical client reports the exact thread closed, without waiting for unrelated sibling leases to terminate the whole process. Retain process-exit fencing when ownership merely disappears, and cover both notification orderings.

Co-authored-by: roboclaw-bot <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
@RomneyDa

Copy link
Copy Markdown
Member Author

Live proof receipt

Validated the merged fix against the pinned real Codex 0.162.1 app-server binary (not the in-process fake transport).

Scenario:

  • launch two physical app-server clients;
  • start a target thread and a sibling thread on the retiring process;
  • retain the sibling lease so the old process stays alive;
  • close only the target thread and observe the real thread/closed receipt;
  • hand the target to the successor client;
  • verify the sibling remains readable on the old process;
  • verify an unclosed control thread remains fenced.

Results:

  • Parent 72ad5e9dd83e: RED — failed with exact closure did not release handoff.
  • Merged head ae872ec029c7: GREEN — 1/1 passed; the exact target resumed while the sibling stayed live and the unclosed control remained fenced.

This directly reproduces the reported sibling-lease blocker and distinguishes the fix from a process-exit-only test. No follow-up fix was needed.

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

Labels

extensions: codex P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants