Skip to content

fix(codex): discover resumed project stores through writer locks - #3825

Merged
devswha merged 1 commit into
devswha:mainfrom
rocking5566:fix/codex-resumed-project-store
Nov 15, 2026
Merged

devswha merged 1 commit into
devswha:mainfrom
rocking5566:fix/codex-resumed-project-store

Conversation

@rocking5566

Copy link
Copy Markdown
Contributor

Change

After restarting and resuming a Codex TUI with a project-local store, Chat still falls back to empty scrollback even with #3792. The resumed process holds its interactive rollout and exclusive thread writer lock, but no longer keeps state_5.sqlite open. The database-plus-rollout discovery therefore cannot identify its store.

Accept the store of an open interactive rollout whose session ID matches a writer lock held exclusively by the same PID. Verify ownership through Linux fdinfo, retain descriptor/path inode checks and canonical containment, and require exactly one store across database-backed and lock-backed candidates. Explicit CODEX_HOME still wins; inferred lock ownership is rechecked on every lookup.

Regression coverage includes actual kernel locks without an open database, unlock/relock without closing the file, unlocked/shared/mismatched locks, cross-store mismatches, ambiguity between two lock-backed stores or a database-backed and lock-backed store, noninteractive rollouts, replaced lock paths, and explicit CODEX_HOME.

Validation

  • Red/green reproduction: the resumed session test fails on unchanged main and passes with this change.
  • bun test server/codex-process-lock-store.test.ts server/codex-process-store.test.ts server/codex-processes.test.ts: 299 passed.
  • Transplanted only the process-store discovery region into the affected local 0.4.22 installation, with backups; the same three local test files passed 160 tests.
  • Restarted only the Ovis bridge and checked existing conversation endpoints read-only: all 10 Codex panes returned codex-transcript with turns, including all 7 previously falling back to empty scrollback. All existing agent/session identities remained unchanged. No transcript contents are included here.
  • bun run check fast: workflow syntax, generated files, typecheck, and build passed. Unit results: 17,015 passed, 141 failed, 57 skipped across 944 files. All 10 new lock-store cases passed in this run. This is not a green full check. The NFS temp filesystem causes numerous EBUSY cleanup failures; additional existing failures occur in other modules. On a separate unchanged checkout of the same base (15b325e0), targeted reruns of server/codex.test.ts (the WAL cleanup case), server/codex-daemon.test.ts, server/conversation.test.ts, server/pc-install.test.ts, and server/omp.test.ts reproduced 50 of the same failing cases. The remaining broad-suite failures were not individually diagnosed. Tests used TMPDIR under ~/.cache/ovis-tmp/ as required by AGENTS.md.
  • Skipped the full integration/browser suite and native Windows/macOS checks; this change adds Linux process-store discovery and does not change the UI or HTTP/WS contract.
Files with failures in the full fast check
  • server/codex.test.ts
  • server/conversation.test.ts
  • server/pc-install.test.ts
  • server/omp.test.ts
  • server/prompt.test.ts
  • server/question-steps.test.ts
  • scripts/install-ovis-command.test.ts
  • server/grok.test.ts
  • scripts/self-hosted-runner.test.ts
  • server/open-access.test.ts
  • server/codex-daemon.test.ts
  • server/omp-images.test.ts
  • server/machine-core-choice.test.ts
  • server/file-edit.test.ts
  • server/background-agent.test.ts
  • server/runtime-move-lock.test.ts
  • server/herdr-core/terminal-env.test.ts
  • server/pi-delivery.test.ts
  • server/runtime-move-stop.test.ts
  • server/state-document.test.ts
  • server/chat-read-timeout.test.ts
  • server/conversation-shared.test.ts
  • server/skills/cmd.test.ts
  • server/session-history.test.ts

@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • On Linux, resumed Codex sessions can now open Chat when the session’s conversation and matching writer lock remain available, even if the state database is closed.
    • Session discovery still requires a uniquely matching interactive session and an active writer lock; ambiguous or incomplete results do not qualify.

Linux process-based Codex home discovery now recognizes a matching held writer lock and interactive rollout when the database descriptor is closed. Tests cover lock ownership and related discovery cases. A changelog entry documents the resumed-session scenario.

Changes: Codex home discovery

Layer / File(s) Summary
Writer-lock discovery and validation
server/codex.ts, server/codex-process-lock-store.test.ts, changelog.d/codex-resumed-project-store.md
processCodexHome recognizes a store when a process holds the matching exclusive writer lock and the store contains an interactive rollout with the matching metadata ID. The existing database-based discovery remains. Tests cover lock, rollout, ambiguity, and explicit CODEX_HOME cases. The changelog describes the resumed-session scenario.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: Minimal · up to 05d07

Resumed Codex sessions should now open Chat when only the writer lock and conversation remain. Discovery is limited to Linux and falls back safely when ambiguous. No merge-blocking risk is identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: Codex resumed project store discovery through writer locks, which matches the codex.ts and test changes. The fix prefix fits the changelog Fixed entry. It is specific …
Description check Passed The description has the Change and Validation sections from the template. It explains the problem (resumed TUI falls back to empty scrollback without an open state_5.sqlite), the behavior change, regr…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: Codex resumed project store discovery through writer locks, which matches the codex.ts and test changes. The fix prefix fits the changelog Fixed entry. It is specific and concise.

Full details: Description check

Explanation

The description has the Change and Validation sections from the template. It explains the problem (resumed TUI falls back to empty scrollback without an open state_5.sqlite), the behavior change, regression coverage, and detailed validation. It does not mention the changelog entry, but the template's CONTRIBUTING reference is guidance and the raw summary shows changelog.d/ was updated. The Validation section reports a failing full check, but it is transparent about the result. The description is mostly complete.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: devswha/ovis
  • Branch: main
  • File: .coderabbit.yaml
  • Commit: 15b325e
  • Layers: Repository YAML
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 685d4bba-1f0c-4a46-8d4c-1570e20440ae
Commits

Reviewing files that changed from the base of the PR and between 15b325e and 05d077a.

Files selected for processing: 3

  • changelog.d/codex-resumed-project-store.md
  • server/codex-process-lock-store.test.ts
  • server/codex.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

@devswha

devswha commented Nov 13, 2026

Copy link
Copy Markdown
Owner

Thank you again, @rocking5566. The merge pass reviewed this at 05d077a with two reviewers under the stricter bar for outside PRs; both are clear, with nothing above LOW. The Opus reviewer ran your new test file against main's server/codex.ts: the two cases the fix exists for (a resumed session holding only its rollout and writer lock; a database store next to a different locked store) fail there and pass here; 23 tests pass in the two store files. No supply-chain change: the only new I/O is local reads under /proc.

It does not merge yet for one reason that is not about the code: a release freeze is on, and nothing touching server/ merges until the next Release run is done. It merges then on green, with a local gate (a fork's checks do not run here).

Two LOW points, for you to take or leave (both read, not run): a writer lock released between two system calls of the scan (a subagent ending) now makes the whole lookup return null for one poll, where main resolves the database-backed store (server/codex.ts:477-481): skip a lock that vanished instead of failing the scan; each held lock re-reads every open rollout's header, 256 KiB at a time, about every 2 s for a visible chat (:496-506): read each header once before matching.

@devswha

devswha commented Nov 14, 2026

Copy link
Copy Markdown
Owner

Thank you, @rocking5566. To keep three neighbouring Codex fixes from rotting, the merge pass read this one together with #3762 and #3442. They fix different steps of the same lookup (yours: finding the store; #3762: finding the process behind tmux; #3442: finding the conversation by its saved name), none is a duplicate, and yours conflicts with nothing. This one lands first, as soon as the release freeze ends (it touches server/codex.ts); both reviewers are clear. One optional improvement the comparison found: move the /proc/<pid>/fdinfo read inside the per-descriptor try, so one descriptor closing mid-scan does not fail the whole lookup.

@devswha
devswha merged commit 6fc18d0 into devswha:main Nov 15, 2026
24 checks passed
@devswha

devswha commented Nov 15, 2026

Copy link
Copy Markdown
Owner

Merge pass

Merged head 05d077a4b176 as 6fc18d050b87 on GitHub's checks, with no unresolved review threads.

Reviewer Verdict Note
claude CLEAR
codex CLEAR

Thank you, @rocking5566.

The bug was reproduced before merging: the pull request's own new test, run against main's server/codex.ts, fails with resolves a resumed project rollout with its exclusive writer lock and no database (expected the project's .codex, received null); at this head the file passes 10 of 10, including the unlock and relock checks.

One more thing this changes, for the record: a process that holds one store's database with a rollout and also another store's locked rollout was resolved to the database store on main; it is now treated as ambiguous and Chat falls back to the terminal's scrollback. Linux only, and skipped when CODEX_HOME is set.

devswha added a commit to cheol-95/ovis that referenced this pull request Nov 15, 2026
Brings in devswha#3825 (Codex stores found through writer locks). No conflicts; it changes
how a process's Codex home is found and does not touch the saved-name recovery.

Co-authored-by: sisyphus-dev-ai <[email protected]>
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