nmarshall commited on
Commit
3fe958b
·
1 Parent(s): e6585be

qvm: trace allocated defuse callback

Browse files
docs/FINDINGS.md CHANGED
@@ -2035,3 +2035,5 @@ RE-1034–1043 batch validation passed:2,018 Python tests,339 Rust tests,146 det
2035
  - Defuse state updates precede allocation. An elapsed completion also requests its log before allocation. [QVM terminal evidence](research/QVM_DEFUSE_ALLOCATION_TERMINAL.md).
2036
 
2037
  - The Rust defuse adapter preserves allocator-terminal caller writes and the completion log plan. [Rust terminal parity](research/RUST_DEFUSE_ALLOCATION_TERMINAL.md).
 
 
 
2035
  - Defuse state updates precede allocation. An elapsed completion also requests its log before allocation. [QVM terminal evidence](research/QVM_DEFUSE_ALLOCATION_TERMINAL.md).
2036
 
2037
  - The Rust defuse adapter preserves allocator-terminal caller writes and the completion log plan. [Rust terminal parity](research/RUST_DEFUSE_ALLOCATION_TERMINAL.md).
2038
+
2039
+ - Defuse event linking precedes the caller's payload and flag writes for start, cancellation and completion. [Full QVM callback evidence](research/QVM_DEFUSE_ALLOCATED_CALLBACK.md).
docs/PROVISIONAL_TODO.md CHANGED
@@ -2097,3 +2097,5 @@ RE-974–983 completed routing, command rewrite, inactivity, movement-parameter
2097
  - [x] RE-1044 Trace defuse caller state at allocator terminals ([evidence](research/QVM_DEFUSE_ALLOCATION_TERMINAL.md)).
2098
 
2099
  - [x] RE-1045 Preserve defuse caller state across allocator terminals in Rust ([evidence](research/RUST_DEFUSE_ALLOCATION_TERMINAL.md)).
 
 
 
2097
  - [x] RE-1044 Trace defuse caller state at allocator terminals ([evidence](research/QVM_DEFUSE_ALLOCATION_TERMINAL.md)).
2098
 
2099
  - [x] RE-1045 Preserve defuse caller state across allocator terminals in Rust ([evidence](research/RUST_DEFUSE_ALLOCATION_TERMINAL.md)).
2100
+
2101
+ - [x] RE-1046 Trace the complete defuse callback through returned event allocations ([evidence](research/QVM_DEFUSE_ALLOCATED_CALLBACK.md)).
docs/RESEARCH_LEDGER.md CHANGED
@@ -2855,3 +2855,7 @@ The start, both cancellation branches and elapsed completion reach allocator ter
2855
  ## 2026-11-21 — RE-1045 Preserve defuse caller state across allocator terminals in Rust
2856
 
2857
  Rust matches the caller state, earlier log and allocator results in sixteen traced cases. The adapter keeps the event projection and fixed pool records intact while committing the allocator count and caller state. See [Rust terminal integration](research/RUST_DEFUSE_ALLOCATION_TERMINAL.md).
 
 
 
 
 
2855
  ## 2026-11-21 — RE-1045 Preserve defuse caller state across allocator terminals in Rust
2856
 
2857
  Rust matches the caller state, earlier log and allocator results in sixteen traced cases. The adapter keeps the event projection and fixed pool records intact while committing the allocator count and caller state. See [Rust terminal integration](research/RUST_DEFUSE_ALLOCATION_TERMINAL.md).
