Fairy-Stockfish WASM — Engine Host for AI장기
==============================================

This directory contains the GPLv3 Fairy-Stockfish WebAssembly build and the
engine-bridge Worker that loads it. These files are a separate Engine Host
distribution unit from the main AI장기 application.

License
-------
GNU General Public License version 3 (GPLv3).
Full text bundled at ./LICENSE (also https://www.gnu.org/licenses/gpl-3.0.html).

Upstream
--------
- Fairy-Stockfish: https://github.com/fairy-stockfish/Fairy-Stockfish
- WASM port (fairy-stockfish-nnue.wasm): https://github.com/fairy-stockfish/fairy-stockfish.wasm
- npm package: fairy-stockfish-nnue.wasm (version pinned in package.json)

Corresponding Source
--------------------
Unmodified binaries are redistributed from the upstream WASM port / npm package.
Corresponding Source for the Stockfish engine itself is available from the
Upstream URLs above at the package version recorded in the application's
package.json dependency `fairy-stockfish-nnue.wasm`.

For our own GPLv3 code (engine-bridge.js / fairy-uci-worker.js) plus this
NOTICE/LICENSE and the upstream/version pointers above, bundled together in
one download: ./janggi-engine-host-source.zip (same directory). This package
intentionally excludes the main AI장기 application (game logic, UI, economy/
billing, server) — that code is proprietary and outside GPL scope because the
Engine Host runs as a separate Worker/process talking to the app only over a
plain-text UCI protocol.

engine-bridge.js
----------------
GPLv3 Worker that loads stockfish.js, performs NNUE file I/O via the engine FS,
and relays UCI text to the main app. It contains no AI장기 billing/UI logic.

NNUE weights
------------
File: janggi-9991472750de.nnue
Purpose: Janggi evaluation network used via UCI EvalFile (data file).
Source: official Fairy-Stockfish-NNUE release asset, fetched verbatim from
https://github.com/fairy-stockfish/Fairy-Stockfish-NNUE/raw/master/janggi-9991472750de.nnue
(see scripts/ensure-janggi-nnue.mjs). Confirmed (checked 2026-08-20): the
Fairy-Stockfish-NNUE repository carries no per-file license exception —
it ships a single GPLv3 Copying.txt covering the whole repository,
including the NNUE weight files, and its README does not call out any
different terms for them. Distributed here under GPLv3 accordingly.

Integrity
---------
SHA-256 digests for stockfish.js, stockfish.wasm, and the Janggi NNUE file are
recorded in asset-hashes.json. engine-bridge.js verifies these hashes before
loading assets into the Engine Host Worker.

Deployment layout
-----------------
- Default (same origin): served under /engine/ on the main app host.
- Phase 4 (recommended for commercial optics): serve these files from a dedicated
  host (e.g. https://engine.<domain>/) with Cross-Origin-Resource-Policy:
  cross-origin, and set the main app meta tag janggi-engine-host to that origin.
