Skip to content

[P0] default Code runtime to Cloud (CLI audit P0-1) - #49

Merged
echobt merged 5 commits into
mainfrom
cursor/default-code-runtime-cloud-aff4
Sep 8, 2026
Merged

[P0] default Code runtime to Cloud (CLI audit P0-1)#49
echobt merged 5 commits into
mainfrom
cursor/default-code-runtime-cloud-aff4

Conversation

@echobt

@echobt echobt commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes CLI audit P0-1 (CLI_100_AUDIT_READY, author echobt). Designer cli signed CLI_100_CHROME_LOCK_SIGNED and answered Q9: Cloud is the shipped default for the TUI and cortex exec; This PC and SSH are explicit opt-in and may ship in 0.1.x.

A fresh install was This PC by default, so ensure_session() refused every first turn. Cortex CLI / Cortex Code now defaults the Code runtime to Cloud. This PC/SSH require CORTEX_COMPUTER (or CORTEX_SSH_HOST / CORTEX_SSH_TARGET) and an already connected session — Cloud is never substituted. No TUI chrome change.

Head SHA: 41d8112381ba471895468ce1b64421385dd783d5

Test plan

  • cargo fmt --all -- --check
  • cargo clippy -p cortex-engine -p cortex-cli -p cortex-tui --all-targets with the workspace -D warnings allowlist
  • cargo test -p cortex-engine --lib client:: (ComputerKind + ensure_session product copy)
  • cargo test -p cortex-engine --test runtime_contract_client (default Cloud POST /v1/code/sessions runtime: cloud)
  • cargo test -p cortex-cli --test exec_runtime
  • cargo test -p cortex-tui --lib first_submit_uses_cloud
  • TUI chrome / lock frames unchanged
  • Source/dependency policy — code_agent.rs split so it no longer worsens the 1000-line regression (computer.rs is new and under the cap)
  • Changed-line coverage — removed uncovered debug config --env rows (runtime vars stay in docs/configuration/env.md)
  • cargo audit — not re-run; no dependency change
  • Local QA — engine mock + exec fixture + TUI unit test; no live api.cortex.foundation turn

Attestation (required)

I attest that:

  • Security reviewed — auth, exec/sandbox, path traversal, network egress, and secret handling in this diff were reviewed. No secrets, tokens, or keyring dumps are in the change. This PC/SSH still fail closed (no silent Cloud substitution).
  • Product-facing errors — disconnected This PC/SSH use DISCONNECTED_RUNTIME. API-down paths still say The coding service is temporarily unavailable. No raw provider, SDK, or transport names.
  • TUI verified — first-submit path shares tui_code_turn_context() (Cloud via detect()). No chrome or lock frames edited.
  • Tests added — default (no CORTEX_COMPUTER) creates a Cloud session on a loopback mock; This PC/SSH without a session refuse with product copy; TUI first submit is Cloud unless explicit opt-in.
  • No secrets — no API keys, WorkOS secrets, R2/AWS credentials, or .env files are included.

Risk

Code-session create now proceeds on a fresh install (Cloud). Operators who relied on the undocumented This PC default must set CORTEX_COMPUTER=this_pc. This PC/SSH pairing stays available as opt-in in 0.1.x. No sandbox change.

Open in Web Open in Cursor 

cursoragent and others added 5 commits September 8, 2026 01:44
Fresh installs were This PC by default, so ensure_session refused
every first turn. Cloud is now the default; This PC and SSH require
CORTEX_COMPUTER (or CORTEX_SSH_HOST) and a connected session.

Co-authored-by: Mathis <echobt@users.noreply.github.com>
Co-authored-by: Mathis <echobt@users.noreply.github.com>
Co-authored-by: Mathis <echobt@users.noreply.github.com>
Designer Q9 / CLI_100_CHROME_LOCK_SIGNED: Cloud is the product
default for TUI and exec; This PC/SSH stay explicit 0.1.x opt-in.

Co-authored-by: Mathis <echobt@users.noreply.github.com>
code_agent.rs grew past the 1000-line regression cap. Move ComputerKind
into client/computer.rs and drop uncovered debug-config env rows.

Co-authored-by: Mathis <echobt@users.noreply.github.com>
@echobt
echobt marked this pull request as ready for review September 8, 2026 02:24
@echobt
echobt merged commit dd8c02e into main Sep 8, 2026
16 checks passed
@greptile-apps

greptile-apps Bot commented Sep 8, 2026

Copy link
Copy Markdown

Greptile Summary

Summary

This change has two blocking runtime-selection problems: an invalid explicit runtime can create a Cloud session, and a cached Cloud session can continue receiving turns after the user explicitly selects This PC or SSH. The disconnected SSH recovery message also gives incomplete instructions for returning to Cloud.

Merge safety

Not safe to merge until runtime selection rejects invalid explicit values and cached sessions are checked against the currently selected runtime. The SSH recovery wording should also be corrected so operators can successfully follow it.

Confidence Score: 2/5

Do not merge until explicit runtime changes cannot be bypassed by cached Cloud sessions and invalid runtime configuration fails clearly.

Two reproduced runtime-routing failures can send turns to Cloud despite an explicit non-Cloud choice or invalid configuration. A separate reproduced recovery-message issue prevents SSH users from reaching Cloud by following the displayed instructions.

