The infinite lifespan of most food items presents a significant gap in the games realism and challenge, it's been said many times that sieges can't be threatening when the player has a untouchable food reserve. Spoiling food would limit the size of reserves and also introduce a lot of potential for happiness mechanisms, without fail in all cultures and at all times eating fresh food is considered highly pleasurable and rotten food is extremely unpleasant so giving the player control of what (and perhaps how much) is eaten is the single most powerful happiness tool in the players arsenal.
The main problem with implementing food spoilage is how to present it to the player in a understandable format. The naive implementation is to simply make each food item 'rot' after a set period of time. As most crops are harvested in a short period of time this means an equally short period of time later in which it will all rot. This can be very hard for the player to manage as sudden disappearance of food can seemingly come out of no ware and put the settlement in danger of starvation. Worse the player could be confronted with a quandary if foods rotting time is sufficiently long that multiple batches of different ages of the same food stuff are in storage at the same time, a strawberry that is a month old is now very different from one that is a year old and about to rot. Displaying all this information for every type of food stuff would be an interface nightmare.
Thus I propose that food rot on a PROBABILISTIC basis rather then on a purely time driven basis, think of it like radioactive decay, over a given period of time each unit of food regardless of age has the same change of rotting. This eliminates the need to distinguish between different strawberries, the player just needs to know his total strawberry count and he can accurately predict how many will rot over any foreseeable timer period. We can go further by grouping food into classes of equal decay rate, if all strawberries, apples and other fruits have the same decay rate then their quantity can be aggregated without impairing the players ability to predict. I believe that just 4 classes should be adequate, half life is relative to a real year for illustration purposes, adjustment to Gnomoria day/month ratios will be necessary of course. AI of course eats the most perishable food first. Lastly it is vastly simpler to program as food doesn't need to hold a variable to record it's age, we simply iterate all food on a regular basis like once per day and roll random numbers to rot or not rot it.
Very Perishable - half life 3 days (Grapes, Strawberry, Milk, Sandwich)
Perishable - half life 2 weeks (Oranges, Eggs, Meat, Bread)
Stable - half life 3 months (Apples, Sausage)
Very Stable - half life 1 year (Wheat)
In addition it makes sense to have several stages of rottenness before food items disappear completely so the player can both see the gradual change and that the rotting dose not immediately removes food from possible consumption but rather reduces potential happiness from the loss in quality. Again 4 states seem appropriate, each food retains it's original perishability rate as it rots so highly perishable milk would continue to advance through each state at the same probability.
Fresh - Maximum Happiness gain
Stale - neutral Happiness
Rancid - Negative Happiness, 25% reduced nutritional value
Rotten - Very Negative Happiness, 50% reduced nutritional value plus disease potential
Rotten food that decays further simply disappears completely into unusable muck that simply needs to be cleaned up. The AI automatically eats the most rotten food first but the player can set a lower limit on what will be eaten, so for example Stale could be selected as the limit and anything below that (Rancid and Rotten) will be thrown out immediately and only Stale and Fresh will be eaten. Any of the 4 levels can be selected as the limit and Stale would be the default limit. Setting a higher limit guarantees more happiness but will result in more food being thrown out, a lower limit will guarantee no food is wasted but at the cost of lower happiness.
Lastly we want to let the player control the quantity of food consumed, many of you may remember Oregon Trail and it's food settings, again I'll go with 4 settings here, shamelessly ripped strait from OT. I'm assuming that Gnomes don't have fat reserves so some of the effects here like disease and weakness are more immediate then would be logical, loss of strength is a major factor in making military weak.
Sumptuous - 133% of requirements, bonus happiness
Filling - 100% of physical requirements for normal work, normal happiness
Meager - 66% of requirements, work slows, strength reduced, happiness penalty
Bare Bones - 33% of requirements, work nearly halted, strength nearly gone, large happiness penalty, disease very likely
Between the two big 'levers' of food quality and food quantity the player gains a lot of control over their settlements happiness and the game becomes a lot more flexible to changes in food production, we move away from the boring binary states of 'more food then I can eat that piles up to the sky' and 'less food then needed so mass starvation and rapid death'. Having this kind of flexibility is the first requirement of making food production less reliable as under the current system it will just push the player into the death zone without any real way to respond. But with Perishable food and these simple but powerful management settings adds immediate game-play while opening the door to future improvements.