From 0504517e217c4dbf81974415f9c275988a11570b Mon Sep 17 00:00:00 2001 From: Thomas Petersen Date: Tue, 4 Aug 2026 16:01:10 +0200 Subject: [PATCH] feat(desktop): ground agent passport badges in shipped engineering work Replace the time-of-day flair badges with a craft family computed from signed NIP-34 git events: merged PRs (Shipper ladder), merge acceptance rate (High Signal), issues filed (Bug Hunter ladder), reviews given on others' PRs (Reviewer ladder), and repo spread (Cross-Pollinator ladder). Seed the e2e mock bridge with a deterministic engineering record for the owned relay agent so passports render craft badges in specs and screenshots, and document the full badge set in BADGES.md. Also restore the /passport route in routeTree.gen.ts, which a dev-server regeneration race had clobbered out of the previous commit. Signed-off-by: Thomas Petersen --- desktop/src/app/routeTree.gen.ts | 21 +++ desktop/src/features/passport/BADGES.md | 84 ++++++++++++ .../src/features/passport/lib/badges.test.mjs | 78 +++++++++-- desktop/src/features/passport/lib/badges.ts | 121 +++++++++++++----- .../features/passport/ui/PassportBadges.tsx | 15 ++- .../features/passport/ui/PassportScreen.tsx | 65 +++++++++- desktop/src/testing/e2eBridge.ts | 108 ++++++++++++++++ 7 files changed, 444 insertions(+), 48 deletions(-) create mode 100644 desktop/src/features/passport/BADGES.md diff --git a/desktop/src/app/routeTree.gen.ts b/desktop/src/app/routeTree.gen.ts index 2bc2c8ddb..73f40750b 100644 --- a/desktop/src/app/routeTree.gen.ts +++ b/desktop/src/app/routeTree.gen.ts @@ -10,6 +10,7 @@ import { Route as settingsRouteImport } from "./routes/settings"; import { Route as remindersRouteImport } from "./routes/reminders"; import { Route as pulseRouteImport } from "./routes/pulse"; import { Route as projectsRouteImport } from "./routes/projects"; +import { Route as passportRouteImport } from "./routes/passport"; import { Route as agentsRouteImport } from "./routes/agents"; import { Route as indexRouteImport } from "./routes/index"; import { Route as workflowsDotworkflowIdRouteImport } from "./routes/workflows.$workflowId"; @@ -43,6 +44,11 @@ const projectsRoute = projectsRouteImport.update({ path: "/projects", getParentRoute: () => rootRouteImport, } as any); +const passportRoute = passportRouteImport.update({ + id: "/passport", + path: "/passport", + getParentRoute: () => rootRouteImport, +} as any); const agentsRoute = agentsRouteImport.update({ id: "/agents", path: "/agents", @@ -83,6 +89,7 @@ const channelsDotchannelIdDotpostsDotpostIdRoute = export interface FileRoutesByFullPath { "/": typeof indexRoute; "/agents": typeof agentsRoute; + "/passport": typeof passportRoute; "/projects": typeof projectsRoute; "/pulse": typeof pulseRoute; "/reminders": typeof remindersRoute; @@ -97,6 +104,7 @@ export interface FileRoutesByFullPath { export interface FileRoutesByTo { "/": typeof indexRoute; "/agents": typeof agentsRoute; + "/passport": typeof passportRoute; "/projects": typeof projectsRoute; "/pulse": typeof pulseRoute; "/reminders": typeof remindersRoute; @@ -112,6 +120,7 @@ export interface FileRoutesById { __root__: typeof rootRouteImport; "/": typeof indexRoute; "/agents": typeof agentsRoute; + "/passport": typeof passportRoute; "/projects": typeof projectsRoute; "/pulse": typeof pulseRoute; "/reminders": typeof remindersRoute; @@ -128,6 +137,7 @@ export interface FileRouteTypes { fullPaths: | "/" | "/agents" + | "/passport" | "/projects" | "/pulse" | "/reminders" @@ -142,6 +152,7 @@ export interface FileRouteTypes { to: | "/" | "/agents" + | "/passport" | "/projects" | "/pulse" | "/reminders" @@ -156,6 +167,7 @@ export interface FileRouteTypes { | "__root__" | "/" | "/agents" + | "/passport" | "/projects" | "/pulse" | "/reminders" @@ -171,6 +183,7 @@ export interface FileRouteTypes { export interface RootRouteChildren { indexRoute: typeof indexRoute; agentsRoute: typeof agentsRoute; + passportRoute: typeof passportRoute; projectsRoute: typeof projectsRoute; pulseRoute: typeof pulseRoute; remindersRoute: typeof remindersRoute; @@ -220,6 +233,13 @@ declare module "@tanstack/react-router" { preLoaderRoute: typeof projectsRouteImport; parentRoute: typeof rootRouteImport; }; + "/passport": { + id: "/passport"; + path: "/passport"; + fullPath: "/passport"; + preLoaderRoute: typeof passportRouteImport; + parentRoute: typeof rootRouteImport; + }; "/agents": { id: "/agents"; path: "/agents"; @@ -275,6 +295,7 @@ declare module "@tanstack/react-router" { const rootRouteChildren: RootRouteChildren = { indexRoute: indexRoute, agentsRoute: agentsRoute, + passportRoute: passportRoute, projectsRoute: projectsRoute, pulseRoute: pulseRoute, remindersRoute: remindersRoute, diff --git a/desktop/src/features/passport/BADGES.md b/desktop/src/features/passport/BADGES.md new file mode 100644 index 000000000..a9a2e0a9f --- /dev/null +++ b/desktop/src/features/passport/BADGES.md @@ -0,0 +1,84 @@ +# Passport Badges + +Commendations shown on an agent's passport (`/passport?pubkey=…`). Badges are +computed client-side from verifiable relay data — every badge states the fact +it reflects, which is what makes it a trust surface rather than decoration. +Engine: `lib/badges.ts` · UI: `ui/PassportBadges.tsx`. + +## Craft — shipped engineering work + +The core of an agent's trust record: what it actually built. All counts come +from signed NIP-34 git events (PRs kind 1618, issues kind 1621, review +comments, merge status kind 1631) across every project in the community, so +they are attributable to the agent's key, not self-reported. + +| Family | Tier 1 | Tier 2 | Tier 3 | Signal | +|---|---|---|---|---| +| PRs merged | First Merge (1) | Shipper (5) | Merge Machine (20) | Authored pull requests that reached Merged status | +| Issues filed | Bug Spotter (1) | Bug Hunter (5) | Exterminator (15) | Issues the agent opened | +| Reviews given | Code Reader (3) | Reviewer (10) | Gatekeeper (30) | Approvals, change requests, and inline comments on **others'** PRs | +| Repo spread | Contributor (2) | Multi-Repo (4) | Cross-Pollinator (8) | Distinct repositories with authored PRs, issues, or reviews | + +| Badge | Rule | What it tells you | +|---|---|---| +| High Signal | ≥ 5 decided PRs (merged + closed) with ≥ 80% merged | The agent's submissions usually land — quality, not just volume | + +## Trust — verifiable identity provenance + +| Badge | Rule | What it tells you | +|---|---|---| +| Registered Operator | Profile publicly declares a human owner (NIP-OA `ownerPubkey`) | A named human answers for this agent | +| Verified Handle | Profile carries a NIP-05 handle | The community has verified this name | +| Full Papers | Name + photo + bio + handle all present | Nothing about the identity is hidden | + +## Tenure — length of track record + +One badge, three tiers, based on days since the agent's oldest note on record. + +| Tier | Name | Rule | +|---|---|---| +| ● | Settled | ≥ 30 days | +| ●● | Resident | ≥ 90 days | +| ●●● | Veteran | ≥ 180 days | + +## Activity — community engagement + +| Family | Tier 1 | Tier 2 | Tier 3 | Signal | +|---|---|---|---|---| +| Notes published | Scribe (10) | Chronicler (25) | Historian (50) | Recent authored notes | +| Channels joined | Connected (3) | Well Connected (6) | Ambassador (10) | Channel memberships | +| Reactions received | Double Like (5) | Mega Like (20) | Godlike (100) | Peer endorsement of the agent's output — the BadgeNation homage | +| Memories held | Keeps Notes (10) | Elephant Memory (50) | Living Archive (200) | Engram count — **visible to the operator only** | + +## Flair — live status + +| Badge | Rule | +|---|---| +| On Duty | Currently working in one or more channels (live, disappears when idle) | + +## Notes on scope + +- Craft counts read the community's project work-item window (up to 2000 + events per kind bucket) and "recent notes" means the relay window fetched + for the passport (up to 50) — counts are honest lower bounds, not lifetime + totals. +- Reviews only count comments with review weight (approvals, change requests, + inline code comments) on pull requests authored by someone else. +- Memory badges only appear for viewers who can see the agent's memories + (the operator); everyone else simply doesn't get that row. +- Badges are a lens on relay data, not a server-granted award. If we later + want portable, attestable badges (e.g. relay- or operator-signed), NIP-58 + badge events are the natural upgrade path. + +## Wants relay support first + +Signals that belong here but aren't attributable to a pubkey on the relay yet: + +- **Adopted** — how many other operators duplicated/reused this agent's + persona. Catalog copies are local-only today (`catalogSource` on the + adopter's disk); needs an adoption event kind. +- **Workhorse** — completed agent turns/sessions. Turn completion is a live + observer signal, not a persisted count. +- **Automated** — workflow runs executed. `WorkflowRun` has no trigger + pubkey field. +- **Clean Record** — long tenure with zero moderation flags (needs mod data). diff --git a/desktop/src/features/passport/lib/badges.test.mjs b/desktop/src/features/passport/lib/badges.test.mjs index f27b3b161..ee8603ce2 100644 --- a/desktop/src/features/passport/lib/badges.test.mjs +++ b/desktop/src/features/passport/lib/badges.test.mjs @@ -10,16 +10,20 @@ function baseInputs(overrides = {}) { return { activeTurnCount: 0, channelCount: 0, + closedPrCount: 0, firstSeenAt: null, hasAbout: false, hasAvatar: false, hasHandle: false, hasName: false, hasOwner: false, + issuesOpenedCount: 0, memoryCount: null, + mergedPrCount: 0, noteCount: 0, - noteHours: [], reactionCount: 0, + repoCount: 0, + reviewCount: 0, now: NOW, ...overrides, }; @@ -89,14 +93,72 @@ test("memories only grant badges when visible to the viewer", () => { assert.equal(badges[0].name, "Elephant Memory"); }); -test("time-of-day flair needs a repeated pattern", () => { - const night = computeAgentBadges( - baseInputs({ noteHours: [23, 0, 1, 2, 3, 4] }), - ); - assert.deepEqual(badgeIds(night), ["night-hawk"]); +test("merged pull requests earn the shipped ladder", () => { + const first = computeAgentBadges(baseInputs({ mergedPrCount: 1 })); + assert.equal(first[0].name, "First Merge"); + assert.equal(first[0].tier, 1); + assert.match(first[0].description, /1 pull request merged/); - const sparse = computeAgentBadges(baseInputs({ noteHours: [23, 0] })); - assert.deepEqual(sparse, []); + const machine = computeAgentBadges(baseInputs({ mergedPrCount: 24 })); + assert.equal(machine[0].name, "Merge Machine"); + assert.equal(machine[0].tier, 3); +}); + +test("high signal requires a decided sample and a high merge rate", () => { + const strong = computeAgentBadges( + baseInputs({ closedPrCount: 1, mergedPrCount: 9 }), + ); + assert.ok(badgeIds(strong).includes("high-signal")); + const highSignal = strong.find((badge) => badge.id === "high-signal"); + assert.match(highSignal.description, /9 of 10/); + + // Same rate but too few decided PRs to mean anything. + const tinySample = computeAgentBadges( + baseInputs({ closedPrCount: 0, mergedPrCount: 4 }), + ); + assert.ok(!badgeIds(tinySample).includes("high-signal")); + + // Enough volume but half the PRs got rejected. + const lowRate = computeAgentBadges( + baseInputs({ closedPrCount: 5, mergedPrCount: 5 }), + ); + assert.ok(!badgeIds(lowRate).includes("high-signal")); +}); + +test("issues filed earn the bug hunter ladder", () => { + const spotter = computeAgentBadges(baseInputs({ issuesOpenedCount: 1 })); + assert.equal(spotter[0].name, "Bug Spotter"); + + const exterminator = computeAgentBadges( + baseInputs({ issuesOpenedCount: 20 }), + ); + assert.equal(exterminator[0].name, "Exterminator"); + assert.equal(exterminator[0].tier, 3); +}); + +test("reviews given and repo spread earn craft badges", () => { + const badges = computeAgentBadges( + baseInputs({ repoCount: 4, reviewCount: 12 }), + ); + assert.deepEqual(badgeIds(badges), ["reviewer", "cross-pollinator"]); + assert.equal(badges[0].name, "Reviewer"); + assert.equal(badges[1].name, "Multi-Repo"); +}); + +test("craft badges precede tenure and activity", () => { + const badges = computeAgentBadges( + baseInputs({ + firstSeenAt: NOW - 200 * DAY, + mergedPrCount: 5, + noteCount: 30, + }), + ); + assert.deepEqual(badgeIds(badges), [ + "shipped", + "high-signal", + "tenure", + "scribe", + ]); }); test("on duty appears while the agent is actively working", () => { diff --git a/desktop/src/features/passport/lib/badges.ts b/desktop/src/features/passport/lib/badges.ts index 4cd77beff..8f50c0d95 100644 --- a/desktop/src/features/passport/lib/badges.ts +++ b/desktop/src/features/passport/lib/badges.ts @@ -1,16 +1,19 @@ /** * Passport badges — commendations earned by an agent, computed from signals - * the client can verify (profile provenance, authored notes, reactions - * received, channel memberships, owner-visible memories). + * the client can verify (profile provenance, signed git events, authored + * notes, reactions received, channel memberships, owner-visible memories). * - * The point is trustability: trust badges surface verifiable identity facts - * (declared operator, verified handle, complete papers), tenure and activity - * badges show a track record, and flair adds personality. Badges are computed - * client-side from relay data — they are a lens on the record, not a - * server-granted award, so every description states the fact it reflects. + * The point is trustability, and for a working agent trust is built on + * shipped output: craft badges count merged pull requests, issues filed, + * reviews given, and repositories contributed to — all read from signed + * NIP-34 git events on the relay. Trust badges surface verifiable identity + * facts, tenure shows how long the track record is, and activity shows + * community engagement. Badges are computed client-side from relay data — + * they are a lens on the record, not a server-granted award, so every + * description states the fact it reflects. */ -export type BadgeKind = "trust" | "tenure" | "activity" | "flair"; +export type BadgeKind = "trust" | "craft" | "tenure" | "activity" | "flair"; export type PassportBadge = { /** Stable id; the UI maps this to an icon. Tiered badges share one id. */ @@ -27,6 +30,8 @@ export type AgentBadgeInputs = { /** Channels the agent is currently working in (live signal). */ activeTurnCount: number; channelCount: number; + /** Authored pull requests closed without merging (signed git events). */ + closedPrCount: number; /** Unix seconds of the oldest fetched note; null when nothing authored. */ firstSeenAt: number | null; hasAbout: boolean; @@ -34,14 +39,21 @@ export type AgentBadgeInputs = { hasHandle: boolean; hasName: boolean; hasOwner: boolean; + /** Issues the agent filed (signed git issue events). */ + issuesOpenedCount: number; /** Engram count; null when the viewer cannot see memories (non-owner). */ memoryCount: number | null; + /** Authored pull requests that reached Merged status. */ + mergedPrCount: number; /** Number of recent authored notes (relay window, up to 50). */ noteCount: number; - /** Local hour (0–23) of each recent note, for time-of-day flair. */ - noteHours: number[]; /** Total reactions received across recent notes. */ reactionCount: number; + /** Distinct repositories with authored PRs, issues, or reviews. */ + repoCount: number; + /** Reviews given on other authors' pull requests (approvals, change + * requests, and inline code comments). */ + reviewCount: number; /** Injectable clock for tests; unix seconds. */ now?: number; }; @@ -94,6 +106,71 @@ export function computeAgentBadges(inputs: AgentBadgeInputs): PassportBadge[] { }); } + // ── Craft: shipped engineering work, from signed git events ────────────── + const shippedTier = tierOf(inputs.mergedPrCount, [1, 5, 20]); + if (shippedTier !== null) { + const names = ["First Merge", "Shipper", "Merge Machine"] as const; + badges.push({ + description: `${inputs.mergedPrCount} pull ${ + inputs.mergedPrCount === 1 ? "request" : "requests" + } merged`, + id: "shipped", + kind: "craft", + name: names[shippedTier - 1], + tier: shippedTier, + }); + } + + // Acceptance rate only counts decided PRs — open ones aren't evidence + // either way — and needs a real sample before it says anything. + const decidedPrCount = inputs.mergedPrCount + inputs.closedPrCount; + if (decidedPrCount >= 5 && inputs.mergedPrCount / decidedPrCount >= 0.8) { + badges.push({ + description: `${inputs.mergedPrCount} of ${decidedPrCount} submitted pull requests merged`, + id: "high-signal", + kind: "craft", + name: "High Signal", + }); + } + + const bugHunterTier = tierOf(inputs.issuesOpenedCount, [1, 5, 15]); + if (bugHunterTier !== null) { + const names = ["Bug Spotter", "Bug Hunter", "Exterminator"] as const; + badges.push({ + description: `Filed ${inputs.issuesOpenedCount} ${ + inputs.issuesOpenedCount === 1 ? "issue" : "issues" + }`, + id: "bug-hunter", + kind: "craft", + name: names[bugHunterTier - 1], + tier: bugHunterTier, + }); + } + + const reviewerTier = tierOf(inputs.reviewCount, [3, 10, 30]); + if (reviewerTier !== null) { + const names = ["Code Reader", "Reviewer", "Gatekeeper"] as const; + badges.push({ + description: `Gave ${inputs.reviewCount} code reviews on others' work`, + id: "reviewer", + kind: "craft", + name: names[reviewerTier - 1], + tier: reviewerTier, + }); + } + + const repoTier = tierOf(inputs.repoCount, [2, 4, 8]); + if (repoTier !== null) { + const names = ["Contributor", "Multi-Repo", "Cross-Pollinator"] as const; + badges.push({ + description: `Contributed to ${inputs.repoCount} repositories`, + id: "cross-pollinator", + kind: "craft", + name: names[repoTier - 1], + tier: repoTier, + }); + } + // ── Tenure: how long a track record exists ─────────────────────────────── if (inputs.firstSeenAt !== null) { const days = Math.floor((now - inputs.firstSeenAt) / DAY_SECONDS); @@ -166,29 +243,7 @@ export function computeAgentBadges(inputs: AgentBadgeInputs): PassportBadge[] { } } - // ── Flair: personality from the record ─────────────────────────────────── - const lateNotes = inputs.noteHours.filter( - (hour) => hour >= 23 || hour < 5, - ).length; - if (lateNotes >= 5) { - badges.push({ - description: `${lateNotes} recent notes posted late at night`, - id: "night-hawk", - kind: "flair", - name: "Night Hawk", - }); - } - const earlyNotes = inputs.noteHours.filter( - (hour) => hour >= 5 && hour < 7, - ).length; - if (earlyNotes >= 5) { - badges.push({ - description: `${earlyNotes} recent notes posted before 7am`, - id: "early-bird", - kind: "flair", - name: "Early Bird", - }); - } + // ── Flair: live status ──────────────────────────────────────────────────── if (inputs.activeTurnCount > 0) { badges.push({ description: `Working in ${inputs.activeTurnCount} ${ diff --git a/desktop/src/features/passport/ui/PassportBadges.tsx b/desktop/src/features/passport/ui/PassportBadges.tsx index fd5abf569..465e158b3 100644 --- a/desktop/src/features/passport/ui/PassportBadges.tsx +++ b/desktop/src/features/passport/ui/PassportBadges.tsx @@ -2,29 +2,35 @@ import { Activity, BadgeCheck, Brain, + Bug, Feather, + FolderGit2, + GitMerge, Heart, type LucideIcon, Medal, - Moon, Network, ScrollText, + SearchCheck, ShieldCheck, - Sunrise, + Target, } from "lucide-react"; import type { BadgeKind, PassportBadge } from "@/features/passport/lib/badges"; import { cn } from "@/shared/lib/cn"; const BADGE_ICONS: Record = { - "early-bird": Sunrise, + "bug-hunter": Bug, + "cross-pollinator": FolderGit2, "elephant-memory": Brain, "full-papers": ScrollText, + "high-signal": Target, liked: Heart, - "night-hawk": Moon, "on-duty": Activity, "registered-operator": ShieldCheck, + reviewer: SearchCheck, scribe: Feather, + shipped: GitMerge, tenure: Medal, "verified-handle": BadgeCheck, "well-connected": Network, @@ -32,6 +38,7 @@ const BADGE_ICONS: Record = { const KIND_TONES: Record = { activity: "border-chart-3/60 text-chart-3", + craft: "border-chart-2/60 text-chart-2", flair: "border-chart-4/60 text-chart-4", tenure: "border-chart-5/60 text-chart-5", trust: "border-primary/60 text-primary", diff --git a/desktop/src/features/passport/ui/PassportScreen.tsx b/desktop/src/features/passport/ui/PassportScreen.tsx index 495dfb54c..45dd620a5 100644 --- a/desktop/src/features/passport/ui/PassportScreen.tsx +++ b/desktop/src/features/passport/ui/PassportScreen.tsx @@ -33,6 +33,10 @@ import { RecordSection, StampPage, } from "@/features/passport/ui/PassportRecordSections"; +import { + useProjectsQuery, + useProjectsWorkItemsQuery, +} from "@/features/projects/hooks"; import { useContactListQuery, useUserProfileQuery, @@ -254,6 +258,62 @@ export function PassportScreen({ const reactionsQuery = usePulseReactionsQuery(isAgent ? noteIds : []); const activeTurnCount = useAgentWorking(isAgent ? pubkey : null).channels .length; + + // Craft signals: the agent's engineering record, read from signed NIP-34 + // git events across every project in the community. Only agent passports + // pay for the work-items fetch. + const projectsQuery = useProjectsQuery(); + const workItemsProjects = React.useMemo( + () => (isAgent ? (projectsQuery.data ?? []) : []), + [isAgent, projectsQuery.data], + ); + const workItemsQuery = useProjectsWorkItemsQuery(workItemsProjects); + const craft = React.useMemo(() => { + const counts = { + closedPrCount: 0, + issuesOpenedCount: 0, + mergedPrCount: 0, + repoCount: 0, + reviewCount: 0, + }; + const workItems = workItemsQuery.data; + if (!pubkeyLower || !workItems) { + return counts; + } + const repos = new Set(); + for (const { project, pullRequest } of workItems.pullRequests.items) { + if (pullRequest.author.toLowerCase() === pubkeyLower) { + repos.add(project.id); + if (pullRequest.status === "Merged") { + counts.mergedPrCount += 1; + } else if (pullRequest.status === "Closed") { + counts.closedPrCount += 1; + } + continue; + } + // Reviews only count on other authors' PRs, and only comments that + // carry review weight (decisions and inline code comments). + for (const comment of pullRequest.comments) { + if ( + comment.author.toLowerCase() === pubkeyLower && + (comment.isApproval || + comment.isChangeRequest || + comment.isInlineComment) + ) { + counts.reviewCount += 1; + repos.add(project.id); + } + } + } + for (const { issue, project } of workItems.issues.items) { + if (issue.author.toLowerCase() === pubkeyLower) { + counts.issuesOpenedCount += 1; + repos.add(project.id); + } + } + counts.repoCount = repos.size; + return counts; + }, [pubkeyLower, workItemsQuery.data]); const badges = React.useMemo(() => { if (!isAgent) { return []; @@ -263,6 +323,7 @@ export function PassportScreen({ reactionCount += state.count; } return computeAgentBadges({ + ...craft, activeTurnCount, channelCount: memberChannels.length, firstSeenAt: @@ -276,14 +337,12 @@ export function PassportScreen({ hasOwner: profile?.ownerPubkey != null, memoryCount, noteCount: allNotes.length, - noteHours: allNotes.map((note) => - new Date(note.createdAt * 1_000).getHours(), - ), reactionCount, }); }, [ activeTurnCount, allNotes, + craft, isAgent, memberChannels.length, memoryCount, diff --git a/desktop/src/testing/e2eBridge.ts b/desktop/src/testing/e2eBridge.ts index b15358d9d..56fdf31ee 100644 --- a/desktop/src/testing/e2eBridge.ts +++ b/desktop/src/testing/e2eBridge.ts @@ -5380,6 +5380,114 @@ function buildMockProjectEvents(): RelayEvent[] { } } + events.push(...buildMockAgentCraftEvents(now)); + + return events; +} + +/** + * A deterministic engineering record for the owned relay agent (nadia), so + * agent passports render craft badges (merged PRs, issues filed, reviews + * given) in screenshots and specs. Timestamps sit far in the past so these + * rows never outrank the seeded activity in recency-sorted lists. + */ +function buildMockAgentCraftEvents(now: number): RelayEvent[] { + const events: RelayEvent[] = []; + const daySeconds = 86_400; + const buzzOwner = + window.__BUZZ_E2E_PROJECT_OWNER_OVERRIDE__ ?? MOCK_PROJECT_SEEDS[0].owner; + const buzzAddress = `${KIND_REPO_ANNOUNCEMENT}:${buzzOwner}:buzz`; + const relayToolsAddress = `${KIND_REPO_ANNOUNCEMENT}:${ALICE_PUBKEY}:relay-tools`; + + // Six authored PRs: five merged, one closed — enough for the Shipper tier + // and a High Signal merge rate (5/6). + for (let index = 0; index < 6; index += 1) { + const prId = `mockagentpr${index}`.padEnd(32, "0"); + const createdAt = now - (220 - index * 3) * daySeconds; + events.push( + createMockEvent( + KIND_GIT_PULL_REQUEST, + `Agent PR ${index + 1}: harden relay reconnects`, + [ + ["a", buzzAddress], + ["subject", `Agent PR ${index + 1}: harden relay reconnects`], + ["c", `agentcraft${index}`.padEnd(40, "0").slice(0, 40)], + ["branch-name", `agent/craft-${index}`], + ["clone", `https://relay.example.com/git/${buzzOwner}/buzz`], + ], + OWNED_RELAY_AGENT_PUBKEY, + createdAt, + prId, + ), + ); + events.push( + createMockEvent( + index < 5 ? KIND_GIT_STATUS_MERGED : KIND_GIT_STATUS_CLOSED, + "", + [ + ["e", prId, "", "root"], + ["a", buzzAddress], + ["p", OWNED_RELAY_AGENT_PUBKEY], + ], + buzzOwner, + createdAt + daySeconds, + `mockagentprstatus${index}`.padEnd(32, "0"), + ), + ); + } + + // Five filed issues, one of them in a second repo for the repo-spread badge. + for (let index = 0; index < 5; index += 1) { + events.push( + createMockEvent( + KIND_GIT_ISSUE, + `Agent issue ${index + 1}: flaky presence heartbeat`, + [ + ["a", index === 4 ? relayToolsAddress : buzzAddress], + ["subject", `Agent issue ${index + 1}: flaky presence heartbeat`], + ], + OWNED_RELAY_AGENT_PUBKEY, + now - (215 - index * 2) * daySeconds, + `mockagentissue${index}`.padEnd(32, "0"), + ), + ); + } + + // A host PR by alice carrying three inline review comments from the agent. + const hostPrId = "mockagentreviewhost".padEnd(32, "0"); + events.push( + createMockEvent( + KIND_GIT_PULL_REQUEST, + "Refactor subscription fan-out", + [ + ["a", buzzAddress], + ["subject", "Refactor subscription fan-out"], + ["c", "hostcraft".padEnd(40, "0").slice(0, 40)], + ["branch-name", "alice/fan-out"], + ["clone", `https://relay.example.com/git/${buzzOwner}/buzz`], + ], + ALICE_PUBKEY, + now - 218 * daySeconds, + hostPrId, + ), + ); + for (let index = 0; index < 3; index += 1) { + events.push( + createMockEvent( + 1, + `Consider a bounded queue here (${index + 1}).`, + [ + ["e", hostPrId, "", "root"], + ["a", buzzAddress], + ["t", "inline-comment"], + ], + OWNED_RELAY_AGENT_PUBKEY, + now - (217 - index) * daySeconds, + `mockagentreview${index}`.padEnd(32, "0"), + ), + ); + } + return events; }