Trace post-skip tilt and gate gameplay changes on original lifecycle recovery

This commit is contained in:
UnixNight committed 2026-11-05 22:14:49 -05:00
1 parent a2e89c625a
commit 68154dffce
15 files changed
+752 -6

No files matched your search

+106
View File
@@ -0,0 +1,106 @@
#!/usr/bin/env python3
"""Read-only source ordering and actual lab camera graph; no gameplay mutation."""
import argparse
import hashlib
import json
from pathlib import Path
import re
import struct
from checkpoint_script_state import EXE_SHA256, find_case, read_va, rel_call_target
from pe_inspect import PE
import gam
REA_ID = 'ev_0d64cc58fa8f5573fc8e61e0f2c20e36288099212bd2257d3a3121361fd6c904'
CALLS = (('physics before registry', 0x47e554, 0x479bc0),
('registry callbacks', 0x47e582, 0x473740),
('dynamic contact notification', 0x479c83, 0x47a430),
('AI trigger base contact', 0x40c209, 0x470a90),
('AI trigger synchronous action', 0x40c21f, 0x40c300),
('Carl inherited AI before talk', 0x41b95d, 0x408000))
SITES = (('first dynamic enter', 0x47a555, 'ff5040'),
('second dynamic enter', 0x47a578, 'ff5240'),
('registry per-object update', 0x473758, 'ff5010'),
('Carl talk in ordinary actor update', 0x41b988, 'ff9240010000'),
('MCA shot complete', 0x430ed8, 'ff92e4000000'),
('MCA skip input-latch write', 0x430f37, 'c680001e000001'),
('MCA shared skip flag', 0x430f3e, 'c605e4834f0001'),
('MCA skip finish', 0x431012, 'ff90e4000000'),
('CAM skip input-latch write', 0x41613b, 'c680001e000001'),
('CAM shared skip flag', 0x416142, 'c605e4834f0001'),
('DEFAULT clears shared skip', 0x447f89, 'c605e4834f0000'))
SLOTS = (('AI trigger enter, game interface+C8', 0x48f8c0, 0x40, 0x40c200),
('Carl enter, game interface+C0', 0x495364, 0x40, 0x40a3c0),
('Carl update', 0x495364, 0x3c4, 0x41b950),
('CAM update, game interface+C8', 0x497bfc, 0x3c4, 0x415f90),
('MCA update, game interface+C8', 0x4a8f64, 0x3c4, 0x430da0),
('MCA finish, complete table', 0x4a93c8, 0xe4, 0x4311f0))
RANGES = ((0x47e554, 0x47e58c), (0x479c7e, 0x479c8c),
(0x47a488, 0x47a57c), (0x40c200, 0x40c227),
(0x41b950, 0x41b98e), (0x41b7b0, 0x41b810),
(0x473740, 0x473768), (0x430da0, 0x430ef2),
(0x430eed, 0x431027), (0x4160f1, 0x4161cd),
(0x447f73, 0x447fc5))
FIELDS = {'ObjectTag','NextTrigger','PlayerControlled','DeactivateInv','AITarget',
'AIAnim','AIState','AINewPos','AINewRotY','AIHideObj','ActivateBy',
'ActivateByAnim','TaskName','TimesToTrigger','TouchActivated',
'TargetActAnim','TargetDeactAnim','FaceObject'}
def collect(original, rea=None):
original = Path(original)
pe = PE(find_case(original, 'Neutron.exe'))
if hashlib.sha256(pe.data).hexdigest() != EXE_SHA256:
raise ValueError('Unexpected original executable')
calls=[]
for name, va, target in CALLS:
if rel_call_target(pe,va) != target:
raise ValueError(name)
calls.append(dict(name=name,va=hex(va),file_offset=hex(pe.offset(va-pe.base)),target=hex(target)))
sites=[]
for name,va,expected in SITES:
if read_va(pe,va,len(bytes.fromhex(expected))).hex()!=expected:
raise ValueError(name)
sites.append(dict(name=name,va=hex(va),file_offset=hex(pe.offset(va-pe.base)),bytes=expected))
slots=[]
for name,table,slot,target in SLOTS:
if struct.unpack('<I',read_va(pe,table+slot,4))[0]!=target:
raise ValueError(name)
slots.append(dict(name=name,table=hex(table),slot=hex(slot),target=hex(target),
file_offset=hex(pe.offset(table+slot-pe.base))))
gam_path=find_case(original,'gam/level1b.gam')
level=gam.parse(gam_path.read_bytes())
by={}
for index,e in enumerate(level.entities):
by.setdefault(str(e.values().get('ObjectTag','')).casefold(),(index,e))
route=[]
pending=['teleportexplanation','neutron1a'];seen=set()
while pending:
tag=pending.pop(0).casefold()
if tag in seen or tag in ('none','default'):continue
seen.add(tag)
index,e=by[tag];v=e.values()
route.append(dict(index=index,kind=e.kind,offset=hex(e.offset),fields={k:x for k,x in v.items()
if k in FIELDS or k.startswith(('ActivateState','ActivateObject','CameraTarget','TargetAnim'))}))
pending.extend(str(x) for k,x in v.items() if k=='NextTrigger' or k.startswith('ActivateObject'))
result=dict(source_sha256=EXE_SHA256,rea_evidence_id=REA_ID,calls=calls,sites=sites,slots=slots,
ranges=[dict(va=hex(a),file_offset=hex(pe.offset(a-pe.base)),length=b-a,
sha256=hashlib.sha256(read_va(pe,a,b-a)).hexdigest()) for a,b in RANGES],
gam_sha256=hashlib.sha256(gam_path.read_bytes()).hexdigest(),route=route,
scope='Static source and data partial order; no runtime chain, full registry or causal fix proven.')
if rea:
record=next(r for r in json.loads(Path(rea).read_text())['records'] if r['evidence_id']==REA_ID)
if record['subject']['digest']['sha256']!=EXE_SHA256:raise ValueError('REA identity mismatch')
rows=[]
for line in record['raw_result']['stdout'].splitlines():
m=re.match(r'\s*([0-9a-f]+):',line)
if m:rows.append((int(m[1],16),line))
result['rea_extracts']={hex(a):'\n'.join(l for va,l in rows if a<=va<b)+'\n' for a,b in RANGES}
return result
if __name__=='__main__':
cli=argparse.ArgumentParser(description=__doc__)
cli.add_argument('original',type=Path)
cli.add_argument('--rea-disassembly',type=Path)
args=cli.parse_args()
print(json.dumps(collect(args.original,args.rea_disassembly),indent=2))
+111
View File
@@ -0,0 +1,111 @@
#!/usr/bin/env python3
"""Read-only guards for cutscene completion and the first resumed Jimmy input.
This inventories exact original boundaries. It does not project a hypothetical
state reset or certify the original whole-frame schedule.
"""
import argparse
import hashlib
import json
from pathlib import Path
import re
import struct
from checkpoint_script_state import EXE_SHA256, find_case, read_va
from pe_inspect import PE
REA_ID = 'ev_0d64cc58fa8f5573fc8e61e0f2c20e36288099212bd2257d3a3121361fd6c904'
RANGES = (
('control pointer setter', 0x475a40, 0x475a4c),
('DEFAULT Jimmy control and camera restore', 0x447d34, 0x447fc5),
('MCA completion', 0x4311f0, 0x43127f),
('Jimmy script cleanup', 0x42ae00, 0x42ae29),
('gadget cleanup prelude', 0x427ff0, 0x428037),
('gadget cleanup common epilogue and dispatch table', 0x42882f, 0x428864),
('menu selection callback', 0x405fb0, 0x4061a0),
('menu resource close', 0x406590, 0x406645),
('Jimmy active input guards', 0x426030, 0x4260a6),
('movement input dispatch', 0x438a60, 0x438ba2),
('player raw identity and movement dispatch', 0x437a15, 0x437c33),
('neutral keyboard air-turn recovery', 0x439989, 0x439a69),
('ordinary air target publication', 0x439db7, 0x439e33),
)
SITES = (
('control pointer store', 0x475a44, 'a3e4995000'),
('DEFAULT control grant', 0x447e27, 'ff9018010000'),
('MCA named control grant', 0x431222, 'ff9218010000'),
('cleanup unsigned raw-mode rejection', 0x428027, '83f8070f87ff070000'),
('cleanup common selected-gadget reset', 0x428832, '66c70588054f00ffff'),
('input-global suppression', 0x426062, 'a030844f00'),
('input-actor suppression', 0x42606f, '8a862d1d0000'),
('camera-bump dispatch gate', 0x438ab3, 'd986c8070000'),
('input dispatch reads stored movement mode', 0x438b1e, '0fbf8604070000'),
('air input dispatch', 0x438b76, 'ff9228010000'),
('grounded mode reset', 0x437ba5, '66899e04070000'),
('grounded turn reset', 0x437bac, '899e14060000'),
)
SLOTS = (
('Jimmy ground input', 0x4a3bdc, 0x124, 0x438bc0),
('Jimmy air input', 0x4a3bdc, 0x128, 0x439900),
('Jimmy alternate input', 0x4a3bdc, 0x12c, 0x43a120),
('Jimmy ground apply', 0x4a3bdc, 0x130, 0x437c40),
('Jimmy air apply', 0x4a3bdc, 0x134, 0x437f90),
('Jimmy landing helper', 0x4a3bdc, 0x140, 0x429910),
('Jimmy active input callback', 0x4a373c, 0x3cc, 0x426030),
('Jimmy frame callback', 0x4a373c, 0x3c4, 0x424600),
('Jimmy cleanup', 0x4a373c, 0x438, 0x42ae00),
('Lab control setter', 0x4c3cd0, 0x118, 0x475a40),
('VR04 control setter', 0x4ce910, 0x118, 0x475a40),
('Outside control setter', 0x4c5a80, 0x118, 0x475a40),
)
def collect(original, rea=None):
pe = PE(find_case(Path(original), 'Neutron.exe'))
if hashlib.sha256(pe.data).hexdigest() != EXE_SHA256:
raise ValueError('Unexpected original executable')
sites = []
for name, va, expected in SITES:
actual = read_va(pe, va, len(bytes.fromhex(expected))).hex()
if actual != expected:
raise ValueError(f'Changed {name} at {va:#x}: {actual}')
sites.append(dict(name=name, va=hex(va), file_offset=hex(pe.offset(va-pe.base)), bytes=actual))
slots = []
for name, table, slot, expected in SLOTS:
actual, = struct.unpack('<I', read_va(pe, table+slot, 4))
if actual != expected:
raise ValueError(f'Changed {name} binding')
slots.append(dict(name=name, table=hex(table), slot=hex(slot), target=hex(actual),
file_offset=hex(pe.offset(table+slot-pe.base))))
dispatch, = struct.unpack('<I', read_va(pe, 0x428844 + 3*4, 4))
if dispatch != 0x42882f:
raise ValueError('Jetpack cleanup no longer targets common epilogue')
result = dict(source_sha256=EXE_SHA256, rea_evidence_id=REA_ID, sites=sites, slots=slots,
raw3_cleanup_target=hex(dispatch),
ranges=[dict(name=name, va=hex(a), file_offset=hex(pe.offset(a-pe.base)), length=b-a,
sha256=hashlib.sha256(read_va(pe, a, b-a)).hexdigest())
for name, a, b in RANGES],
scope='Static exact boundaries; no original completion-frame execution or proven remedy for post-cutscene tilt.')
if rea:
records = json.loads(Path(rea).read_text())['records']
record = next(r for r in records if r['evidence_id'] == REA_ID)
if record['subject']['digest']['sha256'] != EXE_SHA256:
raise ValueError('Retained REA subject mismatch')
rows = []
for line in record['raw_result']['stdout'].splitlines():
match = re.match(r'\s*([0-9a-f]+):', line)
if match:
rows.append((int(match[1], 16), line))
result['rea_extracts'] = {name: '\n'.join(line for va, line in rows if a <= va < b) + '\n'
for name, a, b in RANGES}
if any(not value.strip() for value in result['rea_extracts'].values()):
raise ValueError('Retained REA lacks an inspected boundary')
return result
if __name__ == '__main__':
cli = argparse.ArgumentParser(description=__doc__)
cli.add_argument('original', type=Path)
cli.add_argument('--rea-disassembly', type=Path)
args = cli.parse_args()
print(json.dumps(collect(args.original, args.rea_disassembly), indent=2))
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
</PropertyGroup>
<ItemGroup>
<Compile Include="Program.cs"/>
<Compile Include="../../../src/GamePort/Assets/*.cs"/>
<Compile Include="../../../src/GamePort/Game/*.cs"/>
</ItemGroup>
</Project>
@@ -0,0 +1,104 @@
// Diagnostic composition of the existing port. No original code execution or
// production state-policy change; snapshots expose the first returning writer.
using System.Buffers.Binary;
using System.Numerics;
using System.Text;
using System.Text.Json;
using GamePort.Assets;
using GamePort.Game;
var originals = Path.GetFullPath(args.Length > 0 ? args[0] : "../Original");
var output = Path.GetFullPath(args.Length > 1 ? args[1] : "artifacts/jimmy-cutscene-return/port-trace/observations.json");
var level = GamLevel.Load(AssetPath.Resolve(originals,"gam/level1b.gam"));
var save = OriginalSave.Load(AssetPath.Resolve(originals,"NewGame.tsk"));
var cases = new List<object>();
foreach (var camera in new[]{"CAM", "CarlMCA"})
foreach (var inputAfterPlayer in new[]{false,true})
foreach (var left in new[]{false,true})
foreach (var finish in new[]{"natural","skip","default"})
foreach (var heldDuringScene in new[]{false,true})
{
var scene = camera == "CarlMCA"
? new SceneDirector(level,new TaskStates(save.Tasks),(_,_)=>2)
: new SceneDirector(new("LV1B", [Entity("3JIM","JIM1"),
Entity("3CAM","camera",("PlayerControlled","NULL"),("CameraTarget","JIM1"),
("SoundDatabase","voice"),("SoundIndex",1),("NextTrigger","default"))]),new TaskStates([]),(_,_)=>2);
var body=FlatBody();
body.InputAfterPlayerUpdate=inputAfterPlayer;
using var binding=new PlayerSceneBinding(scene,body,new SceneInventory(new int[19]),"JIM1");
var rows=new List<object>();
var phase="entry";
var tick=0;
var recordInput=false;
body.InputActions+=_=>{if(recordInput)Snapshot("input-published");};
var jumpInput=new PlayerInput(true,false,left,!left,true);
for(var i=0;i<8;i++)binding.Step(jumpInput);
if(body.Grounded || !body.FacingDirty || body.TurnRate==0)
throw new InvalidOperationException("Trace did not establish a banked jump");
Snapshot("before-trigger");
scene.Trigger(camera=="CarlMCA"?"neutron1a":"camera");
Snapshot("after-trigger");
phase="locked";
if(finish=="natural")
{
for(tick=0;tick<5000 && (!scene.Controlled || scene.Playing);tick++)
{
binding.Step(heldDuringScene?jumpInput:default);
scene.Step(FixedStepClock.Step);
if(tick==0 || tick==59 || scene.Controlled)Snapshot("after-step");
}
if(tick==5000)throw new InvalidOperationException("Natural camera chain did not complete");
}
else
{
for(tick=0;tick<180;tick++)binding.Step(heldDuringScene?jumpInput:default);
Snapshot("before-finish");
if(finish=="skip")scene.Skip();else scene.Trigger("default");
}
Snapshot("after-finish");
if(!body.Grounded || !scene.Controlled)
throw new InvalidOperationException("Trace must return idle after grounding during the camera");
phase="neutral-resumption";
recordInput=true;
for(tick=1;tick<=300;tick++)
{
if(tick>3)recordInput=false;
binding.Step(default);
if(tick<=3 || tick==30 || tick==300)Snapshot("after-step");
}
cases.Add(new {camera,inputAfterPlayer,left,finish,heldDuringScene,rows,
finalCurrent=Vector(body.Rotation),finalTarget=Vector(body.FacingTarget)});
void Snapshot(string boundary)=>rows.Add(new {phase,tick,boundary,
current=Vector(body.Rotation),target=Vector(body.FacingTarget),dirty=body.FacingDirty,
mode=body.CaptureLevelState(-1)!.MovementMode,turn=body.TurnRate,speed=body.Speed,
grounded=body.Grounded,control=scene.AuthoredControlledTag,script=scene.CurrentTag,
playing=scene.Playing,controller=body.ControllerSteps,physics=body.PhysicsSteps,
root=Vector(body.ActorRoot)});
}
Directory.CreateDirectory(Path.GetDirectoryName(output)!);
File.WriteAllText(output,JsonSerializer.Serialize(new {
scope="Existing-port managed diagnostic; synthetic flat-floor body, actual original Carl GAM chain or synthetic CAM and 2-second sound clock. No original execution, GPU or gameplay modification.",
cases},new JsonSerializerOptions{WriteIndented=true}));
Console.WriteLine($"Recorded {cases.Count} port-only handoff cases: {output}");
static float[] Vector(Vector3 v)=>[v.X,v.Y,v.Z];
static LabSimulation FlatBody()
{
var points=new[]{new Vector3(-10000,0,-10000),new(-10000,0,10000),new(10000,0,10000),new(10000,0,-10000)};
var floor=new Mesh(points.Select(p=>new MeshVertex(p,Vector2.Zero,Vector3.One)).ToArray(),[0,1,2,0,2,3]);
var standing=new Mesh([new(new(-20,-20,-20),Vector2.Zero,Vector3.One),new(new(20,80,20),Vector2.Zero,Vector3.One)],[]);
return new(new SceneCollision(floor),standing,new(0,25,0),0);
}
static GamEntity Entity(string kind,string tag,params (string Name,object Value)[] values)
{
var properties=new Dictionary<string,GamProperty>();
foreach(var(name,value) in values.Prepend(("ObjectTag",(object)tag)))
{
uint type;byte[] raw;
if(value is string text){type=1;raw=Encoding.Latin1.GetBytes(text);}
else{raw=new byte[4];type=value is float?3u:6u;BinaryPrimitives.WriteInt32BigEndian(raw,value is float f?BitConverter.SingleToInt32Bits(f):(int)value);}
properties[name]=new(name,type,raw);
}
return new(kind,0,properties,new byte[4]);
}