Skip to content

improve(macos): reuse the Codex App Server client - #116325

Merged
vincentkoc merged 5 commits into
mainfrom
perf/kova-stack-07-codex-client
Jul 31, 2026
Merged

vincentkoc merged 5 commits into
mainfrom
perf/kova-stack-07-codex-client

Conversation

@vincentkoc

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes an issue where every macOS Codex thread list or transcript read started a fresh Codex App Server process and repeated its initialization handshake.

Stack position: 7 of 7. Base: perf/kova-stack-06-claude-catalog.

Why This Change Was Made

The macOS node runtime now owns a serialized App Server client that reuses one initialized connection for bounded requests. It has a 30-second idle lifetime, a 64-request queue bound, bounded idle output, and restarts after invocation changes, process exit, timeout, or caller cancellation.

User Impact

Repeated Codex catalog operations avoid process startup and initialization round trips while retaining existing request validation, deadlines, cancellation, and error behavior.

Evidence

  • Focused macOS proof: MacNodeCodexThreadCatalogTests and MacNodeRuntimeTests passed as part of 98 tests across 7 suites
  • Covers connection reuse, handshake, queueing, idle shutdown, invocation/process changes, timeout, cancellation, oversized output, large frames, and deinitialization
  • Dependency contract checked against the upstream Codex App Server connection lifecycle and request dispatcher
  • SwiftFormat: clean
  • Final autoreview: clean, 0.90 confidence
  • TruffleHog: clean

AI assistance: Codex was used for investigation, implementation, and review. The resulting changes and evidence were manually inspected.

@vincentkoc vincentkoc self-assigned this Jul 30, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added app: macos App: macos size: XL maintainer Maintainer-authored PR labels Jul 30, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Jul 30, 2026
@clawsweeper

clawsweeper Bot commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 30, 2026, 10:36 PM ET / July 31, 2026, 02:36 UTC.

ClawSweeper review

What this changes

The PR changes macOS Codex thread-list and transcript reads from launching a fresh Codex App Server process each time to using one bounded, serialized client that reuses an initialized connection.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep this PR open for human maintainer review. It is member-authored and carries the protected maintainer label; its shared client deliberately changes macOS lifecycle and failure isolation, so it should not be auto-closed or auto-landed despite focused test evidence.

Priority: P2
Reviewed head: 537f45944e210a3bcd06772a64a884f498c4efd7
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch has substantial focused lifecycle coverage in the supplied evidence, but the large shared-process ownership change still needs a macOS maintainer’s acceptance.
Proof confidence 🌊 off-meta tidepool Not applicable: This member-authored macOS runtime PR is exempt from the external-contributor proof gate; the PR nonetheless reports focused native test coverage for the changed lifecycle behavior.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This member-authored macOS runtime PR is exempt from the external-contributor proof gate; the PR nonetheless reports focused native test coverage for the changed lifecycle behavior.
Evidence reviewed 5 items Protected maintainer handling: The PR is authored by a repository MEMBER and is labeled maintainer; repository review policy requires such items to remain open for explicit maintainer judgment.
Shared-client implementation: The PR adds MacNodeCodexThreadCatalogClient and CodexAppServerThreadClient, while MacNodeRuntime receives a persistent catalog client instead of defaulting both requests to one-shot catalog helpers.
Lifecycle coverage claimed: The PR body and author follow-up describe focused coverage for reuse, queue deadlines, cancellation, timeout, process exit, invocation changes, frame limits, idle shutdown, and deinitialization.
Findings None None.
Security None None.

How this fits together

The macOS node runtime serves catalog requests for stored Codex threads and transcripts. This change inserts a reusable App Server connection between those requests and the Codex executable, then resets or stops that connection for cancellation, timeout, exit, invocation changes, and idle shutdown.

flowchart LR
  A[macOS catalog request] --> B[Mac node runtime]
  B --> C[Shared bounded client]
  C --> D[Codex App Server process]
  D --> E[Initialized connection]
  E --> F[Thread list or transcript result]
  C --> G[Timeout cancellation exit or idle reset]
Loading

Decision needed

Question Recommendation
Should the Mac node runtime remain the lifecycle owner for a single serialized Codex App Server client used only by stored thread and transcript reads? Accept the bounded read-only owner: Approve the Mac node runtime as owner for the serialized catalog client, retaining resets for timeout, cancellation, process exit, invocation changes, and idle shutdown.

Why: The shared client is a deliberate macOS ownership and failure-isolation boundary; source tests can validate mechanics, but maintainers must accept the persistent-process scope and exclusion of turn-driving methods.