2858
+
2859
+ ## 2026-11-21 — RE-1046 Trace the complete defuse callback through returned event allocations
2860
+
2861
+ Thirty-nine source cases combine eligibility, bomb search, distance routing and real event construction. Both cancellation branches write payload zero and completion writes one, after the native link request. See [full callback findings](research/QVM_DEFUSE_ALLOCATED_CALLBACK.md).
docs/research/QVM_DEFUSE_ALLOCATED_CALLBACK.md ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # Full defuse callback with allocated events
2
+
3
+ [The source report](qvm-defuse-allocated-callback.json) follows 39 cases through the eligibility gates, bomb search 276433, distance helper 65655 and event construction. Twenty-four reach allocation across start, elapsed completion, both cancellation branches, a fallback bomb and a zero-duration start. These cases cover extension, reuse, skipping a recently freed slot and retry at full capacity.
4
+
5
+ Constructor 277695 receives the chosen bomb's origin, initializes event 83 or 84 and sets the snapped origin before requesting native link −31. At link time word 184 and bit 32 of word 424 still hold their allocator values. The caller subsequently writes the configured duration for start, zero for cancellation or one for completion, and sets bit 32. The test fixture holds bit 32 clear until this write.
6
+
7
+ Blocked eligibility, an in-progress timer and missing bombs produce no allocation. Missing-bomb fixtures stop at the reported null-pointer boundary. The 1024-slot missing-bomb case exceeds the current bounded class-search trace budget and is omitted. Log, radio, score and counter calls remain ordered captures. Native registration and linking are requests. The [terminal allocator study](QVM_DEFUSE_ALLOCATION_TERMINAL.md) covers the non-returning prefixes separately.
docs/research/QVM_LOCATION_ALLOCATION_BATCH.md CHANGED
@@ -71,3 +71,5 @@ The single `cargo xtask test-full --since a1fd4e2b` run at the tenth-commit boun
71
  RE-1044 traces the caller and constructor prefixes before diagnostic/fatal allocation in [all four defuse branches](QVM_DEFUSE_ALLOCATION_TERMINAL.md). Rust terminal integration and successful cancel/finish construction remain open.
72
 
73
  RE-1045 matches all sixteen prefixes in [the Rust adapter](RUST_DEFUSE_ALLOCATION_TERMINAL.md). The adapter commits the earlier writes at a terminal outcome and exposes the completion log separately from later effects.
 
 
 
71
  RE-1044 traces the caller and constructor prefixes before diagnostic/fatal allocation in [all four defuse branches](QVM_DEFUSE_ALLOCATION_TERMINAL.md). Rust terminal integration and successful cancel/finish construction remain open.
72
 
73
  RE-1045 matches all sixteen prefixes in [the Rust adapter](RUST_DEFUSE_ALLOCATION_TERMINAL.md). The adapter commits the earlier writes at a terminal outcome and exposes the completion log separately from later effects.
74
+
75
+ RE-1046 combines successful allocation and event construction with [the full source callback](QVM_DEFUSE_ALLOCATED_CALLBACK.md). Link-time and final event fields are captured separately for starts, cancellations and completions.
docs/research/README.md CHANGED
@@ -1663,3 +1663,5 @@ The extension collector adds five focused tests for native tail calls, command-r
1663
  - [Defuse caller state at allocator terminals](QVM_DEFUSE_ALLOCATION_TERMINAL.md)
1664
 
1665
  - [Defuse allocation terminals in Rust](RUST_DEFUSE_ALLOCATION_TERMINAL.md)
 
 
 
1663
  - [Defuse caller state at allocator terminals](QVM_DEFUSE_ALLOCATION_TERMINAL.md)
1664
 
1665
  - [Defuse allocation terminals in Rust](RUST_DEFUSE_ALLOCATION_TERMINAL.md)
1666
+
1667
+ - [Full defuse callback with allocated events](QVM_DEFUSE_ALLOCATED_CALLBACK.md)
docs/research/qvm-defuse-allocated-callback.json ADDED
The diff for this file is too large to render. See raw diff
 
docs/research/qvm-resumer-audit.json CHANGED
@@ -9436,7 +9436,7 @@
9436
  ],
9437
  "explicit_result_offsets": null,
9438
  "helper": "qvm_trace_support.resume",
9439
- "line": 153,
9440
  "literal_range": [
9441
  153774,
9442
  154088
 
9436
  ],
9437
  "explicit_result_offsets": null,
9438
  "helper": "qvm_trace_support.resume",
