nmarshall commited on
Commit
ebc1faa
·
1 Parent(s): f1f5ce1

gameplay: port bot genome winner policy

Browse files
crates/urt-gameplay/src/bin/urt-native-policy.rs ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ use urt_gameplay::native_policy::*;
2
+ fn list(v: &[u32]) -> String {
3
+ format!(
4
+ "[{}]",
5
+ v.iter()
6
+ .map(|x| x.to_string())
7
+ .collect::<Vec<_>>()
8
+ .join(",")
9
+ )
10
+ }
11
+ fn nested(v: &[Vec<u32>]) -> String {
12
+ format!(
13
+ "[{}]",
14
+ v.iter().map(|x| list(x)).collect::<Vec<_>>().join(",")
15
+ )
16
+ }
17
+ fn bots(w: &[u32]) -> Result<Vec<Bot>, String> {
18
+ if w.len() != 256 {
19
+ return Err("expected64 bot records".into());
20
+ }
21
+ Ok(w.chunks_exact(4)
22
+ .map(|v| Bot {
23
+ active: v[0] as i32,
24
+ wins: v[1] as i32,
25
+ losses: v[2] as i32,
26
+ handle: v[3],
27
+ })
28
+ .collect())
29
+ }
30
+ fn run() -> Result<String, String> {
31
+ let a = std::env::args().skip(1).collect::<Vec<_>>();
32
+ let kind = a.first().ok_or("missing command")?;
33
+ let w = a[1..]
34
+ .iter()
35
+ .map(|x| x.parse::<u32>().map_err(|_| "invalid word".to_string()))
36
+ .collect::<Result<Vec<_>, _>>()?;
37
+ match kind.as_str() {
38
+ "best" => {
39
+ if w.len() != 257 {
40
+ return Err("invalid best input".into());
41
+ }
42
+ let b = bots(&w[1..])?;
43
+ let calls = best_bot(&b)
44
+ .map_err(|e| format!("{e:?}"))?
45
+ .map(|j| vec![vec![b[j].handle, w[0]]])
46
+ .unwrap_or_default();
47
+ Ok(format!("{{\"calls\":{}}}", nested(&calls)))
48
+ }
49
+ _ => Err("unknown command".into()),
50
+ }
51
+ }
52
+ fn main() {
53
+ match run() {
54
+ Ok(s) => println!("{s}"),
55
+ Err(e) => {
56
+ eprintln!("{e}");
57
+ std::process::exit(1)
58
+ }
59
+ }
60
+ }
crates/urt-gameplay/src/lib.rs CHANGED
@@ -179,3 +179,5 @@ pub mod transition;
179
  pub mod camera_world;
180
 
181
  pub mod map_commands;
 
 
 
179
  pub mod camera_world;
180
 
181
  pub mod map_commands;
182
+
183
+ pub mod native_policy;
crates/urt-gameplay/src/native_policy.rs ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //! Recovered QVM policies at explicit native botlib/collision boundaries.
2
+ #[derive(Clone, Copy, Debug, PartialEq, Eq)]
3
+ pub enum Error {
4
+ InvalidCount,
5
+ InvalidIndex,
6
+ NonFinite,
7
+ }
8
+ #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
9
+ pub struct Bot {
10
+ pub active: i32,
11
+ pub wins: i32,
12
+ pub losses: i32,
13
+ pub handle: u32,
14
+ }
15
+ /// QVM fitness wraps as a signed word before conversion to f32.
16
+ pub fn fitness(bot: Bot) -> f32 {
17
+ if bot.active == 0 {
18
+ -1.0
19
+ } else {
20
+ bot.wins.wrapping_shl(1).wrapping_sub(bot.losses) as f32
21
+ }
22
+ }
23
+ /// Match the fixed 64-slot scan; inactive or nonpositive fitness never wins.
24
+ pub fn best_bot(bots: &[Bot]) -> Result<Option<usize>, Error> {
25
+ if bots.len() != 64 {
26
+ return Err(Error::InvalidCount);
27
+ }
28
+ let mut best = 0.0;
29
+ let mut selected = None;
30
+ for (j, bot) in bots.iter().enumerate() {
31
+ let score = fitness(*bot);
32
+ if score > best {
33
+ best = score;
34
+ selected = Some(j)
35
+ }
36
+ }
37
+ Ok(selected)
38
+ }
39
+ #[cfg(test)]
40
+ mod tests {
41
+ use super::*;
42
+ #[test]
43
+ fn best_requires_positive_and_keeps_first_tie() {
44
+ let mut b = [Bot::default(); 64];
45
+ assert_eq!(best_bot(&b), Ok(None));
46
+ b[3] = Bot {
47
+ active: 1,
48
+ wins: 2,
49
+ losses: 1,
50
+ handle: 5,
51
+ };
52
+ b[4] = b[3];
53
+ assert_eq!(best_bot(&b), Ok(Some(3)));
54
+ b[3].wins = i32::MAX;
55
+ assert_eq!(fitness(b[3]), -3.0);
56
+ assert_eq!(best_bot(&b), Ok(Some(4)));
57
+ }
58
+ #[test]
59
+ fn best_requires_full_population() {
60
+ assert_eq!(best_bot(&[]), Err(Error::InvalidCount));
61
+ }
62
+ }
docs/FINDINGS.md CHANGED
@@ -1622,3 +1622,6 @@ RE-813–822 replaces the scoreboard decimal assumption with actual37914 executi
1622
 
