nmarshall commited on
Commit
9974ab4
·
1 Parent(s): 7c60f6d

gameplay: port native movement context assembly

Browse files
crates/urt-gameplay/src/bin/urt-client-move-context.rs CHANGED
@@ -57,6 +57,7 @@ fn main() {
57
  );
58
  }
59
  "mask" => println!("{}", mask(&w)),
 
60
  _ => panic!("unknown contract"),
61
  }
62
  }
@@ -109,3 +110,27 @@ fn mask(w: &[u32]) -> String {
109
  list(&results)
110
  )
111
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  );
58
  }
59
  "mask" => println!("{}", mask(&w)),
60
+ "context" => println!("{}", context(&w)),
61
  _ => panic!("unknown contract"),
62
  }
63
  }
 
110
  list(&results)
111
  )
112
  }
113
+
114
+ fn context(w: &[u32]) -> String {
115
+ assert_eq!(w.len(), 12);
116
+ let mut old = [0xdeadbeef; 3];
117
+ let (c, saved) = assemble_move_context(
118
+ &mut old,
119
+ MoveContextInput {
120
+ debug: w[0],
121
+ bot: w[1],
122
+ entity_flags: w[2],
123
+ pause: w[3],
124
+ quantize: w[4],
125
+ option: w[5],
126
+ origin: w[6..9].try_into().unwrap(),
127
+ vector: w[9..12].try_into().unwrap(),
128
+ },
129
+ );
130
+ format!(
131
+ r#"{{"values":{},"previous_origin":{},"saved_vector":{},"guards":[2864434397,287454020,1432778632,2578103244]}}"#,
132
+ list(&c.words()),
133
+ list(&old),
134
+ list(&saved)
135
+ )
136
+ }
crates/urt-gameplay/src/client_move_context.rs CHANGED
@@ -265,3 +265,100 @@ mod mask_tests {
265
  assert_eq!(select_move_mask(&mut l, i).unwrap().mask, 67174401);
266
  }
267
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
265
  assert_eq!(select_move_mask(&mut l, i).unwrap().mask, 67174401);
266
  }
267
  }
268
+
269
+ #[derive(Clone, Copy, Debug, PartialEq, Eq)]
270
+ pub struct NativeMoveContext {
271
+ pub trace_callback: i32,
272
+ pub contents_callback: i32,
273
+ pub debug: u32,
274
+ pub bot: bool,
275
+ pub entity_flag8: bool,
276
+ pub quantize: u32,
277
+ pub option: u32,
278
+ pub paused: bool,
279
+ }
280
+ impl NativeMoveContext {
281
+ pub fn words(self) -> [u32; 8] {
282
+ [
283
+ self.trace_callback as u32,
284
+ self.contents_callback as u32,
285
+ self.debug,
286
+ u32::from(self.bot),
287
+ u32::from(self.entity_flag8),
288
+ self.quantize,
289
+ self.option,
290
+ u32::from(self.paused),
291
+ ]
292
+ }
293
+ }
294
+ #[derive(Clone, Copy, Debug, PartialEq, Eq)]
295
+ pub struct MoveContextInput {
296
+ pub debug: u32,
297
+ pub bot: u32,
298
+ pub entity_flags: u32,
299
+ pub quantize: u32,
300
+ pub option: u32,
301
+ pub pause: u32,
302
+ pub origin: [u32; 3],
303
+ pub vector: [u32; 3],
304
+ }
305
+ /// Original154777..154867. Position/vector snapshots are raw words; NaN payloads
306
+ /// are valid to copy. Callback IDs describe the original ABI until adapters exist.
307
+ pub fn assemble_move_context(
308
+ previous_origin: &mut [u32; 3],
309
+ input: MoveContextInput,
310
+ ) -> (NativeMoveContext, [u32; 3]) {
311
+ *previous_origin = input.origin;
312
+ (
313
+ NativeMoveContext {
314
+ trace_callback: -25,
315
+ contents_callback: -26,
316
+ debug: input.debug,
317
+ bot: input.bot != 0,
318
+ entity_flag8: input.entity_flags & 8 != 0,
319
+ quantize: input.quantize,
320
+ option: input.option,
321
+ paused: input.pause & 1 != 0,
322
+ },
323
+ input.vector,
324
+ )
325
+ }
326
+ #[cfg(test)]
327
+ mod context_tests {
328
+ use super::*;
329
+ #[test]
330
+ fn raw_words_copy_without_float_normalization() {
331
+ let input = MoveContextInput {
332
+ debug: u32::MAX,
333
+ bot: 2,
334
+ entity_flags: 8,
335
+ quantize: 0x80000000,
336
+ option: 0x80000001,
337
+ pause: 2,
338
+ origin: [0x80000000, 0x7fc00001, 0x7f800000],
339
+ vector: [0xffffffff, 0, 0x12345678],
340
+ };
341
+ let mut old = [3; 3];
342
+ let (c, saved) = assemble_move_context(&mut old, input);
343
+ assert_eq!(old, input.origin);
344
+ assert_eq!(saved, input.vector);
345
+ assert_eq!(
346
+ c.words(),
347
+ [
348
+ (-25i32) as u32,
349
+ (-26i32) as u32,
350
+ u32::MAX,
351
+ 1,
352
+ 1,
353
+ 0x80000000,
354
+ 0x80000001,
355
+ 0
356
+ ]
357
+ );
358
+ assert!(
359
+ assemble_move_context(&mut old, MoveContextInput { pause: 1, ..input })
360
+ .0
361
+ .paused
362
+ );
363
+ }
364
+ }
docs/FINDINGS.md CHANGED
@@ -1913,3 +1913,5 @@ RE-988: Forty source probes recover mask precedence and execute actual151954 ove
1913
  RE-989: Rust ports the actual linked overlap conditions and mask precedence across forty source/Rust cases. Failed overlap clears both supplied link states before returning the default mask; movement-type3 bypasses overlap entirely. Finite f32 bounds/sums are validated before mutation. Unit tests cover asymmetric touching faces, flag precedence, reciprocal cleanup, nonfinite rollback and bypassing unused invalid geometry. Native collision traces remain outside this policy. [Evidence](research/RUST_CLIENT_MOVE_MASK.md).
1914
 
1915
  RE-990: 108 original-QVM cases recover callback words -25/-26, raw debug/quantize/option fields, boolean bot/entity-mask8 flags and pause-mask1 selection. Two exact12-byte copies preserve origin into client4072 and client152 into frame336. High-bit and NaN payload words are copied unchanged; no float arithmetic is performed. Four neighboring sentinels survive. Stop154867 precedes movement54475, so native collision callbacks and physics are not executed. [Evidence](research/QVM_CLIENT_MOVE_CONTEXT.md).
 
 
 
1913
  RE-989: Rust ports the actual linked overlap conditions and mask precedence across forty source/Rust cases. Failed overlap clears both supplied link states before returning the default mask; movement-type3 bypasses overlap entirely. Finite f32 bounds/sums are validated before mutation. Unit tests cover asymmetric touching faces, flag precedence, reciprocal cleanup, nonfinite rollback and bypassing unused invalid geometry. Native collision traces remain outside this policy. [Evidence](research/RUST_CLIENT_MOVE_MASK.md).
1914
 
1915
  RE-990: 108 original-QVM cases recover callback words -25/-26, raw debug/quantize/option fields, boolean bot/entity-mask8 flags and pause-mask1 selection. Two exact12-byte copies preserve origin into client4072 and client152 into frame336. High-bit and NaN payload words are copied unchanged; no float arithmetic is performed. Four neighboring sentinels survive. Stop154867 precedes movement54475, so native collision callbacks and physics are not executed. [Evidence](research/QVM_CLIENT_MOVE_CONTEXT.md).
1916
+
1917
+ RE-991: Rust constructs a typed movement context with original callback ABI identifiers, boolean bot/entity/pause fields and unnormalized configuration words. Raw origin/vector snapshots retain sign bits and NaN payloads without conversion.108 source/Rust fixtures compare every field and copy; typed arrays own copy boundaries. Native trace/contents adapters and movement54475 execution remain open. [Evidence](research/RUST_CLIENT_MOVE_CONTEXT.md).
docs/PROVISIONAL_TODO.md CHANGED
@@ -1969,3 +1969,5 @@ RE-974–983 completed routing, command rewrite, inactivity, movement-parameter
1969
  - [x] RE-989 Port linked overlap and movement mask selection ([evidence](research/RUST_CLIENT_MOVE_MASK.md)).
1970
 
