diff --git a/dev/phase-handler.sh b/dev/phase-handler.sh index b72ab5b..08ef9df 100644 --- a/dev/phase-handler.sh +++ b/dev/phase-handler.sh @@ -410,9 +410,11 @@ Write PHASE:awaiting_review to the phase file, then stop and wait for review fee _ci_pipeline_url="${WOODPECKER_SERVER}/repos/${WOODPECKER_REPO_ID}/pipeline/${PIPELINE_NUM:-0}" if [ "$CI_FIX_COUNT" -gt "$MAX_CI_FIXES" ]; then log "CI failure not recoverable after ${CI_FIX_COUNT} fix attempts — escalating" + local _mention_html="" + [ -n "${MATRIX_MENTION_USER:-}" ] && _mention_html="${MATRIX_MENTION_USER} " notify_ctx \ "CI exhausted after ${CI_FIX_COUNT} attempts — escalating for human help" \ - "CI exhausted after ${CI_FIX_COUNT} attempts on PR #${PR_NUMBER} | Pipeline
Step: ${FAILED_STEP:-unknown} — escalating for human help" + "${_mention_html}CI exhausted after ${CI_FIX_COUNT} attempts on PR #${PR_NUMBER} | Pipeline
Step: ${FAILED_STEP:-unknown} — escalating for human help" printf 'PHASE:escalate\nReason: ci_exhausted after %d attempts (step: %s)\n' "$CI_FIX_COUNT" "${FAILED_STEP:-unknown}" > "$PHASE_FILE" # Do NOT update LAST_PHASE_MTIME here — let the main loop detect PHASE:escalate return 0 @@ -646,9 +648,11 @@ Instructions: _issue_url="${FORGE_WEB}/issues/${ISSUE}" _pr_link="" [ -n "${PR_NUMBER:-}" ] && _pr_link=" | PR #${PR_NUMBER}" + local _mention_html="" + [ -n "${MATRIX_MENTION_USER:-}" ] && _mention_html="${MATRIX_MENTION_USER} " notify_ctx \ "⚠️ Issue #${ISSUE} (PR #${PR_NUMBER:-none}) escalated — needs human input.${ESCALATE_REASON:+ Reason: ${ESCALATE_REASON}}" \ - "⚠️ Issue #${ISSUE}${_pr_link} escalated — needs human input.${ESCALATE_REASON:+ Reason: ${ESCALATE_REASON}}
Reply in this thread to send guidance to the agent." + "${_mention_html}⚠️ Issue #${ISSUE}${_pr_link} escalated — needs human input.${ESCALATE_REASON:+ Reason: ${ESCALATE_REASON}}
Reply in this thread to send guidance to the agent." log "phase: escalate — notified via Matrix, session stays alive waiting for reply" # Session stays alive — matrix_listener injects human reply directly diff --git a/lib/load-project.sh b/lib/load-project.sh index 49e4199..fc4e579 100755 --- a/lib/load-project.sh +++ b/lib/load-project.sh @@ -66,6 +66,8 @@ if 'bot_user' in mx: emit('MATRIX_BOT_USER', mx['bot_user']) if 'token_env' in mx: emit('MATRIX_TOKEN_ENV', mx['token_env']) +if 'mention_user' in mx: + emit('MATRIX_MENTION_USER', mx['mention_user']) # [monitoring] section mon = cfg.get('monitoring', {}) diff --git a/projects/disinto.toml.example b/projects/disinto.toml.example index 759865f..c0a3003 100644 --- a/projects/disinto.toml.example +++ b/projects/disinto.toml.example @@ -17,9 +17,10 @@ stale_minutes = 60 containers = [] [matrix] -room_id = "!your_room_id:matrix.example.org" -bot_user = "@disinto-factory:matrix.example.org" -token_env = "DISINTO_MATRIX_TOKEN" +room_id = "!your_room_id:matrix.example.org" +bot_user = "@disinto-factory:matrix.example.org" +token_env = "DISINTO_MATRIX_TOKEN" +mention_user = "@johba:matrix.allf.in" # Matrix user to @mention on escalations [monitoring] check_prs = true diff --git a/projects/harb.toml.example b/projects/harb.toml.example index 0761a59..83bb1e1 100644 --- a/projects/harb.toml.example +++ b/projects/harb.toml.example @@ -17,9 +17,10 @@ stale_minutes = 60 containers = ["ponder"] [matrix] -room_id = "!your_room_id:matrix.example.org" -bot_user = "@harb-factory:matrix.example.org" -token_env = "MATRIX_TOKEN" +room_id = "!your_room_id:matrix.example.org" +bot_user = "@harb-factory:matrix.example.org" +token_env = "MATRIX_TOKEN" +mention_user = "@johba:matrix.allf.in" # Matrix user to @mention on escalations [monitoring] check_prs = true