fix: stale phase file poisons recovery — clear before respawn (#628)
- Clear phase file after reading it in recovery mode so new sessions start clean instead of inheriting stale state - When last phase was escalate, tell Claude "previous session escalated — starting fresh" instead of "resume from escalate" to prevent re-escalation - Add explicit "PR already exists — do NOT create a new PR" instructions to recovery prompt to prevent Claude from calling forge API directly Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
9a9b82eea5
commit
a5cbd30bb6
1 changed files with 10 additions and 3 deletions
|
|
@ -606,6 +606,7 @@ if [ "$RECOVERY_MODE" = true ]; then
|
||||||
# Build recovery context
|
# Build recovery context
|
||||||
GIT_DIFF_STAT=$(git -C "$WORKTREE" diff "origin/${PRIMARY_BRANCH}..HEAD" --stat 2>/dev/null | head -20 || echo "(no diff)")
|
GIT_DIFF_STAT=$(git -C "$WORKTREE" diff "origin/${PRIMARY_BRANCH}..HEAD" --stat 2>/dev/null | head -20 || echo "(no diff)")
|
||||||
LAST_PHASE=$(read_phase)
|
LAST_PHASE=$(read_phase)
|
||||||
|
rm -f "$PHASE_FILE" # Clear stale phase — new session starts clean
|
||||||
CI_RESULT=$(cat "/tmp/ci-result-${PROJECT_NAME}-${ISSUE}.txt" 2>/dev/null || echo "")
|
CI_RESULT=$(cat "/tmp/ci-result-${PROJECT_NAME}-${ISSUE}.txt" 2>/dev/null || echo "")
|
||||||
REVIEW_COMMENTS=$(curl -sf -H "Authorization: token ${FORGE_TOKEN}" \
|
REVIEW_COMMENTS=$(curl -sf -H "Authorization: token ${FORGE_TOKEN}" \
|
||||||
"${API}/issues/${PR_NUMBER}/comments?limit=10" | \
|
"${API}/issues/${PR_NUMBER}/comments?limit=10" | \
|
||||||
|
|
@ -628,9 +629,14 @@ Git is the checkpoint — your code changes survived.
|
||||||
${GIT_DIFF_STAT}
|
${GIT_DIFF_STAT}
|
||||||
\`\`\`
|
\`\`\`
|
||||||
|
|
||||||
### Last known phase: ${LAST_PHASE:-unknown}
|
$(if [ "$LAST_PHASE" = "PHASE:escalate" ]; then
|
||||||
|
printf '### Previous session escalated — starting fresh\nThe previous session hit an issue and escalated. Do NOT re-escalate for the same reason.\nRead the issue and review comments carefully, then address the problem.'
|
||||||
|
else
|
||||||
|
printf '### Last known phase: %s' "${LAST_PHASE:-unknown}"
|
||||||
|
fi)
|
||||||
|
|
||||||
### PR: #${PR_NUMBER} (${BRANCH})
|
### PR: #${PR_NUMBER} (${BRANCH})
|
||||||
|
**IMPORTANT: PR #${PR_NUMBER} already exists — do NOT create a new PR.** Do NOT call the Codeberg/Gitea/Forgejo API to create PRs. The orchestrator manages PR creation.
|
||||||
|
|
||||||
### Recent PR comments:
|
### Recent PR comments:
|
||||||
${REVIEW_COMMENTS}
|
${REVIEW_COMMENTS}
|
||||||
|
|
@ -638,8 +644,9 @@ $(if [ -n "$CI_RESULT" ]; then printf '\n### Last CI result:\n%s\n' "$CI_RESULT"
|
||||||
|
|
||||||
### Next steps
|
### Next steps
|
||||||
1. Run \`git log --oneline -5\` and \`git status\` to understand current state.
|
1. Run \`git log --oneline -5\` and \`git status\` to understand current state.
|
||||||
2. Resume from the last known phase.
|
2. **PR #${PR_NUMBER} already exists.** Address any review comments, commit, push to \`${BRANCH}\`, then write \`PHASE:awaiting_ci\`.
|
||||||
3. Follow the phase protocol below.
|
3. Do NOT attempt to create PRs via API calls — the orchestrator handles that.
|
||||||
|
4. Follow the phase protocol below.
|
||||||
|
|
||||||
${SCRATCH_INSTRUCTION}
|
${SCRATCH_INSTRUCTION}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue