Skip to content

fix(bots): use the selected codex profile for isolated bot login - #1213

Merged
nixuuu merged 14 commits into
devfrom
fix/windows-codex-login-link
Nov 24, 2026
Merged

nixuuu merged 14 commits into
devfrom
fix/windows-codex-login-link

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Change

Codex bots authenticate through the selected native provider profile on the worker. A fresh local app-server resolves the profile's login. The bot uses an ephemeral credential store in its private home and keeps its conversation, tool restrictions and instructions. On resume the bot asks for the thread handle while Codex loads the full history internally. Bot startup and renewal no longer create credential links or require Windows Developer Mode.

The worker checks effective inference, account and catalog routes before providing credentials. On supported Codex releases it checks the active stored workspace and user before requesting the access token again. ChatGPT renewal stays bound to that same identity and can reuse recently renewed access. The selected profile keeps the refresh token. API-key logins use the same local transport. Unsupported authentication and incompatible routing stop the turn.

Upstream Codex can independently renew stale credentials during app-server startup. Codex 0.164 and 0.165 lack the cached account preflight and can also renew during the status read. The worker verifies the identity of returned credentials before using them in the bot.

Startup cleans verified obsolete bot aliases. An unrecognized login file is preserved under a private backup name before the bot starts. Ordinary isolated instances that still require a link preserve their previous login path when replacement is denied. The default Use CLI home thread path and the title generator keep their existing behavior.

When the default Windows bot home leaves too little room for a SQLite journal, Canopy supplies a shorter private SQLite directory scoped to the same bot, conversation and provider instance. Existing conversation databases are snapshotted with their committed WAL data before the new directory is published. The native rollout stays in place. Explicit SQLite locations configured in the profile or worker environment or Codex configuration retain their normal precedence.

Verification

  • Linux, PR revision 3078abbac: 71 focused tests passed across 12 files. Coverage includes login migration, WorkerHost profile selection and restart, gateway bot turns, conversation isolation and a live-WAL migration fixture, explicit database locations and the ordinary CLI home. Worker typecheck, targeted lint, formatting and diff checks passed.
  • Linux, same revision: real Codex 0.164.0 and 0.172.0 each passed 57 assertions using fictional credentials and loopback services. Tests verify same-session history, access rotation, renewal, sign-out, destination checks and credential persistence.
  • Windows regression on revision 7b82a430b: both CLI versions authenticated successfully but failed to open the history database on cold resume (SQLite 14). The database path was 254 characters before SQLite appended a journal suffix. Windows diagnostics
  • Native Windows, preceding revision a5f69d1e6: both real Codex releases passed the long-path login and cold-resume regression. The WorkerHost and WAL snapshot tests passed as well. Windows job
  • Native Windows, final revision 3078abbac: both pinned Codex releases completed the full login and cold-resume regression with long paths. Profile selection, login recovery, explicit database locations and the WAL snapshot tests passed. Windows verification

Fixes: #1150

Acquire the selected profile's login through local app-server RPC. Bind renewal to the admitted user and workspace and require matching credential destinations before using the isolated process's ephemeral store.

Fixes: #1150
@nixuuu nixuuu changed the title fix(codex): preserve login links when windows denies migration fix(bots): use the selected codex profile for isolated bot login Nov 24, 2026
@nixuuu
nixuuu marked this pull request as ready for review November 24, 2026 14:48
@nixuuu

nixuuu commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

The native Windows regression passed at 3078abbac with Codex 0.164.0 and 0.172.0. Both resumed the same conversation after the selected profile login rotated. The database migration test also passed with committed WAL data. Windows job

Merge is blocked on the GitHub account configuration. GitHub rejected the author’s noreply address for squash auto-merge and currently lists no noreply address as an available commit email. The maintainer needs to make their GitHub noreply address available for web commits, then enable squash auto-merge. Auto-merge is off.

@nixuuu
nixuuu merged commit be7b197 into dev Nov 24, 2026
23 checks passed
@nixuuu
nixuuu deleted the fix/windows-codex-login-link branch November 24, 2026 15:09
nixuuu added a commit that referenced this pull request Nov 26, 2026
## Changes

- Preserve the directory entry when resolving a Codex login. On macOS,
Bun can return the path of another hard link to the same inode during
concurrent lookups. Bot migration now detaches the managed link while
protecting the source login, including a source reached through a
symbolic link.
- Lock the thread before marking `StartTurn` and `SteerTurn` as
delivered. This matches archival and prevents the sandbox profile
trigger from deadlocking against command expiry.
- Wait for the gateway's persisted turn context in the linked-agent
fixture. Give the Tailscale and Windows Codex fixtures separate process
and test budgets with useful failure diagnostics. Run one native
packaging test per macOS architecture and log the slow `actool` and
Swift phases.
- Retry failed Release jobs once for a scheduled nightly when GitHub
annotated each failed job with a hosted runner disconnect or an
exhausted `CreateArtifact` request timeout. The retry uses the same run
and revision and preserves the existing Push CI and publication gates.

## Verification

- Bun 1.4.5 on Apple Silicon passed 24 Codex migration and bot login
tests and 12 desktop packaging tests through `check:tmp`. A
50,000-iteration race reproduced 23,655 missed links with the previous
lookup and zero after the fix.
- PostgreSQL 18 reproduced `40P01` with the old outbox lock order. The
regression passed five repetitions after the fix. All 31 targeted
archive, linked-agent and sandbox integration tests passed.
- Tailscale passed 60 repeated executions. Both pinned Codex versions
passed the live login fixture on macOS. Codex 0.172.0 also passed with
an injected 24-second credential probe startup delay.
- Worker and integration typechecks, focused lint and formatting,
`actionlint`, and `git diff --check` passed. Tested the recovery script
with real historical GitHub job data and a stubbed POST for runner loss,
the `CreateArtifact` timeout that blocked
[v0.11.0-nightly.1](https://github.com/itsoltech/canopy/actions/runs/45770577786/attempts/1),
an ordinary CI failure, and a prior rerun.
- GitHub CI covers the native Windows and macOS Intel changes. Live
recovery requires a future scheduled Release with one of the recognized
GitHub infrastructure failures.

Fixes: #1213
Fixes: #1114
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.

1 participant