Skip to content

Repository files navigation

Patchsmith

Auditable binary localization tooling for legacy visual novels.

Patchsmith technical workbench

Patchsmith turns fragile, format-specific patch work into a reproducible pipeline:

  1. probe an unknown resource without modifying it;
  2. extract addressable text records;
  3. apply changes only to an explicitly authorized field or byte range;
  4. validate translation structure and control codes; and
  5. ship a hash-locked byte patch instead of copyrighted game data.

The repository contains no commercial game files, dialogue dumps, screenshots, fonts, music, or proprietary keys. Every bundled fixture is generated from synthetic data.

One-command demo

Requirements: Python 3.10 or later. No third-party packages are required.

python -m patchsmith demo --output demo-output

The demo generates synthetic FPD, EGPACK, and RIO/CRsa files, then performs a complete audited run:

  • identifies the FPD header without attempting extraction;
  • parses a multi-language EGPACK table;
  • patches one exact id / slot / expected_text target;
  • proves a non-target language slot did not change;
  • decrypts and re-encrypts a synthetic CRsa payload;
  • patches one fixed-capacity UTF-16LE slot at a stable offset;
  • creates and reapplies a SHA-256-locked byte patch; and
  • runs translation-control and stable-ID QA.

Run the test suite:

python -m unittest discover -s tests -v
python -m compileall -q patchsmith tests

Three technical pillars

1. FPD and EGPACK

FPD is treated as an outer container and probed read-only. Patchsmith reports the magic, version, file count, and data offset without embedding title-specific keys.

The EGPACK implementation parses the verified 11-field layout by CRC32 field identity. A change is accepted only when all of these match:

relative_path + text_id + language_slot + expected_text

After rebuilding, the file is parsed again. Stale source text, duplicate targets, unknown slots, malformed UTF-8, unsupported layouts, and manual newline insertion fail closed.

2. RIO and CRsa

Patchsmith locates verifiable CRsa encrypted chunks, validates their paired size fields and per-block checksums, and exposes stable coordinates:

filename + block_offset + payload_offset

UTF-16LE replacement is fixed-capacity and offset-locked. The encrypted block must round-trip to the expected size, and the final distributable can be reduced to changed byte ranges with base and output SHA-256 hashes.

3. Translation provenance and QA

Binary correctness is only half of localization correctness. The CSV auditor treats source text, target text, stable IDs, and control sequences as separate evidence. It detects:

  • missing or duplicate stable IDs;
  • empty source or target text;
  • changed control-code sequences; and
  • manual newline tokens that should be left to the engine.

This supports a staged workflow: terminology baseline, translation, independent review, technical QA, and only then binary writeback.

CLI

patchsmith probe FILE [FILE ...]
patchsmith demo [--output DIR]
patchsmith audit translation_rows.csv
patchsmith patch-create BASE OUTPUT PATCH.json
patchsmith patch-apply BASE PATCH.json OUTPUT

Example audit input is available at examples/translation_rows.csv.

Safety model

  • Read-only probing is the default for unknown formats.
  • Original files are never overwritten by the demo or library APIs.
  • Every write requires an exact address and expected source value.
  • Byte patches refuse the wrong base SHA-256 or file size.
  • No fuzzy matching or fallback language slot is used.
  • No commercial resource is needed to run tests or evaluate the project.

OpenAI Build Week

Patchsmith is a clean-room, judgeable developer-tool edition of a longer localization-engineering project. The pre-existing project established format research and real-world failure cases. During the Build Week submission period, the work was meaningfully extended with a new title pipeline, automated asset tests, separated translation/review/technical standards, and this standalone synthetic demonstration.

How Codex and GPT-5.6 were used

Codex sessions running GPT-5.6 inspected the multi-worktree source project, separated reusable format primitives from title-specific data, designed the public/private boundary, and implemented this standalone CLI. GPT-5.6 also helped build synthetic binary fixtures, reason through encrypted-block round trips and fail-closed writeback rules, add success and failure tests, and prepare the reproducible judge workflow. The pre-existing format research remains identified separately below; it is not claimed as Build Week work.

See Build Week provenance for the dated boundary and Judge guide for a two-minute evaluation path.

The system design is documented in Architecture.

Scope and limitations

  • FPD support in this public edition is deliberately a header-only safety probe; encrypted index extraction requires independently authorized title-specific material.
  • RIO/CRsa layouts vary between engine and platform versions. A detected CRsa marker is reported as verified only if decryption, sizes, and checksums all succeed.
  • Patchsmith is preservation and interoperability tooling. It does not bypass ownership checks and does not distribute source assets.

License

Original source code and documentation in this repository are licensed under the MIT License. Third-party games and formats remain the property of their respective owners.

About

Auditable binary localization tooling for legacy visual novels

Topics

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages