Skip to content

LOCAL: serve the TeamClaude day leaderboard over teamclaude.leaderboard - #68

Merged
kiwidream merged 2 commits into
swaplabs/mainfrom
kiwidream/tcl-service
Oct 28, 2026
Merged

kiwidream merged 2 commits into
swaplabs/mainfrom
kiwidream/tcl-service

Conversation

@kiwidream

@kiwidream kiwidream commented Oct 28, 2026 •

Copy link
Copy Markdown
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​477 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​477
Prod 12 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​675 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​675

ELI5

This is the data behind #67's leaderboard. On a minidev with TeamClaude, Orca asks the TeamClaude coordinator for everyone's token use today, merges each person's VMs into one score, ranks them and hands the sidebar a small, safe board. It never sends the key or the coordinator's raw data to the UI.

What Changed

The runtime host (the minidev's Orca main process) gains a TeamClaude leaderboard service, src/main/teamclaude-leaderboard/, exposed as the read-only runtime RPC teamclaude.leaderboard. The renderer client (runtime-teamclaude-leaderboard-client.ts) now implements the seam #67 builds against.

Reading the coordinator

  • Source: the coordinator's existing GET /teamclaude/status, read with the wrapper's operator key from $XDG_CONFIG_HOME/teamclaude/wrappers.json. Nothing on the coordinator changes.
  • Connection: pinned to the single online tailnet peer that the Tailscale netmap binds to the configured *.ts.net name. No DNS lookup, proxy or redirects; a 32 MiB cap; one 10s deadline.
  • The rules are ported from orca-delegate's teamclaude_usage.py.

Ranking

  • minidev-<person><n> clients fold into one person, so several minidevs add up to one score. sixthman-* automation hosts are excluded.
  • The ranking uses fresh tokens (input + output + cache writes). Tied totals share a rank.
  • The host's own identity comes from teamclaude wrappers status --json → client.

Reads and failures

  • Reads happen on demand, at most once per TEAMCLAUDE_LEADERBOARD_REFRESH_MS (60s), and concurrent callers share one read. A slower, older read can't overwrite a newer one.
  • A failed refresh keeps the last good board, marked stale. With no good board yet, the method reports unavailable and says why. A missing config, or Windows, reports not-configured.

What crosses the process boundary

  • Only names, ranks and counts leave the main process. The key, account names and egress IPs stay in main.
  • The renderer client returns null for runtimes that don't have the method, such as older or upstream builds.

Why

It serves the operator's leaderboard request, with three constraints: existing endpoints only, nothing changed on devservices1, and one person's minidevs combined into one score. Running on the runtime host keeps the operator key on the machine that already holds it. A request/response RPC rather than a new subscription keeps the fork's footprint small.

Linked Issue

N/A: operator request in session. This pairs with #67, the sidebar UI. Both carry the shared commit 20990ec7a6, so they merge in either order.

Visual Proof

N/A: no UI in this PR. #67 renders the board. An integrated-app capture follows once both are on one branch.

Testing

  • New unit tests (5 files): coordinator status transport and validation, wrapper config resolution, ranking (folding, exclusion, ties, self across two minidevs) and the service (sharing, staleness, the out-of-order guard).

  • pnpm check:changed --maxWorkers=2 --base=refs/remotes/swaplabs/swaplabs/main: the worker's latest run is in progress. An earlier run stalled in vitest related, which pulls in most of the runtime suite through rpc/methods/index.ts, and was stopped to relieve host memory. Results will be posted here.

  • A live smoke run against the coordinator is pending and will be posted here.

  • I manually tested these changes locally (live smoke pending)

  • Automated tests added/updated, or explained why not below

AI Disclosure

Prepared by Claude Code (Claude Opus 5.5) at the operator's request.

Review

Opened at the operator's request to "open PRs asap and run tests after". The local review and coordinator test runs follow.

Agent skill upstream boundary

  • Not applicable: fork-only runtime service; no agent skill.

Notes

  • Security: the operator key is read only in main and sent only to the authenticated tailnet peer. Only GET /teamclaude/status is ever called.
  • Cross-platform: Windows reports not-configured without spawning anything.
  • Remote: request/response over the existing runtime RPC routing. Mixed versions degrade to the section being hidden.
  • Mobile: a follow-up.
  • Performance: at most one 7.4 MB read per host per minute, and only while a sidebar is asking. The TeamClaude-side payload reduction is a separate PR.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred): the check:changed run is in progress

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

kiwidream and others added 2 commits October 27, 2026 16:34
…nt seam

Shared surface for the sidebar leaderboard: the snapshot the runtime host
serves from the coordinator's existing /teamclaude/status, and the renderer
client the sidebar calls. The client returns null until the service lands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The runtime host reads its coordinator's existing GET /teamclaude/status with
the wrapper's operator key, pinned to the single online tailnet peer the
Tailscale netmap binds to the configured *.ts.net name, under one 10 s
deadline. Only the ranked board leaves the main process: minidev-<person><n>
clients fold into one person, sixthman-* hosts are excluded, and ranking uses
fresh (non-cache-read) tokens with shared ranks for ties.

Reads happen on demand, at most once per refresh interval, with concurrent
callers sharing one read. A failed refresh keeps the last good board marked
stale; without one the method reports why it is unavailable. The renderer
client returns null for runtimes without the method or callers refused it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-28T14:58:45.606506Z 6a4e4b7 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@kiwidream
kiwidream merged commit a1597a1 into swaplabs/main Oct 28, 2026
68 of 71 checks passed
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.

1 participant