Replace QuirkChecker.exe with a cross-platform Python port (byte-identical output)#10830
Open
nx-thaddeusaid wants to merge 1 commit intoBattletechModders:masterfrom
Open
Conversation
…rt.py
The 18 MB exe is a Launch4j-wrapped Spring Boot jar
(roguetech-quirk-checker 1.0.0-SNAPSHOT, Java 14, Spring Boot 2.2.6,
built 2020-07-03). I recovered the jar from the exe, decompiled the
three relevant service classes with javap, and re-implemented the
algorithm in Python.
Algorithm (from decompilation):
pass 1: any *.json with Custom.Category[*].CategoryID == "PositiveQuirk"
contributes its Description.Id to the quirks set (134 found)
pass 2: for each chassisdef_*.json not under CustomUnits / \wip\ /
TARGETDUMMY / REP-ME, pass iff FixedEquipment[] is empty or
some entry's ComponentDefID is in the quirks set (7087 checked)
output: sorted list of basename of failing chassis, one per line
Validation:
- counts match exactly between jvm and port (134 quirks, 7087
chassis, 2 missing)
- output is byte-identical against a parse-clean tree — both emit
chassisdef_barghest_BGS-DBG.json and chassisdef_elemental_manticore.json
- original crashes with an uncaught Jackson exception on malformed
JSON (trailing comma / BOM / comments); the port skips per-file
parse failures and continues
Also included:
- model/quickCheckerSample/: 134 quirks + 7088 chassis decisions +
10,000 (chassis, FixedEquipment-entry) pairs for empirical
review of the input->output mapping
- tools/build_quirk_sample.py: regenerates that sample folder
- tools/quirk_check.py: short-name alias entry point
- docs/reference/quirkchecker-evidence.md: jar recovery steps,
bytecode algorithm trace, validation results
The port is cross-platform (Linux / macOS / Windows from source);
the exe was Windows-only.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Core/QuirkChecker/QuirkChecker.exeis an 18 MB Launch4j-wrappedSpring Boot jar (Java 14, built 2020-07-03). This PR replaces it with
tools/quirkchecker_port.py— a Python reimplementation that producesbyte-identical output to the original on a parse-clean tree, runs
on Linux/macOS/Windows from source, and is strictly more robust than
the original.
How I recovered the algorithm
.exe— found it'sMZ/PE32with a Launch4j wrapperstarting at offset 19,522 and a
PK\\x03\\x04zip header atoffset 25,600.
roguetech-quirk-checker 1.0.0-SNAPSHOT,Start-Class: org.redbat.roguetech.quirk.QuirkCheckerApplication,Spring Boot 2.2.6.
javap -p -c.Algorithm (from decompilation)
Input filter (
FileLoadingService.mechFilter)A "mech chassis file" is any
chassisdef*whose absolute pathcontains none of
CustomUnits,\\wip\\,TARGETDUMMY,REP-ME.Pass 1 — discover quirks
For every non-chassis JSON:
Custom/Custom.Categoryis absentCustom.Category[*].CategoryIDequals theconfigured category (default
PositiveQuirk)Description.IdPass 2 — per-chassis check
Output
quirk_checker_result.txt: one failing chassis basename per line,lexicographically sorted (Java
SortedSet).Validation
Counts match exactly
Byte-identical output
diff original.txt port.txtis empty. Both emit:Reference outputs are checked in under
model/quickCheckerSample/tool_output.{txt,reference.txt}.Relational sample (>17k rows)
model/quickCheckerSample/quirks.ndjson— 134 quirksmodel/quickCheckerSample/chassis_decisions.ndjson— 7,088per-chassis decisions with matched quirk ID
model/quickCheckerSample/equipment_pairs.ndjson— 10,000(chassis, FixedEquipment entry) pairs (all 7,085 positive matches +
2,915 sampled negatives)
For any reviewer who wants to reconstruct the input→output mapping
empirically rather than trust the decompilation.
Robustness delta
The original crashes with an uncaught Jackson exception on any JSON
file with a trailing comma, UTF-8 BOM, or JS-style
//comments(fails in
JsonService.loadJsonAsNode). The port per-file catches andcontinues. On a tree containing any malformed JSON, the original
produces no output; the port produces the correct report.
Changes
tools/quirkchecker_port.py— the port.tools/quirk_check.py— short-name alias.tools/build_quirk_sample.py— regenerates the sample.model/quickCheckerSample/— sample + mapping doc.docs/reference/quirkchecker-evidence.md— full evidence.Core/QuirkChecker/QuirkChecker.exe.Core/QuirkChecker/application.properties.Limitations
part of the report contract).
PositiveQuirk; pass--quirk-categoryfor others.
Test plan
python3 tools/quirkchecker_port.py --output-directory /tmp/qcprints
chassis=7088 quirks=134 missing=2and writes aquirk_checker_result.txtidentical tomodel/quickCheckerSample/tool_output.reference.txt.state), the port still produces correct output; the original
.execrashes in Jackson.python3 tools/build_quirk_sample.pyregeneratesmodel/quickCheckerSample/with identical counts.