1623
 
1624
  **RE-874:** 64 actual122143 cases recover a 64-slot bot population scan, wrapping (wins<<1)-loss converted to f32, strict positive best score and first-wins ties. Only the winner handle and unchanged filename pointer reach captured native -546. Zero/negative fitness means no write. Extreme counters exercise signed wrap and f32 precision. Native botlib serialization remains open. [Evidence](research/QVM_BOT_BEST.md).
 
 
 
 
1622
 
1623
 
1624
  **RE-874:** 64 actual122143 cases recover a 64-slot bot population scan, wrapping (wins<<1)-loss converted to f32, strict positive best score and first-wins ties. Only the winner handle and unchanged filename pointer reach captured native -546. Zero/negative fitness means no write. Extreme counters exercise signed wrap and f32 precision. Native botlib serialization remains open. [Evidence](research/QVM_BOT_BEST.md).
1625
+
1626
+
1627
+ **RE-875:** Rust matches all64 original bot winner cases, with wrapping fitness arithmetic before f32 conversion, strict first-wins comparison and typed rejection of incomplete populations. Native botlib genome writes are returned as intentions, without assuming file serialization or runtime integration. [Evidence](research/RUST_BOT_BEST.md).
docs/PROVISIONAL_TODO.md CHANGED
@@ -1650,3 +1650,6 @@ RE-873: Rust matches192 original normal6939 cases, staging rotation, override ma
1650
 
1651
 
1652
  RE-874: 64 actual122143 cases recover a 64-slot bot population scan, wrapping (wins<<1)-loss converted to f32, strict positive best score and first-wins ties. Only the winner handle and unchanged filename pointer reach captured native -546. Zero/negative fitness means no write. Extreme counters exercise signed wrap and f32 precision. Native botlib serialization remains open. Full runtime completion remains open. [Evidence](research/QVM_BOT_BEST.md).
 
 
 
 
1650
 
1651
 
1652
  RE-874: 64 actual122143 cases recover a 64-slot bot population scan, wrapping (wins<<1)-loss converted to f32, strict positive best score and first-wins ties. Only the winner handle and unchanged filename pointer reach captured native -546. Zero/negative fitness means no write. Extreme counters exercise signed wrap and f32 precision. Native botlib serialization remains open. Full runtime completion remains open. [Evidence](research/QVM_BOT_BEST.md).
1653
+
1654
+
1655
+ RE-875: Rust matches all64 original bot winner cases, with wrapping fitness arithmetic before f32 conversion, strict first-wins comparison and typed rejection of incomplete populations. Native botlib genome writes are returned as intentions, without assuming file serialization or runtime integration. Full runtime completion remains open. [Evidence](research/RUST_BOT_BEST.md).
docs/RESEARCH_LEDGER.md CHANGED
@@ -2075,3 +2075,8 @@ Batch RE-864–873 boundary: the single `cargo xtask test-full --since 171bd705`
2075
  ## 2026-10-28 — RE-874 Original bot genome write selection
