# Stale PR flow

The action does one thing: for every open PR that has gone stale, it posts a single
polite reminder asking the author to merge or close it. It does **not** inspect
approval, Atlantis apply history, or merge state — those checks were the source of
most past bugs, and the decision to auto-close was dropped in favor of simply
nudging the author.

```mermaid
flowchart TD
    A([For each open PR]) --> B{Has 'Dont Merge' or 'do not apply' label?}
    B -- Yes --> SKIP1([Skip — author parked it intentionally])
    B -- No --> C{created_at within STALE_DAYS?}
    C -- Yes --> SKIP2([Skip — not stale])
    C -- No --> D{Bot already commented within COMMENT_LEASE_DAYS?}
    D -- Yes --> SKIP3([Skip — spam guard])
    D -- No --> ACT[💬 Notify: open for N days, please merge or close]

    style ACT fill:#fff3cd,stroke:#856404
    style SKIP1 fill:#e9ecef,stroke:#6c757d
    style SKIP2 fill:#e9ecef,stroke:#6c757d
    style SKIP3 fill:#e9ecef,stroke:#6c757d
```

## Rules

| Condition | Action |
|---|---|
| PR has `Dont Merge` or `do not apply` label | Skip — intentional opt-out |
| `created_at` within `STALE_DAYS` (default 7) | Skip — not stale |
| Bot commented within `COMMENT_LEASE_DAYS` (default 3) | Skip — avoid spam |
| Otherwise | Post one polite "merge or close" reminder (+ best-effort Slack DM) |

The reminder includes a one-line note that long-open infrastructure PRs can drift
from the live state or lose their Atlantis lock. The author decides whether to merge
or close; the bot re-nudges each lease window until they do.

`TEST_PR_NUMBER` bypasses the staleness and lease checks (but still respects the
opt-out labels) so a single PR can be exercised on demand.
