[GH-ISSUE #2441] [Issue]: 11-PROV-RUNTIME-chatgpt-local-auth stale Codex tokens do not refresh #1195

Closed
opened 2026-10-21 05:28:44 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @Promansis on GitHub (Jun 6, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2441

Originally assigned to: @SpicyMarinara on GitHub.

Summary

11-PROV-RUNTIME-chatgpt-local-auth parity gap: the refactor ChatGPT local auth path does not refresh stale Codex ChatGPT tokens on the same conditions as legacy.

Expected behavior

ChatGPT local auth should load Codex auth.json, refresh when the access JWT is near expiry or last_refresh is older than the legacy refresh interval, write refreshed tokens back, and then apply the refreshed token to ChatGPT Codex requests.

Actual behavior

The refactor only refreshes when last_refresh is present but empty. A dated stale refresh timestamp or near-expiry access JWT does not trigger refresh before provider requests.

Steps to reproduce

  1. Configure an openai_chatgpt connection using local Codex ChatGPT auth.
  2. Use a Codex auth file with a near-expiry access JWT or a last_refresh older than the legacy refresh interval.
  3. Trigger connection auth check or ChatGPT generation.

Impact area

  • App shell, navigation, startup, or providers
  • Catalog resources
  • Chat mode
  • Roleplay mode
  • Game mode
  • Shared mode UI
  • Runtime systems: generation, world-state, visuals, tracker, or haptics
  • Professor Mari or shell tools
  • React-free engine behavior, contracts, agents, or capability ports
  • Shared API wrapper or remote runtime routing
  • Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime
  • Docs, contributor workflow, or templates

Environment

  • Branch or commit: refactor@09923989 parityscan context from #2410
  • Run mode: Tauri desktop / remote runtime provider transport
  • OS + version: not run
  • Node + pnpm versions: not run
  • Rust version, if relevant: not run
  • Remote Runtime URL configured? not relevant
  • Provider, model, or integration, if relevant: OpenAI ChatGPT local auth

Logs, screenshots, or video

Static proof only. No private auth files inspected.

Legacy evidence:

  • packages/server/src/services/llm/openai-chatgpt-auth.ts: jwtExpiresSoon and lastRefreshIsStale trigger refresh at lines 96-109; loadAuthImpl refreshes when either condition is true at lines 228-236; refreshed tokens are written back at lines 213-223.

Refactor evidence:

  • src-tauri/crates/llm/src/lib.rs: openai_chatgpt_auth_is_stale returns true only for an empty last_refresh string at lines 1541-1549; load_openai_chatgpt_auth refreshes only through that predicate at lines 1463-1518.

Regression notes

Worked in legacy main per #2410 source definition for 11-PROV-RUNTIME-chatgpt-local-auth.

Additional context

Surface: 11-PROV-RUNTIME-chatgpt-local-auth.

Tracked from #2410 Batch 13.

Acceptance criteria:

  • Refactor refreshes ChatGPT local auth when access JWT expiry is near, matching legacy skew behavior.
  • Refactor refreshes when last_refresh is older than the legacy refresh interval.
  • Refreshed tokens are persisted back to the Codex auth file without leaking token values.
  • Missing/stale-auth errors remain secret-safe and do not expose local secrets.
  • Focused Rust proof covers fresh, stale, near-expiry, and missing-refresh-token cases without using private auth files.

Template check

Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @Promansis on GitHub (Jun 6, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2441 Originally assigned to: @SpicyMarinara on GitHub. ## Summary `11-PROV-RUNTIME-chatgpt-local-auth` parity gap: the refactor ChatGPT local auth path does not refresh stale Codex ChatGPT tokens on the same conditions as legacy. ## Expected behavior ChatGPT local auth should load Codex `auth.json`, refresh when the access JWT is near expiry or `last_refresh` is older than the legacy refresh interval, write refreshed tokens back, and then apply the refreshed token to ChatGPT Codex requests. ## Actual behavior The refactor only refreshes when `last_refresh` is present but empty. A dated stale refresh timestamp or near-expiry access JWT does not trigger refresh before provider requests. ## Steps to reproduce 1. Configure an `openai_chatgpt` connection using local Codex ChatGPT auth. 2. Use a Codex auth file with a near-expiry access JWT or a `last_refresh` older than the legacy refresh interval. 3. Trigger connection auth check or ChatGPT generation. ## Impact area - [ ] App shell, navigation, startup, or providers - [ ] Catalog resources - [ ] Chat mode - [ ] Roleplay mode - [ ] Game mode - [ ] Shared mode UI - [ ] Runtime systems: generation, world-state, visuals, tracker, or haptics - [ ] Professor Mari or shell tools - [ ] React-free engine behavior, contracts, agents, or capability ports - [ ] Shared API wrapper or remote runtime routing - [x] Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime - [ ] Docs, contributor workflow, or templates ## Environment - Branch or commit: refactor@09923989 parityscan context from #2410 - Run mode: Tauri desktop / remote runtime provider transport - OS + version: not run - Node + pnpm versions: not run - Rust version, if relevant: not run - Remote Runtime URL configured? not relevant - Provider, model, or integration, if relevant: OpenAI ChatGPT local auth ## Logs, screenshots, or video Static proof only. No private auth files inspected. Legacy evidence: - `packages/server/src/services/llm/openai-chatgpt-auth.ts`: `jwtExpiresSoon` and `lastRefreshIsStale` trigger refresh at lines 96-109; `loadAuthImpl` refreshes when either condition is true at lines 228-236; refreshed tokens are written back at lines 213-223. Refactor evidence: - `src-tauri/crates/llm/src/lib.rs`: `openai_chatgpt_auth_is_stale` returns true only for an empty `last_refresh` string at lines 1541-1549; `load_openai_chatgpt_auth` refreshes only through that predicate at lines 1463-1518. ## Regression notes Worked in legacy `main` per #2410 source definition for `11-PROV-RUNTIME-chatgpt-local-auth`. ## Additional context Surface: `11-PROV-RUNTIME-chatgpt-local-auth`. Tracked from #2410 Batch 13. Acceptance criteria: - Refactor refreshes ChatGPT local auth when access JWT expiry is near, matching legacy skew behavior. - Refactor refreshes when `last_refresh` is older than the legacy refresh interval. - Refreshed tokens are persisted back to the Codex auth file without leaking token values. - Missing/stale-auth errors remain secret-safe and do not expose local secrets. - Focused Rust proof covers fresh, stale, near-expiry, and missing-refresh-token cases without using private auth files. ## Template check Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:28:44 +07:00
Author
Owner

@SpicyMarinara commented on GitHub (Jun 6, 2026):

Fixed in refactor with commit d0996bae.

Behavior changed:

  • ChatGPT local Codex auth now refreshes when the access JWT expires within the legacy 60-second skew.
  • ChatGPT local Codex auth now refreshes when last_refresh is older than the legacy 8-day interval.
  • Stale auth without a refresh token now fails with the legacy secret-safe guidance instead of silently using stale access.
  • Successful refresh updates access/refresh/id tokens, writes an ISO last_refresh, and fails loudly if the refreshed auth file cannot be serialized or persisted.
  • Missing/stale-auth messages stay local-path/token safe.

Verification:

  • cargo test --manifest-path src-tauri/Cargo.toml -p marinara-llm openai_chatgpt -- --nocapture
  • cargo check --manifest-path src-tauri/Cargo.toml --workspace
  • pnpm check:architecture
<!-- gh-comment-id:4638210833 --> @SpicyMarinara commented on GitHub (Jun 6, 2026): Fixed in refactor with commit d0996bae. Behavior changed: - ChatGPT local Codex auth now refreshes when the access JWT expires within the legacy 60-second skew. - ChatGPT local Codex auth now refreshes when last_refresh is older than the legacy 8-day interval. - Stale auth without a refresh token now fails with the legacy secret-safe guidance instead of silently using stale access. - Successful refresh updates access/refresh/id tokens, writes an ISO last_refresh, and fails loudly if the refreshed auth file cannot be serialized or persisted. - Missing/stale-auth messages stay local-path/token safe. Verification: - cargo test --manifest-path src-tauri/Cargo.toml -p marinara-llm openai_chatgpt -- --nocapture - cargo check --manifest-path src-tauri/Cargo.toml --workspace - pnpm check:architecture
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#1195
No description provided.