I can't program at all so I don't know what's possible but some of this definitely is
a crisis would be triggered by the death of 3 or more dwarves, 33% or more of the population going hungry or thirsty or a certain percentage becoming miserable or whatever. (maybe smaller numbers and percentages if the dwarves are children)
In the case of death, it would have to be by the same cause, say a flood, a siege, a single creature, a cave-in or something and the code would try to define the entity that killed the dwarves.
In the case of siege, creature or cave-in it's easy to define the entity but if it's a flood it would have to be something like:
- must not be a pre-existing body of water(so 3+ dwarves drowning in a river would count as something other than a flood)
- must happen in a dug-out or built area
- must kill 3 dwarves or more
- all deaths must occur in water tiles connected to each other by water
and it would become a tragedy in the history of that fort. The entity would then be dealt with somehow by killing the invaders, draining the water away(maybe it could check for the floor where the dwarves drowned being dry) or whatever measure was applied and that would enter the history as well even if it was years afterwards
of course, not all historic events must be tragedies. It depends on how economy works in the future but right now you usually end up with thousands of food and drink so maybe if food and drink units were 10x the number of dwarves they'd throw a feast or banquet(and maybe you could tell your noble whether feasts are allowed) and that would be an event
maybe parties and feasts could be linked to nobles getting married, having children and so on
other historical moments could be the construction of something particularly elaborate such as a sublime well, artificial waterfall(if there's a way to check that one exists), the manufacture of some elaborate product("it refers to the establishment of a cheese industry in the bla bla bla") or the discovery of a cave
I think it'd be really cool if you looked at engravings, artifacts and so on and found things that had actually happened in your fortress