nmarshall commited on
Commit
d3fdf7c
·
1 Parent(s): 11f252c

gameplay: replay defuse through server frames

Browse files
crates/urt-gameplay/src/bin/urt-defuse.rs CHANGED
@@ -108,6 +108,7 @@ fn main() {
108
  "log-dispatch" => println!("{}", log_dispatch(&w)),
109
  "event-lifecycle" => println!("{}", event_lifecycle(&w)),
110
  "located-full" => println!("{}", located_full(&w, None)),
 
111
  "server-located" => println!("{}", server_located(&w, false)),
112
  "server-stale-location" => println!("{}", server_located(&w, true)),
113
  "world-located" => println!("{}", located_full(&w[1..], Some(w[0]))),
@@ -414,18 +415,8 @@ fn event_lifecycle(w: &[u32]) -> String {
414
  }
415
  slot.words[424 / 4] = 0x12345658;
416
  }
417
- let resume_tick = 10301 + gap;
418
- let schedule = [
419
- (10000, Some(10f32)),
420
- (10300, None),
421
- (10301, Some(75f32)),
422
- (10602, None),
423
- (resume_tick, Some(10f32)),
424
- (resume_tick + 5000, Some(10f32)),
425
- (resume_tick + 5301, None),
426
- ];
427
  let mut frames = Vec::new();
428
- for (tick, distance) in schedule {
429
  let mut expiries = Vec::new();
430
  for index in 64..pool.count as usize {
431
  let slot = &mut pool.slots[index];
@@ -750,3 +741,136 @@ fn server_located(w: &[u32], stale_location: bool) -> String {
750
  server.registered_count()
751
  )
752
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
  "log-dispatch" => println!("{}", log_dispatch(&w)),
109
  "event-lifecycle" => println!("{}", event_lifecycle(&w)),
110
  "located-full" => println!("{}", located_full(&w, None)),
111
+ "server-replay" => println!("{}", server_replay(&w)),
112
  "server-located" => println!("{}", server_located(&w, false)),
113
  "server-stale-location" => println!("{}", server_located(&w, true)),
114
  "world-located" => println!("{}", located_full(&w[1..], Some(w[0]))),
 
415
  }
416
  slot.words[424 / 4] = 0x12345658;
417
  }
 
 
 
 
 
 
 
 
 
 
418
  let mut frames = Vec::new();
419
+ for (tick, distance) in lifecycle_schedule(gap) {
420
  let mut expiries = Vec::new();
421
  for index in 64..pool.count as usize {
422
  let slot = &mut pool.slots[index];
 
741
  server.registered_count()
742
  )
743
  }
744
+
745
+ fn lifecycle_schedule(gap: u32) -> [(u32, Option<f32>); 7] {
746
+ let resume_tick = 10301 + gap;
747
+ [
748
+ (10000, Some(10f32)),
749
+ (10300, None),
750
+ (10301, Some(75f32)),
751
+ (10602, None),
752
+ (resume_tick, Some(10f32)),
753
+ (resume_tick + 5000, Some(10f32)),
754
+ (resume_tick + 5301, None),
755
+ ]
756
+ }
757
+
758
+ fn server_replay(w: &[u32]) -> String {
759
+ use std::io::Read;
760
+ use urt_assets::bsp::BspVisibility;
761
+ use urt_gameplay::area_portals::AreaPortals;
762
+ use urt_gameplay::effect_feedback::RadioClient;
763
+ use urt_gameplay::location_feedback::DefuseRadioState;
764
+ use urt_gameplay::server_entities::{
765
+ DefuseFrameInput, EntityFrameEffect, ServerDefuseRadio, ServerEntities,
766
+ };
767
+ use urt_gameplay::spatial_index::Bounds;
768
+ use urt_gameplay::world_visibility::WorldVisibility;
769
+
770
+ let (mut world, input) = decode_full(&w[..31]);
771
+ let gap = w[31];
772
+ let (mut pool, _, start) = decode_pool(&w[32..]);
773
+ for record in &mut pool.slots {
774
+ record.words[416 / 4..464 / 4].fill(0);
775
+ record.words[500 / 4..512 / 4].fill(0);
776
+ for offset in [
777
+ 180, 520, 528, 548, 556, 560, 576, 592, 604, 608, 612, 616, 620,
778
+ ] {
779
+ record.words[offset / 4] = 0;
780
+ }
781
+ }
782
+ let mut bytes = Vec::new();
783
+ std::io::stdin().read_to_end(&mut bytes).unwrap();
784
+ let bsp = BspVisibility::parse(&bytes).unwrap();
785
+ let portals = AreaPortals::new(bsp.area_count());
786
+ let map = WorldVisibility {
787
+ bsp: &bsp,
788
+ portals: &portals,
789
+ ignore_areas: false,
790
+ };
791
+ let bounds = Bounds::new([-128.; 3], [128.; 3]).unwrap();
792
+ let mut server = ServerEntities::new(bounds, pool).unwrap();
793
+ let clients = vec![
794
+ RadioClient {
795
+ connection: 2,
796
+ team: 1
797
+ };
798
+ input.count
799
+ ];
800
+ let mut radio = DefuseRadioState {
801
+ marker: None,
802
+ ring: 0,
803
+ };
804
+ let mut frames = Vec::new();
805
+ for (tick, distance) in lifecycle_schedule(gap) {
806
+ let callback = distance.map(|distance| {
807
+ world.bombs[4].point[0] = distance.to_bits();
808
+ input
809
+ });
810
+ let frame = server
811
+ .advance_defuse_frame(
812
+ &map,
813
+ &mut world,
814
+ DefuseFrameInput {
815
+ tick,
816
+ level_start: start,
817
+ callback,
818
+ },
819
+ &mut radio,
820
+ ServerDefuseRadio {
821
+ locations: &[],
822
+ order: &[],
823
+ cache: None,
824
+ mode: 8,
825
+ clients: &clients,
826
+ active_server: true,
827
+ },
828
+ |_| None,
829
+ )
830
+ .unwrap();
831
+ let mut selected = "null".to_string();
832
+ let mut registrations = vec![];
833
+ let mut planned = Vec::new();
834
+ if let Some(done) = frame.callback {
835
+ if let Some(allocation) = done.allocation {
836
+ selected = allocation.allocation.selected.unwrap().to_string();
837
+ registrations = allocation.allocation.registrations;
838
+ let mut after = allocation.after_allocation;
839
+ if let Some(radio) = done.radio {
840
+ assert!(after.is_empty());
841
+ after.push(DefuseEffect::TeamRadio {
842
+ slot: radio.slot,
843
+ code: radio.code,
844
+ });
845
+ }
846
+ planned =
847
+ allocation_effects(allocation.before_allocation, allocation.event_kind, after);
848
+ }
849
+ }
850
+ let resources = frame
851
+ .aging
852
+ .effects
853
+ .iter()
854
+ .map(|effect| match effect {
855
+ EntityFrameEffect::Release {
856
+ entity,
857
+ request: EntityRelease::ReleaseResource(_),
858
+ } => entity.slot(),
859
+ _ => panic!("unexpected external effect in lifecycle fixture"),
860
+ })
861
+ .collect::<Vec<_>>();
862
+ let spatial = server.links().spatial().query(bounds, 32).slots;
863
+ let active = (64..server.registered_count() as usize)
864
+ .filter_map(|slot| server.id_at(slot))
865
+ .map(|id| {
866
+ let words = &server.record(id).unwrap().words;
867
+ list(&[id.slot() as u32, words[1], words[184 / 4], words[568 / 4]])
868
+ })
869
+ .collect::<Vec<_>>();
870
+ frames.push(format!(
871
+ r#"{{"tick":{tick},"count":{},"selected":{selected},"registrations":{},"active":[{}],"events":[{}],"resources":{resources:?},"spatial":{spatial:?}}}"#,
872
+ server.registered_count(), list(&registrations), active.join(","), events(&planned),
873
+ ));
874
+ }
875
+ format!(r#"{{"gap":{gap},"frames":[{}]}}"#, frames.join(","))
876
+ }
crates/urt-gameplay/src/server_entities.rs CHANGED
@@ -159,16 +159,26 @@ impl ServerEntities {
159
  mut object_child: impl FnMut(u32) -> Option<u32>,
160
  ) -> Result<ServerEntityFrame, Error> {
161
  let mut staged = self.clone();
 
 
 
 
 
 
 
 
 
 
162
  let mut out = ServerEntityFrame::default();
163
  for slot in 0..self.registered_count as usize {
164
- let Some(id) = staged.id_at(slot) else {
165
  continue;
166
  };
167
- let client = staged.pool.slots[slot].words[520 / 4];
168
  // The QVM writes zero without inspecting the old client event word.
169
  let mut client_event = 1;
170
  let event = (client != 0).then_some(&mut client_event);
171
- let result = staged.expire(id, tick, event, &mut object_child)?;
172
  if client_event == 0 {
173
  out.effects
174
  .push(EntityFrameEffect::ClearClientEvent { entity: id, client });
@@ -187,7 +197,6 @@ impl ServerEntities {
187
  out.dispatch.push(id);
188
  }
189
  }
190
- *self = staged;
191
  Ok(out)
192
  }
193
 
@@ -235,6 +244,18 @@ pub struct ServerDefuseRadio<'a> {
235
  pub active_server: bool,
236
  }
237
 
 
 
 
 
 
 
 
 
 
 
 
 
238
  struct ServerDefuseSpatial<'a, 'map> {
239
  visibility: &'a crate::world_visibility::WorldVisibility<'a, 'map>,
240
  links: &'a mut EntityLinks,
@@ -335,6 +356,30 @@ impl ServerEntities {
335
  Ok(outcome)
336
  }
337
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
338
  fn note_allocation(
339
  &mut self,
340
  allocation: &AllocationOutcome,
 
159
  mut object_child: impl FnMut(u32) -> Option<u32>,
160
  ) -> Result<ServerEntityFrame, Error> {
161
  let mut staged = self.clone();
162
+ let out = staged.age_entities(tick, &mut object_child)?;
163
+ *self = staged;
164
+ Ok(out)
165
+ }
166
+
167
+ fn age_entities(
168
+ &mut self,
169
+ tick: u32,
170
+ mut object_child: impl FnMut(u32) -> Option<u32>,
171
+ ) -> Result<ServerEntityFrame, Error> {
172
  let mut out = ServerEntityFrame::default();
173
  for slot in 0..self.registered_count as usize {
174
+ let Some(id) = self.id_at(slot) else {
175
  continue;
176
  };
177
+ let client = self.pool.slots[slot].words[520 / 4];
178
  // The QVM writes zero without inspecting the old client event word.
179
  let mut client_event = 1;
180
  let event = (client != 0).then_some(&mut client_event);
181
+ let result = self.expire(id, tick, event, &mut object_child)?;
182
  if client_event == 0 {
183
  out.effects
184
  .push(EntityFrameEffect::ClearClientEvent { entity: id, client });
 
197
  out.dispatch.push(id);
198
  }
199
  }
 
200
  Ok(out)
201
  }
202
 
 
244
  pub active_server: bool,
245
  }
246
 
247
+ #[derive(Clone, Copy)]
248
+ pub struct DefuseFrameInput {
249
+ pub tick: u32,
250
+ pub level_start: u32,
251
+ pub callback: Option<crate::defuse::FullDefuseInput>,
252
+ }
253
+
254
+ pub struct DefuseFrameOutcome {
255
+ pub aging: ServerEntityFrame,
256
+ pub callback: Option<crate::location_feedback::LocatedDefuseOutcome>,
257
+ }
258
+
259
  struct ServerDefuseSpatial<'a, 'map> {
260
  visibility: &'a crate::world_visibility::WorldVisibility<'a, 'map>,
261
  links: &'a mut EntityLinks,
 
356
  Ok(outcome)
357
  }
358
 
359
+ /// Age the linked server entities, then run the scheduled defuse callback.
360
+ /// Both phases use the frame tick and commit together.
361
+ pub fn advance_defuse_frame(
362
+ &mut self,
363
+ visibility: &crate::world_visibility::WorldVisibility<'_, '_>,
364
+ world: &mut crate::defuse::DefuseWorld,
365
+ frame: DefuseFrameInput,
366
+ radio: &mut crate::location_feedback::DefuseRadioState,
367
+ context: ServerDefuseRadio<'_>,
368
+ object_child: impl FnMut(u32) -> Option<u32>,
369
+ ) -> Result<DefuseFrameOutcome, Error> {
370
+ let mut staged = self.clone();
371
+ let aging = staged.age_entities(frame.tick, object_child)?;
372
+ let callback = frame
373
+ .callback
374
+ .map(|mut input| {
375
+ input.base.tick = frame.tick;
376
+ staged.process_defuse(visibility, world, input, frame.level_start, radio, context)
377
+ })
378
+ .transpose()?;
379
+ *self = staged;
380
+ Ok(DefuseFrameOutcome { aging, callback })
381
+ }
382
+
383
  fn note_allocation(
384
  &mut self,
385
  allocation: &AllocationOutcome,
docs/FINDINGS.md CHANGED
@@ -2089,3 +2089,5 @@ RE-1034–1043 batch validation passed:2,018 Python tests,339 Rust tests,146 det
2089
  - The server expiry pass consumes unlink while preserving client clear and resource request order across slots. [Server expiry frame](research/RUST_SERVER_EXPIRY_FRAME.md).
2090
 
2091
  - Server radio no longer resolves a stale location handle as the slot's replacement occupant. [Server location identities](research/RUST_SERVER_LOCATION_IDENTITY.md).
 
 
 
2089
  - The server expiry pass consumes unlink while preserving client clear and resource request order across slots. [Server expiry frame](research/RUST_SERVER_EXPIRY_FRAME.md).
2090
 
2091
  - Server radio no longer resolves a stale location handle as the slot's replacement occupant. [Server location identities](research/RUST_SERVER_LOCATION_IDENTITY.md).
2092
+
2093
+ - Server-owned expiry and callback scheduling reproduce the two seven-frame defuse traces, including spatial membership after each step. [Registered replay](research/RUST_SERVER_DEFUSE_REPLAY.md).
docs/PROVISIONAL_TODO.md CHANGED
@@ -2151,3 +2151,5 @@ RE-974–983 completed routing, command rewrite, inactivity, movement-parameter
2151
  - [x] RE-1071 Advance server entity expiry in slot order and report external work ([evidence](research/RUST_SERVER_EXPIRY_FRAME.md)).
2152
 
2153
  - [x] RE-1072 Bind server location records and caches to entity generations ([evidence](research/RUST_SERVER_LOCATION_IDENTITY.md)).
 
 
 
2151
  - [x] RE-1071 Advance server entity expiry in slot order and report external work ([evidence](research/RUST_SERVER_EXPIRY_FRAME.md)).
2152
 
2153
  - [x] RE-1072 Bind server location records and caches to entity generations ([evidence](research/RUST_SERVER_LOCATION_IDENTITY.md)).
2154
+
2155
+ - [x] RE-1073 Replay the original defuse lifecycle through registered server frames ([evidence](research/RUST_SERVER_DEFUSE_REPLAY.md)).
docs/RESEARCH_LEDGER.md CHANGED
@@ -2963,3 +2963,7 @@ The frame pass advances the owned spatial lifetimes, emits ordered client and re
2963
  ## 2026-11-25 — RE-1072 Bind server location records and caches to entity generations
2964
 
2965
  Registered defuse dispatch retains valid cached text and discards stale location records even when the slot is reused by the event. See [server location identities](research/RUST_SERVER_LOCATION_IDENTITY.md).
 
 
 
 
 
2963
  ## 2026-11-25 — RE-1072 Bind server location records and caches to entity generations
2964
 
2965
  Registered defuse dispatch retains valid cached text and discards stale location records even when the slot is reused by the event. See [server location identities](research/RUST_SERVER_LOCATION_IDENTITY.md).
2966
+
2967
+ ## 2026-11-25 — RE-1073 Replay the original defuse lifecycle through registered server frames
2968
+
2969
+ The owned frame path matches both original scripts across expiry, allocation, spatial membership and the source effect order. See [registered server replay](research/RUST_SERVER_DEFUSE_REPLAY.md).
docs/research/README.md CHANGED
@@ -1717,3 +1717,5 @@ The extension collector adds five focused tests for native tail calls, command-r
1717
  - [Slot-ordered server expiry pass](RUST_SERVER_EXPIRY_FRAME.md)
1718
 
1719
  - [Generation-aware server locations](RUST_SERVER_LOCATION_IDENTITY.md)
 
 
 
1717
  - [Slot-ordered server expiry pass](RUST_SERVER_EXPIRY_FRAME.md)
1718
 
1719
  - [Generation-aware server locations](RUST_SERVER_LOCATION_IDENTITY.md)
1720
+
1721
+ - [Multi-frame defuse in the registered server world](RUST_SERVER_DEFUSE_REPLAY.md)
docs/research/RUST_SERVER_DEFUSE_REPLAY.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ # Multi-frame defuse in the registered server world
2
+
3
+ `ServerEntities::advance_defuse_frame` runs the event-aging pass before the scheduled callback, using one tick for both. It stages the server pool and commits both phases when the callback succeeds. Successfully constructed events are visible in the sector index and are removed through the same frame expiry path.
4
+
5
+ [Both original seven-frame schedules](rust-server-defuse-replay.json) agree on registration, selected slot, live temporary events, payloads, and retained external requests. The earlier 999/1000 free-age threshold produces the same change from pool extension to reuse, with matching spatial membership. Frame ticks and callbacks are fixture inputs. The runtime still needs player command scheduling and delivery of the external plans.
docs/research/rust-server-defuse-replay.json ADDED
@@ -0,0 +1,719 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "baseline": "docs/research/qvm-defuse-event-lifecycle.json",
3
+ "baseline_sha256": "5c64be3c674b061ea810ee7029b7172135f9f661d874646c000a28d1f05318fd",
4
+ "limits": "Source replay ticks through the owned frame, linking, and defuse phases.",
5
+ "probes": [
6
+ {
7
+ "expected": {
8
+ "frames": [
9
+ {
10
+ "active": [
11
+ [
12
+ 64,
13
+ 102,
14
+ 5,
15
+ 10000
16
+ ]
17
+ ],
18
+ "count": 65,
19
+ "events": [
20
+ {
21
+ "event": 83,
22
+ "op": "allocate"
23
+ },
24
+ {
25
+ "op": "sound",
26
+ "slot": 2,
27
+ "sound": 7
28
+ }
29
+ ],
30
+ "registrations": [
31
+ 65
32
+ ],
33
+ "resources": [],
34
+ "selected": 64,
35
+ "spatial": [
36
+ 64
37
+ ],
38
+ "tick": 10000
39
+ },
40
+ {
41
+ "active": [
42
+ [
43
+ 64,
44
+ 102,
45
+ 5,
46
+ 10000
47
+ ]
48
+ ],
49
+ "count": 65,
50
+ "events": [],
51
+ "registrations": [],
52
+ "resources": [],
53
+ "selected": null,
54
+ "spatial": [
55
+ 64
56
+ ],
57
+ "tick": 10300
58
+ },
59
+ {
60
+ "active": [
61
+ [
62
+ 65,
63
+ 103,
64
+ 0,
65
+ 10301
66
+ ]
67
+ ],
68
+ "count": 66,
69
+ "events": [
70
+ {
71
+ "event": 84,
72
+ "op": "allocate"
73
+ }
74
+ ],
75
+ "registrations": [
76
+ 66
77
+ ],
78
+ "resources": [
79
+ 64
80
+ ],
81
+ "selected": 65,
82
+ "spatial": [
83
+ 65
84
+ ],
85
+ "tick": 10301
86
+ },
87
+ {
88
+ "active": [],
89
+ "count": 66,
90
+ "events": [],
91
+ "registrations": [],
92
+ "resources": [
93
+ 65
94
+ ],
95
+ "selected": null,
96
+ "spatial": [],
97
+ "tick": 10602
98
+ },
99
+ {
100
+ "active": [
101
+ [
102
+ 66,
103
+ 102,
104
+ 5,
105
+ 11300
106
+ ]
107
+ ],
108
+ "count": 67,
109
+ "events": [
110
+ {
111
+ "event": 83,
112
+ "op": "allocate"
113
+ },
114
+ {
115
+ "op": "sound",
116
+ "slot": 2,
117
+ "sound": 7
118
+ }
119
+ ],
120
+ "registrations": [
121
+ 67
122
+ ],
123
+ "resources": [],
124
+ "selected": 66,
125
+ "spatial": [
126
+ 66
127
+ ],
128
+ "tick": 11300
129
+ },
130
+ {
131
+ "active": [
132
+ [
133
+ 64,
134
+ 103,
135
+ 1,
136
+ 16300
137
+ ]
138
+ ],
139
+ "count": 67,
140
+ "events": [
141
+ {
142
+ "format": "426f6d62207761732064656675736564206279202569210a",
143
+ "op": "log",
144
+ "slot": 2
145
+ },
146
+ {
147
+ "event": 84,
148
+ "op": "allocate"
149
+ },
150
+ {
151
+ "op": "teleport",
152
+ "slot": 2
153
+ },
154
+ {
155
+ "op": "award",
156
+ "slot": 2,
157
+ "value": 5
158
+ }
159
+ ],
160
+ "registrations": [],
161
+ "resources": [
162
+ 66
163
+ ],
164
+ "selected": 64,
165
+ "spatial": [
166
+ 64
167
+ ],
168
+ "tick": 16300
169
+ },
170
+ {
171
+ "active": [],
172
+ "count": 67,
173
+ "events": [],
174
+ "registrations": [],
175
+ "resources": [
176
+ 64
177
+ ],
178
+ "selected": null,
179
+ "spatial": [],
180
+ "tick": 16601
181
+ }
182
+ ],
183
+ "gap": 999
184
+ },
185
+ "rust": {
186
+ "frames": [
187
+ {
188
+ "active": [
189
+ [
190
+ 64,
191
+ 102,
192
+ 5,
193
+ 10000
194
+ ]
195
+ ],
196
+ "count": 65,
197
+ "events": [
198
+ {
199
+ "event": 83,
200
+ "op": "allocate"
201
+ },
202
+ {
203
+ "op": "sound",
204
+ "slot": 2,
205
+ "sound": 7
206
+ }
207
+ ],
208
+ "registrations": [
209
+ 65
210
+ ],
211
+ "resources": [],
212
+ "selected": 64,
213
+ "spatial": [
214
+ 64
215
+ ],
216
+ "tick": 10000
217
+ },
218
+ {
219
+ "active": [
220
+ [
221
+ 64,
222
+ 102,
223
+ 5,
224
+ 10000
225
+ ]
226
+ ],
227
+ "count": 65,
228
+ "events": [],
229
+ "registrations": [],
230
+ "resources": [],
231
+ "selected": null,
232
+ "spatial": [
233
+ 64
234
+ ],
235
+ "tick": 10300
236
+ },
237
+ {
238
+ "active": [
239
+ [
240
+ 65,
241
+ 103,
242
+ 0,
243
+ 10301
244
+ ]
245
+ ],
246
+ "count": 66,
247
+ "events": [
248
+ {
249
+ "event": 84,
250
+ "op": "allocate"
251
+ }
252
+ ],
253
+ "registrations": [
254
+ 66
255
+ ],
256
+ "resources": [
257
+ 64
258
+ ],
259
+ "selected": 65,
260
+ "spatial": [
261
+ 65
262
+ ],
263
+ "tick": 10301
264
+ },
265
+ {
266
+ "active": [],
267
+ "count": 66,
268
+ "events": [],
269
+ "registrations": [],
270
+ "resources": [
271
+ 65
272
+ ],
273
+ "selected": null,
274
+ "spatial": [],
275
+ "tick": 10602
276
+ },
277
+ {
278
+ "active": [
279
+ [
280
+ 66,
281
+ 102,
282
+ 5,
283
+ 11300
284
+ ]
285
+ ],
286
+ "count": 67,
287
+ "events": [
288
+ {
289
+ "event": 83,
290
+ "op": "allocate"
291
+ },
292
+ {
293
+ "op": "sound",
294
+ "slot": 2,
295
+ "sound": 7
296
+ }
297
+ ],
298
+ "registrations": [
299
+ 67
300
+ ],
301
+ "resources": [],
302
+ "selected": 66,
303
+ "spatial": [
304
+ 66
305
+ ],
306
+ "tick": 11300
307
+ },
308
+ {
309
+ "active": [
310
+ [
311
+ 64,
312
+ 103,
313
+ 1,
314
+ 16300
315
+ ]
316
+ ],
317
+ "count": 67,
318
+ "events": [
319
+ {
320
+ "format": "426f6d62207761732064656675736564206279202569210a",
321
+ "op": "log",
322
+ "slot": 2
323
+ },
324
+ {
325
+ "event": 84,
326
+ "op": "allocate"
327
+ },
328
+ {
329
+ "op": "teleport",
330
+ "slot": 2
331
+ },
332
+ {
333
+ "op": "award",
334
+ "slot": 2,
335
+ "value": 5
336
+ }
337
+ ],
338
+ "registrations": [],
339
+ "resources": [
340
+ 66
341
+ ],
342
+ "selected": 64,
343
+ "spatial": [
344
+ 64
345
+ ],
346
+ "tick": 16300
347
+ },
348
+ {
349
+ "active": [],
350
+ "count": 67,
351
+ "events": [],
352
+ "registrations": [],
353
+ "resources": [
354
+ 64
355
+ ],
356
+ "selected": null,
357
+ "spatial": [],
358
+ "tick": 16601
359
+ }
360
+ ],
361
+ "gap": 999
362
+ }
363
+ },
364
+ {
365
+ "expected": {
366
+ "frames": [
367
+ {
368
+ "active": [
369
+ [
370
+ 64,
371
+ 102,
372
+ 5,
373
+ 10000
374
+ ]
375
+ ],
376
+ "count": 65,
377
+ "events": [
378
+ {
379
+ "event": 83,
380
+ "op": "allocate"
381
+ },
382
+ {
383
+ "op": "sound",
384
+ "slot": 2,
385
+ "sound": 7
386
+ }
387
+ ],
388
+ "registrations": [
389
+ 65
390
+ ],
391
+ "resources": [],
392
+ "selected": 64,
393
+ "spatial": [
394
+ 64
395
+ ],
396
+ "tick": 10000
397
+ },
398
+ {
399
+ "active": [
400
+ [
401
+ 64,
402
+ 102,
403
+ 5,
404
+ 10000
405
+ ]
406
+ ],
407
+ "count": 65,
408
+ "events": [],
409
+ "registrations": [],
410
+ "resources": [],
411
+ "selected": null,
412
+ "spatial": [
413
+ 64
414
+ ],
415
+ "tick": 10300
416
+ },
417
+ {
418
+ "active": [
419
+ [
420
+ 65,
421
+ 103,
422
+ 0,
423
+ 10301
424
+ ]
425
+ ],
426
+ "count": 66,
427
+ "events": [
428
+ {
429
+ "event": 84,
430
+ "op": "allocate"
431
+ }
432
+ ],
433
+ "registrations": [
434
+ 66
435
+ ],
436
+ "resources": [
437
+ 64
438
+ ],
439
+ "selected": 65,
440
+ "spatial": [
441
+ 65
442
+ ],
443
+ "tick": 10301
444
+ },
445
+ {
446
+ "active": [],
447
+ "count": 66,
448
+ "events": [],
449
+ "registrations": [],
450
+ "resources": [
451
+ 65
452
+ ],
453
+ "selected": null,
454
+ "spatial": [],
455
+ "tick": 10602
456
+ },
457
+ {
458
+ "active": [
459
+ [
460
+ 64,
461
+ 102,
462
+ 5,
463
+ 11301
464
+ ]
465
+ ],
466
+ "count": 66,
467
+ "events": [
468
+ {
469
+ "event": 83,
470
+ "op": "allocate"
471
+ },
472
+ {
473
+ "op": "sound",
474
+ "slot": 2,
475
+ "sound": 7
476
+ }
477
+ ],
478
+ "registrations": [],
479
+ "resources": [],
480
+ "selected": 64,
481
+ "spatial": [
482
+ 64
483
+ ],
484
+ "tick": 11301
485
+ },
486
+ {
487
+ "active": [
488
+ [
489
+ 65,
490
+ 103,
491
+ 1,
492
+ 16301
493
+ ]
494
+ ],
495
+ "count": 66,
496
+ "events": [
497
+ {
498
+ "format": "426f6d62207761732064656675736564206279202569210a",
499
+ "op": "log",
500
+ "slot": 2
501
+ },
502
+ {
503
+ "event": 84,
504
+ "op": "allocate"
505
+ },
506
+ {
507
+ "op": "teleport",
508
+ "slot": 2
509
+ },
510
+ {
511
+ "op": "award",
512
+ "slot": 2,
513
+ "value": 5
514
+ }
515
+ ],
516
+ "registrations": [],
517
+ "resources": [
518
+ 64
519
+ ],
520
+ "selected": 65,
521
+ "spatial": [
522
+ 65
523
+ ],
524
+ "tick": 16301
525
+ },
526
+ {
527
+ "active": [],
528
+ "count": 66,
529
+ "events": [],
530
+ "registrations": [],
531
+ "resources": [
532
+ 65
533
+ ],
534
+ "selected": null,
535
+ "spatial": [],
536
+ "tick": 16602
537
+ }
538
+ ],
539
+ "gap": 1000
540
+ },
541
+ "rust": {
542
+ "frames": [
543
+ {
544
+ "active": [
545
+ [
546
+ 64,
547
+ 102,
548
+ 5,
549
+ 10000
550
+ ]
551
+ ],
552
+ "count": 65,
553
+ "events": [
554
+ {
555
+ "event": 83,
556
+ "op": "allocate"
557
+ },
558
+ {
559
+ "op": "sound",
560
+ "slot": 2,
561
+ "sound": 7
562
+ }
563
+ ],
564
+ "registrations": [
565
+ 65
566
+ ],
567
+ "resources": [],
568
+ "selected": 64,
569
+ "spatial": [
570
+ 64
571
+ ],
572
+ "tick": 10000
573
+ },
574
+ {
575
+ "active": [
576
+ [
577
+ 64,
578
+ 102,
579
+ 5,
580
+ 10000
581
+ ]
582
+ ],
583
+ "count": 65,
584
+ "events": [],
585
+ "registrations": [],
586
+ "resources": [],
587
+ "selected": null,
588
+ "spatial": [
589
+ 64
590
+ ],
591
+ "tick": 10300
592
+ },
593
+ {
594
+ "active": [
595
+ [
596
+ 65,
597
+ 103,
598
+ 0,
599
+ 10301
600
+ ]
601
+ ],
602
+ "count": 66,
603
+ "events": [
604
+ {
605
+ "event": 84,
606
+ "op": "allocate"
607
+ }
608
+ ],
609
+ "registrations": [
610
+ 66
611
+ ],
612
+ "resources": [
613
+ 64
614
+ ],
615
+ "selected": 65,
616
+ "spatial": [
617
+ 65
618
+ ],
619
+ "tick": 10301
620
+ },
621
+ {
622
+ "active": [],
623
+ "count": 66,
624
+ "events": [],
625
+ "registrations": [],
626
+ "resources": [
627
+ 65
628
+ ],
629
+ "selected": null,
630
+ "spatial": [],
631
+ "tick": 10602
632
+ },
633
+ {
634
+ "active": [
635
+ [
636
+ 64,
637
+ 102,
638
+ 5,
639
+ 11301
640
+ ]
641
+ ],
642
+ "count": 66,
643
+ "events": [
644
+ {
645
+ "event": 83,
646
+ "op": "allocate"
647
+ },
648
+ {
649
+ "op": "sound",
650
+ "slot": 2,
651
+ "sound": 7
652
+ }
653
+ ],
654
+ "registrations": [],
655
+ "resources": [],
656
+ "selected": 64,
657
+ "spatial": [
658
+ 64
659
+ ],
660
+ "tick": 11301
661
+ },
662
+ {
663
+ "active": [
664
+ [
665
+ 65,
666
+ 103,
667
+ 1,
668
+ 16301
669
+ ]
670
+ ],
671
+ "count": 66,
672
+ "events": [
673
+ {
674
+ "format": "426f6d62207761732064656675736564206279202569210a",
675
+ "op": "log",
676
+ "slot": 2
677
+ },
678
+ {
679
+ "event": 84,
680
+ "op": "allocate"
681
+ },
682
+ {
683
+ "op": "teleport",
684
+ "slot": 2
685
+ },
686
+ {
687
+ "op": "award",
688
+ "slot": 2,
689
+ "value": 5
690
+ }
691
+ ],
692
+ "registrations": [],
693
+ "resources": [
694
+ 64
695
+ ],
696
+ "selected": 65,
697
+ "spatial": [
698
+ 65
699
+ ],
700
+ "tick": 16301
701
+ },
702
+ {
703
+ "active": [],
704
+ "count": 66,
705
+ "events": [],
706
+ "registrations": [],
707
+ "resources": [
708
+ 65
709
+ ],
710
+ "selected": null,
711
+ "spatial": [],
712
+ "tick": 16602
713
+ }
714
+ ],
715
+ "gap": 1000
716
+ }
717
+ }
718
+ ]
719
+ }
scripts/analyze_rust_server_defuse_replay.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Replay the source schedules with registered links and owned frame expiry."""
2
+ import hashlib
3
+ import json
4
+ import os
5
+ import subprocess
6
+ from pathlib import Path
7
+
8
+ from analyze_qvm import write_json
9
+ from analyze_rust_defuse_complete import encode as encode_callback
10
+ from analyze_rust_location_allocation import encode as encode_pool
11
+ from analyze_rust_world_visibility import fixture
12
+
13
+
14
+ def main():
15
+ subprocess.run(['cargo', 'build', '--offline', '-p', 'urt-gameplay', '--bin',
16
+ 'urt-defuse'], check=True)
17
+ binary = Path(os.environ.get('CARGO_TARGET_DIR', 'target')) / 'debug' / 'urt-defuse'
18
+ source = Path('docs/research/qvm-defuse-event-lifecycle.json')
19
+ data = source.read_bytes()
20
+ report = json.loads(data)
21
+ a = report['initial']
22
+ probes = []
23
+ for row in report['probes']:
24
+ expected = dict(gap=row['gap'], frames=[])
25
+ for frame in row['frames']:
26
+ projected = {k: v for k, v in frame.items() if k not in ('free', 'expiries')}
27
+ projected.update(spatial=[v[0] for v in frame['active']],
28
+ resources=[r['slot'] for r in frame['expiries'] if 249639 in r['requests']])
29
+ expected['frames'].append(projected)
30
+ words = [*encode_callback(a), row['gap'], *encode_pool(a['allocation'])]
31
+ cmd = [str(binary), 'server-replay', *[str(w & 0xffffffff) for w in words]]
32
+ rust = json.loads(subprocess.run(cmd, check=True, input=fixture(3), capture_output=True).stdout)
33
+ probes.append(dict(expected=expected, rust=rust))
34
+ write_json(Path('docs/research/rust-server-defuse-replay.json'), {
35
+ 'baseline': str(source), 'baseline_sha256': hashlib.sha256(data).hexdigest(),
36
+ 'probes': probes, 'limits': 'Source replay ticks through the owned frame, linking, and defuse phases.',
37
+ })
38
+
39
+
40
+ if __name__ == '__main__':
41
+ main()
scripts/test_rust_server_defuse_replay.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import hashlib
2
+ import json
3
+ import unittest
4
+ from pathlib import Path
5
+
6
+
7
+ class RegisteredDefuseReplayTests(unittest.TestCase):
8
+ def test_owned_frame_and_callback(self):
9
+ report = json.loads(Path('docs/research/rust-server-defuse-replay.json').read_text())
10
+ self.assertEqual(report['baseline_sha256'],
11
+ hashlib.sha256(Path(report['baseline']).read_bytes()).hexdigest())
12
+ self.assertEqual(len(report['probes']), 2)
13
+ for row in report['probes']:
14
+ self.assertEqual(len(row['rust']['frames']), 7)
15
+ with self.subTest(gap=row['rust']['gap']):
16
+ self.assertEqual(row['rust'], row['expected'])
17
+
18
+
19
+ if __name__ == '__main__':
20
+ unittest.main()
xtask/checks.tsv CHANGED
@@ -5018,3 +5018,13 @@ group gameplay scripts/analyze_rust_server_location_identity.py
5018
  edge crates/urt-gameplay/src/server_entities.rs scripts/analyze_rust_server_location_identity.py
5019
  edge crates/urt-gameplay/src/location_feedback.rs scripts/analyze_rust_server_location_identity.py
5020
  edge crates/urt-gameplay/src/bin/urt-defuse.rs scripts/analyze_rust_server_location_identity.py
 
 
 
 
 
 
 
 
 
 
 
5018
  edge crates/urt-gameplay/src/server_entities.rs scripts/analyze_rust_server_location_identity.py
5019
  edge crates/urt-gameplay/src/location_feedback.rs scripts/analyze_rust_server_location_identity.py
5020
  edge crates/urt-gameplay/src/bin/urt-defuse.rs scripts/analyze_rust_server_location_identity.py
5021
+ report scripts/analyze_rust_server_defuse_replay.py docs/research/rust-server-defuse-replay.json
5022
+ edge docs/research/rust-server-defuse-replay.json scripts/test_rust_server_defuse_replay.py
5023
+ edge docs/research/qvm-defuse-event-lifecycle.json scripts/analyze_rust_server_defuse_replay.py
5024
+ group rust-server-defuse-replay scripts/analyze_rust_server_defuse_replay.py
5025
+ group rust-server-defuse-replay scripts/analyze_rust_server_defuse.py
5026
+ group rust-server-defuse-replay scripts/analyze_rust_server_expiry_frame.py
5027
+ group gameplay scripts/analyze_rust_server_defuse_replay.py
5028
+ edge crates/urt-gameplay/src/server_entities.rs scripts/analyze_rust_server_defuse_replay.py
5029
+ edge crates/urt-gameplay/src/location_feedback.rs scripts/analyze_rust_server_defuse_replay.py
5030
+ edge crates/urt-gameplay/src/bin/urt-defuse.rs scripts/analyze_rust_server_defuse_replay.py