fix: add _tea_get and merged-PR catch-up to close issues on merge (#305) #310

Merged
guettlibot merged 3 commits from issue-305-fix into main 2026-05-27 22:07:15 +00:00
guettlibot commented 2026-05-27 22:06:48 +00:00 (Migrated from codeberg.org)

Why State/Question appeared on issue #282

The agent loop set State/Question on issue #282 because ci.yml has a
path filter — changes that only touch .forgejo/workflows/website.yml don't
trigger CI. The loop waited 15 min for a CI run on issue-282-fix, found
none, and concluded the push hadn't happened, marking the issue as a question.

What this PR fixes

1. Add _tea_get() — a direct Codeberg API client

Replaces the internal use of fgj actions run list for CI-run discovery.
_latest_main_ci_run and _latest_ci_run_for_branch now call _tea_get
directly; the latter matches PR runs via the event_payload JSON field
instead of resolving the PR number with a second fgj call.
_handle_pr_still_open_after_merge also uses _tea_get for the mergeable
check. This fixes 14 pre-existing test failures where tests mocked
agent_loop._tea_get but the function didn't exist.

2. Add _merged_issue_prs() + catch-up scan

On each cron tick the loop now scans for merged issue-{N}-fix PRs whose
issues still have state labels, and closes them. This covers the case where
State/Question was set (CI path-filter miss, timeout, etc.) but the PR was
later merged manually. Issue #282 will be closed on the next tick.

Test plan

  • 76 Python unit tests pass (python3 -m unittest scripts.test_agent_loop)
  • 4 new tests cover the merged-PR catch-up (TestMergedPrCatchup)
  • 14 previously-failing tests now pass (TestLatestMainCiRun, TestLatestCiRunForBranch, TestMergeFailsOpen)
  • Pre-commit hooks pass

🤖 Generated with Claude Code

## Why State/Question appeared on issue #282 The agent loop set `State/Question` on issue #282 because `ci.yml` has a path filter — changes that only touch `.forgejo/workflows/website.yml` don't trigger CI. The loop waited 15 min for a CI run on `issue-282-fix`, found none, and concluded the push hadn't happened, marking the issue as a question. ## What this PR fixes **1. Add `_tea_get()` — a direct Codeberg API client** Replaces the internal use of `fgj actions run list` for CI-run discovery. `_latest_main_ci_run` and `_latest_ci_run_for_branch` now call `_tea_get` directly; the latter matches PR runs via the `event_payload` JSON field instead of resolving the PR number with a second `fgj` call. `_handle_pr_still_open_after_merge` also uses `_tea_get` for the `mergeable` check. This fixes 14 pre-existing test failures where tests mocked `agent_loop._tea_get` but the function didn't exist. **2. Add `_merged_issue_prs()` + catch-up scan** On each cron tick the loop now scans for merged `issue-{N}-fix` PRs whose issues still have state labels, and closes them. This covers the case where `State/Question` was set (CI path-filter miss, timeout, etc.) but the PR was later merged manually. Issue #282 will be closed on the next tick. ## Test plan - [x] 76 Python unit tests pass (`python3 -m unittest scripts.test_agent_loop`) - [x] 4 new tests cover the merged-PR catch-up (`TestMergedPrCatchup`) - [x] 14 previously-failing tests now pass (`TestLatestMainCiRun`, `TestLatestCiRunForBranch`, `TestMergeFailsOpen`) - [x] Pre-commit hooks pass 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.