# CS2 production receiver and control journal

Contract: `arena.cs2.v1`. Website discovery: `2026-10-08.4`.

The Arena receiver implementation is shipped separately from the immutable v1
local kit. The kit remains useful for Raif's adapter and control-service work;
its simulator is not the production service.

## Current boundary

- `GET https://hybrid-arena.com/api/integrations/cs2/v1/status` is a public,
  credential-free diagnostic. It discloses no source IDs, keys or private rosters.
- `POST /api/integrations/cs2/v1/events` and
  `GET /api/integrations/cs2/v1/receipts/{batch_id}` are implemented service routes.
  **They return 503 while ingestion is disabled.** Public documentation does not
  provide credentials or authorize writes.
- The durable allocation/roster/start/cancel command journal and fixed-origin
  provider client are implemented as internal control-plane modules. There is
  **no public allocation or match-start API and no activated dispatcher** yet.
- Source keys have not been provisioned. Real match acceptance, public CS2 match
  publication and two-team practice markets remain false. Synthetic CS2 demo
  routes remain explicitly synthetic and do not consume these records.
- Hybrid-ID still owns Steam linking and consent. Its public Explorer receipts
  are not roster or game-admission credentials. Human roster preparation and
  start must revalidate each player's actual private permission, not accept
  browser-supplied Steam IDs. The match-specific consent workflow and fresh per-human authority are implemented
  with enrollment disabled; the storage/control tests use isolated fixtures.

## Provider requests

Use the original v1 schemas, headers and signature canonicalization in
[v1/protocol.mjs](./v1/protocol.mjs), with separate keys in each direction.
The source key is scoped to provider, server, environment and a validity window.
Key IDs and key material must both be unique; never reuse a secret for another source or rotation entry. Every batch must also match an Arena-authorized allocation, match, epoch and
roster version. A source key cannot register itself, allocate a match or change a
roster. Rotated/revoked keys are reread from the private registry on each request.

The signature covers `ARENA-CS2-HMAC-V1`, uppercase method, exact path, integer UTC
seconds, fresh 32-hex nonce and SHA-256 of the original body bytes, separated by
newlines. Timestamp tolerance is 60 seconds. Nonces are stored durably for at
least 120 seconds and are scoped to the key. A retry keeps the original batch ID
and bytes but signs a **new nonce**. Never send Origin, Cookie or Authorization;
Arena browser sessions and Hybrid-ID bearer tokens are not source credentials.

Maximum body: 256 KiB; maximum batch: 100 events. The request body must arrive
within 10 seconds. Receipt reads accept no body or query. Use exact unencoded
paths. The source nonce window is bounded (6,000 per key and 24,000 total); 429
requires backoff, not another identity/key. These are defensive bounds, not a
throughput SLA. Measure actual real-match traffic before activation.

## Ordering and recovery

Events, receipt, digest cursor and match projection commit in one SQLite
transaction with WAL and FULL synchronization. No receipt is returned before the
commit. Identical retries return the stored receipt even after restart or match
completion. Different bytes for the same ID conflict. Receipt lookup is scoped
to the same provider/server/environment.

Sequence1 is `allocation_ready`, with the allocated map. Continue the exact
batch digest chain and monotonically increasing source ticks within the epoch.
`match_started` requires a dispatched (uncertain or confirmed) Arena start command
and matching map/roster. A ready start acknowledgment means start requested; only
authenticated game events advance Arena to live. A merely queued start authorizes
no gameplay. Pending roster changes return `control_pending`; retain and retry
the original batch after reconciliation. A recovered start may report completed,
canceled or failed if control already ended the match; its response resolves the
original command but never replaces or prevents final source event intake.
An old already-committed batch remains idempotent across roster replacement.

Missing batches return409 with `expected_sequence`; retry the missing history.
An explicit `source_gap` permanently holds the result. It does not reset the
cursor or invent missing events. Terminal events are last in their batch;
completed/canceled allocations reject new batches. A contradictory winner/score
is rejected, while a forfeit can name a team with fewer recorded rounds.
There is no automatic settlement, fund movement or correction of terminal evidence.

Cancellation closes admission through the provider control contract. Captured
telemetry can race the cancellation response; a committed terminal result is not
overwritten by a late control response. Resolve uncertain commands using their
original request IDs and exact bytes. Do not start a replacement request merely
because a timeout or 404 occurred.

## Privacy and operations

Private rosters, profile bindings, provider connection details and prepared command
bodies are encrypted using a dedicated Core storage key, separate from Identity.
Only public Arena profile IDs and aliases may be projected for people. The explicit
public projection excludes Steam IDs, provider connection details, raw event strings,
roster hashes, source keys and identity subjects. Publication is still disabled.

No raw movement/video stream is stored here. Normalized event evidence and receipts
currently have no automatic deletion policy. Saved replay retention is unchanged.
Measure database/WAL growth, event volume and disk headroom on the real provider;
do not infer storage or concurrent-server capacity from this local test suite.
Back up the database and encryption key securely with a consistent SQLite backup.

## Joint activation checklist

Raif can continue implementing and testing the five provider operations, authentic
Steam admission and durable normalized outbox using the existing kit. Supply the
staging origin, provider/server IDs, map/region list, exact plugin/game builds and
secure key-provisioning reference in the draft PR. No secrets belong in that PR.

Arena has implemented session-consented roster/seat preparation and attached its
fresh consent authority to the internal control client. It must activate an
operational dispatcher/reconciliation path, provision reviewed source/command
keys and bind staging allocations. Run a real CS2 match plus outsider,
spoof, reconnect, team-change, half/overtime, cancellation, gap, restart and lost-ack
acceptance before setting production availability or publishing matches. Two-team
market rules require their own validation; do not reuse Star Quest's four-outcome
rulebook. Funding, Stripe and all real-value execution remain paused.

