http://perl-qa.yi.org/index.php/TAP_diagnostic_syntax
There's already a proposal for this which nobody's found serious fault with. Its, oh, 9 months old now. Its backwards compatible with existing TAP. It both solves the problems of associating diagnostics with a specific test and making them machine parsable. I'm perfectly happy to accept patches for Test::Builder to support this as an experimental feature. Code!