I've seen several patterns. Many of them collect the first flush water in a container, and the weight of water collected tips something over to re-direct the flow into the cistern. Some use a float for a similar purpose. I've illustrated that sort of a design, as just one example.
In the illustration, a downspout pours onto an open-topped channel, which is balanced on a fulcrum. As the first flush of water fills the container on the right, the float pushes up that side of the channel, and the remaining water flows into the cistern on the left.
Ideally, the container on the right would empty itself at about the same rate as the roof becomes dirty. Maybe a plant that can draw water from this source, or a series of very small holes...
In any event, the weight of the water in the channel provides some stability (hysteresis, technically) to the control system: whichever way it's tilted, it tends to stay that way as long as water is flowing. It might take some tuning to get a float that just overcomes this with a reasonable flow of water and a nearly-full container.
"the qualities of these bacteria, like the heat of the sun, electricity, or the qualities of metals, are part of the storehouse of knowledge of all men. They are manifestations of the laws of nature, free to all men and reserved exclusively to none." SCOTUS, Funk Bros. Seed Co. v. Kale Inoculant Co.