Repository navigation
codex: desktop OTEL tracing on Windows - #1188
Conversation
d3d26e0 to
f01858e
Compare
6748798 to
8c0af20
Compare
062d447 to
575bd49
Compare
## 🥞 Stacked PR Use this [link](https://github.com/databricks/unity-gateway/pull/1187/files) to review incremental changes. - [**stack/andy/codex-desktop-tracing-macos**](databricks#1187) [[Files changed](https://github.com/databricks/unity-gateway/pull/1187/files)] ← _this PR_ - [stack/andy/codex-desktop-tracing-windows](databricks#1188) [[Files changed](https://github.com/databricks/unity-gateway/pull/1188/files/1ef8a4ca357206e5d133f591107a48460c9de89f..575bd49dcd472f5705f795765bfcf7d21a7b88a6)] --------- ## What databricks#1112 runs ug's OTEL proxy as a login service so Codex desktop traces get a fresh Databricks token, but only on Linux. This adds the same service on macOS: the LaunchAgent `com.databricks.ug-codex-otel` in `~/Library/LaunchAgents`, loaded with `launchctl bootstrap gui/<uid>`. `KeepAlive` restarts it after a failure. The proxy, fixed port, `~/.codex/config.toml` exporter, warn-only setup, and removal on disable or `ug revert` are unchanged. Linux code is untouched: macOS returns early from the shared functions, and the Linux unit and `systemctl` calls are byte-identical to main. Windows follows in the next PR of this stack. ## Notes - An unchanged launch leaves a loaded agent alone; a changed plist is reloaded with `bootout` + `bootstrap`. - The only code shared with the systemd path is `_otel_service_env()`, the variables the service inherits, so the unit and the plist can't drift apart. ## Validation - A component test simulates `launchctl` and checks the plist, an unchanged launch, a workspace change, and removal. - A script generates the Linux unit and the `systemctl` call sequence from this branch and from main: they're identical. - `just lint` passes; `tests/test_agent_codex.py` passes. The 7 full-suite failures (`test_agents_init` update prompts, `test_e2e_user_agent`) fail the same way on main. - End to end on a GitHub `macos-latest` runner, with ug installed by `uv tool install`, the real Databricks CLI, and Codex's real `codex app-server`, against a local fake workspace: - `ug configure` writes the exporter and starts the LaunchAgent. - App-server sessions export OTLP traces through it to `/ai-gateway/otel/v1/traces` with the Databricks token, before and after a simulated logout/login (`bootout` + `bootstrap`). - `KeepAlive` restarts a killed proxy, and disabling tracing removes the exporter and the agent. This pull request and its description were written by Isaac. ## E2E Test: <img width="1366" height="779" alt="Screenshot 2026-10-19 at 4 33 27 PM" src="https://github.com/user-attachments/assets/61c82543-174c-497e-a956-970032144e44" /> Co-authored-by: Isaac <no-reply@databricks.com>
Polly AI ReviewBlocking issues
Security vulnerabilitiesThe blocker above can expose traces to the previously configured workspace. No additional security vulnerabilities were identified. Non-blocking notesNone. ApproachThe per-platform service definitions fit the existing lifecycle. Preserve retryability by rolling back the saved definition after registration failure. SummaryDiff size (computed): 6 files; +296 / -30 lines (326 changed text lines); 0 binary files.
Shares use additions + deletions, including generated text and lockfiles. Binary files have no line count. Tests include fixtures/helpers under test paths and colocated test/spec files; categories are path-based, not coverage measurements. ChangesThe diff enables persistent Codex desktop tracing through a macOS LaunchAgent and a Windows per-user scheduled task. Shared changes provide service environment construction, definition/port parsing, and UTF-16 file writing. Documentation describes the platform-specific setup and diagnostics. The size is proportional to that outcome. Consolidating the duplicate subprocess wrappers is a concrete, small reduction; the platform-specific definitions otherwise serve distinct requirements. TestsTest-by-test assessment
Both added test methods are accounted for; no existing test cases were modified or removed. Existing Component testing is the appropriate layer for the replacement/retry regression. Native validation uniquely establishes actual Task Scheduler registration, interactive logon, and windowless behavior. The PR describes platform exercises but leaves real non-admin desktop-session and reboot behavior unverified. Tests were not executed during this review. Findings are based on the frozen diff and trusted-checkout context. ScopeNo unrelated changes were found. The macOS changes included in the full stacked diff, Windows task support, shared helpers, tests, and documentation all support persistent Codex desktop tracing. No unresolved scope questions were identified. Automated review by Polly · workflow run |
Extend the Codex desktop OTEL login service to Windows as a per-user logon task com.databricks.ug-codex-otel (no admin), running the venv's pythonw.exe -m ucode.cli otel-proxy so no console window appears. Task Scheduler keeps its own copy, so ug keeps the XML it registered in ~/.ucode (UTF-16, the encoding schtasks reads) to track ownership and the port. A changed definition ends the running task before /Create /F; IgnoreNew keeps /Run from starting a second proxy. Co-authored-by: Isaac <no-reply@databricks.com>
575bd49 to
d345b38
Compare
|
/merge |
Follows #1187 (macOS, merged); this PR's diff is the Windows change only.
What
Extends the Codex desktop OTEL login service from the previous PR in this stack to Windows: a per-user logon task
com.databricks.ug-codex-otelthat needs no admin rights. It runs the venv'spythonw.exe -m ucode.cli otel-proxy, so no console window appears.Notes
~/.ucodeto track ownership and the port. The file is UTF-16, the encodingschtasksreads, sowrite_text_filegains anencodingargument./Endbefore/Create /F, which would otherwise leave the old proxy running.IgnoreNewkeeps/Runfrom starting a second proxy next to a running one.Validation
schtasksand checks the task XML, the UTF-16 file, an unchanged launch, a workspace change, and removal. It passes in the Windows unit-test CI job.just lintpasses;tests/test_agent_codex.pypasses. The 7 full-suite failures (test_agents_initupdate prompts,test_e2e_user_agent) fail the same way on main.windows-latestrunner, with ug installed byuv tool install, the real Databricks CLI, and Codex's realcodex app-server, against a local fake workspace:ug configurewrites the exporter and registers the task; the proxy listens within ~2s under windowlesspythonw.exe./End+/Run).At logon time/Interactive onlytask, and removal worked.Limits
shortcut:in code: a crashed proxy waits for the next logon orug codexlaunch, and the task doesn't get the shell'sDATABRICKS_*overrides.This pull request and its description were written by Isaac.