Repository navigation
WIP: work: start an existing task branch at its pushed head - #1033
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 (old test tree, red before this change) and the local-commit-off-the-pushed-head case that must keep its tip. Fixes #1028
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ 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 →
🤖 Generated with Claude Code (oxa review lane) |
The stale-ref test pushed a head whose tree matched the lagging local commit apart from the new file, so the fixture stayed green even when the branch was not started at its pushed head. The pushed commit now also drops the old file the lagging commit still holds, so the checkout is distinguishable from both sides.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fdbaa16ed2
ℹ️ 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".
| policy, | ||
| repo, | ||
| &[ | ||
| "update-ref", |
There was a problem hiding this comment.
Keep the ref update inside the sandbox
When the source repository has a reference-transaction hook, this host-side git update-ref executes that repository-controlled hook before the sandboxed supervisor starts. Git documents that the reference-transaction hook is invoked by any reference transaction; unlike the nearby worktree add, this command neither disables hooks nor runs through supervise, so oxa work can execute project code with host access. Perform the update through the sandboxed checkout path or otherwise prevent host hook execution.
AGENTS.md reference: AGENTS.md:L17-L18
Useful? React with 👍 / 👎.
| "pushed version\n" | ||
| ); | ||
| assert!(tree(&record).join("pushed.txt").exists()); | ||
| assert!(!tree(&record).join("old.txt").exists()); |
There was a problem hiding this comment.
Preserve the inherited file in this test
The pushed commit is a descendant of published, so it necessarily still contains old.txt; resetting the local branch to published and later advancing it back to pushed does not delete that file, and merging the ancestor main does not delete it either. This assertion is therefore false on every successful run of the new behavior and makes the oxa-cli test suite fail; either assert that old.txt remains or explicitly delete it in the pushed commit if absence is what the fixture intends.
Useful? React with 👍 / 👎.
| && output(git(policy, repo, &["merge-base", "--is-ancestor", &local, &tip]))? | ||
| .status | ||
| .code() | ||
| == Some(0) |
There was a problem hiding this comment.
Propagate ancestry-check errors
When the tracking tip object exists but ancestry traversal cannot read an intermediate object—for example in an incompletely fetched partial clone while lazy fetching is disabled—merge-base --is-ancestor exits with an error such as 128. Comparing only with Some(0) folds that failure into the ordinary non-ancestor case, so the runner silently keeps the stale local branch and lets the worker audit it instead of reporting that required objects are missing. Treat only exit 1 as non-ancestry and propagate other statuses and stderr, as ensure_merged already does later in this file.
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.
Restrict advancement to the branch's push remote
When a repository has multiple remotes, a same-named branch on an unrelated remote can be the only tracking ref ahead of the local commit—for example, origin/agent/test still equals the local tip while upstream/agent/test contains an extra foreign commit. This wildcard discards the remote identity, and the later tip != local filter makes that foreign commit look uniquely eligible, so the task branch is advanced to work that was never pushed to its configured destination. Use Git's configured branch.<name>.pushRemote/remote.pushDefault, or require the matching remote refs themselves to be unambiguous, before changing the local branch.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: add05f52f5
ℹ️ 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".
| policy, | ||
| repo, | ||
| &[ | ||
| "update-ref", |
There was a problem hiding this comment.
Refuse symbolic task refs before updating them
When refs/heads/<task> is a symbolic ref, this command dereferences it and advances the target branch rather than the named task ref; for example, agent/test pointing to main can move main to origin/agent/test, and the preceding worktree check will not notice that the target branch is checked out because it searches only for the literal task ref. The verified git update-ref -h output documents --no-deref as “update not the one it points to”; reject symbolic task refs (or deliberately handle them without dereferencing) before this destructive update.
AGENTS.md reference: AGENTS.md:L26-L27
Useful? React with 👍 / 👎.
|
First-pass review by oxa → oxc → Codex findings
🤖 Generated with Claude Code (oxa review lane) |
Preservation draft for task i1028. Work is not submitted for review. CI and completion evidence remain pending; do not approve or merge this WIP.