nmarshall commited on
Commit
f50958a
·
1 Parent(s): 65208e6

gameplay: resolve whole connect callback policies

Browse files
crates/urt-gameplay/src/bin/urt-native-policy.rs CHANGED
@@ -959,6 +959,105 @@ fn run() -> Result<String, String> {
959
  .map_err(|e| format!("{e:?}"))?;
960
  Ok(complete_json(&out, &client, &entity, ring))
961
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
962
  "bot-settings" => {
963
  if w.len() < 3 {
964
  return Err("missing bot settings header".into());
 
959
  .map_err(|e| format!("{e:?}"))?;
960
  Ok(complete_json(&out, &client, &entity, ring))
961
  }
962
+ "resolved-connect-complete" => {
963
+ if w.len() < 9 {
964
+ return Err("missing complete header".into());
965
+ }
966
+ let n = w[8] as usize;
967
+ if n > 1024 || w.len() < 9 + 2 * n {
968
+ return Err("invalid complete table".into());
969
+ }
970
+ let entries = w[9..9 + 2 * n]
971
+ .chunks_exact(2)
972
+ .map(|v| (v[0], v[1]))
973
+ .collect::<Vec<_>>();
974
+ let mut p = 9 + 2 * n;
975
+ let info = input_blob(&w, &mut p)?.ok_or("null complete info")?;
976
+ let password = input_blob(&w, &mut p)?.ok_or("null complete password")?;
977
+ if p != w.len() {
978
+ return Err("trailing complete words".into());
979
+ }
980
+ let mut client = 0xaabbccddu32.to_le_bytes().repeat(1584);
981
+ client[504..516].fill(0);
982
+ client[504..507].copy_from_slice(b"old");
983
+ let mut entity = CompleteConnectEntity {
984
+ session: ConnectEntity {
985
+ linked_slot: None,
986
+ field764: 0xaabbccdd,
987
+ field768: 0xaabbccdd,
988
+ },
989
+ tail: ConnectTailEntity {
990
+ flags: 32,
991
+ in_use: 0,
992
+ },
993
+ };
994
+ let mut ring = 0;
995
+ let out = resolved_complete_connect(
996
+ &mut client,
997
+ &mut entity,
998
+ CompleteConnectInput {
999
+ admission: AdmissionInput {
1000
+ slot: 3,
1001
+ bot: w[3] as i32,
1002
+ userinfo: &info,
1003
+ password: &password,
1004
+ entries: &entries,
1005
+ count: n as i32,
1006
+ mode: 1,
1007
+ scratch: w[6],
1008
+ },
1009
+ first_time: w[1] as i32,
1010
+ new_session: w[2] as i32,
1011
+ flags: 1,
1012
+ initialize: InitializeInput {
1013
+ mode: w[0] as i32,
1014
+ slot: 3,
1015
+ userinfo: &info,
1016
+ limit: 2,
1017
+ occupancy: 1,
1018
+ seconds: 0,
1019
+ clock: 100,
1020
+ ticks: 17,
1021
+ handle: 7,
1022
+ client_id: 0,
1023
+ enabled: 1,
1024
+ mapname: b"ut4_test",
1025
+ file_length: 11,
1026
+ file_data: b"9,8,7,6,5,4",
1027
+ },
1028
+ session: b"1,-2,3,4,5,1,1,1,1",
1029
+ ignore_text: b"1,3,",
1030
+ scratch: [w[5]; 5],
1031
+ tail: ConnectTailInput {
1032
+ mode: w[0] as i32,
1033
+ slot: 3,
1034
+ first_time: w[1] as i32,
1035
+ bot: w[3] as i32,
1036
+ bot_answer: w[4] as i32,
1037
+ clock: 100,
1038
+ seconds: 0,
1039
+ after_team: if w[7] != 0 { Some(2) } else { None },
1040
+ name: b"new^1name",
1041
+ },
1042
+ },
1043
+ w[4] as i32,
1044
+ &mut ring,
1045
+ )
1046
+ .map_err(|e| format!("{e:?}"))?;
1047
+ {
1048
+ let bot = out
1049
+ .bot
1050
+ .as_ref()
1051
+ .map(|b| bot_settings_json(b, ring))
1052
+ .unwrap_or("null".into());
1053
+ Ok(format!(
1054
+ r#"{{"parent":{},"bot":{bot},"notices":{},"ring":{},"info_ring":{ring}}}"#,
1055
+ complete_json(&out.caller, &client, &entity, ring),
1056
+ notices_json(&out.notices),
1057
+ out.ring_advance
1058
+ ))
1059
+ }
1060
+ }
1061
  "bot-settings" => {
1062
  if w.len() < 3 {
1063
  return Err("missing bot settings header".into());
crates/urt-gameplay/src/native_policy.rs CHANGED
@@ -2973,3 +2973,139 @@ mod resolved_tail_tests {
2973
  assert_eq!(selector, 0);
2974
  }
2975
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2973
  assert_eq!(selector, 0);
2974
  }
2975
  }
2976
+
2977
+ #[derive(Clone, Debug, PartialEq, Eq)]
2978
+ pub struct ResolvedCompleteConnect {
2979
+ pub caller: CompleteConnect,
2980
+ pub bot: Option<BotSettingsPolicy>,
2981
+ pub notices: Vec<TeamNotice>,
2982
+ pub ring_advance: u32,
2983
+ }
2984
+ /// Compose pure supplied-snapshot child policies with the whole caller. Child
2985
+ /// records attach to the parent's Bot/Join request markers; no native effect is
2986
+ /// executed while deriving these deterministic settings/announcement values.
2987
+ pub fn resolved_complete_connect(
2988
+ client: &mut [u8],
2989
+ entity: &mut CompleteConnectEntity,
2990
+ mut input: CompleteConnectInput<'_>,
2991
+ setup_answer: i32,
2992
+ info_ring: &mut u32,
2993
+ ) -> Result<ResolvedCompleteConnect, Error> {
2994
+ let mut bytes = client.to_vec();
2995
+ let mut e = entity.clone();
2996
+ let mut selector = *info_ring;
2997
+ let bot = if input.admission.bot != 0 {
2998
+ let out = bot_settings(
2999
+ input.admission.slot,
3000
+ i32::from(input.first_time == 0),
3001
+ input.admission.userinfo,
3002
+ setup_answer,
3003
+ &mut selector,
3004
+ )?;
3005
+ input.tail.bot_answer = i32::from(out.result);
3006
+ Some(out)
3007
+ } else {
3008
+ None
3009
+ };
3010
+ let caller = complete_connect(&mut bytes, &mut e, input, &mut selector)?;
3011
+ let mut counter = 0;
3012
+ let mut notices = vec![];
3013
+ for event in &caller.events {
3014
+ if let ConnectTailEvent::Join { choice, .. } = event {
3015
+ notices.extend(team_announcement(
3016
+ raw_word(&bytes, 3096) as i32,
3017
+ *choice,
3018
+ &bytes[504..],
3019
+ &mut counter,
3020
+ )?);
3021
+ }
3022
+ }
3023
+ let ring_advance = caller.ring_advance.wrapping_add(counter);
3024
+ client.copy_from_slice(&bytes);
3025
+ *entity = e;
3026
+ *info_ring = selector;
3027
+ Ok(ResolvedCompleteConnect {
3028
+ caller,
3029
+ bot,
3030
+ notices,
3031
+ ring_advance,
3032
+ })
3033
+ }
3034
+ #[cfg(test)]
3035
+ mod resolved_complete_tests {
3036
+ use super::*;
3037
+ #[test]
3038
+ fn unsupported_wrapper_preserves_all_caller_state() {
3039
+ let mut bytes = vec![7; CLIENT_BYTES];
3040
+ let old = bytes.clone();
3041
+ let mut entity = CompleteConnectEntity {
3042
+ session: ConnectEntity {
3043
+ linked_slot: None,
3044
+ field764: 7,
3045
+ field768: 8,
3046
+ },
3047
+ tail: ConnectTailEntity {
3048
+ flags: 32,
3049
+ in_use: 0,
3050
+ },
3051
+ };
3052
+ let before = entity.clone();
3053
+ let info = b"\\skill\\1E2";
3054
+ let mut selector = 0;
3055
+ let result = resolved_complete_connect(
3056
+ &mut bytes,
3057
+ &mut entity,
3058
+ CompleteConnectInput {
3059
+ admission: AdmissionInput {
3060
+ slot: 0,
3061
+ bot: 1,
3062
+ userinfo: info,
3063
+ password: b"",
3064
+ entries: &[],
3065
+ count: 0,
3066
+ mode: 1,
3067
+ scratch: 0,
3068
+ },
3069
+ first_time: 1,
3070
+ new_session: 0,
3071
+ flags: 0,
3072
+ initialize: InitializeInput {
3073
+ mode: 0,
3074
+ slot: 0,
3075
+ userinfo: info,
3076
+ limit: 0,
3077
+ occupancy: 0,
3078
+ seconds: 0,
3079
+ clock: 0,
3080
+ ticks: 0,
3081
+ handle: 0,
3082
+ client_id: 0,
3083
+ enabled: 0,
3084
+ mapname: b"m",
3085
+ file_length: 0,
3086
+ file_data: b"",
3087
+ },
3088
+ session: b"",
3089
+ ignore_text: b"",
3090
+ scratch: [0; 5],
3091
+ tail: ConnectTailInput {
3092
+ mode: 0,
3093
+ slot: 0,
3094
+ first_time: 1,
3095
+ bot: 1,
3096
+ bot_answer: 1,
3097
+ clock: 0,
3098
+ seconds: 0,
3099
+ after_team: None,
3100
+ name: b"n",
3101
+ },
3102
+ },
3103
+ 1,
3104
+ &mut selector,
3105
+ );
3106
+ assert_eq!(result, Err(Error::InvalidInput));
3107
+ assert_eq!(bytes, old);
3108
+ assert_eq!(entity, before);
3109
+ assert_eq!(selector, 0);
3110
+ }
3111
+ }
docs/FINDINGS.md CHANGED
@@ -1790,3 +1790,6 @@ RE-813–822 replaces the scoreboard decimal assumption with actual37914 executi
1790
 
1791
 
1792
  **RE-930:** 96 complete173979 executions replace supplied161744 booleans and captured182896 with actual bot settings/drop and announcement bodies. Parent decisions, client/entity bytes and persistence timing are preserved; setup records, exact broadcasts and extra selector/formatter carry are verified. Native125185 setup,171668 mutation, ranking/logging/network/IO remain supplied/captured. [Evidence](research/QVM_RESOLVED_CONNECT_COMPLETE.md).
 
 
 
 
1790
 
1791
 
1792
  **RE-930:** 96 complete173979 executions replace supplied161744 booleans and captured182896 with actual bot settings/drop and announcement bodies. Parent decisions, client/entity bytes and persistence timing are preserved; setup records, exact broadcasts and extra selector/formatter carry are verified. Native125185 setup,171668 mutation, ranking/logging/network/IO remain supplied/captured. [Evidence](research/QVM_RESOLVED_CONNECT_COMPLETE.md).
1793
+
1794
+
1795
+ **RE-931:** Rust matches96 complete source173979/161744/182896 compositions, including settings/drop records, extra selector toggles and announcement/counter carry while preserving prior caller state, cvar timing and return decisions. Typed errors stage all caller state. Native setup/userinfo/ranking/network/IO remain explicit boundaries. [Evidence](research/RUST_RESOLVED_CONNECT_COMPLETE.md).
docs/PROVISIONAL_TODO.md CHANGED
@@ -1833,3 +1833,6 @@ RE-929: Rust matches144 original suffix compositions with actual161744/182896 po
1833
 
1834
 
1835
  RE-930: 96 complete173979 executions replace supplied161744 booleans and captured182896 with actual bot settings/drop and announcement bodies. Parent decisions, client/entity bytes and persistence timing are preserved; setup records, exact broadcasts and extra selector/formatter carry are verified. Native125185 setup,171668 mutation, ranking/logging/network/IO remain supplied/captured. Full runtime completion remains open. [Evidence](research/QVM_RESOLVED_CONNECT_COMPLETE.md).
 
 
 
 
1833
 
1834
 
1835
  RE-930: 96 complete173979 executions replace supplied161744 booleans and captured182896 with actual bot settings/drop and announcement bodies. Parent decisions, client/entity bytes and persistence timing are preserved; setup records, exact broadcasts and extra selector/formatter carry are verified. Native125185 setup,171668 mutation, ranking/logging/network/IO remain supplied/captured. Full runtime completion remains open. [Evidence](research/QVM_RESOLVED_CONNECT_COMPLETE.md).
1836
+
1837
+
1838
+ RE-931: Rust matches96 complete source173979/161744/182896 compositions, including settings/drop records, extra selector toggles and announcement/counter carry while preserving prior caller state, cvar timing and return decisions. Typed errors stage all caller state. Native setup/userinfo/ranking/network/IO remain explicit boundaries. Full runtime completion remains open. [Evidence](research/RUST_RESOLVED_CONNECT_COMPLETE.md).
docs/RESEARCH_LEDGER.md CHANGED
@@ -2380,3 +2380,8 @@ Rust matches144 original suffix compositions with actual161744/182896 policies,
2380
  ## 2026-10-28 — RE-930 Complete original connect with bot/announcement children
2381
 
2382
  96 complete173979 executions replace supplied161744 booleans and captured182896 with actual bot settings/drop and announcement bodies. Parent decisions, client/entity bytes and persistence timing are preserved; setup records, exact broadcasts and extra selector/formatter carry are verified. Native125185 setup,171668 mutation, ranking/logging/network/IO remain supplied/captured. Focused `cargo xtask test-group qvm-resolved-connect-complete` passes (7 Python tests); selected reports regenerate twice deterministically, with storage, documentation links and whitespace guards. Full suite deferred to task ten. Original assets unchanged; source fixtures do not establish complete native/runtime parity.
 
 
 
 
 
 
2380
  ## 2026-10-28 — RE-930 Complete original connect with bot/announcement children
2381
 
2382
  96 complete173979 executions replace supplied161744 booleans and captured182896 with actual bot settings/drop and announcement bodies. Parent decisions, client/entity bytes and persistence timing are preserved; setup records, exact broadcasts and extra selector/formatter carry are verified. Native125185 setup,171668 mutation, ranking/logging/network/IO remain supplied/captured. Focused `cargo xtask test-group qvm-resolved-connect-complete` passes (7 Python tests); selected reports regenerate twice deterministically, with storage, documentation links and whitespace guards. Full suite deferred to task ten. Original assets unchanged; source fixtures do not establish complete native/runtime parity.
2383
+
2384
+
2385
+ ## 2026-10-28 — RE-931 Rust complete connect with recovered child policies
2386
+
2387
+ Rust matches96 complete source173979/161744/182896 compositions, including settings/drop records, extra selector toggles and announcement/counter carry while preserving prior caller state, cvar timing and return decisions. Typed errors stage all caller state. Native setup/userinfo/ranking/network/IO remain explicit boundaries. Focused `cargo xtask test-group rust-resolved-connect-complete` passes (11 Python tests); selected reports regenerate twice deterministically, with storage, documentation links and whitespace guards. Full suite deferred to task ten. Original assets unchanged; source fixtures do not establish complete native/runtime parity.
docs/REVERSE_ENGINEERING_TODO.md CHANGED
@@ -1870,3 +1870,6 @@ Purpose: turn the supplied installation into an evidence-backed specification of
1870
 
1871
 
1872
  - [x] RE-930 Complete original connect with bot/announcement children ([evidence](research/QVM_RESOLVED_CONNECT_COMPLETE.md)).
 
 
 
 
1870
 
1871
 
1872
  - [x] RE-930 Complete original connect with bot/announcement children ([evidence](research/QVM_RESOLVED_CONNECT_COMPLETE.md)).
1873
+
1874
+
1875
+ - [x] RE-931 Rust complete connect with recovered child policies ([evidence](research/RUST_RESOLVED_CONNECT_COMPLETE.md)).
docs/research/README.md CHANGED
@@ -1405,3 +1405,6 @@ The extension collector adds five focused tests for native tail calls, command-r
1405
 
1406
 
1407
  [RE-930: Complete original connect with bot/announcement children](QVM_RESOLVED_CONNECT_COMPLETE.md).
 
 
 
 
1405
 
1406
 
1407
  [RE-930: Complete original connect with bot/announcement children](QVM_RESOLVED_CONNECT_COMPLETE.md).
1408
+
1409
+
1410
+ [RE-931: Rust complete connect with recovered child policies](RUST_RESOLVED_CONNECT_COMPLETE.md).
docs/research/RUST_RESOLVED_CONNECT_COMPLETE.md ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # Rust complete connect with recovered child policies
2
+
3
+ RE-931. Reproduce with `python3 scripts/analyze_rust_resolved_connect_complete.py`; focused validation: `cargo xtask test-group rust-resolved-connect-complete`. [Machine report](rust-resolved-connect-complete.json).
4
+
5
+ Rust matches96 complete source173979/161744/182896 compositions, including settings/drop records, extra selector toggles and announcement/counter carry while preserving prior caller state, cvar timing and return decisions. Typed errors stage all caller state. Native setup/userinfo/ranking/network/IO remain explicit boundaries.
6
+
7
+ Original executable/native runtime and complete Linux/macOS Rust/Bevy/Solari acceptance remain unverified.
docs/research/rust-health-impulse.json CHANGED
@@ -2985,7 +2985,7 @@
2985
  "exit_code": 2
2986
  }
2987
  ],
2988
- "rust_unit_tests": 182,
2989
  "source_report": "docs/research/qvm-health-impulse.json",
2990
  "source_report_sha256": "625fd8064004ea6dbdf398d51d0af844d9c635ff04c0a0790886dddb6ab81e71"
2991
  }
 
2985
  "exit_code": 2
2986
  }
2987
  ],
2988
+ "rust_unit_tests": 183,
2989
  "source_report": "docs/research/qvm-health-impulse.json",
2990
  "source_report_sha256": "625fd8064004ea6dbdf398d51d0af844d9c635ff04c0a0790886dddb6ab81e71"
2991
  }
docs/research/rust-resolved-connect-complete.json ADDED
The diff for this file is too large to render. See raw diff
 
scripts/analyze_rust_resolved_connect_complete.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ import hashlib,json
3
+ from pathlib import Path
4
+ from rust_native_policy_support import binary,result,invoke
5
+ from analyze_qvm import write_json
6
+ from analyze_rust_connect_complete import encode
7
+ def project(s):
8
+ notice=s['resolved'].get('announcements',[]);bot=s['resolved'].get('bot');parent={k:s[k] for k in ['accepted','message','steps','filter','events','choice','raw','client_checksum','words','entity','sets','reads','info_ring']};parent['ring']=s['ring']-len(notice);return {'parent':parent,'bot':None if bot is None else {k:bot[k] for k in ['settings','lookups','calls','result']}|{'ring':s['info_ring']},'notices':notice,'ring':s['ring'],'info_ring':s['info_ring']}
9
+
10
+ def main():
11
+ b=binary();p=Path('docs/research/qvm-resolved-connect-complete.json');data=p.read_bytes();rows=[]
12
+ for s in json.loads(data)['probes']:rows.append({'source':project(s),'rust':result(b,'resolved-connect-complete',encode(s))})
13
+ write_json(Path('docs/research/rust-resolved-connect-complete.json'),{'source_report':str(p),'source_report_sha256':hashlib.sha256(data).hexdigest(),'probes':rows,'limits':'Rust matches96 complete source173979/161744/182896 compositions, including settings/drop records, extra selector toggles and announcement/counter carry while preserving prior caller state, cvar timing and return decisions. Typed errors stage all caller state. Native setup/userinfo/ranking/network/IO remain explicit boundaries.'})
14
+ if __name__=='__main__':main()
scripts/test_rust_resolved_connect_complete.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ import hashlib,json,unittest
2
+ from pathlib import Path
3
+ class PortTests(unittest.TestCase):
4
+ def test_all_original_cases(self):
5
+ r=json.loads(Path('docs/research/rust-resolved-connect-complete.json').read_text());src=json.loads(Path(r['source_report']).read_text());self.assertEqual(len(r['probes']),len(src['probes']));self.assertGreater(len(r['probes']),20)
6
+ for p in r['probes']:self.assertEqual(p['rust'],p['source'])
7
+ def test_source_identity(self):
8
+ r=json.loads(Path('docs/research/rust-resolved-connect-complete.json').read_text());self.assertEqual(hashlib.sha256(Path(r['source_report']).read_bytes()).hexdigest(),r['source_report_sha256'])
9
+ if __name__=='__main__':unittest.main()
xtask/checks.tsv CHANGED
@@ -3069,3 +3069,19 @@ report scripts/analyze_qvm_resolved_connect_complete.py docs/research/qvm-resolv
3069
  edge docs/research/qvm-resolved-connect-complete.json scripts/test_qvm_resolved_connect_complete.py
3070
  group qvm-resolved-connect-complete scripts/analyze_qvm_resolved_connect_complete.py
3071
  edge scripts/analyze_qvm_resolved_connect_complete.py scripts/analyze_qvm_resumer_audit.py
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3069
  edge docs/research/qvm-resolved-connect-complete.json scripts/test_qvm_resolved_connect_complete.py
3070
  group qvm-resolved-connect-complete scripts/analyze_qvm_resolved_connect_complete.py
3071
  edge scripts/analyze_qvm_resolved_connect_complete.py scripts/analyze_qvm_resumer_audit.py
3072
+ edge Cargo.toml scripts/analyze_rust_resolved_connect_complete.py
3073
+ edge Cargo.lock scripts/analyze_rust_resolved_connect_complete.py
3074
+ edge crates/urt-gameplay/Cargo.toml scripts/analyze_rust_resolved_connect_complete.py
3075
+ edge crates/urt-gameplay/src/lib.rs scripts/analyze_rust_resolved_connect_complete.py
3076
+ edge crates/urt-gameplay/src/native_policy.rs scripts/analyze_rust_resolved_connect_complete.py
3077
+ edge crates/urt-gameplay/src/bin/urt-native-policy.rs scripts/analyze_rust_resolved_connect_complete.py
3078
+ edge docs/research/qvm-resolved-connect-complete.json scripts/analyze_rust_resolved_connect_complete.py
3079
+ group rust-resolved-connect-complete scripts/analyze_rust_health_impulse.py
3080
+ group gameplay scripts/analyze_rust_resolved_connect_complete.py
3081
+ edge crates/urt-gameplay/src/intermission.rs scripts/analyze_rust_resolved_connect_complete.py
3082
+ edge crates/urt-gameplay/src/qvm_format.rs scripts/analyze_rust_resolved_connect_complete.py
3083
+ group rust-resolved-connect-complete scripts/analyze_rust_connect_complete.py
3084
+ report scripts/analyze_rust_resolved_connect_complete.py docs/research/rust-resolved-connect-complete.json
3085
+ edge docs/research/rust-resolved-connect-complete.json scripts/test_rust_resolved_connect_complete.py
3086
+ group rust-resolved-connect-complete scripts/analyze_rust_resolved_connect_complete.py
3087
+ edge scripts/analyze_rust_resolved_connect_complete.py scripts/analyze_qvm_resumer_audit.py