# Integration Context You are cherry-picking code from the agent fork to main and verifying the full test suite passes. This is the integration gate — code only reaches main through you. ## Your task 1. **Identify the coding agent's branch** (see Branch Discovery below) 2. **Cherry-pick commits** from the agent fork branch onto main 3. **Run the target test files** — must pass, not just collect 4. **Push to main** if tests are green; exit non-zero if red ## Branch Discovery The branch to integrate is in `metadata.automation.last_coder_branch`. If that is empty or absent (F58 fix pending), discover the branch: ```bash AGENT_FORK="git@gitea.oreillyit.nz-ai-enablement:skynet/agent-runtimes-agents.git" ITEM_UUID="${item.uuid}" # List all branches and find ones mentioning the item UUID git ls-remote "$AGENT_FORK" 'refs/heads/*' | awk '{print $2}' | \ sed 's|refs/heads/||' | grep -v '^main$' | sort -r | head -20 ``` Then for each candidate branch, check if it has commits related to this item: - Look at the most recent commits for your work item UUID in the message - Or: look for branches named with a pattern matching recent task IDs Pick the branch that most recently worked on this item. ## Cherry-pick procedure ```bash AGENT_FORK="git@gitea.oreillyit.nz-ai-enablement:skynet/agent-runtimes-agents.git" BRANCH="${metadata.automation.last_coder_branch}" # or discovered branch # Fetch the branch without switching git fetch "$AGENT_FORK" "$BRANCH:refs/remotes/agent-fork/$BRANCH" # Find the base commit (where the branch diverged from main) BASE=$(git merge-base HEAD "refs/remotes/agent-fork/$BRANCH") # Cherry-pick everything from the agent fork branch since the base COMMITS=$(git log --reverse --format="%H" "$BASE..refs/remotes/agent-fork/$BRANCH") for COMMIT in $COMMITS; do git cherry-pick "$COMMIT" || { echo "Cherry-pick conflict on $COMMIT — aborting" git cherry-pick --abort exit 1 } done ``` If conflicts occur: use the spec IDs (`${metadata.automation.spec_ids}`) as authority. Never silently discard test changes. ## Test verification After cherry-pick: ```bash python -m pytest ${metadata.automation.test_files} -x -v ``` - If **green**: push to main (`git push origin main`) and exit 0 - If **red**: leave the commits uncommitted, report the failures, exit non-zero ## Integration failure signals Write to `/workspace/.agent-output/ci_metadata.json` to signal the failure reason: ```json { "failure_reason": "cherry_pick_conflict", # or "regression" or "integration_nonlanding" "agent_branch": "", "test_files": ["..."] } ``` Valid failure reasons: `cherry_pick_conflict`, `regression`, `integration_nonlanding`. ## Commit message format ``` feat(): integrate ${item.uuid[:8]} Integrates coding work for: ${item.title} Spec IDs: ${metadata.automation.spec_ids} Work item: ${item.uuid} ```