# Third-party sources and licensing

## Rust fst

- Project: [`BurntSushi/fst`](https://github.com/BurntSushi/fst).
- Reference release: tag [`0.4.7`](https://github.com/BurntSushi/fst/tree/0.4.7).
- Fixed source revision: [`fbd5992376f176c35af2644d74efad58f5656e5c`](https://github.com/BurntSushi/fst/tree/fbd5992376f176c35af2644d74efad58f5656e5c).
- Copyright: **Copyright (c) 2015 Andrew Gallant**.
- Upstream licensing: MIT OR Unlicense. This port uses the **MIT** option.
- Original terms: [upstream LICENSE-MIT](https://github.com/BurntSushi/fst/blob/fbd5992376f176c35af2644d74efad58f5656e5c/LICENSE-MIT), retained in this repository's [LICENSE](LICENSE) with an additional copyright line for new contributions.

The port adapts these upstream areas:

| Upstream source | Adaptation in this repository |
|---|---|
| `src/raw/build.rs`, `src/raw/registry.rs` | Sorted incremental construction, output factoring and equivalent-node reuse |
| `src/raw/node.rs`, `src/bytes.rs`, `src/raw/common_inputs.rs` | Versioned compact node encoding, packed integers and common-input labels in `codec/` |
| `src/raw/crc32.rs`, `build.rs` | CRC32C polynomial and masked checksum semantics |
| `src/raw/mod.rs`, `src/map.rs`, `src/set.rs` | Immutable graph, set/map and lookup semantics |
| `src/raw/ops.rs` | Ordered multiway set-operation semantics |
| `src/automaton/mod.rs`, `src/automaton/levenshtein.rs` | Automaton composition and bounded edit-distance semantics |

This is a source-level adaptation to MoonBit, not a wrapper linking an upstream
binary. Public APIs, iterative graph validation, optional rank/select indexing,
reversible cursors, explicit DFA construction and finite scalar-class UTF-8
lowering are implemented for this project. The port does not claim to include
the upstream CLI, mmap adapter, regex integration or parallel construction.

## Reference oracle and fixtures

`oracle/Cargo.toml` pins the unmodified crates.io dependency `fst = "=0.4.7"`.
`oracle/Cargo.lock` pins its development-tool dependencies. Those dependencies
retain their own package licenses and are not linked into the MoonBit library.
The oracle source and Python acceptance scripts are development tooling.

Committed `.fst` fixtures are generated by that pinned upstream builder from
the synthetic inputs described in `fixtures/manifest.json`. Expected records
use hexadecimal byte keys and decimal-string u64 values. Generated MoonBit
embeddings are test data; they are not hand-written implementation code and are
excluded from production LOC.

## MoonBit standard library

The runtime imports MoonBit's standard-library UTF-8 and debug facilities and
uses its built-in collections and numeric types. These are toolchain
dependencies, not vendored copies. See the installed toolchain and
[`moonbitlang/core`](https://github.com/moonbitlang/core) for their applicable
license notices. The project's own `LICENSE` does not replace dependency
licenses.

## Real dictionary benchmark data

The optional real-workload benchmark downloads `jieba/dict.txt` from
[`fxsjy/jieba`](https://github.com/fxsjy/jieba) at revision
`67fa2e36e72f69d9134b8a1037b83fbb070b9775`. This dictionary is distributed
under the MIT license, **Copyright (c) 2013 Sun Junyi**. Its original notice
is retained in [benchmarks/corpora/JIEBA-LICENSE.txt](https://github.com/starAndHonor/moonfst/blob/main/benchmarks/corpora/JIEBA-LICENSE.txt).
The pinned digest, transformation and sampling rules are documented in
[benchmarks/corpora/README.md](https://github.com/starAndHonor/moonfst/blob/main/benchmarks/corpora/README.md).
Downloaded data is kept in an ignored development cache and excluded from
the published Mooncakes library. Word frequencies remain unchanged; the
identical duplicate entry is coalesced and POS labels are omitted.

## New contributions

The eight-byte zero-lane test in `packed.mbt` uses the public-domain
`haszero`/`hasvalue` arithmetic pattern documented in Sean Eron Anderson's
[Bit Twiddling Hacks](https://graphics.stanford.edu/~seander/bithacks.html#ZeroInWord).
The MoonBit traversal, tail handling, validation preconditions and differential
tests are project implementations.

New MoonBit code, documentation and development tools in this repository are
provided under MIT, **Copyright (c) 2026 moonfst contributors**. Derived material
continues to retain Andrew Gallant's copyright and the upstream MIT terms.
