Skip to content

Commit 3e9b666

Browse files
committed
codex 0.141.0 + MIO with event ports patch
1 parent 5304b2a commit 3e9b666

7 files changed

Lines changed: 1123 additions & 17 deletions

README.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ build/install/codex/bin/codex --version
6161
- The wrapper uses the official Solaris Rust standalone installer target
6262
`x86_64-pc-solaris`.
6363
- The pinned Codex source is the upstream `openai/codex` release tag
64-
`rust-v0.140.0`, built from its `codex-rs/` workspace.
64+
`rust-v0.141.0`, built from its `codex-rs/` workspace.
6565
- Set `SOLARIS_CODEX_PROXY_SETUP=/path/to/proxy.sh` if your host needs an
6666
environment hook before downloads.
6767
- The codex build clears inherited Solaris `LD_*` hardening variables because
@@ -78,11 +78,6 @@ patch series under `patches/codex/` before vendoring:
7878
- `0002-tui-disable-unsupported-clipboard-backends-on-solaris.patch` disables
7979
native clipboard image and text paths that have no maintained Solaris backend
8080
and leaves the SSH and OSC 52 text-copy path available.
81-
- `0003-tui-work-around-solaris-terminal-input-and-layout.patch` keeps the TUI
82-
off terminal capability probes that stalled some Solaris PTYs, replaces the
83-
unreliable default `crossterm::event::EventStream` path with a Solaris input
84-
reader, prefers an ASCII-safe presentation on older terminals, and redraws the
85-
onboarding flow so the actionable step stays visible on smaller PTYs.
8681
- `0004-config-host-name-use-solaris-ai-canonname-fallback.patch` supplies the
8782
Solaris `AI_CANONNAME` value that the Rust `libc` crate does not expose.
8883
- `0005-state-use-rollback-journal-on-solaris.patch` keeps Codex state
@@ -96,6 +91,14 @@ patch series under `patches/codex/` before vendoring:
9691
- `0008-http-client-honor-no-proxy-before-system-proxy.patch` makes
9792
exec-server HTTP requests honor `NO_PROXY`/`no_proxy` hosts before reqwest's
9893
system proxy lookup.
94+
- `0010-exec-server-drain-fs-helper-output-concurrently.patch` keeps large
95+
filesystem-helper responses from blocking on a full stdout pipe.
96+
97+
Before vendoring, `patch_tui_solaris_terminal_input()` keeps the TUI off
98+
terminal capability probes that stalled some Solaris PTYs, replaces the
99+
unreliable default `crossterm::event::EventStream` path with a Solaris input
100+
reader, prefers an ASCII-safe presentation on older terminals, and redraws the
101+
onboarding flow so the actionable step stays visible on smaller PTYs.
99102

100103
After `cargo vendor`, `build-codex.sh` still applies the remaining Solaris
101104
vendored-crate rewrites in place:
@@ -104,9 +107,13 @@ vendored-crate rewrites in place:
104107
- `patch_vendored_tree_sitter_endian()`
105108
- `patch_vendored_fslock()`
106109
- `patch_vendored_onig_sys_alloca()`
110+
- `patch_vendored_mio_event_ports()`
107111

108112
Those helpers remain scripted because they also update vendored crate
109113
`.cargo-checksum.json`, which makes static patch files awkward to maintain.
114+
The mio event-ports rewrite applies the upstream proposal from
115+
`https://github.com/tokio-rs/mio/pull/1962`, refreshed against the `mio 1.2.0`
116+
crate version locked by Codex.
110117

111118
## Maintainer Notes
112119

build-codex.sh

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,60 @@ checksum_json.write_text(json.dumps(data, separators=(",", ":")))
344344
PY2
345345
}
346346

