I’m not sure if this answers your question, but here is something to think about:
As a landlord, in my leases, the tenant is always responsible for obtaining and doing what is necessary, as per their use, to obtain a CO.
Regarding the code violations or issues; that is something that would come up during your due diligence. If there was such an issue, you would renegotiate the price to accommodate for the initial investment you will have to make upon purchase due to the seller’s lack of proper construction or maintenance. As a landlord, I warrant that the structure, plumbing, and electrical are in good working condition upon commencement date, plus anything we agreed to as the Landlord’s Work.
Let’s say for example that there is now a requirement for buildings or units of a certain size to have a sprinkler system, but due to the subject property’s age, there is none. It may not be fair to require the seller to install a sprinkler system because of the amount of improvements you want to make, which may trigger a requirement to bring the building up to code just for you to obtain your CO. That type of cost is normally incurred by the tenant or buyer.