feat(rust): Teams from first-party clans (phase 9, protocol 6)
All checks were successful
PR Checks / server-tests (pull_request) Successful in 24s
PR Checks / frozen-manifest (pull_request) Successful in 46s
PR Checks / client-build (pull_request) Successful in 8m3s

A first-party Rust clan is a Team (R5). This module becomes the site's
Team provider and answers core from the plugin's `clans` board. Design
of record: docs/modules/rust/PLAN.md §24, D47-D58.

- The store: rust_clans, rust_clan_members and rust_clan_boards. A clan's
  identity is <serverId>:<clanId>:<createdMs> (D52), because the game
  restarts clan ids whenever its clan database version changes.
- The provider (D53): getTeams is complete only when every server's
  board is fresh, supported and untruncated. It is partial when some
  are, and refuses when none are. Freshness is judged by the website's
  clock, from when the board's `t` last advanced.
- Only a complete board may mark a clan gone. A board at the game's
  100-clan ceiling (D55), or one with an unreadable row, proves nothing
  about what it leaves out.
- Leadership is diffed board to board and published (D54). The five clan
  events are published as team.* kinds, and written to the Team feed as
  members-only lines (D49).
- Core only writes feed items for a Team it already holds. So the last 10
  minutes of clan events are re-offered on each board refresh, deduped by
  a sha1 key: core clamps a dedupeKey to 40 characters, and a readable key
  would be truncated into collisions.
- projectRoster and the clan page share one audience rule (D48): the
  clan's linked members and staff by default, re-read from the users row.
  The setting lives on Admin > Rust visibility, which also warns about
  uMod Clans (D47) and the ceiling.
- Public: GET servers/:id/clans (the list is public, D58) and
  GET clans/:externalId. The client adds a Clans tab and
  /rust/clans/:externalId, with three module slots for core's notify,
  activity and forum contributions (D56).
- Linking and unlinking an account ask core to reconcile Teams (D57).
- The clan kinds are staff-class in the public feed allowlist.
- PROTOCOL_VERSION is now 6.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E14m6SuuY6i1vASFeGDBeY
This commit is contained in:
2026-09-23 05:14:18 -05:00
parent da1a393702
commit c94271104f
33 changed files with 3456 additions and 32 deletions

View File

@@ -0,0 +1,118 @@
// ── The clans on one server ───────────────────────────────────────────────
//
// Rust's OWN clans (R5), best score first. Public at every setting (D58): a
// clan's name, colour, score and member count name nobody. Who is IN a clan is
// the roster, and that lives on the clan's own page behind the operator's
// roster audience (D48).
//
// **The list is only as good as the board it came from**, and the answer says
// how good that is. Three cases would all look like an empty list if rendered
// bare, and they are three different sentences:
//
// • the bridge cannot read this server's clans at all (an older plugin, or a
// Nexus server whose clans live elsewhere) — "unavailable";
// • the game's clan system is switched off — "this server has no clans";
// • it can, and there are none — "nobody has founded one yet".
//
// And a board at the game's 100-clan ceiling (D55) says there may be more.
import { Link } from 'react-router-dom'
import { ErrorState, Loading, useAsync } from '../core.js'
import Empty from './Empty.jsx'
import { count } from '../lib/format.js'
import api from '../api.js'
export default function Clans({ serverId }) {
const { data, loading, error } = useAsync(() => api.servers.clans(serverId), [serverId])
if (loading) return <Loading />
if (error) return <ErrorState error={error} />
const clans = (data && data.clans) || []
const board = (data && data.board) || {}
if (clans.length === 0) {
if (!board.supported) {
return (
<Empty
title="Clans are unavailable for this server"
message={board.reason ? `${capitalise(board.reason)}.` : 'The bridge has not reported this server’s clans yet.'}
/>
)
}
if (board.enabled === false) {
return <Empty title="This server has no clans" message="Its operator has switched the game’s clan system off." />
}
return <Empty title="No clans yet" message="Nobody on this server has founded a clan." />
}
return (
<>
{board.truncated && (
<p className="sans" style={{ color: 'var(--dim)', fontSize: '0.8rem', marginTop: 0 }}>
The game lists at most 100 clans, by score, so there may be more on this server than are shown here.
</p>
)}
<ul style={{ listStyle: 'none', margin: 0, padding: 0 }}>
{clans.map((clan, index) => (
<li
key={clan.externalId}
style={{
display: 'flex',
alignItems: 'baseline',
gap: 12,
padding: '10px 0',
borderBottom: '1px solid var(--line-soft, var(--line))',
}}
>
<span className="sans" style={{ color: 'var(--dim)', fontSize: '0.78rem', minWidth: 22, textAlign: 'right' }}>
{index + 1}
</span>
<Swatch color={clan.color} />
<Link to={clanPath(clan.externalId)} style={{ fontWeight: 600, flex: 1, minWidth: 0 }}>
{clan.name}
</Link>
<span className="sans" style={{ color: 'var(--dim)', fontSize: '0.8rem', whiteSpace: 'nowrap' }}>
{count(clan.memberCount)} {clan.memberCount === 1 ? 'member' : 'members'}
</span>
<span className="sans" style={{ fontSize: '0.8rem', whiteSpace: 'nowrap', minWidth: 70, textAlign: 'right' }}>
{count(clan.score)} pts
</span>
</li>
))}
</ul>
</>
)
}
/** Where a clan's page is: the same template the Team provider hands core. */
export function clanPath(externalId) {
return `/rust/clans/${encodeURIComponent(externalId)}`
}
/**
* A clan's colour, as a small square. The server has already checked it is a
* `#rrggbb` — it ends up in a style — and a clan with no colour gets an outline
* rather than a guess.
*/
export function Swatch({ color, size = 12 }) {
return (
<span
aria-hidden="true"
style={{
display: 'inline-block',
flex: 'none',
width: size,
height: size,
borderRadius: 3,
background: color || 'transparent',
border: color ? 'none' : '1px solid var(--line)',
alignSelf: 'center',
}}
/>
)
}
function capitalise(text) {
return text ? text.charAt(0).toUpperCase() + text.slice(1) : text
}