Before merge

  • Resolve merge risk (P1) - A serialized shared App Server process changes failure isolation: cancellation, deadline expiry, process exit, invocation changes, and shutdown can reset the connection used by later catalog reads.
  • Resolve merge risk (P1) - The PR is behind current main; maintainers should refresh the merge result and confirm the stacked predecessor order before landing.
Agent review details

Security

None.

PR surface

Other +841. Total +841 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 4 1238 397 +841
Total 4 1238 397 +841

Review metrics

Metric Value Why it matters
Shared process lifecycle 1 shared client; 30-second idle lifetime; 64-request queue bound These bounds define the availability and backpressure behavior that replaces one-process-per-read isolation.

Merge-risk options

Maintainer options:

  1. Approve the bounded client boundary (recommended)
    After reviewing the refreshed merge result, accept the read-only shared-client lifecycle and its reset semantics for catalog requests.
  2. Require stronger isolation
    Keep per-request processes or narrow the client further if maintainers do not want later reads to share reset and shutdown consequences.

Technical review

Best possible solution:

Keep one bounded client only for read-only stored-thread catalog operations, preserve the documented reset and deadline behavior, and obtain macOS/Codex-owner approval after refreshing the merge result against current main.

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

Yes, from the PR’s described source path: prior macOS list and transcript reads invoked one-shot catalog helpers, while the branch routes them through a persistent client. The provided context reports focused tests, but this read-only review did not independently execute the macOS runtime.

Is this the best way to solve the issue?

Unclear: a bounded, read-only shared connection matches the reported repeated-handshake cost and the author’s upstream-contract review, but maintainers must decide whether the Mac node runtime is the right lifecycle owner for the resulting shared failure boundary.

AGENTS.md: unclear because the file could not be read completely.

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

Labels

Label justifications:

  • P2: This is a bounded macOS performance and lifecycle improvement with meaningful but non-emergency operator impact.
  • merge-risk: 🚨 availability: A shared serialized subprocess can affect subsequent catalog reads when the connection is reset by cancellation, timeout, exit, invocation changes, or shutdown.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This member-authored macOS runtime PR is exempt from the external-contributor proof gate; the PR nonetheless reports focused native test coverage for the changed lifecycle behavior.

Evidence

What I checked:

  • Protected maintainer handling: The PR is authored by a repository MEMBER and is labeled maintainer; repository review policy requires such items to remain open for explicit maintainer judgment. (537f45944e21)
  • Shared-client implementation: The PR adds MacNodeCodexThreadCatalogClient and CodexAppServerThreadClient, while MacNodeRuntime receives a persistent catalog client instead of defaulting both requests to one-shot catalog helpers. (apps/macos/Sources/OpenClaw/NodeMode/MacNodeCodexThreadCatalogClient.swift:4, 537f45944e21)
  • Lifecycle coverage claimed: The PR body and author follow-up describe focused coverage for reuse, queue deadlines, cancellation, timeout, process exit, invocation changes, frame limits, idle shutdown, and deinitialization. (apps/macos/Tests/OpenClawIPCTests/MacNodeCodexThreadCatalogTests.swift:1, 537f45944e21)
  • Explicit owner-boundary decision: The latest author comment accepts the Mac node runtime as lifecycle owner and limits reuse to stored thread/history reads, leaving turn-driving methods outside this client because they require the upstream bidirectional server-request contract. (apps/macos/Sources/OpenClaw/NodeMode/MacNodeRuntime.swift:119, 537f45944e21)
  • Current PR state: The PR remains open and mergeable but is behind main; it has not been implemented on current main or shipped in release v2026.7.1. (9ccc8fcc271b)

Likely related people:

  • vincentkoc: Authored the five-commit macOS Codex client series and explicitly documented acceptance of the Mac node runtime as the lifecycle owner. (role: current lifecycle-owner proposer and recent area contributor; confidence: high; commits: 9c6b34897e3a, 14099051dc27, d3d073973396; files: apps/macos/Sources/OpenClaw/NodeMode/MacNodeCodexThreadCatalog.swift, apps/macos/Sources/OpenClaw/NodeMode/MacNodeCodexThreadCatalogClient.swift, apps/macos/Sources/OpenClaw/NodeMode/MacNodeRuntime.swift)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Refresh the branch or merge result against current main without disturbing the reviewed stack order.
  • Have the macOS/Codex owner explicitly accept the shared-client failure-isolation boundary before merge.

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.

History

