that gave me the clue: I changed the keyboard layout from a bundle to individual files in the /Library/Keyboard layouts/ directory. Now it works. So Apple's API presumably isn't the one they are using themselves…
Thanks for working it all through, much appreciated.