Files
skills/orchestrator/templates/page-rule-request.js
T
Kevin Veen-BirkenbachandClaude Opus 5.5 14bb4f38df feat(hub): Select collects option picks, rules and red-gate reviews too
In Select mode every grant button and every option pick toggles its item into the selection (operator 2026-11-20): a decision or decision row keeps the option picked for it and picking it again takes it out; a rule request or red-gate review joins the selection as a solo item. Grant n signs every batchable item under one passkey signature, then asks one more signature per rule and red-gate review, one after the other, since the server accepts neither inside a batch; the sheet's note counts them. Requirement 020 decision 3 and its acceptance criteria follow.

Stacked on allow (aa4a337). The one conflict in page-inbox.js keeps the ux reason chips in the deny sheet next to the new solo note. node --check and ruff pass.

Tests: test_hub_grant_mode (pick collects with its label, rule and red-gate review get their own signature after the batch). 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 5 files covered. The server checks are unchanged.

🎯 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>
2026-11-22 15:55:43 +00:00

47 lines
2.2 KiB
JavaScript

const COUNTED = {ask: "asks", review: "reviews", decision: "decisions"};
function ruleRequestBody(item) {
const rule = item.rule;
const dry = item.dry_run;
const pairs = [["Kind", RULE_KINDS[rule.kind]], rule.kind === "ask" ? ["Tool (glob)", rule.tool] : null, ["Pattern (glob)", rule.pattern], rule.kind === "decision" ? null : ["Directory (glob)", rule.scope], ["Expires on", absolute.format(stampOf(rule.expires))]];
return h("div", {class: "rule-request"},
item.detail ? h("p", {class: "text"}, revealed(item.detail)) : null,
meta(pairs.filter(Boolean)),
h("p", {class: "muted dry-run-count"}, "Dry run: the rule would have granted ", h("strong", {}, `${dry.matched} of ${dry.total}`), ` ${COUNTED[rule.kind]} from the last ${dry.days} days.`),
h("p", {class: "muted"}, RULE_HINTS[rule.kind]));
}
/**
* @param {Object} item a rule request.
* @param {string} label the toast and passkey prompt label.
* @returns {Promise<Object|null>} the accept body with the rule and its passkey assertion, null when the server refused or the operator cancelled.
*/
async function signRule(item, label) {
const prepared = await sendJson(`/api/rule-requests/${encodeURIComponent(item.id)}/sign`, {});
if (!prepared.ok || !prepared.data) {
if (!closeGone(prepared, [keyOf(item)], label)) {
toast(`${label}: not possible`, fail(prepared), false);
}
return null;
}
const signed = await assertion(prepared.data, label);
return signed ? {rule: prepared.data.payload, assertion: signed} : null;
}
/**
* @param {Object} item a rule request.
* @returns {Promise<boolean>} whether the rule was created.
*/
async function acceptRule(item) {
const label = `Rule: ${short(item.title)}`;
ui.busy = true;
const body = await signRule(item, label);
const result = body ? await sendJson(`/api/rule-requests/${encodeURIComponent(item.id)}/accept`, body) : null;
ui.busy = false;
if (result && !closeGone(result, [keyOf(item)], label)) {
toast(result.ok ? `Created: ${short(item.title)}` : `${label}: not created`, result.ok ? [] : fail(result), result.ok);
}
await load();
return Boolean(result && result.ok);
}