nmarshall commited on
Commit
a0bd519
·
1 Parent(s): 952b689

qvm: weapon transition completion

Browse files
docs/ASSET_PIPELINE_TODO.md CHANGED
@@ -406,3 +406,6 @@ Research progress: RE-571 [report](research/QVM_WEAPON_LOOKUP.md); remaining nat
406
 
407
 
408
  Research progress: RE-572 [report](research/QVM_WEAPON_SELECT.md); remaining native/content/runtime/platform scope stays open.
 
 
 
 
406
 
407
 
408
  Research progress: RE-572 [report](research/QVM_WEAPON_SELECT.md); remaining native/content/runtime/platform scope stays open.
409
+
410
+
411
+ Research progress: RE-573 [report](research/QVM_WEAPON_COMPLETE.md); remaining native/content/runtime/platform scope stays open.
docs/FINDINGS.md CHANGED
@@ -764,3 +764,6 @@ Bounded qagame paths recover bomb-plant/inactivity correction requests, direct f
764
 
765
 
766
  **RE-572 — Weapon selection request gates and transition effects:** 48798 validates requested IDs1..27 and actual slot presence, emits30/parameter0, sets state2/timer0-or300 and timed torso54, then resets counters/resources and clears bits64/8/512 without switching slots. [Evidence](research/QVM_WEAPON_SELECT.md).
 
 
 
 
764
 
765
 
766
  **RE-572 — Weapon selection request gates and transition effects:** 48798 validates requested IDs1..27 and actual slot presence, emits30/parameter0, sets state2/timer0-or300 and timed torso54, then resets counters/resources and clears bits64/8/512 without switching slots. [Evidence](research/QVM_WEAPON_SELECT.md).
767
+
768
+
769
+ **RE-573 — Weapon transition completion and fallback contract:** 49028 looks up command weapon byte then fallbackID1, writes the returned slot without checking a second−1, sets state1, adds250 to timer, requests torso55 and emits30/parameter1. [Evidence](research/QVM_WEAPON_COMPLETE.md).
docs/PROVISIONAL_TODO.md CHANGED
@@ -720,3 +720,6 @@ Research progress: RE-571 [report](research/QVM_WEAPON_LOOKUP.md); remaining nat
720
 
721
 
722
  Research progress: RE-572 [report](research/QVM_WEAPON_SELECT.md); remaining native/content/runtime/platform scope stays open.
 
 
 
 
720
 
721
 
722
  Research progress: RE-572 [report](research/QVM_WEAPON_SELECT.md); remaining native/content/runtime/platform scope stays open.
723
+
724
+
725
+ Research progress: RE-573 [report](research/QVM_WEAPON_COMPLETE.md); remaining native/content/runtime/platform scope stays open.
docs/RESEARCH_LEDGER.md CHANGED
@@ -556,3 +556,8 @@ Actual54444 reload/interaction order exposes timer interference before the weapo
556
  ## 2026-10-20 — RE-572 Weapon selection request gates and transition effects (separate task commit)
557
 
558
  48798 validates requested IDs1..27 and actual slot presence, emits30/parameter0, sets state2/timer0-or300 and timed torso54, then resets counters/resources and clears bits64/8/512 without switching slots. 76 fixtures independently check every guard, slot15 versus excluded16, state3 magazine exception overridden by state8, actual child order and all retained weapon records. Full suite: 807 tests pass. Report regenerates byte-identically (531673 bytes). Storage/filter, links and whitespace checks pass. No assets/Rust runtime/shared VM evaluator changed; native/reference/legal/full platform scope remains open.
 
 
 
 
 
 
556
  ## 2026-10-20 — RE-572 Weapon selection request gates and transition effects (separate task commit)
557
 
558
  48798 validates requested IDs1..27 and actual slot presence, emits30/parameter0, sets state2/timer0-or300 and timed torso54, then resets counters/resources and clears bits64/8/512 without switching slots. 76 fixtures independently check every guard, slot15 versus excluded16, state3 magazine exception overridden by state8, actual child order and all retained weapon records. Full suite: 807 tests pass. Report regenerates byte-identically (531673 bytes). Storage/filter, links and whitespace checks pass. No assets/Rust runtime/shared VM evaluator changed; native/reference/legal/full platform scope remains open.
