Recover dynamic box shared-context ownership and kernel winding

This commit is contained in:
UnixNight committed 2026-11-07 00:20:22 -05:00
1 parent 346d350176
commit 135ff3642a
18 files changed
+640 -1

No files matched your search

+6
View File
@@ -62,6 +62,12 @@ vr04-generated-bodies.md cover72 records/13 classes,12 original component cases
and21 helper edges. Runtime/packages remain924ad2f. Common append is not deduped; and21 helper edges. Runtime/packages remain924ad2f. Common append is not deduped;
Jimmy49E guards the whole bridge. Per-node Init/PostLoad visits new registry tails. Jimmy49E guards the whole bridge. Per-node Init/PostLoad visits new registry tails.
Full retained helper membership/cleanup/activation and shared reclip remain open. Full retained helper membership/cleanup/activation and shared reclip remain open.
Dynamic continuation: docs/checkpoint/dynamic-context.md adds17 complete original/
C# test-only reclip cases and12 captured kernel arguments. Kernel winding is A,C,B
relative to construction; preserve retained hit/last polygon and final local-root
publication. Jeep default deletion eligibility is guarded, full cleanup remains
open. Next nonempty shared static reclip/ordered bodies and real callbacks;
no live pair admission or package change.345 Python checks and539 originals pass.
2026-11-06 continuation: the earlier292 original component cases plus50 derived- 2026-11-06 continuation: the earlier292 original component cases plus50 derived-
caller cases and body/visual-sync audit supply no extra reset. Startup diagnostics caller cases and body/visual-sync audit supply no extra reset. Startup diagnostics
+15
View File
@@ -128,3 +128,18 @@ actual lab bars closed/open passage using the existing provisional swept-sphere
SceneCollision adapter. The latter verifies port integration, not original47BD80 SceneCollision adapter. The latter verifies port integration, not original47BD80
or original runtime behavior. Full edge/vertex sphere response, static reclipping, or original runtime behavior. Full edge/vertex sphere response, static reclipping,
door pushing/crushing and native original comparison remain unresolved. door pushing/crushing and native original comparison remain unresolved.
## Shared response continuation — 2026-11-07
[Dynamic context](../checkpoint/dynamic-context.md) now supplies17 complete
original mode2/static-reclip observations and a test-only C# composition. Twelve
captured kernel calls establish A,C,B argument winding relative to the construction
topology above, with the construction normal retained. Do not reverse live
construction topology indiscriminately. The injected live adapter is unchanged.
The original retains hit/last polygon, can invoke a stale static callback after
the dynamic hit, and publishes its local root after callbacks unless inhibited.
Empty-grid tests close that finite ownership contract, not nonempty shared-world
behavior, real actor responses or broad live admission. The source kernel itself
has since been recovered in collision-response/body reports; the older unresolved
wording above describes this report's original implementation checkpoint.
+9
View File
@@ -1,5 +1,14 @@
# Core architecture coverage map # Core architecture coverage map
2026-11-07: [dynamic/shared context](dynamic-context.md) adds17 complete original/
C# test-composition cases and12 captured kernel argument matches (S/P/M).
Hit/last-polygon retention, old static callback and final local-root publication
are recovered under empty-grid/non-reentrant fixtures. Original kernel A,C,B
arguments differ from construction topology; final position alone hid that error.
Jeep's default deletion predicate is guarded; full active cleanup remains open.
Live collision, nonempty shared reclip, real actor callbacks and retained helper
order remain gated. No new R/whole-original/native Windows coverage is claimed.
2026-11-06 TSK-entry correction: [menu/player lifetime](../gameplay/main-menu-player-lifetime.md) 2026-11-06 TSK-entry correction: [menu/player lifetime](../gameplay/main-menu-player-lifetime.md)
establishes backgroundJimmy construction and reuse before the first playable establishes backgroundJimmy construction and reuse before the first playable
story scene. Input is now after Jimmy for that TSK path, while direct fresh-GAM story scene. Input is now after Jimmy for that TSK path, while direct fresh-GAM
+151
View File
@@ -0,0 +1,151 @@
# Dynamic box response and shared static context
2026-11-07. Continues [pair lifecycle](pair-lifecycle.md) and
[physical registration](physical-registration.md). This checkpoint executes the
complete original mode2 box query and composes existing C# source kernels in a
**test fixture**, without admitting dynamic pairs to live gameplay.
## Evidence and scope
Canonical Neutron.exe SHA-256:
`f5281076e1a2492f2d61f87aae3f4544b6d0f535ebe33f9fbb6f78710fe1aea8`.
REA instruction Evidence:
`ev_0d64cc58fa8f5573fc8e61e0f2c20e36288099212bd2257d3a3121361fd6c904`.
New REA/Ghidra mode2 pseudocode:
`ev_76827fca086933b7c48a9036a5a4a0a0f86d714935de6373eca4a3530fd231c5`.
Jeep PostLoad4217D0:
`ev_72e727e980c8ad114b46c1f23905088233e2925ff8bf8a9420d3b81bddccda27`.
The request for teardown46DFF0 remains an unrecognized-procedure error; no full
cleanup decompilation or execution is claimed. Complete replies, export and
closed-session snapshot are local under `artifacts/dynamic-context/rea/`.
`tools/binary/dynamic_context.py` guards11 copied bodies and102 relocated
operands, including the complete47A5E0..47B3DC query/switch-table span
(file7A5E0, lengthDFC, SHA-256
`9bb2c187d12f73a73f4ac2f31e19072d9010f919ce93fb6884e2be35b2fac894`).
It uses the prior dispatcher/kernel mapper and a copied original OMT2.dll.
Actor getters, contact callbacks, root setter and box point transform are
synthetic. The source static grid is empty, with a deliberately seeded old
polygon. This is original component execution under isolated Wine32, not an
original scene, live Jimmy callback or native Windows observation.
## Recovered call order and ownership
Text file offsets below equal VA−400000; the tools verify actual PE mapping.
The box query is reached from ordered pair47A430. Its other actor geometry gate,
source radius broadphase and other-mode2 shortcut precede triangle processing.
Those early paths preserve the seeded nearest/hit/last-polygon context.
| Original VA / file offset | Recovered operation |
|---|---|
|47AB3F / 7AB3F|Write sphere radius to edge limit5CFBE0.|
|47AB4B / 7AB4B|Set nearest face695D5C to−1. Do not clear hit5CFBE8 or last polygon695D4C.|
|47B277 / 7B277|Call47BD80 for each of12 transformed box triangles, updating the shared nearest state and local candidate.|
|47B29B / 7B29B|Each accepted kernel result invokes sphere virtual374 with a **null polygon**. This is not a normal-Y choice between370/374.|
|47B2EF / 7B2EF|Read box virtual1E0 after triangle callbacks. If inhibited, return contact without world reclip or sphere root setter.|
|47B364 / 7B364|Call47B4B0 from source previous root with candidate−previous displacement; edge checking is disabled. Reuse current hit/nearest/last state.|
|47B399 / 7B399|Publish the clipped local candidate through sphere314 after the static callback; there is no live-root comparison before publication.|
After all triangles, face−1 and edge>=radius means no contact. An accepted
query resets the nearest limits even when it misses, while old hit and last
polygon survive. The chained fixture verifies this across two successive calls.
Its callback/setter/pass counters are cumulative, not reset for the second call.
With an empty grid,47B4B0 can still issue its terminal callback for the seeded
old polygon, including when static geometry4F69E5 is disabled. An uninhibited
dynamic hit therefore gives a null-polygon dynamic callback followed by an
old-polygon static callback. A callback's live-root mutation is overwritten by
the final local candidate; inhibition leaves that mutation intact, including W2.
Do not replace this with a root-changed suppression rule.
The global primitive mode695D74 is a separate owner.47B6F4 sets it to1 around
an individual static primitive when sphere42C is set, then47B742 clears it.
Our empty-grid fixture starts and ends with mode0, including42C=true. That case
does not establish general mode reset, recursive queries or arbitrary callback
mutations. Parent static-body479D20 normally initializes its own query state;
the later dynamic phase can see another body's last polygon. Explicit seeding
tests state retention, not which real actor supplied it in a complete frame.
## Kernel winding: a meaningful failed comparison
The first C# composition used `DynamicSceneCollision.Triangles` construction
order directly. Its first fixture reached the same root(0,0,20,1), but reported
face−1/edge5 instead of original face40/edge10. The passing interpretation uses
kernel arguments **A,C,B**, with the normal retained from construction A,B,C.
To test that interpretation, the generated private mapped kernel entry is
instrumented to record its first12 triangle/normal arguments. The hook restores
the original five bytes before invoking the actual source kernel and reinstalls
it afterward. All12 complete arguments match the C# fixture; each captured
cross(B−A,C−A) points opposite its supplied normal. The original files and copied
on-disk EXE are not patched. This validates the kernel boundary, not a blanket
change to construction topology or the provisional live collision adapter.
The intentionally wrong construction-winding run remains a failing diagnostic
(`--construction-winding`), with its first divergence and nonzero exit saved in
`artifacts/dynamic-context/construction-winding-failure.json`. Matching final
positions alone would have missed the shared-state error.
## Implemented comparison and verification
`tests/GamePort.DynamicContextTests` composes the existing source sphere and
static kernels with this bounded control flow. No production solver or gameplay
actor is added. Fixed references run without generated artifacts; `--native`
also compares every emitted field and all12 captured kernel arguments.
The17 observations cover old/null polygon, inhibition, geometry-off and
broadphase rejection, other-box overlap/rejection, triangle miss, root-mutating
callbacks with/without inhibition, static-geometry-off,42C force-static flag,
Y45 face contact, translated/90-degree box and a two-call hit→away sequence.
Each compares contact, XYZW, nearest face/edge/hit, retained polygon identity,
dynamic/static callback counts, setter count, static passes and global mode.
The Y45 case is not proof of a successful geometric edge/corner response.
Verification: all17 full native/C# observations and12 kernel arguments match;
fixed references pass;345 Python tests,11 static-dispatcher groups,10 dynamic-box
groups and28 pair lifecycle cases pass. All539 original files remain unchanged.
Both packaged DLLs and BUILD-INFO remain identical to the924ad2f baseline.
No new GPU, audible, whole-original or native Windows comparison is claimed.
Reproduction from GamePort (probe execution uses a separate copied game):
```sh
python3 tools/binary/dynamic_context.py ../Original --output artifacts/dynamic-context/native
i686-w64-mingw32-gcc -O0 -Wall -Wextra -Wno-unused-function -o artifacts/dynamic-context/native/probe.exe artifacts/dynamic-context/native/dynamic_context_probe.c
python3 tools/recon/reference_capture.py --asset-probe --probe-executable artifacts/dynamic-context/native/probe.exe --probe-success DYNAMIC_CONTEXT_COMPLETE --seconds 12 --output artifacts/dynamic-context/probe
python3 tools/binary/dynamic_context.py ../Original --output artifacts/dynamic-context/native --capture artifacts/dynamic-context/probe
source scripts/env.sh
dotnet run --project tests/GamePort.DynamicContextTests -- --native artifacts/dynamic-context/native/observations.json
```
## Helper teardown follow-up
`tools/binary/helper_teardown.py` guards13 sites and5 Jeep bindings at table
4A2AEC (fileA2AEC). Constructor42129A (file2129A) pushes1, and4212A8 calls
470F40: authored predicate+11 is stored and dispatched through204 to live+139.
Generic Init4705B3/4705BC restores the authored predicate through8C→204.
Table slots8C/200/204 target470F30/4719B0/4719C0. Default Jeep is therefore
eligible for ordinary deletion, unlike the retained Jimmy default; pointer
clearing in Jimmy PostLoad is not itself evidence of a retained old Jeep.
Teardown re-reads200 at46E032,46E06F and46E0AC (files6E032/6E06F/6E0AC),
with virtual20/34 cleanup between reads, then marks+6 at46E0CA before the
473710 sweep. Jeep20 targets4213E0→462390;34 targets458C50, whose game+4B0
condition can invoke430. Callback/active-vehicle mutations can affect those
re-reads. This closes the **default eligibility** question, not complete active
cleanup, child deletion, sweep execution or final retained registry order.
## Remaining admission gates and next chunk
1. Exercise static geometry after a dynamic hit, rather than only empty-grid
reclip. Compare shared nearest/last ownership across two real primitive
candidates and ordered bodies, including face/edge ties and flag transitions.
2. Trace actual Jimmy/door/VR04 actor callbacks and their root, mode, activation
and polygon requirements. Synthetic callbacks do not establish these owners.
3. Finish constructor-only helper re-entry/deletion and physical order across
ordinary LOAD/RETURN, including cleanup mutations between the three reads.
Then implement a bounded shared-context response component and integrate only
the evidenced VR04 actor set. Keep lab/outside capsule and current playable
movement while these gates remain. Preserve ordinary landing bank; this report
adds no rotation reset and does not reopen the completed TSK-entry order fix.
+8
View File
@@ -35,6 +35,14 @@ fresh/retained helper membership. See [registration](physical-registration.md).
Next resolve helper re-entry/deletion/activation and dynamic shared reclip state; Next resolve helper re-entry/deletion/activation and dynamic shared reclip state;
keep live scene admission unchanged until those dependencies close. keep live scene admission unchanged until those dependencies close.
2026-11-07 continuation: [dynamic context](dynamic-context.md) executes17 original
mode2/reclip cases and captures12 kernel triangle/normal arguments. Test-only C#
composition matches complete snapshots, including retained old polygon and
callback publication. Jeep default deletion eligibility is guarded, while cleanup
mutations/children/order remain open. Next extend to nonempty static reclip and
ordered-body context, then real actor callbacks and retained helper cleanup.
Keep the current live solver and924ad2f packages while those gates remain.
## Objective ## Objective
Establish the original ownership and timing of player state across gameplay, Establish the original ownership and timing of player state across gameplay,
+7
View File
@@ -66,6 +66,13 @@ then calls the wheel-construction hook; existing Scooter documentation covers it
four wheel objects. Old Jeep teardown/deletion and complete retained ordering four wheel objects. Old Jeep teardown/deletion and complete retained ordering
remain open; no leak or new carry/reset policy is inferred. remain open; no leak or new carry/reset policy is inferred.
2026-11-07 [teardown follow-up](dynamic-context.md#helper-teardown-follow-up):
Jeep constructor42129A pushes1 into470F40, storing authored+11 and live+139;
Init restores that value. Default Jeep is eligible for ordinary deletion.
Thirteen guarded sites/five bindings also establish three live-predicate reads
around cleanup20/34. This narrows default eligibility, while active callback
mutations, child cleanup, deletion sweep and final retained order remain open.
## Implementation consequence ## Implementation consequence
The live port reconstructs selected actors and bounded body records per scene. The live port reconstructs selected actors and bounded body records per scene.
+12
View File
@@ -1,5 +1,17 @@
# Compatibility and validation # Compatibility and validation
2026-11-07 dynamic-context checkpoint:17 copied-original mode2/static reclip
observations match the C# test composition in full, including XYZW, shared
nearest/hit/old polygon, callback/setter/pass counts and mode. All12 instrumented
kernel triangle/normal arguments also match. A retained diagnostic intentionally
fails with construction winding despite the same final position. The source
static grid is empty, transforms/callbacks are synthetic and mode starts0;
nonempty/reentrant/live actor behavior is not established. All345 Python tests,
17 fixed context cases,11 static groups,10 dynamic groups and28 pair cases pass.
539 originals and both924ad2f packaged DLLs/BUILD-INFO are unchanged. No runtime
code, package refresh, new GPU run or native Windows execution is claimed.
See [shared context and helper follow-up](checkpoint/dynamic-context.md).
2026-11-06 physical-registration continuation:12 copied-code registration/loader 2026-11-06 physical-registration continuation:12 copied-code registration/loader
cases pass with complete emitted callback/order/count/flag/transform checks. cases pass with complete emitted callback/order/count/flag/transform checks.
All72 VR04 records/13 class interfaces are inventoried, with a bounded catalogue All72 VR04 records/13 class interfaces are inventoried, with a bounded catalogue
+9
View File
@@ -403,3 +403,12 @@ assets and generated packages stay excluded.
neither visibility nor an exposed InitPhysics method establishes membership. neither visibility nor an exposed InitPhysics method establishes membership.
Do not synthesize a full live body count or retained re-entry from the72-record Do not synthesize a full live body count or retained re-entry from the72-record
serialized partition. See checkpoint/physical-registration.md. serialized partition. See checkpoint/physical-registration.md.
57. **Preserve shared context and validate kernel arguments before live admission.**
Full47A5E0 execution retains old hit/last polygon and can issue its static
callback after a dynamic hit. Final local-root publication overwrites callback
changes unless inhibited. Seventeen complete comparisons pass in a test-only
composition. Kernel A,C,B/retained construction normal is confirmed by all12
captured arguments; a same-position match with wrong nearest state was rejected.
Keep source topology and kernel boundary distinct. Empty-grid/synthetic actor
results do not admit live scene collision. Guard default Jeep deletion while
leaving cleanup-mutated active lifetime open. See checkpoint/dynamic-context.md.
+21 -1
View File
@@ -1,4 +1,4 @@
# Progress — 2026-11-06 # Progress — 2026-11-07
Workflow update: the user authorizes pushing completed, verified commits to the Workflow update: the user authorizes pushing completed, verified commits to the
existing `Gitea/main` upstream from now on. See docs/decisions.md and AGENTS.md. existing `Gitea/main` upstream from now on. See docs/decisions.md and AGENTS.md.
@@ -7,6 +7,26 @@ Next-work plan: [recover interactions, then implement verified changes](checkpoi
It defines the Carl source/differential gate, the bounded implementation step, It defines the Carl source/differential gate, the bounded implementation step,
movement/contact/animation recovery and the end-to-end platform checkpoint. movement/contact/animation recovery and the end-to-end platform checkpoint.
## Dynamic response and shared context
[Dynamic context](checkpoint/dynamic-context.md) adds17 complete original/C#
component comparisons and12 captured kernel triangle/normal argument matches.
The original box query retains old hit/last-polygon state, can issue an old
static callback after a dynamic hit, and overwrites callback root mutations at
final publication unless box response is inhibited. A same-position/wrong-state
comparison exposed kernel A,C,B winding relative to construction A,B,C; captured
arguments confirm it. The composition is test-only, not live scene collision.
The helper follow-up guards13 sites/5 Jeep bindings: default Jeep is eligible
for ordinary deletion, with three live-predicate reads around cleanup hooks.
Active cleanup, child lifetime and retained physical ordering remain open.
Two new REA pseudocode results and complete instruction Evidence support this
chunk;46DFF0 remains an unrecognized-procedure error. All345 Python checks,
17 context,11 static,10 dynamic and28 pair cases/groups pass;539 originals and
both924ad2f packages remain unchanged. No new platform runtime claim is made.
Next: nonempty static reclip/ordered-body context, real actor callbacks, and
retained helper cleanup before bounded live admission.
## VR04 registration and generated-helper continuation ## VR04 registration and generated-helper continuation
[Physical registration](checkpoint/physical-registration.md) now covers all72 [Physical registration](checkpoint/physical-registration.md) now covers all72
+6
View File
@@ -5,6 +5,12 @@ offsets, virtual addresses, API symbols or observed behavior. Decompiled output
evidence, not original source. Original gameplay has not yet been observed successfully; isolated original DLL evidence, not original source. Original gameplay has not yet been observed successfully; isolated original DLL
probes and modern runtime checks are recorded separately. probes and modern runtime checks are recorded separately.
- [Dynamic box/shared context](checkpoint/dynamic-context.md): full47A5E0 plus
static reclip/kernel execution,17 complete C# composition comparisons and12
captured kernel triangle/normal arguments. Nearest reset, retained hit/last
polygon, callback effects and publication are bounded source/component facts.
Jeep default deletion eligibility has13 guarded sites/5 bindings; complete
cleanup and live actor/shared-world integration remain open.
- [Physical registration](checkpoint/physical-registration.md) and - [Physical registration](checkpoint/physical-registration.md) and
[generated helpers](checkpoint/vr04-generated-bodies.md): all72 VR04 serialized [generated helpers](checkpoint/vr04-generated-bodies.md): all72 VR04 serialized
records/13 RTTI interfaces;12 original registration/loader cases;21 helper records/13 RTTI interfaces;12 original registration/loader cases;21 helper
+7
View File
@@ -81,6 +81,13 @@ Execution order and acceptance criteria: [next work plan](checkpoint/next-work-p
owner-driven fire/Baseball re-entry from constructor-only or conditional helpers. owner-driven fire/Baseball re-entry from constructor-only or conditional helpers.
Full live body counts and retained helper cleanup remain open. See Full live body counts and retained helper cleanup remain open. See
checkpoint/physical-registration.md and vr04-generated-bodies.md. checkpoint/physical-registration.md and vr04-generated-bodies.md.
- [x] Execute complete dynamic-box query/shared static reclip in17 bounded
original cases; match full C# snapshots and12 captured kernel arguments.
Preserve old polygon/hit, post-callback publication and kernel winding.
Guard Jeep default teardown eligibility separately from full cleanup. See
checkpoint/dynamic-context.md; no live pair admission is enabled.
- [ ] Extend dynamic reclip to nonempty static geometry/ordered bodies, real
actor callbacks and cleanup-mutated helper lifetime before live integration.
- [x] Expand original lifecycle coverage:96 Carl contact,8 composed input/ - [x] Expand original lifecycle coverage:96 Carl contact,8 composed input/
controller/skip-prefix,48 task/objective and140 base/STOP cases; recover complete controller/skip-prefix,48 task/objective and140 base/STOP cases; recover complete
+1
View File
@@ -19,6 +19,7 @@ dotnet run --project tests/GamePort.StaticCollisionTests
dotnet run --project tests/GamePort.BodyPhysicsTests dotnet run --project tests/GamePort.BodyPhysicsTests
dotnet run --project tests/GamePort.BodyOwnershipTests dotnet run --project tests/GamePort.BodyOwnershipTests
dotnet run --project tests/GamePort.PairLifecycleTests dotnet run --project tests/GamePort.PairLifecycleTests
dotnet run --project tests/GamePort.DynamicContextTests
dotnet run --project tests/GamePort.GadgetTests dotnet run --project tests/GamePort.GadgetTests
dotnet run --project tests/GamePort.InvisibleTests dotnet run --project tests/GamePort.InvisibleTests
dotnet run --project tests/GamePort.BubbleMotionTests dotnet run --project tests/GamePort.BubbleMotionTests
@@ -0,0 +1,10 @@
<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,144 @@
using System.Numerics;
using System.Text.Json;
using GamePort.Game;
//Test composition of recovered47A5E0 ownership over existing source kernels.
//Not wired into gameplay: actors/getters/transform are fixtures; point roots W1,
//empty static grid and non-reentrant normal callbacks bound this comparison.
var fixture=new Fixture(args is ["--construction-winding"]);var rows=new List<Observation>();
void Query(string name)=>rows.Add(fixture.Query(name));
fixture.Reset();Query("face_stale_polygon");
fixture.Reset();fixture.Context.LastPolygon=null;Query("face_no_polygon");
fixture.Reset();fixture.Inhibit=true;Query("inhibited");
fixture.Reset();fixture.Geometry=false;Query("geometry_off");
fixture.Reset();fixture.Root.Z=200;Query("broadphase_reject");
fixture.Reset();fixture.Mode=2;Query("other_box_overlap");
fixture.Reset();fixture.Mode=2;fixture.Root.Z=51;Query("other_box_reject");
fixture.Reset();fixture.Previous.Z=100;fixture.Root.Z=80;Query("no_triangle_hit");
fixture.Reset();fixture.Mutate=true;Query("callback_root_overwritten");
fixture.Reset();fixture.Mutate=fixture.Inhibit=true;Query("inhibited_callback_root_survives");
fixture.Reset();fixture.StaticGeometry=false;Query("static_geometry_off_stale_polygon");
fixture.Reset();fixture.ForceStatic=true;Query("forced_static_mode");
fixture.Reset();fixture.Root.Y=fixture.Previous.Y=45;Query("near_top_edge");
fixture.Reset();fixture.BoxRoot.X=fixture.Root.X=fixture.Previous.X=100;Query("translated_box");
fixture.Reset();fixture.Rotate=true;fixture.Root=new(15,0,0,1);fixture.Previous=new(50,0,0);Query("rotated_box");
fixture.Reset();Query("chain_first");fixture.Previous=new(fixture.Root.X,fixture.Root.Y,fixture.Root.Z);fixture.Root.Z=25;Query("chain_away");
//Fixed finite original observations; no generated trace is needed for normal tests.
string[] references=[
"1|0,0,20,1|40|10|0,0,10,1|1|1|1|1|1|0",
"1|0,0,20,1|40|10|0,0,10,1|0|1|0|1|1|0",
"1|0,0,15,1|40|10|0,0,10,1|1|1|0|0|0|0",
"0|0,0,15,1|77|88|111,222,333,1|1|0|0|0|0|0",
"0|0,0,200,1|77|88|111,222,333,1|1|0|0|0|0|0",
"1|0,0,15,1|77|88|111,222,333,1|1|0|0|0|0|0",
"0|0,0,51,1|77|88|111,222,333,1|1|0|0|0|0|0",
"0|0,0,80,1|-1|10|111,222,333,1|1|0|0|0|0|0",
"1|0,0,20,1|40|10|0,0,10,1|1|1|1|1|1|0",
"1|777,888,999,2|40|10|0,0,10,1|1|1|0|0|0|0",
"1|0,0,20,1|40|10|0,0,10,1|1|1|1|1|1|0",
"1|0,0,20,1|40|10|0,0,10,1|1|1|1|1|1|0",
"1|0,45,20,1|40|10|0,45,10,1|1|1|1|1|1|0",
"1|100,0,20,1|40|10|100,0,10,1|1|1|1|1|1|0",
"1|20,0,0,1|40|10|10,0,0,1|1|1|1|1|1|0",
"1|0,0,20,1|40|10|0,0,10,1|1|1|1|1|1|0",
"0|0,0,25,1|-1|10|0,0,10,1|1|1|1|1|1|0"
];
for(var i=0;i<rows.Count;i++)
if(rows[i].Reference()!=references[i])throw new Exception($"{rows[i].Name}: {rows[i].Reference()} != {references[i]}");
if(args.Length==2&&args[0]=="--native")
{
using var data=JsonDocument.Parse(File.ReadAllText(args[1]));
var cases=data.RootElement.GetProperty("cases").EnumerateArray().ToArray();
if(cases.Length!=rows.Count)throw new Exception("Original case count");
for(var i=0;i<rows.Count;i++)
{
var actual=JsonSerializer.SerializeToElement(rows[i],new JsonSerializerOptions{PropertyNamingPolicy=JsonNamingPolicy.CamelCase});
foreach(var property in cases[i].EnumerateObject())
if(!actual.TryGetProperty(property.Name,out var value)||!JsonElement.DeepEquals(value,property.Value))
throw new Exception($"{rows[i].Name}: original {property.Name} differs");
}
var arguments=JsonSerializer.SerializeToElement(fixture.KernelArguments);
if(!JsonElement.DeepEquals(arguments,data.RootElement.GetProperty("kernel_triangles")))
throw new Exception("Original12 kernel triangles/normals differ");
Console.WriteLine("Matched17 complete original dynamic/context observations and12 kernel triangle/normal arguments.");
}
else if(args.Length!=0)throw new ArgumentException("Use --native <observations.json>");
Console.WriteLine("PASS17 dynamic context/reclip compositions; live collision admission unchanged.");
sealed record Observation(string Name,int Contact,float[] Root,float Face,float Edge,float[] Hit,
int Last,int DynamicCallbacks,int StaticCallbacks,int Setters,int Passes,int Mode)
{
public string Reference()=>string.Join('|',Contact,string.Join(',',Root),Face,Edge,string.Join(',',Hit),
Last,DynamicCallbacks,StaticCallbacks,Setters,Passes,Mode);
}
sealed class Fixture(bool constructionWinding=false)
{
public Vector4 Root;
public Vector3 Previous,BoxRoot;
public bool Inhibit,Geometry,StaticGeometry,ForceStatic,Rotate,Mutate;
public int Mode;
public StaticCollisionContext Context=null!;
private readonly OriginalStaticCollision world=new([]);
private readonly CameraRayPolygon stale=new(new(new(-100,-100,0),new(-100,100,0),new(100,100,0)),Vector3.UnitZ);
private int dynamicCallbacks,staticCallbacks,setters;
public List<float[][]> KernelArguments {get;}=[];
public void Reset()
{
Root=new(0,0,15,1);Previous=new(0,0,50);BoxRoot=default;
Inhibit=ForceStatic=Rotate=Mutate=false;Geometry=StaticGeometry=true;Mode=0;
Context=new(88,77){Nearest=new(77,88,new(111,222,333)),LastPolygon=stale};
dynamicCallbacks=staticCallbacks=setters=0;
}
private void Notify(CameraRayPolygon? polygon)
{
if(polygon is null)dynamicCallbacks++;else staticCallbacks++;
if(Mutate)Root=new(777,888,999,2);
}
public Observation Query(string name)
{
var current=new Vector3(Root.X,Root.Y,Root.Z);
var transform=Rotate?new Matrix4x4(0,0,-1,0,0,1,0,0,1,0,0,0,BoxRoot.X,BoxRoot.Y,BoxRoot.Z,1)
:Matrix4x4.CreateTranslation(BoxRoot);
var box=new DynamicBoxCollider(1,BoxRoot,new(-50,-50,-10),new(50,50,10),transform,40);
var sphere=new DynamicSphereMotion(Previous,current,10,GeometryCollisionEnabled:Geometry,Mode:Mode);
bool contact=false;
if(DynamicSceneCollision.BroadPhase(box,sphere))
{
if(Mode==2)contact=true;
else
{
Context.Nearest=Context.Nearest with{FaceDistance=-1,EdgeDistance=10};
var candidate=current;
foreach(var triangle in DynamicSceneCollision.Triangles(box))
{
var cross=Vector3.Cross(triangle.B-triangle.A,triangle.C-triangle.A);
var normal=cross/OriginalBodySupport.QuickMagnitude(cross);
//47A5E0's vector argument pushes reverse the constructed
//triangle winding at the kernel boundary; normal is retained.
var kernelTriangle=constructionWinding?triangle:new SupportTriangle(triangle.A,triangle.C,triangle.B);
if(name=="face_stale_polygon")KernelArguments.Add([
[kernelTriangle.A.X,kernelTriangle.A.Y,kernelTriangle.A.Z,1],
[kernelTriangle.B.X,kernelTriangle.B.Y,kernelTriangle.B.Z,1],
[kernelTriangle.C.X,kernelTriangle.C.Y,kernelTriangle.C.Z,1],
[normal.X,normal.Y,normal.Z,0]]);
var hit=OriginalSphereResponse.Resolve(kernelTriangle,normal,Previous,candidate,10,Context.Nearest);
if(hit.Contact==SphereContact.None)continue;
candidate=hit.Position;Context.Nearest=hit.State;Notify(null);
}
contact=Context.Nearest.FaceDistance!=-1||Context.Nearest.EdgeDistance<10;
if(contact&&!Inhibit)
{
var clipped=world.Move(Previous,candidate-Previous,10,Context,edges:false,
lowerEdges:ForceStatic,geometryEnabled:StaticGeometry);
if(clipped.CallbackPolygon is{} polygon)Notify(polygon);
Root=new(clipped.Position,1);setters++;
}
}
}
var p=Context.Nearest.Hit??throw new Exception("Seeded hit lost");
return new(name,contact?1:0,[Root.X,Root.Y,Root.Z,Root.W],Context.Nearest.FaceDistance,
Context.Nearest.EdgeDistance,[p.X,p.Y,p.Z,1],Context.LastPolygon==stale?1:0,
dynamicCallbacks,staticCallbacks,setters,Context.Passes,0);
}
}
+34
View File
@@ -0,0 +1,34 @@
from pathlib import Path
import sys
import unittest
ROOT=Path(__file__).resolve().parents[1]
sys.path.insert(0,str(ROOT/'tools/binary'))
from dynamic_context import collect
from helper_teardown import collect as teardown
class DynamicContextTests(unittest.TestCase):
def test_complete_box_kernel_and_reclip_source(self):
source=collect(ROOT.parent/'Original')
self.assertEqual(len(source['bodies']),11)
self.assertEqual(len(source['probe_operands']),102)
body=source['bodies'][-1]
self.assertEqual(body['va'],'0x47a5e0')
self.assertEqual(body['file_offset'],'0x7a5e0')
self.assertEqual(body['length'],0xdfc)
def test_jump_table_relocated_alongside_instruction_operand(self):
source=collect(ROOT.parent/'Original')
sites={p['va']:p['target'] for p in source['probe_operands']}
self.assertEqual(len([va for va in sites if 0x47b3ac<=va<0x47b3dc]),12)
self.assertIn(0x47b3ac,sites.values())
def test_jeep_default_eligibility_is_independent_of_owner_pointer(self):
source=teardown(ROOT.parent/'Original')
self.assertEqual(len(source['sites']),13)
self.assertEqual(len(source['bindings']),5)
self.assertEqual(source['sites'][0]['bytes'],'6a01')
if __name__=='__main__':unittest.main()
+72
View File
@@ -0,0 +1,72 @@
#!/usr/bin/env python3
"""Guard/generate complete mode2 context and static reclip component evidence."""
import argparse,hashlib,json,struct
from pathlib import Path
from collision_dispatch import collect as dispatch_collect,POINTERS
from collision_response import header
from checkpoint_script_state import find_case,read_va
from pe_inspect import PE
START,END=0x47a5e0,0x47b3dc
DIGEST='9bb2c187d12f73a73f4ac2f31e19072d9010f919ce93fb6884e2be35b2fac894'
def collect(original):
report=dispatch_collect(original);pe=PE(find_case(Path(original),'Neutron.exe'))
body=read_va(pe,START,END-START)
if hashlib.sha256(body).hexdigest()!=DIGEST:raise ValueError('Changed mode2 routine/table')
report['bodies'].append(dict(name='mode2_box',va=hex(START),file_offset=hex(pe.offset(START-pe.base)),length=END-START,sha256=DIGEST))
jumps=struct.unpack('<12I',read_va(pe,0x47b3ac,48))
for target in sorted(set((*POINTERS,0x695d45,0x47b3ac,*jumps))):
encoded=struct.pack('<I',target)
for i in range(len(body)-3):
if body[i:i+4]==encoded:report['probe_operands'].append(dict(va=START+i,target=target))
report['probe_operands'].sort(key=lambda p:p['va'])
report['omt_sha256']=hashlib.sha256(find_case(Path(original),'OMT2.dll').read_bytes()).hexdigest()
report['scope']='Full copied mode2 box, static dispatcher and kernel; synthetic actor getters/transform/contact callbacks and grid, not full original scene.'
return report
def generate(original,output):
original,output=Path(original).resolve(),Path(output).resolve()
if output.is_relative_to(original) or original.is_relative_to(output):raise ValueError('Separate output required')
if output.exists() and any(p.is_symlink() for p in output.rglob('*')):raise ValueError('Generated output contains symlinks')
report=collect(original);output.mkdir(parents=True,exist_ok=True)
for name in ('dynamic_context_probe.c','collision_dispatch_probe.c','collision_response_probe.c'):
text=Path(__file__).with_name(name).read_text()
if name=='collision_dispatch_probe.c':text=text.split('int main(void)')[0]
(output/name).write_text(text)
(output/'collision_response_relocations.h').write_text(header(report))
(output/'source.json').write_text(json.dumps(report,indent=2)+'\n')
return dict(guarded_bodies=len(report['bodies']),relocations=len(report['probe_operands']))
def capture(output,directory):
output,directory=Path(output),Path(directory);sha=lambda p:hashlib.sha256(p.read_bytes()).hexdigest()
source=json.loads((output/'source.json').read_text());metadata=json.loads((directory/'capture.json').read_text())
log=(directory/'wine.log').read_text()
if metadata['captures'][-1]['wineExit']!=0 or 'DYNAMIC_CONTEXT_COMPLETE' not in log:raise ValueError('Incomplete component execution')
for filename,key in [('Neutron.exe','sha256'),('OMT2.dll','omt_sha256')]:
if sha(find_case(directory/'game',filename))!=source[key]:raise ValueError('Copied source mismatch')
if json.loads((directory/'probe-identity.json').read_text())['sha256']!=sha(output/'probe.exe'):raise ValueError('Probe identity mismatch')
cases=[json.loads(l[8:]) for l in log.splitlines() if l.startswith('DYNAMIC ')]
if len(cases)!=17 or len({c['name'] for c in cases})!=17:raise ValueError('Missing cases')
triangles=[json.loads(l[17:]) for l in log.splitlines() if l.startswith('KERNEL_TRIANGLES ')]
if len(triangles)!=1 or len(triangles[0])!=12:raise ValueError('Missing kernel argument capture')
for a,b,c,n in triangles[0]:
u=[b[i]-a[i] for i in range(3)];v=[c[i]-a[i] for i in range(3)]
cross=[u[1]*v[2]-u[2]*v[1],u[2]*v[0]-u[0]*v[2],u[0]*v[1]-u[1]*v[0]]
if sum(cross[i]*n[i] for i in range(3))>=0:raise ValueError('Kernel winding/normal relationship changed')
files=[directory/'wine.log',directory/'capture.json',directory/'probe-identity.json',output/'source.json',
*(output/name for name in ('dynamic_context_probe.c','collision_dispatch_probe.c',
'collision_response_probe.c','collision_response_relocations.h','probe.exe'))]
result=dict(cases=cases,kernel_triangles=triangles[0],provenance={str(p):sha(p) for p in files},scope=source['scope'])
(output/'observations.json').write_text(json.dumps(result,indent=2)+'\n')
return dict(cases=len(cases),scope=source['scope'])
if __name__=='__main__':
cli=argparse.ArgumentParser(description=__doc__);cli.add_argument('original',type=Path)
cli.add_argument('--output',type=Path);cli.add_argument('--capture',type=Path);args=cli.parse_args()
if args.capture and not args.output:cli.error('--capture requires --output')
print(json.dumps(capture(args.output,args.capture) if args.capture else generate(args.original,args.output) if args.output else collect(args.original),indent=2))
+85
View File
@@ -0,0 +1,85 @@
/* Full copied47A5E0 plus static dispatcher/kernel; synthetic actor/box transforms.
Global context is seeded deliberately. No original entry point or real actors. */
#include "collision_dispatch_probe.c"
static unsigned char box_object[0x500],sphere_object[0x500];
static uintptr_t box_table[0x440/4],sphere_table[0x440/4];
static Vec box_root,low,high,sphere_root,sphere_previous;
static float box_radius,sphere_radius;
static int geometry,other_mode,inhibit,rotate_box,mutate;
static unsigned dynamic_callbacks,static_callbacks,setters;
static Vec kernel_arguments[12][4];static unsigned kernel_calls;static unsigned char kernel_prefix[5];
static void hook_jump(void*destination,void*target){unsigned char*p=destination;*p=0xe9;int32_t d=(unsigned char*)target-p-5;memcpy(p+1,&d,4);}
static unsigned capture_kernel(Vec a,Vec b,Vec c,Vec n,Vec previous,Vec*current,float radius,int edges){
if(kernel_calls<12){kernel_arguments[kernel_calls][0]=a;kernel_arguments[kernel_calls][1]=b;kernel_arguments[kernel_calls][2]=c;kernel_arguments[kernel_calls][3]=n;}kernel_calls++;
memcpy(AT(0x47bd80),kernel_prefix,5);
unsigned result=((Kernel)AT(0x47bd80))(a,b,c,n,previous,current,radius,edges);
hook_jump(AT(0x47bd80),capture_kernel);return result;
}
static float TC get_radius(void*self){return self==box_object?box_radius:sphere_radius;}
static int TC get_geometry(void*self){(void)self;return geometry;}
static int TC get_mode(void*self){(void)self;return other_mode;}
static int TC get_inhibit(void*self){(void)self;return inhibit;}
static Vec*TC get_root(void*self,Vec*out){*out=self==box_object?box_root:sphere_root;return out;}
static Vec*TC get_previous(void*self,Vec*out){(void)self;*out=sphere_previous;return out;}
static Vec*TC get_low(void*self,Vec*out){(void)self;*out=low;return out;}
static Vec*TC get_high(void*self,Vec*out){(void)self;*out=high;return out;}
static Vec*TC point(void*self,Vec*out,float x,float y,float z){
(void)self;*out=rotate_box?(Vec){z+box_root.x,y+box_root.y,-x+box_root.z,1}:
(Vec){x+box_root.x,y+box_root.y,z+box_root.z,1};return out;
}
static void TC set_root(void*self,Vec value){require(self==sphere_object,"root setter owner");sphere_root=value;setters++;}
static void TC on_contact(void*self,Vec n,void*p){
require(self==sphere_object,"contact owner");(void)n;
if(p)static_callbacks++;else dynamic_callbacks++;
if(mutate)sphere_root=(Vec){777,888,999,2};
}
static void reset(void){
memset(box_object,0,sizeof(box_object));memset(sphere_object,0,sizeof(sphere_object));
memset(box_table,0,sizeof(box_table));memset(sphere_table,0,sizeof(sphere_table));
*(void**)box_object=box_table;*(void**)sphere_object=sphere_table;
box_table[0x260/4]=sphere_table[0x260/4]=(uintptr_t)get_radius;
box_table[0x310/4]=sphere_table[0x310/4]=(uintptr_t)get_root;
box_table[0x2e4/4]=(uintptr_t)get_low;box_table[0x2dc/4]=(uintptr_t)get_high;
box_table[0x384/4]=(uintptr_t)point;box_table[0x1e0/4]=(uintptr_t)get_inhibit;
sphere_table[0x1d0/4]=(uintptr_t)get_geometry;sphere_table[0x178/4]=(uintptr_t)get_mode;
sphere_table[0x2f8/4]=(uintptr_t)get_previous;sphere_table[0x314/4]=(uintptr_t)set_root;
sphere_table[0x374/4]=sphere_table[0x370/4]=(uintptr_t)on_contact;
box_root=(Vec){0,0,0,1};low=(Vec){-50,-50,-10,1};high=(Vec){50,50,10,1};
sphere_previous=(Vec){0,0,50,1};sphere_root=(Vec){0,0,15,1};box_radius=40;sphere_radius=10;
geometry=1;other_mode=inhibit=rotate_box=mutate=0;dynamic_callbacks=static_callbacks=setters=0;
empty_grid();*(Vec*)(polygon[0]+8)=(Vec){0,0,1,0};
*(void**)AT(0x695d4c)=polygon[0];*(float*)AT(0x695d5c)=77;*(float*)AT(0x5cfbe0)=88;
*(Vec*)AT(0x5cfbe8)=(Vec){111,222,333,1};*(unsigned*)AT(0x695d74)=0;
*(unsigned*)AT(0x695d70)=*(unsigned*)AT(0x695d78)=0;
*(unsigned char*)AT(0x4f69e5)=1;*(unsigned char*)AT(0x695d46)=*(unsigned char*)AT(0x695d45)=0;
}
static void query(const char*name){
int hit=((int(__cdecl*)(void*,void*))AT(0x47a5e0))(box_object,sphere_object)&255;
Vec h=*(Vec*)AT(0x5cfbe8);
printf("DYNAMIC {\"name\":\"%s\",\"contact\":%d,\"root\":[%.9g,%.9g,%.9g,%.9g],\"face\":%.9g,\"edge\":%.9g,\"hit\":[%.9g,%.9g,%.9g,%.9g],\"last\":%d,\"dynamicCallbacks\":%u,\"staticCallbacks\":%u,\"setters\":%u,\"passes\":%u,\"mode\":%u}\n",
name,hit,sphere_root.x,sphere_root.y,sphere_root.z,sphere_root.w,*(float*)AT(0x695d5c),*(float*)AT(0x5cfbe0),h.x,h.y,h.z,h.w,
*(void**)AT(0x695d4c)==polygon[0],dynamic_callbacks,static_callbacks,setters,*(unsigned*)AT(0x695d78),*(unsigned*)AT(0x695d74));
}
int main(void){
setbuf(stdout,NULL);map_copy();
memcpy(kernel_prefix,AT(0x47bd80),5);hook_jump(AT(0x47bd80),capture_kernel);
reset();query("face_stale_polygon");
reset();*(void**)AT(0x695d4c)=NULL;query("face_no_polygon");
reset();inhibit=1;query("inhibited");
reset();geometry=0;query("geometry_off");
reset();sphere_root.z=200;query("broadphase_reject");
reset();other_mode=2;query("other_box_overlap");
reset();other_mode=2;sphere_root.z=51;query("other_box_reject");
reset();sphere_previous.z=100;sphere_root.z=80;query("no_triangle_hit");
reset();mutate=1;query("callback_root_overwritten");
reset();mutate=inhibit=1;query("inhibited_callback_root_survives");
reset();*(unsigned char*)AT(0x4f69e5)=0;query("static_geometry_off_stale_polygon");
reset();sphere_object[0x42c]=1;query("forced_static_mode");
reset();sphere_root=(Vec){0,45,15,1};sphere_previous=(Vec){0,45,50,1};query("near_top_edge");
reset();box_root.x=100;sphere_root.x=sphere_previous.x=100;query("translated_box");
reset();rotate_box=1;sphere_root=(Vec){15,0,0,1};sphere_previous=(Vec){50,0,0,1};query("rotated_box");
reset();query("chain_first");sphere_previous=sphere_root;sphere_root.z=25;query("chain_away");
printf("KERNEL_TRIANGLES [");
for(unsigned i=0;i<12;i++){printf("%s[",i?",":"");for(unsigned j=0;j<4;j++){Vec v=kernel_arguments[i][j];printf("%s[%.9g,%.9g,%.9g,%.9g]",j?",":"",v.x,v.y,v.z,v.w);}printf("]");}puts("]");
puts("DYNAMIC_CONTEXT_COMPLETE");return 0;
}
+43
View File
@@ -0,0 +1,43 @@
#!/usr/bin/env python3
"""Read-only default Jeep teardown eligibility, distinct from helper retention."""
import argparse,hashlib,json,struct
from pathlib import Path
from checkpoint_script_state import EXE_SHA256,find_case,read_va,rel_call_target
from pe_inspect import PE
SITES=(
('Jeep constructor requests deletion predicate true',0x42129a,'6a01'),
('stored predicate getter',0x470f30,'8a4111c3'),
('stored predicate setter and live dispatch',0x470f47,'884111ff9204020000'),
('live predicate getter',0x4719b0,'8a8139010000c3'),
('live predicate setter',0x4719c4,'888139010000'),
('generic Init stored predicate query',0x4705b3,'ff978c000000'),
('generic Init live predicate restore',0x4705bc,'ff9704020000'),
('teardown first predicate query',0x46e032,'ff9200020000'),
('teardown second predicate query',0x46e06f,'ff9000020000'),
('teardown final predicate query',0x46e0ac,'ff9000020000'),
('teardown deletion flag',0x46e0ca,'c6460601'),
('Jeep UnInitObject bridge',0x4213e0,'e9ab0f0400'),
('generic second cleanup conditional',0x458c50,'8a81b004000084c07408'),
)
def collect(original):
pe=PE(find_case(Path(original),'Neutron.exe'))
if hashlib.sha256(pe.data).hexdigest()!=EXE_SHA256:raise ValueError('Unsupported original')
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))
if rel_call_target(pe,0x4212a8)!=0x470f40:raise ValueError('Jeep constructor predicate target')
bindings=[]
for slot,target in [(0x8c,0x470f30),(0x200,0x4719b0),(0x204,0x4719c0),(0x20,0x4213e0),(0x34,0x458c50)]:
if struct.unpack('<I',read_va(pe,0x4a2aec+slot,4))[0]!=target:raise ValueError('Jeep binding')
bindings.append(dict(table='0x4a2aec',slot=hex(slot),target=hex(target),file_offset=hex(pe.offset(0x4a2aec+slot-pe.base))))
return dict(source_sha256=EXE_SHA256,sites=sites,bindings=bindings,
scope='Default constructor/Init deletion eligibility and re-read boundaries only. Cleanup callbacks, active vehicle mutations, child deletion and complete retained order are not executed here.')
if __name__=='__main__':
cli=argparse.ArgumentParser(description=__doc__);cli.add_argument('original',type=Path)
print(json.dumps(collect(cli.parse_args().original),indent=2))