feat(kvb-org-queue): cap the booked RAM share per kind with ram_cap_percent

Operator order relayed by Main on 2026-11-14 22:25: book at most 30 % RAM for test jobs.
learn() folds ram_cap_percent {kind: percent} into each kind the way it folds light_kinds;
footprint() and ceiling() book min(share, cap), while the learned shares and the history
rows stay raw. A cap map that is not {kind: percent above 0 up to 100} makes hold exit 2,
keeps fresh() on the last good config and makes admit refuse. learning.md documents the
key and the re-hold after an install.

Security acceptances (kvb-think-criticize with an independent skeptic; false positives or
by design, all in unchanged lines of the touched files): MEDUSA-MM-SCAN-058 queue.py 375
377 621 623 624 629 630 633 634; MEDUSA-ACP-SCAN-028 queue.py 297; MEDUSA-RT-SCAN-054
queue.py 731; MEDUSA-AI-BACKDOOR-006 queue.py 746 806 1140 1166 1189 1190 1243 and
history.py 353; MEDUSA-WM-SCAN-780 queue.py 1215.

🎯 Fix: 88 %
💥 Break: 3 %
💸 Tokens: –
⏱️ Velocity: –
🛡️ Security: ~100 %
🏆 Score: 85
🚦 Gate: ⛔ fix 88 % < 90

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kevin Veen-BirkenbachandClaude Opus 5.5 committed 2026-11-14 22:58:07 +00:00
1 parent b95e305db0
commit e1445cb88b
5 files changed
+96 -17

No files matched your search

+11
View File
@@ -1148,6 +1148,17 @@ class TestWatchCommands(unittest.TestCase):
self.assertEqual(short.returncode, 3)
self.assertIn("memory stage stop", short.stdout)
def test_admit_refuses_while_the_ram_cap_is_broken_and_grants_under_a_valid_one(self):
self.cfg["thresholds_gb"] = {"warn": 0, "stop": 0, "critical": 0}
self.cfg["ram_cap_percent"] = {"test": "30"}
self._write_config()
denied = self._run("admit", "--kind", "test", "--", "true")
self.assertEqual(denied.returncode, 3)
self.assertIn("ram_cap_percent is no {kind: percent above 0 up to 100} map", denied.stdout)
self.cfg["ram_cap_percent"] = {"test": 30}
self._write_config()
self.assertEqual(self._run("admit", "--kind", "test", "--", "true").returncode, 0)
def test_admit_refuses_a_heavy_command_and_names_the_queue_hold_of_kind_test(self):
self.cfg["thresholds_gb"] = {"warn": 0, "stop": 0, "critical": 0}
self.cfg["slot_need_gb"]["test-nostack"] = 0