I did get it working while trying to find the culprit. I have both MailTags and Mail Act-On from
http://indev.com installed.
1. I tried the script on another, similarly set up machine---it failed.
2. I quit Mail.app.
3. I moved my MailTags Preferences, together with ~/Library/MailTags.mailbundle and ~/Library/MailTags Extras to a folder on the desktop.
4. I restarted Mail.app.
5. The script worked.
6. I quit Mail.app.
7. I put my MailTags Preferences and ~/Library/MailTags.mailbundle back where they belonged.
8. The script worked.
9. I quit Mail.app.
10. I put ~/Library/MailTags Extras back where it belonged.
11. The script worked. MailTags' behavior was also unchanged.
So... in the end, I now have just what I had before, but the script works fine. There must've been some sort of cruft in some cache which got cleared out when MailTags was not loaded once.