Repository navigation
feat: allow limited git writes in workspace sandbox - #25664
viyatb-oai wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dae5690232
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if is_git_pointer_file(&top_level_git) | ||
| && let Some(gitdir) = resolve_gitdir_from_file(&top_level_git) | ||
| { | ||
| subpaths.extend(protected_git_subpaths_when_writable(&gitdir)); |
There was a problem hiding this comment.
Add the linked gitdir as a writable root
When allow_limited_git_writes is enabled for a linked worktree, this branch only records <gitdir>/config and <gitdir>/hooks as read-only carveouts, but it never grants write access to the resolved <gitdir> itself. The platform lowerings I inspected (e.g. bwrap binds only each WritableRoot.root before re-applying read_only_subpaths) treat these subpaths as exclusions, not write grants, so a normal linked worktree whose .git file points outside the workspace still cannot update HEAD, index, or lock files in the actual gitdir. This means the new “limited git writes” mode works for directory .git repos but still fails for linked worktrees, which is one of the scenarios this code path is meant to support.
Useful? React with 👍 / 👎.
| #[serde(default)] | ||
| allow_limited_git_writes: bool, |
There was a problem hiding this comment.
Keep the new v2 field optional for clients
For app-server v2 clients that consume the generated TypeScript, adding this boolean without a TS optional annotation makes the workspaceWrite variant require allowLimitedGitWrites (as generated in schema/typescript/v2/SandboxPolicy.ts), even though serde still accepts old JSON because of the default. Existing clients that construct a sandboxPolicy for command/exec or turn/start now fail to compile until they know about this new flag. Please make the new field optional in the TS surface, or otherwise avoid making an additive defaulted server field a required client-side property.
Useful? React with 👍 / 👎.
| file_system_sandbox_policy.allow_limited_git_writes = profile | ||
| .filesystem | ||
| .as_ref() | ||
| .is_some_and(|filesystem| filesystem.allow_limited_git_writes); |
There was a problem hiding this comment.
Preserve inherited limited-Git-write settings
When a custom permission profile inherits a filesystem profile that set allow_limited_git_writes = true, a child profile that adds its own [filesystem] entries but omits this new flag is deserialized with the default false, and this assignment then overwrites the inherited runtime policy. That makes limited Git writes disappear merely because the child adds another filesystem rule. The flag needs to distinguish “omitted” from “explicitly false” during profile merging/compilation so inherited profiles keep their setting unless the child overrides it.
Useful? React with 👍 / 👎.
| if is_git_pointer_file(&top_level_git) | ||
| && let Some(gitdir) = resolve_gitdir_from_file(&top_level_git) | ||
| { | ||
| subpaths.extend(protected_git_subpaths_when_writable(&gitdir)); |
There was a problem hiding this comment.
Keep linked-worktree .git pointer files read-only
For worktrees/submodules where .git is a pointer file, this branch protects only the resolved gitdir’s config and hooks but leaves the .git file itself writable under allow_limited_git_writes. In a writable workspace the agent can rewrite that pointer to a gitdir it controls, after which later Git commands read config/hooks from the new location and bypass the protected paths. The pointer file needs to stay read-only while the actual gitdir metadata is made writable.
Useful? React with 👍 / 👎.
| } else { | ||
| // Git metadata remains writable, but these execution surfaces do | ||
| // not become writable merely because `.git` is created later. | ||
| subpaths.extend(protected_git_subpaths_when_writable(&top_level_git)); |
There was a problem hiding this comment.
Protect bare-repository config and hooks
When the writable root is itself a bare Git repository, there is no .git child; the sensitive files are <root>/config and <root>/hooks. This branch falls into the missing-.git path and protects <root>/.git/config and <root>/.git/hooks instead, so bare repos run with allow_limited_git_writes still allow modifying their real config and hooks. The bare-repo case called out in the comment needs to add carveouts for the root gitdir itself.
Useful? React with 👍 / 👎.
Co-authored-by: Codex [email protected]
dae5690 to
8980fd1
Compare
Co-authored-by: Codex [email protected]
Co-authored-by: Codex [email protected]
Co-authored-by: Codex [email protected]
Co-authored-by: Codex [email protected]
|
Closing this pull request because it has had no updates for more than 14 days. If you plan to continue working on it, feel free to reopen or open a new PR. |
Stack
allow_gitpermissions and requirements setting built on this runtime support.Why
Codex needs a sandbox policy shape that lets Git update repository metadata without making repository-local execution or configuration surfaces writable.
What changed
.git/config,.git/hooks, and linked-worktree<gitdir>/config/<gitdir>/hooksread-only.Security
This does not grant network access. Git config and hooks remain protected, so this enables local metadata updates without allowing repository-local config or hook mutation.
Validation
just fmtjust clippy -p codex-core(run on the stacked branch after the CI compile fix)Part of #15505