The term 'ex post facto' literally means "from something done afterward" but it was always a technical term in criminal law. The inapplicability of the clause to civil matters and what aspects it refers to in the criminal law was explained and resolved by the SCOTUS in the case of Calder v. Bull in 1798, almost right after the Constitution was ratified. In the court's words, the ex post facto clause is implicated in the following circumstances: The opinion can be found here: Calder v. Bull