Even if in transit at SFO you must clear US immigration and customs, then recheck any checked bags and clear security to get back airside. You will do this close to the International terminal so will be able to go to the SQ lounge if it is open. AC flights generally depart from the AA pier which is quite a walk but at least you won't have to clear security again. Allow at least 10-minutes to walk from the SQ lounge to the gate.