My understanding of the system under US patent law is that after 20 years, the patented process or device can be freely produced and sold by anyone. Is this always true? Is it legally safe to, say, research 20-year-old patents and to produce and market products directly based on them without significant changes?
Is this always true?
While the basic rule is that a US patent has a term of 20 years from its filing date (assuming all the renewal fees were paid), there are (at least) two ways in which the term of a US patent could be longer than this.
The first is by patent term adjustment under 35 USC § 154(b) due to delays by the USPTO. The calculation of this is complex. However, in general, if prosecution takes longer than the period specified in the statute, the term of the patent is extended based on the number of days beyond the specified period. This can add up to several years.
The second is by patent term extension under 35 USC § 156 due to regulatory delays. If approval of a patented drug or medical device takes so long that the applicant would have only a short period to exploit their patented invention, the term of the patent may be extended by up to 5 years.
There is a further category, though it is mostly of historical relevance. Before 1995 a US patent had a term of 17 years from issuance (not from filing). If issuance was delayed substantially, then the patent could in principle have a term of much longer than 20 years from filing. It is possible that there are still patent applications which were filed before 1995 that are still pending. Once these are granted, the term will be calculated according to the old rules.
In view of these, a more comprehensive statement of the law would be that you cannot be sued for patent infringement by copying a product exactly as it is described in an expired patent. That is much less pithy, of course.