Skip to content

Commit 3acf465

Browse files
committed
feat(discovery): expose recommendation confidence and reason codes
1 parent 6fb8f8b commit 3acf465

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

apps/dashboard/index.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3353,12 +3353,15 @@ <h3>Action Console</h3>
33533353
const data = await res.json().catch(() => ({ ok: false }));
33543354
if (!res.ok || data?.ok === false) throw new Error(data?.error || `discover failed (${res.status})`);
33553355
const recommended = data?.data?.recommended || "";
3356+
const confidence = String(data?.data?.confidence || "none");
3357+
const reasonCode = String(data?.data?.reasonCode || "unknown");
3358+
const source = String(data?.data?.source || "unknown");
33563359
const top = (data?.data?.candidates || []).slice(0, 3).map((x) => `${x.pool} (liq=${Number(x.liquidityScore || 0).toFixed(2)})`);
33573360
if (recommended) {
33583361
bscConfigPoolEl.value = recommended;
3359-
metaEl.textContent = `Auto-discover ${protocol}: selected ${recommended}`;
3362+
metaEl.textContent = `Auto-discover ${protocol}: selected ${recommended} [source=${source}, confidence=${confidence}]`;
33603363
} else {
3361-
metaEl.textContent = `Auto-discover ${protocol}: no candidate found. ${data?.data?.warning || ""}`;
3364+
metaEl.textContent = `Auto-discover ${protocol}: withheld/no candidate [reason=${reasonCode}, source=${source}] ${data?.data?.warning || ""}`;
33623365
}
33633366
if (bscConfigCardEl && top.length) {
33643367
bscConfigCardEl.innerHTML += `<br/>discovered top: <span class="muted">${top.join(" ; ")}</span>`;

apps/dashboard/server.mjs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9496,13 +9496,31 @@ async function discoverBscPoolsByProtocol(protocol) {
94969496
const rows = await scorePoolCandidates(candidates);
94979497
const topScore = Number(rows[0]?.liquidityScore || 0);
94989498
const recommended = topScore > 0 ? (rows[0]?.pool ?? null) : null;
9499+
let reasonCode = "recommended";
94999500
if (!warning && rows.length > 0 && topScore <= 0) {
95009501
warning =
95019502
"auto-discovery candidates found but liquidity score is zero; recommendation withheld for safety";
9503+
reasonCode = "withheld_zero_liquidity";
95029504
}
9505+
if (rows.length === 0) {
9506+
reasonCode = "no_candidates";
9507+
}
9508+
if (!recommended && rows.length > 0 && topScore > 0) {
9509+
reasonCode = "withheld_policy";
9510+
}
9511+
const confidence =
9512+
recommended && topScore > 1_000
9513+
? "high"
9514+
: recommended && topScore > 50
9515+
? "medium"
9516+
: recommended
9517+
? "low"
9518+
: "none";
95039519
return {
95049520
protocol: key,
95059521
source,
9522+
reasonCode,
9523+
confidence,
95069524
candidates: rows,
95079525
recommended,
95089526
warning,

0 commit comments

Comments
 (0)