There is clearly a serious breakdown in communication here.
A certificate of occupancy doesn't give a person the right to occupy a house or land; it's a certificate that all zoning and building codes have been met by a structure and that the use of the structure is legal.
No one can move into your house without your permission; the government certainly can't give them that right.
However, you need to get copies of this certificate, any application that was made, and find out what led to any confusion, if only because you don't want the City to think that you've done something to change your house. After you get copies, talk to the person who is the "zoning official" or "building official" in the City and explain the situation. If they don't clear up the problem, go up the chain . . . but be prepared to talk to an attorney if it looks like the construction company wants to start putting materials, trucks, etc. on your land.
Nobody may move into your home without your permission. This does not make sense. You say you live there, then why did you need a friend to tell you that someone was occupying your house? Who applied for the "certificate of occupancy" and on what basis? Why didn't you just demand that the people leave?
I have been licensed to practice in the State of Oregon since 1990. I am not offering legal advice regarding your question, only general information regarding the law. You are not my client nor am I your attorney unless we sign a retainer agreement.
This is quite an odd situation. I agree with my colleague. The city just cannot issue a permit for someone to live in a house that's owned by another private citizen.
Consult an attorney in your area.
DISCLAIMER: Brandy A. Peeples is licensed to practice law in the State of Maryland. This answer is being provided for informational purposes only and the laws of your jurisdiction may differ. This answer based on general legal principles and is not intended for the purpose of providing specific legal advice or opinions. Under no circumstances does this answer constitute the establishment of an attorney-client relationship. For legal advice relating to your specific situation, I strongly urge you to consult with an attorney in your area. NO COMMUNICATIONS WITH ME ARE TO BE CONSTRUED AS ARISING FROM AN ATTORNEY-CLIENT RELATIONSHIP AND NO ATTORNEY-CLIENT RELATIONSHIP WILL BE ESTABLISHED WITH ME UNLESS I HAVE EXPRESSLY AGREED TO UNDERTAKE YOUR REPRESENTATION, WHICH INCLUDES THE EXECUTION OF A WRITTEN AGREEMENT OF RETAINER.