feat(hub): requirements 023 to 031 and line comments on grant-time code
023 box heads: one head band per box under its top border; in widget mode its controls join the widget title band. 024 Match card content: merge cards show their diff (the runner previews a review's tree against its worktree HEAD), every card carries legal and architecture scores, the null under command cards is gone. 025 Radio speak card: no hint text, a rounder flowing card, a MAYDAY toggle beside push to talk. 026 widget zoom: zoom a widget's content by keyboard and the context menu. 027 slash skill suggestions: every field that messages agents suggests skills after a slash, from a skills index the tree timer writes. 028 Resources accounts: an Accounts panel (provider, renewal, resets, usage and remaining, host-local, emails never in git) and panel checkboxes. 029 Controls layout: Rules and Groups pages laid out. 030 Yes/No answers as buttons, and nothing hides: rows the runner cannot run stay greyed with the reason. 031 mic in fields. Line comments (operator 2026-11-24): wherever code waits for a grant (Waits on Operator, the stream, the review overlay) selected lines or a right-clicked row take a comment that marks its lines and collects on the card; Deny opens with them as the reason and Call preselected, Grant sends them after the signed grant as one post. Requirement 003 decision 4 and its contract follow. Tests are written for every requirement and run once on this head. 🎯 Fix: 80 % 💥 Break: 20 % 💸 Tokens: – ⏱️ Velocity: – 🛡️ Security: ~95 % 🏆 Score: 61 🚦 Gate: ⛔ fix 80 % < 90, break 20 % > 5; security ~95 % < 100: ask the operator before the commit Created-with: https://s.veen.world/skills Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7d1926e3de
commit
2722cda1b5
120 files changed
+5372
-486
No files matched your search
@@ -4,9 +4,9 @@ import json
|
||||
import re
|
||||
import time
|
||||
|
||||
from .diffs import valid_diff
|
||||
from .diffs import stored_diff, valid_diff
|
||||
from .errors import Conflict, Missing, ToolError
|
||||
from .fields import bounded, decode, expect
|
||||
from .fields import bounded, decode, expect, field
|
||||
from .records import digest
|
||||
from .register import OPERATOR, REGISTER, operator_rows, read_register
|
||||
from .signed import signing
|
||||
@@ -15,12 +15,18 @@ OBJECT_ID = re.compile(r"[0-9a-f]{40}|[0-9a-f]{64}")
|
||||
ERROR_LIMIT = 500
|
||||
SHOWN = ("task", "command", "head", "base", "target", "diff")
|
||||
FAILED = ("task", "command", "head", "error")
|
||||
REVIEW_SHOWN = ("id", "head", "diff")
|
||||
REVIEW_FAILED = ("id", "head", "error")
|
||||
|
||||
|
||||
def card_id(task: str) -> str:
|
||||
return f"operator:{task}"
|
||||
|
||||
|
||||
def review_card(review_id: str) -> str:
|
||||
return f"review:{review_id}"
|
||||
|
||||
|
||||
def object_id(payload: dict, name: str, empty: bool) -> str:
|
||||
value = payload[name]
|
||||
if not isinstance(value, str) or not (OBJECT_ID.fullmatch(value) or (empty and value == "")):
|
||||
@@ -51,22 +57,69 @@ class Previewing:
|
||||
found = self.merge_previews.get(card_id(row["task"]))
|
||||
return found if found is not None and found["command"] == row["command"] else None
|
||||
|
||||
def shipped(self, review_id: str) -> bool:
|
||||
try:
|
||||
return bool(stored_diff(self.reviews.pages, "review", review_id)["diff"])
|
||||
except Missing:
|
||||
return False
|
||||
|
||||
def review_preview(self, review_id: str) -> dict | None:
|
||||
"""Returns:
|
||||
The runner's diff of a review that shipped none, its staged tree
|
||||
against its worktree's HEAD: {head, diff} or {head, error}, with
|
||||
moved, the HEAD it saw later, once HEAD moved; None before any.
|
||||
"""
|
||||
return None if self.shipped(review_id) else self.merge_previews.get(review_card(review_id))
|
||||
|
||||
def preview_rows(self) -> dict:
|
||||
"""Returns:
|
||||
{"rows"}: every open operator row in an absolute directory with
|
||||
the HEAD of the preview the hub holds, None for none, for the
|
||||
runner to preview the git merges among them.
|
||||
{"rows", "reviews"}: every open operator row in an absolute
|
||||
directory with the HEAD of the preview the hub holds, None for
|
||||
none, for the runner to preview the git merges among them; and
|
||||
every pending review in an absolute worktree that shipped no
|
||||
diff, with its tree and the HEAD the hub last saw, for the
|
||||
runner to diff the tree against HEAD.
|
||||
"""
|
||||
rows = [row for row in self.open_rows() if row["directory"].startswith("/")]
|
||||
return {"rows": [{"task": row["task"], "command": row["command"], "directory": row["directory"], "head": (self.preview_of(row) or {}).get("head")} for row in rows]}
|
||||
reviews = [review for review in self.reviews.pending() if review["worktree"].startswith("/") and not self.shipped(review["id"])]
|
||||
seen = {review["id"]: self.merge_previews.get(review_card(review["id"])) or {} for review in reviews}
|
||||
return {
|
||||
"rows": [{"task": row["task"], "command": row["command"], "directory": row["directory"], "head": (self.preview_of(row) or {}).get("head")} for row in rows],
|
||||
"reviews": [{"id": review["id"], "worktree": review["worktree"], "tree": review["tree"], "head": seen[review["id"]].get("moved") or seen[review["id"]].get("head")} for review in reviews],
|
||||
}
|
||||
|
||||
def record_review_preview(self, payload: dict) -> dict:
|
||||
expect(payload, REVIEW_FAILED if "error" in payload else REVIEW_SHOWN)
|
||||
review_id = field(payload, "id")
|
||||
review = self.reviews.get(review_id)
|
||||
if review is None or review["status"] != "pending":
|
||||
raise Missing(review_id)
|
||||
head = object_id(payload, "head", "error" in payload)
|
||||
key = review_card(review_id)
|
||||
found = self.merge_previews.get(key)
|
||||
if found is not None and "diff" in found and found["head"] != head:
|
||||
self.merge_previews.change(key, {"moved": head})
|
||||
return {"id": key, "head": head}
|
||||
record = {"head": head, "taken": time.time()}
|
||||
if "error" in payload:
|
||||
record["error"] = bounded(payload, "error", ERROR_LIMIT)
|
||||
else:
|
||||
record["diff"] = valid_diff(payload["diff"])
|
||||
self.merge_previews.remove(key)
|
||||
self.merge_previews.insert(key, record)
|
||||
return {"id": key, "head": head}
|
||||
|
||||
def record_preview(self, body: bytes) -> dict:
|
||||
"""Args:
|
||||
body: from the runner, {task, command, head, base, target, diff}
|
||||
for a git merge row, or {task, command, head, error} when it
|
||||
could not preview it; head is empty when HEAD is unreadable.
|
||||
could not preview it; {id, head, diff} or {id, head, error}
|
||||
for a review that shipped no diff; head is empty when HEAD is
|
||||
unreadable.
|
||||
"""
|
||||
payload = decode(body)
|
||||
if "id" in payload:
|
||||
return self.record_review_preview(payload)
|
||||
expect(payload, FAILED if "error" in payload else SHOWN)
|
||||
task = payload["task"]
|
||||
if not isinstance(task, str) or not task.startswith(OPERATOR) or not signing.TASK.fullmatch(task):
|
||||
|
||||
Reference in new issue
Block a user