Skip to content

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

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

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

Conversation

@oxa-agent

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

Copy link
Copy Markdown
Contributor

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

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
@oxa-orchestrator
oxa-orchestrator Bot marked this pull request as ready for review November 17, 2026 15:12
@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-17T15:27:34.967646Z add05f5 Draft marked ready
🔒 Security Review ✅ Completed 2026-11-17T15:26:36.171389Z add05f5 Draft marked ready
ℹ️ 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 fdbaa16 (O-241; the orchestrator adjudicates and enqueues).

  • P1 — oxa/oxa-work/src/tree.rs:141–153: The new host-side git update-ref can execute a repository’s reference-transaction hook outside the sandbox. metadata_git disables fsmonitor and network protocols but not hooks; unlike the adjacent worktree add, this command does not set core.hooksPath=/dev/null. When a qualifying pushed tip exists, a configured hook can execute arbitrary host commands, bypassing sandbox file restrictions.
  • P2 — oxa/oxa-cli/tests/work_continue.rs:100: The new success test incorrectly asserts that old.txt is absent. Both commits use commit_file, which only adds or updates the named file; the pushed commit therefore contains both old.txt and pushed.txt. A correct fast-forward preserves both, so this test fails with the proposed fix.
    TIER: T3
    VERDICT: REVISE

🤖 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.
@oxa-agent
oxa-agent Bot marked this pull request as draft November 17, 2026 15:16

@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: 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".

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 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());

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

Comment thread oxa/oxa-work/src/tree.rs
Comment on lines +117 to +120
&& output(git(policy, repo, &["merge-base", "--is-ancestor", &local, &tip]))?
.status
.code()
== Some(0)

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

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

@oxa-orchestrator
oxa-orchestrator Bot marked this pull request as ready for review November 17, 2026 15:24

@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: 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".

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

@n0rpan

n0rpan commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator

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

Codex findings

  • CONFIRMED — P1, oxa/oxa-work/src/tree.rs:142: Host-side update-ref can execute a repository’s reference-transaction hook outside the sandbox; metadata_git does not disable hooks.
  • FIXED — oxa/oxa-cli/tests/work_continue.rs:88: The pushed commit now explicitly removes old.txt, making the subsequent absence assertion valid.
  • CONFIRMED — P2, oxa/oxa-work/src/tree.rs:121: An ancestry traversal error (for example, a missing intermediate object) is treated as non-ancestry, silently leaving the worker on the stale local tip.
  • CONFIRMED — P2, oxa/oxa-work/src/tree.rs:102: With multiple remotes, an unrelated remote’s same-named branch can be the sole ahead candidate and advance the task branch instead of its configured push destination.
    TIER: T3
    VERDICT: REVISE

🤖 Generated with Claude Code (oxa review lane)

@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-1033; 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