Skip to content

Commit 01a7313

Browse files
demo: pages + perf live badges on the live-status strip — conclusions, not workflow enablement
Three real sources, one strip: the dde cycle and the pages build read latest run conclusions (cancelled runs skipped), perf reads the badge SVGs against the CI gates' own budgets. Bilingual; checking lines stay honest when a source is unreachable. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
1 parent 8a5d748 commit 01a7313

1 file changed

Lines changed: 66 additions & 18 deletions

File tree

‎docs/DELIVERY-DISPUTE-DEMO.html‎

Lines changed: 66 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,16 @@
116116
<h1>CoreGuard <span style="color:var(--violet)">DDE/1</span> — <span data-i18n="title">Delivery &amp; Dispute Evidence</span></h1>
117117
<p class="sub" data-i18n="sub">A complete, replayable bilateral fixture that demonstrates the boundary in code: the on-chain payment is real, the rejection stands on named acceptance criteria, and nothing in the chain of custody lets the engine decide who is right.</p>
118118
<p class="sub mono" style="margin-top:8px; font-size:12px" data-i18n="runline">Replay: node examples/delivery-fixture/verify-fixture.mjs → VERIFIED (10 PASS · exit 0)</p>
119-
<p class="sub mono" id="cicBadge" style="margin-top:6px; font-size:12px; display:none">
120-
<a id="cicLink" href="https://github.com/EslaM-X/coreguard/actions/workflows/dde.yml" target="_blank" rel="noopener" style="text-decoration:none">
119+
<p class="sub mono" id="liveBadges" style="margin-top:6px; font-size:12px; display:none">
120+
<a id="cicLink" href="https://github.com/EslaM-X/coreguard/actions/workflows/dde.yml" target="_blank" rel="noopener" style="text-decoration:none; margin-right:16px">
121121
<span id="cicDot" style="display:inline-block; width:9px; height:9px; border-radius:50%; margin-right:6px; vertical-align:middle; background:var(--amber)"></span><span data-i18n="cic_checking">DDE evidence surveillance: checking live workflow status…</span>
122122
</a>
123+
<a id="pagesLink" href="https://github.com/EslaM-X/coreguard/deployments/pages" target="_blank" rel="noopener" style="text-decoration:none; margin-right:16px">
124+
<span id="pagesDot" style="display:inline-block; width:9px; height:9px; border-radius:50%; margin-right:6px; vertical-align:middle; background:var(--amber)"></span><span data-i18n="pages_checking">Publication: checking live pages build status…</span>
125+
</a>
126+
<a id="perfLink" href="https://github.com/EslaM-X/coreguard/blob/main/benchmarks/perf-history.jsonl" target="_blank" rel="noopener" style="text-decoration:none">
127+
<span id="perfDot" style="display:inline-block; width:9px; height:9px; border-radius:50%; margin-right:6px; vertical-align:middle; background:var(--amber)"></span><span data-i18n="perf_checking">Performance budgets: checking live medians…</span>
128+
</a>
123129
</p>
124130
</header>
125131

@@ -264,6 +270,12 @@ <h3 data-i18n="pc_t2">What the mapping is — and is not</h3>
264270
cic_checking:{en:"DDE evidence surveillance: checking live workflow status…",ar:"مراقبة أدلة DDE: جارٍ فحص حالة الـworkflow الحية…"},
265271
cic_passing:{en:"DDE evidence under continuous surveillance — live cycle PASSING",ar:"أدلة DDE تحت مراقبة مستمرة — الدورة الحية خضراء"},
266272
cic_failing:{en:"DDE evidence surveillance: live cycle FAILING — do not cite engine output",ar:"مراقبة أدلة DDE: الدورة الحية حمراء — لا تُقتبس مخرجات المحرك"},
273+
pages_checking:{en:"Publication: checking live pages build status…",ar:"النشر: جارٍ فحص حالة بناء الصفحات الحية…"},
274+
pages_passing:{en:"Publication under continuous watch — last pages build PASSED",ar:"النشر تحت مراقبة مستمرة — آخر بناء صفحات أخضر"},
275+
pages_failing:{en:"Publication: last pages build FAILED — this demo may be stale",ar:"النشر: آخر بناء صفحات فاشل — قد يكون هذا العرض قديمًا"},
276+
perf_checking:{en:"Performance budgets: checking live medians…",ar:"ميزانيات الأداء: جارٍ جلب آخر المتوسطات الحية…"},
277+
perf_ok:{en:"Performance budgets honored — live medians within budget",ar:"ميزانيات الأداء محترمة — المتوسطات الحية داخل الحدود"},
278+
perf_over:{en:"Performance budget exceeded — a live median is outside its budget",ar:"تجاوز ميزانية أداء — أحد المتوسطات الحية خارج حدّها"},
267279
h_life:{en:"Evidence lifecycle — each step a signed record",ar:"دورة الأدلة — كل خطوة سجل موقّع"},
268280
tag_syn:{en:"SYNTHETIC",ar:"SYNTHETIC"},
269281
tag_real:{en:"REAL",ar:"حقيقي"},
@@ -496,26 +508,62 @@ <h3 data-i18n="pc_t2">What the mapping is — and is not</h3>
496508
document.dispatchEvent(new CustomEvent("cg41:lang", { detail: { lang: window.cgLang } }));
497509
};
498510

