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:
Kevin Veen-BirkenbachandClaude Opus 5.5 committed 2026-11-22 22:50:16 +00:00
1 parent 20b1500b80
commit a4f7017691
10 files changed
+209 -67

No files matched your search

+5 -3
View File
@@ -36,7 +36,9 @@ check passed (<check>)"), or `done` ("... marked done by <name>").
`add` under the same slug reopens the row and clears `cancelled` and
`failed`.
The hub's runner reports through `ran` and `failed`, as the same calls:
exit 0 closes the row from any status but done, whatever its check; exit
130 and signals count as failures. Any agent of the same user can forge `ran`, `failed` or
The hub's runner runs the command as `$SHELL -ic` too and reports through
`ran` and `failed`, as the same calls: after exit 0 it runs `checked` on
the host, and the row closes from any status but done only when that
passes; otherwise `ran --check-failed` keeps it open. Exit 130 and signals
count as failures. Any agent of the same user can forge `ran`, `failed` or
`done`: the register and the radio are writable by every agent already.
+40 -12
View File
@@ -85,11 +85,14 @@ Args:
done <slug> [--session <id>]: mark a row done, whatever its check, with
a message unless it was done; a stale `failed` or `cancelled` goes
as in ran. Without a session the caller is Operator.
ran <slug> --command "<cmd>" --dir <dir>: the hub's report of a job
that exited 0: the row set done from every status but done and
whatever its check, which the hub cannot run without the host's
repos, PATH and installed dirs; a stale `failed` or `cancelled`
goes.
ran <slug> --command "<cmd>" --dir <dir> [--check-failed]: the hub's
report of a job that exited 0: the row set done from every status
but done, or with --check-failed (the runner's `checked` on the host
did not pass) kept open with a message like run's; a stale `failed`
or `cancelled` goes.
checked <slug>: exit 0 when the row's check passes here as run would
close it, 1 when it does not, 2 for a slug the register lacks; the
hub's runner calls it on the host after a job's exit 0.
failed <slug> --why "<text>" --command "<cmd>" --dir <dir>: the hub's
report of a job that failed: the row set stopped with why and no
output lines under `failed`, sent as a message like a failure in run.
@@ -792,11 +795,20 @@ def settle(rasci: ModuleType, row: dict, status: str | None, fields: dict, statu
return addressees(holders, None)
def succeeded(rasci: ModuleType, row: dict, hub: bool) -> str:
def holds(row: dict) -> bool:
"""Returns:
Whether the row's check passes here; manual and an unreadable check
pass at once.
"""
check = "manual" if problem(row["check"]) else row["check"]
return check == "manual" or passed(check)
def succeeded(rasci: ModuleType, row: dict, hub: bool, complete: bool) -> str:
"""Args:
hub: the hub's report: the row closes whatever its check and from
every status but done; else only while open and once its check
passes (manual: at once).
hub: the hub's report: the row closes from every status but done;
else only while open.
complete: whether its check passed where the command ran.
Returns:
What an exit 0 did: the row as shown set done, or kept open while
@@ -806,7 +818,6 @@ def succeeded(rasci: ModuleType, row: dict, hub: bool) -> str:
"""
name = visible(row["task"], "")
check = "manual" if problem(row["check"]) else row["check"]
complete = hub or check == "manual" or passed(check)
statuses = tuple(status for status in rasci.STATUSES if status != "done") if hub else OPEN
agents = settle(rasci, row, "done" if complete else None, {}, statuses)
if agents is None:
@@ -1065,7 +1076,7 @@ def cmd_run(rasci: ModuleType, args: argparse.Namespace) -> int:
elif code != 0:
print(failure(rasci, row, f"exit {code}", shared(lines, typed)))
else:
print(succeeded(rasci, row, False))
print(succeeded(rasci, row, False, holds(row)))
return 0
@@ -1097,10 +1108,22 @@ def ran_row(rasci: ModuleType, args: argparse.Namespace) -> dict:
def cmd_ran(rasci: ModuleType, args: argparse.Namespace) -> int:
print(succeeded(rasci, ran_row(rasci, args), True))
print(succeeded(rasci, ran_row(rasci, args), True, not args.check_failed))
return 0
def cmd_checked(rasci: ModuleType, args: argparse.Namespace) -> int:
"""Returns:
0 when the row's check passes here, the way run closes a row after
exit 0; 1 when it does not; exit 2 for a task the register lacks.
"""
task = task_of(rasci, args.slug)
entry = rasci.load().get(task)
if entry is None:
fail(f"{task}: not in the register")
return 0 if holds({"check": entry.get("check") or "manual"}) else 1
def cmd_failed(rasci: ModuleType, args: argparse.Namespace) -> int:
why = visible(" ".join(args.why.split()), "")
if not why:
@@ -1142,6 +1165,11 @@ def main() -> int:
for flag in flags:
p.add_argument(flag, required=True)
p.set_defaults(func=func)
if name == "ran":
p.add_argument("--check-failed", action="store_true")
p = sub.add_parser("checked")
p.add_argument("slug")
p.set_defaults(func=cmd_checked)
args = parser.parse_args()
return args.func(module("rasci", RASCI), args)