fix(hub): the grant label helper no longer redeclares labelOf, and the grant-mode probe escapes its inner templates

14bb4f3 added function labelOf(item) to page-grant.js beside page-dom.js's labelOf(key), the agent name every other page file calls. The assembled page script then stopped parsing ('Identifier labelOf has already been declared'), so the hub page could not load, and test_page_scope, test_hub_page, test_page_reveal and the decision-row, inbox-gone and operator-task harnesses failed on it. The item helper is now grantLabel(item); its 5 callers in page-inbox.js follow, page-dom.js keeps labelOf.

The same commit put two template literals (b${proofs.length} and ${label}: ) inside test_hub_grant_mode.py's probe, itself a template literal, so they closed it early; both are escaped now.

Checks: the assembled page parses with no name declared twice (test_page_scope's own parse_error and clashes helpers, called inline), and node --check passes the probe. No test ran: the full suite runs again on master after the four fix bundles (operator order).

Security: MEDUSA over the 7 files of the four fix bundles on master: 100, all covered, 0 open findings.

🎯 Fix: 90 %
💥 Break: 2 %
💸 Tokens: –
⏱️ Velocity: –
🛡️ Security: 100 %
🏆 Score: 88
🚦 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 23:28:53 +00:00
1 parent a4f7017691
commit 9b8e2a7d71
3 files changed
+7 -7

No files matched your search

+1 -1
View File
@@ -20,7 +20,7 @@
* @param {Object} item a batchable inbox item. * @param {Object} item a batchable inbox item.
* @returns {string} the label its grant carries: the picked option, else a decision's recommendation, else "". * @returns {string} the label its grant carries: the picked option, else a decision's recommendation, else "".
*/ */
function labelOf(item) { function grantLabel(item) {
const label = chosenLabel(item); const label = chosenLabel(item);
if (label !== undefined) { if (label !== undefined) {
return label; return label;
+4 -4
View File
@@ -138,13 +138,13 @@
*/ */
const choiceOf = (item, after) => { const choiceOf = (item, after) => {
if (item.kind === "decision") { if (item.kind === "decision") {
return choiceDialog(item, {pick: (label) => { after(); chooseOne(item, label); }, toggled: new Set(), chosen: ui.selected.has(keyOf(item)) ? labelOf(item) : "", locked: item.held, hint: signsFor(item), group: "", other: OTHER_PROMPT}); return choiceDialog(item, {pick: (label) => { after(); chooseOne(item, label); }, toggled: new Set(), chosen: ui.selected.has(keyOf(item)) ? grantLabel(item) : "", locked: item.held, hint: signsFor(item), group: "", other: OTHER_PROMPT});
} }
if (item.kind === "ask") { if (item.kind === "ask") {
return choiceDialog(askDialog(item.id), {pick: (answer, typed) => { after(); answerAsk(item, answer, typed); }, toggled: new Set(), chosen: ui.selected.has(keyOf(item)) ? ALLOW : "", locked: item.held, hint: `your passkey signs it, the answer goes to ${item.to || "its session"}`, group: "", other: TELL}); return choiceDialog(askDialog(item.id), {pick: (answer, typed) => { after(); answerAsk(item, answer, typed); }, toggled: new Set(), chosen: ui.selected.has(keyOf(item)) ? ALLOW : "", locked: item.held, hint: `your passkey signs it, the answer goes to ${item.to || "its session"}`, group: "", other: TELL});
} }
const told = answerOf(item); const told = answerOf(item);
const shown = told || (ui.selected.has(keyOf(item)) ? labelOf(item) : ""); const shown = told || (ui.selected.has(keyOf(item)) ? grantLabel(item) : "");
return asked(item) ? [answerTo(item), choiceDialog(item, {pick: (label) => { after(); answerPick(item, label); }, toggled: new Set(), chosen: shown, locked: item.held || Boolean(told), hint: signsFor(item), group: "", other: OTHER_PROMPT})] : null; return asked(item) ? [answerTo(item), choiceDialog(item, {pick: (label) => { after(); answerPick(item, label); }, toggled: new Set(), chosen: shown, locked: item.held || Boolean(told), hint: signsFor(item), group: "", other: OTHER_PROMPT})] : null;
}; };
@@ -186,7 +186,7 @@
return; return;
} }
const rows = [...usable, ...alone].map((item) => h("li", {}, const rows = [...usable, ...alone].map((item) => h("li", {},
h("div", {class: "row"}, pill(ITEM_LABELS[item.kind], KIND_TONES[item.kind]), !deny && labelOf(item) ? h("span", {class: "muted"}, revealed(`→ ${shownPick(labelOf(item))}`)) : null), h("div", {class: "row"}, pill(ITEM_LABELS[item.kind], KIND_TONES[item.kind]), !deny && grantLabel(item) ? h("span", {class: "muted"}, revealed(`→ ${shownPick(grantLabel(item))}`)) : null),
h("strong", {}, revealed(item.title)), h("strong", {}, revealed(item.title)),
item.kind === "operator" ? h("div", {class: "command"}, h("code", {}, revealed(item.command))) : null, item.kind === "operator" ? h("div", {class: "command"}, h("code", {}, revealed(item.command))) : null,
item.kind === "operator" ? h("span", {class: "muted"}, revealed(`in ${item.directory}`)) : null, item.kind === "operator" ? h("span", {class: "muted"}, revealed(`in ${item.directory}`)) : null,
@@ -201,7 +201,7 @@
} }
} }
if (usable.length) { if (usable.length) {
await submit(usable.map((item) => (deny ? denialOf(item, reason.value) : entryOf(item, "approve", labelOf(item)))), `${label}: ${usable.length} entries`); await submit(usable.map((item) => (deny ? denialOf(item, reason.value) : entryOf(item, "approve", grantLabel(item)))), `${label}: ${usable.length} entries`);
} }
}); });
openSheet(label, [h("p", {class: "muted"}, deny ? DENY_NOTE : grantNote(alone.length, usable.length)), h("ul", {class: "mini"}, rows), ...(deny ? [reasonChips(reason), h("label", {class: "deny-reason"}, "Reason (optional, every requester reads it)", reason)] : []), openSheet(label, [h("p", {class: "muted"}, deny ? DENY_NOTE : grantNote(alone.length, usable.length)), h("ul", {class: "mini"}, rows), ...(deny ? [reasonChips(reason), h("label", {class: "deny-reason"}, "Reason (optional, every requester reads it)", reason)] : []),
+2 -2
View File
@@ -72,7 +72,7 @@ let renders = 0;
let streams = 0; let streams = 0;
let signing = false; let signing = false;
proofFor = async (entries) => { proofs.push(entries.map((entry) => entry.kind + ":" + entry.id)); sent.push(entries.map((entry) => entry.label)); return signing ? {proof: "p"} : null; }; proofFor = async (entries) => { proofs.push(entries.map((entry) => entry.kind + ":" + entry.id)); sent.push(entries.map((entry) => entry.label)); return signing ? {proof: "p"} : null; };
sendJson = async () => ({ok: true, data: {id: `b${proofs.length}`, due: 0}}); sendJson = async () => ({ok: true, data: {id: \`b\${proofs.length}\`, due: 0}});
undoToast = () => {}; undoToast = () => {};
acceptRule = async (item) => { accepts.push(item.id); return true; }; acceptRule = async (item) => { accepts.push(item.id); return true; };
openSheet = (title, body) => { sheets.push(body); }; openSheet = (title, body) => { sheets.push(body); };
@@ -83,7 +83,7 @@ toast = () => ({remove() {}});
const results = {}; const results = {};
const take = () => ({selected: [...ui.selected].sort(), proofs: proofs.splice(0), labels: sent.splice(0), accepts: accepts.splice(0), renders, streams}); const take = () => ({selected: [...ui.selected].sort(), proofs: proofs.splice(0), labels: sent.splice(0), accepts: accepts.splice(0), renders, streams});
const dialogOf = (item) => { const made = choiceOf(item, () => {}); return Array.isArray(made) ? made[1] : made; }; const dialogOf = (item) => { const made = choiceOf(item, () => {}); return Array.isArray(made) ? made[1] : made; };
const option = (item, label) => buttons(dialogOf(item)).find((button) => (button.getAttribute("title") || "").startsWith(`${label}: `)); const option = (item, label) => buttons(dialogOf(item)).find((button) => (button.getAttribute("title") || "").startsWith(\`\${label}: \`));
const pressedOptions = (item) => buttons(dialogOf(item)).filter((button) => button.getAttribute("aria-pressed") === "true").map((button) => button.getAttribute("title").split(": ")[0]); const pressedOptions = (item) => buttons(dialogOf(item)).filter((button) => button.getAttribute("aria-pressed") === "true").map((button) => button.getAttribute("title").split(": ")[0]);
const press = (item) => { const press = (item) => {
const first = actionsFor(item)[0]; const first = actionsFor(item)[0];