Commit Graph
9551 Commits
Author SHA1 Message Date
Michael Bolin f04febf58b safety: honor filesystem policy carveouts in apply_patch 2026-03-06 15:22:20 -08:00
Michael Bolin 3c052a333e linux-sandbox: honor split filesystem policies in bwrap 2026-03-06 15:22:20 -08:00
Michael Bolin 99caae69b2 protocol: keep root carveouts sandboxed 2026-03-06 15:22:20 -08:00
Michael Bolin 8883fe0ff6 sandboxing: preserve denied paths when widening permissions 2026-03-06 15:22:20 -08:00
Michael Bolin 9b81b65552 linux-sandbox: plumb split sandbox policies through helper 2026-03-06 15:22:20 -08:00
Michael Bolin 42ff727f6f seatbelt: honor split filesystem sandbox policies 2026-03-06 15:22:20 -08:00
Michael Bolin 58ece05629 merge commit for archive created by Sapling 2026-03-06 15:20:28 -08:00
Michael Bolin 80859304d5 linux-sandbox: honor split filesystem policies in bwrap 2026-03-06 15:20:10 -08:00
Michael Bolin f9db355578 protocol: keep root carveouts sandboxed 2026-03-06 15:20:10 -08:00
Curtis 'Fjord' Hawthorne d6c8186195 Clarify js_repl binding reuse guidance (#13803)
## Summary

Clarify the `js_repl` prompt guidance around persistent bindings and
redeclaration recovery.

This updates the generated `js_repl` instructions in
`core/src/project_doc.rs` to prefer this order when a name is already
bound:

1. Reuse the existing binding
2. Reassign a previously declared `let`
3. Pick a new descriptive name
4. Use `{ ... }` only for short-lived scratch scope
5. Reset the kernel only when a clean state is actually needed

The prompt now also explicitly warns against wrapping an entire cell in
block scope when the goal is to reuse names across later cells.

## Why

The previous wording still left too much room for low-value workarounds
like whole-cell block wrapping. In downstream browser rollouts, that
pattern was adding tokens and preventing useful state reuse across
`js_repl` cells.

This change makes the preferred behavior more explicit without changing
runtime semantics.

## Scope

- Prompt/documentation change only
- No runtime behavior changes
- Updates the matching string-backed `project_doc` tests
2026-03-06 15:19:06 -08:00
Michael Bolin 05e9b522f1 protocol: derive effective file access from filesystem policies 2026-03-06 15:19:04 -08:00
Michael Bolin 6fbab753cb sandboxing: preserve denied paths when widening permissions 2026-03-06 15:19:04 -08:00
Michael Bolin bddefc9edd linux-sandbox: plumb split sandbox policies through helper 2026-03-06 15:19:04 -08:00
Michael Bolin 7b5b968483 seatbelt: honor split filesystem sandbox policies 2026-03-06 15:19:04 -08:00
Michael Bolin 4b6d18c755 safety: honor filesystem policy carveouts in apply_patch 2026-03-06 15:19:04 -08:00
Michael Bolin 4544dd25b6 merge commit for archive created by Sapling 2026-03-06 15:17:38 -08:00
Michael Bolin 2dc364500b linux-sandbox: honor split filesystem policies in bwrap 2026-03-06 15:17:07 -08:00
Michael Bolin 099a061460 protocol: keep root carveouts sandboxed 2026-03-06 15:17:07 -08:00
Michael Bolin b483d481e9 sandboxing: preserve denied paths when widening permissions 2026-03-06 15:17:07 -08:00
Michael Bolin 85a06286ce linux-sandbox: plumb split sandbox policies through helper 2026-03-06 15:15:48 -08:00
Michael Bolin b1a6de9f00 seatbelt: honor split filesystem sandbox policies 2026-03-06 15:15:14 -08:00
Michael Bolin b2ddc1c49f safety: honor filesystem policy carveouts in apply_patch 2026-03-06 15:14:40 -08:00
Michael Bolin cf4dd5b730 protocol: derive effective file access from filesystem policies 2026-03-06 15:14:39 -08:00
Michael Bolin 0acad009b2 sandboxing: plumb split sandbox policies through runtime 2026-03-06 15:14:19 -08:00
Ruslan Nigmatullin 5b04cc657f utils/pty: add streaming spawn and terminal sizing primitives (#13695)
Enhance pty utils:
* Support closing stdin
* Separate stderr and stdout streams to allow consumers differentiate them
* Provide compatibility helper to merge both streams back into combined one
* Support specifying terminal size for pty, including on-demand resizes while process is already running
* Support terminating the process while still consuming its outputs
2026-03-06 15:13:12 -08:00
Michael Bolin 5c6f557faa merge commit for archive created by Sapling 2026-03-06 15:02:05 -08:00
Michael Bolin bfbe45d517 linux-sandbox: honor split filesystem policies in bwrap 2026-03-06 15:01:33 -08:00
Michael Bolin 487e6354ba protocol: keep root carveouts sandboxed 2026-03-06 15:01:33 -08:00
Michael Bolin 9e76f2b75b sandboxing: preserve denied paths when widening permissions 2026-03-06 15:01:33 -08:00
Michael Bolin f7776662b5 linux-sandbox: plumb split sandbox policies through helper 2026-03-06 15:01:33 -08:00
Michael Bolin 8681522c0b seatbelt: honor split filesystem sandbox policies 2026-03-06 15:01:33 -08:00
Michael Bolin 2e6098cd7b safety: honor filesystem policy carveouts in apply_patch 2026-03-06 15:01:33 -08:00
Michael Bolin c58266bb80 protocol: derive effective file access from filesystem policies 2026-03-06 15:01:33 -08:00
Michael Bolin eb5869bec3 sandboxing: plumb split sandbox policies through runtime 2026-03-06 15:01:33 -08:00
Michael Bolin 39b15e3f45 config: add v3 filesystem permission profiles 2026-03-06 15:01:32 -08:00
Josh McKinneyandCodex 4e68fb96e2 feat: add auth login diagnostics (#13797)
## Problem

Browser login failures historically leave support with an incomplete
picture. HARs can show that the browser completed OAuth and reached the
localhost callback, but they do not explain why the native client failed
on the final `/oauth/token` exchange. Direct `codex login` also relied
mostly on terminal stderr and the browser error page, so even when the
login crate emitted better sign-in diagnostics through TUI or app-server
flows, the one-shot CLI path still did not leave behind an easy artifact
to collect.

## Mental model

This implementation treats the browser page, the returned `io::Error`,
and the normal structured log as separate surfaces with different safety
requirements. The browser page and returned error preserve the detail
that operators need to diagnose failures. The structured log stays
narrower: it records reviewed lifecycle events, parsed safe fields, and
redacted transport errors without becoming a sink for secrets or
arbitrary backend bodies.

Direct `codex login` now adds a fourth support surface: a small
file-backed log at `codex-login.log` under the configured `log_dir`.
That artifact carries the same login-target events as the other
entrypoints without changing the existing stderr/browser UX.

## Non-goals

This does not add auth logging to normal runtime requests, and it does
not try to infer precise transport root causes from brittle string
matching. The scope remains the browser-login callback flow in the
`login` crate plus a direct-CLI wrapper that persists those events to
disk.

This also does not try to reuse the TUI logging stack wholesale. The TUI
path initializes feedback, OpenTelemetry, and other session-oriented
layers that are useful for an interactive app but unnecessary for a
one-shot login command.

## Tradeoffs

The implementation favors fidelity for caller-visible errors and
restraint for persistent logs. Parsed JSON token-endpoint errors are
logged safely by field. Non-JSON token-endpoint bodies remain available
to the returned error so CLI and browser surfaces still show backend
detail. Transport errors keep their real `reqwest` message, but attached
URLs are surgically redacted. Custom issuer URLs are sanitized before
logging.

On the CLI side, the code intentionally duplicates a narrow slice of the
TUI file-logging setup instead of sharing the full initializer. That
keeps `codex login` easy to reason about and avoids coupling it to
interactive-session layers that the command does not need.

## Architecture

The core auth behavior lives in `codex-rs/login/src/server.rs`. The
callback path now logs callback receipt, callback validation,
token-exchange start, token-exchange success, token-endpoint non-2xx
responses, and transport failures. App-server consumers still use this
same login-server path via `run_login_server(...)`, so the same
instrumentation benefits TUI, Electron, and VS Code extension flows.

The direct CLI path in `codex-rs/cli/src/login.rs` now installs a small
file-backed tracing layer for login commands only. That writes
`codex-login.log` under `log_dir` with login-specific targets such as
`codex_cli::login` and `codex_login::server`.

## Observability

The main signals come from the `login` crate target and are
intentionally scoped to sign-in. Structured logs include redacted issuer
URLs, redacted transport errors, HTTP status, and parsed token-endpoint
fields when available. The callback-layer log intentionally avoids
`%err` on token-endpoint failures so arbitrary backend bodies do not get
copied into the normal log file.

Direct `codex login` now leaves a durable artifact for both failure and
success cases. Example output from the new file-backed CLI path:

Failing callback:

```text
2026-03-06T22:08:54.143612Z  INFO codex_cli::login: starting browser login flow
2026-03-06T22:09:03.431699Z  INFO codex_login::server: received login callback path=/auth/callback has_code=false has_state=true has_error=true state_valid=true
2026-03-06T22:09:03.431745Z  WARN codex_login::server: oauth callback returned error error_code="access_denied" has_error_description=true
```

Succeeded callback and token exchange:

```text
2026-03-06T22:09:14.065559Z  INFO codex_cli::login: starting browser login flow
2026-03-06T22:09:36.431678Z  INFO codex_login::server: received login callback path=/auth/callback has_code=true has_state=true has_error=false state_valid=true
2026-03-06T22:09:36.436977Z  INFO codex_login::server: starting oauth token exchange issuer=https://auth.openai.com/ redirect_uri=http://localhost:1455/auth/callback
2026-03-06T22:09:36.685438Z  INFO codex_login::server: oauth token exchange succeeded status=200 OK
```

## Tests

- `cargo test -p codex-login`
- `cargo clippy -p codex-login --tests -- -D warnings`
- `cargo test -p codex-cli`
- `just bazel-lock-update`
- `just bazel-lock-check`
- manual direct `codex login` smoke tests for both a failing callback
and a successful browser login

---------

Co-authored-by: Codex <noreply@openai.com>
2026-03-06 15:00:37 -08:00
Owen Lin dd4a5216c9 chore(otel): reorganize codex-otel crate (#13800)
## Summary
This is a structural cleanup of `codex-otel` to make the ownership
boundaries a lot clearer.

For example, previously it was quite confusing that `OtelManager` which
emits log + trace event telemetry lived under
`codex-rs/otel/src/traces/`. Also, there were two places that defined
methods on OtelManager via `impl OtelManager` (`lib.rs` and
`otel_manager.rs`).

What changed:
- move the `OtelProvider` implementation into `src/provider.rs`
- move `OtelManager` and session-scoped event emission into
`src/events/otel_manager.rs`
- collapse the shared log/trace event helpers into
`src/events/shared.rs`
- pull target classification into `src/targets.rs`
- move `traceparent_context_from_env()` into `src/trace_context.rs`
- keep `src/otel_provider.rs` as a compatibility shim for existing
imports
- update the `codex-otel` README to reflect the new layout

## Why
`lib.rs` and `otel_provider.rs` were doing too many different jobs at
once: provider setup, export routing, trace-context helpers, and session
event emission all lived together.

This refactor separates those concerns without trying to change the
behavior of the crate. The goal is to make future OTEL work easier to
reason about and easier to review.

## Notes
- no intended behavior change
- `OtelManager` remains the session-scoped event emitter in this PR
- the `otel_provider` shim keeps downstream churn low while the
internals move around

## Validation
- `just fmt`
- `cargo test -p codex-otel`
- `just fix -p codex-otel`
2026-03-06 14:58:18 -08:00
Michael Bolin 41b8f45b83 Merge ee0e8728fd into sapling-pr-archive-bolinfest 2026-03-06 14:45:48 -08:00
Michael Bolin 751e9463e4 merge commit for archive created by Sapling 2026-03-06 14:41:57 -08:00
Michael Bolin ee0e8728fd linux-sandbox: honor split filesystem policies in bwrap 2026-03-06 14:41:46 -08:00
Michael Bolin 4ff802ef6b config: add v3 filesystem permission profiles 2026-03-06 14:41:46 -08:00
Michael Bolin 83067a18e7 protocol: keep root carveouts sandboxed 2026-03-06 14:41:46 -08:00
Michael Bolin 66c5b0d249 sandboxing: preserve denied paths when widening permissions 2026-03-06 14:41:46 -08:00
Michael Bolin d9845f56ca linux-sandbox: plumb split sandbox policies through helper 2026-03-06 14:41:46 -08:00
Michael Bolin a7965133a0 seatbelt: honor split filesystem sandbox policies 2026-03-06 14:41:46 -08:00
Michael Bolin dc40ece846 safety: honor filesystem policy carveouts in apply_patch 2026-03-06 14:41:46 -08:00
Michael Bolin bee47a2643 protocol: derive effective file access from filesystem policies 2026-03-06 14:41:46 -08:00
Michael Bolin 45efe16881 sandboxing: plumb split sandbox policies through runtime 2026-03-06 14:41:46 -08:00
Michael Bolin b08d15058b merge commit for archive created by Sapling 2026-03-06 14:33:54 -08:00
Michael Bolin 5da322b66e linux-sandbox: honor split filesystem policies in bwrap 2026-03-06 14:12:25 -08:00