559
+
560
+
561
+ ## 2026-10-20 — RE-573 Weapon transition completion and fallback contract (separate task commit)
562
+
563
+ 49028 looks up command weapon byte then fallbackID1, writes the returned slot without checking a second−1, sets state1, adds250 to timer, requests torso55 and emits30/parameter1. 52 probes independently check requested/fallback priority, slot15, missing fallback, signed timer overflow, type/timer animation gates and event parameter1. Full suite: 811 tests pass. Report regenerates byte-identically (670259 bytes). Storage/filter, links and whitespace checks pass. No assets/Rust runtime/shared VM evaluator changed; native/reference/legal/full platform scope remains open.
docs/REVERSE_ENGINEERING_TODO.md CHANGED
@@ -760,3 +760,6 @@ Purpose: turn the supplied installation into an evidence-backed specification of
760
 
761
 
762
  - [x] RE-572 Weapon selection request gates and transition effects ([report](research/QVM_WEAPON_SELECT.md)).
 
 
 
 
760
 
761
 
762
  - [x] RE-572 Weapon selection request gates and transition effects ([report](research/QVM_WEAPON_SELECT.md)).
763
+
764
+
765
+ - [x] RE-573 Weapon transition completion and fallback contract ([report](research/QVM_WEAPON_COMPLETE.md)).
docs/research/QVM_WEAPON_COMPLETE.md ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Weapon transition completion and fallback contract
2
+
3
+ RE-573. Reproduce with `python3 scripts/analyze_qvm_weapon_complete.py`; check with `python3 scripts/test_qvm_weapon_complete.py`. The [machine report](qvm-weapon-complete.json) retains source identity and bounded fixtures.
4
+
5
+ Complete49028 uses actual31691 with the command weapon byte at FRAME24. If lookup returns−1 it searches ID1; the second result is written directly into PS144. It sets PS148=1, adds250 to PS44 using32-bit arithmetic, requests direct torso55 via39338 and emits event30 parameter1. No packed weapon word is changed. Direct torso request honors its existing timer and kind guards.
6
+
7
+ 52 fixtures retain a separate explicit PS308 canary. With both lookups missing, PS144 becomes−1 and subsequent selected-word observation addresses that adjacent word; this exposes an unguarded contract, not a claim that−1 is a legal runtime slot. The caller must ensure fallback presence or the Rust implementation must choose an explicit checked policy. Original behavior must be validated before changing semantics.
8
+
9
+ The bounded driver now accepts explicit byte inputs so FRAME24 is supplied separately from signed movement bytes25..27. Existing defaults are unchanged; focused and full regression checks cover this addition. Remaining: connect48798→49028 through actual50746 timer/phase gates and map animation/event IDs to content.
10
+
11
+ No original executable/full QVM/native collision/physics/rendering executes. Native responses and legal input domains are supplied or unverified where stated; full runtime/macOS/Linux Rust/Bevy/Solari gameplay remains open.
docs/research/README.md CHANGED
@@ -321,3 +321,6 @@ The extension collector adds five focused tests for native tail calls, command-r
321
 
322
 
323
  [RE-572: Weapon selection request gates and transition effects](QVM_WEAPON_SELECT.md). Reproduce with `python3 scripts/analyze_qvm_weapon_select.py`; check with `python3 scripts/test_qvm_weapon_select.py`.
 
 
 
 
321
 
322
 
323
  [RE-572: Weapon selection request gates and transition effects](QVM_WEAPON_SELECT.md). Reproduce with `python3 scripts/analyze_qvm_weapon_select.py`; check with `python3 scripts/test_qvm_weapon_select.py`.
324
+
325
+
326
+ [RE-573: Weapon transition completion and fallback contract](QVM_WEAPON_COMPLETE.md). Reproduce with `python3 scripts/analyze_qvm_weapon_complete.py`; check with `python3 scripts/test_qvm_weapon_complete.py`.
docs/research/qvm-weapon-complete.json ADDED
The diff for this file is too large to render. See raw diff
 
