Repository navigation
WIP: work: start an existing task branch at its pushed head - #1051
oxa-agent[bot] wants to merge 2 commits into
Conversation
An existing task branch whose local ref lagged the fetched remote-tracking tip made the runner check out the older commit, so a worker audited a tree that missed the newest pushed commits. Before creating a worktree for an existing branch, the runner now starts the branch at the single remote-tracking tip of the same name when that tip strictly extends the local commit. No fetch, reset or force checkout is added: a tip that is not ahead, several diverging tips, a local commit the tip lacks, a dangling tracking ref, or a branch checked out in another worktree keeps the local tip, and the update is a compare-and-swap. Tests: work_continue covers the stale-ref case, the local-commit-off-the-pushed head case, and the several-ahead-tips case that must keep the local tip. Refs #1004
…ip test The several_ahead_tracking_tips_keep_the_local_tip fixture detached at the published commit, committed there, then reset --hard while still detached. A reset on a detached head moves only HEAD, so refs/heads/agent/test never left the pushed commit. The test then asserted the retained worktree starts at the published commit, while the branch it reuses was still the pushed one; the pushed.txt-absent assertion could not hold and the worktree carries the pushed work regardless of advance_to_pushed_head. The fixture now checks out agent/test before the reset and asserts the branch ref really sits at the published commit, which is the setup the assertions describe. With that branch state both tracking tips strictly extend it, so prepare keeps the local tip, and the test fails if advance_to_pushed_head ever picks one of two diverging ahead tips. Also apply rustfmt to the file: the three new git(...) calls overflowed the 110-column width, so cargo fmt --check failed on the pushed head. Refs #1004
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
Security findingsFinding details are still loading. Check the individual review comments. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
First-pass review by oxa → oxc →
TIER: T3 🤖 Generated with Claude Code (oxa review lane) |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c0a502f6f8
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| &["for-each-ref", "--format=%(refname)", &pattern], | ||
| ))?; | ||
| let mut ahead = Vec::new(); | ||
| for name in tracking.lines().filter(|name| !name.ends_with("/HEAD")) { |
There was a problem hiding this comment.
Do not discard task branches ending in /HEAD
For a valid task branch such as agent/HEAD, the matching tracking ref refs/remotes/origin/agent/HEAD is removed by this suffix check, so ahead remains empty and the runner audits the stale local commit instead of the pushed head. The remote's symbolic default ref cannot match this branch-specific pattern because a bare task branch named HEAD is invalid, so this filter should not classify every nested branch ending in /HEAD as the remote default.
Useful? React with 👍 / 👎.
| let pattern = format!("refs/remotes/*/{branch}"); | ||
| let tracking = checked(git( | ||
| policy, | ||
| repo, | ||
| &["for-each-ref", "--format=%(refname)", &pattern], |
There was a problem hiding this comment.
Include configured remote names containing slashes
When a valid configured remote is named company/fork, its normal fetch refspec stores this branch as refs/remotes/company/fork/agent/test, but this pattern assumes the remote name occupies exactly one path component. As a result, for-each-ref never returns that tracking ref and the runner still audits the stale local tip. Git documents these pattern operands as matching using fnmatch(3); enumerate the configured remotes and construct their exact tracking-ref names instead of globbing a single component.
Useful? React with 👍 / 👎.
| policy, | ||
| repo, | ||
| &[ | ||
| "update-ref", |
There was a problem hiding this comment.
Run the branch ref update inside the sandbox
When an ahead tracking tip qualifies, this host-side git update-ref runs through metadata_git, which neither disables core.hooksPath nor invokes the sandboxed supervisor. Git specifies that the reference-transaction hook is invoked by any command performing reference updates, so a repository hook now executes with the runner's unsandboxed host environment and can write private paths or access the network before checkout; route this update through the existing sandboxed reference-hook path rather than invoking it directly on the host.
AGENTS.md reference: AGENTS.md:L17-L18
Useful? React with 👍 / 👎.
Preservation draft for task i1004. Work is not submitted for review. CI and completion evidence remain pending; do not approve or merge this WIP.