fix(kvb-org-queue): restart holders on stale queue code; link host skills into projects
Every holder judges the shared queue.json with its own loaded code, so the project copies from 2026-11-07 (no RAM/CPU budget) granted heavy jobs on the slot limit alone and overloaded the host at 18:24. Each entry now stamps a hash of queue.py and the sibling scripts it loads; a poll that finds other code installed in ~/.agents/skills leaves the queue ungranted and re-execs the same hold with the installed queue.py, on the realpath interpreter, with signals reset and a caught signal ending the hold instead. queue.py list prefixes entries on other or unstamped code. A project install now symlinks every skill the global install holds instead of copying it, so the project hooks and ../ references stay valid and one host runs one version. 🎯 Fix: 92 % 💥 Break: 4 % 💸 Cost: 100 % ⏱️ Time: 100 % 🛡️ Security: 100 % 🏆 Score: 88 🚦 Gate: ✅ 90/5, cost and time <= 100, security 100 % Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e805b07c27
commit
ca54420f4d
4 files changed
+135
-21
No files matched your search
@@ -6,6 +6,7 @@ import fcntl
|
||||
import importlib.util
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
import signal
|
||||
import subprocess
|
||||
import sys
|
||||
@@ -532,6 +533,41 @@ class TestQueueCommands(unittest.TestCase):
|
||||
reason = self.run_queue("list").stdout.splitlines()[1].split("\t")[-1]
|
||||
self.assertRegex(reason, r"^RAM \d+ % used \+ \d+ % still to come reach the limit 0 %$")
|
||||
|
||||
def install_host_skills(self) -> Path:
|
||||
skills = self.base / "home" / ".agents" / "skills"
|
||||
for name in ("kvb-org-queue", "kvb-org-organize", "kvb-org-rasci"):
|
||||
shutil.copytree(QUEUE.parents[2] / name, skills / name)
|
||||
return skills / "kvb-org-queue" / "scripts" / "queue.py"
|
||||
|
||||
def test_a_hold_on_other_code_than_the_host_install_restarts_with_it_before_any_grant(self):
|
||||
host = self.install_host_skills()
|
||||
ran = self.base / "ran"
|
||||
args = ("hold", "--kind", "test", "--task", "work/a", "--session", "s1", "--", "touch", str(ran))
|
||||
same = self.run_queue(*args)
|
||||
self.assertEqual((same.returncode, same.stderr), (0, ""))
|
||||
self.assertTrue(ran.exists())
|
||||
ran.unlink()
|
||||
seen = self.base / "argv.json"
|
||||
host.write_text(f"import json, sys\njson.dump(sys.argv[1:], open({str(seen)!r}, 'w'))\nsys.exit(9)\n", encoding="utf-8")
|
||||
other = self.run_queue(*args)
|
||||
self.assertEqual(other.returncode, 9, other.stderr)
|
||||
self.assertIn(f"grants nothing on its own code. Restarting this hold with {host};", other.stderr)
|
||||
self.assertEqual(json.loads(seen.read_text(encoding="utf-8")), list(args))
|
||||
self.assertFalse(ran.exists())
|
||||
self.assertEqual(self.entries(), [])
|
||||
|
||||
def test_list_marks_an_entry_on_other_code_than_the_host_install(self):
|
||||
queue = _load(QUEUE)
|
||||
me, mine = os.getpid(), queue.identity(os.getpid())
|
||||
self.install_host_skills()
|
||||
self.write_store([
|
||||
{**stored(1, "waiting", me, mine, None, None), "code": queue.CODE},
|
||||
stored(2, "waiting", me, mine, None, None),
|
||||
])
|
||||
reasons = [line.split("\t")[-1] for line in self.run_queue("list").stdout.splitlines()[1:]]
|
||||
self.assertEqual(reasons[0], "granted on its next poll")
|
||||
self.assertTrue(reasons[1].startswith(f"queue code without a stamp, the host runs {queue.CODE}: "), reasons[1])
|
||||
|
||||
def test_hold_refuses_bad_input_with_exit_2_and_enqueues_nothing(self):
|
||||
def hold(*args: str) -> list[str]:
|
||||
return ["hold", "--session", "s1", *args]
|
||||
|
||||
Reference in new issue
Block a user