Run body and fire phases during scripted control locks

This commit is contained in:
UnixNight committed 2026-10-26 12:21:25 -04:00
1 parent 5876da112c
commit c285b57091
35 files changed
+1503 -45

No files matched your search

+179
View File
@@ -0,0 +1,179 @@
#!/usr/bin/env python3
"""Read-only CAM/MCA/AI preparation provenance and bounded event projection."""
from __future__ import annotations
import argparse
from dataclasses import dataclass, replace
import hashlib
import json
from pathlib import Path
import struct
from checkpoint_script_state import EXE_SHA256, find_case, read_va
from pe_inspect import PE
SITES = (
('cam_already_active_guard', 0x4165AB, '389e800900000f856c040000'),
('cam_control_none_branch', 0x4165F8, '0f84fc000000'),
('cam_control_null_compare', 0x4165FE, '6864d04e00'),
('cam_named_control', 0x41662A, 'ff9218010000'),
('cam_raw_owner_guard', 0x416635, 'a1e49950003bc30f84a9000000'),
('cam_owner438', 0x41665D, 'ff9038040000'),
('cam_owner410', 0x41666B, 'ff9210040000'),
('cam_owner_euler', 0x41667E, 'ff9028030000'),
('cam_cached_euler', 0x4166A0, '81c174020000'),
('cam_flatten_logical_euler', 0x4166E5, 'ff922c030000'),
('cam_clear_control', 0x4166F4, 'ff9018010000'),
('cam_target_resolution_after_control', 0x416754, 'e817d90500'),
('mca_activation_index_reset', 0x4312A7, '899ea40e0000'),
('mca_first_none_guard', 0x431300, '0f8462030000'),
('mca_first_none_return', 0x431668, '5f5e5d5b83c420c3'),
('mca_first_target_lookup', 0x43131A, 'e8512d0400'),
('mca_first_target_missing_continues', 0x431330, '0f84e9000000'),
('mca_target_animation_prelude', 0x431417, 'ff92e0000000'),
('mca_raw_owner_guard', 0x431502, '8b0de49950003bcb0f849d000000'),
('mca_owner410', 0x431512, 'ff9210040000'),
('mca_owner_euler', 0x431525, 'ff9028030000'),
('mca_flatten_logical_euler', 0x431565, 'ff922c030000'),
('mca_cached_euler', 0x431578, '0574020000'),
('mca_owner438', 0x431598, 'ff9038040000'),
('mca_clear_control', 0x4315A7, 'ff9218010000'),
('mca_start_first_shot', 0x431600, 'ff90e0000000'),
('mca_later_shot_dispatch', 0x430E87, 'ff90e0000000'),
('mca_finish_dispatch', 0x430ED8, 'ff92e4000000'),
('mca_shot_sound_guard', 0x431771, '83bc86e40d0000ff'),
('mca_shot_target_lookup', 0x4317C1, 'e8aa280400'),
('mca_shot_sound_start', 0x431838, 'e853bb0400'),
('mca_shot_target_animation', 0x431909, 'ff92e0000000'),
('mca_completion_null_compare', 0x4311F4, '6864d04e00'),
('mca_completion_control', 0x431222, 'ff9218010000'),
('ai_interface_to_complete', 0x40CA72, '81c138ffffffe883f8ffff'),
('ai_control_descriptor', 0x40C1A5, '8d868c0900006a01506818ce4e00'),
('ai_null_control_guard', 0x40C4AD, '8b0de499500085c97466'),
('ai_owner410', 0x40C4B9, 'ff9210040000'),
('ai_clear_control', 0x40C527, 'ff9218010000'),
('ai_marker_root', 0x40C732, 'ff9010030000'),
('ai_set_root', 0x40C757, 'ff9214030000'),
('ai_yaw_sentinel', 0x40C88F, '81bd940b0000000080bf'),
('ai_set_authored_yaw', 0x40C93E, 'ff9274010000'),
('ai_set_cached_euler', 0x40C94C, '81c334030000'),
('jimmy_prepare_base', 0x42AFC3, 'e888f70000'),
('jimmy_prepare_stop', 0x42AFDE, '6840d04e008bceff9250010000'),
('prepare_speed_zero', 0x43A758, 'c7860806000000000000'),
('prepare_velocity_xyz', 0x43A764, '6a006a006a008bceff90c4020000'),
('jimmy438_cleanup', 0x42AE08, '8b8640ffffff8d8e40ffffffff9078010000'),
('jimmy438_runtime_flags', 0x42AE1A, 'b0018886651d0000a282814f00'),
('default_already_owned', 0x447D5C, '3bc6753f'),
('default_restore_control', 0x447E27, 'ff9018010000'),
('default_snap_strict', 0x447E9D, 'd81dace54800dfe0f6c441'),
('input_owner_guard', 0x475A9C, '8b0de499500085c97409'),
('input_owner_dispatch', 0x475AA9, 'ff92cc030000'),
('jump_held_raw_checks', 0x4378DC, 'a06598500084c0751fa048985000'),
)
TABLES = (
('CAM activation', 0x498060, 0xD8, 0x4165A0),
('MCA activation', 0x4A93C8, 0xD8, 0x431280),
('MCA per-shot', 0x4A93C8, 0xE0, 0x431750),
('MCA completion', 0x4A93C8, 0xE4, 0x4311F0),
('Jimmy410', 0x4A373C, 0x410, 0x42AFC0),
('Jimmy438', 0x4A373C, 0x438, 0x42AE00),
('Jimmy Euler getter', 0x4A373C, 0x328, 0x4723F0),
('Jimmy Euler setter', 0x4A373C, 0x32C, 0x472450),
('Jimmy position setter', 0x4A373C, 0x314, 0x472360),
('Jimmy authored Euler setter', 0x4A373C, 0x174, 0x4716D0),
('Jimmy stop sound', 0x4A3BDC, 0x148, 0x429A00),
('Jimmy action request', 0x4A3BDC, 0x150, 0x43AFF0),
('Jimmy gadget cleanup', 0x4A3BDC, 0x178, 0x427FF0),
('Jimmy held jump', 0x4A3BDC, 0x158, 0x4378D0),
)
# Full body identity guards negative claims as well as selected positive sites.
BODY_RANGES = (('MCA per-shot', 0x431750, 0x4319A2),
('held jump getter', 0x4378D0, 0x43793A))
def preparation_events(kind: str, raw_owner: str | None) -> list[str]:
"""Local source-event projection, not an original routine execution.
Activation preconditions have already reached the inspected preparation
block. Real target, sound and skip handling are intentionally not simulated.
"""
events = []
if kind == 'cam_null':
if raw_owner:
events += [raw_owner + ':438', raw_owner + ':410', raw_owner + ':flatten_euler']
events += ['control:NULL']
elif kind == 'mca_activation':
if raw_owner:
events += [raw_owner + ':410', raw_owner + ':flatten_euler', raw_owner + ':438', 'control:NULL']
elif kind == 'ai_null':
if raw_owner:
events += [raw_owner + ':410']
events += ['control:NULL']
elif kind in ('mca_next_shot', 'default_restore'):
pass # Neither boundary dispatches410/438.
else:
raise ValueError('Unknown preparation boundary')
return events
@dataclass(frozen=True)
class JetpackPreparationState:
speed: float = 350
velocity: tuple[float, float, float] = (10, 20, 30)
impulse: tuple[float, float, float] = (1, 2, 3)
acceleration: tuple[float, float, float] = (4, 5, 6)
mode: int = 1
jump: int = 3
hold: float = .625
fire: float = 6.125
selected_gadget: int = 3
euler: tuple[float, float, float] = (15, 150, 25)
def project_jetpack_preparation(state: JetpackPreparationState, kind: str):
"""Bounded−1/3 selected-gadget projection; do not generalize other gadgets."""
if state.selected_gadget not in (-1, 3):
raise ValueError('Other gadget cleanup policies are outside this fixture')
result = state
for event in preparation_events(kind, 'JIM1'):
if event.endswith(':410'):
result = replace(result, speed=0, velocity=(0, 0, 0))
elif event.endswith(':438'):
result = replace(result, selected_gadget=-1)
elif event.endswith(':flatten_euler'):
result = replace(result, euler=(0, result.euler[1], 0))
return result
def collect(root):
pe = PE(find_case(Path(root), 'Neutron.exe'))
if hashlib.sha256(pe.data).hexdigest() != EXE_SHA256:
raise ValueError('Unsupported source EXE')
sites = []
for name, va, expected in SITES:
actual = read_va(pe, va, len(bytes.fromhex(expected))).hex()
if actual != expected:
raise ValueError(f'{name} changed at {va:#x}: {actual}')
sites.append(dict(name=name, va=hex(va), file_offset=hex(pe.offset(va-pe.base)), bytes=actual))
tables = []
for name, table, slot, target in TABLES:
actual, = struct.unpack('<I', read_va(pe, table+slot, 4))
if actual != target:
raise ValueError(f'{name} target changed')
tables.append(dict(name=name, table=hex(table), slot=hex(slot), target=hex(target),
file_offset=hex(pe.offset(table+slot-pe.base))))
bodies = []
for name, start, end in BODY_RANGES:
bodies.append(dict(name=name, start=hex(start), end=hex(end),
sha256=hashlib.sha256(read_va(pe, start, end-start)).hexdigest()))
return dict(sha256=EXE_SHA256, sites=sites, tables=tables, bodies=bodies,
scope='Static source bytes and a bounded interpretation fixture; no source execution.')
if __name__ == '__main__':
cli = argparse.ArgumentParser(description=__doc__)
cli.add_argument('original', type=Path)
print(json.dumps(collect(cli.parse_args().original), indent=2))
+107
View File
@@ -0,0 +1,107 @@
#!/usr/bin/env python3
"""Decompile selected native procedures in one local REA stdio session.
Uses the public project launcher, no client registration changes or target
execution. Keeps complete replies/Evidence on disk and closes owned analysis.
"""
import argparse
import json
import os
from pathlib import Path
import selectors
import signal
import subprocess
import time
def main():
cli = argparse.ArgumentParser(description=__doc__)
cli.add_argument('target', type=Path)
cli.add_argument('output', type=Path)
cli.add_argument('procedures', nargs='+')
args = cli.parse_args()
project = Path(__file__).resolve().parents[2]
target = args.target.resolve(strict=True)
output = args.output.resolve()
originals = (project.parent / 'Original').resolve()
if target.is_relative_to(originals) or output.is_relative_to(originals):
cli.error('Use a generated target copy and a separate output directory')
output.mkdir(parents=True, exist_ok=False)
serial = 0
with (output / 'server.stderr').open('w') as stderr:
process = subprocess.Popen([str(project / 'scripts/rea.sh'), 'mcp'], cwd=project,
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=stderr, text=True, bufsize=1, start_new_session=True)
selector = selectors.DefaultSelector()
selector.register(process.stdout, selectors.EVENT_READ)
def rpc(method, params):
nonlocal serial
serial += 1
process.stdin.write(json.dumps(dict(jsonrpc='2.0', id=serial, method=method, params=params)) + '\n')
process.stdin.flush()
deadline = time.monotonic() + 180
while time.monotonic() < deadline:
if not selector.select(timeout=1):
if process.poll() is not None:
raise RuntimeError('REA exited; inspect server.stderr')
continue
line = process.stdout.readline()
if not line:
raise RuntimeError('REA stdio closed')
message = json.loads(line)
if message.get('id') == serial:
if 'error' in message:
raise RuntimeError(message['error'])
return message['result']
raise TimeoutError('REA request deadline expired; do not repeat unchanged work')
def tool(name, values, filename, required=True):
result = rpc('tools/call', dict(name=name, arguments=values))
(output / filename).write_text(json.dumps(result, indent=2) + '\n')
if result.get('isError') and required:
raise RuntimeError(f'{name} failed; inspect {filename}')
return result
opened = False
failures = 0
try:
rpc('initialize', dict(protocolVersion='2024-11-05', capabilities={},
clientInfo=dict(name='Neutron-local-static-batch', version='1')))
process.stdin.write(json.dumps(dict(jsonrpc='2.0', method='notifications/initialized')) + '\n')
process.stdin.flush()
tool('open_binary', dict(path=str(target), provider_id='ghidra'), 'open.json')
opened = True
for index, procedure in enumerate(args.procedures):
print('Decompiling', procedure, flush=True)
result = tool('procedure_pseudo_code', dict(procedure=procedure), f'{index:02d}.json', required=False)
if result.get('isError'):
failures += 1
print('Unavailable:', procedure, '(see complete reply)', flush=True)
tool('export_evidence_bundle', dict(path=str(output / 'evidence.json')), 'export.json')
finally:
try:
if opened:
tool('close_binary', dict(snapshot_path=str(output / 'analysis.snapshot.json')), 'close.json')
finally:
process.stdin.close()
try:
try:
process.wait(timeout=15)
except subprocess.TimeoutExpired:
# This group contains only the server/helpers started
#above. Never terminate an existing MCP client session.
os.killpg(process.pid, signal.SIGTERM)
try:
process.wait(timeout=5)
except subprocess.TimeoutExpired:
os.killpg(process.pid, signal.SIGKILL)
process.wait(timeout=5)
finally:
selector.close()
if failures:
raise SystemExit(f'{failures} procedure(s) unavailable; successful Evidence retained')
if __name__ == '__main__':
main()
+71
View File
@@ -0,0 +1,71 @@
#!/usr/bin/env python3
"""Read-only frame/body integration eligibility, independent of raw control."""
import argparse
import hashlib
import json
from pathlib import Path
import struct
from checkpoint_script_state import EXE_SHA256, find_case, read_va
from pe_inspect import PE
SITES = (
('frame_game_gate', 0x47E531, 'e86a77ffff'),
('physics_before_objects', 0x47E554, 'e867b6ffff'),
('game_gate_globals', 0x475CA0, 'a0ab99500084c07409a01c644f0084c07403b001c332c0c3'),
('pause_store', 0x44E458, 'a2ab995000'),
('pause_override_clear', 0x44E465, '880d1c644f00'),
('body_list_enable', 0x479BE9, 'a0e7694f0084c00f8496000000'),
('body_list_payload', 0x479C1A, '8b730885f67450'),
('body_integrate', 0x479C2B, 'e8f0000000'),
('body_integration_gate', 0x479D58, 'ff921002000084c00f84bd050000'),
('integration_flag_get', 0x4719F0, '8a813e010000c3'),
('integration_flag_set', 0x471A04, '88813e010000'),
('init_get_authored_integration', 0x470612, 'ff97b4000000'),
('init_set_live_integration', 0x47061B, 'ff9714020000'),
('constructor_integration_enabled', 0x46FDDF, '6a018bcde848120000'),
('integration_authored_get', 0x471020, '8a4116c3'),
('integration_authored_set', 0x471037, '884116ff9214020000'),
('physics_impulse', 0x479EBB, 'ff9284020000'),
('physics_acceleration', 0x479F01, 'ff9070020000'),
('physics_velocity', 0x479F8D, 'ff92bc020000'),
)
TABLES = (
(0x4A373C, 0x210, 0x4719F0), (0x4A373C, 0x214, 0x471A00),
(0x4A373C, 0xB4, 0x471020),
(0x4C3CD0, 0x168, 0x44E450), (0x4CE910, 0x168, 0x44E450),
(0x4C5A80, 0x168, 0x44E450),
)
def eligible(*, frame_valid=True, flag5099ab=False, override4f641c=False,
supervisor=True, editor=False, bodies_enabled=True, registered=True,
body_integration=True, raw_control=None):
"""Source-gate projection, not original execution; raw owner is not a gate."""
return (frame_valid and (not flag5099ab or override4f641c) and supervisor
and not editor and bodies_enabled and registered and body_integration)
def collect(root):
pe = PE(find_case(Path(root), 'Neutron.exe'))
if hashlib.sha256(pe.data).hexdigest() != EXE_SHA256:
raise ValueError('Unsupported original EXE')
sites = []
for name, va, expected in SITES:
actual = read_va(pe, va, len(bytes.fromhex(expected))).hex()
if actual != expected:
raise ValueError(f'{name} changed at {va:#x}: {actual}')
sites.append(dict(name=name, va=hex(va), file_offset=hex(pe.offset(va-pe.base)), bytes=actual))
tables = []
for table, slot, target in TABLES:
if struct.unpack('<I', read_va(pe, table+slot, 4))[0] != target:
raise ValueError('Physics eligibility virtual target changed')
tables.append(dict(table=hex(table), slot=hex(slot), target=hex(target)))
return dict(sha256=EXE_SHA256, sites=sites, tables=tables,
scope='Static physics eligibility; no original collision/cadence runtime verification.')
if __name__ == '__main__':
cli = argparse.ArgumentParser(description=__doc__)
cli.add_argument('original', type=Path)
print(json.dumps(collect(cli.parse_args().original), indent=2))
+147
View File
@@ -0,0 +1,147 @@
#!/usr/bin/env python3
"""Read-only Jimmy ownership gate and control-independent fire callback evidence."""
from __future__ import annotations
import argparse
import hashlib
import json
from pathlib import Path
import struct
from checkpoint_script_state import EXE_SHA256, find_case, read_va
from pe_inspect import PE
SITES = (
('jimmy_global_elapsed_before_ownership', 0x424600, 'd90508844f00d8442404a1e4995000'),
('jimmy_null_cleanup_branch', 0x424622, '7577'),
('jimmy_null_sound974_stop', 0x424662, 'e839910500'),
('jimmy_null_sound97c_stop', 0x42468D, 'e80e910500'),
('jimmy_grounded_query', 0x42469F, 'ff9218020000'),
('jimmy_normal_radius60', 0x4246DC, '6800007042'),
('jimmy_wrapper_ceiling', 0x424BFC, 'ff92a4010000'),
('jimmy_wrapper_ground_distance', 0x424C08, 'ff90a8010000'),
('jimmy_wrapper_movement', 0x424C34, 'e8072d0100'),
('jimmy_wrapper_late_menu', 0x424C3F, 'ff92c8010000'),
('jimmy_wrapper_history', 0x424C88, 'ff92b4010000'),
('controller_game_gate', 0x437946, 'e855e30300'),
('controller_game_gate_exit', 0x43794D, '0f84e0020000'),
('controller_elapsed774', 0x437953, 'd9442414d88674070000'),
('controller_base_update', 0x43796A, 'e8e166fdff'),
('controller_raw_pointer', 0x437A1B, '8b0de4995000'),
('controller_identity_compare', 0x437A29, '3bc8'),
('controller_not_jimmy_exit', 0x437A2B, '0f8502020000'),
('controller_status_gate83e0', 0x437A31, '381de0834f00'),
('controller_modal_gate8181', 0x437A3D, '381d81814f00'),
('controller_mode_after_gates', 0x437A49, '0fbf8604070000'),
('grounded_release_reset_after_gates', 0x437B9E, '66899e2807000066899e04070000899e14060000'),
('controller_air_apply', 0x437BC5, 'ff9034010000'),
('controller_ground_apply', 0x437C1C, 'ff9230010000'),
('controller_final_speed', 0x437C2D, 'ff926c020000'),
('fire_game_gate', 0x421FB6, 'e8e53c0500'),
('fire_base_update', 0x421FCA, 'e881c0feff'),
('fire_owner', 0x421FCF, '8b8efc050000'),
('fire_missing_owner_exit', 0x421FD5, '85c90f84df000000'),
('fire_owner_support', 0x421FDF, 'ff9218020000'),
('fire_grounded_zero', 0x421FE9, 'c7860006000000000000'),
('fire_subtract_dt', 0x421FF3, 'd98600060000d8642418'),
('fire_store_then_compare', 0x422003, 'd99600060000d81d14d94800'),
('fire_positive_energy', 0x42202B, 'd9442418d9e0dc0dd0e54800'),
('fire_energy_helper', 0x42203B, 'e8e0880000'),
('fire_owner_position_get', 0x422059, 'ff9010030000'),
('fire_position_set', 0x42207E, 'ff9214030000'),
('fire_owner_euler_get', 0x422091, 'ff9028030000'),
('fire_euler_set', 0x4220B6, 'ff922c030000'),
('support_force_override', 0x458960, '8a81a0040000'),
('support_flag_fallback', 0x45896D, 'e99e900100'),
('support_flag_read', 0x471A10, '8a813f010000c3'),
('energy_tutorial_lower', 0x42A92B, '3d31305256'),
('energy_tutorial_upper', 0x42A932, '3d38305256'),
('ceiling_fire_cancel', 0x425159, 'c780c006000000000000'),
('ceiling_jump_reset', 0x425139, '66c786e80700000000'),
('ceiling_fall_request', 0x425149, 'ff92e0000000'),
)
TABLES = (
('Jimmy normal callback', 0x4A373C, 0x3C4, 0x424600),
('Jimmy supported predicate', 0x4A373C, 0x218, 0x458960),
('Jimmy complete ground apply', 0x4A3BDC, 0x130, 0x437C40),
('Jimmy complete air apply', 0x4A3BDC, 0x134, 0x437F90),
('Jimmy complete ceiling test', 0x4A3BDC, 0x1A4, 0x425170),
('Jimmy complete distance test', 0x4A3BDC, 0x1A8, 0x4252E0),
('Jimmy complete ceiling cancellation', 0x4A3BDC, 0x1E0, 0x425120),
('Jimmy complete late menu', 0x4A3BDC, 0x1C8, 0x424E80),
('Jimmy complete history', 0x4A3BDC, 0x1B0, 0x425490),
('Fire normal callback', 0x4A3160, 0x3C4, 0x421FB0),
('Fire logical position setter', 0x4A3160, 0x314, 0x472360),
('Fire logical Euler setter', 0x4A3160, 0x32C, 0x472450),
)
BODY_HASHES = (
('complete_fire_callback', 0x421FB0, 0x113,
'9c4aa99608cebb2c5953b94475dce8b732d7613c8a48be37b3090af4cd238e3a'),
('complete_movement_callback', 0x437940, 0x2FA,
'9579bfb1c4d9ae6abf2a1c78d6f99544871a63216fb80b9a906e3a76ebe27983'),
)
def controller_phases(raw_control, jimmy=0x1000, *, game_enabled=True,
status83e0=False, modal8181=False):
"""Source-gate projection, not execution of original/controller arithmetic."""
phases = ['game_gate']
if not game_enabled:
return phases
phases += ['elapsed774', 'base40E050', 'conditional_timer7A8', 'ownership_check']
if raw_control != jimmy or status83e0 or modal8181:
return phases
return phases + ['controller_modes', 'jump_ground_air', 'speed26C']
def fire_projection(remaining, delta, energy, level_code, *, game_enabled=True,
owner=True, grounded=False):
"""Bounded effect-state projection; no ownership pointer participates.
Python arithmetic is not an x87 bit-identity oracle. The base class callback
has independent work; this projection covers timer/energy/owner-follow only.
"""
if not game_enabled or not owner:
return remaining, energy, False, False
remaining = (0 if grounded else remaining) - delta
active = remaining > 0
if active and not 0x56523031 <= level_code <= 0x56523038:
energy = max(0, min(100, energy - delta * .5))
return remaining, energy, active, True
def collect(root):
pe = PE(find_case(Path(root), 'Neutron.exe'))
if hashlib.sha256(pe.data).hexdigest() != EXE_SHA256:
raise ValueError('Unsupported original EXE')
sites = []
for name, va, expected in SITES:
actual = read_va(pe, va, len(bytes.fromhex(expected))).hex()
if actual != expected:
raise ValueError(f'Changed instruction {name} at {va:#x}: {actual}')
sites.append(dict(name=name, va=hex(va), file_offset=hex(pe.offset(va-pe.base)), bytes=actual))
tables = []
for name, table, slot, target in TABLES:
if struct.unpack('<I', read_va(pe, table+slot, 4))[0] != target:
raise ValueError(f'Changed virtual target {name}')
tables.append(dict(name=name, table=hex(table), slot=hex(slot), target=hex(target),
file_offset=hex(pe.offset(table+slot-pe.base))))
bodies = []
for name, va, length, expected in BODY_HASHES:
raw = read_va(pe, va, length)
actual = hashlib.sha256(raw).hexdigest()
if actual != expected:
raise ValueError(f'Changed source body {name}')
bodies.append(dict(name=name, va=hex(va), file_offset=hex(pe.offset(va-pe.base)),
length=length, sha256=actual,
raw_control_reference=struct.pack('<I', 0x5099E4) in raw))
return dict(sha256=EXE_SHA256, sites=sites, tables=tables, bodies=bodies,
scope='Static source bytes and explicit gate/state projection; no original execution.')
if __name__ == '__main__':
cli = argparse.ArgumentParser(description=__doc__)
cli.add_argument('original', type=Path)
print(json.dumps(collect(cli.parse_args().original), indent=2))