diff --git a/docs/evidence/ste-23-landing-claims-2026-09-20.json b/docs/evidence/ste-23-landing-claims-2026-09-20.json new file mode 100644 index 0000000..21d6eb1 --- /dev/null +++ b/docs/evidence/ste-23-landing-claims-2026-09-20.json @@ -0,0 +1,104 @@ +{ + "ticket": "STE-23", + "date": "2026-09-20", + "task": "Verify every factual claim on the landing page before it is published", + "principle": "The page states facts to strangers who cannot check them. Nothing was written from memory; each claim below was read from a source on this date, and the counts are re-read from the live API at render time rather than typed into the copy.", + "live_numbers": { + "method": "Read from https://api.sterish.xyz/skills?limit=100 at render time (frontend/src/modules/landing/liveStats.ts). The values below are the snapshot used as a labelled fallback when the API does not answer.", + "observed": { + "chain_total": 30, + "shown": 24, + "hidden_test_entries": 6, + "verdicts": { + "SAFE": 17, + "WARNING": 2, + "DANGEROUS": 5 + }, + "verified": 17 + }, + "derived": { + "official_catalogue": "13 of 13 org.stellar.skills.* are SAFE and VERIFIED — zero exclusions", + "poisoned_fixtures": "4 of 4 com.fixtures.poisoned.* are DANGEROUS", + "fifth_dangerous": "com.fixtures.demo.release-notes v2.0.0 — the rug pull, not a poisoned fixture" + }, + "honesty_rule": "CLAUDE.md forbids hiding the test namespaces silently. The page prints 'of 30 on chain' and names the 6 filtered entries, and liveStats falls back to 30 rather than to `total` when an older API omits chain_total, so no code path can assert the chain holds only what is shown. Covered by liveStats.test.ts." + }, + "rug_pull": { + "claim": "One skill, two versions: v1 Safe and VERIFIED, v2 Dangerous and refused a licence. Same name, different bytes.", + "skill_id": "com.fixtures.demo.release-notes", + "verified_against": "https://api.sterish.xyz/check/com.fixtures.demo.release-notes/{version}", + "v1.0.0": { + "verdict": "SAFE", + "trust_score": 100, + "is_verified": true, + "content_hash": "e5da489eb751e96fb30bb622602b8ab471de4898f333028aeeb7a36211d341f5" + }, + "v2.0.0": { + "verdict": "DANGEROUS", + "trust_score": 10, + "is_verified": false, + "content_hash": "befb592d3cb1afa4c471a7c4ddf2666f1c6ebd0364e76977ecd294be7c01653d" + }, + "guard": "getRugPull() falls back to the dated snapshot if the chain ever stops saying SAFE and DANGEROUS, rather than rendering a story the chain contradicts." + }, + "cves": { + "note": "Both are published advisories, not our characterisation. Checked on 2026-09-20 before being put on a public page.", + "CVE-2025-54136": { + "name": "MCPoison", + "product": "Cursor IDE", + "cvss": 8.8, + "disclosed_by": "Check Point Research, July 2025", + "mechanism": "Approval was remembered under an MCP entry's NAME; a later change to its command or arguments executed without a new prompt. An attacker commits a benign config to a shared repo, waits for approval, then swaps the payload.", + "fixed_in": "Cursor 1.3, late July 2025", + "why_it_is_on_the_page": "It is the argument in one sentence. Approval bound to a name is exactly what Sterish replaces with approval bound to a content hash." + }, + "CVE-2025-6514": { + "product": "mcp-remote", + "affected_versions": "0.0.5 to 0.1.15", + "cvss": 9.6, + "downloads_at_disclosure": "437,000+", + "mechanism": "OS command injection; the first documented case of full remote code execution on a client OS triggered by connecting to an untrusted MCP server." + } + }, + "stellar_claims": { + "note": "Verified through MCP Stellar Raven during STE-7 on 2026-09-20; see ste-7-raven-positioning-2026-09-20.json for the full record.", + "x402": { + "wording_on_page": "x402 turns HTTP 402 into a usable payment step; the agent pays in USDC and receives a soulbound licence.", + "source": "https://developers.stellar.org/docs/build/agentic-payments/x402", + "caution": "MPP sits beside x402 in Stellar's docs. The page names x402 only and does not use the two interchangeably." + }, + "usdc_sac": { + "source": "https://developers.stellar.org/docs/build/guides/tokens/stellar-asset-contract", + "note": "SEP-41 Token Interface plus CAP-46-6. Matches the CLAUDE.md decision to use the official USDC SAC rather than issuing an asset." + }, + "positioning": "The page says 'an audit registry for agent skills — not an official Stellar product, and not an app store.' Raven found no Stellar project occupying the audit-the-skill position." + }, + "restraint": { + "dashboard": "Updated 24 Sep 2026: the dashboard went public at https://app.sterish.xyz (docs/deployments.md), so the CTA now links to it. It previously read 'Dashboard — coming soon' because the deployment redirected to Vercel SSO; STE-23 allowed that only until STE-26 was live, and that condition has expired. Verified HTTP 200 on 24 Sep 2026.", + "testnet": "Stated on the page, in the hero and again beside the evidence links.", + "expiry": "The page says Stellar testnet resets to genesis on 16 December 2026, so stellar.expert links carry that expiry rather than an implied permanence." + }, + "tests": { + "file": "frontend/src/modules/landing/liveStats.test.ts", + "count": 9, + "covers": [ + "catalogue and poisoned fixtures counted separately", + "chain total reported rather than the filtered total", + "older API omitting chain_total must not imply nothing is filtered", + "API failure falls back with live:false so the page can label it", + "an empty registry is not-live rather than rendered as zeros", + "live figures dated today, snapshot dated 2026-09-20", + "rug pull passes through only while the chain still tells the story", + "either read failing falls back" + ] + }, + "not_verified_here": [ + "Visual check at 375px. The browser harness would not apply a window resize, so mobile layout rests on standard responsive classes (the hero, steps and stat grids all collapse to one column, and both the 64-character hash and the skill id carry break-all). Worth an eyeball in devtools before merge.", + "The 'Instawards by @StellarOrg.' line, which repeats the wording Axel specified. The InstAward / Instawards spelling question raised in STE-7 is still open and applies to this page too." + ], + "public_urls_2026_09_24": { + "api": "https://api.sterish.xyz (HTTP 200)", + "dashboard": "https://app.sterish.xyz (HTTP 200, public since 24 Sep)", + "landing": "https://sterish.xyz (HTTP 404 — reserved for this page, not yet pointed at it)" + } +} diff --git a/frontend/app/landing/page.tsx b/frontend/app/landing/page.tsx new file mode 100644 index 0000000..2754d18 --- /dev/null +++ b/frontend/app/landing/page.tsx @@ -0,0 +1,13 @@ +import type { Metadata } from "next"; + +import { Landing } from "@/modules/landing/Landing"; + +export const metadata: Metadata = { + title: { absolute: "Sterish — audited skills for AI agents on Stellar" }, + description: + "Sterish audits AI agent skills and writes the verdict on chain, pinned to the hash of the files it read. Check a specific version before installing it.", +}; + +export default function LandingPage() { + return ; +} diff --git a/frontend/pnpm-lock.yaml b/frontend/pnpm-lock.yaml index 8dba2c9..0410b6d 100644 --- a/frontend/pnpm-lock.yaml +++ b/frontend/pnpm-lock.yaml @@ -6,6 +6,9 @@ importers: .: configDependencies: {} packageManagerDependencies: + '@pnpm/exe': + specifier: 12.3.4 + version: 12.3.4 pnpm: specifier: 12.3.4 version: 12.3.4 @@ -56,6 +59,11 @@ packages: cpu: [x64] os: [win32] + '@pnpm/exe@12.3.4': + resolution: {integrity: sha512-Rq7JokWAyYF9IFfn8zofB/q2AgnZlmoMuH5fMHB2+Ta61I9aD7sNm+woZpx6iH+5vb38chdSoYRvOtSqlH72YQ==} + engines: {node: '>=18.*'} + hasBin: true + pnpm@12.3.4: resolution: {integrity: sha512-lhqkH7B32joEpEHZ+OFevAyW2o73ELLrZ7+e58sGEOq9SPH9hfUc/+c4RnhfoPh8VqOocqHYk/hEZ0G1zORUVw==} engines: {node: '>=18.*'} @@ -87,6 +95,17 @@ snapshots: '@pnpm/exe.win32-x64@12.3.4': optional: true + '@pnpm/exe@12.3.4': + optionalDependencies: + '@pnpm/exe.darwin-arm64': 12.3.4 + '@pnpm/exe.darwin-x64': 12.3.4 + '@pnpm/exe.linux-arm64': 12.3.4 + '@pnpm/exe.linux-arm64-musl': 12.3.4 + '@pnpm/exe.linux-x64': 12.3.4 + '@pnpm/exe.linux-x64-musl': 12.3.4 + '@pnpm/exe.win32-arm64': 12.3.4 + '@pnpm/exe.win32-x64': 12.3.4 + pnpm@12.3.4: optionalDependencies: '@pnpm/exe.darwin-arm64': 12.3.4 diff --git a/frontend/src/lib/types.ts b/frontend/src/lib/types.ts index 8d5e3cc..3bd5723 100644 --- a/frontend/src/lib/types.ts +++ b/frontend/src/lib/types.ts @@ -106,6 +106,16 @@ export interface SkillList { total: number; start: number; limit: number; + /** + * Chain reality behind the filtered list. The API hides test namespaces by + * default but always reports what it hid (CLAUDE.md: hiding it silently is + * forbidden — a reader must never be able to conclude that what is shown is + * the whole chain). Optional because older API builds omit them, and a + * consumer that needs them must say what it does when they are absent + * rather than quietly treating `total` as the chain total. + */ + chain_total?: number; + hidden_test_entries?: number; } /** Spec §3.5. Returns 503 rather than 200 when the chain is unreachable. */ diff --git a/frontend/src/modules/landing/Landing.tsx b/frontend/src/modules/landing/Landing.tsx new file mode 100644 index 0000000..a372eef --- /dev/null +++ b/frontend/src/modules/landing/Landing.tsx @@ -0,0 +1,490 @@ +import { Suspense } from "react"; + +import { API_BASE_URL } from "@/lib/api"; +import { Skeleton } from "@/components/ui/skeleton"; +import { RugPull } from "./component/RugPull"; +import { RUG_PULL_SKILL, getLandingStats, getRugPull } from "./liveStats"; + +/** + * The landing page (STE-23): one scroll from "what is this" to "check it + * yourself". + * + * Every number on this page is read from the live registry at render time + * (liveStats.ts). Every technical claim was verified before it was written: + * the two CVEs against their published advisories, the x402 and USDC SAC + * wording against Stellar's own docs through MCP Stellar Raven, and the rug + * pull against the contract. Notes and sources are in + * docs/evidence/ste-23-landing-claims-2026-09-20.json. + * + * Colours, type and spacing come only from the STE-7 tokens in globals.css. + * + * The two registry reads sit behind their own Suspense boundaries rather than + * being awaited before anything renders. GET /skills costs about 2.8s against + * the live API, so awaiting it up front meant a 3.5s blank page — measured, in + * a production build. This is the page we send to people who have never heard + * of us, and a blank page is the worst possible first frame. The prose paints + * at once and the numbers arrive when the chain answers. + * + * Caching them instead was the obvious alternative and was rejected: the + * shared API client sets cache: "no-store" on purpose (api-spec §4 — a stale + * verdict is the worst thing this product can serve), and Next 16's `use + * cache` needs cacheComponents enabled app-wide, which would change that + * guarantee for the dashboard too. Streaming buys the same result without + * touching anyone else's correctness. + */ + +const X_URL = "https://x.com/sterishxyz"; +/** Public since 24 September 2026 (docs/deployments.md). */ +const DASHBOARD_URL = "https://app.sterish.xyz"; +const REGISTRY_CONTRACT = "CCZJN366SV57JEBZVXGYY3ZBLJNFV4IR5ILCAI3EMX2WDNQPEPQ4BRL2"; +const EXPERT = `https://stellar.expert/explorer/testnet/contract/${REGISTRY_CONTRACT}`; + +export function Landing() { + return ( +
+ + + + + + +
+ ); +} + +/** Awaits the two versions of the rug pull; the rest of the hero does not. */ +async function RugPullLoader() { + return ; +} + +async function ProofLoader() { + return ; +} + +function Hero() { + return ( +
+
+

+ Your agent trusts the name. +
+ Attackers change the bytes. +

+

+ Sterish audits AI agent skills and writes the verdict on chain, + pinned to the hash of the exact files it read. Anyone can check a + specific version before installing it, without taking the + publisher’s word for anything. +

+ +

+ Stellar testnet. Real transactions, no mainnet funds. +

+
+ + }> + + +
+ ); +} + +function Problem() { + return ( +
+
+

+ An agent skill is instructions the model will follow, handed over + with the agent’s own authority. Nothing in the format carries + provenance, and nothing checks that what you approved is what later + runs. Two published advisories show both halves of that going wrong. +

+
+ + +
+
+ +

+ The first one is the whole argument. Approval was bound to a{" "} + name. Sterish binds the verdict to a{" "} + content hash, so a changed byte is a different skill + and carries no badge. +

+ +

+ Meanwhile the skills an agent installs today arrive with no security + signal at all — no audit, no provenance, nothing between reading a + README and running it. +

+
+ ); +} + +function Cve({ + id, + score, + name, + body, +}: { + id: string; + score: string; + name: string; + body: string; +}) { + return ( +
+

+ {id} + {score} +

+

{name}

+

{body}

+
+ ); +} + +/** A real sequence, so it is numbered. Order carries information here. */ +const STEPS = [ + { + n: "01", + title: "Register", + body: "A publisher registers a skill version against the sha256 of its files. The Registry contract refuses a hash it has already seen.", + }, + { + n: "02", + title: "Audit, three stages", + body: "Structural checks, then declared-versus-actual static analysis, then an LLM pass over the prose an agent would obey. Each stage can only make the verdict worse.", + }, + { + n: "03", + title: "Verdict on chain", + body: "Safe, Warning, Dangerous or Unaudited, plus a trust score, written to the Registry against that hash. Only Safe mints a VERIFIED badge.", + }, + { + n: "04", + title: "Pay per use", + body: "An agent calling a paid skill gets HTTP 402, pays in USDC over x402, and a soulbound licence token is minted to its address.", + }, + { + n: "05", + title: "Use", + body: "The next request carries proof of that licence and returns 200. No account, no subscription, no human in the loop.", + }, +]; + +function HowItWorks() { + return ( +
+
    + {STEPS.map((s) => ( +
  1. +

    + {s.n} +

    +

    {s.title}

    +

    {s.body}

    +
  2. + ))} +
+
+ ); +} + +function WhyStellar() { + return ( +
+

+ A verdict written on chain and pinned to the content hash{" "} + cannot be forged, a + slashable USDC bond{" "} + keeps auditors honest, and + x402{" "} + + lets an agent pay per use with no account + + . +

+ +
+ + The badge belongs to a hash, not to a name or a publisher. Change one + byte and the hash changes completely, so the new version starts again + at Unaudited. + + + An auditor locks a USDC bond in escrow before the audit. A verdict + shown to be wrong is slashed to whoever reported it, settled by the + contract rather than by us. + + + x402 turns HTTP 402 into a usable payment step. The agent pays in + USDC, receives a soulbound licence, and continues — no signup, no + card, no human. + +
+
+ ); +} + +function Point({ + title, + children, +}: { + title: string; + children: React.ReactNode; +}) { + return ( +
+

{title}

+

{children}

+
+ ); +} + +/** The section frame paints at once; only the figures inside it wait. */ +function Evidence() { + return ( +
+ }> + + +
+ ); +} + +function Proof({ stats }: { stats: Awaited> }) { + return ( + <> +
+ + + + +
+ +

+ {stats.onChain - stats.shown === stats.hiddenTest ? ( + <> + The registry holds {stats.onChain} entries; {stats.hiddenTest} are + test namespaces from our own integration runs and are filtered out + of the public list. They are not hidden: the API reports the count + on every response, and ?include_test=true{" "} + returns everything. + + ) : ( + <> + The registry holds {stats.onChain} entries, of which {stats.shown}{" "} + are listed publicly. The API reports what it filters on every + response. + + )}{" "} + {stats.live ? ( + <>Read live at page load, {stats.asOf}. + ) : ( + + The registry did not answer; these are verified figures from{" "} + {stats.asOf}. + + )} +

+ +
+ + +
+ +

+ Stellar testnet resets to genesis on 16 December 2026; links to + stellar.expert have that expiry date. +

+ + ); +} + +function Stat({ + value, + label, + tone, +}: { + value: string; + label: string; + tone?: "safe" | "danger"; +}) { + return ( +
+

+ {value} +

+

{label}

+
+ ); +} + +function EvidenceLink({ + href, + title, + body, +}: { + href: string; + title: string; + body: string; +}) { + return ( + +

+ {title} +

+

{body}

+
+ ); +} + +function Close() { + return ( +
+

+ Check a skill before your agent runs it. +

+

+ The verification API is public and needs no key. Ask by hash if you + want a security answer — asking by name trusts the name. +

+ +

+ Instawards by @StellarOrg. Sterish is an audit registry for agent + skills — not an official Stellar product, and not an app store. +

+
+ ); +} + +/** Holds the card's height so the hero does not jump when the read lands. */ +function CardSkeleton() { + return ( +
+ + + + + + + +
+ ); +} + +function StatsSkeleton() { + return ( +
+ {[0, 1, 2, 3].map((i) => ( +
+ + + +
+ ))} +
+ ); +} + +function Section({ + eyebrow, + title, + children, +}: { + eyebrow: string; + title: string; + children: React.ReactNode; +}) { + return ( +
+

+ {eyebrow} +

+

+ {title} +

+
{children}
+
+ ); +} diff --git a/frontend/src/modules/landing/component/RugPull.tsx b/frontend/src/modules/landing/component/RugPull.tsx new file mode 100644 index 0000000..1ac27e9 --- /dev/null +++ b/frontend/src/modules/landing/component/RugPull.tsx @@ -0,0 +1,173 @@ +"use client"; + +import { useState } from "react"; + +import { API_BASE_URL } from "@/lib/api"; +import { RUG_PULL_SKILL, type RugPull as RugPullData } from "../liveStats"; + +/** + * The hero, and the argument the whole page rests on. + * + * Not a headline with a gradient: the most characteristic object in this + * product's world is a skill's identity, and the thesis is that identity is + * the bytes and not the name. So the hero is the thing an agent looks at + * before installing, and the reader flips it between two versions of one real + * skill. The name does not move a pixel. The hash and the verdict do. + * + * That is CVE-2025-54136 rendered as an object rather than described: Cursor + * remembered approval under an MCP entry's NAME, so swapping what it ran + * needed no new prompt. A reader who sees the name hold still while the + * verdict flips has understood the problem and the fix in one gesture. + * + * The data is live from the registry (see liveStats.ts), and the hash is set + * large on purpose — it is the page's display type, because it is the thing + * being argued about. + */ +export function RugPull({ data }: { data: RugPullData }) { + const [poisoned, setPoisoned] = useState(false); + const shown = poisoned ? data.dangerous : data.safe; + + return ( +
+
+ {/* The name bar. Deliberately outside the flipping region: it is the + one thing that must visibly not change. */} +
+

+ Skill +

+

+ {RUG_PULL_SKILL} +

+
+ +
+
+

+ + {shown.verdict} +

+

+ v{shown.version} · trust {shown.trust_score}/100 +

+
+ +

+ content hash +

+

+ {shown.content_hash} +

+ +

+ {shown.is_verified + ? "VERIFIED badge minted. An agent may install this version." + : "No VERIFIED badge. The contract refuses to licence this version."} +

+
+ +
+ setPoisoned(false)} + label={`v${data.safe.version}`} + /> + setPoisoned(true)} + label={`v${data.dangerous.version}`} + /> + + check it yourself + +
+
+ +
+ One skill, two versions. The name never changes.{" "} + {data.live ? ( + Read live from the registry just now. + ) : ( + + The registry did not answer; showing a verified snapshot from 20 Sep + 2026. + + )} +
+
+ ); +} + +function Toggle({ + active, + onClick, + label, +}: { + active: boolean; + onClick: () => void; + label: string; +}) { + return ( + + ); +} + +/** Verdict is never colour alone (docs/brand.md §2). */ +function Glyph({ poisoned }: { poisoned: boolean }) { + return ( + + ); +} diff --git a/frontend/src/modules/landing/liveStats.test.ts b/frontend/src/modules/landing/liveStats.test.ts new file mode 100644 index 0000000..b781977 --- /dev/null +++ b/frontend/src/modules/landing/liveStats.test.ts @@ -0,0 +1,200 @@ +import { beforeEach, describe, expect, it, vi } from "vitest"; + +import type { SkillList, SkillListItem, VersionCheck } from "@/lib/types"; + +const listSkills = vi.fn(); +const checkVersion = vi.fn(); + +vi.mock("@/lib/api", () => ({ + API_BASE_URL: "https://api.example.test", + listSkills: (...args: unknown[]) => listSkills(...args), + checkVersion: (...args: unknown[]) => checkVersion(...args), +})); + +const { getLandingStats, getRugPull } = await import("./liveStats"); + +/** + * The landing page states these numbers as fact to strangers who cannot check + * them. Two failures matter more than the rest: + * + * 1. Claiming the chain holds only what we chose to show. CLAUDE.md forbids + * hiding the test namespaces silently, and the page's honesty rests on + * chain_total surviving every path through here — including the one where + * the API is too old to send it. + * 2. Printing a stale number as if it were live. The fallback must always + * arrive with live:false so the page can label it. + */ + +function skill(over: Partial = {}): SkillListItem { + return { + skill_id: "com.example.thing", + owner: "GAAA", + registered_at: 0, + version_count: 1, + latest_version: "1.0.0", + latest_audited_version: "1.0.0", + latest_audited_verdict: "SAFE", + latest_audited_trust_score: 100, + latest_audited_is_verified: true, + ...over, + }; +} + +function list(skills: SkillListItem[], over: Partial = {}): SkillList { + return { + skills, + total: skills.length, + start: 0, + limit: 100, + chain_total: skills.length, + hidden_test_entries: 0, + ...over, + }; +} + +const CATALOGUE = Array.from({ length: 13 }, (_, i) => + skill({ skill_id: `org.stellar.skills.group.item-${i}` }), +); +const POISONED = Array.from({ length: 4 }, (_, i) => + skill({ + skill_id: `com.fixtures.poisoned.bad-${i}`, + latest_audited_verdict: "DANGEROUS", + latest_audited_trust_score: 10, + latest_audited_is_verified: false, + }), +); + +beforeEach(() => { + listSkills.mockReset(); + checkVersion.mockReset(); +}); + +describe("getLandingStats", () => { + it("counts the catalogue and the poisoned fixtures separately", async () => { + listSkills.mockResolvedValue( + list([...CATALOGUE, ...POISONED], { chain_total: 23, hidden_test_entries: 6 }), + ); + const s = await getLandingStats(); + + expect(s.live).toBe(true); + expect(s.catalogue).toBe(13); + expect(s.catalogueSafe).toBe(13); + expect(s.poisoned).toBe(4); + expect(s.poisonedCaught).toBe(4); + expect(s.verified).toBe(13); + expect(s.safe).toBe(13); + expect(s.dangerous).toBe(4); + }); + + it("reports the chain total, not the filtered total", async () => { + // The whole honesty claim: 24 shown of 30 on chain, 6 filtered. + listSkills.mockResolvedValue( + list(CATALOGUE, { total: 24, chain_total: 30, hidden_test_entries: 6 }), + ); + const s = await getLandingStats(); + expect(s.shown).toBe(24); + expect(s.onChain).toBe(30); + expect(s.hiddenTest).toBe(6); + expect(s.onChain).toBeGreaterThan(s.shown); + }); + + it("never claims the chain holds exactly what is shown when the API omits the counts", async () => { + // An older API build sends no chain_total. Falling back to `total` would + // silently assert that nothing is filtered, which is the one claim this + // page must not make by accident. + const { chain_total, hidden_test_entries, ...older } = list(CATALOGUE, { + total: 13, + }); + void chain_total; + void hidden_test_entries; + listSkills.mockResolvedValue(older as SkillList); + + const s = await getLandingStats(); + expect(s.onChain).not.toBe(s.shown); + expect(s.onChain).toBe(30); // the verified snapshot figure + expect(s.hiddenTest).toBe(6); + }); + + it("falls back, labelled, when the API throws", async () => { + listSkills.mockRejectedValue(new Error("gateway down")); + const s = await getLandingStats(); + expect(s.live).toBe(false); + expect(s.asOf).toBe("2026-09-20"); + expect(s.catalogueSafe).toBe(13); + }); + + it("treats an empty registry as not-live rather than as zeros", async () => { + // Rendering "0/0 skills audited" because a read came back empty would be a + // worse lie than showing the dated snapshot. + listSkills.mockResolvedValue(list([])); + const s = await getLandingStats(); + expect(s.live).toBe(false); + expect(s.catalogue).toBe(13); + }); + + it("dates live figures today, not with the snapshot's date", async () => { + listSkills.mockResolvedValue(list(CATALOGUE)); + const s = await getLandingStats(); + expect(s.asOf).toBe(new Date().toISOString().slice(0, 10)); + }); +}); + +function check(over: Partial): VersionCheck { + return { + skill_id: "com.fixtures.demo.release-notes", + version: "1.0.0", + content_hash: "a".repeat(64), + verdict: "SAFE", + trust_score: 100, + is_verified: true, + owner: "GAAA", + auditor: "GBBB", + registered_at: 0, + audited_at: 0, + audited_at_iso: null, + ...over, + } as VersionCheck; +} + +describe("getRugPull", () => { + it("passes both versions through when the chain still tells the story", async () => { + checkVersion.mockImplementation((_id: string, version: string) => + Promise.resolve( + version === "1.0.0" + ? check({ version: "1.0.0", content_hash: "e5".repeat(32) }) + : check({ + version: "2.0.0", + content_hash: "be".repeat(32), + verdict: "DANGEROUS", + trust_score: 10, + is_verified: false, + }), + ), + ); + + const r = await getRugPull(); + expect(r.live).toBe(true); + expect(r.safe.is_verified).toBe(true); + expect(r.dangerous.is_verified).toBe(false); + // The hashes differing is the entire argument; equal hashes would mean the + // page is demonstrating nothing. + expect(r.safe.content_hash).not.toBe(r.dangerous.content_hash); + }); + + it("falls back rather than showing a story the chain no longer tells", async () => { + // If v2 were ever re-audited to SAFE, rendering it as the rug pull would + // be a claim about the chain that the chain contradicts. + checkVersion.mockResolvedValue(check({ verdict: "SAFE" })); + const r = await getRugPull(); + expect(r.live).toBe(false); + expect(r.dangerous.verdict).toBe("DANGEROUS"); + }); + + it("falls back when either read fails", async () => { + checkVersion.mockRejectedValue(new Error("timeout")); + const r = await getRugPull(); + expect(r.live).toBe(false); + expect(r.safe.verdict).toBe("SAFE"); + expect(r.dangerous.verdict).toBe("DANGEROUS"); + }); +}); diff --git a/frontend/src/modules/landing/liveStats.ts b/frontend/src/modules/landing/liveStats.ts new file mode 100644 index 0000000..2b4fc26 --- /dev/null +++ b/frontend/src/modules/landing/liveStats.ts @@ -0,0 +1,173 @@ +import { checkVersion, listSkills } from "@/lib/api"; +import type { VersionCheck } from "@/lib/types"; + +/** + * The numbers the landing page puts in front of strangers. + * + * Read from the live API at render time rather than typed into the copy. A + * landing page that claims "24 skills audited" is making a factual claim to + * people who have no way to check it except by trusting us, and a hardcoded + * number goes wrong silently the first time the registry grows. STE-23 asks + * for claims "akurat terhadap yang benar-benar live"; the only way to keep + * that promise is to not hold a copy of the answer. + * + * When the API cannot be reached the page still renders, but it says so and + * falls back to a snapshot carrying the date it was taken. A stale number + * labelled stale is honest; a stale number presented as live is not. + */ + +/** The rug pull the whole page is built around. Real, on chain, checkable. */ +export const RUG_PULL_SKILL = "com.fixtures.demo.release-notes"; + +/** + * Verified against the live API on 2026-09-20. Used only when the API is + * unreachable, and always rendered with its date attached. + */ +const SNAPSHOT: Omit = { + asOf: "2026-09-20", + shown: 24, + onChain: 30, + hiddenTest: 6, + safe: 17, + warning: 2, + dangerous: 5, + verified: 17, + catalogue: 13, + catalogueSafe: 13, + poisoned: 4, + poisonedCaught: 4, +}; + +export type LandingStats = { + /** Date the figures describe: today when live, the snapshot's date when not. */ + asOf: string; + /** Listed publicly, after the test-namespace filter. */ + shown: number; + /** Everything the Registry holds, filtered or not. */ + onChain: number; + /** Test-namespace entries the API filtered out, reported rather than hidden. */ + hiddenTest: number; + safe: number; + warning: number; + dangerous: number; + verified: number; + /** org.stellar.skills.* — the official catalogue. */ + catalogue: number; + catalogueSafe: number; + /** com.fixtures.poisoned.* — the fixtures the gate must catch. */ + poisoned: number; + poisonedCaught: number; + /** False when the API did not answer and the snapshot is being shown. */ + live: boolean; +}; + +export type RugPull = { + live: boolean; + safe: Pick & { + verdict: string; + is_verified: boolean; + }; + dangerous: Pick & { + verdict: string; + is_verified: boolean; + }; +}; + +const RUG_PULL_SNAPSHOT: RugPull = { + live: false, + safe: { + version: "1.0.0", + content_hash: + "e5da489eb751e96fb30bb622602b8ab471de4898f333028aeeb7a36211d341f5", + verdict: "SAFE", + trust_score: 100, + is_verified: true, + }, + dangerous: { + version: "2.0.0", + content_hash: + "befb592d3cb1afa4c471a7c4ddf2666f1c6ebd0364e76977ecd294be7c01653d", + verdict: "DANGEROUS", + trust_score: 10, + is_verified: false, + }, +}; + +/** Derived here rather than in the view, so the copy cannot disagree with it. */ +export async function getLandingStats(): Promise { + try { + // The API clamps limit to 100; the registry is well under that. `total`, + // `chain_total` and `hidden_test_entries` come straight off the response. + const list = await listSkills({ limit: 100 }); + const skills = list.skills ?? []; + if (skills.length === 0) return { ...SNAPSHOT, live: false }; + + const by = (v: string) => + skills.filter((s) => s.latest_audited_verdict === v).length; + const catalogue = skills.filter((s) => + s.skill_id.startsWith("org.stellar.skills."), + ); + const poisoned = skills.filter((s) => + s.skill_id.startsWith("com.fixtures.poisoned."), + ); + + return { + asOf: new Date().toISOString().slice(0, 10), + shown: list.total ?? skills.length, + // Absent on older API builds; falling back to `total` would claim the + // chain holds exactly what is shown, which is the one thing it must not. + onChain: list.chain_total ?? SNAPSHOT.onChain, + hiddenTest: list.hidden_test_entries ?? SNAPSHOT.hiddenTest, + safe: by("SAFE"), + warning: by("WARNING"), + dangerous: by("DANGEROUS"), + verified: skills.filter((s) => s.latest_audited_is_verified).length, + catalogue: catalogue.length, + catalogueSafe: catalogue.filter( + (s) => s.latest_audited_verdict === "SAFE", + ).length, + poisoned: poisoned.length, + poisonedCaught: poisoned.filter( + (s) => s.latest_audited_verdict === "DANGEROUS", + ).length, + live: true, + }; + } catch { + return { ...SNAPSHOT, live: false }; + } +} + +/** Both versions of the rug pull, fetched together so they cannot disagree. */ +export async function getRugPull(): Promise { + try { + const [v1, v2] = await Promise.all([ + checkVersion(RUG_PULL_SKILL, "1.0.0"), + checkVersion(RUG_PULL_SKILL, "2.0.0"), + ]); + // The point only lands if the chain still says what we claim it says. If + // the verdicts ever stop being SAFE and DANGEROUS, showing the snapshot + // is wrong too — so fall back and let the page label it. + if (v1.verdict !== "SAFE" || v2.verdict !== "DANGEROUS") { + return RUG_PULL_SNAPSHOT; + } + return { + live: true, + safe: { + version: v1.version, + content_hash: v1.content_hash, + verdict: v1.verdict, + trust_score: v1.trust_score, + is_verified: v1.is_verified, + }, + dangerous: { + version: v2.version, + content_hash: v2.content_hash, + verdict: v2.verdict, + trust_score: v2.trust_score, + is_verified: v2.is_verified, + }, + }; + } catch { + return RUG_PULL_SNAPSHOT; + } +}