Skip to content

Recognise a full crew stack even in games the owner isn't playing - #53

Merged
PureXYZ merged 4 commits into
mainfrom
claude/ecstatic-carson-23de27
Jun 16, 2026
Merged

PureXYZ merged 4 commits into
mainfrom
claude/ecstatic-carson-23de27

Conversation

@PureXYZ

@PureXYZ PureXYZ commented Jun 16, 2026

Copy link
Copy Markdown
Owner

What & why

Builds on the earlier discussion: the coach should recognise a full stack of the user's crew even in games the owner isn't playing in (the friends play without the owner sometimes).

The blocker was structural: all teammate detection was anchored on the configured primary (the owner). With the owner absent, the same-side vote never ran, nothing was confirmed, and the coach went silent on every team surface. This adds a primary-independent path.

(Supersedes the reverted COACH_SQUAD fixed-5 identity list from #52 — that didn't fit a rotating pool. For games you ARE in, COACH_SQUAD_SIZE=5 already suffices; a team is exactly 5, so 5 confirmed same-side feeds prove a full stack.)

The safety problem, and the fix

Detecting a stack with no owner-anchor is dangerous: two of the crew's separate games on the same map could be glued into a phantom "5-stack" and trigger a false "you're the last one alive". Round numbers and scores collide across concurrent games, so they can't separate lobbies.

The fix is to key the lobby on round-win history — the sequence of who-won-each-round, which diverges between two real games within a round or two:

  • electSideAnchor — when no live primary + a pool is configured, elect a crew-pool feed (in the largest round-win-agreeing cluster, with a proven own side) as the side anchor, and run the existing accumulated same-side vote against it.
  • roundWinAgreement / MIN_FINGERPRINT_ROUNDS = 4 — a non-anchor pool feed is only confirmed once its round-outcome history agrees with the anchor's for ≥4 completed rounds. This is the cold-start hedge (no whole-team calls until ~round 4, since early on there's no history to tell two Mirage games apart) and what makes the two-same-map-games merge impossible.
  • tracker.hasSelfSide() — only feeds that posted a real first-person frame count, so a wired observer/caster can't pad the same-side count.
  • The anchor votes itself same-side, so the owner joining mid-match hands off anchor→primary without flickering a confirmed member out.

Everything downstream inherits through the single isTeammate predicate (authority/clock election, last-man — named in the third person since there's no "you" — econ, weak-link). The primary-present path is byte-identical (the anchor is null whenever the owner's feed is live), confirmed by the unchanged existing suite.

Config

COACH_PRIMARY_STEAM64=...        # you (required when COACH_SQUAD is set)
COACH_SQUAD_SIZE=5               # stack size
COACH_SQUAD=id1,id2,...,id7      # OPTIONAL: the crew pool, for the without-me feature

Known limitation (inherent, not a bug)

In games the owner isn't in, whole-team calls only begin ~round 4 — before that there is no round-win history, so the coach safely hedges. This was surfaced by the design verification and is the price of having no owner-anchor.

Testing

  • npm run test (typecheck + sim): 336 checks pass, no regression.
  • New simulate.ts scenarios prove: cold start hedges; a full crew stack the owner isn't in fires last-man (named third-person); two same-map games never merge into a phantom stack; the owner-join handoff keeps the stack.

How it was built

