[P0] /v1/me via configured API origin (CLI audit P0-4) - #50
Conversation
Greptile SummaryThis PR moves identity lookup to
Confidence Score: 2/5The PR is not yet safe to merge because its timeout contract, A slow successful response body can bypass the intended three-second cap, Files Needing Attention: src/cortex-engine/src/client/me.rs, src/cortex-cli/src/cli/handlers.rs, src/cortex-cli/tests/whoami_me.rs
|
| Filename | Overview |
|---|---|
| src/cortex-engine/src/client/me.rs | Adds configured-origin /v1/me fetching and profile parsing, but scopes the three-second timeout too narrowly. |
| src/cortex-cli/src/cli/handlers.rs | Makes whoami perform a live identity request, but its final credential fallback bypasses CORTEX_HOME. |
| src/cortex-cli/tests/whoami_me.rs | Adds configured-origin and unauthorized-response integration tests whose blocking subprocess calls starve their current-thread Wiremock runtime. |
| src/cortex-tui/src/runner/app_runner/runner.rs | Replaces the hard-coded pre-render identity request with a background request using the provider manager's configured origin. |
| src/cortex-tui/src/runner/event_loop/me.rs | Polls and applies the completed identity task without awaiting an unfinished request on the render path. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
Config[CORTEX_API_URL] --> Client[CodeAgentClient]
Token[Resolved bearer] --> Client
Client -->|GET /v1/me| API[Configured API origin]
API -->|Headers| HeaderTimeout[3-second timeout ends]
HeaderTimeout -->|Body parsing currently outside timeout| Profile[MeProfile]
Profile --> CLI[cortex whoami output]
Profile --> Task[TUI background task]
Task --> Tick[Event-loop tick]
Tick --> State[Apply identity and rerender]
Reviews (1): Last reviewed commit: "refactor: extract /v1/me to keep file-le..." | Re-trigger Greptile
Route identity through GET {CORTEX_API_URL}/v1/me instead of a
hard-coded production /auth/me, keep the call off the TUI render
path with a 3s cap, and make whoami a live check that honours
CORTEX_HOME.
Co-authored-by: Mathis <echobt@users.noreply.github.com>
Wiremock records localhost while CORTEX_API_URL uses 127.0.0.1; compare path and port instead of the host string. 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>
Co-authored-by: Mathis <echobt@users.noreply.github.com>
Move GET /v1/me client and TUI apply helpers out of already-over-limit files so the quality gate does not regress. No chrome or lock changes. Co-authored-by: Mathis <echobt@users.noreply.github.com>
Keep the 3s identity cap around headers and body, stop whoami reading $HOME/.cortex when CORTEX_HOME is isolated, and run Wiremock CLI tests on a multithreaded runtime so the fixture can serve the child process. Co-authored-by: Mathis <echobt@users.noreply.github.com>
a48ca0c to
3d17806
Compare
Summary
Fixes CLI audit P0-4: the TUI runner no longer sends the stored bearer to a hard-coded
https://api.cortex.foundation/auth/mebefore the first frame (staging tokens were leaking to production, and/auth/meis not the product path).CodeAgentClient::fetch_mecallsGET {base}/v1/meon the same origin resolver as device login and turns (CORTEX_API_URL).cortex whoamiis a live/v1/mecheck, honoursCORTEX_HOME(does not fall back to$HOME/.cortex), and exits non-zero on 401 with thecortex loginrecovery copy./v1/meclient and TUI apply helpers live in dedicated modules socode_agent.rs,state.rs, andevent_loop/core.rsdo not grow past their existing line-count caps.CLI_100_CHROME_LOCK_SIGNED).Rebase: replayed onto
origin/main9154266(#49 Cloud-default + #51 green lock packs). Only conflict:src/cortex-engine/src/client/mod.rs(two commits). Kept bothmod computer/DISCONNECTED_RUNTIMEfrom #49 and the/v1/mememodule exports. New HEAD:3d178068add022ad1f36698390ec1d22c9b19fbc. GitHub now reportsmergeable=MERGEABLE. Leave squash-merge to Oding.Test plan
cargo fmt --all -- --check(post-rebase)-p cortex-engine -p cortex-cli -p cortex-tui --all-targetswith the CI allow list (-D warnings)cargo test --locked -p cortex-engine --lib -- fetch_me me_urlcargo test --locked -p cortex-engine --test runtime_contract_client(Cloud-default from [P0] default Code runtime to Cloud (CLI audit P0-1) #49)cargo test --locked -p cortex-cli --test whoami_me --test exec_runtimecargo test --locked -p cortex-tui -- apply_me_profile snapshot_motd_shows_org ux_contract_me_profile me_profile_request_urlpython3 scripts/readiness/schema.py --writenot needed)cargo audit—cargo-auditis not installed in this environment (CI Security Audit is green)mainsizesCORTEX_API_URL/v1/meAttestation (required)
I attest that:
CORTEX_API_URL/CodeAgentClientbase). IsolatedCORTEX_HOMEdoes not inherit$HOME/.cortex. No secrets, tokens, or keyring dumps are in the change.cortex login/ The coding service is temporarily unavailable). No raw provider, SDK, or transport names./v1/meis the only host contacted; stalled body times out inside 3s;whoamiagainst a 401 fixture prints the login copy and exits non-zero. No mock-success..envfiles are included.Risk
Auth/API-contract: identity and
whoaminow depend on liveGET /v1/me. A stagingCORTEX_API_URLno longer forwards the bearer to production. Slow/v1/meno longer freezes TUI open (org may stayPersonaluntil the background fetch lands).