fix(hub): commit rows run only after their reviews, which now hold two hours

Stage 2.0's commit row failed because its approvals lived 15 minutes and the row ran before them (operator picks 2026-11-20). A review approval now holds two hours (signing.REVIEW_LIFETIME 7200 for all-review batches, signing.lifetime and checked_approval shared by the verifier and the hub). operator.py run reads the approval.py verify steps of a row's command (VERIFY_STEP, the same pattern signing uses), asks the hub through the client's hub_api for each review and skips the row with 'waits <name>: <why>; the row stays open' until every one is approved; a hub that does not answer, a missing client or a port above 65535 also skips it. The inbox lists each commit row's reviews (inbox.linked) with a reviews k/n approved pill; its Run button becomes 'Approve n and run', which brings the row's pending reviews into the selection, signs each rule and red-gate review alone first and then the rest once; approving.apply settles operator rows after the reviews they verify. kvb-git-diff and requirement 020 describe it.

Stacked on grantall (14bb4f3). Conflicts in page-inbox.js (grantNote and DENY_NOTE next to the ux reason chips) and kvb-git-diff/SKILL.md (the superseded line next to the two-hour paragraph) keep both sides. ruff and node --check pass.

Tests: tests/test_operator.py ran once before the commit (operator exception): 51 passed, 61 subtests. test_hub_approval, test_hub_console, test_hub_grant_mode and the fixture updates are written, not run: the full suite runs once on master after all bundles (operator order).

Security: MEDUSA over the staged tree on master: 100, no findings, all 16 files covered. WEB-SSRF at skills/kvb-org-operator/scripts/operator.py:996 (urllib.request to the local hub at base_url(port)) stays accepted as by design after kvb-think-criticize with 1 skeptic over 2 rounds and the operator's accept on 2026-11-21: the port is checked against 65535, the opener has no proxy and no redirects.

🎯 Fix: 92 %
💥 Break: 5 %
💸 Tokens: –
⏱️ Velocity: –
🛡️ Security: 100 %
🏆 Score: 87
🚦 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 16:41:45 +00:00
1 parent 14bb4f38df
commit 0fa05c54d5
16 files changed
+288 -33

No files matched your search

+4
View File
@@ -48,6 +48,10 @@ once the operator's pinned passkey signature over it verifies here.
`rejected`, or the tree changed: no commit; report the printed reason.
`superseded`: a newer request for the same worktree and branch replaced
it; wait on the review its `superseded_by` names.
A review's approval holds two hours. A `kvb-org-operator` commit row
chaining these steps runs only once every review is approved:
`operator.py run` skips it until then, and its hub card offers
`Approve n and run`.
No kvb-orchestrator tools, or the verify step refused: ask the calling
skill's approval question in chat.
+61 -2
View File
@@ -47,8 +47,11 @@ Args:
directory, command, reason and check in a label column (control
characters made visible; on a terminal values wrap under their
column, and unless NO_COLOR is set the separator is bold, labels dim,
the command bold cyan and preview commands yellow), then a preview
of what the command changes, its output indented, and asks [y]es /
the command bold cyan and preview commands yellow). A commit row
whose approval.py verify steps name a review the Agent Orchestrator
on their --port does not hold approved, or whose hub does not
answer, is skipped with the reason and stays open (unready()).
Otherwise a preview of what the command changes, its output indented, and asks [y]es /
[s]kip / [c]ancel / [d]iff / [q]uit; d shows the full diff. A repo
whose git config names filter commands gets no preview. c asks for a
reason (empty: back to the question), sets the row as shown stopped
@@ -152,6 +155,7 @@ import subprocess
import termios
import textwrap
import time
import urllib.request
from collections.abc import Callable
from pathlib import Path
from types import ModuleType
@@ -162,6 +166,11 @@ WATCH = SKILLS / "kvb-org-organize" / "scripts" / "watch.py"
QUEUE = SKILLS / "kvb-org-queue" / "scripts" / "queue.py"
RADIO = SKILLS / "kvb-org-radio" / "scripts" / "radio.py"
COUNCIL = SKILLS / "kvb-org-organize" / "scripts" / "council.py"
HUB_API = Path.home() / ".local" / "share" / "kvb-orchestrator" / "client" / "hub_api.py"
VERIFY_STEP = re.compile(r"approval\.py verify(?=[^;&|]*--port (?P<port>[0-9]+))(?=[^;&|]*--review (?P<review>[0-9a-f]{16}))")
HUB_SECONDS = 5
PORT_LIMIT = 65535
REVIEWS_SHOWN = 5
HOLD_KIND = "operator"
HOLD_SESSION = "Operator"
NOT_RUN = 75
@@ -961,6 +970,52 @@ def cmd_granted(rasci: ModuleType, args: argparse.Namespace) -> int:
return subprocess.run(args.argv, cwd=row["directory"], check=False).returncode
def unapproved(command: str) -> list[str] | None:
"""Returns:
The review ids the approval.py verify steps of command name whose
review the Agent Orchestrator on their --port does not hold approved,
in order; [] when every one is approved or command names none; None
when the hub does not answer, a --port lies above PORT_LIMIT (the
resolver would wrap it onto another port), or
the client's hub_api.py, whose
loopback opener sends no proxy and follows no redirect, is missing,
so the commit would fail at its verify.
"""
steps = list(VERIFY_STEP.finditer(command))
if not steps:
return []
if not HUB_API.is_file():
return None
api = module("kvb_operator_hub_api", HUB_API)
waiting = []
for step in steps:
port = int(step["port"])
if port > PORT_LIMIT:
return None
try:
status = api.call(urllib.request.Request(f"{api.base_url(port)}/api/reviews/{step['review']}", headers=api.GUARD), HUB_SECONDS).get("status")
except (OSError, ValueError, TypeError):
return None
if status != "approved":
waiting.append(step["review"])
return list(dict.fromkeys(waiting))
def unready(row: dict) -> str | None:
"""Returns:
Why run skips row for now: reviews its commit verifies that the
operator has not approved yet, or a hub that does not answer about
them; None when it may run.
"""
waiting = unapproved(row["command"])
if waiting is None:
return f"the hub does not answer about the reviews its commit verifies, or {HUB_API} is missing; start or install it, then run again"
if not waiting:
return None
more = " …" if len(waiting) > REVIEWS_SHOWN else ""
return f"{len(waiting)} reviews its commit verifies are not approved yet ({', '.join(waiting[:REVIEWS_SHOWN])}{more}); approve them in the hub, then run again"
def cmd_run(rasci: ModuleType, args: argparse.Namespace) -> int:
shell = os.environ.get("SHELL")
if not shell:
@@ -982,6 +1037,10 @@ def cmd_run(rasci: ModuleType, args: argparse.Namespace) -> int:
print(field("command", visible(row["command"], ""), "command"))
print(field("why", visible(row["why"] or "-", "")))
print(field("check", visible(check, "")), flush=True)
why = unready(row)
if why:
print(f"waits {name}: {why}; the row stays open")
continue
holdable = heavy_row(watch, cfg, row)
answer, reason = decide(row, holdable, typed)
if answer == "q" or (answer == "c" and reason is None):