Review history (9 earlier review cycles; latest 8 shown)
  • reviewed 2026-07-30T09:24:06.287Z sha 7005f409279c022311fd09c7e2ae17a59e56edb5 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-30T09:39:23.351Z sha fa4db4614b7fb335e15d8475aafbbc704a241a02 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-30T09:47:17.802Z sha a4398e5 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-30T09:51:14.536Z sha a4398e5 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-30T10:04:57.461Z sha 0df27ea :: needs maintainer review before merge. :: none
  • reviewed 2026-07-30T10:08:55.636Z sha 0df27ea :: needs maintainer review before merge. :: none
  • reviewed 2026-07-30T10:23:16.493Z sha bcde24a :: needs maintainer review before merge. :: none
  • reviewed 2026-07-31T02:32:55.604Z sha 537f459 :: needs maintainer review before merge. :: none

@vincentkoc

vincentkoc commented Jul 30, 2026 •

Copy link
Copy Markdown
Member Author

Rank-up moves disposition:

  • The seven-PR stack was refreshed onto main at 714a46d7f21; this PR is based on the exact predecessor head 66bbf76da3c.
  • Exact-head GitHub CI is complete with zero pending, failed, or cancelled checks at bcde24a12cc.
  • Exact-head native proof passed 68 focused tests across the Codex catalog and node runtime suites after splitting the lifecycle client into its own source file. The Codex catalog cases cover connection reuse, repeated requests, cancellation, wall-clock timeout behavior, process exit, invocation changes, idle shutdown, oversized output, large frames, coalesced JSONL messages, per-request frame limits, and deinitialization.
  • Strict macOS Periphery completed with no unused code after removing the obsolete one-shot catalog wrappers.
  • Final autoreview is clean at 0.91 confidence after fixing its persistent-connection findings: frame caps apply per message, stdout drains yield to timers and cancellation, request-limit changes are respected, large final frames drain before process-exit failure is projected, and queue wait remains part of callers’ wall-clock deadline.
  • The upstream Codex App Server contract was inspected directly: codex-rs/app-server/README.md:76-87 documents one initialization followed by multiple requests per connection; codex-rs/app-server/src/message_processor.rs:125-197 owns per-connection initialization state; codex-rs/app-server/src/message_processor.rs:525-577 dispatches requests through that shared connection state.
  • I am intentionally not rewriting the already reviewed seven-PR stack for unrelated moving-main churn. GitHub merge-ref checks are green; each child should be rebased onto its parent after the parent lands, preserving the reviewed order without invalidating all exact-head evidence at once.

The remaining macOS/Codex lifecycle-owner acceptance is intentionally left to human maintainer review. That is an ownership decision, not an unresolved code finding.

@vincentkoc
vincentkoc marked this pull request as ready for review July 30, 2026 09:29
@vincentkoc
vincentkoc force-pushed the perf/kova-stack-07-codex-client branch from 7005f40 to fa4db46 Compare July 30, 2026 09:34
@vincentkoc
vincentkoc force-pushed the perf/kova-stack-06-claude-catalog branch from df2e27d to 7a0c719 Compare July 30, 2026 09:34
@vincentkoc
vincentkoc force-pushed the perf/kova-stack-07-codex-client branch from fa4db46 to a4398e5 Compare July 30, 2026 09:43
@vincentkoc
vincentkoc force-pushed the perf/kova-stack-06-claude-catalog branch from 7a0c719 to 66bbf76 Compare July 30, 2026 09:43
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Jul 30, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Jul 30, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@vincentkoc
vincentkoc force-pushed the perf/kova-stack-06-claude-catalog branch from 66bbf76 to 8b704e3 Compare July 31, 2026 02:27
@vincentkoc
vincentkoc changed the base branch from perf/kova-stack-06-claude-catalog to main July 31, 2026 02:28
@vincentkoc
vincentkoc force-pushed the perf/kova-stack-07-codex-client branch from bcde24a to 537f459 Compare July 31, 2026 02:28
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@vincentkoc

Copy link
Copy Markdown
Member Author

Owner decision:

  • I accept the Mac node runtime as the lifecycle owner for the serialized Codex App Server catalog client.
  • Direct upstream inspection confirms initialization is connection-scoped and multiple requests are supported on one connection.
  • Exact-head MacNodeCodexThreadCatalogTests passed all 38 tests, including reuse, process exit, timeout, cancellation, queue deadlines, frame limits, idle shutdown, and deinitialization.

The client remains intentionally limited to stored thread/history reads; turn-driving methods would require the upstream bidirectional server-request contract.

@vincentkoc
vincentkoc merged commit b2cba40 into main Jul 31, 2026
58 of 102 checks passed
@vincentkoc
vincentkoc deleted the perf/kova-stack-07-codex-client branch July 31, 2026 02:40
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 31, 2026
* perf(macos): reuse Codex app server client

* refactor(macos): split Codex app server client

* fix(macos): enforce Codex frame limits per message

* refactor(macos): remove obsolete Codex wrappers

* test(macos): lock Codex wall-clock deadlines
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: macos App: macos maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL 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.

1 participant