2076
 
2077
  64 actual122143 cases recover a 64-slot bot population scan, wrapping (wins<<1)-loss converted to f32, strict positive best score and first-wins ties. Only the winner handle and unchanged filename pointer reach captured native -546. Zero/negative fitness means no write. Extreme counters exercise signed wrap and f32 precision. Native botlib serialization remains open. Focused `cargo xtask test-group qvm-bot-best` passes (4 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.
 
 
 
 
 
 
2075
  ## 2026-10-28 — RE-874 Original bot genome write selection
2076
 
2077
  64 actual122143 cases recover a 64-slot bot population scan, wrapping (wins<<1)-loss converted to f32, strict positive best score and first-wins ties. Only the winner handle and unchanged filename pointer reach captured native -546. Zero/negative fitness means no write. Extreme counters exercise signed wrap and f32 precision. Native botlib serialization remains open. Focused `cargo xtask test-group qvm-bot-best` passes (4 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.
2078
+
2079
+
2080
+ ## 2026-10-28 — RE-875 Rust bot genome winner policy
2081
+
2082
+ Rust matches all64 original bot winner cases, with wrapping fitness arithmetic before f32 conversion, strict first-wins comparison and typed rejection of incomplete populations. Native botlib genome writes are returned as intentions, without assuming file serialization or runtime integration. Focused `cargo xtask test-group rust-bot-best` passes (9 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
@@ -1687,3 +1687,6 @@ Purpose: turn the supplied installation into an evidence-backed specification of
1687
 
1688
 
1689
  - [x] RE-874 Original bot genome write selection ([evidence](research/QVM_BOT_BEST.md)).
 
 
 
 
1687
 
1688
 
1689
  - [x] RE-874 Original bot genome write selection ([evidence](research/QVM_BOT_BEST.md)).
1690
+
1691
+
1692
+ - [x] RE-875 Rust bot genome winner policy ([evidence](research/RUST_BOT_BEST.md)).
docs/research/README.md CHANGED
@@ -1222,3 +1222,6 @@ The extension collector adds five focused tests for native tail calls, command-r
1222
 
1223
 
1224
  [RE-874: Original bot genome write selection](QVM_BOT_BEST.md).
 
 
 
 
1222
 
1223
 
1224
  [RE-874: Original bot genome write selection](QVM_BOT_BEST.md).
1225
+
1226
+
1227
+ [RE-875: Rust bot genome winner policy](RUST_BOT_BEST.md).
docs/research/RUST_BOT_BEST.md ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # Rust bot genome winner policy
2
+
3
+ RE-875. Reproduce with `python3 scripts/analyze_rust_bot_best.py`; focused validation: `cargo xtask test-group rust-bot-best`. [Machine report](rust-bot-best.json).
4
+
5
+ Rust matches all64 original bot winner cases, with wrapping fitness arithmetic before f32 conversion, strict first-wins comparison and typed rejection of incomplete populations. Native botlib genome writes are returned as intentions, without assuming file serialization or runtime integration.
6
+
7
+ Original executable/native runtime and complete Linux/macOS Rust/Bevy/Solari acceptance remain unverified.
docs/research/rust-bot-best.json ADDED
@@ -0,0 +1,899 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "limits": "Rust matches all64 original bot winner cases, with wrapping fitness arithmetic before f32 conversion, strict first-wins comparison and typed rejection of incomplete populations. Native botlib genome writes are returned as intentions, without assuming file serialization or runtime integration.",
3
+ "probes": [
4
+ {
5
+ "rust": {
6
+ "calls": []
7
+ },
8
+ "source": {
9
+ "calls": []
10
+ }
11
+ },
12
+ {
13
+ "rust": {
14
+ "calls": []
15
+ },
16
+ "source": {
17
+ "calls": []
18
+ }
19
+ },
20
+ {
21
+ "rust": {
22
+ "calls": []
23
+ },
24
+ "source": {
25
+ "calls": []
26
+ }
27
+ },
28
+ {
29
+ "rust": {
30
+ "calls": []
31
+ },
32
+ "source": {
33
+ "calls": []
34
+ }
35
+ },
36
+ {
37
+ "rust": {
38
+ "calls": [
39
+ [
40
+ 703,
41
+ 9000
42
+ ]
43
+ ]
44
+ },
45
+ "source": {
46
+ "calls": [
47
+ [
48
+ 703,
49
+ 9000
50
+ ]
51
+ ]
52
+ }
53
+ },
54
+ {
55
+ "rust": {
56
+ "calls": [
57
+ [
58
+ 703,
59
+ 0
60
+ ]
61
+ ]
62
+ },
63
+ "source": {
64
+ "calls": [
65
+ [
66
+ 703,
67
+ 0
68
+ ]
69
+ ]
70
+ }
71
+ },
72
+ {
73
+ "rust": {
74
+ "calls": [
75
+ [
76
+ 703,
77
+ 9000
78
+ ]
79
+ ]
80
+ },
81
+ "source": {
82
+ "calls": [
83
+ [
84
+ 703,
85
+ 9000
86
+ ]
87
+ ]
88
+ }
89
+ },
90
+ {
91
+ "rust": {
92
+ "calls": [
93
+ [
94
+ 703,
95
+ 0
96
+ ]
97
+ ]
98
+ },
99
+ "source": {
100
+ "calls": [
101
+ [
102
+ 703,
103
+ 0
104
+ ]
105
+ ]
106
+ }
107
+ },
108
+ {
109
+ "rust": {
110
+ "calls": []
111
+ },
112
+ "source": {
113
+ "calls": []
114
+ }
115
+ },
116
+ {
117
+ "rust": {
118
+ "calls": []
119
+ },
120
+ "source": {
121
+ "calls": []
122
+ }
123
+ },
124
+ {
125
+ "rust": {
126
+ "calls": []
127
+ },
128
+ "source": {
129
+ "calls": []
130
+ }
131
+ },
132
+ {
133
+ "rust": {
134
+ "calls": []
135
+ },
136
+ "source": {
137
+ "calls": []
138
+ }
139
+ },
140
+ {
141
+ "rust": {
142
+ "calls": [
143
+ [
144
+ 702,
145
+ 9000
146
+ ]
147
+ ]
148
+ },
149
+ "source": {
150
+ "calls": [
151
+ [
152
+ 702,
153
+ 9000
154
+ ]
155
+ ]
156
+ }
157
+ },
158
+ {
159
+ "rust": {
160
+ "calls": [
161
+ [
162
+ 702,
163
+ 0
164
+ ]
165
+ ]
166
+ },
167
+ "source": {
168
+ "calls": [
169
+ [
170
+ 702,
171
+ 0
172
+ ]
173
+ ]
174
+ }
175
+ },
176
+ {
177
+ "rust": {
178
+ "calls": [
179
+ [
180
+ 702,
181
+ 9000
182
+ ]
183
+ ]
184
+ },
185
+ "source": {
186
+ "calls": [
187
+ [
188
+ 702,
189
+ 9000
190
+ ]
191
+ ]
192
+ }
193
+ },
194
+ {
195
+ "rust": {
196
+ "calls": [
197
+ [
198
+ 702,
199
+ 0
200
+ ]
201
+ ]
202
+ },
203
+ "source": {
204
+ "calls": [
205
+ [
206
+ 702,
207
+ 0
208
+ ]
209
+ ]
210
+ }
211
+ },
212
+ {
213
+ "rust": {
214
+ "calls": []
215
+ },
216
+ "source": {
217
+ "calls": []
218
+ }
219
+ },
220
+ {
221
+ "rust": {
222
+ "calls": []
223
+ },
224
+ "source": {
225
+ "calls": []
226
+ }
227
+ },
228
+ {
229
+ "rust": {
230
+ "calls": [
231
+ [
232
+ 700,
233
+ 9000
234
+ ]
235
+ ]
236
+ },
237
+ "source": {
238
+ "calls": [
239
+ [
240
+ 700,
241
+ 9000
242
+ ]
243
+ ]
244
+ }
245
+ },
246
+ {
247
+ "rust": {
248
+ "calls": [
249
+ [
250
+ 700,
251
+ 0
252
+ ]
253
+ ]
254
+ },
255
+ "source": {
256
+ "calls": [
257
+ [
258
+ 700,
259
+ 0
260
+ ]
261
+ ]
262
+ }
263
+ },
264
+ {
265
+ "rust": {
266
+ "calls": [
267
+ [
268
+ 701,
269
+ 9000
270
+ ]
271
+ ]
272
+ },
273
+ "source": {
274
+ "calls": [
275
+ [
276
+ 701,
277
+ 9000
278
+ ]
279
+ ]
280
+ }
281
+ },
282
+ {
283
+ "rust": {
284
+ "calls": [
285
+ [
286
+ 701,
287
+ 0
288
+ ]
289
+ ]
290
+ },
291
+ "source": {
292
+ "calls": [
293
+ [
294
+ 701,
295
+ 0
296
+ ]
297
+ ]
298
+ }
299
+ },
300
+ {
301
+ "rust": {
302
+ "calls": [
303
+ [
304
+ 701,
305
+ 9000
306
+ ]
307
+ ]
308
+ },
309
+ "source": {
310
+ "calls": [
311
+ [
312
+ 701,
313
+ 9000
314
+ ]
315
+ ]
316
+ }
317
+ },
318
+ {
319
+ "rust": {
320
+ "calls": [
321
+ [
322
+ 701,
323
+ 0
324
+ ]
325
+ ]
326
+ },
327
+ "source": {
328
+ "calls": [
329
+ [
330
+ 701,
331
+ 0
332
+ ]
333
+ ]
334
+ }
335
+ },
336
+ {
337
+ "rust": {
338
+ "calls": []
339
+ },
340
+ "source": {
341
+ "calls": []
342
+ }
343
+ },
344
+ {
345
+ "rust": {
346
+ "calls": []
347
+ },
348
+ "source": {
349
+ "calls": []
350
+ }
351
+ },
352
+ {
353
+ "rust": {
354
+ "calls": [
355
+ [
356
+ 700,
357
+ 9000
358
+ ]
359
+ ]
360
+ },
361
+ "source": {
362
+ "calls": [
363
+ [
364
+ 700,
365
+ 9000
366
+ ]
367
+ ]
368
+ }
369
+ },
370
+ {
371
+ "rust": {
372
+ "calls": [
373
+ [
374
+ 700,
375
+ 0
376
+ ]
377
+ ]
378
+ },
379
+ "source": {
380
+ "calls": [
381
+ [
382
+ 700,
383
+ 0
384
+ ]
385
+ ]
386
+ }
387
+ },
388
+ {
389
+ "rust": {
390
+ "calls": [
391
+ [
392
+ 700,
393
+ 9000
394
+ ]
395
+ ]
396
+ },
397
+ "source": {
398
+ "calls": [
399
+ [
400
+ 700,
401
+ 9000
402
+ ]
403
+ ]
404
+ }
405
+ },
406
+ {
407
+ "rust": {
408
+ "calls": [
409
+ [
410
+ 700,
411
+ 0
412
+ ]
413
+ ]
414
+ },
415
+ "source": {
416
+ "calls": [
417
+ [
418
+ 700,
419
+ 0
420
+ ]
421
+ ]
422
+ }
423
+ },
424
+ {
425
+ "rust": {
426
+ "calls": [
427
+ [
428
+ 700,
429
+ 9000
430
+ ]
431
+ ]
432
+ },
433
+ "source": {
434
+ "calls": [
435
+ [
436
+ 700,
437
+ 9000
438
+ ]
439
+ ]
440
+ }
441
+ },
442
+ {
443
+ "rust": {
444
+ "calls": [
445
+ [
446
+ 700,
447
+ 0
448
+ ]
449
+ ]
450
+ },
451
+ "source": {
452
+ "calls": [
453
+ [
454
+ 700,
455
+ 0
456
+ ]
457
+ ]
458
+ }
459
+ },
460
+ {
461
+ "rust": {
462
+ "calls": []
463
+ },
464
+ "source": {
465
+ "calls": []
466
+ }
467
+ },
468
+ {
469
+ "rust": {
470
+ "calls": []
471
+ },
472
+ "source": {
473
+ "calls": []
474
+ }
475
+ },
476
+ {
477
+ "rust": {
478
+ "calls": []
479
+ },
480
+ "source": {
481
+ "calls": []
482
+ }
483
+ },
484
+ {
485
+ "rust": {
486
+ "calls": []
487
+ },
488
+ "source": {
489
+ "calls": []
490
+ }
491
+ },
492
+ {
493
+ "rust": {
494
+ "calls": [
495
+ [
496
+ 707,
497
+ 9000
498
+ ]
499
+ ]
500
+ },
501
+ "source": {
502
+ "calls": [
503
+ [
504
+ 707,
505
+ 9000
506
+ ]
507
+ ]
508
+ }
509
+ },
510
+ {
511
+ "rust": {
512
+ "calls": [
513
+ [
514
+ 707,
515
+ 0
516
+ ]
517
+ ]
518
+ },
519
+ "source": {
520
+ "calls": [
521
+ [
522
+ 707,
523
+ 0
524
+ ]
525
+ ]
526
+ }
527
+ },
528
+ {
529
+ "rust": {
530
+ "calls": [
531
+ [
532
+ 707,
533
+ 9000
534
+ ]
535
+ ]
536
+ },
537
+ "source": {
538
+ "calls": [
539
+ [
540
+ 707,
541
+ 9000
542
+ ]
543
+ ]
544
+ }
545
+ },
546
+ {
547
+ "rust": {
548
+ "calls": [
549
+ [
550
+ 707,
551
+ 0
552
+ ]
553
+ ]
554
+ },
555
+ "source": {
556
+ "calls": [
557
+ [
558
+ 707,
559
+ 0
560
+ ]
561
+ ]
562
+ }
563
+ },
564
+ {
565
+ "rust": {
566
+ "calls": []
567
+ },
568
+ "source": {
569
+ "calls": []
570
+ }
571
+ },
572
+ {
573
+ "rust": {
574
+ "calls": []
575
+ },
576
+ "source": {
577
+ "calls": []
578
+ }
579
+ },
580
+ {
581
+ "rust": {
582
+ "calls": []
583
+ },
584
+ "source": {
585
+ "calls": []
586
+ }
587
+ },
588
+ {
589
+ "rust": {
590
+ "calls": []
591
+ },
592
+ "source": {
593
+ "calls": []
594
+ }
595
+ },
596
+ {
597
+ "rust": {
598
+ "calls": [
599
+ [
600
+ 706,
601
+ 9000
602
+ ]
603
+ ]
604
+ },
605
+ "source": {
606
+ "calls": [
607
+ [
608
+ 706,
609
+ 9000
610
+ ]
611
+ ]
612
+ }
613
+ },
614
+ {
615
+ "rust": {
616
+ "calls": [
617
+ [
618
+ 706,
619
+ 0
620
+ ]
621
+ ]
622
+ },
623
+ "source": {
624
+ "calls": [
625
+ [
626
+ 706,
627
+ 0
628
+ ]
629
+ ]
630
+ }
631
+ },
632
+ {
633
+ "rust": {
634
+ "calls": [
635
+ [
636
+ 706,
637
+ 9000
638
+ ]
639
+ ]
640
+ },
641
+ "source": {
642
+ "calls": [
643
+ [
644
+ 706,
645
+ 9000
646
+ ]
647
+ ]
648
+ }
649
+ },
650
+ {
651
+ "rust": {
652
+ "calls": [
653
+ [
654
+ 706,
655
+ 0
656
+ ]
657
+ ]
658
+ },
659
+ "source": {
660
+ "calls": [
661
+ [
662
+ 706,
663
+ 0
664
+ ]
665
+ ]
666
+ }
667
+ },
668
+ {
669
+ "rust": {
670
+ "calls": []
671
+ },
672
+ "source": {
673
+ "calls": []
674
+ }
675
+ },
676
+ {
677
+ "rust": {
678
+ "calls": []
679
+ },
680
+ "source": {
681
+ "calls": []
682
+ }
683
+ },
684
+ {
685
+ "rust": {
686
+ "calls": [
687
+ [
688
+ 700,
689
+ 9000
690
+ ]
691
+ ]
692
+ },
693
+ "source": {
694
+ "calls": [
695
+ [
696
+ 700,
697
+ 9000
698
+ ]
699
+ ]
700
+ }
701
+ },
702
+ {
703
+ "rust": {
704
+ "calls": [
705
+ [
706
+ 700,
707
+ 0
708
+ ]
709
+ ]
710
+ },
711
+ "source": {
712
+ "calls": [
713
+ [
714
+ 700,
715
+ 0
716
+ ]
717
+ ]
718
+ }
719
+ },
720
+ {
721
+ "rust": {
722
+ "calls": [
723
+ [
724
+ 705,
725
+ 9000
726
+ ]
727
+ ]
728
+ },
729
+ "source": {
730
+ "calls": [
731
+ [
732
+ 705,
733
+ 9000
734
+ ]
735
+ ]
736
+ }
737
+ },
738
+ {
739
+ "rust": {
740
+ "calls": [
741
+ [
742
+ 705,
743
+ 0
744
+ ]
745
+ ]
746
+ },
747
+ "source": {
748
+ "calls": [
749
+ [
750
+ 705,
751
+ 0
752
+ ]
753
+ ]
754
+ }
755
+ },
756
+ {
757
+ "rust": {
758
+ "calls": [
759
+ [
760
+ 705,
761
+ 9000
762
+ ]
763
+ ]
764
+ },
765
+ "source": {
766
+ "calls": [
767
+ [
768
+ 705,
769
+ 9000
770
+ ]
771
+ ]
772
+ }
773
+ },
774
+ {
775
+ "rust": {
776
+ "calls": [
777
+ [
778
+ 705,
779
+ 0
780
+ ]
781
+ ]
782
+ },
783
+ "source": {
784
+ "calls": [
785
+ [
786
+ 705,
787
+ 0
788
+ ]
789
+ ]
790
+ }
791
+ },
792
+ {
793
+ "rust": {
794
+ "calls": []
795
+ },
796
+ "source": {
797
+ "calls": []
798
+ }
799
+ },
800
+ {
801
+ "rust": {
802
+ "calls": []
803
+ },
804
+ "source": {
805
+ "calls": []
806
+ }
807
+ },
808
+ {
809
+ "rust": {
810
+ "calls": []
811
+ },
812
+ "source": {
813
+ "calls": []
814
+ }
815
+ },
816
+ {
817
+ "rust": {
818
+ "calls": []
819
+ },
820
+ "source": {
821
+ "calls": []
822
+ }
823
+ },
824
+ {
825
+ "rust": {
826
+ "calls": [
827
+ [
828
+ 704,
829
+ 9000
830
+ ]
831
+ ]
832
+ },
833
+ "source": {
834
+ "calls": [
835
+ [
836
+ 704,
837
+ 9000
838
+ ]
839
+ ]
840
+ }
841
+ },
842
+ {
843
+ "rust": {
844
+ "calls": [
845
+ [
846
+ 704,
847
+ 0
848
+ ]
849
+ ]
850
+ },
851
+ "source": {
852
+ "calls": [
853
+ [
854
+ 704,
855
+ 0
856
+ ]
857
+ ]
858
+ }
859
+ },
860
+ {
861
+ "rust": {
862
+ "calls": [
863
+ [
864
+ 704,
865
+ 9000
866
+ ]
867
+ ]
868
+ },
869
+ "source": {
870
+ "calls": [
871
+ [
872
+ 704,
873
+ 9000
874
+ ]
875
+ ]
876
+ }
877
+ },
878
+ {
879
+ "rust": {
880
+ "calls": [
881
+ [
882
+ 704,
883
+ 0
884
+ ]
885
+ ]
886
+ },
887
+ "source": {
888
+ "calls": [
889
+ [
890
+ 704,
891
+ 0
892
+ ]
893
+ ]
894
+ }
895
+ }
896
+ ],
897
+ "source_report": "docs/research/qvm-bot-best.json",
898
+ "source_report_sha256": "ac7ef8e7551da9ce39a04ea7a31397bedbcfdac54831da91029045dda1618a50"
899
+ }
docs/research/rust-health-impulse.json CHANGED
@@ -2985,7 +2985,7 @@
2985
  "exit_code": 2
2986
  }
2987
  ],
