feat(hub): every choice is one numbered dialog with an Other answer

Decisions, decision rows and hook questions render through one page-dialog.js: numbered options, check boxes for multi picks, the recommended option tagged, and a one-line Other answer; page-inbox.js and page-match.js drop their own option code. choosing.picks accepts one line of other text for every decision and decision row, not only hook questions, and approving checks a decision row's label through it and visible(). operator.py add --check decision now needs 2 to 4 --option values, as an AskUserQuestion offers (OPTION_FLOOR 2, OPTION_LIMIT 4 instead of 12), and refuses --option or --recommended on any other check; kvb-agent-optimize's graph.py passes two answers for each row it adds, and checks.md names the instruction-step answers Done= and Blocked=.

Stacked on questions (a6eee78); applied cleanly. ruff and node --check pass.

Tests: test_hub_decision_rows, test_hub_questions, test_operator, test_code_graph, test_hub_match and the Match waiting and question e2e updated. 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 over 21 files; index.html.j2 is not covered and was read by hand (dialog style rules and the page-dialog.js include).

🎯 Fix: 90 %
💥 Break: 5 %
💸 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 15:10:26 +00:00
1 parent a6eee78165
commit 88e53ac51f
22 files changed
+212 -181

No files matched your search

+8 -3
View File
@@ -508,13 +508,15 @@ def unit_active() -> bool:
return unit is not None and unit.returncode == 0
def add_row_once(slug: str, session: str, command: str, reason: str) -> None:
def add_row_once(slug: str, session: str, command: str, reason: str, options: list[str]) -> None:
"""Args:
slug: the kvb-org-operator row; added at most once per host, so a row
the operator cancelled is never reopened.
session: the hook payload's session id, forwarded as --session.
command: the row's command, shown only (--check decision).
reason: why the row exists.
options: the row's answers as "<label>=<consequence>", the
recommended one first.
"""
rows = state_dir() / "rows.json"
with locked_json(rows) as added:
@@ -526,6 +528,7 @@ def add_row_once(slug: str, session: str, command: str, reason: str) -> None:
result = run([
sys.executable, "-I", str(script), "add", slug, "--session", session,
"--dir", str(Path.home()), "--command", command, "--reason", reason, "--check", "decision",
*[part for option in options for part in ("--option", option)], "--recommended", options[0].partition("=")[0],
], timeout=ROW_TIMEOUT)
if result is not None and result.returncode == 0:
with locked_json(rows) as added:
@@ -537,7 +540,8 @@ def notices(session: str, settings: dict | None) -> list[str]:
if settings is None:
path = config_path()
messages.append(f"kvb-code-graph: nothing is indexed until {path} sets queue_file_threshold and queue_task (operator row {CONFIG_ROW})")
add_row_once(CONFIG_ROW, session, f"code {path}", "set queue_file_threshold and queue_task; the code graph hook indexes nothing until both are set")
add_row_once(CONFIG_ROW, session, f"code {path}", "set queue_file_threshold and queue_task; the code graph hook indexes nothing until both are set",
[f"Configure=set queue_file_threshold and queue_task in {path}; indexing starts", "Leave off=nothing is indexed"])
kind = daemon_kind(binary())
if kind == "permanent":
return messages
@@ -548,7 +552,8 @@ def notices(session: str, settings: dict | None) -> list[str]:
messages.append(NOTICE_PENDING if kind == "session-managed" else NOTICE_STUCK)
elif unit_installed():
messages.append(NOTICE)
add_row_once(DAEMON_ROW, session, ENABLE, "no permanent codebase-memory-mcp daemon: graphs lose their watch when the last session ends")
add_row_once(DAEMON_ROW, session, ENABLE, "no permanent codebase-memory-mcp daemon: graphs lose their watch when the last session ends",
["Enable=run the command; one permanent daemon keeps every graph watched", "Per session=graphs lose their watch when the last session ends"])
else:
messages.append(NOTICE_NO_UNIT)
return messages
+6 -5
View File
@@ -21,8 +21,9 @@ without a shell command takes `decision`, its question or instruction as
`--command`. Other kinds, relative paths and shell
metacharacters exit 2.
A `decision` row carries each answer as `--option "<label>=<what it
means>"` and your pick as `--recommended`; the hub shows them as buttons,
and the answer reaches the row's A as a passkey-signed post
`Decision <task>` / `Answer: <answer>` to check with `operator_message`
before acting.
A `decision` row carries two to four answers, as an `AskUserQuestion`
offers, each as `--option "<label>=<what it means>"`, and your pick as
`--recommended`; an instruction step offers `Done=` and `Blocked=`. The hub
shows them as a numbered dialog with a one-line Other answer, and the answer
reaches the row's A as a passkey-signed post `Decision <task>` /
`Answer: <answer>` to check with `operator_message` before acting.
+19 -18
View File
@@ -18,11 +18,12 @@ Args:
--check <kind>[:<arg>] [--option "<label>=<description>" ...]
[--recommended <label>] [--session <id>]: record a command, or update
the row of that slug, as queued with Operator R and the adder A, its
session id under `sessions`. --option, only with --check decision
and at most OPTION_LIMIT times, gives the answers the Agent
Orchestrator shows as buttons beside a free answer; the operator's
pick arrives as a signed post to the adder. --recommended names one
of them.
session id under `sessions`. --option, required with --check
decision OPTION_FLOOR to OPTION_LIMIT times and refused otherwise,
gives the answers the Agent Orchestrator shows as numbered rows
beside a free Other answer, as an AskUserQuestion does; the
operator's pick arrives as a signed post to the adder. --recommended
names one of them.
Kinds, never a shell command:
pushed:<repo dir> `git rev-list --count @{u}..HEAD` is 0 there;
no upstream counts as open.
@@ -173,7 +174,8 @@ INTERRUPTED = 130
SUDO = re.compile(r"\bsudo\b")
PREFIX = "operator/"
KINDS = ("pushed", "installed", "binary", "absent", "manual", "decision")
OPTION_LIMIT = 12
OPTION_FLOOR = 2
OPTION_LIMIT = 4
LABEL_LIMIT = 80
OPEN = ("queued", "blocked")
META = re.compile(r"[\s|&;()<>$`\\\"'*?\[\]{}~!#]")
@@ -313,19 +315,18 @@ def choices(raw: list[str] | None, recommended: str | None, check: str) -> list[
check: the row's --check kind.
Returns:
[{"label", "description"}] in the given order; [] without options.
Exits 2 when options come with another check than decision, exceed
OPTION_LIMIT, repeat a label, hold an empty, multi-line or longer
than LABEL_LIMIT label, or when --recommended names no option.
[{"label", "description"}] in the given order; [] for another check.
Exits 2 when options or a pick come with another check than
decision, when a decision holds fewer than OPTION_FLOOR or more than
OPTION_LIMIT options, repeats a label, holds an empty, multi-line or
longer than LABEL_LIMIT label, or when --recommended names no option.
"""
if not raw:
if recommended:
fail("--recommended needs --option")
return []
if check != "decision":
fail("--option is only for --check decision")
if len(raw) > OPTION_LIMIT:
fail(f"at most {OPTION_LIMIT} --option values")
if raw or recommended:
fail("--option and --recommended are only for --check decision")
return []
if not OPTION_FLOOR <= len(raw or []) <= OPTION_LIMIT:
fail(f"--check decision needs {OPTION_FLOOR} to {OPTION_LIMIT} --option values, as an AskUserQuestion offers")
options = []
for text in raw:
label, _, description = text.partition("=")
@@ -354,7 +355,7 @@ def cmd_add(rasci: ModuleType, args: argparse.Namespace) -> int:
fail(f"--command {visible(command, '')!r} holds a control character; record one line")
refused = None if args.check == "decision" else unrunnable(command, args.dir)
if refused:
fail(f"--command {command!r} {refused}; write the real command, or record the step with --check decision")
fail(f"--command {command!r} {refused}; write the real command, or ask the step as --check decision with {OPTION_FLOOR} to {OPTION_LIMIT} --option answers")
options = choices(args.option, args.recommended, args.check)
council = module("council", rasci.COUNCIL)
sid, _ = council.caller(args.session)