Will Zerodha be responsible or is it CSDL /NSDL?
When you buy a stock, until it hits your demat account (after 2 days), the onus is on the broker (Zerodha) to ensure that stocks reach your demat account. It is the onus on the broker to ensure if there is a short delivery (person who has sold stocks defaulting), that either stocks or cash from an auction settlement happens.
Once the stock is in your demat, it is responsibility of the depository (NSDL/CDSL).
Brokers will get holding file from depository everyday of all stocks the client has in demat, and this is updated on their trading/reporting platforms. When stocks are sitting in demat, there is no calculation done on buying price of the stocks. So the broker might run an analytic layer to show this, for which he might keep a tab on trades that resulted in a particular holding.