fix(match): release card repairs, hotfix 092

An Ask accepted while pending expired before the release, and the hub
refused all 11 decisions with a raw 409. The release card now checks
every row first: an unreleasable row turns red with its reason, Release
names the rows on click, and a red Cancel drops them and their cards.
A hub refusal names the card's title and marks its row. The verdict pill
opens a menu (options, Accept, Reject, Back to the stack, impossible
entries greyed with their reason). Back to the stack puts the card
behind the release card, last in the deck. W no longer puts a skipped
card in front of the release card. An expired decision no longer claims
its tool call went back to the terminal.

🎯 Fix: 85 %
💥 Break: 8 %
💸 Tokens: -
⏱️ Velocity: -
🛡️ Security: 100 %
🏆 Score: 78
🚦 Gate: ⛔ fix 85 % < 90, break 8 % > 5 (E2E rerun after 085 to 094, operator word 2026-11-27)

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-27 20:53:57 +00:00
1 parent ca97776b4d
commit b15dd5e414
11 files changed
+301 -49

No files matched your search

+7 -3
View File
@@ -20,7 +20,10 @@ from .tree import inside
OPERATOR = "operator/" OPERATOR = "operator/"
WAITING = ("ask", "decision", "rule") WAITING = ("ask", "decision", "rule")
EXPIRED = "expired" EXPIRED = "expired"
EXPIRED_REASON = f"{LAPSED.capitalize()}: its tool call went back to the terminal, only Reject is left" EXPIRED_REASONS = {
"ask": f"{LAPSED.capitalize()}: its tool call went back to the terminal, only Reject is left",
"decision": f"{LAPSED.capitalize()}: its agent stopped waiting for the answer, only Reject is left",
}
def expired_card(card: dict, expires: float) -> dict: def expired_card(card: dict, expires: float) -> dict:
@@ -29,9 +32,10 @@ def expired_card(card: dict, expires: float) -> dict:
expires: when it expired, in epoch seconds. expires: when it expired, in epoch seconds.
Returns: Returns:
The card greyed with blocked_kind EXPIRED and its expires time. The card greyed with blocked_kind EXPIRED, the EXPIRED_REASONS line of
its kind and its expires time.
""" """
return {**card, "blocked": EXPIRED_REASON, "blocked_kind": EXPIRED, "expires": expires} return {**card, "blocked": EXPIRED_REASONS[card["kind"]], "blocked_kind": EXPIRED, "expires": expires}
def repository_of(common_dir: str) -> str: def repository_of(common_dir: str) -> str:
+1 -1
View File
@@ -37,7 +37,7 @@
const MOVE = 2000; const MOVE = 2000;
const RELAYOUT = 60000; const RELAYOUT = 60000;
const SESSION_ID = /^[A-Za-z0-9_-]{1,128}$/; const SESSION_ID = /^[A-Za-z0-9_-]{1,128}$/;
const STORE = {views: "kvb-orchestrator.views", status: "kvb-orchestrator.status", comments: "kvb-orchestrator.match-comments", peeks: "kvb-orchestrator.match-peeks", wide: "kvb-orchestrator.match-wide"}; const STORE = {views: "kvb-orchestrator.views", status: "kvb-orchestrator.status", comments: "kvb-orchestrator.match-comments", peeks: "kvb-orchestrator.match-peeks", wide: "kvb-orchestrator.match-wide", dropped: "kvb-orchestrator.match-dropped"};
const PRESENCE = { const PRESENCE = {
working: ["Working", "bi-gear-fill", "info"], working: ["Working", "bi-gear-fill", "info"],
alive: ["Alive", "bi-heart-pulse-fill", "ok"], alive: ["Alive", "bi-heart-pulse-fill", "ok"],
+24 -3
View File
@@ -27,23 +27,44 @@
} }
const sending = new Set(); const sending = new Set();
const refusedIds = new Map();
async function submit(entries, label) { /**
* @param {object} result a hub answer; a 409 carries {id, status} of the item it refused.
* @param {string} label the batch's label.
* @param {Map<string, string>|undefined} names item id to the title the toast shows instead of the id.
* @returns {boolean} whether it was such a refusal: kept in refusedIds and toasted by title.
*/
function namedRefusal(result, label, names) {
const id = result.status === 409 && result.data && typeof result.data.id === "string" ? result.data.id : "";
if (!id) {
return false;
}
const status = typeof result.data.status === "string" ? result.data.status : "refused";
refusedIds.set(id, status);
toast(`${label}: not possible`, [`${(names && names.get(id)) || id}: ${status}. Change or drop its row, then release again.`], false);
return true;
}
async function submit(entries, label, names) {
const keys = entries.map(keyOf); const keys = entries.map(keyOf);
keys.forEach((key) => sending.add(key)); keys.forEach((key) => sending.add(key));
drawInbox(); drawInbox();
try { try {
return await sendBatch(entries, label, keys); return await sendBatch(entries, label, keys, names);
} finally { } finally {
keys.forEach((key) => sending.delete(key)); keys.forEach((key) => sending.delete(key));
drawInbox(); drawInbox();
} }
} }
async function sendBatch(entries, label, keys) { async function sendBatch(entries, label, keys, names) {
ui.busy = true; ui.busy = true;
let missing = null; let missing = null;
const gone = (result) => { const gone = (result) => {
if (namedRefusal(result, label, names)) {
return true;
}
if (keys.length > 1 && result.status === 404) { if (keys.length > 1 && result.status === 404) {
missing = result; missing = result;
return true; return true;
+139 -31
View File
@@ -8,6 +8,7 @@
const FEEDBACK_LIMIT = 2000; const FEEDBACK_LIMIT = 2000;
const FLY_MS = 400; const FLY_MS = 400;
const CONFETTI = 28; const CONFETTI = 28;
const DROPS_KEPT = 200;
const COMMENTS_KEPT = 5; const COMMENTS_KEPT = 5;
const PATTERNS = ["dots", "stripes", "waves", "grid", "rings"]; const PATTERNS = ["dots", "stripes", "waves", "grid", "rings"];
const RELEASE = "release"; const RELEASE = "release";
@@ -55,7 +56,8 @@
if (response.ok) { if (response.ok) {
const data = await response.json(); const data = await response.json();
if (epoch === matchView.epoch) { if (epoch === matchView.epoch) {
matchView.cards = Array.isArray(data.cards) ? data.cards : []; const dropped = new Set(droppedKeys());
matchView.cards = (Array.isArray(data.cards) ? data.cards : []).filter((card) => !dropped.has(cardKey(card)));
} }
} }
} catch { } catch {
@@ -149,19 +151,20 @@
matchView.order = [id, ...matchView.order.filter((one) => one !== id)]; matchView.order = [id, ...matchView.order.filter((one) => one !== id)];
}; };
const toBack = (id) => { const toBack = (id) => {
const rest = matchView.order.filter((one) => one !== id); matchView.order = [...matchView.order.filter((one) => one !== id), id];
const release = id === RELEASE ? -1 : rest.indexOf(RELEASE);
matchView.order = release < 0 ? [...rest, id] : [...rest.slice(0, release), id, ...rest.slice(release)];
}; };
/** /**
* @param {string[]} order card ids and RELEASE. * @param {string[]} kept the order so far: card ids and RELEASE.
* @param {string[]} fresh the ids of the cards new to the stack.
* @param {Set<string>} open the ids of the undecided cards. * @param {Set<string>} open the ids of the undecided cards.
* @returns {string[]} order with the release card last, unless it is the front card the operator sees now. * @returns {string[]} kept with the fresh cards queued before the release card, or behind it while it is the front
* card the operator sees now; the release card keeps its place in the round.
*/ */
function releaseLast(order, open) { function releaseLast(kept, fresh, open) {
const front = order.find((id) => id === RELEASE || open.has(id)); const at = kept.indexOf(RELEASE);
return front === RELEASE || !order.includes(RELEASE) ? order : [...order.filter((id) => id !== RELEASE), RELEASE]; const front = kept.find((id) => id === RELEASE || open.has(id));
return at < 0 || front === RELEASE ? [...kept, ...fresh] : [...kept.slice(0, at), ...fresh, ...kept.slice(at)];
} }
/** /**
@@ -192,7 +195,7 @@
const kept = matchView.order.filter((id) => ids.has(id) || id === RELEASE); const kept = matchView.order.filter((id) => ids.has(id) || id === RELEASE);
const fresh = cards.filter((card) => !kept.includes(card.id)).sort((a, b) => Number(Boolean(a.blocked)) - Number(Boolean(b.blocked)) || Number(a.stale) - Number(b.stale) || (a.created_ts || 0) - (b.created_ts || 0)); const fresh = cards.filter((card) => !kept.includes(card.id)).sort((a, b) => Number(Boolean(a.blocked)) - Number(Boolean(b.blocked)) || Number(a.stale) - Number(b.stale) || (a.created_ts || 0) - (b.created_ts || 0));
const open = new Set(cards.filter((card) => !decisionOf(card)).map((card) => card.id)); const open = new Set(cards.filter((card) => !decisionOf(card)).map((card) => card.id));
matchView.order = releaseLast([...kept, ...fresh.map((card) => card.id)], open); matchView.order = releaseLast(kept, fresh.map((card) => card.id), open);
const byId = new Map(cards.map((card) => [card.id, card])); const byId = new Map(cards.map((card) => [card.id, card]));
return matchView.order.filter((id) => id !== RELEASE).map((id) => byId.get(id)); return matchView.order.filter((id) => id !== RELEASE).map((id) => byId.get(id));
} }
@@ -595,6 +598,7 @@
function decide(card, verdict, feedback, label) { function decide(card, verdict, feedback, label) {
flyOff(verdict, () => { flyOff(verdict, () => {
logStep(card.id); logStep(card.id);
refusedIds.delete(card.ref);
matchView.decisions.set(card.id, {verdict, feedback, label, hash: card.hash, card, risk: false}); matchView.decisions.set(card.id, {verdict, feedback, label, hash: card.hash, card, risk: false});
drawMatch(true); drawMatch(true);
}); });
@@ -793,37 +797,91 @@
const risky = (card, decision) => card.kind === "commit" && decision.verdict === "accept" && card.gate !== "pass"; const risky = (card, decision) => card.kind === "commit" && decision.verdict === "accept" && card.gate !== "pass";
const decisionWords = (count) => (count === 1 ? "1 decision" : `${count} decisions`); const decisionWords = (count) => (count === 1 ? "1 decision" : `${count} decisions`);
/**
* @param {object} card a card on the release card.
* @param {object} decision its decision.
* @returns {string} why the release cannot carry the row now, "" when it can: the hub refused it last time, it was
* accepted and expired since, or it is blocked; a reject of an expired card still goes by radio.
*/
function unreleasable(card, decision) {
if (card.withdrawn) {
return "";
}
const refused = refusedIds.get(card.ref);
if (refused) {
return `the hub refused it: ${refused}; reject or drop it`;
}
const lapsed = lapsedCard(card);
if (lapsed && decision.verdict === "accept") {
return `${expiredWords(card)}: can no longer be granted; reject or drop it`;
}
return card.blocked && !(lapsed && decision.verdict === "reject") ? `not possible now: ${card.blocked}; drop it or send it back to the stack` : "";
}
/** /**
* @param {Array<Array>} picked [card, decision] pairs from decided(). * @param {Array<Array>} picked [card, decision] pairs from decided().
* @returns {object} lone: risk-accepted red-gate commits, each signed on its own first; rest: every other decision * @returns {object} lone: risk-accepted red-gate commits, each signed on its own first; rest: every other decision
* signed together; gone: withdrawn rejects, sent by radio only; held: red-gate commits whose risk is not accepted, * signed together; gone: withdrawn rejects, sent by radio only; held: red-gate commits whose risk is not accepted,
* which block the release until each is risk-accepted or sent back to the stack. * which block the release until each is risk-accepted or sent back to the stack; bad: rows unreleasable() names,
* which block the release until each is changed or dropped.
*/ */
function releasePlan(picked) { function releasePlan(picked) {
const signed = picked.filter(([card]) => !card.withdrawn); const signed = picked.filter(([card]) => !card.withdrawn);
const bad = signed.filter(([card, decision]) => unreleasable(card, decision));
const good = signed.filter((pair) => !bad.includes(pair));
return { return {
lone: signed.filter(([card, decision]) => risky(card, decision) && decision.risk), lone: good.filter(([card, decision]) => risky(card, decision) && decision.risk),
rest: signed.filter(([card, decision]) => !risky(card, decision)), rest: good.filter(([card, decision]) => !risky(card, decision)),
gone: picked.filter(([card]) => card.withdrawn), gone: picked.filter(([card]) => card.withdrawn),
held: signed.filter(([card, decision]) => risky(card, decision) && !decision.risk), held: good.filter(([card, decision]) => risky(card, decision) && !decision.risk),
bad,
}; };
} }
const droppedKeys = () => {
const kept = stored(STORE.dropped, []);
return Array.isArray(kept) ? kept.filter((key) => typeof key === "string") : [];
};
/**
* @param {Array<Array>} bad the unreleasable [card, decision] pairs: their decisions go, their cards leave the deck
* in this browser for good, the last DROPS_KEPT dropped cards remembered.
*/
function dropUnreleasable(bad) {
const keys = bad.map(([card]) => cardKey(card));
bad.forEach(([card]) => {
matchView.decisions.delete(card.id);
refusedIds.delete(card.ref);
});
keep(STORE.dropped, [...keys, ...droppedKeys().filter((key) => !keys.includes(key))].slice(0, DROPS_KEPT));
const gone = new Set(bad.map(([card]) => card.id));
matchView.cards = matchView.cards.filter((card) => !gone.has(card.id));
matchView.order = matchView.order.filter((id) => !gone.has(id));
matchView.history = [];
toast(`Dropped ${decisionWords(bad.length)}`, bad.map(([card]) => card.title), true);
drawMatch(true);
}
async function releaseMatch(cards) { async function releaseMatch(cards) {
const plan = releasePlan(decided(cards)); const plan = releasePlan(decided(cards));
if (plan.bad.length) {
toast("Release: not possible", plan.bad.map(([card, decision]) => `${card.title}: ${unreleasable(card, decision)}`), false);
return;
}
if (matchView.releasing || plan.held.length || !(plan.lone.length + plan.rest.length + plan.gone.length)) { if (matchView.releasing || plan.held.length || !(plan.lone.length + plan.rest.length + plan.gone.length)) {
return; return;
} }
matchView.releasing = true; matchView.releasing = true;
const names = new Map([...plan.lone, ...plan.rest].map(([card]) => [card.ref, card.title]));
const done = []; const done = [];
try { try {
for (const pair of plan.lone) { for (const pair of plan.lone) {
if (!(await submit([matchEntry(...pair)], `Release: ${pair[0].title}`))) { if (!(await submit([matchEntry(...pair)], `Release: ${pair[0].title}`, names))) {
return; return;
} }
done.push(pair); done.push(pair);
} }
if (plan.rest.length && !(await submit(plan.rest.map((pair) => matchEntry(...pair)), `Release: ${decisionWords(plan.rest.length)}`))) { if (plan.rest.length && !(await submit(plan.rest.map((pair) => matchEntry(...pair)), `Release: ${decisionWords(plan.rest.length)}`, names))) {
return; return;
} }
done.push(...plan.rest, ...plan.gone); done.push(...plan.rest, ...plan.gone);
@@ -831,6 +889,8 @@
matchView.releasing = false; matchView.releasing = false;
if (done.length) { if (done.length) {
await settleRelease(done); await settleRelease(done);
} else {
drawMatch(true);
} }
} }
} }
@@ -870,23 +930,68 @@
}}}, icon(taken ? "bi-shield-fill-exclamation" : "bi-shield-exclamation"), words); }}}, icon(taken ? "bi-shield-fill-exclamation" : "bi-shield-exclamation"), words);
} }
function backToStack(card) {
logStep(card.id);
matchView.decisions.delete(card.id);
refusedIds.delete(card.ref);
toBack(card.id);
drawMatch(true);
}
/**
* @param {object} card a card on the release card.
* @returns {string} why Accept is impossible for it now, "" when it is possible.
*/
function acceptBlock(card) {
if (lapsedCard(card)) {
return `${expiredWords(card)}: it can no longer be granted`;
}
if (card.blocked) {
return `not possible now: ${card.blocked}`;
}
if (card.stale) {
return `the card is stale: ${card.stale_reason}`;
}
return needsPick(card) || pickOnly(card) ? "pick one of its options" : "";
}
function menuEntry(words, mark, why, act) {
return h("button", {type: "button", class: "menu-item", disabled: Boolean(why), title: why ? revealed(`${words}: ${why}`) : revealed(words), on: {click: (event) => {
event.currentTarget.closest("details").open = false;
act();
}}}, icon(mark), revealed(words), why ? h("span", {class: "muted match-verdict-why"}, revealed(why)) : null);
}
/**
* @param {object} card a card on the release card, not withdrawn.
* @param {object} decision its decision.
* @returns {HTMLElement} its verdict pill as a menu: each option of a decision card, Accept, Reject and Back to the
* stack, an impossible entry greyed with its reason.
*/
function verdictMenu(card, decision) {
const [word, tone, mark] = MATCH_VERDICTS[decision.verdict];
const lapsed = lapsedCard(card);
const options = card.kind === "decision" && !card.multi && Array.isArray(card.options) ? card.options.map((option) => menuEntry(`Pick: ${shownPick(option.label)}`, "bi-signpost-split", lapsed ? acceptBlock(card) : "", () => decide(card, "accept", "", option.label))) : [];
const accept = card.kind === "decision" && Array.isArray(card.options) ? null : menuEntry("Accept", "bi-check-lg", acceptBlock(card), () => acceptCard(card));
const rejectWhy = card.blocked && !lapsed ? `not possible now: ${card.blocked}` : pickOnly(card) && !lapsed ? "a choice is answered with one of its options" : "";
return h("details", {class: "menu match-verdict-menu"},
h("summary", {class: "pill match-verdict", "data-tone": tone, ...named(`${word}: change`, "Change this decision")}, icon(mark), decision.label ? revealed(`${word}: ${shownPick(decision.label)}`) : word, caret()),
h("div", {class: "menu-box end", role: "group", "aria-label": "Change the decision"}, options, accept, menuEntry("Reject …", "bi-x-lg", rejectWhy, () => rejectCard(card)), menuEntry("Back to the stack", "bi-stack", "", () => backToStack(card))));
}
function overviewRow(card, decision) { function overviewRow(card, decision) {
const [kindName, kindTone, kindIcon] = MATCH_KINDS[card.kind] || [card.kind, "neutral", "bi-collection"]; const [kindName, kindTone, kindIcon] = MATCH_KINDS[card.kind] || [card.kind, "neutral", "bi-collection"];
const [word, tone, mark] = MATCH_VERDICTS[decision.verdict]; const [word, tone, mark] = MATCH_VERDICTS[decision.verdict];
const other = decision.verdict === "accept" ? "reject" : "accept"; const back = iconBtn("bi-arrow-counterclockwise", card.withdrawn ? "Drop the reject" : "Back to the stack", "btn small ghost match-undecide", () => backToStack(card), card.withdrawn ? "Drop the reject: nothing is sent" : "Back to the stack: the card goes behind the release card, last in the deck");
const flip = card.withdrawn || (other === "reject" && pickOnly(card)) || (other === "accept" && !flies(card)) ? null : iconBtn(MATCH_VERDICTS[other][2], MATCH_VERDICTS[other][0], "btn small ghost match-flip", () => (other === "accept" ? acceptCard(card) : rejectCard(card)), `${MATCH_VERDICTS[other][0]} instead`);
const back = iconBtn("bi-arrow-counterclockwise", card.withdrawn ? "Drop the reject" : "Back to the stack", "btn small ghost match-undecide", () => {
matchView.decisions.delete(card.id);
toFront(card.id);
drawMatch(true);
});
const risk = risky(card, decision); const risk = risky(card, decision);
const held = risk && !decision.risk; const held = risk && !decision.risk;
const note = card.withdrawn ? "Card withdrawn: the feedback goes to its agent by radio call at the release." : decision.verdict === "reject" && decision.hash !== card.hash ? "Card changed since your reject." : held ? "Accept its risk or send it back to the stack: the release waits until you do." : ""; const bad = unreleasable(card, decision);
return h("li", {class: "match-decision", "data-card": card.id, "data-verdict": decision.verdict, "data-withdrawn": String(Boolean(card.withdrawn)), "data-held": String(held)}, const note = bad ? `Cannot be released: ${bad}.` : card.withdrawn ? "Card withdrawn: the feedback goes to its agent by radio call at the release." : decision.verdict === "reject" && decision.hash !== card.hash ? "Card changed since your reject." : held ? "Accept its risk or send it back to the stack: the release waits until you do." : "";
const verdict = card.withdrawn ? h("span", {class: "pill match-verdict", "data-tone": tone}, icon(mark), word) : verdictMenu(card, decision);
return h("li", {class: "match-decision", "data-card": card.id, "data-verdict": decision.verdict, "data-withdrawn": String(Boolean(card.withdrawn)), "data-held": String(held), "data-bad": String(Boolean(bad))},
h("div", {class: "row"}, agentFace(card.agent || "-", false), h("span", {class: "pill", "data-tone": kindTone}, icon(kindIcon), kindName), h("strong", {class: "match-decision-title"}, revealed(card.title)), h("span", {class: "spacer"}), h("div", {class: "row"}, agentFace(card.agent || "-", false), h("span", {class: "pill", "data-tone": kindTone}, icon(kindIcon), kindName), h("strong", {class: "match-decision-title"}, revealed(card.title)), h("span", {class: "spacer"}),
risk ? riskButton(decision) : h("span", {class: "pill match-verdict", "data-tone": tone}, icon(mark), decision.label ? revealed(`${word}: ${shownPick(decision.label)}`) : word), decision.verdict === "reject" ? iconBtn("bi-pencil", "Edit feedback", "btn small ghost match-edit", () => rejectCard(card)) : null, flip, back), risk && !bad ? riskButton(decision) : verdict, decision.verdict === "reject" && !card.withdrawn ? iconBtn("bi-pencil", "Edit feedback", "btn small ghost match-edit", () => rejectCard(card)) : null, back),
note ? h("p", {class: "muted match-decision-note"}, icon("bi-info-circle"), note) : null, note ? h("p", {class: `muted match-decision-note${bad ? " match-decision-bad" : ""}`}, icon(bad ? "bi-exclamation-octagon" : "bi-info-circle"), revealed(note)) : null,
decision.verdict === "reject" ? h("pre", {class: "match-decision-feedback"}, revealedLines(decision.feedback === "" ? "no feedback text" : decision.feedback)) : null); decision.verdict === "reject" ? h("pre", {class: "match-decision-feedback"}, revealedLines(decision.feedback === "" ? "no feedback text" : decision.feedback)) : null);
} }
@@ -900,7 +1005,9 @@
const picked = decided(cards); const picked = decided(cards);
const plan = releasePlan(picked); const plan = releasePlan(picked);
const held = plan.held.length; const held = plan.held.length;
const count = held ? 0 : plan.lone.length + plan.rest.length + plan.gone.length; const bad = plan.bad.length;
const count = held || bad ? 0 : plan.lone.length + plan.rest.length + plan.gone.length;
const badWhy = plan.bad.map(([card, decision]) => `${card.title}: ${unreleasable(card, decision)}`).join("\n");
const signatures = plan.lone.length ? `${plan.lone.length === 1 ? "The risk-accepted commit gets its own" : `Each of the ${plan.lone.length} risk-accepted commits gets its own`} passkey signature first, then one signature releases the rest` : "One passkey signature releases every decision"; const signatures = plan.lone.length ? `${plan.lone.length === 1 ? "The risk-accepted commit gets its own" : `Each of the ${plan.lone.length} risk-accepted commits gets its own`} passkey signature first, then one signature releases the rest` : "One passkey signature releases every decision";
const run = () => releaseMatch(cards); const run = () => releaseMatch(cards);
const back = open ? () => { const back = open ? () => {
@@ -909,16 +1016,17 @@
drawMatch(true); drawMatch(true);
} : null; } : null;
const release = held ? h("p", {class: "muted match-release-held"}, icon("bi-shield-exclamation"), `${held === 1 ? "One red-gate commit waits" : `${held} red-gate commits wait`} for your risk accept or its way back to the stack.`) const release = held ? h("p", {class: "muted match-release-held"}, icon("bi-shield-exclamation"), `${held === 1 ? "One red-gate commit waits" : `${held} red-gate commits wait`} for your risk accept or its way back to the stack.`)
: h("button", {type: "button", class: "btn primary match-release", disabled: !count, title: count ? `${signatures}; after each signature ${undoWords()}.` : "Nothing to release yet.", on: {click: run}}, icon("bi-key"), `Release ${decisionWords(count)}`); : h("button", {type: "button", class: "btn primary match-release", disabled: !(count || bad), "aria-disabled": String(Boolean(bad)), title: revealed(bad ? `Release waits: drop or change ${bad === 1 ? "this row" : `these ${bad} rows`} first.\n${badWhy}` : count ? `${signatures}; after each signature ${undoWords()}.` : "Nothing to release yet."), on: {click: run}}, icon("bi-key"), `Release ${decisionWords(count || plan.lone.length + plan.rest.length + plan.gone.length + bad)}`);
const cancel = h("button", {type: "button", class: "btn danger match-drop", disabled: !bad, title: revealed(bad ? `Cancel: drop the ${bad === 1 ? "row" : `${bad} rows`} that cannot be released, and their cards leave the deck.\n${badWhy}` : "Cancel: no row is blocked, nothing to drop."), on: {click: () => dropUnreleasable(plan.bad)}}, icon("bi-x-lg"), bad ? `Cancel ${bad}` : "Cancel");
const article = h("article", {class: "card match-card front match-release-card match-overview", "data-card": "release", "aria-label": "Release card: the decisions"}, const article = h("article", {class: "card match-card front match-release-card match-overview", "data-card": "release", "aria-label": "Release card: the decisions"},
h("header", {class: "match-head"}, widenToggle(), h("h2", {class: "match-title"}, icon("bi-key"), "Release"), h("header", {class: "match-head"}, widenToggle(), h("h2", {class: "match-title"}, icon("bi-key"), "Release"),
h("p", {class: "muted match-release-hint"}, [count ? "D, → or a right swipe releases" : "", open ? "A, W, ← or a left swipe goes on to the next card" : "", "S undoes the last step."].filter(Boolean).join("; "))), h("p", {class: "muted match-release-hint"}, [count ? "D, → or a right swipe releases" : "", open ? "A, W, ← or a left swipe goes on to the next card" : "", "S undoes the last step."].filter(Boolean).join("; "))),
h("div", {class: "match-body"}, h("div", {class: "match-body"},
h("p", {class: "muted"}, "Nothing has run yet. Accepted commits get the operator's signature for their exact tree, accepted commands run once as jobs under Waits on Operator, accepted asks are granted, every picked option and every rejection goes to its agent by radio call."), h("p", {class: "muted"}, "Nothing has run yet. Accepted commits get the operator's signature for their exact tree, accepted commands run once as jobs under Waits on Operator, accepted asks are granted, every picked option and every rejection goes to its agent by radio call."),
picked.length ? h("ol", {class: "match-decisions"}, picked.map(([card, decision]) => overviewRow(card, decision))) : h("p", {class: "muted"}, "No decision yet."), picked.length ? h("ol", {class: "match-decisions"}, picked.map(([card, decision]) => overviewRow(card, decision))) : h("p", {class: "muted"}, "No decision yet."),
h("div", {class: "actions"}, back ? iconBtn("bi-stack", `Back to the stack (${open})`, "btn ghost match-back", back) : null, h("span", {class: "spacer"}), release))); h("div", {class: "actions"}, cancel, back ? iconBtn("bi-stack", `Back to the stack (${open})`, "btn ghost match-back", back) : null, h("span", {class: "spacer"}), release)));
paint(article, "release"); paint(article, "release");
matchView.release = {accept: count ? run : null, reject: back, later: back}; matchView.release = {accept: count || bad ? run : null, reject: back, later: back};
draggable(article, matchView.release, () => false); draggable(article, matchView.release, () => false);
return article; return article;
} }
+6
View File
@@ -145,6 +145,12 @@ table.diff tr.match-mark td, table.diff tr.match-comment td { padding: 4px 10px;
.match-accept-risk { display: inline-flex; align-items: center; gap: 4px; border-color: var(--bad); color: var(--bad); } .match-accept-risk { display: inline-flex; align-items: center; gap: 4px; border-color: var(--bad); color: var(--bad); }
.match-accept-risk[aria-pressed="true"] { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); } .match-accept-risk[aria-pressed="true"] { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.match-decision[data-held="true"] { border-style: dashed; border-color: var(--bad); } .match-decision[data-held="true"] { border-style: dashed; border-color: var(--bad); }
.match-decision[data-bad="true"] { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 8%, transparent); }
.match-decision-bad { color: var(--bad); }
.match-verdict-menu > summary { cursor: pointer; list-style: none; }
.match-verdict-menu > summary::-webkit-details-marker { display: none; }
.match-verdict-menu .menu-item { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.match-verdict-why { flex-basis: 100%; font-size: var(--fs-sm); }
.match-decisions { display: grid; gap: var(--sp-1); margin: 0; padding: 0; list-style: none; } .match-decisions { display: grid; gap: var(--sp-1); margin: 0; padding: 0; list-style: none; }
.match-decision { display: grid; gap: 4px; min-width: 0; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; } .match-decision { display: grid; gap: 4px; min-width: 0; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; }
.match-decision > .row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; } .match-decision > .row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
+11 -3
View File
@@ -84,8 +84,11 @@ FLOW = """(async () => {@HELPERS@
const leaned = await swipe(width * 0.4, 0); const leaned = await swipe(width * 0.4, 0);
await until(() => front() !== order[2], 3000); await until(() => front() !== order[2], 3000);
order.push(front()); order.push(front());
key("w");
await until(() => front() !== order[3], 3000);
order.push(front());
const short = await swipe(width * 0.1, 0); const short = await swipe(width * 0.1, 0);
const stayed = front() === order[3]; const stayed = front() === order[4];
await swipe(width * 0.4, 4); await swipe(width * 0.4, 4);
const overview = await until(() => document.querySelector("#main .match-overview"), 3000); const overview = await until(() => document.querySelector("#main .match-overview"), 3000);
const rows = overview ? all("#main .match-decision").map((item) => [item.dataset.card, item.dataset.verdict, text(item.querySelector(".match-decision-feedback"))]) : []; const rows = overview ? all("#main .match-decision").map((item) => [item.dataset.card, item.dataset.verdict, text(item.querySelector(".match-decision-feedback"))]) : [];
@@ -102,7 +105,12 @@ FLOW = """(async () => {@HELPERS@
found.kept = all("#main .match-decision").length; found.kept = all("#main .match-decision").length;
} }
const flashed = new Set(); const flashed = new Set();
const watch = window.setInterval(() => all("#main .match-card").forEach((node) => flashed.add(node.dataset.card)), 20); const shownBefore = new Set(all("#main .match-card").map((node) => node.dataset.card));
let cleared = false;
const watch = window.setInterval(() => {
cleared = cleared || Boolean(document.querySelector("#main .match-stack .empty"));
all("#main .match-card").filter((node) => !node.hasAttribute("data-blocked") && (cleared || !shownBefore.has(node.dataset.card))).forEach((node) => flashed.add(node.dataset.card));
}, 20);
found.toast = await toastAfter(() => document.querySelector("#main .match-release").click()); found.toast = await toastAfter(() => document.querySelector("#main .match-release").click());
found.emptied = @SIGNS@ ? Boolean(await until(() => document.querySelector("#main .match-stack .empty"), 15000)) : false; found.emptied = @SIGNS@ ? Boolean(await until(() => document.querySelector("#main .match-stack .empty"), 15000)) : false;
await sleep(@SIGNS@ ? 2500 : 0); await sleep(@SIGNS@ ? 2500 : 0);
@@ -175,7 +183,7 @@ class TestMatchRelease(HubCase):
def check_flow(self, found: dict) -> None: def check_flow(self, found: dict) -> None:
reason = f"{FIRST}:3: rename it" reason = f"{FIRST}:3: rename it"
self.assertNotIn("error", found, found) self.assertNotIn("error", found, found)
self.assertEqual(found["order"], [self.cards[0], self.cards[1], self.cards[2], self.cards[1]], found) self.assertEqual(found["order"], [self.cards[0], self.cards[1], self.cards[2], "release", self.cards[1]], found)
self.assertEqual((found["prefill"], found["leaned"], found["short"], found["stayed"]), (reason, "accept", "accept", True), found) self.assertEqual((found["prefill"], found["leaned"], found["short"], found["stayed"]), (reason, "accept", "accept", True), found)
expected = [[self.cards[0], "reject", f"{reason}\nalso add a test"], [self.cards[1], "accept", None], [self.cards[2], "accept", None]] expected = [[self.cards[0], "reject", f"{reason}\nalso add a test"], [self.cards[1], "accept", None], [self.cards[2], "accept", None]]
self.assertEqual(sorted(found["rows"]), sorted(expected), found) self.assertEqual(sorted(found["rows"]), sorted(expected), found)
+4 -1
View File
@@ -65,9 +65,12 @@ WASD = """(async () => {@HELPERS@@CARD@@STEPS@
for (let step = 0; step < 8; step += 1) { for (let step = 0; step < 8; step += 1) {
lap.push(await press("w")); lap.push(await press("w"));
} }
while (front() !== "release") { for (let tries = 0; tries < 12 && front() !== "release"; tries += 1) {
await press("w"); await press("w");
} }
if (front() !== "release") {
return {error: "W never brought the release card", seen, lap};
}
const onRelease = {a: await press("a")}; const onRelease = {a: await press("a")};
document.querySelector("#main .match-open-overview").click(); document.querySelector("#main .match-open-overview").click();
await until(releasing, 3000); await until(releasing, 3000);
+7 -2
View File
@@ -48,7 +48,12 @@ RELEASED = """(async () => {@HELPERS@@CARD@@STEPS@
if (!(await until(card, 8000)) || !(await decideAll())) { if (!(await until(card, 8000)) || !(await decideAll())) {
return {error: text(document.getElementById("main")).slice(0, 300)}; return {error: text(document.getElementById("main")).slice(0, 300)};
} }
return {title: document.querySelector("#main .match-release").title}; const risk = document.querySelector('#main .match-decision[data-card="@RED@"] .match-accept-risk');
if (risk) {
risk.click();
}
const release = await until(() => document.querySelector("#main .match-release"), 4000);
return release ? {title: release.title} : {error: text(document.getElementById("main")).slice(0, 300)};
})()""" })()"""
@@ -63,7 +68,7 @@ class TestUndoDial(deck.ReleaseDeck):
def test_chromium_sets_the_undo_window_on_a_dial_and_every_undo_text_names_the_saved_seconds(self): def test_chromium_sets_the_undo_window_on_a_dial_and_every_undo_text_names_the_saved_seconds(self):
steps = [ steps = [
{"width": 1366, "height": 768, "url": f"{self.base}?dial#stream/inbox", "wait": 1500, "shot": str(OUT / "chromium-1366-undo-dial.png"), "probe": deck.probe(TEXTS, red=f"review:{self.red}")}, {"width": 1366, "height": 768, "url": f"{self.base}?dial#stream/inbox", "wait": 1500, "shot": str(OUT / "chromium-1366-undo-dial.png"), "probe": deck.probe(TEXTS, red=f"review:{self.red}")},
{"width": 1920, "height": 1080, "url": f"{self.base}?dial-release#tasks/match", "wait": 1500, "shot": str(OUT / "chromium-1920-undo-release.png"), "probe": deck.probe(RELEASED)}, {"width": 1920, "height": 1080, "url": f"{self.base}?dial-release#tasks/match", "wait": 1500, "shot": str(OUT / "chromium-1920-undo-release.png"), "probe": deck.probe(RELEASED, red=f"review:{self.red}")},
] ]
data = self.drive(steps, None, init=deck.INIT) data = self.drive(steps, None, init=deck.INIT)
(OUT / "chromium-undo-dial.json").write_text(json.dumps(data, indent=1), encoding="utf-8") (OUT / "chromium-undo-dial.json").write_text(json.dumps(data, indent=1), encoding="utf-8")
+8 -3
View File
@@ -12,7 +12,7 @@ from kvb_orchestrator import batches, skill_scripts
from kvb_orchestrator.asking import TERMINAL from kvb_orchestrator.asking import TERMINAL
from kvb_orchestrator.denying import LAPSED from kvb_orchestrator.denying import LAPSED
from kvb_orchestrator.inbox import LAPSE_WINDOW, lapsed_of from kvb_orchestrator.inbox import LAPSE_WINDOW, lapsed_of
from kvb_orchestrator.matching import EXPIRED, EXPIRED_REASON, expired_card from kvb_orchestrator.matching import EXPIRED, EXPIRED_REASONS, expired_card
from test_hub_match import MatchCase from test_hub_match import MatchCase
FEEDBACK = "run it again after the gate" FEEDBACK = "run it again after the gate"
@@ -49,9 +49,14 @@ class TestExpiredFilter(unittest.TestCase):
def test_an_expired_card_is_greyed_with_blocked_kind_expired_and_keeps_its_expires(self): def test_an_expired_card_is_greyed_with_blocked_kind_expired_and_keeps_its_expires(self):
card = expired_card({"id": "ask:a1", "kind": "ask", "blocked": "", "stale": False}, 990.0) card = expired_card({"id": "ask:a1", "kind": "ask", "blocked": "", "stale": False}, 990.0)
self.assertEqual((card["blocked_kind"], card["blocked"], card["expires"], card["stale"]), (EXPIRED, EXPIRED_REASON, 990.0, False)) self.assertEqual((card["blocked_kind"], card["blocked"], card["expires"], card["stale"]), (EXPIRED, EXPIRED_REASONS["ask"], 990.0, False))
self.assertIn(LAPSED, card["blocked"].lower()) self.assertIn(LAPSED, card["blocked"].lower())
def test_an_expired_decision_says_its_agent_stopped_waiting_not_that_a_tool_call_returned(self):
card = expired_card({"id": "decision:d1", "kind": "decision", "blocked": "", "stale": False}, 990.0)
self.assertEqual(card["blocked"], EXPIRED_REASONS["decision"])
self.assertNotIn("tool call", card["blocked"])
class TestExpiredRelease(MatchCase): class TestExpiredRelease(MatchCase):
def radio(self) -> list[list[str]]: def radio(self) -> list[list[str]]:
@@ -81,7 +86,7 @@ class TestExpiredRelease(MatchCase):
def test_an_expired_ask_stays_a_greyed_card_with_its_expiry_but_leaves_the_inbox_and_the_badge(self): def test_an_expired_ask_stays_a_greyed_card_with_its_expiry_but_leaves_the_inbox_and_the_badge(self):
ask = self.lapsed_ask(CALLED) ask = self.lapsed_ask(CALLED)
card = self.card(f"ask:{ask}") card = self.card(f"ask:{ask}")
self.assertEqual((card["kind"], card["blocked_kind"], card["blocked"], card["to"]), ("ask", EXPIRED, EXPIRED_REASON, "Skills")) self.assertEqual((card["kind"], card["blocked_kind"], card["blocked"], card["to"]), ("ask", EXPIRED, EXPIRED_REASONS["ask"], "Skills"))
self.assertEqual(card["expires"], self.httpd.hub.asks.get(ask)["expires"]) self.assertEqual(card["expires"], self.httpd.hub.asks.get(ask)["expires"])
snapshot = self.snapshot() snapshot = self.snapshot()
self.assertNotIn(ask, [item["id"] for item in snapshot["inbox"]]) self.assertNotIn(ask, [item["id"] for item in snapshot["inbox"]])
+2 -2
View File
@@ -87,8 +87,8 @@ class TestReleaseCardLast(unittest.TestCase):
def test_a_new_card_queues_before_the_release_card(self): def test_a_new_card_queues_before_the_release_card(self):
self.assertEqual(self.data["fresh"], "a,b,c,release") self.assertEqual(self.data["fresh"], "a,b,c,release")
def test_later_puts_a_card_before_the_release_card(self): def test_later_puts_a_card_behind_the_release_card(self):
self.assertEqual(self.data["later"], "a,c,b,release") self.assertEqual(self.data["later"], "a,c,release,b")
def test_a_shown_release_card_stays_in_front_and_new_cards_queue_behind_it(self): def test_a_shown_release_card_stays_in_front_and_new_cards_queue_behind_it(self):
self.assertEqual(self.data["shown"], "release,b,c,a,d") self.assertEqual(self.data["shown"], "release,b,c,a,d")
+92
View File
@@ -0,0 +1,92 @@
from __future__ import annotations
import json
import re
import subprocess
import unittest
from hub_support import HUB
MATCH = HUB / "templates" / "page-match.js"
NAMES = ("lapsedCard", "toBack", "logStep", "backToStack", "unreleasable", "risky", "releasePlan")
PROBE = r"""
const vm = require("vm");
const sandbox = {
RELEASE: "release",
matchView: {order: [], decisions: new Map(), history: []},
refusedIds: new Map(),
expiredWords: () => "expired 20:41, 3 minutes ago",
drawMatch: () => {},
out: {},
};
vm.runInNewContext(process.argv[1], sandbox);
vm.runInNewContext(`
const accept = {verdict: "accept"};
const reject = {verdict: "reject"};
const card = (id, extra) => ({id, ref: id, kind: "ask", title: id, blocked: "", ...extra});
const expired = card("x", {blocked: "expired", blocked_kind: "expired"});
out.expiredAccept = unreleasable(expired, accept);
out.expiredReject = unreleasable(expired, reject);
out.blocked = unreleasable(card("b", {blocked: "runs", blocked_kind: "running"}), accept);
out.fine = unreleasable(card("f"), accept);
refusedIds.set("r", "expired");
out.refused = unreleasable(card("r"), accept);
const plan = releasePlan([[expired, accept], [card("f"), accept], [card("w", {withdrawn: true}), reject]]);
out.plan = {bad: plan.bad.map(([c]) => c.id), rest: plan.rest.map(([c]) => c.id), gone: plan.gone.map(([c]) => c.id)};
matchView.order = ["a", "release", "c"];
matchView.decisions.set("a", accept);
refusedIds.set("a", "expired");
backToStack(card("a"));
out.order = matchView.order.join(",");
out.undecided = !matchView.decisions.has("a") && !refusedIds.has("a");
out.steps = matchView.history.length;
`, sandbox);
console.log(JSON.stringify(sandbox.out));
"""
def extracted() -> str:
source = MATCH.read_text(encoding="utf-8")
parts = []
for name in NAMES:
found = re.search(rf"^ const {name} = [^\n]*;$", source, re.MULTILINE) or re.search(rf"^ (?:function {name}\(|const {name} = ).*?^ }};?$", source, re.MULTILINE | re.DOTALL)
if found is None:
raise AssertionError(f"{name} not found in {MATCH}")
parts.append(found.group(0).replace(f"const {name} = ", f"var {name} = "))
return "\n".join(parts)
class TestReleaseCardRepairs(unittest.TestCase):
@classmethod
def setUpClass(cls):
done = subprocess.run(["node", "-e", PROBE, extracted()], capture_output=True, text=True, timeout=60, check=False)
if done.returncode != 0:
raise AssertionError(done.stderr[-4000:])
cls.data = json.loads(done.stdout)
def test_an_accepted_card_that_expired_names_its_expiry(self):
self.assertEqual(self.data["expiredAccept"], "expired 20:41, 3 minutes ago: can no longer be granted; reject or drop it")
def test_a_reject_of_an_expired_card_still_releases(self):
self.assertEqual(self.data["expiredReject"], "")
def test_a_blocked_card_names_its_block(self):
self.assertIn("not possible now: runs", self.data["blocked"])
def test_a_card_the_hub_refused_names_the_refusal(self):
self.assertIn("the hub refused it: expired", self.data["refused"])
def test_a_fine_card_releases(self):
self.assertEqual(self.data["fine"], "")
def test_the_plan_keeps_bad_rows_out_of_the_signed_batch(self):
self.assertEqual(self.data["plan"], {"bad": ["x"], "rest": ["f"], "gone": ["w"]})
def test_back_to_the_stack_puts_the_card_last_behind_the_release_card(self):
self.assertEqual(self.data["order"], "release,c,a")
self.assertTrue(self.data["undecided"])
self.assertEqual(self.data["steps"], 1)
if __name__ == "__main__":
unittest.main()