What I did when encountering a similar issue was to take one of the messages from INBOX that should have been moved elsewhere and use sieve-test on it:
sieve-test -Tlevel=matching <sieve source file> <message file>
That generates a lot of output as it goes through every line of the sieve file and shows the actual values that are used for the tests. However, it pointed out my problem quite clearly.
Thank you for this.
Actually, after many hours of head-bashing, I discovered the problem.
sieve doesn't work when you're just using telnet port 25 !
I was doing : ehlo test mail from:sender@example.com rcpt to:recip@example.com data Subject: hello world Hello World ! .
With the above, sieve was simply sending everything to INBOX
When I changed my methodology : ehlo test mail from:sender@example.com rcpt to:recip@example.com data From:sender@example.com To:recip@example.com Subject: hello world Hello World ! .
It worked as expected.