I had a play with this the other night, worked nicely but my footage was a little shoddy, need to give it another run.

Just some general thoughts about bulb ramping/post process correction...
In my mind it seems that how your eye/brain expects to perceive brightness transitions isnt (necesarily) consistent with having the whole scene sampled.
For example,
Lets say you are shooting a timelapse that has 50% foreground items, 50% background hills and sky.
Lets say that where you are standing, there is no cloud cover overhead, consistent lighting conditions of foreground items.
The only change to foreground item brightness occurs with the reducing natural sunlight or whatever.
However in the background of what you are shooting, there are rolling clouds causing rapid variations in brightness to the sky in that portion of your shot.
When the clouds dissapear and it's bright sky, the brightness of the sky causes exposure compensation to the foreground, despite no fluctuating lighting changes actually occuring there.
And vice versa.
The visual impact is an exposure 'wobble' to foreground items which was not present in reality, and a single foreground items flicker event across many frames that is impossible to compensate for when sampling the whole frame.
What I think would work well to eliminate this would to have two groups of RAW files to work from initially.
Folder A contains images to sample from
Folder B contains images to apply correction to
Folder C contains output images
In folder A, you edit the images so that they no longer contain the 'unstable' portions, for example you could crop out the sky, or mask out areas perhaps so it only samples from the foreground or areas where you want the stability in ramping.
Then you run the script, so something like:
FolderA\Image1.CR2 - checks exposure etc of cropped image (foreground items only)
FolderB\Image1.CR2 - applies brightness settings across to the whole scene contained in this file
FolderC\Image1.JPG - the output file
So you should be able to eliminate the 'long' flicker events quite easily I'd imagine.
The video thats a few posts above with the mountain with the clouds rolling overhead is an example of where I think the above methodology would perhaps work great, if you sampled from only the bottom half of the shot for exposure correction.