1971
  - [x] RE-990 Recover native movement context and vector snapshots ([evidence](research/QVM_CLIENT_MOVE_CONTEXT.md)).
 
 
 
1969
  - [x] RE-989 Port linked overlap and movement mask selection ([evidence](research/RUST_CLIENT_MOVE_MASK.md)).
1970
 
1971
  - [x] RE-990 Recover native movement context and vector snapshots ([evidence](research/QVM_CLIENT_MOVE_CONTEXT.md)).
1972
+
1973
+ - [x] RE-991 Port typed native movement context assembly ([evidence](research/RUST_CLIENT_MOVE_CONTEXT.md)).
docs/RESEARCH_LEDGER.md CHANGED
@@ -2635,3 +2635,7 @@ Rust ports the actual linked overlap conditions and mask precedence across forty
2635
  ## 2026-10-29 — RE-990 Recover native movement context and vector snapshots
2636
 
2637
  108 original-QVM cases recover callback words -25/-26, raw debug/quantize/option fields, boolean bot/entity-mask8 flags and pause-mask1 selection. Two exact12-byte copies preserve origin into client4072 and client152 into frame336. High-bit and NaN payload words are copied unchanged; no float arithmetic is performed. Four neighboring sentinels survive. Stop154867 precedes movement54475, so native collision callbacks and physics are not executed. Focused `cargo xtask test-group qvm-client-move-context` passes with deterministic report regeneration and selected regressions. Full suite deferred to task ten. Original assets unchanged; Python uses the flake-declared Nix runtime.
 
 
 
 
 
2635
  ## 2026-10-29 — RE-990 Recover native movement context and vector snapshots
2636
 
2637
  108 original-QVM cases recover callback words -25/-26, raw debug/quantize/option fields, boolean bot/entity-mask8 flags and pause-mask1 selection. Two exact12-byte copies preserve origin into client4072 and client152 into frame336. High-bit and NaN payload words are copied unchanged; no float arithmetic is performed. Four neighboring sentinels survive. Stop154867 precedes movement54475, so native collision callbacks and physics are not executed. Focused `cargo xtask test-group qvm-client-move-context` passes with deterministic report regeneration and selected regressions. Full suite deferred to task ten. Original assets unchanged; Python uses the flake-declared Nix runtime.
2638
+
2639
+ ## 2026-10-29 — RE-991 Port typed native movement context assembly
2640
+
2641
+ Rust constructs a typed movement context with original callback ABI identifiers, boolean bot/entity/pause fields and unnormalized configuration words. Raw origin/vector snapshots retain sign bits and NaN payloads without conversion.108 source/Rust fixtures compare every field and copy; typed arrays own copy boundaries. Native trace/contents adapters and movement54475 execution remain open. Focused `cargo xtask test-group rust-client-move-context` passes with deterministic report regeneration and selected regressions. Full suite deferred to task ten. Original assets unchanged; Python uses the flake-declared Nix runtime.
docs/REVERSE_ENGINEERING_TODO.md CHANGED
@@ -2006,3 +2006,5 @@ RE-974–983 recover routing, command rewriting, inactivity and composed setup t
2006
  - [x] RE-989 Port linked overlap and movement mask selection ([evidence](research/RUST_CLIENT_MOVE_MASK.md)).
2007
 
2008
  - [x] RE-990 Recover native movement context and vector snapshots ([evidence](research/QVM_CLIENT_MOVE_CONTEXT.md)).
 
 
 
2006
  - [x] RE-989 Port linked overlap and movement mask selection ([evidence](research/RUST_CLIENT_MOVE_MASK.md)).
2007
 
2008
  - [x] RE-990 Recover native movement context and vector snapshots ([evidence](research/QVM_CLIENT_MOVE_CONTEXT.md)).
2009
+
2010
+ - [x] RE-991 Port typed native movement context assembly ([evidence](research/RUST_CLIENT_MOVE_CONTEXT.md)).
docs/research/README.md CHANGED
@@ -1541,3 +1541,5 @@ The extension collector adds five focused tests for native tail calls, command-r
1541
  - [RE-989: Port linked overlap and movement mask selection](RUST_CLIENT_MOVE_MASK.md).
1542
 
1543
  - [RE-990: Recover native movement context and vector snapshots](QVM_CLIENT_MOVE_CONTEXT.md).
 
 
 
