Skip to content

Achievement badge system — unlock badges#358

Open
clintjeff2 wants to merge 5 commits into
Bitcoindefi:mainfrom
clintjeff2:Achievement-badge-system-—-unlock-badges

Hidden character warning

The head ref may contain hidden characters: "Achievement-badge-system-\u2014-unlock-badges"
Open

Achievement badge system — unlock badges#358
clintjeff2 wants to merge 5 commits into
Bitcoindefi:mainfrom
clintjeff2:Achievement-badge-system-—-unlock-badges

Conversation

@clintjeff2

Copy link
Copy Markdown
Contributor

Motivation

  • Introduce a gamified achievement system so agents can unlock badges for milestones (tasks, payments, uptime, etc.) and surface them in the UI and real-time event stream.
  • Keep badge logic decoupled from producers by hooking into the existing system event bus so unlocks are discovered automatically for relevant events.
  • Provide a simple in-memory catalog and per-agent badge store for quick iteration and unit testing.

Description

  • Added a badge engine and catalog in lib/gamification/badges.ts that tracks per-agent progress, evaluates unlock conditions, persists unlocked badges in-memory, and emits badge.unlocked system events when appropriate.
  • Integrated the badge processor into the core event flow by invoking processBadgeEvent() from lib/events/system-events.ts after publishing non-badge events so badge checks run automatically.
  • Exposed HTTP endpoints GET /api/badges and GET /api/agents/:id/badges that return the full catalog and an agent's unlocked badges respectively (app/api/badges/route.ts, app/api/agents/[id]/badges/route.ts).
  • Added UI components and wiring: components/badges-panel.tsx and a new Badges sidebar tab (hooked in components/sidebar-panel.tsx) plus runtime state updates in components/open-stellar/open-stellar-hub.tsx to show unlock overlays/toasts/particles when badges unlock.
  • Updated types and agent fixtures: added AgentBadge type to lib/types.ts and initialized badges: [] in lib/data.ts so agents can hold unlocked badges.
  • Added unit tests for the badge engine in lib/gamification/badges.test.ts covering initial unlock, repeated unlock prevention, milestone progression and multi-tasker detection.

Testing

  • Ran the badge unit tests with npm test -- lib/gamification/badges.test.ts and they passed (4 tests).
  • Ran integration checks npm test -- __tests__/api/events.test.ts lib/gamification/badges.test.ts and those passed (8 tests across the two files).
  • Ran the full test suite with npm test; this failed due to 3 pre-existing task-drain tests unrelated to the badge changes (failures stem from queue/pending caps and an existing test timing/destructuring assumption), so those require a separate fix in the task-queue/test expectations.
  • Lint (npm run lint) and typecheck (npx tsc --noEmit) were executed and surfaced pre-existing lint/type issues in unrelated parts of the repo (e.g., app/offline/page.tsx, lib/passport/validator-client.ts, and a missing @wagmi/connectors typing); these were not introduced by the badge changes.

Closes #33

clintjeff2 and others added 5 commits June 27, 2026 08:18
Add achievement badge system (catalog, engine, API, UI, SSE integration)
- Update Next.js Route Handlers to use Promise for params (Next.js 15+ requirement).
- Install missing peer dependencies @base-org/account and @metamask/connect-evm for @wagmi/connectors.
- Fix ESLint errors: unescaped entities in OfflinePage and unsafe declaration merging/ts-ignore in validator-client.
- Ensure all CI checks (Typecheck, tests, build, lint, size-limit, secret scan) pass.

Co-authored-by: clintjeff2 <119521983+clintjeff2@users.noreply.github.com>
…134008

Fix CI failures (Typecheck, Build, and Lint)
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Achievement badge system — unlock badges for milestones

1 participant