fix(hub): runner runs operator rows in the operator's shell and closes them only when the host check passes
A hub-run operator row ran under bash -c with PATH=/usr/bin:/bin, so a command that works in the operator's terminal (aliases, PATH additions) failed there, and exit 0 closed the row whatever its check, because the hub cannot read the host's repos, PATH and installed dirs. The runner now runs the signed text as $SHELL -ic <text> in the signed directory, like operator.py run (SHELL, else the runner uid's login shell). After exit 0 it runs operator.py checked <slug> the same way and reports checked true, false or null; the hub calls ran without --check-failed only when checked is true, so a row whose check fails on the host stays open with a message like run's.
operator.py: new checked <slug> (exit 0 pass, 1 fail, 2 unknown slug) and ran --check-failed; holds() shares the check with run. jobs.py accepts the optional checked field and drops the old usage-error fallback to done. The runner unit passes --operator with the installed operator.py; without it, or with an older hub or runner on either side, checked stays null and the row stays open (fails closed).
Rebased onto master from its lane base 2754568 with a 3-way apply: all 10 files clean, the staged stat equal to the patch's own (+206/-64), nothing of master reverted.
Tests: test_operator.py ran once on the staged tree (operator-approved run): 52 passed, 61 subtests passed. test_hub_executors and test_hub_console cover checked() and the ran/--check-failed calls; written, not run: the full suite runs once on master after all bundles (operator order). A probe of /bin/bash -ic without a tty, as systemd starts the runner, passes the exit code through (7); the rc file's 56-line banner lands at the head and falls out of the runner's last-lines output tail.
Security: MEDUSA over the staged tree on master: 100, 9 of 10 files covered, 0 open findings, every hit accepted earlier (RH005 after a skeptic review and the operator's accept). The systemd unit is outside MEDUSA's coverage; its one change appends --operator <installed operator.py>.
🎯 Fix: 90 %
💥 Break: 4 %
💸 Tokens: –
⏱️ Velocity: –
🛡️ Security: 100 %
🏆 Score: 86
🚦 Gate: ✅ 90/5, tokens and velocity <= 100, security 100 %
Created-with: https://s.veen.world/skills
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
20b1500b80
commit
a4f7017691
10 files changed
+209
-67
No files matched your search
+15
-1
@@ -1016,6 +1016,20 @@ class TestOperator(unittest.TestCase):
|
||||
with self.subTest(args=args):
|
||||
self.assertEqual(self._as(None, *args).returncode, 2)
|
||||
|
||||
def test_checked_answers_the_host_check_and_ran_with_check_failed_keeps_the_row_open(self):
|
||||
self._add("open", self.base, "true", "r", f"absent:{self.base}")
|
||||
self._add("gone", self.base, "true", "r", f"absent:{self.base / 'nothing'}")
|
||||
self._add("man", self.base, "true", "r", "manual")
|
||||
codes = {slug: self._as(None, "checked", slug).returncode for slug in ("open", "gone", "man", "missing")}
|
||||
self.assertEqual(codes, {"open": 1, "gone": 0, "man": 0, "missing": 2})
|
||||
shown = ("--command", "true", "--dir", str(self.base))
|
||||
kept = self._as(None, "ran", "open", *shown, "--check-failed")
|
||||
self.assertEqual(kept.returncode, 0, kept.stderr)
|
||||
self.assertIn(f"but absent:{self.base} does not pass yet; the row stays open", kept.stdout)
|
||||
self.assertIn("operator/open", self._open())
|
||||
self.assertEqual(self._as(None, "ran", "open", *shown).returncode, 0)
|
||||
self.assertNotIn("operator/open", self._open())
|
||||
|
||||
def test_the_hub_runner_calls_the_stored_session_with_ran_and_failed_even_when_its_channel_says_post(self):
|
||||
radio = REPO_ROOT / "skills" / "kvb-org-radio" / "scripts" / "radio.py"
|
||||
chosen = subprocess.run([sys.executable, str(radio), "feedback", "set", "post"], capture_output=True, text=True, env=self.env, check=False)
|
||||
@@ -1031,7 +1045,7 @@ class TestOperator(unittest.TestCase):
|
||||
"from kvb_orchestrator.jobs import Jobs\n"
|
||||
"from kvb_orchestrator.skill_scripts import Scripts\n"
|
||||
"hub = types.SimpleNamespace(scripts=Scripts(Path(sys.argv[2]), Path(sys.argv[3]), Path(sys.argv[4])))\n"
|
||||
"print(json.dumps([Jobs.close_row(hub, job, status, code) for job, status, code in json.loads(sys.argv[5])]))\n"
|
||||
"print(json.dumps([Jobs.close_row(hub, job, status, code, True) for job, status, code in json.loads(sys.argv[5])]))\n"
|
||||
)
|
||||
jobs = [
|
||||
[{"task": "operator/go", "command": "true", "directory": str(self.base)}, "done", 0],
|
||||
|
||||
Reference in new issue
Block a user