diff --git a/supervisor/best-practices/dev-agent.md b/supervisor/best-practices/dev-agent.md index b11d1dd..c55aa52 100644 --- a/supervisor/best-practices/dev-agent.md +++ b/supervisor/best-practices/dev-agent.md @@ -71,3 +71,23 @@ When the phase-handler injects 'CI failed' with a push pipeline number (e.g. #62 Root cause: the injected event does not always carry the correct pipeline number. Symptom: agent in awaiting_review with PR CI=failure and push CI=success. Fix: inject with explicit pipeline #623 (the pull_request event pipeline), point to the failing step and the specific duplicate blocks to fix. Use: woodpecker_api /repos/4/pipelines?event=pull_request (or look for event=pull_request in recent pipelines list) to find the correct pipeline number before injecting. + +### Race Condition: Review Posted Before PHASE:awaiting_review Transitions +**Symptom:** Dev-agent status unchanged at 'waiting for review on PR #N', no `review-injected-disinto-N` sentinel, but a formal review already exists on Codeberg and `/tmp/disinto-review-output-N.json` was written before the phase file updated. + +**Root cause:** review-pr.sh runs while the dev-agent is still in PHASE:awaiting_ci. inject_review_into_dev_session returns early (phase check fails). On subsequent review-poll cycles, the PR is skipped (formal review already exists for SHA), so inject is never called again. + +**Fix:** Manually inject the review: +```bash +source /home/debian/dark-factory/lib/env.sh +PROJECT_TOML=/home/debian/dark-factory/projects/disinto.toml +source /home/debian/dark-factory/lib/load-project.sh "$PROJECT_TOML" +PHASE_FILE="/tmp/dev-session-${PROJECT_NAME}-.phase" +PR_NUM=; PR_BRANCH="fix/issue-"; PR_SHA=$(cat /tmp/dev-session-${PROJECT_NAME}-.phase | grep SHA | cut -d: -f2 || git -C $PROJECT_REPO_ROOT rev-parse origin/$PR_BRANCH) +REVIEW_TEXT=$(curl -sf -H "Authorization: token ${CODEBERG_TOKEN}" "${CODEBERG_API}/issues/${PR_NUM}/comments?limit=50" | jq -r --arg sha "$PR_SHA" '[.[] | select(.body | contains("