2988
- "rust_unit_tests": 129,
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": 131,
2989
  "source_report": "docs/research/qvm-health-impulse.json",
2990
  "source_report_sha256": "625fd8064004ea6dbdf398d51d0af844d9c635ff04c0a0790886dddb6ab81e71"
2991
  }
scripts/analyze_rust_bot_best.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ def encode(s):return [s['input']['filename'],*[v for row in s['input']['records'] for v in row]]
7
+ def project(s):return {'calls':s['calls']}
8
+
9
+ def main():
10
+ b=binary();p=Path('docs/research/qvm-bot-best.json');data=p.read_bytes();rows=[]
11
+ for s in json.loads(data)['probes']:rows.append({'source':project(s),'rust':result(b,'best',encode(s))})
12
+ write_json(Path('docs/research/rust-bot-best.json'),{'source_report':str(p),'source_report_sha256':hashlib.sha256(data).hexdigest(),'probes':rows,'limits':'Rust matches all64 original bot winner cases, with wrapping fitness arithmetic before f32 conversion, strict first-wins comparison and typed rejection of incomplete populations. Native botlib genome writes are returned as intentions, without assuming file serialization or runtime integration.'})
13
+ if __name__=='__main__':main()
scripts/rust_native_policy_support.py ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ """Build the scoped native-boundary Rust policy adapter with the declared toolchain."""
2
+ import os,subprocess
3
+ from pathlib import Path
4
+ from rust_lifecycle_support import result,invoke
5
+ def binary():
6
+ subprocess.run(['cargo','build','--offline','--package','urt-gameplay','--bin','urt-native-policy'],capture_output=True,text=True,check=True)
7
+ return Path(os.environ.get('CARGO_TARGET_DIR','target'))/'debug'/'urt-native-policy'
scripts/test_rust_bot_best.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-bot-best.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-bot-best.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
@@ -2520,3 +2520,18 @@ report scripts/analyze_qvm_bot_best.py docs/research/qvm-bot-best.json
2520
  edge docs/research/qvm-bot-best.json scripts/test_qvm_bot_best.py
