gameplay: compose registered defuse feedback
Browse files- crates/urt-gameplay/src/bin/urt-defuse.rs +175 -0
- crates/urt-gameplay/src/lib.rs +2 -0
- crates/urt-gameplay/src/server_defuse_frame.rs +107 -0
- crates/urt-gameplay/src/server_entities.rs +17 -3
- docs/FINDINGS.md +2 -0
- docs/PROVISIONAL_TODO.md +2 -0
- docs/RESEARCH_LEDGER.md +4 -0
- docs/research/README.md +4 -0
- docs/research/RUST_SERVER_DEFUSE_FEEDBACK.md +5 -0
- docs/research/RUST_SERVER_WORLD_BATCH.md +14 -0
- docs/research/rust-server-defuse-feedback.json +123 -0
- scripts/analyze_rust_server_defuse_feedback.py +34 -0
- scripts/test_rust_server_defuse_feedback.py +13 -0
- xtask/checks.tsv +12 -0
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-replay" => println!("{}", server_replay(&w)),
|
| 112 |
"server-located" => println!("{}", server_located(&w, false)),
|
| 113 |
"server-stale-location" => println!("{}", server_located(&w, true)),
|
|
@@ -874,3 +875,177 @@ fn server_replay(w: &[u32]) -> String {
|
|
| 874 |
}
|
| 875 |
format!(r#"{{"gap":{gap},"frames":[{}]}}"#, frames.join(","))
|
| 876 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
"log-dispatch" => println!("{}", log_dispatch(&w)),
|
| 109 |
"event-lifecycle" => println!("{}", event_lifecycle(&w)),
|
| 110 |
"located-full" => println!("{}", located_full(&w, None)),
|
| 111 |
+
"server-feedback" => println!("{}", server_feedback(&w)),
|
| 112 |
"server-replay" => println!("{}", server_replay(&w)),
|
| 113 |
"server-located" => println!("{}", server_located(&w, false)),
|
| 114 |
"server-stale-location" => println!("{}", server_located(&w, true)),
|
|
|
|
| 875 |
}
|
| 876 |
format!(r#"{{"gap":{gap},"frames":[{}]}}"#, frames.join(","))
|
| 877 |
}
|
| 878 |
+
|
| 879 |
+
fn server_feedback(w: &[u32]) -> String {
|
| 880 |
+
use std::io::Read;
|
| 881 |
+
use urt_assets::bsp::BspVisibility;
|
| 882 |
+
use urt_gameplay::area_portals::AreaPortals;
|
| 883 |
+
use urt_gameplay::effect_feedback::{
|
| 884 |
+
DefuseLogOutput, DefuseRankAction, DefuseRankSlot, RadioClient,
|
| 885 |
+
};
|
| 886 |
+
use urt_gameplay::location_feedback::DefuseRadioState;
|
| 887 |
+
use urt_gameplay::ranking::Client;
|
| 888 |
+
use urt_gameplay::ranking_population::Slot;
|
| 889 |
+
use urt_gameplay::server_client_events::ServerClientEvents;
|
| 890 |
+
use urt_gameplay::server_defuse_frame::{
|
| 891 |
+
FeedbackSettings, ServerDefuseWork, ServerFeedbackState, advance_server_defuse,
|
| 892 |
+
};
|
| 893 |
+
use urt_gameplay::server_entities::{DefuseFrameInput, ServerDefuseRadio, ServerEntities};
|
| 894 |
+
use urt_gameplay::spatial_index::Bounds;
|
| 895 |
+
use urt_gameplay::world_visibility::WorldVisibility;
|
| 896 |
+
|
| 897 |
+
let (mut world, input) = decode_full(&w[..31]);
|
| 898 |
+
let (mut pool, _, start) = decode_pool(&w[31..]);
|
| 899 |
+
for slot in &mut pool.slots {
|
| 900 |
+
slot.words[416 / 4..464 / 4].fill(0);
|
| 901 |
+
slot.words[500 / 4..512 / 4].fill(0);
|
| 902 |
+
for offset in [
|
| 903 |
+
180, 520, 528, 548, 556, 560, 576, 592, 604, 608, 612, 616, 620,
|
| 904 |
+
] {
|
| 905 |
+
slot.words[offset / 4] = 0;
|
| 906 |
+
}
|
| 907 |
+
}
|
| 908 |
+
let mut bytes = Vec::new();
|
| 909 |
+
std::io::stdin().read_to_end(&mut bytes).unwrap();
|
| 910 |
+
let bsp = BspVisibility::parse(&bytes).unwrap();
|
| 911 |
+
let portals = AreaPortals::new(bsp.area_count());
|
| 912 |
+
let map = WorldVisibility {
|
| 913 |
+
bsp: &bsp,
|
| 914 |
+
portals: &portals,
|
| 915 |
+
ignore_areas: false,
|
| 916 |
+
};
|
| 917 |
+
let bounds = Bounds::new([-128.; 3], [128.; 3]).unwrap();
|
| 918 |
+
let mut server = ServerEntities::new(bounds, pool).unwrap();
|
| 919 |
+
let clients = vec![
|
| 920 |
+
RadioClient {
|
| 921 |
+
connection: 2,
|
| 922 |
+
team: 1
|
| 923 |
+
};
|
| 924 |
+
input.count
|
| 925 |
+
];
|
| 926 |
+
let roster = [4, 3, 5].map(|score| DefuseRankSlot {
|
| 927 |
+
ranking: Slot {
|
| 928 |
+
client: Client {
|
| 929 |
+
spectator_state: 0,
|
| 930 |
+
follow_index: 0,
|
| 931 |
+
connection: 2,
|
| 932 |
+
team: 1,
|
| 933 |
+
spectator_time: 0,
|
| 934 |
+
time: 0,
|
| 935 |
+
class: 0,
|
| 936 |
+
score,
|
| 937 |
+
deaths: 0,
|
| 938 |
+
awards: 0,
|
| 939 |
+
},
|
| 940 |
+
entity_flags: 0,
|
| 941 |
+
rank: 77,
|
| 942 |
+
},
|
| 943 |
+
counters: [0; 15],
|
| 944 |
+
});
|
| 945 |
+
let mut feedback = ServerFeedbackState {
|
| 946 |
+
client_events: ServerClientEvents::new([]).unwrap(),
|
| 947 |
+
radio: DefuseRadioState {
|
| 948 |
+
marker: None,
|
| 949 |
+
ring: 0,
|
| 950 |
+
},
|
| 951 |
+
ranking: roster[..2].to_vec(),
|
| 952 |
+
};
|
| 953 |
+
let settings = FeedbackSettings {
|
| 954 |
+
console: true,
|
| 955 |
+
log_file: 7,
|
| 956 |
+
team_scores: [2, 1],
|
| 957 |
+
paused: false,
|
| 958 |
+
scoreboard: true,
|
| 959 |
+
};
|
| 960 |
+
let context = || ServerDefuseRadio {
|
| 961 |
+
locations: &[],
|
| 962 |
+
order: &[],
|
| 963 |
+
cache: None,
|
| 964 |
+
mode: 8,
|
| 965 |
+
clients: &clients,
|
| 966 |
+
active_server: true,
|
| 967 |
+
};
|
| 968 |
+
let frame = |tick| DefuseFrameInput {
|
| 969 |
+
tick,
|
| 970 |
+
level_start: start,
|
| 971 |
+
callback: Some(input),
|
| 972 |
+
};
|
| 973 |
+
let begin = advance_server_defuse(
|
| 974 |
+
&mut server,
|
| 975 |
+
&map,
|
| 976 |
+
&mut world,
|
| 977 |
+
frame(input.base.tick),
|
| 978 |
+
&mut feedback,
|
| 979 |
+
settings,
|
| 980 |
+
context(),
|
| 981 |
+
|_| None,
|
| 982 |
+
)
|
| 983 |
+
.unwrap();
|
| 984 |
+
let previous_world = world.clone();
|
| 985 |
+
let previous_radio = feedback.radio;
|
| 986 |
+
let terminal_tick = input.base.tick + input.base.duration * 1000;
|
| 987 |
+
let rejected = advance_server_defuse(
|
| 988 |
+
&mut server,
|
| 989 |
+
&map,
|
| 990 |
+
&mut world,
|
| 991 |
+
frame(terminal_tick),
|
| 992 |
+
&mut feedback,
|
| 993 |
+
settings,
|
| 994 |
+
context(),
|
| 995 |
+
|_| None,
|
| 996 |
+
)
|
| 997 |
+
.is_err();
|
| 998 |
+
let retained = server.links().spatial().query(bounds, 32).slots;
|
| 999 |
+
let rollback = rejected && world == previous_world && feedback.radio == previous_radio;
|
| 1000 |
+
feedback.ranking = roster.to_vec();
|
| 1001 |
+
let finish = advance_server_defuse(
|
| 1002 |
+
&mut server,
|
| 1003 |
+
&map,
|
| 1004 |
+
&mut world,
|
| 1005 |
+
frame(terminal_tick),
|
| 1006 |
+
&mut feedback,
|
| 1007 |
+
settings,
|
| 1008 |
+
context(),
|
| 1009 |
+
|_| None,
|
| 1010 |
+
)
|
| 1011 |
+
.unwrap();
|
| 1012 |
+
let work = |effects: &[ServerDefuseWork]| {
|
| 1013 |
+
effects
|
| 1014 |
+
.iter()
|
| 1015 |
+
.map(|effect| match effect {
|
| 1016 |
+
ServerDefuseWork::Release(r) => format!(r#"["release",{}]"#, r.entity.slot()),
|
| 1017 |
+
ServerDefuseWork::Log(DefuseLogOutput::Console(bytes)) => {
|
| 1018 |
+
format!(r#"["console","{}"]"#, hex(bytes))
|
| 1019 |
+
}
|
| 1020 |
+
ServerDefuseWork::Log(DefuseLogOutput::File { handle, bytes }) => {
|
| 1021 |
+
format!(r#"["file",{handle},"{}"]"#, hex(bytes))
|
| 1022 |
+
}
|
| 1023 |
+
ServerDefuseWork::EventLinked(id) => format!(r#"["link",{}]"#, id.slot()),
|
| 1024 |
+
ServerDefuseWork::Radio(plan) => {
|
| 1025 |
+
format!(r#"["radio",{}]"#, plan.output.radio.commands.len())
|
| 1026 |
+
}
|
| 1027 |
+
ServerDefuseWork::Rank(DefuseRankAction::ScoreAttempt { slot, delta }) => {
|
| 1028 |
+
format!(r#"["score",{slot},{delta}]"#)
|
| 1029 |
+
}
|
| 1030 |
+
ServerDefuseWork::Rank(DefuseRankAction::Rank { plan, broadcast }) => format!(
|
| 1031 |
+
r#"["rank",{:?},{broadcast}]"#,
|
| 1032 |
+
plan.ranking.population.order
|
| 1033 |
+
),
|
| 1034 |
+
ServerDefuseWork::Rank(DefuseRankAction::Counter { slot, index }) => {
|
| 1035 |
+
format!(r#"["counter",{slot},{index}]"#)
|
| 1036 |
+
}
|
| 1037 |
+
})
|
| 1038 |
+
.collect::<Vec<_>>()
|
| 1039 |
+
.join(",")
|
| 1040 |
+
};
|
| 1041 |
+
let spatial = server.links().spatial().query(bounds, 32).slots;
|
| 1042 |
+
let scorer = feedback.ranking[2];
|
| 1043 |
+
format!(
|
| 1044 |
+
r#"{{"start":[{}],"finish":[{}],"rollback":{rollback},"retained":{retained:?},"spatial":{spatial:?},"score":{},"counter":{},"registered":{}}}"#,
|
| 1045 |
+
work(&begin.work),
|
| 1046 |
+
work(&finish.work),
|
| 1047 |
+
scorer.ranking.client.score,
|
| 1048 |
+
scorer.counters[5],
|
| 1049 |
+
server.registered_count()
|
| 1050 |
+
)
|
| 1051 |
+
}
|
crates/urt-gameplay/src/lib.rs
CHANGED
|
@@ -215,3 +215,5 @@ pub mod entity_links;
|
|
| 215 |
pub mod server_entities;
|
| 216 |
|
| 217 |
pub mod server_client_events;
|
|
|
|
|
|
|
|
|
| 215 |
pub mod server_entities;
|
| 216 |
|
| 217 |
pub mod server_client_events;
|
| 218 |
+
|
| 219 |
+
pub mod server_defuse_frame;
|
crates/urt-gameplay/src/server_defuse_frame.rs
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//! Registered defuse frame with owned client state and ordered external work.
|
| 2 |
+
use crate::defuse::{DefuseEffect, DefuseWorld};
|
| 3 |
+
use crate::effect_feedback::{
|
| 4 |
+
DefuseLogOutput, DefuseRankAction, DefuseRankSlot, defuse_log_dispatch, resolve_defuse_ranks,
|
| 5 |
+
};
|
| 6 |
+
use crate::location_feedback::{DefuseRadioPlan, DefuseRadioState};
|
| 7 |
+
use crate::native_policy::Error;
|
| 8 |
+
use crate::server_client_events::{ResourceRequest, ServerClientEvents};
|
| 9 |
+
use crate::server_entities::{DefuseFrameInput, EntityId, ServerDefuseRadio, ServerEntities};
|
| 10 |
+
use crate::world_visibility::WorldVisibility;
|
| 11 |
+
|
| 12 |
+
#[derive(Clone)]
|
| 13 |
+
pub struct ServerFeedbackState {
|
| 14 |
+
pub client_events: ServerClientEvents,
|
| 15 |
+
pub radio: DefuseRadioState,
|
| 16 |
+
pub ranking: Vec<DefuseRankSlot>,
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
#[derive(Clone, Copy)]
|
| 20 |
+
pub struct FeedbackSettings {
|
| 21 |
+
pub console: bool,
|
| 22 |
+
pub log_file: u32,
|
| 23 |
+
pub team_scores: [i32; 2],
|
| 24 |
+
pub paused: bool,
|
| 25 |
+
pub scoreboard: bool,
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
pub enum ServerDefuseWork {
|
| 29 |
+
Release(ResourceRequest),
|
| 30 |
+
Log(DefuseLogOutput),
|
| 31 |
+
EventLinked(EntityId),
|
| 32 |
+
Radio(DefuseRadioPlan),
|
| 33 |
+
Rank(DefuseRankAction),
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
pub struct ServerDefuseFrame {
|
| 37 |
+
pub dispatch: Vec<EntityId>,
|
| 38 |
+
pub work: Vec<ServerDefuseWork>,
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
/// Advance a server frame and update both client stores before returning its
|
| 42 |
+
/// ordered work. The caller dispatches the external requests after success.
|
| 43 |
+
pub fn advance_server_defuse(
|
| 44 |
+
server: &mut ServerEntities,
|
| 45 |
+
map: &WorldVisibility<'_, '_>,
|
| 46 |
+
world: &mut DefuseWorld,
|
| 47 |
+
frame: DefuseFrameInput,
|
| 48 |
+
feedback: &mut ServerFeedbackState,
|
| 49 |
+
settings: FeedbackSettings,
|
| 50 |
+
radio_context: ServerDefuseRadio<'_>,
|
| 51 |
+
object_child: impl FnMut(u32) -> Option<u32>,
|
| 52 |
+
) -> Result<ServerDefuseFrame, Error> {
|
| 53 |
+
let mut next_server = server.clone();
|
| 54 |
+
let mut next_world = world.clone();
|
| 55 |
+
let mut next_feedback = feedback.clone();
|
| 56 |
+
let outcome = next_server.advance_defuse_staged(
|
| 57 |
+
map,
|
| 58 |
+
&mut next_world,
|
| 59 |
+
frame,
|
| 60 |
+
&mut next_feedback.radio,
|
| 61 |
+
radio_context,
|
| 62 |
+
object_child,
|
| 63 |
+
)?;
|
| 64 |
+
let resources = next_feedback.client_events.apply(&outcome.aging)?;
|
| 65 |
+
let mut work = resources
|
| 66 |
+
.into_iter()
|
| 67 |
+
.map(ServerDefuseWork::Release)
|
| 68 |
+
.collect::<Vec<_>>();
|
| 69 |
+
if let Some(callback) = outcome.callback {
|
| 70 |
+
if let Some(allocation) = callback.allocation {
|
| 71 |
+
for effect in allocation.before_allocation {
|
| 72 |
+
if let DefuseEffect::Log { format, slot } = effect {
|
| 73 |
+
let outputs = defuse_log_dispatch(
|
| 74 |
+
frame.tick,
|
| 75 |
+
settings.console,
|
| 76 |
+
settings.log_file,
|
| 77 |
+
&format,
|
| 78 |
+
slot,
|
| 79 |
+
)?;
|
| 80 |
+
work.extend(outputs.into_iter().map(ServerDefuseWork::Log));
|
| 81 |
+
}
|
| 82 |
+
}
|
| 83 |
+
if let Some(link) = allocation.link {
|
| 84 |
+
let id = next_server.id_at(link.slot).ok_or(Error::InvalidIndex)?;
|
| 85 |
+
work.push(ServerDefuseWork::EventLinked(id));
|
| 86 |
+
}
|
| 87 |
+
if let Some(radio) = callback.radio {
|
| 88 |
+
work.push(ServerDefuseWork::Radio(radio));
|
| 89 |
+
}
|
| 90 |
+
let rank = resolve_defuse_ranks(
|
| 91 |
+
&mut next_feedback.ranking,
|
| 92 |
+
&allocation.after_allocation,
|
| 93 |
+
settings.team_scores,
|
| 94 |
+
settings.paused,
|
| 95 |
+
settings.scoreboard,
|
| 96 |
+
)?;
|
| 97 |
+
work.extend(rank.into_iter().map(ServerDefuseWork::Rank));
|
| 98 |
+
}
|
| 99 |
+
}
|
| 100 |
+
*server = next_server;
|
| 101 |
+
*world = next_world;
|
| 102 |
+
*feedback = next_feedback;
|
| 103 |
+
Ok(ServerDefuseFrame {
|
| 104 |
+
dispatch: outcome.aging.dispatch,
|
| 105 |
+
work,
|
| 106 |
+
})
|
| 107 |
+
}
|
crates/urt-gameplay/src/server_entities.rs
CHANGED
|
@@ -389,15 +389,29 @@ impl ServerEntities {
|
|
| 389 |
object_child: impl FnMut(u32) -> Option<u32>,
|
| 390 |
) -> Result<DefuseFrameOutcome, Error> {
|
| 391 |
let mut staged = self.clone();
|
| 392 |
-
let
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 393 |
let callback = frame
|
| 394 |
.callback
|
| 395 |
.map(|mut input| {
|
| 396 |
input.base.tick = frame.tick;
|
| 397 |
-
|
| 398 |
})
|
| 399 |
.transpose()?;
|
| 400 |
-
*self = staged;
|
| 401 |
Ok(DefuseFrameOutcome { aging, callback })
|
| 402 |
}
|
| 403 |
|
|
|
|
| 389 |
object_child: impl FnMut(u32) -> Option<u32>,
|
| 390 |
) -> Result<DefuseFrameOutcome, Error> {
|
| 391 |
let mut staged = self.clone();
|
| 392 |
+
let outcome =
|
| 393 |
+
staged.advance_defuse_staged(visibility, world, frame, radio, context, object_child)?;
|
| 394 |
+
*self = staged;
|
| 395 |
+
Ok(outcome)
|
| 396 |
+
}
|
| 397 |
+
|
| 398 |
+
pub(crate) fn advance_defuse_staged(
|
| 399 |
+
&mut self,
|
| 400 |
+
visibility: &crate::world_visibility::WorldVisibility<'_, '_>,
|
| 401 |
+
world: &mut crate::defuse::DefuseWorld,
|
| 402 |
+
frame: DefuseFrameInput,
|
| 403 |
+
radio: &mut crate::location_feedback::DefuseRadioState,
|
| 404 |
+
context: ServerDefuseRadio<'_>,
|
| 405 |
+
object_child: impl FnMut(u32) -> Option<u32>,
|
| 406 |
+
) -> Result<DefuseFrameOutcome, Error> {
|
| 407 |
+
let aging = self.age_entities(frame.tick, object_child)?;
|
| 408 |
let callback = frame
|
| 409 |
.callback
|
| 410 |
.map(|mut input| {
|
| 411 |
input.base.tick = frame.tick;
|
| 412 |
+
self.process_defuse(visibility, world, input, frame.level_start, radio, context)
|
| 413 |
})
|
| 414 |
.transpose()?;
|
|
|
|
| 415 |
Ok(DefuseFrameOutcome { aging, callback })
|
| 416 |
}
|
| 417 |
|
docs/FINDINGS.md
CHANGED
|
@@ -2093,3 +2093,5 @@ RE-1034–1043 batch validation passed:2,018 Python tests,339 Rust tests,146 det
|
|
| 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).
|
| 2094 |
|
| 2095 |
- Server expiry now clears the owned client event word and rolls back on an unresolved client token. [Server client event ownership](research/RUST_SERVER_CLIENT_EVENTS.md).
|
|
|
|
|
|
|
|
|
| 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).
|
| 2094 |
|
| 2095 |
- Server expiry now clears the owned client event word and rolls back on an unresolved client token. [Server client event ownership](research/RUST_SERVER_CLIENT_EVENTS.md).
|
| 2096 |
+
|
| 2097 |
+
- The registered defuse frame returns ordered expiry, logging, linking, radio and ranking work after updating owned state. [Registered frame feedback](research/RUST_SERVER_DEFUSE_FEEDBACK.md).
|
docs/PROVISIONAL_TODO.md
CHANGED
|
@@ -2155,3 +2155,5 @@ RE-974–983 completed routing, command rewrite, inactivity, movement-parameter
|
|
| 2155 |
- [x] RE-1073 Replay the original defuse lifecycle through registered server frames ([evidence](research/RUST_SERVER_DEFUSE_REPLAY.md)).
|
| 2156 |
|
| 2157 |
- [x] RE-1074 Apply server expiry clears to owned client event words ([evidence](research/RUST_SERVER_CLIENT_EVENTS.md)).
|
|
|
|
|
|
|
|
|
| 2155 |
- [x] RE-1073 Replay the original defuse lifecycle through registered server frames ([evidence](research/RUST_SERVER_DEFUSE_REPLAY.md)).
|
| 2156 |
|
| 2157 |
- [x] RE-1074 Apply server expiry clears to owned client event words ([evidence](research/RUST_SERVER_CLIENT_EVENTS.md)).
|
| 2158 |
+
|
| 2159 |
+
- [x] RE-1075 Compose ordered feedback and client ownership in the registered defuse frame ([evidence](research/RUST_SERVER_DEFUSE_FEEDBACK.md)).
|
docs/RESEARCH_LEDGER.md
CHANGED
|
@@ -2971,3 +2971,7 @@ The owned frame path matches both original scripts across expiry, allocation, sp
|
|
| 2971 |
## 2026-11-25 — RE-1074 Apply server expiry clears to owned client event words
|
| 2972 |
|
| 2973 |
Registered expiry now commits entity changes and client event clears together. Missing client tokens preserve both stores, and repeated clears target one shared event word. See [server client event ownership](research/RUST_SERVER_CLIENT_EVENTS.md).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2971 |
## 2026-11-25 — RE-1074 Apply server expiry clears to owned client event words
|
| 2972 |
|
| 2973 |
Registered expiry now commits entity changes and client event clears together. Missing client tokens preserve both stores, and repeated clears target one shared event word. See [server client event ownership](research/RUST_SERVER_CLIENT_EVENTS.md).
|
| 2974 |
+
|
| 2975 |
+
## 2026-11-25 — RE-1075 Compose ordered feedback and client ownership in the registered defuse frame
|
| 2976 |
+
|
| 2977 |
+
The frame applies local state changes together and emits the ordered external work for defuse. A late rank failure rolls back expiry and callback changes. See [registered frame feedback](research/RUST_SERVER_DEFUSE_FEEDBACK.md).
|
docs/research/README.md
CHANGED
|
@@ -1721,3 +1721,7 @@ The extension collector adds five focused tests for native tail calls, command-r
|
|
| 1721 |
- [Multi-frame defuse in the registered server world](RUST_SERVER_DEFUSE_REPLAY.md)
|
| 1722 |
|
| 1723 |
- [Client event ownership during server expiry](RUST_SERVER_CLIENT_EVENTS.md)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1721 |
- [Multi-frame defuse in the registered server world](RUST_SERVER_DEFUSE_REPLAY.md)
|
| 1722 |
|
| 1723 |
- [Client event ownership during server expiry](RUST_SERVER_CLIENT_EVENTS.md)
|
| 1724 |
+
|
| 1725 |
+
- [Ordered feedback in the registered defuse frame](RUST_SERVER_DEFUSE_FEEDBACK.md)
|
| 1726 |
+
|
| 1727 |
+
- [Server world and defuse integration batch](RUST_SERVER_WORLD_BATCH.md)
|
docs/research/RUST_SERVER_DEFUSE_FEEDBACK.md
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Ordered feedback in the registered defuse frame
|
| 2 |
+
|
| 3 |
+
`advance_server_defuse` advances the registered world, applies client event clears, updates radio and ranking state, and returns ordered work. Expiry resource requests precede callback logging. The callback retains console-before-file order, records the linked event, then emits its radio or score, rank and counter actions. The frame stages entity, defuse and feedback state through typed validation.
|
| 4 |
+
|
| 5 |
+
[The controlled start and completion](rust-server-defuse-feedback.json) show the start event linked before its radio plan and the earlier event released before the completion log. A late rank error leaves the starting event linked and permits a corrected retry. Actual console, file, resource, network and scoreboard dispatch still require runtime sinks and the current client session state.
|
docs/research/RUST_SERVER_WORLD_BATCH.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Rust server world and defuse integration
|
| 2 |
+
|
| 3 |
+
RE-1060–1075 connect source-derived spatial policies to the registered server pool. The sector index uses link history for candidate ordering. [Spatial index](RUST_SPATIAL_INDEX.md) records the native tree and placement comparisons. Absolute entity bounds now feed ordered BSP leaf enumeration and [link metadata](RUST_ENTITY_LINKS.md). [World visibility](RUST_WORLD_VISIBILITY.md) composes loaded cluster masks with the current area portal graph.
|
| 4 |
+
|
| 5 |
+
The server pool owns entity generations and linked membership. Registered defuse allocates and links the temporary event before its payload and radio. The frame ages events in slot order and clears the owning client event word. [The registered replay](RUST_SERVER_DEFUSE_REPLAY.md) follows both source schedules through expiry, link removal, slot extension and reuse. [Frame feedback](RUST_SERVER_DEFUSE_FEEDBACK.md) combines local state changes and ordered logs, radio and ranking plans, including rollback when a late validation fails.
|
| 6 |
+
|
| 7 |
+
All 16 tasks passed focused `cargo xtask` validation before commit. At the boundary, `cargo xtask test-full --since 46fc1824` passed 2,051 Python tests in 590 modules and 339 Rust tests. The 161 affected producers regenerated deterministically and left the worktree clean. Storage and whitespace checks passed, along with links across 655 documentation files.
|
| 8 |
+
|
| 9 |
+
## Remaining runtime work
|
| 10 |
+
|
| 11 |
+
- [ ] Source objective and actor state from the server's registered world and client roster throughout command dispatch.
|
| 12 |
+
- [ ] Dispatch the console, file, radio, scoreboard and resource plans through runtime sinks and check client identity at delivery.
|
| 13 |
+
- [ ] Drive portal adjustments and player-command scheduling from the server frame, then connect client-side objective presentation.
|
| 14 |
+
- [ ] Run original-versus-Rust conformance and macOS/Linux acceptance on complete gameplay sessions.
|
docs/research/rust-server-defuse-feedback.json
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"expected": {
|
| 3 |
+
"counter": 1,
|
| 4 |
+
"finish": [
|
| 5 |
+
[
|
| 6 |
+
"release",
|
| 7 |
+
64
|
| 8 |
+
],
|
| 9 |
+
[
|
| 10 |
+
"console",
|
| 11 |
+
"426f6d622077617320646566757365642062792032210a"
|
| 12 |
+
],
|
| 13 |
+
[
|
| 14 |
+
"file",
|
| 15 |
+
7,
|
| 16 |
+
"2020303a313520426f6d622077617320646566757365642062792032210a"
|
| 17 |
+
],
|
| 18 |
+
[
|
| 19 |
+
"link",
|
| 20 |
+
65
|
| 21 |
+
],
|
| 22 |
+
[
|
| 23 |
+
"score",
|
| 24 |
+
2,
|
| 25 |
+
1
|
| 26 |
+
],
|
| 27 |
+
[
|
| 28 |
+
"rank",
|
| 29 |
+
[
|
| 30 |
+
2,
|
| 31 |
+
0,
|
| 32 |
+
1
|
| 33 |
+
],
|
| 34 |
+
true
|
| 35 |
+
],
|
| 36 |
+
[
|
| 37 |
+
"counter",
|
| 38 |
+
2,
|
| 39 |
+
5
|
| 40 |
+
]
|
| 41 |
+
],
|
| 42 |
+
"registered": 66,
|
| 43 |
+
"retained": [
|
| 44 |
+
64
|
| 45 |
+
],
|
| 46 |
+
"rollback": true,
|
| 47 |
+
"score": 6,
|
| 48 |
+
"spatial": [
|
| 49 |
+
65
|
| 50 |
+
],
|
| 51 |
+
"start": [
|
| 52 |
+
[
|
| 53 |
+
"link",
|
| 54 |
+
64
|
| 55 |
+
],
|
| 56 |
+
[
|
| 57 |
+
"radio",
|
| 58 |
+
3
|
| 59 |
+
]
|
| 60 |
+
]
|
| 61 |
+
},
|
| 62 |
+
"limits": "Controlled registered frame through expiry, allocation, radio, logging and ranking. External delivery remains planned.",
|
| 63 |
+
"rust": {
|
| 64 |
+
"counter": 1,
|
| 65 |
+
"finish": [
|
| 66 |
+
[
|
| 67 |
+
"release",
|
| 68 |
+
64
|
| 69 |
+
],
|
| 70 |
+
[
|
| 71 |
+
"console",
|
| 72 |
+
"426f6d622077617320646566757365642062792032210a"
|
| 73 |
+
],
|
| 74 |
+
[
|
| 75 |
+
"file",
|
| 76 |
+
7,
|
| 77 |
+
"2020303a313520426f6d622077617320646566757365642062792032210a"
|
| 78 |
+
],
|
| 79 |
+
[
|
| 80 |
+
"link",
|
| 81 |
+
65
|
| 82 |
+
],
|
| 83 |
+
[
|
| 84 |
+
"score",
|
| 85 |
+
2,
|
| 86 |
+
1
|
| 87 |
+
],
|
| 88 |
+
[
|
| 89 |
+
"rank",
|
| 90 |
+
[
|
| 91 |
+
2,
|
| 92 |
+
0,
|
| 93 |
+
1
|
| 94 |
+
],
|
| 95 |
+
true
|
| 96 |
+
],
|
| 97 |
+
[
|
| 98 |
+
"counter",
|
| 99 |
+
2,
|
| 100 |
+
5
|
| 101 |
+
]
|
| 102 |
+
],
|
| 103 |
+
"registered": 66,
|
| 104 |
+
"retained": [
|
| 105 |
+
64
|
| 106 |
+
],
|
| 107 |
+
"rollback": true,
|
| 108 |
+
"score": 6,
|
| 109 |
+
"spatial": [
|
| 110 |
+
65
|
| 111 |
+
],
|
| 112 |
+
"start": [
|
| 113 |
+
[
|
| 114 |
+
"link",
|
| 115 |
+
64
|
| 116 |
+
],
|
| 117 |
+
[
|
| 118 |
+
"radio",
|
| 119 |
+
3
|
| 120 |
+
]
|
| 121 |
+
]
|
| 122 |
+
}
|
| 123 |
+
}
|
scripts/analyze_rust_server_defuse_feedback.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Check registered frame feedback order and rollback after a late rank error."""
|
| 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_defuse_complete import encode as encode_callback
|
| 9 |
+
from analyze_rust_location_allocation import encode as encode_pool
|
| 10 |
+
from analyze_rust_world_visibility import fixture
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def main():
|
| 14 |
+
subprocess.run(['cargo', 'build', '--offline', '-p', 'urt-gameplay', '--bin',
|
| 15 |
+
'urt-defuse'], check=True)
|
| 16 |
+
binary = Path(os.environ.get('CARGO_TARGET_DIR', 'target')) / 'debug' / 'urt-defuse'
|
| 17 |
+
a = json.loads(Path('docs/research/qvm-defuse-event-lifecycle.json').read_text())['initial']
|
| 18 |
+
words = [*encode_callback(a), *encode_pool(a['allocation'])]
|
| 19 |
+
cmd = [str(binary), 'server-feedback', *[str(w & 0xffffffff) for w in words]]
|
| 20 |
+
rust = json.loads(subprocess.run(cmd, check=True, input=fixture(3), capture_output=True).stdout)
|
| 21 |
+
body = b'Bomb was defused by 2!\n'
|
| 22 |
+
expected = dict(start=[['link', 64], ['radio', 3]],
|
| 23 |
+
finish=[['release', 64], ['console', body.hex()],
|
| 24 |
+
['file', 7, (b' 0:15 ' + body).hex()], ['link', 65],
|
| 25 |
+
['score', 2, 1], ['rank', [2, 0, 1], True], ['counter', 2, 5]],
|
| 26 |
+
rollback=True, retained=[64], spatial=[65], score=6, counter=1, registered=66)
|
| 27 |
+
write_json(Path('docs/research/rust-server-defuse-feedback.json'), {
|
| 28 |
+
'expected': expected, 'rust': rust,
|
| 29 |
+
'limits': 'Controlled registered frame through expiry, allocation, radio, logging and ranking. External delivery remains planned.',
|
| 30 |
+
})
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
if __name__ == '__main__':
|
| 34 |
+
main()
|
scripts/test_rust_server_defuse_feedback.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json
|
| 2 |
+
import unittest
|
| 3 |
+
from pathlib import Path
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
class ServerDefuseFeedbackTests(unittest.TestCase):
|
| 7 |
+
def test_frame_feedback_and_late_rollback(self):
|
| 8 |
+
report = json.loads(Path('docs/research/rust-server-defuse-feedback.json').read_text())
|
| 9 |
+
self.assertEqual(report['rust'], report['expected'])
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
if __name__ == '__main__':
|
| 13 |
+
unittest.main()
|
xtask/checks.tsv
CHANGED
|
@@ -5037,3 +5037,15 @@ edge crates/urt-gameplay/src/server_client_events.rs scripts/analyze_rust_server
|
|
| 5037 |
edge crates/urt-gameplay/src/server_entities.rs scripts/analyze_rust_server_client_events.py
|
| 5038 |
edge crates/urt-gameplay/src/bin/urt-server-entities.rs scripts/analyze_rust_server_client_events.py
|
| 5039 |
edge crates/urt-gameplay/src/server_client_events.rs scripts/analyze_rust_health_impulse.py
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5037 |
edge crates/urt-gameplay/src/server_entities.rs scripts/analyze_rust_server_client_events.py
|
| 5038 |
edge crates/urt-gameplay/src/bin/urt-server-entities.rs scripts/analyze_rust_server_client_events.py
|
| 5039 |
edge crates/urt-gameplay/src/server_client_events.rs scripts/analyze_rust_health_impulse.py
|
| 5040 |
+
report scripts/analyze_rust_server_defuse_feedback.py docs/research/rust-server-defuse-feedback.json
|
| 5041 |
+
edge docs/research/rust-server-defuse-feedback.json scripts/test_rust_server_defuse_feedback.py
|
| 5042 |
+
group rust-server-defuse-feedback scripts/analyze_rust_server_defuse_feedback.py
|
| 5043 |
+
group rust-server-defuse-feedback scripts/analyze_rust_server_defuse_replay.py
|
| 5044 |
+
group rust-server-defuse-feedback scripts/analyze_rust_server_client_events.py
|
| 5045 |
+
group gameplay scripts/analyze_rust_server_defuse_feedback.py
|
| 5046 |
+
edge crates/urt-gameplay/src/server_defuse_frame.rs scripts/analyze_rust_server_defuse_feedback.py
|
| 5047 |
+
edge crates/urt-gameplay/src/server_entities.rs scripts/analyze_rust_server_defuse_feedback.py
|
| 5048 |
+
edge crates/urt-gameplay/src/server_client_events.rs scripts/analyze_rust_server_defuse_feedback.py
|
| 5049 |
+
edge crates/urt-gameplay/src/effect_feedback.rs scripts/analyze_rust_server_defuse_feedback.py
|
| 5050 |
+
edge crates/urt-gameplay/src/bin/urt-defuse.rs scripts/analyze_rust_server_defuse_feedback.py
|
| 5051 |
+
edge crates/urt-gameplay/src/server_defuse_frame.rs scripts/analyze_rust_health_impulse.py
|