The design was adversarially verified first (three independent reviewers found the naive version's false-call paths — observer padding, two-lobby merge, the cold-start blind window — which directly shaped the fixes above), then implemented test-first.

PureXYZ and others added 4 commits June 15, 2026 21:11
The multi-feed coach anchored ALL teammate detection on the configured primary
(the owner): with the owner absent, no feed could be confirmed, so the coach
went silent on every team surface. This adds primary-INDEPENDENT full-stack
detection so a stack of the crew is coached even when the owner isn't in it.

New config:
- COACH_SQUAD (optional) — the crew POOL (every friend's SteamID64). Scopes
  "whose games to talk about" to your group. Membership-only, not a stack size;
  requires COACH_PRIMARY_STEAM64 and COACH_SQUAD_SIZE.
- COACH_SQUAD_SIZE keeps its meaning. When you ARE playing, it alone is enough
  for a rotating crew: 5 confirmed same-side feeds already prove a full team,
  whoever the five are.

Mechanism (safety-critical — the naive version makes the coach lie):
- No live primary + pool set => elect a crew-pool SIDE ANCHOR (electSideAnchor)
  and accumulate the same-side vote against it instead of the primary. The
  anchor is the feed in the largest round-win-agreeing cluster (the majority
  lobby on the shared token) with a PROVEN own side.
- LOBBY FINGERPRINT by round-win history (roundWinAgreement): two feeds are the
  same match only when their round-OUTCOME histories agree for
  >= MIN_FINGERPRINT_ROUNDS (4) completed rounds. This is the cold-start hedge
  (no whole-team calls until ~round 4, before which there's no history to tell
  two same-map games apart) and what stops two of the crew's separate games
  merging into a phantom stack.
- Only feeds with a real first-person frame count (tracker.hasSelfSide), so a
  wired observer/caster can't pad the same-side count.
- The anchor votes itself same-side, so the owner joining mid-match hands off
  anchor->primary without flickering a confirmed member out.

Everything downstream inherits through the single isTeammate predicate:
authority/clock election, last-man (named third-person, no "you"), econ,
weak-link. The primary-PRESENT path is byte-identical (anchor is null whenever
the owner's feed is live).

tracker: roundWinsRaw() (keyed round-win history) + hasSelfSide()/sawSelfSide.

simulate.ts proves cold-start hedges, a full crew stack the owner isn't in
fires last-man (named), two same-map games never merge, and the owner-join
handoff keeps the stack. 336 checks pass, no regression.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ze guard

Addresses the top findings from the xhigh review of the crew-pool feature.

- HANDOFF LEAK (could produce a FALSE whole-team member): when the owner
  joined a game in progress, isTeammate reverted to the bare same-side vote,
  so a benched friend in a DIFFERENT same-map game who'd banked a same-side
  vote during the cold-start window rode that stale tally into the squad once
  the owner joined. The primary-present path now also excludes any feed whose
  round-win history CONTRADICTS the primary's lobby. Proven by a new sim
  scenario that FAILS with the guard removed (teeth-checked).

- DANGLING ANCHOR: reap() cleared authorityId but not anchorId, so a reaped
  pool anchor left anchorId pointing at a deleted feed and (on the feed-cap
  early-return path, which skips re-election) collapsed the confirmed stack.
  reap() now clears anchorId too.

- MISCONFIG: a COACH_SQUAD pool shorter than COACH_SQUAD_SIZE can never field
  a full stack, so whole-team calls would silently never fire — now a loud
  startup throw, matching the other crew cross-checks.

Also hardened two sim assertions that passed vacuously: the two-games
scenario now positively asserts lobby A IS confirmed (so a total confirmation
failure can't hide), and the cold-start assertion pins "no team block" rather
than the weaker "!== true".

340 checks pass; the new contaminant scenario fails with the handoff guard
removed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
A review agent's `git show main:...` redirect created a mangled-path file in
the repo root; it was swept in by the previous commit's `git add -A`. Not part
of the change.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Resolves the lower-severity findings from the xhigh review, and the defects an
adversarial verification pass found in this batch's own first cut.

Behavioral:
- Anchor RE-ELECTION (#2): electSideAnchor no longer seats permanently on the
  cold-start pick. It scores each eligible feed by how many others POSITIVELY
  share its round-win history (agreement >= 1 — a no-history feed agrees with
  everyone, so >= 0 would wrongly elect it), keeps the anchor only while it's a
  co-leader, and re-elects to the majority lobby once histories diverge. So a
  cold-start anchor seated in a minority same-map lobby is corrected to the real
  stack instead of hedging it out for the whole match.
- On a lobby-change re-election, per-feed side votes (measured against the OLD
  lobby's side reference) are RESET, so a real stack on the opposite side label
  isn't suppressed by stale opposite-side votes after the correction.
- confirmedEver is re-validated for lobby agreement at its READ sites (buildTeam
  appendee, deriveLastMan count) every frame, replacing a one-shot purge that was
  fragile to a transient no-history frame — a different-match high-water member
  can no longer linger as a phantom teammate inflating last-man/rosterComplete.
- REVERTED the stale-primary referenceFeed fallback from the prior batch: it let
  a non-pool enemy feed bank a cross-match same-side vote against a frozen
  prior-match primary and be confirmed as a teammate. Losing a few votes during
  the owner's brief blip is the safe trade.
- index.ts no longer logs a "check the ID" misconfig warning for an owner-absent
  crew game (expected when COACH_SQUAD is set).

Cleanup / diagnostics:
- membershipReason mirrors isTeammate's anchor-path branch, so /coach status
  names the real reason (not-in-crew-pool / no-self-side-yet / different-match /
  fingerprint-immature / opposite-side-vote) on the owner-absent path.
- Shared isPoolPlayer()/lobbyAgreement() helpers de-duplicate the membership
  predicate across the vote, isTeammate, electSideAnchor, and membershipReason.
- config splitCsv() extracted; doc notes on the dead-connect over-hedge and the
  getter-vs-update anchor-staleness invariant.

simulate.ts: adds the minority-lobby re-election and the opposite-side
vote-reset scenarios (both teeth-checked — they fail with the respective fix
removed). 344 checks pass, no regression.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@PureXYZ
PureXYZ merged commit 72de311 into main Jun 16, 2026
1 check passed
@PureXYZ
PureXYZ deleted the claude/ecstatic-carson-23de27 branch June 16, 2026 04:18
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