Files Needing Attention: src/cortex-engine/src/client/computer.rs needs invalid-value handling and corrected recovery instructions; src/cortex-engine/src/client/code_agent.rs needs cached-session runtime compatibility validation.

Security Review

An invalid explicit CORTEX_COMPUTER value is treated as Cloud and creates a remote Cloud session. This can send work to a remote runtime when an operator intended an invalid local-runtime configuration to fail.

T-Rex T-Rex Logs

What T-Rex did

  • T-Rex produced proof for a posted P1 finding.
  • Artifacts were produced for the P1 finding, including a Rust proof, a shell script, and a log, to support review.
  • T-Rex produced proof for a posted P2 finding, with the Rust and shell-script proofs and a log artifact.
  • General-contract-validation-proof confirmed that the unknown-value path selects Cloud and creates a Cloud session. This was demonstrated by executing the unknown-computer-contract path and the run script.
  • General-contract-validation-proof demonstrated SSH override repro validation completed. The test ran the ssh-override repro script and produced a complete output log.

View all artifacts

T-Rex Ran code and verified through T-Rex

Comments Outside Diff (2)

  1. src/cortex-engine/src/client/code_agent.rs, line 465-477 (link)

    P1 Validate cached session runtime

    When a Cloud session ID is cached, this branch returns it after checking only the model. The later non-Cloud guard is skipped, so a user who explicitly selects This PC or SSH can still send a turn to the cached Cloud session. Validate the fetched session runtime against the selected computer before reusing it, or refuse the turn when they do not match.

    Artifacts

    Evidence from the check

    • This executed Rust integration-test source starts a local HTTP loopback service, creates a Cloud session, changes the selected runtime to This PC and SSH, and asserts the client posts turns to the cached Cloud session, proving the exercised scope.

    Evidence from the check

    • This authored shell wrapper writes the same loopback test and records its cargo-test command and output for comparison, showing the reproducible verification procedure.

    Command output from the check

    • The executed current-checkout cargo test exited 0 and records 201 Created for the Cloud session plus 200 OK session lookups and 200 OK turn posts after both non-Cloud selections, decisively verifying the bypass.

    View artifacts

    T-Rex Ran code and verified through T-Rex

  2. General comment

    P1 Cached Cloud session bypasses explicit This PC or SSH runtime selection

    • Bug
      • Once a Cloud session is cached, selecting This PC or SSH still permits a turn on that cached Cloud session. The deterministic loopback contract test created sess_cloud, selected each non-Cloud runtime, and observed GET /v1/code/sessions/sess_cloud followed by POST /v1/code/sessions/sess_cloud/turns, both with HTTP 200 OK.
    • Cause
      • ensure_session() processes session_id first and validates only the selected model before returning it (code_agent.rs:465-477). The ctx.computer != ComputerKind::Cloud rejection exists only in the no-cached-session branch (:479-481), so it is not applied to resumed Cloud sessions.
    • Fix
      • Before returning an existing session, validate that its runtime is compatible with the currently selected ComputerKind; reject a cached Cloud session when This PC or SSH is explicitly selected, using the disconnected-runtime error or a dedicated runtime-mismatch error.

    T-Rex Ran code and verified through T-Rex

Reviews (1): Last reviewed commit: "fix(engine): split computer kind to pass..." | Re-trigger Greptile

match normalized.as_str() {
"this_pc" | "thispc" | "local" | "paired" | "connected" => Self::ThisPc,
"ssh" => Self::Ssh,
_ => Self::Cloud,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 security Reject invalid runtimes

If an operator sets a nonempty but misspelled CORTEX_COMPUTER value, this fallback selects Cloud rather than reporting invalid configuration. The client then creates a Cloud session, so work intended for a local runtime can be sent remotely without warning. Distinguish an unset or empty value from an unknown explicit value and reject the latter.

How this was verified: An isolated recording service observed CORTEX_COMPUTER=typoed-runtime select Cloud and create a session with {"runtime":"cloud"}.

T-Rex Ran code and verified through T-Rex

use serde::{Deserialize, Serialize};

/// This PC and SSH need a bound host session. Cloud is never substituted.
pub const DISCONNECTED_RUNTIME: &str = "This PC and SSH Code execution require an already connected Code session. Connect a host and resume that session, or leave CORTEX_COMPUTER unset to use Cloud. No runtime was substituted.";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Fix SSH recovery advice

The disconnected-runtime message says that leaving CORTEX_COMPUTER unset selects Cloud, but CORTEX_SSH_HOST and CORTEX_SSH_TARGET take precedence. A user who retains either SSH setting follows this instruction, remains on SSH, and receives the same refusal again. Tell users to clear or disable the SSH selectors as well before using Cloud. This is a non-blocking usability concern that leaves the documented recovery path unusable for SSH-configured users.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Artifacts

Evidence from the check

  • Authored Rust integration test used for the targeted check.

Evidence from the check

  • Shell script that installed and ran the repro under the specified environment.

Command output from the check

  • Captured command, environment values, selected runtime, recovery error, test result, and exit code.

Evidence from the check

  • Authored Rust integration test used for the targeted check.

Evidence from the check

  • Shell script that installed and ran the repro under the specified environment.

Command output from the check

  • Captured command, environment values, selected runtime, recovery error, test result, and exit code.

View artifacts

T-Rex Ran code and verified through T-Rex

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants