Skip to content

WIP: work: start an existing task branch at its pushed head - #1051

Closed
oxa-agent[bot] wants to merge 2 commits into
mainfrom
oxa/issue-1004
Closed

oxa-agent[bot] wants to merge 2 commits into
mainfrom
oxa/issue-1004

Conversation

@oxa-agent

@oxa-agent oxa-agent Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Preservation draft for task i1004. Work is not submitted for review. CI and completion evidence remain pending; do not approve or merge this WIP.

oxa and others added 2 commits November 17, 2026 16:49
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
@oxa-orchestrator
oxa-orchestrator Bot marked this pull request as ready for review November 17, 2026 16:05
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T16:09:59.174916Z c0a502f Draft marked ready
🔒 Security Review ✅ Completed 2026-11-17T16:12:13.543127Z c0a502f Draft marked ready

Security findings

Finding details are still loading. Check the individual review comments.

ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@n0rpan

n0rpan commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator

First-pass review by oxa → oxc → chatgpt/gpt-6.1-sol at head c0a502f (O-241; the orchestrator adjudicates and enqueues).

  • P1 — oxa/oxa-work/src/tree.rs:138–149: Unsandboxed hook execution. The new host-side git update-ref can execute the repository’s reference-transaction hook. Its git() → metadata_git() wrapper does not disable hooks, unlike the adjacent worktree-add command. When a stale task branch has one qualifying pushed tip, a repository-provided hook therefore runs on the host before the sandboxed checkout, bypassing the task sandbox and potentially accessing credentials. Disable hooks for this metadata update.

TIER: T3
VERDICT: REVISE

🤖 Generated with Claude Code (oxa review lane)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread oxa/oxa-work/src/tree.rs
&["for-each-ref", "--format=%(refname)", &pattern],
))?;
let mut ahead = Vec::new();
for name in tracking.lines().filter(|name| !name.ends_with("/HEAD")) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Comment thread oxa/oxa-work/src/tree.rs
Comment on lines +98 to +102
let pattern = format!("refs/remotes/*/{branch}");
let tracking = checked(git(
policy,
repo,
&["for-each-ref", "--format=%(refname)", &pattern],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Comment thread oxa/oxa-work/src/tree.rs
policy,
repo,
&[
"update-ref",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

@n0rpan n0rpan added the parked Closed without merging; work kept at tag archive/pr-N, listed in the parked-work index label Nov 17, 2026
@n0rpan

n0rpan commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator

Superseded by #1144 (same root cause as issue #1052; duplicate-work cleanup). Head archived as tag archive/pr-1051; branch kept.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

parked Closed without merging; work kept at tag archive/pr-N, listed in the parked-work index

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant