std::println("stacks and memory: the slots config, slot.json, free memory, a pass's measured cost, the admission, the prompts, the preflight, `slots`");
&&bad(sl({{"dir",".local-stack/slots"},{"start","bash s.sh full --slot {n}"},{"stop","bash s.sh stop --slot {n}"},{"memMb",1500}})).empty()
&&AnyContains(bad(sl({{"dir","/abs"},{"memMb",1}})),"inside the repository")&&AnyContains(bad(sl({{"dir","s"},{"start","bash s.sh"},{"memMb",1}})),"{n}")
Check("config: functional.concurrency is retired - no problem (a freeze or a run goes on), the key dropped, a warning that says what replaced it; the --config path kept; no _warnings in the dump",
cr.problems.empty()&&cr2.problems.empty()&&warnings.size()==1&&w0.starts_with("functional.concurrency is no longer read - remove it from config.json:")&&w0.contains("free memory")
Check("slot_stacks: the slots that are up in slot order (2, 10), the URL without its trailing slash; a hosted database, no appUrl and bad JSON are problems; a dir without slot.json is not up",
Check("memory: MemAvailable and MemTotal in MB; the reserve is 10 % of MemTotal (at least 2048 MB) unless REVIEW_GATES_MEM_RESERVE_MB says otherwise; no file, no number",
Check("memory: a process tree's PSS - this process measures above zero, a pid that is gone measures zero",Platform::PssMb(tree)>1&&Platform::PssMb(gone)==0&&std::ranges::contains(tree,me));
Check("Calibration: the measured default before any peak; then the highest of the last 30 peaks of this repository and environment (an old outlier ages out); another repository keeps its own",
d0.megabytes==900&&d0.source=="the default measured 2026-10-22; none measured in this repository yet"&&cal.CostOf("browser").megabytes==700.0&&cal.Peaks("browser").size()==Memory::Keep
Check("Admission: a pass with an application takes a stack of its own and its cost; the next one waits for the stack, one over the budget waits for memory",
Check("Admission: inside the budget but the machine has less than cost + reserve free right now -> wait; with room -> go",!low&&adm.Can(j4));
adm.Give(j1);
Jsonbig={{"label","e"},{"mb",5000}};
constboolalone=adm.Can(big);
adm.Take(big);
Check("Admission: given back, the stack and the memory are free again; with nothing in flight a pass over the budget runs alone, and the log says so once",
Check("app block with slots: a stack of this pass's own, STACK FOR THIS PASS named, no URL, origin, fixture or TOTP command in the shared block; the rules: yours alone, not reset between passes",
abSlots.contains("a stack of this pass's own")&&abSlots.contains("STACK FOR THIS PASS")&&!abSlots.contains("localhost:8080")&&!abSlots.contains("54321")&&!abSlots.contains("test-user.json")
&&!abSlots.contains("/p/bin/crafter-review")&&abSlots.contains("TOTP enrolled")&&abSlots.ends_with(Prompt::ShotRules)&&abSlots.contains("not reset between passes")&&abOne.contains("localhost:8080")
&&abOne.contains("test-user.json")&&abOne.contains("not reset between passes")&&!abOne.contains("STACK FOR THIS PASS"));
Check("user prompt: the pass's stack - its URL, origins, login and exact TOTP command, never its database URL - between the scope and the budget line; without one the message is what it was",
up.find("TAIL")<up.find("STACK FOR THIS PASS (slot 2, yours alone while this pass runs)")&&up.find("STACK FOR THIS PASS (slot 2, yours alone while this pass runs)")<up.find("Tool-call budget")
&&up0==std::format("TAIL{}\n\nReturn the structured output described in your instructions.\n",Prompt::BudgetLine(seven))&&Prompt::StackText(With(stk,{{"login",nullptr}}),std::nullopt).contains("no login fixture"));
Check("functional block hint: the stack is the pass's own and not reset between passes",
Prompt::FunctionalBlockHint.contains("yours alone while this pass runs, but it is not reset between passes")&&!Prompt::FunctionalBlockHint.contains("at the same time"));
g.migrationsDrift=[](conststd::string&){returnstd::pair<std::optional<std::string>,std::optional<std::string>>(std::nullopt,"its 2 applied migrations are the range HEAD's");};
constautogood=pre({Fn});
conststd::vector<std::string>appSeen=answered;
conststd::vector<std::string>dbSeen=probed;
answered.clear();
probed.clear();
constautoonlyDb=pre({"repo-bug-prover.md"});
conststd::vector<std::string>dbOnlySeen=probed;
users.clear();
constautostale=pre({Fn});
users.push_back({"x"});
g.appReady=[](std::string_viewurl,std::string_view){returnstd::pair<bool,std::string>(!url.contains(":22180"),std::format("connection refused by {}",url));};
constautodown=pre({Fn});
Check("preflight: slots configured and none up stops the run and names `<invocation> slots`; a broken slot.json stops it",
noneUp.first=="3"&&noneUp.second.contains("no slot is up under .local-stack/slots")&&noneUp.second.contains(std::format("`{} slots`",Invocation()))&&broken.first=="3"
&&broken.second.contains("slots/3/slot.json"),
noneUp.second+broken.second);
Check("preflight: a lens that drives the application checks every stack - its app, its database, its migrations; a lens with the database alone checks the first",
good.first=="ok"&&appSeen.size()==2&&dbSeen.size()==2&&dbOnlySeen==std::vector<std::string>{two.front().at("dbUrl").get<std::string>()}&&good.second.contains("2 slot(s) under .local-stack/slots")
&&g.dbChecked&&g.dbChecked->starts_with("the database of each of the 2 stacks answers")&&onlyDb.first=="ok",
good.second);
Check("preflight: a stack whose login is not in its auth.users stops the run (a fixture left from another bring-up); an app that does not answer names its slot and the start command",
stale.first=="3"&&stale.second.contains("slot 1: its login l/u.json (a@x.test) is not in that stack's auth.users")&&down.first=="3"&&down.second.contains("slot 2: the application does not answer")
&&down.second.contains("(up --slot {n})"),
stale.second+down.second);
// exec_job: the stack the admission gave, the measured peak into the
Check("exec_job: the record names the pass's stack, and its measured peak becomes its environment's calibration",rec.at("stack")=="slot 2"&&g.calibration->CostOf("browser+supabase").megabytes==812.5);
// `slots`: as many as free memory holds, no more than the range's
// browser passes, the commands for the missing ones.
// 20000 free - 4000 reserve - 1 slot up x 812.5 = 15187.5 for (1500 +
// 812.5) each -> 6 more.
Check("slots: room = free - reserve - the passes of the slots up, each new slot at memMb plus one measured pass -> 6 more, numbered after the ones up; with the fixture range no more than its 3 browser block passes",
want==7&&cmds==expected&&want2==3&&cmds2==std::vector<std::string>{"up --slot 2","up --slot 3"}&&AnyContains(out,"room for 6 more by memory"),Dyn::Join(out," | "));
Check("slots: no more start at once than free memory holds at slots.startMb each (15187 MB / 6000 -> 2), and one at a time without it",AnyContains(out,"at most 2 at once (slots.startMb 6000 MB each"),