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

+23 -2
View File
@@ -12,11 +12,13 @@ from pathlib import Path
RP_ID = "localhost"
VERSION = 1
LIFETIME = 900
REVIEW_LIFETIME = 7200
RULE_LIFETIME = 366 * 86400
ALGORITHMS = {-7: "ES256", -8: "EdDSA", -257: "RS256"}
HASH = re.compile(r"[0-9a-f]{64}")
NONCE = re.compile(r"[0-9a-f]{32}")
ID = re.compile(r"[0-9a-f]{16}")
VERIFY_STEP = re.compile(r"approval\.py verify(?=[^;&|]*--port (?P<port>[0-9]+))(?=[^;&|]*--review (?P<review>[0-9a-f]{16}))")
CHAINED = re.compile(r"[;&|`$<>()\n\r]")
OFFICE = re.compile(r"chair|[a-z0-9][a-z0-9._-]{0,63}/[a-z0-9][a-z0-9._-]{0,63}")
SESSION = re.compile(r"(?!-)[A-Za-z0-9_-]{1,128}")
@@ -110,6 +112,15 @@ def review_item(review_id: str, repo: str, worktree: str, branch: str, tree: str
return {"kind": "review", "id": review_id, "repo": repo, "worktree": worktree, "branch": branch, "tree": tree}
def verified_reviews(command: str) -> list[str]:
"""Returns:
The review ids the approval.py verify steps of an operator command
check, in order and each once: a commit row whose run needs them
approved first.
"""
return list(dict.fromkeys(step["review"] for step in VERIFY_STEP.finditer(command)))
def operator_item(task: str, command: str, directory: str) -> dict:
return {"kind": "operator", "id": task, "command": command, "directory": directory}
@@ -755,7 +766,17 @@ def expiry(value: object, now: float, cap: int) -> int:
return value
def checked_approval(payload: object, now: float) -> dict:
def lifetime(items: list[dict]) -> int:
"""Returns:
How long an approval of items may live: REVIEW_LIFETIME when every
item is a review, whose approval names one exact tree and is used
once at the commit, so a commit row may run well after the clicks;
LIFETIME for any other mix.
"""
return REVIEW_LIFETIME if items and all(item.get("kind") == "review" for item in items) else LIFETIME
def checked_approval(payload: object, now: float, cap: int) -> dict:
if not isinstance(payload, dict) or set(payload) != APPROVAL_KEYS or payload["v"] != VERSION or payload["kind"] != "approve":
raise Refused("the payload is no approval")
items = payload["items"]
@@ -763,7 +784,7 @@ def checked_approval(payload: object, now: float) -> dict:
raise Refused("the approval lists no item hashes")
if not isinstance(payload["nonce"], str) or not NONCE.fullmatch(payload["nonce"]):
raise Refused("the approval holds no nonce")
expiry(payload["expires"], now, LIFETIME)
expiry(payload["expires"], now, cap)
return payload
+2 -1
View File
@@ -20,6 +20,7 @@ from signing import (
checked_approval,
checked_rule,
item_hash,
lifetime,
load_pinned,
rule_allows,
)
@@ -301,7 +302,7 @@ def check(proof: object, item: dict, gate: str, trust: Trust, now: float) -> Non
if not rule_allows(payload, item, gate, now):
raise Refused("the signed rule does not match this item")
return
checked_approval(payload, now)
checked_approval(payload, now, lifetime([item]))
count = verify_assertion(proof["assertion"], payload, pinned(trust.approvers), trust.origin)
digest = item_hash(item)
if digest not in payload["items"]: