Skip to content

[WRONG BRANCH] fix(stream): gate macOS eager-relay on a verified Bun runtime - #56

Draft
luvs01 wants to merge 1 commit into
mainfrom
codex/analyze-vulnerability-in-macos-eager-relay
Draft

[WRONG BRANCH] fix(stream): gate macOS eager-relay on a verified Bun runtime#56
luvs01 wants to merge 1 commit into
mainfrom
codex/analyze-vulnerability-in-macos-eager-relay

Conversation

@luvs01

@luvs01 luvs01 commented Aug 7, 2026

Copy link
Copy Markdown
Owner

Motivation

  • A previously-introduced policy let streamMode: "eager-relay" enable the eager SSE relay on macOS even when the bundled Bun runtime was not proven to contain the async-pull cancel fix (Bun#32111), exposing the process to a client-abort crash risk.
  • The change intentionally preserves the operator opt-in but must not make macOS reach the known-risk relay shape on unverified runtimes.

Description

  • Require a verified runtime for Darwin: selectEagerPath now permits config-eager on darwin only when bunHasAsyncPullCancelFix(version, minFixed) is true, keeping auto and known-bad runtimes on the tee path (src/lib/bun-stream-caps.ts).
  • Add focused regression tests: tests/bun-stream-caps.test.ts now asserts darwin + config-eager stays null on a known-bad runtime and becomes eager only on a fixed runtime.
  • Update config/type and documentation text to reflect the tightened policy and that macOS requires both explicit opt-in and a verified-fixed Bun (edited src/types.ts, docs-site/**/troubleshooting/windows-memory.md, and supporting structure/ pages and localized docs).
  • Minor comments and structure docs updated to keep the code, tests, and docs in sync with the new platform policy.

Testing

  • Ran bun test tests/bun-stream-caps.test.ts, which passed (new and existing assertions succeeded).
  • Ran bun run typecheck (TS typecheck) which completed successfully.
  • Ran bun run privacy:scan which passed in-repo checks for privacy-sensitive changes.
  • Ran the full bun run test; the broader suite ran but encountered unrelated timeouts (notably tests/oauth-login-cli-live-update.test.ts and tests/grok-models-effort-list.test.ts) so the full-suite run was not clean for unrelated reasons.
  • Attempted docs build in docs-site/ but dependency installation failed due to external registry 403s, so the site build could not be completed in this environment.

Codex Task

Summary by CodeRabbit

  • Bug Fixes

    • Improved stream mode selection on macOS by requiring explicit eager-relay configuration and a verified runtime fix.
    • Clarified platform-specific behavior for eager-relay, legacy-tee, and auto.
    • Windows automatically uses eager relay only when the runtime includes the verified fix.
  • Documentation

    • Updated troubleshooting, configuration, transport, and settings guidance across supported languages.
    • Removed outdated crash warnings and obsolete configuration instructions.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@github-actions github-actions Bot added the bug Something isn't working label Aug 7, 2026
@github-actions github-actions Bot changed the title fix(stream): gate macOS eager-relay on a verified Bun runtime [WRONG BRANCH] fix(stream): gate macOS eager-relay on a verified Bun runtime Aug 7, 2026
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

⏳ DRAFT

  • wrong target branch (main); retarget to dev.

What to do

  • Retarget this PR to dev — all contributions go to dev.

Its title has been prefixed with [WRONG BRANCH].
This pull request was already a draft. Its draft status will be preserved after every issue above is resolved.

@github-actions
github-actions Bot marked this pull request as draft August 7, 2026 13:34
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Darwin eager-relay now requires explicit configuration and a runtime verified to contain the Bun fix. Tests cover fixed and known-bad runtimes. Configuration, transport, GUI, management API, and troubleshooting documentation describe the updated platform behavior.

Changes

Stream mode runtime gating

Layer / File(s) Summary
Runtime-gated Darwin decision and validation
src/lib/bun-stream-caps.ts, tests/bun-stream-caps.test.ts
Darwin returns an eager decision only for explicit config-eager mode when bunHasAsyncPullCancelFix passes. Tests cover both known-bad and fixed runtimes.
Configuration and transport contracts
src/types.ts, structure/02_config-and-codex-home.md, structure/04_transports-and-sidecars.md, structure/05_gui-and-management-api.md
The configuration and transport rules require explicit macOS eager-relay configuration and a proven-fixed runtime. Darwin auto remains on tee mode.
Troubleshooting guidance
docs-site/src/content/docs/troubleshooting/windows-memory.md, docs-site/src/content/docs/ja/troubleshooting/windows-memory.md, docs-site/src/content/docs/ko/troubleshooting/windows-memory.md, docs-site/src/content/docs/ru/troubleshooting/windows-memory.md, docs-site/src/content/docs/zh-cn/troubleshooting/windows-memory.md
Troubleshooting pages describe platform-specific eager-relay, legacy-tee, and auto behavior. Obsolete configuration instructions and the Bun 1.3.14 crash warning are removed.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Configuration
  participant bunStreamCaps
  participant BunRuntime
  Configuration->>bunStreamCaps: Request eager-relay selection
  bunStreamCaps->>BunRuntime: Check bunHasAsyncPullCancelFix
  BunRuntime-->>bunStreamCaps: Return runtime status
  bunStreamCaps-->>Configuration: Return eager decision or null
Loading

Suggested reviewers: lidge-jun, ingwannu

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: gating macOS eager-relay on a verified Bun runtime.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/analyze-vulnerability-in-macos-eager-relay

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

Deterministic PR hygiene checks passed.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs-site/src/content/docs/ja/troubleshooting/windows-memory.md`:
- Line 45: Synchronize the translated configuration paragraphs with the English
source by explicitly naming config.json and PUT /api/settings, and stating that
API changes apply to new turns without requiring a restart. Update
docs-site/src/content/docs/ja/troubleshooting/windows-memory.md:45-45,
docs-site/src/content/docs/ko/troubleshooting/windows-memory.md:39-39,
docs-site/src/content/docs/ru/troubleshooting/windows-memory.md:80-80, and
docs-site/src/content/docs/zh-cn/troubleshooting/windows-memory.md:39-39;
preserve each locale’s existing translation and streamMode behavior.

In `@docs-site/src/content/docs/troubleshooting/windows-memory.md`:
- Around line 63-65: Update the macOS gate documentation to describe the
currently running Bun runtime, including the runtime selected through
OPENCODEX_BUN_PATH, rather than implying it always uses the bundled runtime.
Apply this wording change at
docs-site/src/content/docs/troubleshooting/windows-memory.md lines 63-65 and
92-97, and the corresponding Japanese line 45, Korean line 39, Russian line 80,
and Simplified Chinese line 39. Retain “bundled runtime” terminology only for
the default update path.

In `@tests/bun-stream-caps.test.ts`:
- Around line 116-118: Update the test case around selectEagerPath to pass the
configured fixed-version threshold "1.4.0" instead of null, while preserving the
existing inputs and null expectation so it specifically verifies that version
1.3.14 is rejected by the version gate.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: c9f6137f-67bf-4f21-8e09-86ca8d2a19bd

📥 Commits

Reviewing files that changed from the base of the PR and between 2468502 and 03a4332.

📒 Files selected for processing (11)
  • docs-site/src/content/docs/ja/troubleshooting/windows-memory.md
  • docs-site/src/content/docs/ko/troubleshooting/windows-memory.md
  • docs-site/src/content/docs/ru/troubleshooting/windows-memory.md
  • docs-site/src/content/docs/troubleshooting/windows-memory.md
  • docs-site/src/content/docs/zh-cn/troubleshooting/windows-memory.md
  • src/lib/bun-stream-caps.ts
  • src/types.ts
  • structure/02_config-and-codex-home.md
  • structure/04_transports-and-sidecars.md
  • structure/05_gui-and-management-api.md
  • tests/bun-stream-caps.test.ts


3. **`streamMode: "eager-relay"` を使用して有界リレーにオプトインします。** 2 つの方法:
`config.json` を編集する (`"streamMode": "eager-relay"` を追加する) か、管理 API を呼び出します。`PUT /api/settings` と `{"streamMode":"eager-relay"}` は、再起動せずに新しいターンに適用されます。 **クラッシュのリスク警告:** Bun 1.3.14 では、#32111 の影響を受けるストリーム形状が使用されており、ストリームの途中でプロセスがクラッシュする可能性があります (Windows に限らず、どの OS でも)。サービス マネージャーはサービスを再起動しますが、実行中のリクエストは失敗します。 `"legacy-tee"` は現在のデフォルトを固定します。 Windows では、`"auto"` (デフォルト) によりランタイム ゲートが決定します。 macOS では、`"auto"` は常に T 上にあります。明示的な `"eager-relay"` はオプトインです。
3. **`streamMode: "eager-relay"` で bounded relay を明示的に選択します。** 設定方法は変わりませんが、macOS では bundled runtime に #32111 の修正が含まれると検証された場合にのみ有効になり、それまでは tee を使用します。Windows では既存の明示設定の動作を維持します。`"legacy-tee"` は tee を固定し、`"auto"` は Windows では runtime gate に従い、macOS では常に tee を使用します。

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Synchronize the translated configuration instructions with the English source.

The English page names config.json and PUT /api/settings, and states that the API applies to new turns without a restart. The four locale paragraphs only say that the configuration method is unchanged.

  • docs-site/src/content/docs/ja/troubleshooting/windows-memory.md#L45-L45: restore the concrete configuration methods and no-restart behavior.
  • docs-site/src/content/docs/ko/troubleshooting/windows-memory.md#L39-L39: restore the concrete configuration methods and no-restart behavior.
  • docs-site/src/content/docs/ru/troubleshooting/windows-memory.md#L80-L80: restore the concrete configuration methods and no-restart behavior.
  • docs-site/src/content/docs/zh-cn/troubleshooting/windows-memory.md#L39-L39: restore the concrete configuration methods and no-restart behavior.
📍 Affects 4 files
  • docs-site/src/content/docs/ja/troubleshooting/windows-memory.md#L45-L45 (this comment)
  • docs-site/src/content/docs/ko/troubleshooting/windows-memory.md#L39-L39
  • docs-site/src/content/docs/ru/troubleshooting/windows-memory.md#L80-L80
  • docs-site/src/content/docs/zh-cn/troubleshooting/windows-memory.md#L39-L39
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs-site/src/content/docs/ja/troubleshooting/windows-memory.md` at line 45,
Synchronize the translated configuration paragraphs with the English source by
explicitly naming config.json and PUT /api/settings, and stating that API
changes apply to new turns without requiring a restart. Update
docs-site/src/content/docs/ja/troubleshooting/windows-memory.md:45-45,
docs-site/src/content/docs/ko/troubleshooting/windows-memory.md:39-39,
docs-site/src/content/docs/ru/troubleshooting/windows-memory.md:80-80, and
docs-site/src/content/docs/zh-cn/troubleshooting/windows-memory.md:39-39;
preserve each locale’s existing translation and streamMode behavior.

Source: Path instructions

Comment on lines +63 to +65
#32111 fix; today it is opt-in only (see below). On macOS it requires both
that verified runtime and explicit opt-in — flipping macOS `auto` is a
separate decision.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail
rg -n -C 6 'selectEagerPath|Bun\.version|OPENCODEX_BUN_PATH' src

Repository: luvs01/opencodex

Length of output: 16449


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- bun-stream-caps.ts ---'
sed -n '1,135p' src/lib/bun-stream-caps.ts

printf '%s\n' '--- bun-runtime.ts ---'
sed -n '1,215p' src/lib/bun-runtime.ts

printf '%s\n' '--- relevant launch/runtime references ---'
rg -n -C 5 'OPENCODEX_BUN_PATH|withProcessRuntimeProvenance|durableBunRuntime|reportedBunRuntimeSource|BUN_OVERRIDE_ENV|Bun\.version' src --glob '*.ts' --glob '*.mjs'

printf '%s\n' '--- documentation context ---'
for f in \
  docs-site/src/content/docs/troubleshooting/windows-memory.md \
  docs-site/src/content/docs/ja/troubleshooting/windows-memory.md \
  docs-site/src/content/docs/ko/troubleshooting/windows-memory.md \
  docs-site/src/content/docs/ru/troubleshooting/windows-memory.md \
  docs-site/src/content/docs/zh-cn/troubleshooting/windows-memory.md
do
  echo "### $f"
  wc -l "$f"
  sed -n '35,105p' "$f"
done

Repository: luvs01/opencodex

Length of output: 50372


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- all runtime override and launcher selection references ---'
rg -n -C 4 'OPENCODEX_BUN_PATH|bundledBunPath|process\.execPath|selectEagerPath\(' . \
  -g '!node_modules' -g '!dist' -g '!build' -g '*.ts' -g '*.mjs' -g '*.json' -g '*.sh' \
  | head -n 500

printf '%s\n' '--- exact English gate and option text ---'
nl -ba docs-site/src/content/docs/troubleshooting/windows-memory.md | sed -n '55,102p'

printf '%s\n' '--- exact translated stream-mode paragraphs ---'
for spec in \
  'docs-site/src/content/docs/ja/troubleshooting/windows-memory.md:35:52' \
  'docs-site/src/content/docs/ko/troubleshooting/windows-memory.md:30:46' \
  'docs-site/src/content/docs/ru/troubleshooting/windows-memory.md:70:87' \
  'docs-site/src/content/docs/zh-cn/troubleshooting/windows-memory.md:30:46'
do
  file=${spec%%:*}
  rest=${spec#*:}
  start=${rest%%:*}
  end=${rest##*:}
  echo "### $file"
  nl -ba "$file" | sed -n "${start},${end}p"
done

printf '%s\n' '--- precise selectEagerPath call arguments ---'
rg -n -U -C 3 'selectEagerPath\(' src --glob '*.ts'

Repository: luvs01/opencodex

Length of output: 34135


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- launcher runtime selection ---'
sed -n '350,435p' bin/ocx.mjs

printf '%s\n' '--- English affected lines ---'
awk 'NR >= 55 && NR <= 102 { printf "%6d:%s\n", NR, $0 }' \
  docs-site/src/content/docs/troubleshooting/windows-memory.md

printf '%s\n' '--- translated affected lines ---'
for spec in \
  'docs-site/src/content/docs/ja/troubleshooting/windows-memory.md 35 52' \
  'docs-site/src/content/docs/ko/troubleshooting/windows-memory.md 30 46' \
  'docs-site/src/content/docs/ru/troubleshooting/windows-memory.md 70 87' \
  'docs-site/src/content/docs/zh-cn/troubleshooting/windows-memory.md 30 46'
do
  set -- $spec
  file=$1
  echo "### $file"
  awk -v start="$2" -v end="$3" 'NR >= start && NR <= end { printf "%6d:%s\n", NR, $0 }' "$file"
done

Repository: luvs01/opencodex

Length of output: 11685


Use the running Bun runtime in the macOS gate documentation. selectEagerPath defaults to Bun.version, and OPENCODEX_BUN_PATH can select the runtime used by the service. Update docs-site/src/content/docs/troubleshooting/windows-memory.md#L63-L65, #L92-L97, and the corresponding ja#L45, ko#L39, ru#L80, and zh-cn#L39 text. Keep “bundled runtime” only for the default update path.

📍 Affects 5 files
  • docs-site/src/content/docs/troubleshooting/windows-memory.md#L63-L65 (this comment)
  • docs-site/src/content/docs/troubleshooting/windows-memory.md#L92-L97
  • docs-site/src/content/docs/ja/troubleshooting/windows-memory.md#L45-L45
  • docs-site/src/content/docs/ko/troubleshooting/windows-memory.md#L39-L39
  • docs-site/src/content/docs/ru/troubleshooting/windows-memory.md#L80-L80
  • docs-site/src/content/docs/zh-cn/troubleshooting/windows-memory.md#L39-L39
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs-site/src/content/docs/troubleshooting/windows-memory.md` around lines 63
- 65, Update the macOS gate documentation to describe the currently running Bun
runtime, including the runtime selected through OPENCODEX_BUN_PATH, rather than
implying it always uses the bundled runtime. Apply this wording change at
docs-site/src/content/docs/troubleshooting/windows-memory.md lines 63-65 and
92-97, and the corresponding Japanese line 45, Korean line 39, Russian line 80,
and Simplified Chinese line 39. Retain “bundled runtime” terminology only for
the default update path.

Source: Path instructions

Comment on lines +116 to +118
test("darwin + no rewrite + config-eager + known-bad runtime → tee", () => {
expect(selectEagerPath("darwin", false, "eager-relay", "1.3.14", null)).toBeNull();
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Exercise the configured version boundary.

minFixed is null in this known-bad case. The assertion therefore exercises the “no threshold configured” branch. It does not prove that selectEagerPath rejects 1.3.14 when the fixed threshold is 1.4.0. Pass "1.4.0" as minFixed.

As per path instructions: a behavior change in src/ must have a focused regression test near the existing tests for that subsystem. This test should exercise the version gate, not only the unset-threshold fallback.

Proposed test correction
-    expect(selectEagerPath("darwin", false, "eager-relay", "1.3.14", null)).toBeNull();
+    expect(selectEagerPath("darwin", false, "eager-relay", "1.3.14", "1.4.0")).toBeNull();
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
test("darwin + no rewrite + config-eager + known-bad runtime → tee", () => {
expect(selectEagerPath("darwin", false, "eager-relay", "1.3.14", null)).toBeNull();
});
test("darwin + no rewrite + config-eager + known-bad runtime → tee", () => {
expect(selectEagerPath("darwin", false, "eager-relay", "1.3.14", "1.4.0")).toBeNull();
});
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/bun-stream-caps.test.ts` around lines 116 - 118, Update the test case
around selectEagerPath to pass the configured fixed-version threshold "1.4.0"
instead of null, while preserving the existing inputs and null expectation so it
specifically verifies that version 1.3.14 is rejected by the version gate.

Source: Path instructions

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

Labels

aardvark bug Something isn't working codex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant