Drain, then the third crash
A model takes memory, and unloading one while it is answering is discourteous. The Citadel is polite about it, and then firm.
When a model is asked to unload, new requests are refused at once with a 503, model_unloading. Requests already running get up to thirty seconds, which is configurable, and are then cancelled. The reply to the unload comes only after the model is out of memory.
Crashes get a ledger. The Citadel writes a marker before it loads a model and removes it afterwards, and writes another while it runs, removed on a clean shutdown. Either marker present at start means the last start or run died. It logs the unclean start, clears the markers and loads as usual.
After three recoveries within an hour it stops trying. It starts with no models, writes HALTED, and reports crash_marker: true on its health endpoint until a person clears the files. A kill counts as a crash. A clean stop does not.
Restores load the smallest model first, each through the fit check. A model that is refused is flagged and skipped, and the rest still load. An empty list is not an error. It means the server is up and nothing is loaded.
A keep rebuilds itself twice, and then waits for its warden.
Corvin
