You must file a US tax return if you have any trade effectively connected with a US trade or business. Even if you receive no income from the US.
The filing procedure depends on the structure business, if you are an individual (i.e. self-employed) you file as it outlines in this publication:
http://www.cra-arc.gc.ca/E/pub/tg/p151/README.html
Having spoken to the IRS the other day, you'd be amazed just how many people are supposed to file US returns. Essentially if you have an e-bay business based solely in Canada and you sell to anyone in the US you have to file a return. However, if your US-source income is less than $3,400 (2007) you do not have to, provided you are an individual (as opposed to a corporation or partnership).
The "substantial" presence test is really only relevant in as far as what paperwork you file, either a Form 8840 or an 8833 with the 1040NR return.
If you have a "fixed base" in the US, under the provisions of the tax treaty (e.g. an office, a house where you work from, a representative with an office etc. in the US) then your clients must perform 30% withholding on Form 1042-S on payments made to you. You'll probably also need to register as self-employed in the US.
The first time you file a return you should apply for an ITIN so they can identify you, an ITIN is similar to an SSN.
To cut a long story short the closer your connection to the US the more paperwork you have to do.
If 100% of the work is done in Canada and you have no office in the US and are merely acting on instructions of a US employer as a person self-employed in Canada, your only paperwork liability is a 1040NR and an 8840. There is no tax to pay, it's merely a reporting requirement.
The more you have in the US, i.e. fixed base, the more paperwork there is. There will be tax to pay because you work there. What paperwork depends on your status with the client/employer.
A dependent employee (i.e. direct labour) is not subject to withholding on earnings less than $10,000. An independent contractor is subject to the withholding though.
If your business is a corporation, the corporation files Form 1120-F together with Form 8833 instead.
IRS publication 515 explains the responsibility of your clients;
IRS publication 519 explains your responsibilities;
IRS publication 597 explains the tax treaty.
The main thing to bear in mind when you read these publications is that under the terms of the tax treaty there is no withholding necessary by your clients if you do not have a fixed base in the US.
On the Canadian end you have to claim a foreign tax credit for any tax paid in the US, which is explained in the general guide for the T1 or the instructions for schedule 21 for the T2 corporation return.
Bear in mind also that if you have a Canadian-based business, there is a very good chance you will be subject to Canadian departure tax if you ever move your tax home to the US. Departure tax does not apply to real estate or plant and equipment, but it does apply to liquid assets that have a capital gain of over $50,000. So if you started your business from zero and it currently has liquid assets (e.g. cash) of more than $50,000 on hand it will be subject to a 25% tax on amounts over that.
From the immigration standpoint, if you plan on using the existing arrangement, the entry category you want is L-1 intermittent, this allows you to enter the US for up to 180 days to work, however you must be a direct employee (and have been for at least a year) of the company to do that.
Steve.