gameplay: own registered entity lifetimes
Browse files- crates/urt-gameplay/src/bin/urt-server-entities.rs +67 -0
- crates/urt-gameplay/src/lib.rs +2 -0
- crates/urt-gameplay/src/server_entities.rs +159 -0
- docs/FINDINGS.md +2 -0
- docs/PROVISIONAL_TODO.md +2 -0
- docs/RESEARCH_LEDGER.md +4 -0
- docs/research/README.md +2 -0
- docs/research/RUST_SERVER_ENTITIES.md +5 -0
- docs/research/rust-server-entities.json +55 -0
- scripts/analyze_rust_server_entities.py +30 -0
- scripts/test_rust_server_entities.py +13 -0
- xtask/checks.tsv +13 -0
crates/urt-gameplay/src/bin/urt-server-entities.rs
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
use std::io::Read;
|
| 2 |
+
use urt_assets::bsp::BspVisibility;
|
| 3 |
+
use urt_gameplay::location_feedback::{EntityPool, EntityRelease, EntitySlot};
|
| 4 |
+
use urt_gameplay::server_entities::ServerEntities;
|
| 5 |
+
use urt_gameplay::spatial_index::Bounds;
|
| 6 |
+
|
| 7 |
+
fn main() {
|
| 8 |
+
let mut bytes = Vec::new();
|
| 9 |
+
std::io::stdin().read_to_end(&mut bytes).unwrap();
|
| 10 |
+
let bsp = BspVisibility::parse(&bytes).unwrap();
|
| 11 |
+
let bounds = Bounds::new([-16.; 3], [16.; 3]).unwrap();
|
| 12 |
+
let mut pool = EntityPool {
|
| 13 |
+
count: 64,
|
| 14 |
+
slots: vec![EntitySlot { words: [0; 220] }; 1024],
|
| 15 |
+
};
|
| 16 |
+
pool.slots[64].words[568 / 4] = 5000;
|
| 17 |
+
pool.slots[64].words[572 / 4] = 1;
|
| 18 |
+
let mut world = ServerEntities::new(bounds, pool).unwrap();
|
| 19 |
+
let (_, first) = world.allocate(5000, 0).unwrap();
|
| 20 |
+
let first = first.unwrap();
|
| 21 |
+
world.link(&bsp, first, true).unwrap();
|
| 22 |
+
let linked = world.links().spatial().query(bounds, 8).slots;
|
| 23 |
+
let retained = world.expire(first, 5300, None, |_| None).unwrap();
|
| 24 |
+
let before = world.links().spatial().query(bounds, 8).slots;
|
| 25 |
+
let expired = world.expire(first, 5301, None, |_| None).unwrap();
|
| 26 |
+
assert_eq!(expired.releases, [EntityRelease::ReleaseResource(97243)]);
|
| 27 |
+
let after = world.links().spatial().query(bounds, 8).slots;
|
| 28 |
+
let older_removed = world.record(first).is_none();
|
| 29 |
+
let (_, extended) = world.allocate(6300, 0).unwrap();
|
| 30 |
+
let (_, reused) = world.allocate(6301, 0).unwrap();
|
| 31 |
+
let reused = reused.unwrap();
|
| 32 |
+
let stale_rejected = world.link(&bsp, first, true).is_err();
|
| 33 |
+
world.link(&bsp, reused, true).unwrap();
|
| 34 |
+
let visible = world.links().spatial().query(bounds, 8).slots;
|
| 35 |
+
let current = world.record(reused).unwrap();
|
| 36 |
+
|
| 37 |
+
let linked_word = current.words[416 / 4];
|
| 38 |
+
let registered = world.registered_count();
|
| 39 |
+
let mut unavailable = EntitySlot { words: [0; 220] };
|
| 40 |
+
unavailable.words[532 / 4] = 1;
|
| 41 |
+
let mut full_world = ServerEntities::new(
|
| 42 |
+
bounds,
|
| 43 |
+
EntityPool {
|
| 44 |
+
count: 1024,
|
| 45 |
+
slots: vec![unavailable; 1024],
|
| 46 |
+
},
|
| 47 |
+
)
|
| 48 |
+
.unwrap();
|
| 49 |
+
let (terminal, id) = full_world.allocate(6302, 0).unwrap();
|
| 50 |
+
assert!(id.is_none() && terminal.registrations.is_empty());
|
| 51 |
+
let registered_terminal = full_world.registered_count();
|
| 52 |
+
let no_slot = full_world.id_at(1024).is_none();
|
| 53 |
+
let retry_rejected = full_world.allocate(6302, 0).is_err();
|
| 54 |
+
|
| 55 |
+
println!(
|
| 56 |
+
r#"{{"linked":{linked:?},"at_300":{before:?},"dispatch_300":{},"at_301":{after:?},"expired_dispatch":{},"older_removed":{older_removed},"extended":{},"reused":{},"stale_rejected":{stale_rejected},"visible":{visible:?},"registered":{},"linked_word":{},"resource_releases":{},"terminal_status":"{}","terminal_count":{},"registered_terminal":{registered_terminal},"no_slot":{no_slot},"retry_rejected":{retry_rejected}}}"#,
|
| 57 |
+
retained.dispatch,
|
| 58 |
+
expired.dispatch,
|
| 59 |
+
extended.unwrap().slot(),
|
| 60 |
+
reused.slot(),
|
| 61 |
+
registered,
|
| 62 |
+
linked_word,
|
| 63 |
+
expired.releases.len(),
|
| 64 |
+
terminal.status,
|
| 65 |
+
terminal.count
|
| 66 |
+
);
|
| 67 |
+
}
|
crates/urt-gameplay/src/lib.rs
CHANGED
|
@@ -211,3 +211,5 @@ pub mod area_portals;
|
|
| 211 |
pub mod world_visibility;
|
| 212 |
|
| 213 |
pub mod entity_links;
|
|
|
|
|
|
|
|
|
| 211 |
pub mod world_visibility;
|
| 212 |
|
| 213 |
pub mod entity_links;
|
| 214 |
+
|
| 215 |
+
pub mod server_entities;
|
crates/urt-gameplay/src/server_entities.rs
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//! Ownership of the fixed entity pool, registrations, and spatial lifetimes.
|
| 2 |
+
use crate::entity_links::EntityLinks;
|
| 3 |
+
use crate::location_feedback::{
|
| 4 |
+
AllocationOutcome, EntityEventFrame, EntityPool, EntityRelease, EntitySlot, allocate_entity,
|
| 5 |
+
expire_entity_event, release_entity,
|
| 6 |
+
};
|
| 7 |
+
use crate::native_policy::Error;
|
| 8 |
+
use crate::spatial_index::Bounds;
|
| 9 |
+
use urt_assets::bsp::BspVisibility;
|
| 10 |
+
|
| 11 |
+
const SLOTS: usize = 1024;
|
| 12 |
+
|
| 13 |
+
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
| 14 |
+
pub struct EntityId {
|
| 15 |
+
slot: usize,
|
| 16 |
+
generation: u64,
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
impl EntityId {
|
| 20 |
+
pub fn slot(self) -> usize {
|
| 21 |
+
self.slot
|
| 22 |
+
}
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
pub struct ServerEntities {
|
| 26 |
+
pool: EntityPool,
|
| 27 |
+
links: EntityLinks,
|
| 28 |
+
generations: [u64; SLOTS],
|
| 29 |
+
registered_count: u32,
|
| 30 |
+
next_generation: u64,
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
impl ServerEntities {
|
| 34 |
+
/// Start from level records before any links have been published.
|
| 35 |
+
pub fn new(world: Bounds, pool: EntityPool) -> Result<Self, Error> {
|
| 36 |
+
if !(64..=SLOTS as u32).contains(&pool.count) || pool.slots.len() < SLOTS {
|
| 37 |
+
return Err(Error::InvalidCount);
|
| 38 |
+
}
|
| 39 |
+
if pool.slots[..SLOTS]
|
| 40 |
+
.iter()
|
| 41 |
+
.any(|record| record.words[416 / 4] != 0)
|
| 42 |
+
{
|
| 43 |
+
return Err(Error::InvalidInput);
|
| 44 |
+
}
|
| 45 |
+
let generations = std::array::from_fn(|slot| {
|
| 46 |
+
u64::from(slot < pool.count as usize && pool.slots[slot].words[532 / 4] != 0)
|
| 47 |
+
});
|
| 48 |
+
Ok(Self {
|
| 49 |
+
registered_count: pool.count,
|
| 50 |
+
next_generation: 2,
|
| 51 |
+
pool,
|
| 52 |
+
links: EntityLinks::new(world, SLOTS)?,
|
| 53 |
+
generations,
|
| 54 |
+
})
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
pub fn links(&self) -> &EntityLinks {
|
| 58 |
+
&self.links
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
pub fn registered_count(&self) -> u32 {
|
| 62 |
+
self.registered_count
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
pub fn id_at(&self, slot: usize) -> Option<EntityId> {
|
| 66 |
+
if slot >= self.registered_count as usize || self.pool.slots[slot].words[532 / 4] == 0 {
|
| 67 |
+
return None;
|
| 68 |
+
}
|
| 69 |
+
Some(EntityId {
|
| 70 |
+
slot,
|
| 71 |
+
generation: self.generations[slot],
|
| 72 |
+
})
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
pub fn record(&self, id: EntityId) -> Option<&EntitySlot> {
|
| 76 |
+
(self.id_at(id.slot) == Some(id)).then(|| &self.pool.slots[id.slot])
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
pub fn allocate(
|
| 80 |
+
&mut self,
|
| 81 |
+
tick: u32,
|
| 82 |
+
level_start: u32,
|
| 83 |
+
) -> Result<(AllocationOutcome, Option<EntityId>), Error> {
|
| 84 |
+
let generation = self.next_generation;
|
| 85 |
+
let next_generation = generation.checked_add(1).ok_or(Error::InvalidCount)?;
|
| 86 |
+
let outcome = allocate_entity(&mut self.pool, tick, level_start)?;
|
| 87 |
+
if let Some(&count) = outcome.registrations.last() {
|
| 88 |
+
self.registered_count = count;
|
| 89 |
+
}
|
| 90 |
+
let id = outcome.selected.map(|slot| {
|
| 91 |
+
self.next_generation = next_generation;
|
| 92 |
+
self.generations[slot] = generation;
|
| 93 |
+
EntityId { slot, generation }
|
| 94 |
+
});
|
| 95 |
+
Ok((outcome, id))
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
pub fn link(
|
| 99 |
+
&mut self,
|
| 100 |
+
bsp: &BspVisibility<'_>,
|
| 101 |
+
id: EntityId,
|
| 102 |
+
active_server: bool,
|
| 103 |
+
) -> Result<(), Error> {
|
| 104 |
+
let slot = self.checked_slot(id)?;
|
| 105 |
+
self.links
|
| 106 |
+
.link(bsp, slot, &mut self.pool.slots[slot], active_server)
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
pub fn unlink(&mut self, id: EntityId) -> Result<bool, Error> {
|
| 110 |
+
let slot = self.checked_slot(id)?;
|
| 111 |
+
self.links.unlink(slot, &mut self.pool.slots[slot])
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
pub fn free(
|
| 115 |
+
&mut self,
|
| 116 |
+
id: EntityId,
|
| 117 |
+
tick: u32,
|
| 118 |
+
object_child: impl FnOnce(u32) -> Option<u32>,
|
| 119 |
+
) -> Result<Vec<EntityRelease>, Error> {
|
| 120 |
+
let slot = self.checked_slot(id)?;
|
| 121 |
+
let mut requests = release_entity(Some(&mut self.pool.slots[slot]), tick, object_child)?;
|
| 122 |
+
self.apply_unlink(slot, &mut requests)?;
|
| 123 |
+
Ok(requests)
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
pub fn expire(
|
| 127 |
+
&mut self,
|
| 128 |
+
id: EntityId,
|
| 129 |
+
tick: u32,
|
| 130 |
+
client_event: Option<&mut u32>,
|
| 131 |
+
object_child: impl FnOnce(u32) -> Option<u32>,
|
| 132 |
+
) -> Result<EntityEventFrame, Error> {
|
| 133 |
+
let slot = self.checked_slot(id)?;
|
| 134 |
+
let mut frame =
|
| 135 |
+
expire_entity_event(&mut self.pool.slots[slot], tick, client_event, object_child)?;
|
| 136 |
+
self.apply_unlink(slot, &mut frame.releases)?;
|
| 137 |
+
Ok(frame)
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
fn checked_slot(&self, id: EntityId) -> Result<usize, Error> {
|
| 141 |
+
if self.id_at(id.slot) == Some(id) {
|
| 142 |
+
Ok(id.slot)
|
| 143 |
+
} else {
|
| 144 |
+
Err(Error::InvalidIndex)
|
| 145 |
+
}
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
fn apply_unlink(
|
| 149 |
+
&mut self,
|
| 150 |
+
slot: usize,
|
| 151 |
+
requests: &mut Vec<EntityRelease>,
|
| 152 |
+
) -> Result<(), Error> {
|
| 153 |
+
if requests.first() == Some(&EntityRelease::Unlink) {
|
| 154 |
+
self.links.unlink(slot, &mut self.pool.slots[slot])?;
|
| 155 |
+
requests.remove(0);
|
| 156 |
+
}
|
| 157 |
+
Ok(())
|
| 158 |
+
}
|
| 159 |
+
}
|
docs/FINDINGS.md
CHANGED
|
@@ -2081,3 +2081,5 @@ RE-1034–1043 batch validation passed:2,018 Python tests,339 Rust tests,146 det
|
|
| 2081 |
- Rust can enumerate the BSP leaves an entity's link bounds touch and carry forward the final clustered leaf even on overflow. [BSP box queries](research/RUST_BSP_BOX.md).
|
| 2082 |
|
| 2083 |
- Entity relinking now updates game-record link words, ordered spatial membership and BSP area and cluster metadata together. [Entity link ownership](research/RUST_ENTITY_LINKS.md).
|
|
|
|
|
|
|
|
|
| 2081 |
- Rust can enumerate the BSP leaves an entity's link bounds touch and carry forward the final clustered leaf even on overflow. [BSP box queries](research/RUST_BSP_BOX.md).
|
| 2082 |
|
| 2083 |
- Entity relinking now updates game-record link words, ordered spatial membership and BSP area and cluster metadata together. [Entity link ownership](research/RUST_ENTITY_LINKS.md).
|
| 2084 |
+
|
| 2085 |
+
- The server pool removes linked metadata on expiry and rejects an earlier occupant's handle after slot reuse. [Server entity lifetimes](research/RUST_SERVER_ENTITIES.md).
|
docs/PROVISIONAL_TODO.md
CHANGED
|
@@ -2143,3 +2143,5 @@ RE-974–983 completed routing, command rewrite, inactivity, movement-parameter
|
|
| 2143 |
- [x] RE-1067 Recover and port BSP box leaf enumeration for linked entity bounds ([evidence](research/RUST_BSP_BOX.md)).
|
| 2144 |
|
| 2145 |
- [x] RE-1068 Compose shared sector membership and BSP metadata for entity links ([evidence](research/RUST_ENTITY_LINKS.md)).
|
|
|
|
|
|
|
|
|
| 2143 |
- [x] RE-1067 Recover and port BSP box leaf enumeration for linked entity bounds ([evidence](research/RUST_BSP_BOX.md)).
|
| 2144 |
|
| 2145 |
- [x] RE-1068 Compose shared sector membership and BSP metadata for entity links ([evidence](research/RUST_ENTITY_LINKS.md)).
|
| 2146 |
+
|
| 2147 |
+
- [x] RE-1069 Own entity registration, spatial links and slot generations in the server pool ([evidence](research/RUST_SERVER_ENTITIES.md)).
|
docs/RESEARCH_LEDGER.md
CHANGED
|
@@ -2947,3 +2947,7 @@ The Rust reader enumerates ordered leaf intersections and tracks the most recent
|
|
| 2947 |
## 2026-11-25 — RE-1068 Compose shared sector membership and BSP metadata for entity links
|
| 2948 |
|
| 2949 |
The entity link service uses record-derived bounds, BSP leaf enumeration and sector ownership. All 208 native metadata fixtures match, and a controlled BSP verifies relink and unlink. See [entity link parity](research/RUST_ENTITY_LINKS.md).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2947 |
## 2026-11-25 — RE-1068 Compose shared sector membership and BSP metadata for entity links
|
| 2948 |
|
| 2949 |
The entity link service uses record-derived bounds, BSP leaf enumeration and sector ownership. All 208 native metadata fixtures match, and a controlled BSP verifies relink and unlink. See [entity link parity](research/RUST_ENTITY_LINKS.md).
|
| 2950 |
+
|
| 2951 |
+
## 2026-11-25 — RE-1069 Own entity registration, spatial links and slot generations in the server pool
|
| 2952 |
+
|
| 2953 |
+
The server pool consumes unlink requests, invalidates freed identities and keeps registered extent bounded even at the full-pool allocator terminal. See [server entity lifetimes](research/RUST_SERVER_ENTITIES.md).
|
docs/research/README.md
CHANGED
|
@@ -1709,3 +1709,5 @@ The extension collector adds five focused tests for native tail calls, command-r
|
|
| 1709 |
- [BSP leaf enumeration for entity bounds](RUST_BSP_BOX.md)
|
| 1710 |
|
| 1711 |
- [Entity link ownership and BSP metadata](RUST_ENTITY_LINKS.md)
|
|
|
|
|
|
|
|
|
| 1709 |
- [BSP leaf enumeration for entity bounds](RUST_BSP_BOX.md)
|
| 1710 |
|
| 1711 |
- [Entity link ownership and BSP metadata](RUST_ENTITY_LINKS.md)
|
| 1712 |
+
|
| 1713 |
+
- [Ownership of registered entity slots](RUST_SERVER_ENTITIES.md)
|
docs/research/RUST_SERVER_ENTITIES.md
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Ownership of registered entity slots
|
| 2 |
+
|
| 3 |
+
`ServerEntities` owns the fixed game pool and its linked BSP metadata. Successful allocation returns a slot identity with a generation scoped to the server world. Free and expiry consume unlink requests before returning external resource requests. Reusing the same slot produces a new generation, so a stored handle to its earlier occupant cannot relink the new record.
|
| 4 |
+
|
| 5 |
+
[The server-pool fixture](rust-server-entities.json) checks that a temporary event remains a spatial candidate at age 300 and disappears at 301. Allocation just before the reuse threshold extends the pool, then reuses the old slot at the threshold. A full-pool terminal preserves the allocator's recorded count of 1025 while registered capacity remains 1024 and no new identity is issued. The fixture supplies frame timing. The allocated callback still needs to consume this pool at the event link boundary.
|
docs/research/rust-server-entities.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"expected": {
|
| 3 |
+
"at_300": [
|
| 4 |
+
64
|
| 5 |
+
],
|
| 6 |
+
"at_301": [],
|
| 7 |
+
"dispatch_300": false,
|
| 8 |
+
"expired_dispatch": false,
|
| 9 |
+
"extended": 65,
|
| 10 |
+
"linked": [
|
| 11 |
+
64
|
| 12 |
+
],
|
| 13 |
+
"linked_word": 1,
|
| 14 |
+
"no_slot": true,
|
| 15 |
+
"older_removed": true,
|
| 16 |
+
"registered": 66,
|
| 17 |
+
"registered_terminal": 1024,
|
| 18 |
+
"resource_releases": 1,
|
| 19 |
+
"retry_rejected": true,
|
| 20 |
+
"reused": 64,
|
| 21 |
+
"stale_rejected": true,
|
| 22 |
+
"terminal_count": 1025,
|
| 23 |
+
"terminal_status": "fatal-error-pending",
|
| 24 |
+
"visible": [
|
| 25 |
+
64
|
| 26 |
+
]
|
| 27 |
+
},
|
| 28 |
+
"limits": "Controlled BSP server pool composition. Resource releases remain requests and frame ticks are supplied.",
|
| 29 |
+
"rust": {
|
| 30 |
+
"at_300": [
|
| 31 |
+
64
|
| 32 |
+
],
|
| 33 |
+
"at_301": [],
|
| 34 |
+
"dispatch_300": false,
|
| 35 |
+
"expired_dispatch": false,
|
| 36 |
+
"extended": 65,
|
| 37 |
+
"linked": [
|
| 38 |
+
64
|
| 39 |
+
],
|
| 40 |
+
"linked_word": 1,
|
| 41 |
+
"no_slot": true,
|
| 42 |
+
"older_removed": true,
|
| 43 |
+
"registered": 66,
|
| 44 |
+
"registered_terminal": 1024,
|
| 45 |
+
"resource_releases": 1,
|
| 46 |
+
"retry_rejected": true,
|
| 47 |
+
"reused": 64,
|
| 48 |
+
"stale_rejected": true,
|
| 49 |
+
"terminal_count": 1025,
|
| 50 |
+
"terminal_status": "fatal-error-pending",
|
| 51 |
+
"visible": [
|
| 52 |
+
64
|
| 53 |
+
]
|
| 54 |
+
}
|
| 55 |
+
}
|
scripts/analyze_rust_server_entities.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Check registration, linking, expiry, and stale identities on one server pool."""
|
| 2 |
+
import json
|
| 3 |
+
import os
|
| 4 |
+
import subprocess
|
| 5 |
+
from pathlib import Path
|
| 6 |
+
|
| 7 |
+
from analyze_qvm import write_json
|
| 8 |
+
from analyze_rust_world_visibility import fixture
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def main():
|
| 12 |
+
subprocess.run(['cargo', 'build', '--offline', '-p', 'urt-gameplay', '--bin',
|
| 13 |
+
'urt-server-entities'], check=True)
|
| 14 |
+
binary = Path(os.environ.get('CARGO_TARGET_DIR', 'target')) / 'debug' / 'urt-server-entities'
|
| 15 |
+
actual = json.loads(subprocess.run([str(binary)], input=fixture(3), check=True,
|
| 16 |
+
capture_output=True).stdout)
|
| 17 |
+
expected = dict(linked=[64], at_300=[64], dispatch_300=False, at_301=[],
|
| 18 |
+
expired_dispatch=False, older_removed=True, extended=65,
|
| 19 |
+
reused=64, stale_rejected=True, visible=[64], registered=66,
|
| 20 |
+
linked_word=1, resource_releases=1, terminal_status='fatal-error-pending',
|
| 21 |
+
terminal_count=1025, registered_terminal=1024, no_slot=True,
|
| 22 |
+
retry_rejected=True)
|
| 23 |
+
write_json(Path('docs/research/rust-server-entities.json'), {
|
| 24 |
+
'expected': expected, 'rust': actual,
|
| 25 |
+
'limits': 'Controlled BSP server pool composition. Resource releases remain requests and frame ticks are supplied.',
|
| 26 |
+
})
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
if __name__ == '__main__':
|
| 30 |
+
main()
|
scripts/test_rust_server_entities.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json
|
| 2 |
+
import unittest
|
| 3 |
+
from pathlib import Path
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
class ServerEntityTests(unittest.TestCase):
|
| 7 |
+
def test_registered_spatial_lifetime(self):
|
| 8 |
+
report = json.loads(Path('docs/research/rust-server-entities.json').read_text())
|
| 9 |
+
self.assertEqual(report['rust'], report['expected'])
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
if __name__ == '__main__':
|
| 13 |
+
unittest.main()
|
xtask/checks.tsv
CHANGED
|
@@ -4974,3 +4974,16 @@ edge crates/urt-gameplay/src/spatial_index.rs scripts/analyze_rust_entity_links.
|
|
| 4974 |
edge crates/urt-gameplay/src/entity_links.rs scripts/analyze_rust_entity_links.py
|
| 4975 |
edge crates/urt-gameplay/src/bin/urt-entity-links.rs scripts/analyze_rust_entity_links.py
|
| 4976 |
edge crates/urt-gameplay/src/entity_links.rs scripts/analyze_rust_health_impulse.py
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4974 |
edge crates/urt-gameplay/src/entity_links.rs scripts/analyze_rust_entity_links.py
|
| 4975 |
edge crates/urt-gameplay/src/bin/urt-entity-links.rs scripts/analyze_rust_entity_links.py
|
| 4976 |
edge crates/urt-gameplay/src/entity_links.rs scripts/analyze_rust_health_impulse.py
|
| 4977 |
+
report scripts/analyze_rust_server_entities.py docs/research/rust-server-entities.json
|
| 4978 |
+
edge docs/research/rust-server-entities.json scripts/test_rust_server_entities.py
|
| 4979 |
+
group rust-server-entities scripts/analyze_rust_server_entities.py
|
| 4980 |
+
group rust-server-entities scripts/analyze_rust_entity_event_expiry.py
|
| 4981 |
+
group rust-server-entities scripts/analyze_rust_entity_links.py
|
| 4982 |
+
group gameplay scripts/analyze_rust_server_entities.py
|
| 4983 |
+
edge crates/urt-gameplay/src/server_entities.rs scripts/analyze_rust_server_entities.py
|
| 4984 |
+
edge crates/urt-gameplay/src/entity_links.rs scripts/analyze_rust_server_entities.py
|
| 4985 |
+
edge crates/urt-gameplay/src/spatial_index.rs scripts/analyze_rust_server_entities.py
|
| 4986 |
+
edge crates/urt-gameplay/src/location_feedback.rs scripts/analyze_rust_server_entities.py
|
| 4987 |
+
edge crates/urt-assets/src/bsp.rs scripts/analyze_rust_server_entities.py
|
| 4988 |
+
edge crates/urt-gameplay/src/bin/urt-server-entities.rs scripts/analyze_rust_server_entities.py
|
| 4989 |
+
edge crates/urt-gameplay/src/server_entities.rs scripts/analyze_rust_health_impulse.py
|