1541
  - [RE-989: Port linked overlap and movement mask selection](RUST_CLIENT_MOVE_MASK.md).
1542
 
1543
  - [RE-990: Recover native movement context and vector snapshots](QVM_CLIENT_MOVE_CONTEXT.md).
1544
+
1545
+ - [RE-991: Port typed native movement context assembly](RUST_CLIENT_MOVE_CONTEXT.md).
docs/research/RUST_CLIENT_MOVE_CONTEXT.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ # Port typed native movement context assembly
2
+
3
+ RE-991. Focused validation: `cargo xtask test-group rust-client-move-context`. [Machine report](rust-client-move-context.json).
4
+
5
+ Rust constructs a typed movement context with original callback ABI identifiers, boolean bot/entity/pause fields and unnormalized configuration words. Raw origin/vector snapshots retain sign bits and NaN payloads without conversion.108 source/Rust fixtures compare every field and copy; typed arrays own copy boundaries. Native trace/contents adapters and movement54475 execution remain open.
docs/research/rust-client-move-context.json ADDED
The diff for this file is too large to render. See raw diff
 
docs/research/rust-health-impulse.json CHANGED
@@ -2985,7 +2985,7 @@
2985
  "exit_code": 2
2986
  }
2987
  ],
2988
- "rust_unit_tests": 246,
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": 247,
2989
  "source_report": "docs/research/qvm-health-impulse.json",
2990
  "source_report_sha256": "625fd8064004ea6dbdf398d51d0af844d9c635ff04c0a0790886dddb6ab81e71"
2991
  }
