How dead is dead? Because of gardening I have veggies sitting around for a long time, sometimes months. It is fascinating to me, that a squash can be fine for months, and then a mold starts to grow and the decay goes pretty fast from that point. It seems obvious the veggie or fruit, can ward off decay up to a point. Not having schooling in such matters, it seems to me a picked veggie or fruit is still living, until that moment when decay consumes its life.
The primary (but not sole) vector for rot/decay is the ability of invading bacteria to grow and reproduce in watery/damaged cell tissues. Accordingly, the higher the moisture content, the weaker the cell structures, the faster the process of bacterial growth and decomposition can occur ... thus, something moist and delicate like a ripe tomato with a nick in its skin can start rotting overnight, whereas a tough thick skinned winter squash or gourd can last weeks or even several months at room temperature, if the skin is kept unblemished and the stem was properly cut and dried. That dry hard rind acts like a fortress wall against bacterial invasion.
Other inhibitors against bacterial invasion and premature spoilage are exterior wax (such as the kind applied to to things like apples and turnips in supermarkets), cold (which also slows ripening as well as the rate of bacterial reproduction and motility), sulfite (usually applied to dried fruits), and various types of salts (used in charcuterie for things like pickles, cured meats, etc), smoke, etc.
Getting back to confit ... the technique, for musrooms, is to clean, chop and slice mushrooms, then cook/reduce/brown them in some butter to kill any bacteria present and remove most of the water (read: bacterial reproduction vector), then you salt/season them to taste (the salt helps preserve them), then you place them piping hot into jars just large enough to hold them all, then top them up with hot clarified butter, with displaces all the air throughout the jar and forms a cap just below the lid. A few pokes with a chopstick or ice pick helps encourage any pockets of air to bubble to the surface, then you lock the lid and refrigerate it. Once solidified, the butter serves as a barrier against spoilage by taking away the opportunity for bacteria to reproduce in a friendly liquid medium. If the cap is undamaged, the confit can last weeks or months in the fridge ... but once you cut into it, you should use it up with a few weeks, at most.
Figure that 1 lb of mushrooms yeilds about 1 cup of mushroom confit. As for seasonings (besides salt), I like a little ground pepper, a whisper of thyme, and just a touch of worchestershire sauce.