aorecomp

Anarchy Online classic in the browser

git clone https://aorecomp.ubeagle.com/code/aorecomp.git


docs/team-ownership.md (3163B)


Team ownership

A team spans zones. Its roster, leader and loot policy belong to one team goroutine, which waits on its command channel when idle. Zones retain immutable team views for local combat, UI and loot checks; they never hold a remote character or session pointer.

A directory routes commands to team owners and queues them without waiting for SQL. Each team owner checks authority and applies an action to its current roster. Commands carry intentions, such as leave or change loot policy, so concurrent independent changes compose instead of overwriting each other. The owner sends detached transaction inputs to the SQLite writer and replaces its authoritative view only after commit. SQL enforces unique membership across teams and checks the expected durable revision. Failed commits retain the previous view. Setting an unchanged loot policy acknowledges the request without a database write.

Transactions allocate a monotonically increasing revision across formation, roster changes and dissolution. The originating zone applies committed local views together, then sends immutable updates through the world directory to remote members. Delivery follows the member across zone transfers. Receivers ignore older revisions, including a departure delayed until after a player has joined another team. Client updates are constructed from the receiver's last view. Open loot windows lose access when the committed membership changes.

Names, affiliation and combat presence cross zone boundaries as values in the routing directory. Owners publish changes after commands and simulation actions; movement frames do not republish social metadata. Invitations still require both live sessions in the same zone, and check every teammate's published combat presence. Kick, leave, leadership and loot policy changes can address remote members. Team roster replay can resolve remote names and affiliation without waiting on another zone's command loop.

An initiating zone currently waits for its team's transaction. Other zones keep processing commands and simulation ticks. Team owners do not wait for recipient zones. World shutdown drains their accepted messages before joining zone owners; database shutdown joins team owners before stopping the SQLite writer.

Verification

The focused tests cover native team behavior, transaction rollback and retry, remote roster replay and affiliation, remote combat checks, stale updates after joining a different team, independent zone movement during a blocked team write, and shutdown delivery that revokes remote loot access. Owner tests also cover authority checks while another team is blocked, composition of queued actions, unique membership across team owners, and draining accepted writes on shutdown.

Production startup partitions mutable world state by zone and uses owner commands for external access. Teams remain independent of that partition: a per-team owner coordinates members across zones. Chat sessions and buddy presence have a separate channel owner; committed team changes publish revisioned membership to it. Mission lifecycle operations coordinate only their participating owners.