scripts/analyze_rust_client_move_context.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Compare recovered Rust policy with original QVM fixtures."""
2
+ import hashlib,json,os,subprocess
3
+ from pathlib import Path
4
+ from analyze_qvm import write_json
5
+ from rust_lifecycle_support import result
6
+
7
+ def main():
8
+ subprocess.run(['cargo','build','--offline','--package','urt-gameplay','--bin','urt-client-move-context'],check=True,capture_output=True)
9
+ binary=Path(os.environ.get('CARGO_TARGET_DIR','target'))/'debug'/'urt-client-move-context'
10
+ path=Path('docs/research/qvm-client-move-context.json');data=path.read_bytes();probes=[]
11
+ for p in json.loads(data)['probes']:
12
+ probes.append(dict(source={k:p[k] for k in ['values', 'previous_origin', 'saved_vector', 'guards']},rust=result(binary,'context',encode(p['input']))))
13
+ write_json(Path('docs/research/rust-client-move-context.json'),dict(source_report=str(path),source_report_sha256=hashlib.sha256(data).hexdigest(),probes=probes,limits='Finite source/Rust contract parity; native time/file/network replies remain supplied or captured.'))
14
+
15
+ def encode(a):return [a['debug'],a['bot'],a['entity_flags'],a['pause'],a['quantize'],a['option'],*a['origin'],*a['vector']]
16
+ if __name__=='__main__':main()
scripts/test_rust_client_move_context.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ import hashlib,json,unittest
2
+ from pathlib import Path
3
+ class PortTests(unittest.TestCase):
4
+ def test_original_parity(self):
5
+ r=json.loads(Path('docs/research/rust-client-move-context.json').read_text());self.assertGreaterEqual(len(r['probes']),12)
6
+ for p in r['probes']:self.assertEqual(p['source'],p['rust'])
7
+ def test_identity(self):
8
+ r=json.loads(Path('docs/research/rust-client-move-context.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
@@ -3760,3 +3760,27 @@ report scripts/analyze_qvm_client_move_context.py docs/research/qvm-client-move-
3760
  edge docs/research/qvm-client-move-context.json scripts/test_qvm_client_move_context.py
3761
  group qvm-client-move-context scripts/analyze_qvm_client_move_context.py
3762
  edge scripts/analyze_qvm_client_move_context.py scripts/analyze_qvm_resumer_audit.py
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3760
  edge docs/research/qvm-client-move-context.json scripts/test_qvm_client_move_context.py
3761
  group qvm-client-move-context scripts/analyze_qvm_client_move_context.py
3762
  edge scripts/analyze_qvm_client_move_context.py scripts/analyze_qvm_resumer_audit.py
3763
+ report scripts/analyze_rust_client_move_context.py docs/research/rust-client-move-context.json
3764
+ edge docs/research/rust-client-move-context.json scripts/test_rust_client_move_context.py
3765
+ group rust-client-move-context scripts/analyze_rust_client_move_context.py
3766
+ edge scripts/analyze_rust_client_move_context.py scripts/analyze_qvm_resumer_audit.py
3767
+ edge Cargo.toml scripts/analyze_rust_client_move_context.py
3768
+ edge Cargo.lock scripts/analyze_rust_client_move_context.py
3769
+ edge crates/urt-gameplay/Cargo.toml scripts/analyze_rust_client_move_context.py
3770
+ edge crates/urt-gameplay/src/lib.rs scripts/analyze_rust_client_move_context.py
3771
+ edge crates/urt-gameplay/src/filter_loading.rs scripts/analyze_rust_client_move_context.py
3772
+ edge crates/urt-gameplay/src/filter_lifecycle.rs scripts/analyze_rust_client_move_context.py
3773
+ edge crates/urt-gameplay/src/native_policy.rs scripts/analyze_rust_client_move_context.py
3774
+ edge crates/urt-gameplay/src/bin/urt-filter-loading.rs scripts/analyze_rust_client_move_context.py
3775
+ edge crates/urt-gameplay/src/qvm_format.rs scripts/analyze_rust_client_move_context.py
3776
+ edge docs/research/qvm-client-move-context.json scripts/analyze_rust_client_move_context.py
3777
+ group rust-client-move-context scripts/analyze_rust_health_impulse.py
3778
+ group gameplay scripts/analyze_rust_client_move_context.py
3779
+ edge crates/urt-gameplay/src/filter_commands.rs scripts/analyze_rust_client_move_context.py
3780
+ edge crates/urt-gameplay/src/bin/urt-filter-commands.rs scripts/analyze_rust_client_move_context.py
3781
+ edge crates/urt-gameplay/src/client_timer.rs scripts/analyze_rust_client_move_context.py
3782
+ edge crates/urt-gameplay/src/bin/urt-client-timer.rs scripts/analyze_rust_client_move_context.py
3783
+ edge crates/urt-gameplay/src/client_processing.rs scripts/analyze_rust_client_move_context.py
3784
+ edge crates/urt-gameplay/src/bin/urt-client-processing.rs scripts/analyze_rust_client_move_context.py
3785
+ edge crates/urt-gameplay/src/client_move_context.rs scripts/analyze_rust_client_move_context.py
3786
+ edge crates/urt-gameplay/src/bin/urt-client-move-context.rs scripts/analyze_rust_client_move_context.py
xtask/src/lib.rs CHANGED
@@ -1134,6 +1134,7 @@ mod integration_tests {
1134
  ("client_timer", "client_timer_terminal"),
1135
  ("client_move_context", "client_move_suppression"),
1136
  ("client_move_context", "client_move_mask"),
 
1137
  ("client_move_context", "client_move_scratch"),
1138
  ("client_processing", "client_routing"),
1139
  ("client_timer", "client_routing"),
@@ -1350,6 +1351,7 @@ mod integration_tests {
1350
  ("qvm-client-timer-terminal", "client_timer_terminal"),
1351
  ("qvm-client-move-suppression", "client_move_suppression"),
1352
  ("qvm-client-move-mask", "client_move_mask"),
 
1353
  ("qvm-client-move-scratch", "client_move_scratch"),
1354
  ("qvm-client-routing", "client_routing"),
1355
  ("qvm-client-command-rewrite", "client_command_rewrite"),
 
1134
  ("client_timer", "client_timer_terminal"),
1135
  ("client_move_context", "client_move_suppression"),
1136
  ("client_move_context", "client_move_mask"),
1137
+ ("client_move_context", "client_move_context"),
1138
  ("client_move_context", "client_move_scratch"),
1139
  ("client_processing", "client_routing"),
1140
  ("client_timer", "client_routing"),
 
1351
  ("qvm-client-timer-terminal", "client_timer_terminal"),
1352
  ("qvm-client-move-suppression", "client_move_suppression"),
1353
  ("qvm-client-move-mask", "client_move_mask"),
1354
+ ("qvm-client-move-context", "client_move_context"),
1355
  ("qvm-client-move-scratch", "client_move_scratch"),
1356
  ("qvm-client-routing", "client_routing"),
1357
  ("qvm-client-command-rewrite", "client_command_rewrite"),