Skip to content

Keep Codex account preparation from sharing SQLite sidecars and runtime state #37

Open

Description

@Tiyouw

Codex account preparation shares missing entries from the default home except auth.json. This can mix a physical account database with another home's transient SQLite journals. The broad sharing path is still present in main cd071c6299c93b91c6e21643ca6c6c11156a39d7.

Reproduction with synthetic fixtures only:

  1. Set fresh HOME, USERPROFILE, ENOWX_HOME, CODEX_HOME and temporary/app-data directories before starting the test process. No agent executable or sign-in is needed.
  2. Open a synthetic default state_5.sqlite in WAL mode and keep it open.
  3. Create two account records and physical SQLite databases in their generated homes. Close those account databases and confirm their WAL/SHM files disappeared.
  4. Reopen the account store and prepare an account with Store.Env("codex", id).
  5. Inspect the absent account WAL path before reopening its database: preparation links it to the default home's WAL. Removing a link once does not prevent preparation from recreating it.

The regression executed against pristine upstream 048b78ece9b54ab5c2d5f32c1944eb738c82311c fails at cycle 0 with runtime state_5.sqlite-wal reached account: <nil>. The correction passes four close/prepare/reopen cycles with two separate row sets. This establishes unsafe path sharing; it does not prove a cause of historical database corruption.

Expected behavior: share known settings and conversations only; keep databases, journals, auth, sockets, daemon state and unknown runtime names private on every preparation. Shared rollouts and their writer locks must use one canonical namespace. Refuse unsafe legacy links without modifying them or their targets. An account-environment preparation failure during daemon restoration should leave the session stopped, rather than start it with the default identity.

The proposed focused correction also respects an explicit config CODEX_HOME before touching an unused generated home. Automatic legacy migration, database repair, private index rebuilding and authenticated lifecycle validation are outside its scope.

Activity

  1. enowdev commented on Nov 5, 2026

    @enowdev
    Owner

    Confirmed on main e306b3b, and worth keeping open until this lands.

    core/accounts/accounts.go:43 lists only auth.json as the account's own, so share() at :334-344 links every other entry of ~/.codex, SQLite sidecars included, and ignores symlink failures. daemon/persist.go:311-315 also logs a failed account preparation and starts the session anyway, without CODEX_HOME.

    PR #38 addresses both. It still needs a migration or a clear way out for account homes that already carry those runtime links, since it refuses them without changing anything.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions