fix(rust): nothing names who is online by default
All checks were successful
PR Checks / client-build (pull_request) Successful in 27s
PR Checks / frozen-manifest (pull_request) Successful in 51s
PR Checks / server-tests (pull_request) Successful in 8m6s

The org lead's rule, settled 2026-09-22: who is online is always the
narrowest audience - staff - unless an operator deliberately widens it,
and a count is fine where a list of names is not.

The public site broke that in three places since phase 4. The Online
tab named every player, the feed carried joins, respawns, deaths, chat
and tallies, and the leaderboard's lastSeen - refreshed every minute by
a gather tally - said who was on as plainly as either. All three now
sit behind one setting:

* PRESENCE_KINDS, a subset of the public allowlist, gated per request.
  Below the audience the feed keeps the server's own story (wipe, start,
  shutdown) and says presenceHidden rather than looking quiet.
* the Online route answers { players: [], hidden, count, audience } -
  same shape, so an older client renders empty rather than breaking.
* rungs staff / signed_in / public, fleet-wide default in a new
  rust_settings table with an optional per-server override on
  rust_servers; an unknown stored word narrows to staff.
* the viewer's standing is RE-READ from the users row (ctx.users.getById),
  not taken from the token, so a demotion or a ban applies on the next
  request. Walked: a moderator demoted mid-session lost the roll call on
  the same cookie.
* per-viewer answers are Cache-Control: private, no-store.
* GET/PUT /admin/rust/visibility (requireRole admin) and an admin page,
  Rust visibility; every save is one activity-log row.

The browser walk also found every empty state in this module rendering
as a blank box. Core's EmptyState renders children only; this module
passed title/message (the shape the Integration Kit template teaches)
and React dropped both without a word. Fixed module-side with a small
Empty wrapper - nothing core or module-uo renders changes - and a client
test that refuses a titled EmptyState or a PageHeader subtitle.

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 00:30:08 -05:00
parent 480a99f661
commit be44839896
31 changed files with 1739 additions and 33 deletions

View File

@@ -82,11 +82,39 @@ const STAFF_KINDS = Object.freeze([
'perm.drift',
])
/**
* The public kinds that say a NAMED player was on the server at a given moment.
*
* A subset of `PUBLIC_KINDS`, not a third list: these are public-page material
* whose audience an operator chooses (`model/visibility`), where the rest of
* `PUBLIC_KINDS` is public by construction. The org lead's rule, settled
* 2026-09-22: **nothing tells who is online by default** — the narrowest
* audience (staff) unless an operator widens it, and a count is never a name.
*
* `player.death` and `player.chat` are here, and that was decided rather than
* overlooked. They are the killfeed and the chat — the content a feed exists
* for — and each one says "this person was on at 12:03" as plainly as a connect
* frame does. `player.tally` is a per-minute flush that is only ever sent for a
* player who is playing, which makes it a roll call with extra steps.
*
* What is left in the public set once these are removed is the server's own
* story — a wipe, a start, a shutdown — which names nobody.
*/
const PRESENCE_KINDS = Object.freeze([
'player.connected',
'player.disconnected',
'player.respawned',
'player.death',
'player.chat',
'player.tally',
])
/** Every kind protocol 3 defines. */
const ALL_KINDS = Object.freeze([...PUBLIC_KINDS, ...STAFF_KINDS])
const PUBLIC = new Set(PUBLIC_KINDS)
const STAFF = new Set(STAFF_KINDS)
const PRESENCE = new Set(PRESENCE_KINDS)
/**
* May a signed-out visitor see this kind?
@@ -103,15 +131,27 @@ function isKnown(kind) {
return PUBLIC.has(kind) || STAFF.has(kind)
}
/** Does this kind name a player who was on the server at the time? */
function isPresence(kind) {
return PRESENCE.has(kind)
}
/**
* Narrows a list of requested kinds to the ones a viewer may have.
*
* Returning the allowlist itself when nothing was requested is what makes the
* public route safe by construction rather than by remembering to filter: there
* is no code path where "no filter" means "everything".
*
* `presence` defaults to `false` for the same reason `admin` does: a caller that
* forgets to say what the viewer may see gets the narrowest answer. The route
* resolves it from the operator's setting (`model/visibility`); nothing else
* should be passing `true`.
*/
function kindsFor({ admin = false, requested = null } = {}) {
const permitted = admin ? ALL_KINDS : PUBLIC_KINDS
function kindsFor({ admin = false, presence = false, requested = null } = {}) {
const permitted = admin
? ALL_KINDS
: PUBLIC_KINDS.filter((k) => presence || !PRESENCE.has(k))
if (!requested || requested.length === 0) return [...permitted]
@@ -122,8 +162,10 @@ function kindsFor({ admin = false, requested = null } = {}) {
module.exports = {
PUBLIC_KINDS,
STAFF_KINDS,
PRESENCE_KINDS,
ALL_KINDS,
isPublic,
isKnown,
isPresence,
kindsFor,
}