My self-employment income is entirely from US entities (not Canadian) but my self-employment base and residency are in Canada (not the US). My self-employment does not have a "permanent establishment" in the US.
i cannot answer fully
The part I can answer is as follows:
You are a resident of Canada. So first of all there is no state tax to file and you just file federal taxes.
Since you are a resident of Canada, you must pay the taxes to Canada. That is your tax country unless you officially have yourself declared as a non tax resident there. But i believe that is unnecessary
So you will pay all of this tax to Canada, and how you pay to them, you need to check with tax office there. This income may be treated special or even with tax incentives, since you are earning money from a foreign country and bringing money to Canada. but bottom line is that you pay its taxes to Canada.
And you of course show this income to US too. How you show is, on schedule C, i am almost positive on this. Foreign address there is also ok and everything as if you were in the US. And you can also deduct the taxes you paid to canada from the taxes you would owe to US.
So far this was the part I could answer.
The part I cannot answer is, what happens when this income is from the US. I mean, now for the US is it still a foreign income or an income from US sources?
well, there is still something i can answer... If you had a company established in Canada, a separate entity form yourself, then, the people who pay you from the US, would not be paying you but to your company. So they would not be paying a US person. so they would not be issuing a 1099 misc to you... they would be paying to a foreign company. when a US person pays to a foreign company, or a foreign person, i believe they must withold some tax on it but i am not sure. and to US, your reporting would be simple. you would just report your canada companys income on the appropriate forms for that to the US. and to canada, your company would report as any other company there.
the more confusing part that i cannot answer is, if you did not have a separate legal company in canada and you are a sole proprietor for example, in that case, what happens i am also not clear. i mean, you would still report this to canada as foreign income?. but when reporting this to US do you report it as foreign still? or US source income? I think in that case this would be US source income. where you pay the tax and where you deduct it in that case.. not sure... when you dont have a seaprate company in canada i mean. that is the confusing part.
please verify my answer with someone competent. I am not an accountant. I just wrote from what i think i know... this answer must be verified with someone knowledgeable.