When a problem is occurring, a code is set as "current", as in happening now. If the problem goes away, the code is stored as "history", for a number of ignition cycles.
Example: When my MAP sensor failed, the CES was never triggered, and there was never a current code , only a history code. I could clear them, start the car, and the MAP code would immediately be in history. This points to an intermittent fault, that doesn't last long enough to meet the criteria of triggering the CEL.
With my Catera, I get "current codes" and "pending codes". The pending codes are codes that the computer is tracking, for example if setting a code requires that the test fail 3 times in so many warm up cycles, it may have two of those failures.
Among other things, one of the functions of the history codes is to keep you from faking the state emissions test by resetting the codes before you go for the test. This history codes remain. I can't read them with my scanner, not sure if it is a function of not having a sophisticated enough scanner, or maybe it is the particular protocol used by the Catera.
History codes do not remain when the codes are cleared. In order to pass inspection, OBD must be "ready", meaning all monitored systems/components have had a chance to operate, and did so as expected. If the codes are cleared, the system will not be "ready" until you have completed one full "driving cycle" (google it).