Skip to content

Feature A: Start new task branches at their published head - #1097

Open
oxa-agent[bot] wants to merge 15 commits into
mainfrom
oxa/issue-1052
Open

oxa-agent[bot] wants to merge 15 commits into
mainfrom
oxa/issue-1052

Conversation

@oxa-agent

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

Copy link
Copy Markdown
Contributor

Feature A (#1214), T3. Fixes #1052. Ports #307's worktree lifecycle and post-commit publish row: a fresh task starts at its unambiguous published task head, preserving earlier work.

Published-head selection reads Git metadata only. It collects every matching remote tip before deduplication and ancestry validation. A sole eligible head becomes the detached worktree's start commit; the existing checkout supervisor creates the task branch without replacing a concurrent writer's branch. Adopted materialization uses the restricted execution policy. Automatic local save and merge retain sandboxed callback execution, refusal and work preservation.

Current source e9af6ccad122d38f547e927c4a100d506cb7b934 normally merges main 1f80c439 after GitHub confirmed an actual new conflict following Ready. The only text conflict was the shared test runner: the tests now reuse main's generic configuration helper, removing the duplicate wrapper and retaining every input/assertion. The PR's product patch is identical to approved parent 18bc55c7; Checkout, Merge and Save code and the entire worktree implementation are unchanged from that parent. Main's publication/save-recovery, diagnostic scrub, reviewed-head, checkpoint and lock/handover guards remain. Landed #1043 normalization, holder cleanup, original-OID/no-deref updates, frozen batch inputs and ordinary checkout callbacks remain alongside adopted policy. No new store or checkpoint schema.

Validation:

  • Tests-only 522bf832 failed at runtime before the repair: the x86 inventory ran 4,744 tests, with the two intended callback assertions failing after successful task completion; 4,742 passed and three existing opt-in tests were skipped. The initial 09f29dbb run stopped at an existing sandbox guard and is fixture feedback, not product failure proof.
  • Parent 18bc55c7 passed lane 44204858138: all 28 oxa crates plus oxc-rs on x86_64 and ARM64. This includes both repaired callback regressions and the combined adopted/normalization control. The owner explicitly read and approved that repaired parent source.
  • Current e9af6cca: lane 44207390279 and Ready full required CI 44207311487 are running, with one observer each. Fresh current-head Cloud Code/security reviews and normal landing gates remain required. Parent green and the old Draft cheap workflow do not qualify this composition.
  • Tests drive the real binary with isolated HOME and synthetic fixtures; no real credentials or external services. Every original control/assertion is retained. Configured rustfmt and git diff --check pass; no local builds/tests.

Retains the complete existing oxa/issue-1052 history. No new branch or history rewrite. Helpers remain paused; no lab script changes.

A task for an already pushed branch (for example a pull request's head)
started a fresh worktree at the captured base, because the local branch did
not exist. The worker then audited and continued a tree that predates the
published commits and redid work that was already on the head.

Before creating the worktree, a task branch that has no local ref is created
at the lone remote-tracking tip of the same name when that tip descends from
the captured base and carries commits the base lacks. No fetch runs, the
update is a compare-and-swap that can only create the ref, and several
diverging tips, an unrelated tip or a tip equal to the base keep the base.
An existing local branch, including a retained or unfinished one, is untouched.

Tests: work_continue starts from a deleted local branch with a fetched
origin/agent/test and asserts the worker's tree and the branch both sit at
the pushed commit.

Fixes #1052
@oxa-orchestrator
oxa-orchestrator Bot marked this pull request as ready for review November 17, 2026 17:08
@n0rpan

n0rpan commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator

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

  • P2 — oxa/oxa-work/src/tree.rs:169: Published branches always fail fresh checkout. When a matching published tip exists, adopt_published_head creates refs/heads/<task.branch>, but create remains true. Preparation therefore creates a detached worktree at the base and passes create: true to the supervisor, which runs git checkout -b '<branch>' HEAD (oxa/oxa-cli/src/work_checks.rs:34). Git refuses because that branch now exists, so oxa work fails instead of continuing the published head. The new fresh_worktree_starts_at_the_published_task_branch_head test exercises this failure.

TIER: T2
VERDICT: REVISE

🤖 Generated with Claude Code (oxa review lane)

Adopting the published head created refs/heads/<task> before the worktree
existed, but the sandboxed checkout still ran `git checkout -b <task> HEAD`
for a task without a local branch and failed with "a branch named '<task>'
already exists", blocking every task whose branch had just been adopted.

The adoption now reports whether it created the ref. When it did, the
worktree attaches to that branch and the sandboxed checkout only materialises
its tree; otherwise the previous detached worktree at the base and the
sandbox-side branch creation are unchanged.

Tests: work_continue asserts the task branch, HEAD and the worker's tree all
sit at the pushed commit.
@oxa-agent
oxa-agent Bot marked this pull request as draft November 17, 2026 17:23
…heckout

The published-head test asserted `symbolic-ref HEAD` in the source checkout,
which `oxa work` deliberately never moves: it stays on the captured base while
the task branch is created for the worktree. The assertion therefore checked
the wrong repository and failed. It now asserts the task worktree's HEAD and
that the source checkout is still on the base.

Adoption also read the base with a strict `rev-parse`, so a base that does not
resolve failed the run before the ordinary path could report it; it is now
skipped and left to that path. The zero old value for the compare-and-swap
follows the repository's hash algorithm instead of assuming SHA-1, and a ref
that appears between the check and the update no longer fails the run: the
caller attaches the existing branch, as it does for any existing branch.

Tests: the published-head test now asserts both HEADs; a second test pushes an
orphan branch under the task name and asserts the worktree and the local branch
both stay at the base without its file.
@oxa-orchestrator
oxa-orchestrator Bot marked this pull request as ready for review November 17, 2026 17:29
@n0rpan

n0rpan commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator

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

  • P1 — oxa/oxa-work/src/tree.rs:146: Unsandboxed reference-transaction hook execution. The new host-side git update-ref invokes an installed reference-transaction hook. metadata_git does not disable hooks, unlike the existing worktree-add command. Starting a task with an eligible published head can therefore execute repository-configured code outside the sandbox, with access to host credentials and private files. Disable hooks for this metadata mutation.
  • P2 — oxa/oxa-work/src/tree.rs:118–133: Ambiguous published heads can be adopted. If origin/agent/test descends from the base but other/agent/test has diverged from it, the latter is discarded before ambiguity checking. The remaining tip is adopted despite the documented guarantee to keep the base for several diverging tips. Collect and deduplicate all matching tips before checking the sole candidate’s ancestry.
    TIER: T3
    VERDICT: REVISE

🤖 Generated with Claude Code (oxa review lane)

@oxa-agent oxa-agent Bot changed the title WIP: work: start a new task branch at its published head Feature A: Start new task branches at their published head Nov 17, 2026
@oxa-agent
oxa-agent Bot marked this pull request as ready for review November 17, 2026 22:18
@n0rpan

n0rpan commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator

@codex review

@n0rpan

n0rpan commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator

@codex security review

@chatgpt-codex-connector

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

Copy link
Copy Markdown
Codex Review Summary: 🔄 Running

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T00:31:13.711997Z e9af6cc Manual request
🔒 Security Review 🔄 Running since 2026-11-18T00:29:25.399504Z e9af6cc Manual request

Security findings

Advisory findings (2)

ℹ️ 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: ca01b0031a

ℹ️ 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".

@oxa-orchestrator
oxa-orchestrator Bot enabled auto-merge November 17, 2026 22:24
@oxa-orchestrator

Copy link
Copy Markdown

st merge-flow>author #1097ca01b00 queue=REJECTED run=? next=refresh-on-main note="Composition with current main failed; rebase/merge main, fix, push; a new head needs a new verdict."

see run log

@oxa-orchestrator
oxa-orchestrator Bot added this pull request to the merge queue Nov 17, 2026

@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 Security Review

Here are some automated security review suggestions for this pull request.

Reviewed commit: ca01b0031a

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Comment thread oxa/oxa-work/src/tree.rs
Comment on lines +177 to +178
args.push(if create {
published.as_deref().unwrap_or(base)

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 Security Review

P1 Badge Security: Reapprove adopted branch code before running checkout hooks

When a trusted repo has an installed checkout hook that invokes tracked code, sandbox networking is on, and gh is logged in, a fetched attacker-controlled remote branch matching a new task is adopted here and checked out before that tip is approved. The checkout command contains git, so NetSandbox injects the owner GH_TOKEN; tip-controlled hook code can send it off-host. Descendant/unique-tip checks do not establish trust, and source trust covers only the current checkout. Disable callbacks/network/token while materializing the tip, then approve its executable content before hooks.

SECURITY.md reference: SECURITY.md:L9-L10

Useful? React with 👍 / 👎.

@oxa-agent
oxa-agent Bot marked this pull request as draft November 17, 2026 22:33
@oxa-agent
oxa-agent Bot removed this pull request from the merge queue due to a manual request Nov 17, 2026
@oxa-agent
oxa-agent Bot marked this pull request as ready for review November 17, 2026 23:12
@n0rpan

n0rpan commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator

@codex review

@n0rpan

n0rpan commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator

@codex security review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 7b6dfa1118

ℹ️ 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".

@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 Security Review

Here are some automated security review suggestions for this pull request.

Reviewed commit: 7b6dfa1118

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Comment thread oxa/oxa-work/src/tree.rs
Comment on lines +300 to +302
args.push(if create {
published.as_deref().unwrap_or(base)
} else {

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 Security Review

P1 Badge Security: Reapprove adopted Git hooks before saving

Required conditions: a trusted repo has core.hooksPath pointing to a tracked directory, sandbox networking is on, gh is logged in, a matching attacker-controlled remote branch was fetched, and the worker makes a change. This revision now disables hooks only for the adopted checkout (fresh evidence beyond the earlier comment); Save later restores with_net and runs an ordinary git commit, so the adopted pre-commit inherits GH_TOKEN and can exfiltrate it. Reapprove the adopted executable content, or keep hooks, network, and credentials disabled through Save.

SECURITY.md reference: SECURITY.md:L9-L11

Useful? React with 👍 / 👎.

@oxa-orchestrator
oxa-orchestrator Bot added this pull request to the merge queue Nov 17, 2026
@oxa-agent
oxa-agent Bot marked this pull request as draft November 17, 2026 23:32
@oxa-agent
oxa-agent Bot removed this pull request from the merge queue due to a manual request Nov 17, 2026
@oxa-agent
oxa-agent Bot marked this pull request as ready for review November 18, 2026 00:16
# Conflicts:
#	oxa/oxa-cli/tests/common/work.rs
@n0rpan

n0rpan commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator

@codex review

@n0rpan

n0rpan commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator

@codex security review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: e9af6ccad1

ℹ️ 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".

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dogfood: Worktree started at the PR base instead of the PR head

1 participant