The window mirrors the US wash-sale-rule at 30 days either side, and it explicitly covers purchases by affiliated persons, including a spouse and a corporation you control, and purchases inside registered accounts.
Where the loss is denied, it is added to the adjusted cost base of the reacquired property, so relief is deferred rather than lost, except where the repurchase happens inside a registered plan, in which case the loss disappears permanently.
Traders reassessed as earning business income under canada-capital-gains-inclusion-rate hold inventory rather than capital property, so the rule does not apply to them in the same way.
This is general information about Canada, not tax advice. Rules change and depend on your circumstances; confirm with a qualified professional or cra-canada.
Related: wash-sale-rule, canada-capital-gains-inclusion-rate, tfsa-day-trading-risk, cra-canada, uk-bed-and-breakfasting-rule