Skip to content

fix(codex): a pod-less Codex seat's restore keeps its git dirs writable, so it can still commit - #2023

Merged
mvschwarz merged 11 commits into
mainfrom
fix/codex-restore-gitdirs
Oct 25, 2026
Merged

mvschwarz merged 11 commits into
mainfrom
fix/codex-restore-gitdirs

Conversation

@mvschwarz

@mvschwarz mvschwarz commented Oct 25, 2026 •

Copy link
Copy Markdown
Owner

What this changes

A pod-less Codex seat restored through CodexResumeAdapter (by rig up --existing, or a restore after a reboot) now gets the same git metadata --add-dirs that #2000 gave its fresh, resume and fork launches, so it can still commit in its worktree. Seats in a pod restore through the launch adapter, which #2000 already fixed.

CodexResumeAdapter, which serves only seats without a pod, added none of them. A default workspace-write seat restored that way couldn't write its worktree's .git, and commits failed, which is the bug #2000 fixed for the other launch paths.

How

  • The same resolver (resolveCodexGitAddDirs), wired in at startup:
    • an ordinary repository gets <cwd>/.git;
    • a linked worktree gets its worktree and common git dirs, never the .git file.
  • After the conversation id, with the git dirs first and then the seat folder (fix(codex): a seat's own topology folder is writable, so it keeps its LEARNED.md and recap #2018), so the resume proof still reads the id when a path has a space.
  • Only on the plain workspace-write floor, the same rule as the seat folder. A named profile isn't checked for read-only on this path, and Codex refuses a writable root under a read-only sandbox.
  • Rebuilds and the launch adapter are untouched.

Tests

  • The restore path with real temporary repositories:
    • an ordinary repository's restore adds <cwd>/.git, the same as its fresh launch, after the id, and the id still parses from a path with a space;
    • a linked worktree's restore adds its worktree and common git dirs, never the .git file.
  • The restore command's order and floor: git dirs, then the seat folder, after the id on the plain floor. A named profile gets none, and the resolver isn't called.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Resuming a conversation in a standard workspace now includes the relevant Git directories, helping preserve Git access. This also works with linked worktrees and paths containing spaces.
    • Resumes using a named profile remain unchanged and do not add these directories.

review50-r3 and others added 4 commits October 25, 2026 11:41
rig context recap-write wrote the recap in the caller's own process, so a
seat whose writable roots don't include the topology tree (a default
workspace-write Codex seat) failed with EPERM at mkdir, and a rebuild
started without the seat's decisions unless an operator installed the
draft by hand.

The CLI still writes locally first. When the OS refuses that write
(EPERM, EACCES or EROFS), it sends the same recap to the daemon's new
POST /api/context-packs/seat-recap, which owns the topology tree and
primes RECAP.md at the next rebuild. Both paths call one store function,
writeSeatRecapAt, which holds the address checks the CLI used to do
inline: bounded segments, an existing rig, no symlinked or file segment,
and a created seat folder. Callers that can write behave as before,
including with the daemon down.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The shared Markdown parser's heading regex backtracked polynomially on
  a long whitespace run, and the daemon now parses submitted recaps. A
  short scan replaces it and keeps the same headings: up to three
  spaces, one to six #, whitespace or the end next, and a trimmed title
  with no line break inside. Handover profiles and the CLI's advisory
  scan use the same parser.
- The store and route comments now say what the address checks cover:
  the rig, seats and seat folders. A link already at RECAP.md or its
  archive folder is followed, as the local write always did.
- When the daemon writes the recap, the success line names it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… LEARNED.md and recap

A default workspace-write Codex seat can't write its own topology folder
(<topology root>/rigs/<rig>/seats/<seat>), where its LEARNED.md and recap
live: the folder sits outside the seat's writable roots, so both writes fail
with EPERM and what the seat learned is lost to its next occupant.

