PORTABILITY AND FUTURE CODEX VERSIONS — portable r4 Scope and environments - macOS, native Windows, native Linux and WSL2 are separate environments. WSL2 needs Linux Python, Linux Codex and its own official login. This sample rejects a Windows executable under WSL, including a /mnt path. No auth folder is copied. - Use an ordinary user account. Do not disable UAC, Defender, ExecutionPolicy, TLS checks, sandboxing or user instructions to make the example run. - Executable discovery resolves an actual local file. Every process uses an argv array and shell=False. UTF-8 JSONL/files are explicit; stderr is separate. - A local config can select one package-relative exercise directory. Browser requests cannot set cwd, executable or RPC method. The real adapter accepts only the fixed control text. The gateway's arbitrary-text input is useful only for local negative/UI tests; it does not authorize general model work. Loopback HTTP and bounded request handling (r4) - The client accepts only an explicit http://127.0.0.1 origin. It disables ambient proxies and rejects redirects, including redirects to another port. It never forwards the machine credential or browser cookie to a new origin. - Gateway sockets have a 2-second idle timeout and a 5-second absolute socket deadline, including slow headers/bodies. At most 16 connections are processed concurrently; excess connections are closed. The JSON body limit is 32 KiB. Machine credentials and browser session/origin/CSRF are checked before body reads; login checks Origin before reading its password body. - These limits reduce local resource exhaustion. They do not make Python's teaching HTTP server suitable for Internet exposure or hostile multiuser use. State, locking and storage - Use a local, unsynchronized filesystem. Network shares/cloud-sync folders are unsupported for SQLite and journals; this sample cannot reliably detect every sync agent or filesystem mount. Verify location before first run. - On POSIX a new private state directory is 0700 and files are 0600. Existing broad permissions cause a failure; the sample does not silently chmod them. - Native Windows uses Win32 owner/DACL APIs. New state directories receive a protected current-user + LocalSystem DACL. Existing state must already have only those allowed principals; otherwise startup blocks for local review. chmod bits are not treated as an ACL. Native Windows ACL calls have NOT been runtime-verified in the Mac evaluation; simulated dispatch is not acceptance. Windows, native Linux and WSL runtime status: NOT_RUNTIME_VERIFIED. - Atomic JSON writes use unique same-directory temporary files, explicit UTF-8, file flush/fsync and replacement. POSIX also fsyncs the parent directory; Windows uses MoveFileExW(REPLACE_EXISTING | WRITE_THROUGH). Tests cover process interruption/replacement failure, not sudden power loss or storage failure. - Kernel-held flock/msvcrt locks serialize credentials, launcher, gateway and worker state. Locks are released by the OS when the owning process exits; lock files are intentionally not deleted. Do not clear journals to unlock work. - Gateway start/stop uses a private machine credential and an exact instance token, not ps/taskkill or a recycled PID. Direct subprocess handles are used for task-owned tests/App Server. Graceful stdin EOF is tried before terminate. A hard OS/process crash is still an unknown outcome requiring review; Windows process-tree/crash behavior needs an actual Windows acceptance run. - Stop removes its management receipt only after authenticated shutdown and an explicit connection-refused response from the same loopback listener. Timeout, reset, unrelated URL errors and identity mismatch preserve the receipt and require review. Listener closure is not process-tree certification. Before writing after an update - contract.json pins the tested CLI version AND five canonical JSON schemas. A renamed executable at another native path can pass the same contract. A new version label or schema fingerprint blocks writes pending review, even if initialize alone succeeds. No runtime changes contract.json. - Each real run performs the compatibility check, then the stdio handshake: initialize -> response -> initialized -> new ephemeral thread/start. It verifies exact cwd, readOnly policy, no sandbox network and never approval. CLI 0.154.0 uses thread/start sandbox="read-only" but turn/start policy type="readOnly". These spellings are not interchangeable. - Normal global owner rules remain enabled. Unexpected project instruction sources block the fixed exercise; inspect placement/config locally rather than disabling global rules or moving credentials. No history methods run. - Only then can the explicitly authorized turn be sent. Durable intent and the one-use marker are saved first. Unknown ACK state is never automatically replayed. Keep immutable receipts and saved final results across restarts. - Received result and verified control output remain separate states. readOnly/never plus a no-tools answer do NOT prove HOME confidentiality or adversarial OS isolation. This sample has no broad sandbox certification. Bounded maintenance is NOT IMPLEMENTED The sample has a compatibility gate, not an autonomous repair manager. A future repair loop requires explicit owner maintenance authorization, one maintenance lock, a durable journal, a bounded attempt/time budget, a retained rollback release, regression/negative tests, and no activation while work is active or its outcome is unknown. Never update hashes just for a green status. An old bridge does not make a changed Codex compatible. Changes to send/receive behavior require a separately authorized synthetic real E2E before claiming restored model integration. No new model call was made for the portable revision. Auth, accounts, security policy, VPN/DNS, firewall, package auto-update and scheduled services are outside this sample. Acceptance still required Native Windows, native Linux and WSL must run their own Python tests, schema check, filesystem ACL/lock/replace/crash verification and, with explicit authorization, one real control turn. UI acceptance and actual remote access are separate checks. No LaunchAgent, Task Scheduler, Windows service, Remote setup, HTTPS gateway, backup/restore, second device or sleep/wake deployment is installed or verified. The POSIX implementation is a candidate for native Linux; no Linux runtime or native Remote support is established by macOS tests or Windows simulations. Primary references https://learn.chatgpt.com/docs/app-server https://learn.chatgpt.com/docs/remote-connections https://docs.python.org/3/library/msvcrt.html https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-movefileexw https://learn.microsoft.com/en-us/windows/win32/api/aclapi/nf-aclapi-getnamedsecurityinfow