9439
+ "line": 159,
9440
  "literal_range": [
9441
  153774,
9442
  154088
scripts/analyze_qvm_defuse_allocated_callback.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Execute the full defuse callback with real successful event allocations."""
2
+ from itertools import product
3
+ from pathlib import Path
4
+
5
+ from analyze_qvm import write_json
6
+ from qvm_defuse_support import full_fixtures, full_run, full_seed, handlers
7
+ from qvm_location_feedback_support import (
8
+ POOL, allocated_event_handler, allocation_fixtures, allocation_seed, seed,
9
+ )
10
+ from qvm_research_support import source
11
+
12
+
13
+ FIELDS = (0, 4, 12, 16, 20, 24, 28, 32, 36, 40, 44, 84, 140, 180, 184, 188,
14
+ 400, 424, 488, 492, 496, 512, 532, 536, 540, 564, 568, 572)
15
+
16
+
17
+ def fixtures():
18
+ profiles = {a['profile']: a for a in full_fixtures() if a['selector'] == 0}
19
+ pools = allocation_fixtures()
20
+ for profile, pool_variant in product((0, 1, 2, 3, 5, 6, 16, 23, 26, 29), (0, 1, 2, 11)):
21
+ if profile == 26 and pool_variant == 11:
22
+ continue # Full-table misses exceed the bounded lookup trace budget.
23
+ a = profiles[profile]
24
+ yield dict(a, allocation=dict(pools[pool_variant], tick=a['tick']), event_flags=0x12345658)
25
+
26
+
27
+ def probe(ins, m, b, a):
28
+ full_seed(m, b, a)
29
+ allocation_seed(m, a['allocation'])
30
+ for index in (64, 65, 66):
31
+ m[POOL + index * 880 + 424] = a['event_flags']
32
+ # Search walks the entire live extent in the missing-bomb fixture.
33
+ for index in range(6, 64):
34
+ record = POOL + index * 880
35
+ m.update({record + 532: 0, record + 536: 0, record + 540: 0})
36
+ effects, allocations, links = [], [], []
37
+ event_handler = allocated_event_handler(allocations, links)
38
+ captures = handlers(effects)
39
+
40
+ def allocate(i, memory, args, bytes_):
41
+ effects.append(dict(op='allocate', event=args[12]))
42
+ return event_handler(i, memory, args, bytes_)
43
+
44
+ captures[277695] = allocate
45
+ m, row, _ = full_run(ins, m, b, a, captures)
46
+ row.update(input=a, events=effects, allocation=None, record=None, links=links)
47
+ if allocations:
48
+ assert len(allocations) == len(links) == 1
49
+ outcome = allocations[0]
50
+ row['execution']['allocator'] = outcome.pop('execution')
51
+ selected = POOL + outcome['selected'] * 880
52
+ row.update(allocation=outcome, record={str(o): m[selected + o] & 0xffffffff for o in FIELDS})
53
+ row['event'] = [row['record'][key] for key in ('184', '424')]
54
+ row['guards'] = [row['record'][key] for key in ('180', '188')]
55
+ return row
56
+
57
+
58
+ def main():
59
+ meta, raw, header, ins = source()
60
+ probes = [probe(ins, *seed(raw, header, a), a) for a in fixtures()]
61
+ write_json(Path('docs/research/qvm-defuse-allocated-callback.json'), {
62
+ 'source': meta['source'], 'sha256': meta['sha256'], 'probes': probes,
63
+ 'limits': 'Actual callback, lookup, distance, allocator, event constructor and origin setter. Radio, score, counter, log and native registration/link captured; allocator terminals covered separately.',
64
+ })
65
+
66
+
67
+ if __name__ == '__main__':
68
+ main()
scripts/qvm_location_feedback_support.py CHANGED
@@ -133,25 +133,31 @@ def allocated_begin_fixtures():
133
  cases=allocation_fixtures()
134
  return [dict(defaults(),tick=cases[index]['tick'],allocation=cases[index],origin=origin,duration=duration) for index,origin,duration in product([0,1,2,11],[[1.9,-2.9,3.1],[-0.5,0.5,-0.]],[0,5,0xffffffff])]
135
 
136
- def allocated_begin(ins,m,b,a):
137
- from qvm_defuse_support import state_seed,BASE as D,BOMB,view
138
- from qvm_trace_support import resume
139
- state_seed(m,a);allocation_seed(m,a['allocation'])
140
- for j,v in enumerate(a['origin']):m[BOMB+24+4*j]=word(v)
141
- from qvm_string_memory_support import frame_args
142
- m,b=frame_args(m,b,{D+28:CLIENT,D+32:BOMB,D+100:ENTITY});allocations=[];links=[]
143
  def event(i,m,args,bs):
144
  def allocate(i,m,args,b):
145
  m,p=allocation_run(i,m);allocations.append(p)
146
- if p['selected'] is None:raise ValueError('allocated defuse fixture requires returned allocation')
147
  return m,POOL+880*p['selected'],{'actual_source_child':277165}
148
  def origin(i,m,args,b):
149
  m,v,p,b=run(i,m,278138,278199,16,args,dict(b),base=BASE+0x80000);return m,0,{'actual_source_child':278138}
150
- def link(i,m,args,b):links.append((args[8]-POOL)//880);return m,0,{'native_link_captured':True}
 
 
 
151
  m,v,p,b=run(i,m,277695,277777,36,args,dict(bs),{277165:allocate,278138:origin,-31:link},base=BASE+0x90000)
152
  return m,v,{'actual_source_child':277695}
153
- m,p=resume(ins,153774,154088,m,D,boundaries=(153917,),handlers={277695:event},byte_inputs=b,repeated_calls=True,sync_child_words=True,coherent_memory=True,byte_handlers=True,capture_byte_memory=True)
 
 
 
 
 
 
 
 
 
154
  selected=POOL+880*allocations[0]['selected'];fields=[0,4,12,16,20,24,28,32,36,40,44,84,140,180,184,188,400,424,488,492,496,512,532,536,540,564,568,572];state=view(m,a)
155
  state.update(event=[m[selected+184]&0xffffffff,m[selected+424]&0xffffffff],guards=[m[selected+180]&0xffffffff,m[selected+188]&0xffffffff])
156
  allocation=allocations[0];allocation.pop('execution')
157
- return m,dict(**state,allocation=allocation,record={str(o):m[selected+o]&0xffffffff for o in fields},links=links,execution={k:p[k] for k in ['stop','trace_length','trace_sha256']}),p['byte_memory']
 
133
  cases=allocation_fixtures()
134
  return [dict(defaults(),tick=cases[index]['tick'],allocation=cases[index],origin=origin,duration=duration) for index,origin,duration in product([0,1,2,11],[[1.9,-2.9,3.1],[-0.5,0.5,-0.]],[0,5,0xffffffff])]
135
 
136
+ def allocated_event_handler(allocations,links):
 
 
 
 
 
 
137
  def event(i,m,args,bs):
138
  def allocate(i,m,args,b):
139
  m,p=allocation_run(i,m);allocations.append(p)
140
+ if p['selected'] is None:raise ValueError('event constructor requires a returned allocation')
141
  return m,POOL+880*p['selected'],{'actual_source_child':277165}
142
  def origin(i,m,args,b):
143
  m,v,p,b=run(i,m,278138,278199,16,args,dict(b),base=BASE+0x80000);return m,0,{'actual_source_child':278138}
144
+ def link(i,m,args,b):
145
+ record=args[8]
146
+ links.append(dict(slot=(record-POOL)//880,payload=m[record+184]&0xffffffff,flags=m[record+424]&0xffffffff))
147
+ return m,0,{'native_link_captured':True}
148
  m,v,p,b=run(i,m,277695,277777,36,args,dict(bs),{277165:allocate,278138:origin,-31:link},base=BASE+0x90000)
149
  return m,v,{'actual_source_child':277695}
150
+ return event
151
+
152
+ def allocated_begin(ins,m,b,a):
153
+ from qvm_defuse_support import state_seed,BASE as D,BOMB,view
154
+ from qvm_trace_support import resume
155
+ state_seed(m,a);allocation_seed(m,a['allocation'])
156
+ for j,v in enumerate(a['origin']):m[BOMB+24+4*j]=word(v)
157
+ from qvm_string_memory_support import frame_args
158
+ m,b=frame_args(m,b,{D+28:CLIENT,D+32:BOMB,D+100:ENTITY});allocations=[];links=[]
159
+ m,p=resume(ins,153774,154088,m,D,boundaries=(153917,),handlers={277695:allocated_event_handler(allocations,links)},byte_inputs=b,repeated_calls=True,sync_child_words=True,coherent_memory=True,byte_handlers=True,capture_byte_memory=True)
160
  selected=POOL+880*allocations[0]['selected'];fields=[0,4,12,16,20,24,28,32,36,40,44,84,140,180,184,188,400,424,488,492,496,512,532,536,540,564,568,572];state=view(m,a)
161
  state.update(event=[m[selected+184]&0xffffffff,m[selected+424]&0xffffffff],guards=[m[selected+180]&0xffffffff,m[selected+188]&0xffffffff])
162
  allocation=allocations[0];allocation.pop('execution')
163
+ return m,dict(**state,allocation=allocation,record={str(o):m[selected+o]&0xffffffff for o in fields},links=[link['slot'] for link in links],execution={k:p[k] for k in ['stop','trace_length','trace_sha256']}),p['byte_memory']
scripts/test_qvm_defuse_allocated_callback.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import unittest
3
+ from pathlib import Path
4
+
5
+ from qvm_defuse_oracle import full
6
+ from qvm_location_feedback_oracle import allocated_begin
7
+
8
+
9
+ class AllocatedCallbackTests(unittest.TestCase):
10
+ def test_routing_and_event_record(self):
11
+ report = json.loads(Path('docs/research/qvm-defuse-allocated-callback.json').read_text())
12
+ self.assertEqual(len(report['probes']), 39)
13
+ covered = set()
14
+ for row in report['probes']:
15
+ a = row['input']
16
+ with self.subTest(profile=a['profile'], pool=a['allocation']['profile']):
17
+ expected = full(a)
18
+ allocation = next((e for e in expected['events'] if e['op'] == 'allocate'), None)
19
+ link = []
20
+ initialized = record = None
21
+ if allocation:
22
+ covered.add((a['profile'], a['allocation']['profile']))
23
+ bomb = expected['lookups'][0]
24
+ origin = (a['distance'] if bomb == 4 else 30., 0., 0.)
25
+ estimate = allocated_begin(dict(a, origin=origin))
26
+ initialized = estimate['allocation']
27
+ initialized['record']['424'] = a['event_flags']
28
+ record = estimate['record']
29
+ payload, _ = expected['event']
30
+ record.update({'4': allocation['event'] + 19, '184': payload,
31
+ '424': a['event_flags'] | 32})
32
+ expected.update(event=[record['184'], record['424']], guards=estimate['guards'])
33
+ link = [dict(slot=initialized['selected'], payload=0x12345678,
34
+ flags=a['event_flags'])]
35
+ self.assertGreater(row['execution']['allocator']['trace_length'], 0)
36
+ expected.update(allocation=initialized, record=record, links=link)
37
+ self.assertEqual({key: row[key] for key in expected}, expected)
38
+ self.assertEqual(covered, {(p, i) for p in (0, 2, 3, 5, 23, 29) for i in (0, 1, 2, 11)})
39
+
40
+
41
+ if __name__ == '__main__':
42
+ unittest.main()
xtask/checks.tsv CHANGED
@@ -4757,3 +4757,8 @@ edge crates/urt-gameplay/src/location_feedback.rs scripts/analyze_rust_defuse_al
4757
  edge crates/urt-gameplay/src/bin/urt-location-feedback.rs scripts/analyze_rust_defuse_allocation_terminal.py
4758
  edge crates/urt-gameplay/src/defuse.rs scripts/analyze_rust_defuse_allocation_terminal.py
4759
  edge crates/urt-gameplay/src/transition.rs scripts/analyze_rust_defuse_allocation_terminal.py
 
 
 
 
 
 
4757
  edge crates/urt-gameplay/src/bin/urt-location-feedback.rs scripts/analyze_rust_defuse_allocation_terminal.py
4758
  edge crates/urt-gameplay/src/defuse.rs scripts/analyze_rust_defuse_allocation_terminal.py
4759
  edge crates/urt-gameplay/src/transition.rs scripts/analyze_rust_defuse_allocation_terminal.py
4760
+ report scripts/analyze_qvm_defuse_allocated_callback.py docs/research/qvm-defuse-allocated-callback.json
4761
+ edge docs/research/qvm-defuse-allocated-callback.json scripts/test_qvm_defuse_allocated_callback.py
4762
+ group qvm-defuse-allocated-callback scripts/analyze_qvm_defuse_allocated_callback.py
4763
+ group qvm-defuse-allocated-callback scripts/analyze_qvm_location_allocated_defuse.py
4764
+ edge scripts/analyze_qvm_defuse_allocated_callback.py scripts/analyze_qvm_resumer_audit.py