## Match-specific consent and roster preparation

Website discovery `2026-10-08.3` adds a first-party match-permission flow. The
Games page lists only operator-created CS2 rooms. `GET /api/cs2/rooms` currently
returns `enabled:false`, `rooms:[]`; no demonstration room is enrolled on Core.
`GET /api/cs2/rooms/{id}/seat` reads the session owner's choice.
`POST /api/cs2/rooms/{id}/seat` confirms or withdraws that choice using the
current session, exact Origin, CSRF, and current room revision.

For join, send only `action:"join"`, a fresh 32-character lowercase hex
`request_id`, `revision`, the room's `team_id`, and
`consent_version:"arena.cs2.seat-consent.v1"`. For withdrawal, send only
`action:"withdraw"`, `request_id`, and `revision`. Keep the exact request ID
and terms on retry. A committed join retried after withdrawal returns current
state and cannot restore permission. Conflicting reuse returns 409. A changed
room revision requires reviewing the current room before a new choice.

The user explicitly allows Arena to send the linked Steam ID privately to the
named provider for this match's roster/admission. This is separate from merely
reading Steam in My Arena. Server-side fixed-origin Identity reads resolve each
Steam ID; no browser-provided Steam ID, owner, profile, provider or roster is
accepted. A public Arena alias is required. Public room data contains no Steam
ID, Identity subject, session reference, grant token or roster digest.

Core stores the match binding encrypted: owning profile/session reference, grant
fingerprint, Steam ID, selected team and consent version/time. It does not copy
OAuth access tokens into CS2 storage. Existing session-bound encrypted grants
remain in the authentication database. Signing out, clearing Steam access,
permission expiration/replacement or a changed Steam link prevents new control
authorization. This does not claim to disconnect a player from a running server.

The internal `Cs2Seats.register` method takes immutable, reviewed room terms:
match/provider ID, provider display label, staging/production environment,
map/region, `cs2_mr12_bo1_v1`, two stable team IDs/display labels, one to five seats
per team, and a deadline within one hour. It is not a public API. Duplicate room
IDs cannot change terms. Capacity, duplicate Steam identity and optimistic room
revision checks commit atomically. `seats_enabled` is optional in the private
receiver configuration and defaults false. Withdrawals remain possible when
new enrollment is paused or Steam access is revoked.

`prepareConsentedRoom` freezes the chosen roster and builds provider allocation
terms from the recorded room, never from a browser. This first human enrollment
flow requires at least one player on each team and uses `bot_policy:"disabled"`.
It does not silently add bots. `consentedCs2Control` attaches the real consent
authority to the existing internal control client. Each human is freshly checked
at preparation and dispatch, including start: the session/grant, profile owner,
Steam ID, exact team, room/provider/environment and frozen roster must match.
After all upstream calls, earlier checked permissions and snapshot deadlines
are checked again. No consent means no outgoing control request.

A locked roster can renew permission only for the same still-consented seat,
team and Steam ID. It cannot use renewal to add/switch a player or revive a
withdrawn seat. A changed roster requires a separate replacement workflow, not
editing the frozen record. New enrollment and game admission are distinct.

An operator can abandon a **never-dispatched queued** command durably, releasing
its pending-command lock. It can never be sent afterward, including if it was
canceled while identity checks were pending. An uncertain/dispatched command
cannot be discarded this way: retain the original terms and reconcile actual
provider state. This integration still needs an operational dispatcher and
provider reconciliation/seat-removal policy before activation. No browser
allocation, start, provider credential or operator API is exposed.

Validation uses isolated accounts, encrypted SQLite stores and simulated
Identity/provider responses, including restart, capacity conflict, duplicate
Steam IDs, revoked/expired/replaced grants, withdrawal during another player's
lookup, permission renewal and command cancellation races. These checks are not
real-user enrollment or real CS2 game admission acceptance. Raif's actual staging
service and a joint real match remain necessary. Enrollment stays disabled.


## Durable command recovery and Core worker

The additive [command recovery extension](./recovery-v1/README.md) specifies
provider-hosted GET `/v1/requests/{request_id}` and POST
`/v1/requests/{request_id}/stop`. The original v1 artifacts remain unchanged.
The extension includes OpenAPI, a durable encrypted provider journal, independent
tests and an explicit staging stop probe. These paths are not Arena browser APIs.

Arena's gated worker now implements one-command passes, persistent retry backoff,
source-bound original-byte recovery and revalidation of current configuration
before every outgoing call. Lost replies are looked up first. Current consent is
required to resend an unknown command; withdrawn consent requests a durable stop.
Only the provider's final canceled receipt releases uncertain work. Pending,
unknown, timeout and 404 never become cancellation. Already-applied facts are
recorded even after consent withdrawal; this does not undo the effect or grant
another start. No silent retry against a different provider/environment/origin.

New private `providers` configuration and `dispatch_enabled` default to empty/off.
The separate Core service/timer must remain inactive until the provider implements
the extension and joint staging checks pass. The public `command_dispatch_enabled`
flag describes configured new dispatch, not timer liveness or successful game
admission. No provider keys or game instances were created for this delivery.

Remaining activation work includes reviewed provider staging and key provisioning,
actual process/game-effect reconciliation, roster replacement and already-admitted
player removal policy, and joint real-match/fault acceptance. No funding or
real-value execution is enabled. The earlier sections describe historical rollout
steps; this continuation supersedes their unfinished worker-implementation note.