scripts/analyze_qvm_weapon_complete.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Complete49028 selected-command lookup, fallback1 and raising transition."""
3
+ import itertools
4
+ from pathlib import Path
5
+ from qvm_research_support import source,execute
6
+ from qvm_weapon_support import weapon_seed,weapon_state
7
+ from qvm_suffix_support import handlers
8
+ from analyze_qvm_weapon_lookup import lookup
9
+ from analyze_qvm_acceleration import PS,FRAME
10
+ from analyze_qvm import write_json
11
+ LOCAL=0x75000000
12
+
13
+ def complete(ins,m,cmd=(0,0,0)):
14
+ before=weapon_state(m);hs=handlers();hs[31691]=lookup;canary=m[PS+308]&0xffffffff
15
+ m,c,r=execute(ins,49029,49115,m,cmd,LOCAL,hs,byte_inputs={FRAME+24:m[FRAME+24]&255})
16
+ return m,{'initial':before,'kind':m[PS+4],'adjacent_slot_minus1':canary,'execution':r,'final':weapon_state(m)}
17
+
18
+ def main():
19
+ q,raw,h,ins=source();rows=[]
20
+ for desired,where,fallback,timer in itertools.product([0,1,22,255],[-1,0,15],[False,True],[0,100]):
21
+ m=weapon_seed(raw,h,desired=desired);m.update({PS+144:7,PS+312+7*4:27,PS+44:timer,PS+308:0x12345678})
22
+ if where>=0:m[PS+312+where*4]=(desired&255)|0xaa000000
23
+ if fallback:m[PS+312+5*4]=1
24
+ rows.append(complete(ins,m)[1])
25
+ for changes in [{PS+80:1},{PS+4:3},{PS+44:0x7fffffff-100},{PS+108:0xffffffff}]:
26
+ m=weapon_seed(raw,h);m.update({PS+312:1,PS+316:22,PS+308:0x12345678});m.update(changes);rows.append(complete(ins,m)[1])
27
+ write_json(Path('docs/research/qvm-weapon-complete.json'),{'source':q['source'],'sha256':q['sha256'],'probes':rows,'limits':'Complete finite49028 with actual slot lookups/39338/29913. Missing desired and fallback records expose unguarded slot−1; adjacent PS308 is an explicit canary, not a legal game state. No native playback.'})
28
+ if __name__=='__main__':main()
scripts/qvm_research_support.py CHANGED
@@ -19,7 +19,7 @@ def memory(raw,h,cmd=(100,0,0),plane=1,flags=0):
19
  m[0x30000+24]=sum((v&255)<<(8*(i+1)) for i,v in enumerate(cmd));return m
20
 
21
 
22
- def execute(ins,start,stop,m,cmd,base,handlers=None,result_offsets=None,boundaries=()):
23
  """Bounded source calls with actual recovered children at empty-stack boundaries."""
24
  import math
25
  from analyze_deferred_auth import trace_slice
@@ -27,7 +27,7 @@ def execute(ins,start,stop,m,cmd,base,handlers=None,result_offsets=None,boundari
27
  from analyze_qvm_acceleration import FRAME,word,number
28
  handlers=handlers or {};result_offsets=result_offsets or {};points=[x['index']+2 for x in ins[start:stop] if x['opcode']=='CALL']+list(boundaries);pc=start;trace=[];calls=[];children=[];writes=[];ret=None
29
  for _ in range(256):
30
- t=trace_slice(ins,start,stop,m,{},resume_at=pc,stop_targets=[p for p in points if p!=pc],byte_memory={FRAME+25+i:v&255 for i,v in enumerate(cmd)},local_base=base,halt_on_leave=True,capture_stack=True,limit=8192);m=t['memory'];pc=t.get('stop',stop);trace+=t['trace'];calls+=t['calls'];writes+=t['byte_writes'];cmd=[t['byte_memory'][FRAME+25+i] for i in range(3)]
31
  for c in t['calls']:
32
  if c['target']==-107:value=word(math.sqrt(number(c['args'][8])));r={'input':c['args'][8]&0xffffffff,'root':value}
33
  else:
 
19
  m[0x30000+24]=sum((v&255)<<(8*(i+1)) for i,v in enumerate(cmd));return m
20
 
21
 
22
+ def execute(ins,start,stop,m,cmd,base,handlers=None,result_offsets=None,boundaries=(),byte_inputs=None):
23
  """Bounded source calls with actual recovered children at empty-stack boundaries."""
24
  import math
25
  from analyze_deferred_auth import trace_slice
 
27
  from analyze_qvm_acceleration import FRAME,word,number
28
  handlers=handlers or {};result_offsets=result_offsets or {};points=[x['index']+2 for x in ins[start:stop] if x['opcode']=='CALL']+list(boundaries);pc=start;trace=[];calls=[];children=[];writes=[];ret=None
29
  for _ in range(256):
30
+ t=trace_slice(ins,start,stop,m,{},resume_at=pc,stop_targets=[p for p in points if p!=pc],byte_memory={**(byte_inputs or {}),**{FRAME+25+i:v&255 for i,v in enumerate(cmd)}},local_base=base,halt_on_leave=True,capture_stack=True,limit=8192);m=t['memory'];pc=t.get('stop',stop);trace+=t['trace'];calls+=t['calls'];writes+=t['byte_writes'];cmd=[t['byte_memory'][FRAME+25+i] for i in range(3)]
31
  for c in t['calls']:
32
  if c['target']==-107:value=word(math.sqrt(number(c['args'][8])));r={'input':c['args'][8]&0xffffffff,'root':value}
33
  else:
scripts/test_qvm_weapon_complete.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json,unittest,copy
2
+ from pathlib import Path
3
+ from test_qvm_water_events import enqueue
4
+ from test_qvm_torso_selector import signed
5
+
6
+ def completion_state(p):
7
+ a=copy.deepcopy(p['initial']);desired=a['command_weapon'];slots=a['weapons'];slot=next((j for j,v in enumerate(slots) if v&255==desired),-1)
8
+ if slot==-1:slot=next((j for j,v in enumerate(slots) if v&255==1),-1)
9
+ a['slot']=slot&0xffffffff;a['packed']=slots[slot] if slot>=0 else p['adjacent_slot_minus1'];a['weapon_state']=1;a['weapon_timer']=(a['weapon_timer']+250)&0xffffffff
10
+ if p['kind']<3 and signed(a['torso_timer'])<=0:a['torso']=((a['torso']&128)^128)|55
11
+ index=a['queue']['sequence']&1;a['queue']=enqueue(a['queue'],[30]);a['queue']['parameters'][index]=1;return a
12
+ class WeaponCompleteTests(unittest.TestCase):
13
+ @classmethod
14
+ def setUpClass(cls):cls.r=json.loads(Path('docs/research/qvm-weapon-complete.json').read_text())
15
+ def test_exact_lookup_fallback_slot_timer_and_event(self):
16
+ self.assertEqual(len(self.r['probes']),52)
17
+ for p in self.r['probes']:self.assertEqual(p['final'],completion_state(p))
18
+ def test_actual_child_order_and_fallback_condition(self):
19
+ for p in self.r['probes']:
20
+ a=p['initial'];found=any(v&255==a['command_weapon'] for v in a['weapons']);self.assertEqual([c['target'] for c in p['execution']['calls']],[31691]+([] if found else [31691])+[39338,29913]);self.assertEqual(p['execution']['calls'][-1]['args'],{'8':30,'12':1,'16':65536})
21
+ def test_missing_fallback_not_silently_coerced(self):
22
+ rows=[p for p in self.r['probes'] if p['final']['slot']==0xffffffff];self.assertTrue(rows)
23
+ for p in rows:self.assertEqual(p['final']['packed'],0x12345678)
24
+ def test_weapons_and_resources_preserved(self):
25
+ for p in self.r['probes']:
26
+ for key in ['weapons','inventory','counter204','resource','resource_timer','state220']:self.assertEqual(p['initial'][key],p['final'][key])
27
+ if __name__=='__main__':unittest.main()