From d19da44f7ae09fa4cd2112bf71532ce8127cfc45 Mon Sep 17 00:00:00 2001 From: Paul O'Reilly Date: Wed, 16 Sep 2026 19:34:47 +1200 Subject: [PATCH] =?UTF-8?q?feat:=20AR-39a=20=E2=80=94=20templates=20pass?= =?UTF-8?q?=20AGENT=5FUPSTREAM=5FREPO=5FURL/BRANCH;=20agent-repo/v1=20init?= =?UTF-8?q?.sh=20invokes=20select-base=20(upstream=20>=20reference=20>=20f?= =?UTF-8?q?ork)=20(bug=200772408e)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Claude-Session: https://claude.ai/code/session_01G3SkMRBRWXyiGuMGs8WVas --- harnesses/contexts/agent-repo/v1/init.sh | 25 ++++++++++++++++++++-- task-templates/workflow/integration@1.yaml | 3 +++ task-templates/workflow/merge@1.yaml | 3 +++ task-templates/workflow/scaffold@1.yaml | 3 +++ 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/harnesses/contexts/agent-repo/v1/init.sh b/harnesses/contexts/agent-repo/v1/init.sh index b3ebec6..36868df 100755 --- a/harnesses/contexts/agent-repo/v1/init.sh +++ b/harnesses/contexts/agent-repo/v1/init.sh @@ -70,8 +70,29 @@ if [ -n "${AGENT_REPO_URL:-}" ] && [ -n "${AGENT_BRANCH:-}" ]; then # Full clone (not --depth 1) so we get a working remote for finalize.sh push. if git clone "$AGENT_REPO_URL" /workspace/project; then cd /workspace/project + # AR-39: resolve the seed point via entrypoint.agent_repo_base + # (upstream > reference > fork). Writes branch_base.json for + # finalize.sh to merge into ci_metadata.json (AR-25). Falls back + # to the legacy inline AR-14a logic if the CLI is unavailable. + mkdir -p /workspace/.agent-output + AR39_OUT=$(python3 -m entrypoint.agent_repo_base select-base \ + --workdir /workspace/project \ + --branch "$AGENT_BRANCH" \ + --upstream-url "${AGENT_UPSTREAM_REPO_URL:-}" \ + --upstream-branch "${AGENT_UPSTREAM_BRANCH:-main}" \ + --reference-dir /workspace/reference/main \ + --out /workspace/.agent-output/branch_base.json \ + --fork-url "$AGENT_REPO_URL" 2>&1) && AR39_RC=0 || AR39_RC=$? + if [ "$AR39_RC" = "0" ]; then + AR39_SHA=$(printf '%s\n' "$AR39_OUT" | sed -n 's/^sha=//p' | head -1) + AR39_SRC=$(printf '%s\n' "$AR39_OUT" | sed -n 's/^source=//p' | head -1) + git checkout -b "$AGENT_BRANCH" "$AR39_SHA" + echo "Seeded $AGENT_BRANCH from $AR39_SRC @ $AR39_SHA (AR-39)" + else + echo "WARNING: AR-39 select-base failed (rc=$AR39_RC): $AR39_OUT — falling back to inline AR-14a seeding" >&2 + fi REF_REPO=/workspace/reference/main - if [ -d "$REF_REPO/.git" ]; then + if [ "$AR39_RC" != "0" ] && [ -d "$REF_REPO/.git" ]; then # Seed working tree from the upstream reference clone — AR-14a. # Reference is read-only (chmod a-w), but git can still read it # as a local-path remote for fetch + reset. @@ -105,7 +126,7 @@ if [ -n "${AGENT_REPO_URL:-}" ] && [ -n "${AGENT_BRANCH:-}" ]; then git checkout -b "$AGENT_BRANCH" echo "WARNING: upstream-ref had no resolvable HEAD; using fork main (may be stale)" >&2 fi - else + elif [ "$AR39_RC" != "0" ]; then # No reference clone available — fall back to fork main. git checkout -b "$AGENT_BRANCH" echo "WARNING: $REF_REPO/.git not found; using fork main (may be stale)" >&2 diff --git a/task-templates/workflow/integration@1.yaml b/task-templates/workflow/integration@1.yaml index 2e4106f..a9a67e7 100644 --- a/task-templates/workflow/integration@1.yaml +++ b/task-templates/workflow/integration@1.yaml @@ -22,6 +22,9 @@ nodes: # see the same tree). Without AGENT_REPO_URL the agent-repo layer never # clones and the agent's output evaporates (E2E 2026-07-04). AGENT_REPO_URL: "git@gitea.oreillyit.nz-ai-enablement:skynet/agent-runtimes-agents.git" + # AR-39a: fresh task branches seed from live upstream, not the fork mirror + AGENT_UPSTREAM_REPO_URL: "git@gitea.oreillyit.nz-ai-enablement:skynet/agent-runtimes.git" + AGENT_UPSTREAM_BRANCH: "main" AGENT_BRANCH: "task/${item.uuid}" prompt: | You are the integration gate for this work item. diff --git a/task-templates/workflow/merge@1.yaml b/task-templates/workflow/merge@1.yaml index 0b99b8b..b9c907b 100644 --- a/task-templates/workflow/merge@1.yaml +++ b/task-templates/workflow/merge@1.yaml @@ -20,6 +20,9 @@ nodes: template: best-practices-minimax-repo runtime_env: AGENT_REPO_URL: "git@gitea.oreillyit.nz-ai-enablement:skynet/agent-runtimes-agents.git" + # AR-39a: fresh task branches seed from live upstream, not the fork mirror + AGENT_UPSTREAM_REPO_URL: "git@gitea.oreillyit.nz-ai-enablement:skynet/agent-runtimes.git" + AGENT_UPSTREAM_BRANCH: "main" AGENT_BRANCH: "task/${item.uuid}" AGENT_SKIP_BRANCH_PUSH: "true" AGENT_EMPTY_DELIVERABLE_CHECK: "false" diff --git a/task-templates/workflow/scaffold@1.yaml b/task-templates/workflow/scaffold@1.yaml index 0bbff15..56cd1e2 100644 --- a/task-templates/workflow/scaffold@1.yaml +++ b/task-templates/workflow/scaffold@1.yaml @@ -22,6 +22,9 @@ nodes: # see the same tree). Without AGENT_REPO_URL the agent-repo layer never # clones and the agent's output evaporates (E2E 2026-07-04). AGENT_REPO_URL: "git@gitea.oreillyit.nz-ai-enablement:skynet/agent-runtimes-agents.git" + # AR-39a: fresh task branches seed from live upstream, not the fork mirror + AGENT_UPSTREAM_REPO_URL: "git@gitea.oreillyit.nz-ai-enablement:skynet/agent-runtimes.git" + AGENT_UPSTREAM_BRANCH: "main" AGENT_BRANCH: "task/${item.uuid}" prompt: | Write stub implementations for the following task.