fix(compile): emit prepare-pr-base in the SafeOutputs job (#1453)#1458
Conversation
The prepare-pr-base fetch/deepen ran only in the Agent job, but the create-pull-request executor runs in the SafeOutputs job with its own fresh shallow checkout, so `git worktree add origin/<target>` failed. Emit the prepare step (and stage the ado-script bundle) in the SafeOutputs job too, before `ado-aw execute`. Adds compiler tests and a hermetic real-git smoke test reproducing the worktree failure. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: a72d41a9-43e0-4ef4-be36-5ab5329df011
🔍 Rust PR ReviewSummary: Looks good — clean, well-tested fix with one minor inefficiency worth noting. Findings
|
…ate-pull-request Addresses PR review feedback: in split-approval configs build_safeoutputs_job is called for both the auto and reviewed variants, but only one runs create-pull-request. Gate the bundle download + prepare step on a per-variant runs_create_pull_request flag so the non-running variant no longer pays for a wasted Node install + fetch/deepen. Adds split-approval tests for both gated and sibling-gated cases. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: a72d41a9-43e0-4ef4-be36-5ab5329df011
🔍 Rust PR ReviewSummary: Looks good — the fix is correct, well-scoped, and fully tested. Findings✅ What Looks Good
|
Summary
Closes #1453.
#1425(v0.43.0) fixed the shallow-clone diff-base problem by adding a host-side "Prepare create-pull-request base ref (fetch/deepen)" step (prepare-pr-base.js). But that step was emitted only in the Agent job, while thecreate-pull-requestexecutor (ado-aw execute) runs in the SafeOutputs job — a separate ADO job with its own fresh, shallowcheckout: self. Each ADO job gets an isolated checkout, so the Agent-job fetch is invisible there and the executor'sgit worktree add origin/<target>fails:This PR emits the existing, tested
prepare-pr-basebundle step in the SafeOutputs job too, immediately beforeado-aw execute(issue option a). It reuses all existing machinery, so the ref is landed in the same checkout that builds the worktree.Key changes
src/compile/agentic_pipeline.rs— extractedcreate_pr_prepare_repos(pure per-repo(dir, target)pairs) andwarn_create_pr_target_inference(advisory emitted once, Agent-job only).build_safeoutputs_jobnow stages the ado-script bundle (install_and_download_steps_typed) and emitsprepare_pr_base_step_typed(...)before the executor.build_safeoutputs_jobis shared viabuild_canonical_jobs, so this covers standalone, 1es, job, and stage targets.runs_create_pull_requestflag, so in a split-approval config (create-pull-requestwithrequire-approvalalongside a non-gated tool) only the variant that actually executescreate-pull-requestpays for the Node install + fetch/deepen; the other variant, which filters the tool out, no longer does wasted work.tests/safe-outputs/create-pull-request.lock.yml— regenerated golden lock (SafeOutputs job now has Node install + ado-script staging + prepare step).tests/compiler_tests.rs— new tests asserting the prepare step (self + per-repo targets) appears in the SafeOutputs job before the executor, plus split-approval tests proving the step lands only in the running variant (both gated and sibling-gated cases).scripts/ado-script/test/smoke.test.ts— hermetic real-git smoke test that builds a shallow single-branch clone missingorigin/<target>, assertsgit worktree add origin/<target>fails (reproducing [aw]: Follow-up to #1413 / #1425:create-pull-requestworktree fails — the prepare-pr-base step runs in the Agent job, but the executor runs in the SafeOutputs job (standalone target) #1453), runs the realprepare-pr-base.js, then asserts the same worktree add succeeds. No ADO/network.package.jsontest:smokenow builds theprepare-pr-basebundle.docs/safe-outputs.md,docs/ado-script.md,AGENTS.md, and the twosite/**.mdxmirrors updated to note the step runs in both jobs.Follow-up
The prepare step also runs in the Agent job for the host-side SafeOutputs MCP diff base; an external comment on #1453 reports that path can still fail on shallow/detached-HEAD checkouts. Tracked separately in #1457 (out of scope here).
Test plan
cargo build— clean.cargo test— full suite, 0 failures (incl. the 10create_pull_requestcompiler tests and the regenerated golden lock).cargo clippy --all-targets --all-features— clean.cargo test --test bash_lint_tests— shellcheck-clean (SafeOutputs job gained bash bundle steps).npm run test:smoke(inscripts/ado-script/) — 7/7, including the newprepare-pr-base.js[aw]: Follow-up to #1413 / #1425:create-pull-requestworktree fails — the prepare-pr-base step runs in the Agent job, but the executor runs in the SafeOutputs job (standalone target) #1453 smoke test.