[CMLIB] Adjust parameter types and annotations. Add diagnostic assertions.