499-
// Live DDE evidence-surveillance badge: real GitHub API status of the
500-
// dedicated dde.yml workflow (same data the README badge renders). The
501-
// page stays self-contained if the API is unreachable — the checking line
511+
// Live status badges: real GitHub API state for (1) the dde.yml evidence
512+
// cycle, (2) the pages build that serves this very page, and (3) the perf
513+
// medians the README's perf badges carry. (1)+(2) read the ONE anonymous
514+
// global runs list; (3) reads this page's sibling badge SVGs. The page
515+
// stays self-contained if any source is unreachable — the checking line
502516
// simply remains, never a fabricated status.
517+
//
518+
// Honesty note: a workflow's `state` is only its ENABLEMENT ("active"),
519+
// never the last result — the previous cic badge conflated the two. The
520+
// badges here read each latest run's `conclusion` instead.
521+
const setBadge = (prefix, key, ok) => {
522+
const dot = document.getElementById(prefix + "Dot");
523+
const label = document.querySelector("#" + prefix + "Link [data-i18n]");
524+
if (!dot || !label) return;
525+
dot.style.background = ok ? "var(--green)" : "var(--red)";
526+
dot.style.boxShadow = ok ? "0 0 8px var(--green)" : "none";
527+
label.setAttribute("data-i18n", key);
528+
label.textContent = L(I18N[key]);
529+
};
503530
try {
504-
const r = await fetch("https://api.github.com/repos/EslaM-X/coreguard/actions/workflows/dde.yml", { headers: { accept: "application/vnd.github+json" } });
531+
const r = await fetch("https://api.github.com/repos/EslaM-X/coreguard/actions/runs?per_page=100", { headers: { accept: "application/vnd.github+json" } });
505532
if (!r.ok) throw new Error("http " + r.status);
506-
const wf = await r.json();
507-
const state = (wf.state || "").toLowerCase();
508-
const dot = document.getElementById("cicDot");
509-
const label = document.querySelector("#cicBadge [data-i18n]");
510-
const key = state === "active" ? "cic_passing" : (state === "disabled_manually" || state === "disabled_inactivity" ? "cic_failing" : null);
511-
if (key) {
512-
dot.style.background = state === "active" ? "var(--green)" : "var(--red)";
513-
dot.style.boxShadow = state === "active" ? "0 0 8px var(--green)" : "none";
514-
label.setAttribute("data-i18n", key);
515-
label.textContent = L(I18N[key]);
533+
const runs = (await r.json()).workflow_runs || [];
534+
// "cancelled" means a newer push superseded that run — not a failure.
535+
const latest = (name) => runs.find((run) => run.name === name && run.conclusion !== "cancelled");
536+
const dde = latest("DDE Evidence Cycle");
537+
if (dde) setBadge("cic", dde.conclusion === "success" ? "cic_passing" : "cic_failing", dde.conclusion === "success");
538+
// The dynamic pages workflow is GitHub-owned; its RUN name (with spaces)
539+
// is what the runs list carries — the file slug never appears there.
540+
const pages = latest("pages build and deployment");
541+
if (pages) setBadge("pages", pages.conclusion === "success" ? "pages_passing" : "pages_failing", pages.conclusion === "success");
542+
} catch { /* offline or rate-limited: the checking lines stay, honest by default */ }
543+
// Perf medians live in the aria-labels of the same static SVGs the README
544+
// renders, served next to this page — same numbers, no API budget. Budgets
545+
// are the CI gates' own: engine/sdk median ≤ 50ms, wire ≤ 150ms
546+
// (scripts/benchmark-dde*.mjs).
547+
try {
548+
const labels = [];
549+
for (const name of ["perf-engine", "perf-wire", "perf-sdk"]) {
550+
const rr = await fetch("badges/" + name + ".svg");
551+
if (!rr.ok) throw new Error("http " + rr.status);
552+
const m = (await rr.text()).match(/aria-label="([^"]+)"/);
553+
labels.push(m ? m[1] : name);
516554
}
517-
document.getElementById("cicBadge").style.display = "block";
518-
} catch { /* offline or rate-limited: the checking line stays, honest by default */ }
555+
const budget = (label) => (label.startsWith("perf·wire") ? 150 : 50);
556+
const medians = labels.map((label) => ({ label, ms: parseFloat((label.match(/[\d.]+ms/) || ["NaN"])[0]) }));
557+
const ok = medians.length >= 3 && medians.every((m) => Number.isFinite(m.ms) && m.ms < budget(m.label));
558+
const dot = document.getElementById("perfDot");
559+
const label = document.querySelector("#perfLink [data-i18n]");
560+
const key = ok ? "perf_ok" : "perf_over";
561+
dot.style.background = ok ? "var(--green)" : "var(--red)";
562+
dot.style.boxShadow = ok ? "0 0 8px var(--green)" : "none";
563+
label.setAttribute("data-i18n", key);
564+
label.textContent = L(I18N[key]) + " — " + labels.join(" · ");
565+
} catch { /* badges unreadable (e.g. file://): the checking line stays */ }
566+
document.getElementById("liveBadges").style.display = "block";
519567
})();
520568
</script>
521569
</body>

0 commit comments

Comments
 (0)