How it works
GmailApp.search runs the same query you'd type into Gmail's search bar. `older_than:30d in:inbox -is:starred` selects every inbox thread older than 30 days, excluding ones you starred to keep visible.
The result is capped at 100 threads per run. moveToArchive() flips Gmail's "Inbox" label off the thread without deleting anything — searches and labels still find it.
Idempotency comes free: a thread that's already archived no longer matches `in:inbox`, so re-running is harmless.