engines/sg: move asserts and debug statements behind a debug flag