feat(orchestrator): verify hub approvals from an MCP record

Sandboxed agents cannot reach the hub on localhost:8737 (refused directly, timeout through the sandbox proxy), so approval.py verify failed and every kvb-git-diff approval fell back to the chat question (Quality: 3 reviews on 2026-11-17). The MCP tools review_status and review_wait, which run outside the sandbox, now also return the review's passkey proof, the record the HTTP proof route already served; approval.py verify --record <file> reads that object instead of fetching it and checks the signature against the pinned approvers, the replay store and the local tree as before, so trust stays with the operator's passkey, not the transport. kvb-git-diff names the sandbox path.

🎯 Fix: 93 %
💥 Break: 3 %
💸 Tokens: 100 %
⏱️ Velocity: 100 %
🛡️ Security: 100 %
🏆 Score: 90
🚦 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-17 21:13:45 +00:00
1 parent d768851b8b
commit b95af2a8e0
6 files changed
+76 -26

No files matched your search

+18 -5
View File
@@ -5,10 +5,12 @@
<file>, written with mode 0600. Run it on the host, outside every
sandbox, e.g. --approvers ~/.config/kvb-orchestrator/approvers.json.
verify --port <port> --approvers <file> --replay <file> --review <id>
--gate <pass|fail>: run in the worktree right before the commit;
fetches the review's signature from the Agent Orchestrator on 127.0.0.1:<port>
and checks it against the repository, worktree, branch and the tree
git write-tree prints, as this process sees them.
--gate <pass|fail> [--record <file>]: run in the worktree right before
the commit; fetches the review's signature from the Agent Orchestrator
on 127.0.0.1:<port>, or reads it from <file>, the JSON object the MCP
tool review_wait or review_status answered, where a sandbox blocks
that port; checks it against the repository, worktree, branch and
the tree git write-tree prints, as this process sees them.
request --port <port> --title <subject> --page <file> --notes <file>
--gate <pass|fail> --score <line> --agent <name> [--rules <dir>]:
run in the worktree; asks the operator to approve the staged tree,
@@ -71,8 +73,18 @@ def fetch(port: int, path: str) -> dict:
return data
def recorded(path: Path, review_id: str) -> dict:
try:
data = json.loads(path.read_text(encoding="utf-8"))
except (OSError, ValueError, RecursionError) as error:
raise Refused(f"the record {path} cannot be read as JSON: {error}") from error
if not isinstance(data, dict) or data.get("id") != review_id:
raise Refused(f"the record {path} is not review {review_id}")
return data
def verify_commit(args: argparse.Namespace) -> str:
review = fetch(args.port, f"/api/reviews/{args.review}")
review = recorded(args.record, args.review) if args.record else fetch(args.port, f"/api/reviews/{args.review}")
if review.get("status") != "approved":
raise Refused(f"the review is {review.get('status')}, not approved")
item = staged(Path.cwd(), args.review)
@@ -140,6 +152,7 @@ def main() -> int:
verifying.add_argument("--replay", type=Path, required=True)
verifying.add_argument("--review", type=review_id, required=True)
verifying.add_argument("--gate", choices=("pass", "fail"), required=True)
verifying.add_argument("--record", type=Path)
requesting = commands.add_parser("request")
requesting.add_argument("--port", type=int, required=True)
for name in ("--title", "--score", "--agent"):
+1 -1
View File
@@ -55,7 +55,7 @@ class Mcp:
"score": text_property("The kvb-check-score line of the commit, one line."),
},
),
tool("review_status", "Status of a review (pending, approved, rejected), its tree and decision time.", {"id": review_id}),
tool("review_status", "Status of a review (pending, approved, rejected), its tree, decision time and the passkey proof that approval.py verify --record checks.", {"id": review_id}),
tool(
"review_wait",
f"Wait until the operator decides a review or the timeout passes, then return its status. "
+7 -3
View File
@@ -40,6 +40,10 @@ def state_of(review: dict) -> dict:
return {key: review[key] for key in STATE}
def proven(review: dict) -> dict:
return {**state_of(review), "proof": review.get("proof")}
def review_row(review: dict) -> dict:
created = datetime.datetime.fromisoformat(review["created"]).timestamp()
return {**{key: review[key] for key in LISTED}, "notes": review["notes"], "created_ts": created, "files": review.get("files")}
@@ -92,7 +96,7 @@ class Reviewing:
review = self.reviews.get(review_id)
if review is None:
raise Missing(review_id)
return {**state_of(review), "proof": review.get("proof")}
return proven(review)
def verdict(self, review_id: str, status: str, body: bytes) -> dict:
review = self.reviews.get(review_id)
@@ -111,13 +115,13 @@ class Reviewing:
def status(self, arguments: dict) -> dict:
expect(arguments, ("id",))
review_id = field(arguments, "id")
return state_of(found(self.reviews.get(review_id), review_id))
return proven(found(self.reviews.get(review_id), review_id))
def wait(self, arguments: dict) -> dict:
expect(arguments, ("id", "timeout_seconds"))
review_id = field(arguments, "id")
timeout = seconds(arguments, "timeout_seconds", WAIT_CAP)
return state_of(found(self.reviews.wait(review_id, timeout), review_id))
return proven(found(self.reviews.wait(review_id, timeout), review_id))
def pending(self, arguments: dict) -> dict:
expect(arguments, ())