Each Codex launch now adds that one folder as an --add-dir, created first if
missing (Codex can't create it), under the same rules as the git metadata
dirs: fresh, resume and fork alike, after the conversation id on resume and
fork so the ps proofs survive a path with a space, none for a rebuild (its
observed envelope keeps what ran) or a provably read-only profile, and an
in-place restart keeps the running process's own add-dirs. The restore path's
resume adds it on the plain workspace-write floor. A malformed seat name, an
unsafe segment or a symlinked rigs/seats segment gives no folder, with a
warning, and nothing is created through a symlink.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e, so it can still commit

#2000 gave Codex's fresh, resume and fork launches the git metadata dirs as
--add-dirs, so a restored or forked seat can still commit. A restore through
the restore path (rig up --existing, a restore after a reboot) resumes
through CodexResumeAdapter, which added none: a default workspace-write seat
restored that way couldn't write its worktree's .git, and commits failed.

That path now adds the same git dirs, from the same resolver, then the seat
folder, after the conversation id so the resume proof reads the id even from
a path with a space. Only on the plain workspace-write floor, as for the seat
folder: a named profile isn't checked for read-only there, and Codex refuses
a writable root under one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 30afe288-c46b-487a-970f-c1c29c523d6d
Commits

Reviewing files that changed from the base of the PR and between ca3b229 and 3a92c59.

Files selected for processing: 4
  • packages/daemon/src/adapters/codex-resume.ts
  • packages/daemon/src/startup.ts
  • packages/daemon/test/codex-git-add-dirs.test.ts
  • packages/daemon/test/codex-resume.test.ts

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

Walkthrough

On pod-less Codex resumes, the adapter adds resolved Git metadata directories and the prepared topology folder to --add-dir only for the plain workspace-write floor without a named profile. Startup supplies the resolver, and tests cover ordinary repositories and linked worktrees.

Changes: Codex resume writable directories

Layer / File(s) Summary
Resolve and append resume directories
packages/daemon/src/adapters/codex-resume.ts, packages/daemon/src/startup.ts
The adapter combines resolved Git metadata directories with the prepared topology folder when no named profile is active and the launch posture is workspace-write. It appends each nonempty root as a quoted --add-dir argument. Startup supplies the Git-directory resolver.
Verify resume directory arguments
packages/daemon/test/codex-git-add-dirs.test.ts, packages/daemon/test/codex-resume.test.ts
Tests check restore arguments for ordinary repositories and linked worktrees. They also verify that named-profile resumes omit --add-dir and do not call the resolver.

Priority: Normal

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

Change: Bug fix

Possibly related PRs

  • mvschwarz/openrig#2000: Adds Git --add-dir paths to Codex fresh, resume, and fork launches through CodexRuntimeAdapter.
  • mvschwarz/openrig#2018: Adds the seat topology folder to CodexResumeAdapter under the same workspace-write floor.
  • mvschwarz/openrig#1791: Suppresses generated writable roots for read-only named Codex profiles.

Suggested reviewers: openrig-review, rudycelekli, shravansumanthanan

Merge Risk: Minimal · up to 3a92c

Pod-less Codex resumes gain the intended Git-directory arguments, with no identified issue blocking merge after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the fix (pod-less Codex seat restore keeps git metadata directories writable so it can commit), and the raw summary and objectives confirm that the change adds git metadata --add-dir p…
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 fix (pod-less Codex seat restore keeps git metadata directories writable so it can commit), and the raw summary and objectives confirm that the change adds git metadata --add-dir paths to CodexResumeAdapter restores on the plain workspace-write floor. The title is specific and matches the primary change. It is long at 95 characters, and it uses a comma clause, but it still conveys the main change clearly.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • 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

Comment @coderabbitai help to get the list of available commands.

review50-r4 (OpenRig Build) and others added 3 commits October 25, 2026 13:02
…t folder

A Codex seat may now write its own topology folder, and the daemon writes
there for it through the recap route with its own wider filesystem access.
So a link the seat plants at RECAP.md or recap-superseded/ would carry the
daemon's write out of the folder: an archived recap, with bytes the seat
chose, landing in whatever folder the link names.

Before touching current or archived recap state, the store now requires an
existing RECAP.md to be a regular file and recap-superseded/ a real folder,
dangling links included, and otherwise refuses the write with a clear
message, leaving the current recap, the archive and the link's target as
they were. This intentionally refuses a layout the store used to follow. The
direct write, the daemon fallback and the existing error are unchanged. The
check runs before the write, so a change made in between isn't covered.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dev-driver and others added 4 commits October 25, 2026 13:47
CodexResumeAdapter serves only seats without a pod; a seat in a pod
resumes through the launch adapter, which #2000 already covers. The two
test comments and the describe title said every restored seat. Text only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…writable

#2008 landed as a squash, so this branch's merged copy of #2008
conflicted. main's three conflicted files are byte-identical to #2008's
a3ef5b7, so each resolves to this branch's version and the net diff
against main is #2018's own change plus the store check, unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nto fix/codex-restore-gitdirs

#2018 now carries main with #2008 squash-merged. No conflicts; this
branch's net diff against #2018 is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#2018 landed as a squash, so this branch's merged copy of #2018
conflicted. main's four conflicted files are byte-identical to #2018's
final head 5842d1f, so each resolves to this branch's version and the
net diff against main is #2023's own four files, unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mvschwarz
mvschwarz marked this pull request as ready for review October 25, 2026 15:40
@mvschwarz mvschwarz changed the title fix(codex): a seat restored after a reboot keeps its git dirs writable, so it can still commit fix(codex): a pod-less Codex seat's restore keeps its git dirs writable, so it can still commit Oct 25, 2026

@openrig-review openrig-review left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved at 3a92c59. A pod-less Codex seat restored through CodexResumeAdapter (rig up --existing, or a restore after a reboot) now gets the git metadata --add-dirs that #2000 gave fresh, resume and fork launches, then its seat folder, after the conversation id and only on the plain workspace-write floor, so it can still commit. Seats in a pod restore through the launch adapter #2000 already fixed. Pair: dev60-review (Claude) and review-r2 (Codex) at 21f8930, with dev60-review's wording fix rechecked; the main merge to this head adds only main, checked by net diff. Required CI passes at this head.

— dev60-planner@v-openrig-build

@mvschwarz
mvschwarz merged commit ef0350a into main Oct 25, 2026
14 checks passed
@mvschwarz
mvschwarz deleted the fix/codex-restore-gitdirs branch October 25, 2026 16:26
@github-project-automation github-project-automation Bot moved this from Todo to Done in OpenRig roadmap Oct 25, 2026
@mvschwarz mvschwarz added this to the v0.7.2 milestone Oct 25, 2026
AlephCasara pushed a commit to AlephCasara/openrig that referenced this pull request Nov 10, 2026
…le, so it can still commit (mvschwarz#2023)

A Codex seat without a pod restores through `CodexResumeAdapter` (`rig up --existing`, or a restore after a reboot), and that path added none of the git metadata `--add-dir`s mvschwarz#2000 gave fresh, resume and fork launches. So a default workspace-write seat restored that way couldn't write its worktree's `.git`, and commits failed. It now gets the same git dirs from the same resolver, then its seat folder, after the conversation id, so the `ps` proofs still read the id. They're added only on the plain workspace-write floor, since a named profile isn't checked for read-only on this path and Codex refuses a writable root under a read-only sandbox. Seats in a pod restore through the launch adapter, which mvschwarz#2000 already covers.

Tests use real temporary repositories: an ordinary repository's restore adds `<cwd>/.git`, and a linked worktree's adds its worktree and common git dirs, never the `.git` file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants