# Process Lessons ## When verifying PR state via the Gitea API, dump the full JSON Do not assert on a single key like `state`. Dump the response (`json.dumps(..., indent=2)`) and read `state`, `merged`, `merged_at`, and `merge_commit_sha` together. PRs that look "closed" may have been merged; PRs that look "open" may have a stale `head` SHA pointing at a deleted branch. ## Fork-cleanup workflows must live on the fork, not the parent When the goal is "clean up branches on a fork", commit the workflow to the fork's `.gitea/workflows/`. The parent repo's Actions runner does not see fork branches. Verify Gitea Actions is enabled on the fork (`has_actions: true` in the fork's repo metadata). ## Use `fetch-depth: 0` in cleanup jobs that inspect commit dates Shallow clones omit the timestamps needed to decide "this branch has been inactive for 7 days". The cleanup job itself must use `fetch-depth: 0` even if every other clone in the workflow is shallow. ## Test the wrong-path detection by writing to the wrong path on purpose When adding output validation + correction prompt, do a smoke test that deliberately writes the expected content to the wrong path. Confirm the sentinel `.correction-prompt.txt` is written and the entrypoint re-invokes the agent. Don't rely on accidental coverage.