347+
patch_vendored_mio_event_ports() {
348+
local mio_root=${CODEX_VENDOR_DIR}/mio
349+
local checksum_json=${mio_root}/.cargo-checksum.json
350+
local event_ports_rs=${mio_root}/src/sys/unix/selector/event_ports.rs
351+
local patch
352+
353+
[[ -d "${mio_root}" ]] || die "missing vendored mio source: ${mio_root}"
354+
[[ -f "${checksum_json}" ]] || die "missing vendored mio checksum: ${checksum_json}"
355+
356+
if [[ ! -f "${event_ports_rs}" ]]; then
357+
for patch in "${TOP}/patches/mio"/*.patch; do
358+
[[ -e "${patch}" ]] || die "missing mio Solaris event ports patch"
359+
if (
360+
cd "${mio_root}"
361+
"${PATCH_TOOL}" --dry-run -p1 < "${patch}" >/dev/null 2>&1
362+
); then
363+
log "Applying vendored mio $(basename "${patch}")"
364+
(
365+
cd "${mio_root}"
366+
"${PATCH_TOOL}" -p1 < "${patch}"
367+
)
368+
else
369+
die "failed to apply vendored mio patch: ${patch}"
370+
fi
371+
done
372+
fi
373+
374+
[[ -f "${event_ports_rs}" ]] || die "vendored mio Solaris event ports source was not created"
375+
376+
python3 - "${mio_root}" "${checksum_json}" <<'PY2'
377+
from pathlib import Path
378+
import hashlib
379+
import json
380+
import sys
381+
382+
root = Path(sys.argv[1])
383+
checksum_json = Path(sys.argv[2])
384+
paths = [
385+
"src/poll.rs",
386+
"src/sys/unix/mod.rs",
387+
"src/sys/unix/selector/event_ports.rs",
388+
]
389+
390+
data = json.loads(checksum_json.read_text())
391+
files = data.setdefault("files", {})
392+
for rel in paths:
393+
path = root / rel
394+
if not path.is_file():
395+
raise SystemExit(f"missing vendored mio file: {path}")
396+
files[rel] = hashlib.sha256(path.read_bytes()).hexdigest()
397+
checksum_json.write_text(json.dumps(data, separators=(",", ":")))
398+
PY2
399+
}
400+
347401
patch_tui_solaris_terminal_input() {
348402
local tui_rs=${CODEX_SRC_DIR}/tui/src/tui.rs
349403
local event_stream_rs=${CODEX_SRC_DIR}/tui/src/tui/event_stream.rs
@@ -935,7 +989,7 @@ v8_install_matches_pin || bash "${TOP}/build-v8.sh"
935989
ensure_codex_source
936990
apply_patch_series "${CODEX_REPO_DIR}" "${TOP}/patches/codex"
937991
patch_tui_solaris_terminal_input
938-
vendor_rust_sources "${CODEX_SRC_DIR}" "${CODEX_VENDOR_DIR}"
992+
vendor_rust_sources "${CODEX_SRC_DIR}" "${CODEX_VENDOR_DIR}" "" unlocked
939993

940994
# Apply the remaining Solaris vendored-crate rewrites after cargo vendor.
941995
# These stay scripted because each change must also refresh the vendored
@@ -944,6 +998,7 @@ patch_vendored_nix_termios
944998
patch_vendored_tree_sitter_endian
945999
patch_vendored_fslock
9461000
patch_vendored_onig_sys_alloca
1001+
patch_vendored_mio_event_ports
9471002

9481003
export GN="${GN_INSTALL_DIR}/bin/gn"
9491004
export RUSTY_V8_ARCHIVE="${V8_INSTALL_DIR}/lib/librusty_v8.a"

common.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ vendor_rust_sources() {
275275
local src_dir=$1
276276
local vendor_dir=$2
277277
local extra_file=${3:-}
278+
local lock_mode=${4:-locked}
278279
local cargo_dir=${src_dir}/.cargo
279280
local config=${cargo_dir}/config.toml
280281
local raw=${vendor_dir}.config.raw
@@ -299,7 +300,9 @@ vendor_rust_sources() {
299300
log "Vendoring Rust dependencies for $(basename "${src_dir}")"
300301
(
301302
cd "${src_dir}"
302-
if ! "${CARGO}" vendor --locked "${vendor_dir}" > "${raw}"; then
303+
if [[ "${lock_mode}" == "unlocked" ]]; then
304+
"${CARGO}" vendor "${vendor_dir}" > "${raw}"
305+
elif ! "${CARGO}" vendor --locked --offline "${vendor_dir}" > "${raw}"; then
303306
log "cargo vendor --locked requested a lockfile refresh; retrying without --locked"
304307
rm -rf "${vendor_dir}" "${raw}"
305308
"${CARGO}" vendor "${vendor_dir}" > "${raw}"

patches/codex/0006-arg0-tolerate-solaris-stale-temp-cleanup.patch

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ What it does:
1010
process-scoped there and do not model a separate live Codex process
1111

1212
diff --git a/codex-rs/arg0/src/lib.rs b/codex-rs/arg0/src/lib.rs
13-
index ba254d5..0eeafe8 100644
13+
index 2102eaf..1b0e530 100644
1414
--- a/codex-rs/arg0/src/lib.rs
1515
+++ b/codex-rs/arg0/src/lib.rs
16-
@@ -478,17 +478,41 @@ fn janitor_cleanup(temp_root: &Path) -> std::io::Result<()> {
16+
@@ -484,17 +484,41 @@ fn janitor_cleanup(temp_root: &Path) -> std::io::Result<()> {
1717
continue;
1818
};
1919

@@ -61,7 +61,7 @@ index ba254d5..0eeafe8 100644
6161
fn try_lock_dir(dir: &Path) -> std::io::Result<Option<File>> {
6262
let lock_path = dir.join(LOCK_FILENAME);
6363
let lock_file = match File::options().read(true).write(true).open(&lock_path) {
64-
@@ -710,6 +734,10 @@ mod tests {
64+
@@ -716,6 +740,10 @@ mod tests {
6565
}
6666

6767
#[test]

patches/codex/0010-exec-server-drain-fs-helper-output-concurrently.patch

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ before it can exit. Add a regression test that returns a helper-shaped response
1010
larger than a typical pipe buffer.
1111

1212
diff --git a/codex-rs/exec-server/src/fs_sandbox.rs b/codex-rs/exec-server/src/fs_sandbox.rs
13-
index a99a949..91c7ae4 100644
13+
index cd2cc38..c348b8d 100644
1414
--- a/codex-rs/exec-server/src/fs_sandbox.rs
1515
+++ b/codex-rs/exec-server/src/fs_sandbox.rs
1616
@@ -16,6 +16,7 @@ use codex_sandboxing::SandboxablePreference;
@@ -21,7 +21,7 @@ index a99a949..91c7ae4 100644
2121
use tokio::io::AsyncWriteExt;
2222
use tokio::process::Command;
2323

24-
@@ -274,6 +275,25 @@ async fn run_command(
24+
@@ -278,6 +279,25 @@ async fn run_command(
2525
request_json: Vec<u8>,
2626
) -> Result<FsHelperPayload, JSONRPCErrorError> {
2727
let mut child = spawn_command(command)?;
@@ -47,7 +47,7 @@ index a99a949..91c7ae4 100644
4747
let mut stdin = child
4848
.stdin
4949
.take()
50-
@@ -282,15 +302,17 @@ async fn run_command(
50+
@@ -286,15 +306,17 @@ async fn run_command(
5151
stdin.shutdown().await.map_err(io_error)?;
5252
drop(stdin);
5353

@@ -70,7 +70,7 @@ index a99a949..91c7ae4 100644
7070
match response {
7171
FsHelperResponse::Ok(payload) => Ok(payload),
7272
FsHelperResponse::Error(error) => Err(error),
73-
@@ -331,6 +353,10 @@ fn io_error(err: std::io::Error) -> JSONRPCErrorError {
73+
@@ -335,6 +357,10 @@ fn io_error(err: std::io::Error) -> JSONRPCErrorError {
7474
internal_error(err.to_string())
7575
}
7676

@@ -81,7 +81,7 @@ index a99a949..91c7ae4 100644
8181
fn json_error(err: serde_json::Error) -> JSONRPCErrorError {
8282
internal_error(format!(
8383
"failed to encode or decode fs sandbox helper message: {err}"
84-
@@ -642,6 +668,58 @@ mod tests {
84+
@@ -646,6 +672,58 @@ mod tests {
8585
assert!(policy.can_read_path_with_cwd(alias_parent.as_path(), cwd.as_path()));
8686
}
8787

0 commit comments

Comments
 (0)