How do you determine the destination email address for catchall?

Right, so, milters (mail filters) are basically little apps that can act as plugins for MTAs, they can examine and even change the e-mail as it flows through. You can make a script in NodeJS using milterjs (ignore my PR, stalwart doesn’t trigger that bug)

So in your case you can do something like milterjs.on("envrcpt", (ctx, rcpt) => { /* if rcpt[0] something something */}) to get the destination address, and reset the destination address to your catchall in the milter script. Then you configure stalwart to use your milter.

You could also do all your analysis in your milter and tell stalwart to drop the e-mail.