2521
  group qvm-bot-best scripts/analyze_qvm_bot_best.py
2522
  edge scripts/analyze_qvm_bot_best.py scripts/analyze_qvm_resumer_audit.py
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2520
  edge docs/research/qvm-bot-best.json scripts/test_qvm_bot_best.py
2521
  group qvm-bot-best scripts/analyze_qvm_bot_best.py
2522
  edge scripts/analyze_qvm_bot_best.py scripts/analyze_qvm_resumer_audit.py
2523
+ edge Cargo.toml scripts/analyze_rust_bot_best.py
2524
+ edge Cargo.lock scripts/analyze_rust_bot_best.py
2525
+ edge crates/urt-gameplay/Cargo.toml scripts/analyze_rust_bot_best.py
2526
+ edge crates/urt-gameplay/src/lib.rs scripts/analyze_rust_bot_best.py
2527
+ edge crates/urt-gameplay/src/native_policy.rs scripts/analyze_rust_bot_best.py
2528
+ edge crates/urt-gameplay/src/bin/urt-native-policy.rs scripts/analyze_rust_bot_best.py
2529
+ edge docs/research/qvm-bot-best.json scripts/analyze_rust_bot_best.py
2530
+ edge crates/urt-gameplay/src/native_policy.rs scripts/analyze_rust_health_impulse.py
2531
+ group rust-bot-best scripts/analyze_rust_health_impulse.py
2532
+ group gameplay scripts/analyze_rust_bot_best.py
2533
+ report scripts/analyze_rust_bot_best.py docs/research/rust-bot-best.json
2534
+ edge docs/research/rust-bot-best.json scripts/test_rust_bot_best.py
2535
+ group rust-bot-best scripts/analyze_rust_bot_best.py
2536
+ edge scripts/analyze_rust_bot_best.py scripts/analyze_qvm_resumer_audit.py
2537
+ edge scripts/rust_native_policy_support.py scripts/analyze_qvm_resumer_audit.py