Files
pr-agent-server/scripts
asepharyana 1dc4d098fa feat(worker): skip-on-error no loop + conflict auto-fix + deduped notif
1. Skip ONCE on infra errors (Claude Code CLI missing/timeout/unreachable):
   - run_ai_fix returns '[INFRA] ...' reasons; worker marks the PR permanently
     skipped at that head SHA in fix-state (no more retry every 5 min)
   - skip is recorded per {repo,pr,sha}; cleared when head SHA changes
2. Merge conflict auto-fix via Claude Code:
   - mergeable=False or merge HTTP 409 now trigger run_ai_fix (prompt already
     merges base + resolves conflicts) once per head SHA
   - success → next tick re-checks mergeable and merges; failure → skip once
3. Discord skip notification dedupe:
   - notify_skip_once(): posts '⏭️ Skipped: <reason>' exactly once per
     PR+head_sha (state.notified flag); no repeated spam every cron tick
   - skip reason + which PR is visible in the notification
4. State migration: legacy {repo:{pr:'sha'}} → dict form handled in _pr_entry
Verified: py_compile clean, state-helper unit tests pass (skip/fixed/notify
dedupe/legacy migration). Cron wrapper execs repo copy — no manual sync.
2026-09-21 15:58:52 +07:00
..

PR Queue Worker

pr-queue-worker.py — the orchestration cron that watches open PRs across all repos where the PR-Agent GitHub App is installed and drives the full lifecycle:

  1. Open PR found → ensure a PR-Agent review exists (fabricates a webhook to pr-agent.asepharyana.my.id if not)
  2. Toolchain pin guard → closes dependabot PRs that bump pinned toolchain majors (see TOOLCHAIN_PINS map — typescript/eslint/@tsparticles/…) instead of waiting on them forever
  3. AI auto-fix → runs Claude Code (-p) on the PR head for up to AI_FIX_MAX_TURNS turns, then pushes the fix
  4. Safety analysis → parses the review body for security/major-issue blockers; score must be ≥ 6/10
  5. CI gate → waits for the required check to pass (closes stale dependabot PRs stuck failing CI for > STALE_CI_CLOSE_DAYS)
  6. Approve + merge

Deployment

  • Cron: Hermes cron job 04f13b9fdadc, every 5 minutes
  • Live path: ~/.hermes/scripts/pr-queue-worker.py (cron reads this file — keep it in sync with this repo copy)
  • Secrets: NOT in this file. Hydrated at import from ~/.hermes/.env ( PR_AGENT_APP_ID, PR_AGENT_KEY_PATH, PR_AGENT_WEBHOOK_SECRET, PR_AGENT_WEBHOOK_URL). The GitHub App private key lives at ~/.hermes/keys/pr-agent-key.pem (gitignored, never commit).

Sync note

This repo is the canonical version. The live cron copy under ~/.hermes/scripts/ is what actually runs — after editing here, cp scripts/pr-queue-worker.py ~/.hermes/scripts/pr-queue-worker.py and verify with:

/home/code/hermes-agent/.venv/bin/python3 -m py_compile ~/.hermes/scripts/pr-queue-worker.py
timeout 90 /home/code/hermes-agent/.venv/bin/python3 ~/.hermes/scripts/pr-queue-worker.py